aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml8
-rw-r--r--README.md5
-rw-r--r--build/build.xml4
-rwxr-xr-xcomposer.pharbin499053 -> 533673 bytes
-rw-r--r--phpBB/adm/style/acp_attachments.html12
-rw-r--r--phpBB/adm/style/acp_ext_details.html97
-rw-r--r--phpBB/adm/style/acp_ext_disable.html34
-rw-r--r--phpBB/adm/style/acp_ext_enable.html34
-rw-r--r--phpBB/adm/style/acp_ext_list.html61
-rw-r--r--phpBB/adm/style/acp_ext_purge.html34
-rw-r--r--phpBB/adm/style/acp_groups.html6
-rw-r--r--phpBB/adm/style/acp_icons.html6
-rw-r--r--phpBB/adm/style/acp_inactive.html6
-rw-r--r--phpBB/adm/style/acp_logs.html6
-rw-r--r--phpBB/adm/style/acp_profile.html4
-rw-r--r--phpBB/adm/style/acp_users.html12
-rw-r--r--phpBB/adm/style/acp_users_feedback.html12
-rw-r--r--phpBB/adm/style/acp_users_overview.html3
-rw-r--r--phpBB/adm/style/acp_users_prefs.html10
-rw-r--r--phpBB/adm/style/admin.css10
-rw-r--r--phpBB/adm/style/install_footer.html2
-rw-r--r--phpBB/adm/style/overall_header.html6
-rw-r--r--phpBB/adm/style/pagination.html12
-rw-r--r--phpBB/adm/style/timezone.js11
-rw-r--r--phpBB/adm/style/timezone_option.html19
-rw-r--r--phpBB/adm/swatch.php4
-rw-r--r--phpBB/assets/javascript/core.js106
-rw-r--r--phpBB/common.php83
-rw-r--r--phpBB/composer.json13
-rw-r--r--phpBB/composer.lock70
-rw-r--r--phpBB/config/.htaccess4
-rw-r--r--phpBB/config/cron_tasks.yml75
-rw-r--r--phpBB/config/services.yml136
-rw-r--r--phpBB/config/tables.yml3
-rw-r--r--phpBB/cron.php4
-rw-r--r--phpBB/develop/create_schema_files.php4
-rw-r--r--phpBB/develop/mysql_upgrader.php3
-rw-r--r--phpBB/develop/repair_bots.php2
-rw-r--r--phpBB/develop/search_fill.php2
-rw-r--r--phpBB/docs/AUTHORS16
-rw-r--r--phpBB/docs/CHANGELOG.html9
-rw-r--r--phpBB/docs/README.html69
-rw-r--r--phpBB/docs/sphinx.sample.conf96
-rw-r--r--phpBB/download/file.php391
-rw-r--r--phpBB/feed.php12
-rw-r--r--phpBB/includes/acp/acp_attachments.php12
-rw-r--r--phpBB/includes/acp/acp_board.php30
-rw-r--r--phpBB/includes/acp/acp_extensions.php303
-rw-r--r--phpBB/includes/acp/acp_forums.php158
-rw-r--r--phpBB/includes/acp/acp_groups.php6
-rw-r--r--phpBB/includes/acp/acp_icons.php6
-rw-r--r--phpBB/includes/acp/acp_inactive.php14
-rw-r--r--phpBB/includes/acp/acp_language.php27
-rw-r--r--phpBB/includes/acp/acp_logs.php6
-rw-r--r--phpBB/includes/acp/acp_permissions.php2
-rw-r--r--phpBB/includes/acp/acp_profile.php6
-rw-r--r--phpBB/includes/acp/acp_reasons.php8
-rw-r--r--phpBB/includes/acp/acp_search.php6
-rw-r--r--phpBB/includes/acp/acp_styles.php8
-rw-r--r--phpBB/includes/acp/acp_users.php81
-rw-r--r--phpBB/includes/acp/auth.php4
-rw-r--r--phpBB/includes/acp/info/acp_extensions.php34
-rw-r--r--phpBB/includes/auth/auth_db.php4
-rw-r--r--phpBB/includes/cache/driver/file.php4
-rw-r--r--phpBB/includes/cache/driver/interface.php2
-rw-r--r--phpBB/includes/cache/driver/memory.php6
-rw-r--r--phpBB/includes/cache/driver/null.php2
-rw-r--r--[-rwxr-xr-x]phpBB/includes/cache/driver/redis.php0
-rw-r--r--phpBB/includes/cache/factory.php42
-rw-r--r--phpBB/includes/cache/service.php11
-rw-r--r--phpBB/includes/constants.php1
-rw-r--r--phpBB/includes/cron/manager.php44
-rw-r--r--phpBB/includes/cron/task/base.php22
-rw-r--r--phpBB/includes/cron/task/core/prune_all_forums.php36
-rw-r--r--phpBB/includes/cron/task/core/prune_forum.php54
-rw-r--r--phpBB/includes/cron/task/core/queue.php27
-rw-r--r--phpBB/includes/cron/task/core/tidy_cache.php24
-rw-r--r--phpBB/includes/cron/task/core/tidy_database.php24
-rw-r--r--phpBB/includes/cron/task/core/tidy_search.php44
-rw-r--r--phpBB/includes/cron/task/core/tidy_sessions.php21
-rw-r--r--phpBB/includes/cron/task/core/tidy_warnings.php27
-rw-r--r--phpBB/includes/cron/task/provider.php43
-rw-r--r--phpBB/includes/cron/task/task.php7
-rw-r--r--phpBB/includes/cron/task/wrapper.php22
-rw-r--r--phpBB/includes/datetime.php158
-rw-r--r--phpBB/includes/db/db_tools.php1
-rw-r--r--phpBB/includes/db/dbal.php35
-rw-r--r--phpBB/includes/db/firebird.php10
-rw-r--r--phpBB/includes/db/mssql.php20
-rw-r--r--phpBB/includes/db/mssql_odbc.php18
-rw-r--r--phpBB/includes/db/mssqlnative.php21
-rw-r--r--phpBB/includes/db/mysql.php20
-rw-r--r--phpBB/includes/db/mysqli.php20
-rw-r--r--phpBB/includes/db/oracle.php12
-rw-r--r--phpBB/includes/db/postgres.php12
-rw-r--r--phpBB/includes/db/sqlite.php12
-rw-r--r--phpBB/includes/di/processor/config.php76
-rw-r--r--phpBB/includes/di/processor/ext.php54
-rw-r--r--phpBB/includes/di/processor/interface.php28
-rw-r--r--phpBB/includes/extension/controller.php25
-rw-r--r--phpBB/includes/extension/exception.php27
-rw-r--r--phpBB/includes/extension/finder.php14
-rw-r--r--phpBB/includes/extension/manager.php30
-rw-r--r--phpBB/includes/extension/metadata_manager.php338
-rw-r--r--phpBB/includes/functions.php486
-rw-r--r--phpBB/includes/functions_acp.php86
-rw-r--r--phpBB/includes/functions_admin.php19
-rw-r--r--phpBB/includes/functions_compress.php41
-rw-r--r--phpBB/includes/functions_content.php120
-rw-r--r--phpBB/includes/functions_convert.php2
-rw-r--r--phpBB/includes/functions_display.php196
-rw-r--r--phpBB/includes/functions_download.php129
-rw-r--r--phpBB/includes/functions_install.php45
-rw-r--r--phpBB/includes/functions_jabber.php8
-rw-r--r--phpBB/includes/functions_posting.php31
-rw-r--r--phpBB/includes/functions_privmsgs.php207
-rw-r--r--phpBB/includes/functions_profile_fields.php51
-rw-r--r--phpBB/includes/functions_upload.php15
-rw-r--r--phpBB/includes/functions_user.php134
-rw-r--r--phpBB/includes/mcp/mcp_forum.php19
-rw-r--r--phpBB/includes/mcp/mcp_front.php2
-rw-r--r--phpBB/includes/mcp/mcp_logs.php6
-rw-r--r--phpBB/includes/mcp/mcp_main.php2
-rw-r--r--phpBB/includes/mcp/mcp_notes.php6
-rw-r--r--phpBB/includes/mcp/mcp_pm_reports.php10
-rw-r--r--phpBB/includes/mcp/mcp_post.php4
-rw-r--r--phpBB/includes/mcp/mcp_queue.php6
-rw-r--r--phpBB/includes/mcp/mcp_reports.php6
-rw-r--r--phpBB/includes/mcp/mcp_topic.php9
-rw-r--r--phpBB/includes/mcp/mcp_warn.php6
-rw-r--r--phpBB/includes/questionnaire/questionnaire.php1
-rw-r--r--phpBB/includes/request/request.php125
-rw-r--r--phpBB/includes/request/type_cast_helper.php22
-rw-r--r--phpBB/includes/search/fulltext_mysql.php232
-rw-r--r--phpBB/includes/search/fulltext_native.php352
-rw-r--r--phpBB/includes/search/fulltext_postgres.php242
-rw-r--r--phpBB/includes/search/fulltext_sphinx.php817
-rw-r--r--phpBB/includes/search/sphinx/config.php288
-rw-r--r--phpBB/includes/search/sphinx/config_comment.php49
-rw-r--r--phpBB/includes/search/sphinx/config_section.php162
-rw-r--r--phpBB/includes/search/sphinx/config_variable.php80
-rw-r--r--phpBB/includes/sphinxapi.php1712
-rw-r--r--phpBB/includes/style/style.php6
-rw-r--r--phpBB/includes/template/filter.php2
-rw-r--r--phpBB/includes/template/template.php19
-rw-r--r--phpBB/includes/ucp/ucp_attachments.php6
-rw-r--r--phpBB/includes/ucp/ucp_groups.php9
-rw-r--r--phpBB/includes/ucp/ucp_main.php21
-rw-r--r--phpBB/includes/ucp/ucp_pm_compose.php2
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewfolder.php14
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewmessage.php32
-rw-r--r--phpBB/includes/ucp/ucp_prefs.php11
-rw-r--r--phpBB/includes/ucp/ucp_profile.php6
-rw-r--r--phpBB/includes/ucp/ucp_register.php23
-rw-r--r--phpBB/includes/ucp/ucp_zebra.php30
-rw-r--r--phpBB/includes/update_helpers.php112
-rw-r--r--phpBB/includes/user.php149
-rw-r--r--phpBB/index.php23
-rw-r--r--phpBB/install/convertors/convert_phpbb20.php2
-rw-r--r--phpBB/install/database_update.php117
-rw-r--r--phpBB/install/index.php33
-rw-r--r--phpBB/install/install_convert.php6
-rw-r--r--phpBB/install/install_install.php12
-rw-r--r--phpBB/install/install_update.php20
-rw-r--r--phpBB/install/schemas/firebird_schema.sql4
-rw-r--r--phpBB/install/schemas/mssql_schema.sql4
-rw-r--r--phpBB/install/schemas/mysql_40_schema.sql4
-rw-r--r--phpBB/install/schemas/mysql_41_schema.sql4
-rw-r--r--phpBB/install/schemas/oracle_schema.sql4
-rw-r--r--phpBB/install/schemas/postgres_schema.sql4
-rw-r--r--phpBB/install/schemas/schema_data.sql8
-rw-r--r--phpBB/install/schemas/sqlite_schema.sql4
-rw-r--r--phpBB/language/en/acp/board.php9
-rw-r--r--phpBB/language/en/acp/common.php4
-rw-r--r--phpBB/language/en/acp/extensions.php103
-rw-r--r--phpBB/language/en/acp/permissions_phpbb.php1
-rw-r--r--phpBB/language/en/acp/profile.php2
-rw-r--r--phpBB/language/en/acp/search.php16
-rw-r--r--phpBB/language/en/acp/users.php2
-rw-r--r--phpBB/language/en/common.php119
-rw-r--r--phpBB/language/en/email/forum_notify.txt2
-rw-r--r--phpBB/language/en/email/newtopic_notify.txt2
-rw-r--r--phpBB/language/en/email/topic_notify.txt2
-rw-r--r--phpBB/language/en/help_faq.php2
-rw-r--r--phpBB/language/en/search.php2
-rw-r--r--phpBB/language/en/ucp.php7
-rw-r--r--phpBB/memberlist.php45
-rw-r--r--phpBB/posting.php47
-rw-r--r--phpBB/search.php35
-rw-r--r--phpBB/styles/prosilver/template/forum_fn.js6
-rw-r--r--phpBB/styles/prosilver/template/forumlist_body.html2
-rw-r--r--phpBB/styles/prosilver/template/login_body.html4
-rw-r--r--phpBB/styles/prosilver/template/mcp_forum.html48
-rw-r--r--phpBB/styles/prosilver/template/mcp_logs.html16
-rw-r--r--phpBB/styles/prosilver/template/mcp_notes_user.html16
-rw-r--r--phpBB/styles/prosilver/template/mcp_queue.html16
-rw-r--r--phpBB/styles/prosilver/template/mcp_reports.html16
-rw-r--r--phpBB/styles/prosilver/template/mcp_topic.html14
-rw-r--r--phpBB/styles/prosilver/template/mcp_warn_list.html29
-rw-r--r--phpBB/styles/prosilver/template/memberlist_body.html18
-rw-r--r--phpBB/styles/prosilver/template/overall_footer.html4
-rw-r--r--phpBB/styles/prosilver/template/overall_header.html8
-rw-r--r--phpBB/styles/prosilver/template/pagination.html15
-rw-r--r--phpBB/styles/prosilver/template/posting_editor.html2
-rw-r--r--phpBB/styles/prosilver/template/posting_smilies.html6
-rw-r--r--phpBB/styles/prosilver/template/search_body.html4
-rw-r--r--phpBB/styles/prosilver/template/search_results.html50
-rw-r--r--phpBB/styles/prosilver/template/simple_header.html4
-rw-r--r--phpBB/styles/prosilver/template/timezone.js19
-rw-r--r--phpBB/styles/prosilver/template/timezone_option.html20
-rw-r--r--phpBB/styles/prosilver/template/ucp_attachments.html16
-rw-r--r--phpBB/styles/prosilver/template/ucp_groups_manage.html6
-rw-r--r--phpBB/styles/prosilver/template/ucp_groups_membership.html2
-rw-r--r--phpBB/styles/prosilver/template/ucp_main_bookmarks.html23
-rw-r--r--phpBB/styles/prosilver/template/ucp_main_front.html15
-rw-r--r--phpBB/styles/prosilver/template/ucp_main_subscribed.html23
-rw-r--r--phpBB/styles/prosilver/template/ucp_pm_message_header.html8
-rw-r--r--phpBB/styles/prosilver/template/ucp_pm_viewfolder.html8
-rw-r--r--phpBB/styles/prosilver/template/ucp_pm_viewmessage.html24
-rw-r--r--phpBB/styles/prosilver/template/ucp_pm_viewmessage_print.html7
-rw-r--r--phpBB/styles/prosilver/template/ucp_prefs_personal.html12
-rw-r--r--phpBB/styles/prosilver/template/ucp_register.html11
-rw-r--r--phpBB/styles/prosilver/template/viewforum_body.html41
-rw-r--r--phpBB/styles/prosilver/template/viewonline_body.html16
-rw-r--r--phpBB/styles/prosilver/template/viewtopic_body.html55
-rw-r--r--phpBB/styles/prosilver/template/viewtopic_print.html2
-rw-r--r--phpBB/styles/prosilver/theme/colours.css23
-rw-r--r--phpBB/styles/prosilver/theme/common.css42
-rw-r--r--phpBB/styles/prosilver/theme/content.css23
-rw-r--r--phpBB/styles/prosilver/theme/cp.css3
-rw-r--r--phpBB/styles/prosilver/theme/forms.css5
-rw-r--r--phpBB/styles/prosilver/theme/links.css9
-rw-r--r--phpBB/styles/prosilver/theme/stylesheet.css2
-rw-r--r--phpBB/styles/subsilver2/template/breadcrumbs.html2
-rw-r--r--phpBB/styles/subsilver2/template/forumlist_body.html2
-rw-r--r--phpBB/styles/subsilver2/template/memberlist_search.html6
-rw-r--r--phpBB/styles/subsilver2/template/overall_header.html10
-rw-r--r--phpBB/styles/subsilver2/template/pagination.html12
-rw-r--r--phpBB/styles/subsilver2/template/posting_smilies.html15
-rw-r--r--phpBB/styles/subsilver2/template/search_results.html13
-rw-r--r--phpBB/styles/subsilver2/template/simple_footer.html2
-rw-r--r--phpBB/styles/subsilver2/template/timezone.js19
-rw-r--r--phpBB/styles/subsilver2/template/timezone_option.html20
-rw-r--r--phpBB/styles/subsilver2/template/ucp_main_bookmarks.html13
-rw-r--r--phpBB/styles/subsilver2/template/ucp_main_subscribed.html13
-rw-r--r--phpBB/styles/subsilver2/template/ucp_pm_viewmessage_print.html2
-rw-r--r--phpBB/styles/subsilver2/template/ucp_prefs_personal.html11
-rw-r--r--phpBB/styles/subsilver2/template/ucp_register.html7
-rw-r--r--phpBB/styles/subsilver2/template/viewforum_body.html26
-rw-r--r--phpBB/styles/subsilver2/template/viewonline_body.html4
-rw-r--r--phpBB/styles/subsilver2/template/viewtopic_print.html2
-rw-r--r--phpBB/styles/subsilver2/theme/stylesheet.css11
-rw-r--r--phpBB/ucp.php12
-rw-r--r--phpBB/viewforum.php36
-rw-r--r--phpBB/viewonline.php49
-rw-r--r--phpBB/viewtopic.php112
-rw-r--r--tests/RUNNING_TESTS.txt21
-rw-r--r--tests/cache/cache_test.php41
-rw-r--r--tests/cache/fixtures/config.xml18
-rw-r--r--tests/compress/archive/.gitkeep0
-rw-r--r--tests/compress/compress_test.php173
-rw-r--r--tests/compress/extract/.gitkeep0
-rw-r--r--tests/compress/fixtures/1.txt1
-rw-r--r--tests/compress/fixtures/archive.tarbin0 -> 10240 bytes
-rw-r--r--tests/compress/fixtures/archive.tar.bz2bin0 -> 224 bytes
-rw-r--r--tests/compress/fixtures/archive.tar.gzbin0 -> 239 bytes
-rw-r--r--tests/compress/fixtures/archive.zipbin0 -> 412 bytes
-rw-r--r--tests/compress/fixtures/dir/2.txt1
-rw-r--r--tests/compress/fixtures/dir/3.txt1
-rw-r--r--tests/compress/fixtures/dir/subdir/4.txt1
-rw-r--r--tests/cron/ext/testext/cron/dummy_task.php5
-rw-r--r--tests/cron/includes/cron/task/core/dummy_task.php5
-rw-r--r--tests/cron/includes/cron/task/core/second_dummy_task.php5
-rw-r--r--tests/cron/manager_test.php32
-rw-r--r--tests/cron/task_provider_test.php37
-rw-r--r--tests/cron/tasks/simple_not_runnable.php5
-rw-r--r--tests/cron/tasks/simple_ready.php5
-rw-r--r--tests/cron/tasks/simple_should_not_run.php5
-rw-r--r--tests/datetime/from_format_test.php57
-rw-r--r--tests/dbal/case_test.php69
-rw-r--r--tests/dbal/concatenate_test.php64
-rw-r--r--tests/dbal/order_lower_test.php2
-rw-r--r--tests/extension/acp.php205
-rw-r--r--tests/extension/ext/foo/composer.json22
-rw-r--r--tests/extension/ext/vendor/moo/composer.json22
-rw-r--r--tests/extension/manager_test.php2
-rw-r--r--tests/extension/metadata_manager_test.php430
-rw-r--r--tests/functional/fileupload_form_test.php41
-rw-r--r--tests/functional/posting_test.php102
-rw-r--r--tests/functions_acp/build_cfg_template_test.php15
-rw-r--r--tests/mock/cache.php2
-rw-r--r--tests/mock/event_dispatcher.php16
-rw-r--r--tests/mock/extension_manager.php2
-rw-r--r--tests/privmsgs/delete_user_pms_test.php102
-rw-r--r--tests/privmsgs/fixtures/delete_user_pms.xml215
-rw-r--r--tests/request/type_cast_helper_test.php20
-rw-r--r--tests/session/append_sid_test.php3
-rw-r--r--tests/test_framework/phpbb_database_connection_odbc_pdo_wrapper.php37
-rw-r--r--tests/test_framework/phpbb_database_test_case.php35
-rw-r--r--tests/test_framework/phpbb_database_test_connection_manager.php110
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php80
-rw-r--r--tests/test_framework/phpbb_test_case_helpers.php112
-rw-r--r--vendor/goutte.pharbin267414 -> 0 bytes
303 files changed, 11616 insertions, 2041 deletions
diff --git a/.travis.yml b/.travis.yml
index 20c0c6bf4f..f296f10230 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,14 +9,14 @@ env:
- DB=postgres
before_script:
- - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS phpbb_tests;' -U postgres; fi"
- - sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'create database phpbb_tests;' -U postgres; fi"
+ - sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'DROP DATABASE IF EXISTS phpbb_tests;' -U postgres; fi"
+ - sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'create database phpbb_tests;' -U postgres; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS phpbb_tests;'; fi"
+ - pyrus set auto_discover 1
- pyrus install --force phpunit/DbUnit
- phpenv rehash
- cd phpBB
- - curl -s http://getcomposer.org/installer | php
- - php composer.phar install
+ - php ../composer.phar install --dev
- cd ../
script:
diff --git a/README.md b/README.md
index a7feb8db40..78aa306bed 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-[![phpBB](http://www.phpbb.com/theme/images/logos/blue/160x52.png)](http://www.phpbb.com)
+[![phpBB](https://www.phpbb.com/theme/images/logos/blue/160x52.png)](http://www.phpbb.com)
## ABOUT
@@ -13,8 +13,7 @@ Find support and lots more on [phpBB.com](http://www.phpbb.com)! Discuss the dev
To be able to run an installation from the repo (and not from a pre-built package) you need to run the following commands to install phpBB's dependencies.
cd phpBB
- curl -s http://getcomposer.org/installer | php
- php composer.phar install
+ php ../composer.phar install --dev
## CONTRIBUTE
diff --git a/build/build.xml b/build/build.xml
index 1b8d42a660..28dd36bea8 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -2,9 +2,9 @@
<project name="phpBB" description="The phpBB forum software" default="all" basedir="../">
<!-- a few settings for the build -->
- <property name="newversion" value="3.0.11-RC1" />
+ <property name="newversion" value="3.0.11" />
<property name="prevversion" value="3.0.10" />
- <property name="olderversions" value="3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.0.7-PL1, 3.0.8, 3.0.9" />
+ <property name="olderversions" value="3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.0.7-PL1, 3.0.8, 3.0.9, 3.0.11-RC1, 3.0.11-RC2" />
<!-- no configuration should be needed beyond this point -->
<property name="oldversions" value="${olderversions}, ${prevversion}" />
diff --git a/composer.phar b/composer.phar
index 3572477546..8b6eddbf21 100755
--- a/composer.phar
+++ b/composer.phar
Binary files differ
diff --git a/phpBB/adm/style/acp_attachments.html b/phpBB/adm/style/acp_attachments.html
index c2f8b34792..bdec9eb3cb 100644
--- a/phpBB/adm/style/acp_attachments.html
+++ b/phpBB/adm/style/acp_attachments.html
@@ -378,11 +378,17 @@
<fieldset class="tabulated">
<legend>{L_TITLE}</legend>
- <!-- IF PAGINATION or TOTAL_FILES -->
<div class="pagination">
- {L_NUMBER_FILES}: {TOTAL_FILES} &bull; {L_TOTAL_SIZE}: {TOTAL_SIZE}<!-- IF S_ON_PAGE --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{S_ON_PAGE}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {S_ON_PAGE}<!-- ENDIF --><!-- ENDIF -->
- </div>
+ <!-- IF .pagination or TOTAL_FILES -->
+ {L_NUMBER_FILES}: {TOTAL_FILES} &bull; {L_TOTAL_SIZE}: {TOTAL_SIZE}
+ <!-- IF .pagination -->
+ &bull;
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {S_ON_PAGE}
+ <!-- ENDIF -->
<!-- ENDIF -->
+ </div>
<table cellspacing="1">
<thead>
diff --git a/phpBB/adm/style/acp_ext_details.html b/phpBB/adm/style/acp_ext_details.html
new file mode 100644
index 0000000000..e7532691ad
--- /dev/null
+++ b/phpBB/adm/style/acp_ext_details.html
@@ -0,0 +1,97 @@
+<!-- INCLUDE overall_header.html -->
+
+<a name="maincontent"></a>
+
+ <a href="{U_BACK}" style="float: {S_CONTENT_FLOW_END};">&laquo; {L_BACK}</a>
+
+ <h1>{L_EXTENSIONS_ADMIN}</h1>
+
+ <fieldset>
+ <legend>{L_EXT_DETAILS}</legend>
+ <!-- IF META_DISPLAY_NAME -->
+ <dl>
+ <dt><label for="meta_display_name">{L_DISPLAY_NAME}:</label></dt>
+ <dd><strong id="meta_display_name">{META_DISPLAY_NAME}</strong></dd>
+ </dl>
+ <!-- ENDIF -->
+ <dl>
+ <dt><label for="meta_name">{L_CLEAN_NAME}:</label></dt>
+ <dd><strong id="meta_name">{META_NAME}</strong></dd>
+ </dl>
+ <!-- IF META_DESCRIPTION -->
+ <dl>
+ <dt><label for="meta_description">{L_DESCRIPTION}:</label></dt>
+ <dd><p id="meta_description">{META_DESCRIPTION}</p></dd>
+ </dl>
+ <!-- ENDIF -->
+ <dl>
+ <dt><label for="meta_version">{L_VERSION}:</label></dt>
+ <dd><p id="meta_version">{META_VERSION}</p></dd>
+ </dl>
+ <!-- IF META_HOMEPAGE -->
+ <dl>
+ <dt><label for="meta_homepage">{L_HOMEPAGE}:</label></dt>
+ <dd><p id="meta_homepage">{META_HOMEPAGE}</p></dd>
+ </dl>
+ <!-- ENDIF -->
+ <!-- IF META_TIME -->
+ <dl>
+ <dt><label for="meta_time">{L_TIME}:</label></dt>
+ <dd><p id="meta_time">{META_TIME}</p></dd>
+ </dl>
+ <!-- ENDIF -->
+ <dl>
+ <dt><label for="meta_license">{L_LICENCE}:</label></dt>
+ <dd><p id="meta_license">{META_LICENCE}</p></dd>
+ </dl>
+ </fieldset>
+
+ <!-- IF META_REQUIRE_PHPBB || META_REQUIRE_PHP -->
+ <fieldset>
+ <legend>{L_REQUIREMENTS}</legend>
+ <!-- IF META_REQUIRE_PHPBB -->
+ <dl<!-- IF META_REQUIRE_PHPBB_FAIL --> class="requirements_not_met"<!-- ENDIF -->>
+ <dt><label for="require_phpbb">{L_PHPBB_VERSION}:</label></dt>
+ <dd><p id="require_phpbb">{META_REQUIRE_PHPBB}</p></dd>
+ </dl>
+ <!-- ENDIF -->
+ <!-- IF META_REQUIRE_PHP -->
+ <dl<!-- IF META_REQUIRE_PHP_FAIL --> class="requirements_not_met"<!-- ENDIF -->>
+ <dt><label for="require_php">{L_PHP_VERSION}:</label></dt>
+ <dd><p id="require_php">{META_REQUIRE_PHP}</p></dd>
+ </dl>
+ <!-- ENDIF -->
+ </fieldset>
+ <!-- ENDIF -->
+
+ <fieldset>
+ <legend>{L_AUTHOR_INFORMATION}</legend>
+ <!-- BEGIN meta_authors -->
+ <fieldset>
+ <dl>
+ <dt><label for="meta_author_name">{L_AUTHOR_NAME}:</label></dt>
+ <dd><strong id="meta_author_name">{meta_authors.AUTHOR_NAME}</strong></dd>
+ </dl>
+ <!-- IF meta_authors.AUTHOR_EMAIL -->
+ <dl>
+ <dt><label for="meta_author_email">{L_AUTHOR_EMAIL}:</label></dt>
+ <dd><strong id="meta_author_email"><a href="mailto:{meta_authors.AUTHOR_EMAIL}">{meta_authors.AUTHOR_EMAIL}</a></strong></dd>
+ </dl>
+ <!-- ENDIF -->
+ <!-- IF meta_authors.AUTHOR_HOMEPAGE -->
+ <dl>
+ <dt><label for="meta_author_url">{L_AUTHOR_HOMEPAGE}:</label></dt>
+ <dd><strong id="meta_author_url"><a href="{meta_authors.AUTHOR_HOMEPAGE}">{meta_authors.AUTHOR_HOMEPAGE}</a></strong></dd>
+ </dl>
+ <!-- ENDIF -->
+ <!-- IF meta_authors.AUTHOR_ROLE -->
+ <dl>
+ <dt><label for="author_role">{L_AUTHOR_ROLE}:</label></dt>
+ <dd><strong id="meta_author_role">{meta_authors.AUTHOR_ROLE}</strong></dd>
+ </dl>
+ <!-- ENDIF -->
+ </fieldset>
+ <!-- END meta_authors -->
+ </fieldset>
+
+<!-- INCLUDE overall_footer.html -->
diff --git a/phpBB/adm/style/acp_ext_disable.html b/phpBB/adm/style/acp_ext_disable.html
new file mode 100644
index 0000000000..7dc3f6ec97
--- /dev/null
+++ b/phpBB/adm/style/acp_ext_disable.html
@@ -0,0 +1,34 @@
+<!-- INCLUDE overall_header.html -->
+
+ <a name="maincontent"></a>
+
+ <h1>{L_EXTENSIONS_ADMIN}</h1>
+
+ <p>{L_EXTENSIONS_EXPLAIN}</p>
+ <p>{L_DISABLE_EXPLAIN}</p>
+
+ <!-- IF PRE -->
+ <div class="errorbox">
+ <p>{L_DISABLE_CONFIRM}</p>
+ </div>
+
+ <form id="acp_extensions" method="post" action="{U_DISABLE}">
+ <fieldset class="submit-buttons">
+ <legend>{L_DISABLE}</legend>
+ <input class="button1" type="submit" name="disable" value="{L_DISABLE}" />
+ <input class="button2" type="submit" name="cancel" value="{L_CANCEL}" />
+ </fieldset>
+ </form>
+ <!-- ELSEIF S_NEXT_STEP -->
+ <div class="errorbox">
+ <p>{L_DISABLE_IN_PROGRESS}</p>
+ </div>
+ <!-- ELSE -->
+ <div class="successbox">
+ <p>{L_DISABLE_SUCCESS}</p>
+ <br />
+ <p><a href="{U_RETURN}">{L_RETURN}</a></p>
+ </div>
+ <!-- ENDIF -->
+
+<!-- INCLUDE overall_footer.html -->
diff --git a/phpBB/adm/style/acp_ext_enable.html b/phpBB/adm/style/acp_ext_enable.html
new file mode 100644
index 0000000000..3f7be2c847
--- /dev/null
+++ b/phpBB/adm/style/acp_ext_enable.html
@@ -0,0 +1,34 @@
+<!-- INCLUDE overall_header.html -->
+
+ <a name="maincontent"></a>
+
+ <h1>{L_EXTENSIONS_ADMIN}</h1>
+
+ <p>{L_EXTENSIONS_EXPLAIN}</p>
+ <p>{L_ENABLE_EXPLAIN}</p>
+
+ <!-- IF PRE -->
+ <div class="errorbox">
+ <p>{L_ENABLE_CONFIRM}</p>
+ </div>
+
+ <form id="acp_extensions" method="post" action="{U_ENABLE}">
+ <fieldset class="submit-buttons">
+ <legend>{L_ENABLE}</legend>
+ <input class="button1" type="submit" name="enable" value="{L_ENABLE}" />
+ <input class="button2" type="submit" name="cancel" value="{L_CANCEL}" />
+ </fieldset>
+ </form>
+ <!-- ELSEIF S_NEXT_STEP -->
+ <div class="errorbox">
+ <p>{L_ENABLE_IN_PROGRESS}</p>
+ </div>
+ <!-- ELSE -->
+ <div class="successbox">
+ <p>{L_ENABLE_SUCCESS}</p>
+ <br />
+ <p><a href="{U_RETURN}">{L_RETURN}</a></p>
+ </div>
+ <!-- ENDIF -->
+
+<!-- INCLUDE overall_footer.html -->
diff --git a/phpBB/adm/style/acp_ext_list.html b/phpBB/adm/style/acp_ext_list.html
new file mode 100644
index 0000000000..53de0b4d12
--- /dev/null
+++ b/phpBB/adm/style/acp_ext_list.html
@@ -0,0 +1,61 @@
+<!-- INCLUDE overall_header.html -->
+
+<a name="maincontent"></a>
+
+ <h1>{L_EXTENSIONS_ADMIN}</h1>
+
+ <p>{L_EXTENSIONS_EXPLAIN}</p>
+
+ <table cellspacing="1">
+ <col class="row1" ><col class="row2" ><col class="row2" >
+ <thead>
+ <tr>
+ <th>{L_EXTENSION_NAME}</th>
+ <th>{L_EXTENSION_OPTIONS}</th>
+ <th>{L_EXTENSION_ACTIONS}</th>
+ </tr>
+ </thead>
+ <tbody>
+ <!-- IF .enabled -->
+ <tr>
+ <td class="row3" colspan="3">
+ <strong>{L_ENABLED} {L_EXTENSIONS}</strong>
+ </td>
+ </tr>
+ <!-- BEGIN enabled -->
+ <tr class="ext_enabled">
+ <td><strong>{enabled.META_DISPLAY_NAME}</strong></a></td>
+ <td style="text-align: center;"><a href="{enabled.U_DETAILS}">{L_DETAILS}</a></td>
+ <td style="text-align: center;">
+ <!-- BEGIN actions -->
+ <a href="{enabled.actions.U_ACTION}" alt="{enabled.actions.L_ACTION}">{enabled.actions.L_ACTION}</a>
+ <!-- IF not enabled.actions.S_LAST_ROW -->&nbsp;|&nbsp;<!-- ENDIF -->
+ <!-- END actions -->
+ </td>
+ </tr>
+ <!-- END enabled -->
+ <!-- ENDIF -->
+
+ <!-- IF .disabled -->
+ <tr>
+ <td class="row3" colspan="3"><strong>{L_DISABLED} {L_EXTENSIONS}</strong></td>
+ </tr>
+ <!-- BEGIN disabled -->
+ <tr class="ext_disabled">
+ <td><strong>{disabled.META_DISPLAY_NAME}</strong></a></td>
+ <td style="text-align: center;">
+ <!-- IF disabled.U_DETAILS --><a href="{disabled.U_DETAILS}">{L_DETAILS}</a><!-- ENDIF -->
+ </td>
+ <td style="text-align: center;">
+ <!-- BEGIN actions -->
+ <a href="{disabled.actions.U_ACTION}" alt="{disabled.actions.L_ACTION}">{disabled.actions.L_ACTION}</a>
+ <!-- IF not disabled.actions.S_LAST_ROW -->&nbsp;|&nbsp;<!-- ENDIF -->
+ <!-- END actions -->
+ </td>
+ </tr>
+ <!-- END disabled -->
+ <!-- ENDIF -->
+ </tbody>
+ </table>
+
+<!-- INCLUDE overall_footer.html -->
diff --git a/phpBB/adm/style/acp_ext_purge.html b/phpBB/adm/style/acp_ext_purge.html
new file mode 100644
index 0000000000..00a58721cb
--- /dev/null
+++ b/phpBB/adm/style/acp_ext_purge.html
@@ -0,0 +1,34 @@
+<!-- INCLUDE overall_header.html -->
+
+ <a name="maincontent"></a>
+
+ <h1>{L_EXTENSIONS_ADMIN}</h1>
+
+ <p>{L_EXTENSIONS_EXPLAIN}</p>
+ <p>{L_PURGE_EXPLAIN}</p>
+
+ <!-- IF PRE -->
+ <div class="errorbox">
+ <p>{L_PURGE_CONFIRM}</p>
+ </div>
+
+ <form id="acp_extensions" method="post" action="{U_PURGE}">
+ <fieldset class="submit-buttons">
+ <legend>{L_PURGE}</legend>
+ <input class="button1" type="submit" name="purge" value="{L_PURGE}" />
+ <input class="button2" type="submit" name="cancel" value="{L_CANCEL}" />
+ </fieldset>
+ </form>
+ <!-- ELSEIF S_NEXT_STEP -->
+ <div class="errorbox">
+ <p>{L_PURGE_IN_PROGRESS}</p>
+ </div>
+ <!-- ELSE -->
+ <div class="successbox">
+ <p>{L_PURGE_SUCCESS}</p>
+ <br />
+ <p><a href="{U_RETURN}">{L_RETURN}</a></p>
+ </div>
+ <!-- ENDIF -->
+
+<!-- INCLUDE overall_footer.html -->
diff --git a/phpBB/adm/style/acp_groups.html b/phpBB/adm/style/acp_groups.html
index ed94fa985e..6e52880131 100644
--- a/phpBB/adm/style/acp_groups.html
+++ b/phpBB/adm/style/acp_groups.html
@@ -239,11 +239,11 @@
<!-- END member -->
</tbody>
</table>
- <!-- IF PAGINATION -->
<div class="pagination">
- <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{S_ON_PAGE}</a> &bull; <span>{PAGINATION}</span>
- </div>
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
<!-- ENDIF -->
+ </div>
<fieldset class="quick">
<select name="action"><option class="sep" value="">{L_SELECT_OPTION}</option>{S_ACTION_OPTIONS}</select>
diff --git a/phpBB/adm/style/acp_icons.html b/phpBB/adm/style/acp_icons.html
index a8864d42f7..b9af20d5a2 100644
--- a/phpBB/adm/style/acp_icons.html
+++ b/phpBB/adm/style/acp_icons.html
@@ -255,7 +255,11 @@
<!-- END items -->
</tbody>
</table>
- <div>{PAGINATION}</div>
+ <div class="pagination">
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ENDIF -->
+ </div>
<p class="quick">
<input class="button2" name="add" type="submit" value="{L_ICON_ADD}" />&nbsp; &nbsp;<input class="button2" type="submit" name="edit" value="{L_ICON_EDIT}" />
</p>
diff --git a/phpBB/adm/style/acp_inactive.html b/phpBB/adm/style/acp_inactive.html
index 0889eaf400..ad5871f291 100644
--- a/phpBB/adm/style/acp_inactive.html
+++ b/phpBB/adm/style/acp_inactive.html
@@ -10,11 +10,11 @@
<div class="clearfix"></div>
-<!-- IF PAGINATION -->
<div class="pagination">
- <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{S_ON_PAGE}</a> &bull; <span>{PAGINATION}</span>
-</div>
+<!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
<!-- ENDIF -->
+</div>
<table cellspacing="1">
<thead>
diff --git a/phpBB/adm/style/acp_logs.html b/phpBB/adm/style/acp_logs.html
index f1c770d33b..16638a5a72 100644
--- a/phpBB/adm/style/acp_logs.html
+++ b/phpBB/adm/style/acp_logs.html
@@ -12,11 +12,11 @@
{L_SEARCH_KEYWORDS}: <input type="text" name="keywords" value="{S_KEYWORDS}" />&nbsp;<input type="submit" class="button2" name="filter" value="{L_SEARCH}" />
</fieldset>
-<!-- IF PAGINATION -->
<div class="pagination" style="float: right; margin: 15px 0 2px 0">
- <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{S_ON_PAGE}</a> &bull; <span>{PAGINATION}</span>
-</div>
+<!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
<!-- ENDIF -->
+</div>
<div class="clearfix">&nbsp;</div>
<div><br style="clear: both;" /></div>
diff --git a/phpBB/adm/style/acp_profile.html b/phpBB/adm/style/acp_profile.html
index 4a6df768a8..5be69aa20b 100644
--- a/phpBB/adm/style/acp_profile.html
+++ b/phpBB/adm/style/acp_profile.html
@@ -68,6 +68,10 @@
<dd><input type="checkbox" class="radio" id="field_required" name="field_required" value="1"<!-- IF S_FIELD_REQUIRED --> checked="checked"<!-- ENDIF --> /></dd>
</dl>
<dl>
+ <dt><label for="field_show_novalue">{L_SHOW_NOVALUE_FIELD}:</label><br /><span>{L_SHOW_NOVALUE_FIELD_EXPLAIN}</span></dt>
+ <dd><input type="checkbox" class="radio" id="field_show_novalue" name="field_show_novalue" value="1"<!-- IF S_FIELD_SHOW_NOVALUE --> checked="checked"<!-- ENDIF --> /></dd>
+ </dl>
+ <dl>
<dt><label for="field_hide">{L_HIDE_PROFILE_FIELD}:</label><br /><span>{L_HIDE_PROFILE_FIELD_EXPLAIN}</span></dt>
<dd><input type="checkbox" class="radio" id="field_hide" name="field_hide" value="1"<!-- IF S_FIELD_HIDE --> checked="checked"<!-- ENDIF --> /></dd>
</dl>
diff --git a/phpBB/adm/style/acp_users.html b/phpBB/adm/style/acp_users.html
index a8794176a9..837629255b 100644
--- a/phpBB/adm/style/acp_users.html
+++ b/phpBB/adm/style/acp_users.html
@@ -157,11 +157,11 @@
<form id="user_attachments" method="post" action="{U_ACTION}">
- <!-- IF PAGINATION -->
<div class="pagination">
- <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{S_ON_PAGE}</a> &bull; <span>{PAGINATION}</span>
- </div>
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
<!-- ENDIF -->
+ </div>
<!-- IF .attach -->
<table cellspacing="1">
@@ -196,11 +196,11 @@
<input class="button2" type="submit" value="{L_GO}" name="sort" />
</fieldset>
<hr />
- <!-- IF PAGINATION -->
<div class="pagination">
- <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{S_ON_PAGE}</a> &bull; <span>{PAGINATION}</span>
- </div>
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
<!-- ENDIF -->
+ </div>
<fieldset class="quick">
<input class="button2" type="submit" name="delmarked" value="{L_DELETE_MARKED}" />
diff --git a/phpBB/adm/style/acp_users_feedback.html b/phpBB/adm/style/acp_users_feedback.html
index aa92353807..1dad7f1927 100644
--- a/phpBB/adm/style/acp_users_feedback.html
+++ b/phpBB/adm/style/acp_users_feedback.html
@@ -1,10 +1,10 @@
<form id="list" method="post" action="{U_ACTION}">
- <!-- IF PAGINATION -->
<div class="pagination">
- <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{S_ON_PAGE}</a> &bull; <span>{PAGINATION}</span>
- </div>
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
<!-- ENDIF -->
+ </div>
<!-- IF .log -->
<table cellspacing="1">
@@ -44,11 +44,11 @@
<input class="button2" type="submit" value="{L_GO}" name="sort" />
</fieldset>
<hr />
- <!-- IF PAGINATION -->
<div class="pagination">
- <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{S_ON_PAGE}</a> &bull; <span>{PAGINATION}</span>
- </div>
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
<!-- ENDIF -->
+ </div>
<!-- IF S_CLEARLOGS -->
<fieldset class="quick">
diff --git a/phpBB/adm/style/acp_users_overview.html b/phpBB/adm/style/acp_users_overview.html
index ffdb4d472c..5c5fa010f4 100644
--- a/phpBB/adm/style/acp_users_overview.html
+++ b/phpBB/adm/style/acp_users_overview.html
@@ -138,10 +138,11 @@
<dt><label for="delete_type">{L_DELETE_USER}:</label><br /><span>{L_DELETE_USER_EXPLAIN}</span></dt>
<dd>
<!-- IF USER_HAS_POSTS -->
- <select id="delete_type" name="delete_type"><option class="sep" value="">{L_SELECT_OPTION}</option><option value="retain">{L_RETAIN_POSTS}</option><option value="remove">{L_DELETE_POSTS}</option></select></dd>
+ <select id="delete_type" name="delete_type"><option class="sep" value="">{L_SELECT_OPTION}</option><option value="retain">{L_RETAIN_POSTS}</option><option value="remove">{L_DELETE_POSTS}</option></select>
<!-- ELSE -->
{L_USER_NO_POSTS_TO_DELETE}<input type="hidden" id="delete_type" name="delete_type" value="retain" />
<!-- ENDIF -->
+ </dd>
</dl>
<p class="quick">
<input class="button1" type="submit" name="update" value="{L_SUBMIT}" />
diff --git a/phpBB/adm/style/acp_users_prefs.html b/phpBB/adm/style/acp_users_prefs.html
index a519447b2f..9439f0cf03 100644
--- a/phpBB/adm/style/acp_users_prefs.html
+++ b/phpBB/adm/style/acp_users_prefs.html
@@ -52,15 +52,7 @@
<dt><label for="style">{L_BOARD_STYLE}:</label></dt>
<dd><select id="style" name="style">{S_STYLE_OPTIONS}</select></dd>
</dl>
- <dl>
- <dt><label for="tz">{L_BOARD_TIMEZONE}:</label></dt>
- <dd><select id="tz" name="tz" style="width: 100%;">{S_TZ_OPTIONS}</select></dd>
- </dl>
- <dl>
- <dt><label for="dst">{L_BOARD_DST}:</label></dt>
- <dd><label><input type="radio" class="radio" name="dst" value="1"<!-- IF DST --> id="dst" checked="checked"<!-- ENDIF --> /> {L_YES}</label>
- <label><input type="radio" class="radio" name="dst" value="0"<!-- IF not DST --> id="dst" checked="checked"<!-- ENDIF --> /> {L_NO}</label></dd>
- </dl>
+ <!-- INCLUDE timezone_option.html -->
<dl>
<dt><label for="dateoptions">{L_BOARD_DATE_FORMAT}:</label><br /><span>{L_BOARD_DATE_FORMAT_EXPLAIN}</span></dt>
<dd><select name="dateoptions" id="dateoptions" onchange="if(this.value=='custom'){dE('custom_date',1);}else{dE('custom_date',-1);} if (this.value == 'custom') { document.getElementById('dateformat').value = default_dateformat; } else { document.getElementById('dateformat').value = this.value; }">{S_DATEFORMAT_OPTIONS}</select></dd>
diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css
index 08613de0dd..585707600d 100644
--- a/phpBB/adm/style/admin.css
+++ b/phpBB/adm/style/admin.css
@@ -1718,3 +1718,13 @@ fieldset.permissions .padding {
.phpinfo td, .phpinfo th, .phpinfo h2, .phpinfo h1 {
text-align: left;
}
+
+.requirements_not_met {
+ padding: 5px;
+ background-color: #BC2A4D;
+}
+
+.requirements_not_met dt label, .requirements_not_met dd p {
+ color: #FFFFFF;
+ font-size: 1.4em;
+} \ No newline at end of file
diff --git a/phpBB/adm/style/install_footer.html b/phpBB/adm/style/install_footer.html
index a3b2294025..73c3f5a6b9 100644
--- a/phpBB/adm/style/install_footer.html
+++ b/phpBB/adm/style/install_footer.html
@@ -8,7 +8,7 @@
</div>
<div id="page-footer">
- Powered by <a href="http://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group
+ Powered by <a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group
</div>
</div>
diff --git a/phpBB/adm/style/overall_header.html b/phpBB/adm/style/overall_header.html
index f79c0318b5..f6d0e1025f 100644
--- a/phpBB/adm/style/overall_header.html
+++ b/phpBB/adm/style/overall_header.html
@@ -62,11 +62,7 @@ function dE(n, s, type)
*/
function marklist(id, name, state)
{
- var parent = document.getElementById(id);
- if (!parent)
- {
- eval('parent = document.' + id);
- }
+ var parent = document.getElementById(id) || document[id];
if (!parent)
{
diff --git a/phpBB/adm/style/pagination.html b/phpBB/adm/style/pagination.html
new file mode 100644
index 0000000000..d62d0b6a81
--- /dev/null
+++ b/phpBB/adm/style/pagination.html
@@ -0,0 +1,12 @@
+
+ <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{S_ON_PAGE}</a> &bull;
+ <ul>
+ <!-- BEGIN pagination -->
+ <!-- IF pagination.S_IS_PREV --><li><a href="{pagination.PAGE_URL}">{L_PREVIOUS}</a></li>
+ <!-- ELSEIF pagination.S_IS_CURRENT --><li class="active"><span>{pagination.PAGE_NUMBER}</span></li>
+ <!-- ELSEIF pagination.S_IS_ELLIPSIS --><li class="ellipsis"><span>{L_ELLIPSIS}</span></li>
+ <!-- ELSEIF pagination.S_IS_NEXT --><li><a href="{pagination.PAGE_URL}">{L_NEXT}</a></li>
+ <!-- ELSE --><li><a href="{pagination.PAGE_URL}">{pagination.PAGE_NUMBER}</a></li>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+ </ul>
diff --git a/phpBB/adm/style/timezone.js b/phpBB/adm/style/timezone.js
new file mode 100644
index 0000000000..4556ea5f94
--- /dev/null
+++ b/phpBB/adm/style/timezone.js
@@ -0,0 +1,11 @@
+(function($) { // Avoid conflicts with other libraries
+
+$('#tz_date').change(function() {
+ phpbb.timezone_switch_date(false);
+});
+
+$(document).ready(
+ phpbb.timezone_enable_date_selection
+);
+
+})(jQuery); // Avoid conflicts with other libraries
diff --git a/phpBB/adm/style/timezone_option.html b/phpBB/adm/style/timezone_option.html
new file mode 100644
index 0000000000..23c0ee19e9
--- /dev/null
+++ b/phpBB/adm/style/timezone_option.html
@@ -0,0 +1,19 @@
+<dl>
+ <dt><label for="timezone">{L_BOARD_TIMEZONE}:</label></dt>
+ <!-- IF S_TZ_DATE_OPTIONS -->
+ <dd id="tz_select_date" style="display: none;">
+ <select name="tz_date" id="tz_date" class="autowidth tz_select">
+ <option value="">{L_SELECT_CURRENT_TIME}</option>
+ {S_TZ_DATE_OPTIONS}
+ </select>
+ </dd>
+ <!-- ENDIF -->
+ <dd>
+ <select name="tz" id="timezone" class="autowidth tz_select">
+ <option value="">{L_SELECT_TIMEZONE}</option>
+ {S_TZ_OPTIONS}
+ </select>
+
+ <!-- INCLUDEJS timezone.js -->
+ </dd>
+</dl>
diff --git a/phpBB/adm/swatch.php b/phpBB/adm/swatch.php
index 434b00e542..86498a255f 100644
--- a/phpBB/adm/swatch.php
+++ b/phpBB/adm/swatch.php
@@ -21,8 +21,10 @@ $user->session_begin(false);
$auth->acl($user->data);
$user->setup();
+$phpbb_admin_path = (defined('PHPBB_ADMIN_PATH')) ? PHPBB_ADMIN_PATH : './';
+
// Set custom template for admin area
-$template->set_custom_template($phpbb_root_path . 'adm/style', 'admin');
+$phpbb_style->set_custom_style('admin', $phpbb_admin_path . 'style', '');
$template->set_filenames(array(
'body' => 'colour_swatch.html')
diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js
index 6b1b08c424..f7d6688f68 100644
--- a/phpBB/assets/javascript/core.js
+++ b/phpBB/assets/javascript/core.js
@@ -411,6 +411,112 @@ phpbb.ajaxify = function(options) {
return this;
}
+/**
+* Hide the optgroups that are not the selected timezone
+*
+* @param bool keep_selection Shall we keep the value selected, or shall the user be forced to repick one.
+*/
+phpbb.timezone_switch_date = function(keep_selection) {
+ if ($('#timezone_copy').length == 0) {
+ // We make a backup of the original dropdown, so we can remove optgroups
+ // instead of setting display to none, because IE and chrome will not
+ // hide options inside of optgroups and selects via css
+ $('#timezone').clone().attr('id', 'timezone_copy').css('display', 'none').attr('name', 'tz_copy').insertAfter('#timezone');
+ } else {
+ // Copy the content of our backup, so we can remove all unneeded options
+ $('#timezone').replaceWith($('#timezone_copy').clone().attr('id', 'timezone').css('display', 'block').attr('name', 'tz'));
+ }
+
+ if ($('#tz_date').val() != '') {
+ $('#timezone > optgroup').remove(":not([label='" + $('#tz_date').val() + "'])");
+ }
+
+ if ($('#tz_date').val() == $('#tz_select_date_suggest').attr('data-suggested-tz')) {
+ $('#tz_select_date_suggest').css('display', 'none');
+ } else {
+ $('#tz_select_date_suggest').css('display', 'inline');
+ }
+
+ if ($("#timezone > optgroup[label='" + $('#tz_date').val() + "'] > option").size() == 1) {
+ // If there is only one timezone for the selected date, we just select that automatically.
+ $("#timezone > optgroup[label='" + $('#tz_date').val() + "'] > option:first").attr('selected', true);
+ keep_selection = true;
+ }
+
+ if (typeof keep_selection !== 'undefined' && !keep_selection) {
+ $('#timezone > option:first').attr('selected', true);
+ }
+}
+
+/**
+* Display the date/time select
+*/
+phpbb.timezone_enable_date_selection = function() {
+ $('#tz_select_date').css('display', 'block');
+}
+
+/**
+* Preselect a date/time or suggest one, if it is not picked.
+*
+* @param bool force_selector Shall we select the suggestion?
+*/
+phpbb.timezone_preselect_select = function(force_selector) {
+
+ // The offset returned here is in minutes and negated.
+ // http://www.w3schools.com/jsref/jsref_getTimezoneOffset.asp
+ var offset = (new Date()).getTimezoneOffset();
+
+ if (offset < 0) {
+ var sign = '+';
+ offset = -offset;
+ } else {
+ var sign = '-';
+ }
+
+ var minutes = offset % 60;
+ var hours = (offset - minutes) / 60;
+
+ if (hours < 10) {
+ hours = '0' + hours.toString();
+ } else {
+ hours = hours.toString();
+ }
+
+ if (minutes < 10) {
+ minutes = '0' + minutes.toString();
+ } else {
+ minutes = minutes.toString();
+ }
+
+ var prefix = 'GMT' + sign + hours + ':' + minutes;
+ var prefix_length = prefix.length;
+ var selector_options = $('#tz_date > option');
+
+ for (var i = 0; i < selector_options.length; ++i) {
+ var option = selector_options[i];
+
+ if (option.value.substring(0, prefix_length) == prefix) {
+ if ($('#tz_date').val() != option.value && !force_selector) {
+ // We do not select the option for the user, but notify him,
+ // that we would suggest a different setting.
+ phpbb.timezone_switch_date(true);
+ $('#tz_select_date_suggest').css('display', 'inline');
+ } else {
+ option.selected = true;
+ phpbb.timezone_switch_date(!force_selector);
+ $('#tz_select_date_suggest').css('display', 'none');
+ }
+
+ $('#tz_select_date_suggest').attr('title', $('#tz_select_date_suggest').attr('data-l-suggestion').replace("%s", option.innerHTML));
+ $('#tz_select_date_suggest').attr('value', $('#tz_select_date_suggest').attr('data-l-suggestion').replace("%s", option.innerHTML.substring(0, 9)));
+ $('#tz_select_date_suggest').attr('data-suggested-tz', option.innerHTML);
+
+ // Found the suggestion, there cannot be more, so return from here.
+ return;
+ }
+ }
+}
+
phpbb.ajax_callbacks = {};
/**
diff --git a/phpBB/common.php b/phpBB/common.php
index 81fe275008..c6bb5c6cfe 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -8,6 +8,10 @@
* Minimum Requirement: PHP 5.3.2
*/
+use Symfony\Component\Config\FileLocator;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+
/**
*/
if (!defined('IN_PHPBB'))
@@ -15,8 +19,6 @@ if (!defined('IN_PHPBB'))
exit;
}
-use Symfony\Component\EventDispatcher\EventDispatcher;
-
require($phpbb_root_path . 'includes/startup.' . $phpEx);
if (file_exists($phpbb_root_path . 'config.' . $phpEx))
@@ -74,65 +76,65 @@ if (!empty($load_extensions) && function_exists('dl'))
// Include files
require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
+require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx);
+require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx);
require($phpbb_root_path . 'includes/functions.' . $phpEx);
require($phpbb_root_path . 'includes/functions_content.' . $phpEx);
require($phpbb_root_path . 'includes/constants.' . $phpEx);
-require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
+require($phpbb_root_path . 'includes/db/' . ltrim($dbms, 'dbal_') . '.' . $phpEx);
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
// Set PHP error handler to ours
set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler');
+$phpbb_container = new ContainerBuilder();
+$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/config'));
+$loader->load('services.yml');
+
+$processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx);
+$processor->process($phpbb_container);
+
// Setup class loader first
-$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx");
-$phpbb_class_loader_ext->register();
-$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx");
-$phpbb_class_loader->register();
+$phpbb_class_loader = $phpbb_container->get('class_loader');
+$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext');
// set up caching
-$cache_factory = new phpbb_cache_factory($acm_type);
-$cache = $cache_factory->get_service();
-$phpbb_class_loader_ext->set_cache($cache->get_driver());
-$phpbb_class_loader->set_cache($cache->get_driver());
+$cache = $phpbb_container->get('cache');
// Instantiate some basic classes
-$phpbb_dispatcher = new phpbb_event_dispatcher();
-$request = new phpbb_request();
-$user = new phpbb_user();
-$auth = new phpbb_auth();
-$db = new $sql_db();
+$phpbb_dispatcher = $phpbb_container->get('dispatcher');
+$request = $phpbb_container->get('request');
+$user = $phpbb_container->get('user');
+$auth = $phpbb_container->get('auth');
+$db = $phpbb_container->get('dbal.conn');
// make sure request_var uses this request instance
request_var('', 0, false, false, $request); // "dependency injection" for a function
-// Connect to DB
-$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, defined('PHPBB_DB_NEW_LINK') ? PHPBB_DB_NEW_LINK : false);
-
-// We do not need this any longer, unset for safety purposes
-unset($dbpasswd);
-
// Grab global variables, re-cache if necessary
-$config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE);
+$config = $phpbb_container->get('config');
set_config(null, null, null, $config);
set_config_count(null, null, null, $config);
// load extensions
-$phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver());
+$phpbb_extension_manager = $phpbb_container->get('ext.manager');
+$phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader');
-// Initialize style
-$phpbb_style_resource_locator = new phpbb_style_resource_locator();
-$phpbb_style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider());
-$template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator);
-$phpbb_style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $phpbb_style_resource_locator, $phpbb_style_path_provider, $template);
+$template = $phpbb_container->get('template');
+$phpbb_style = $phpbb_container->get('style');
-$phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager);
-$phpbb_subscriber_loader->load();
+$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor'));
+foreach ($ids as $id)
+{
+ $processor = $phpbb_container->get($id);
+ $processor->process($phpbb_container);
+}
// Add own hook handler
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
-$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
+$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('phpbb_template', 'display')));
foreach ($cache->obtain_hooks() as $hook)
{
@@ -141,5 +143,20 @@ foreach ($cache->obtain_hooks() as $hook)
if (!$config['use_system_cron'])
{
- $cron = new phpbb_cron_manager(new phpbb_cron_task_provider($phpbb_extension_manager), $cache->get_driver());
+ $cron = $phpbb_container->get('cron.manager');
}
+
+/**
+* Main event which is triggered on every page
+*
+* You can use this event to load function files and initiate objects
+*
+* NOTE: At this point the global session ($user) and permissions ($auth)
+* do NOT exist yet. If you need to use the user object
+* (f.e. to include language files) or need to check permissions,
+* please use the core.user_setup event instead!
+*
+* @event core.common
+* @since 3.1-A1
+*/
+$phpbb_dispatcher->dispatch('core.common');
diff --git a/phpBB/composer.json b/phpBB/composer.json
index 1059b97f84..5e88144bc4 100644
--- a/phpBB/composer.json
+++ b/phpBB/composer.json
@@ -1,5 +1,12 @@
{
- "require": {
- "symfony/event-dispatcher": "2.0.*"
- }
+ "minimum-stability": "beta",
+ "require": {
+ "symfony/config": "2.1.*",
+ "symfony/dependency-injection": "2.1.*",
+ "symfony/event-dispatcher": "2.1.*",
+ "symfony/yaml": "2.1.*"
+ },
+ "require-dev": {
+ "fabpot/goutte": "1.0.x-dev"
+ }
}
diff --git a/phpBB/composer.lock b/phpBB/composer.lock
index 062ad4b3aa..6b0d3584d1 100644
--- a/phpBB/composer.lock
+++ b/phpBB/composer.lock
@@ -1,10 +1,74 @@
{
- "hash": "9bada3748ec2933fe0864dcfafbcd671",
+ "hash": "1632798bc1d5298a4f5bd3087c972a9f",
"packages": [
{
+ "package": "symfony/config",
+ "version": "v2.1.0-RC1"
+ },
+ {
+ "package": "symfony/dependency-injection",
+ "version": "v2.1.0-RC1"
+ },
+ {
"package": "symfony/event-dispatcher",
- "version": "v2.0.10"
+ "version": "v2.1.0-RC1"
+ },
+ {
+ "package": "symfony/yaml",
+ "version": "v2.1.0-RC1"
+ }
+ ],
+ "packages-dev": [
+ {
+ "package": "fabpot/goutte",
+ "version": "dev-master",
+ "alias-pretty-version": "1.0.x-dev",
+ "alias-version": "1.0.9999999.9999999-dev"
+ },
+ {
+ "package": "fabpot/goutte",
+ "version": "dev-master",
+ "source-reference": "6d26279344736f6983a969e46afef082ebf30a67",
+ "commit-date": "1345141401"
+ },
+ {
+ "package": "guzzle/common",
+ "version": "v2.8.4"
+ },
+ {
+ "package": "guzzle/http",
+ "version": "v2.8.4"
+ },
+ {
+ "package": "guzzle/parser",
+ "version": "v2.8.4"
+ },
+ {
+ "package": "symfony/browser-kit",
+ "version": "v2.1.0-RC1"
+ },
+ {
+ "package": "symfony/css-selector",
+ "version": "v2.1.0-RC1"
+ },
+ {
+ "package": "symfony/dom-crawler",
+ "version": "v2.1.0-RC1"
+ },
+ {
+ "package": "symfony/finder",
+ "version": "v2.1.0-RC1"
+ },
+ {
+ "package": "symfony/process",
+ "version": "v2.1.0-RC1"
}
],
- "aliases": []
+ "aliases": [
+
+ ],
+ "minimum-stability": "beta",
+ "stability-flags": {
+ "fabpot/goutte": 20
+ }
}
diff --git a/phpBB/config/.htaccess b/phpBB/config/.htaccess
new file mode 100644
index 0000000000..4128d345ab
--- /dev/null
+++ b/phpBB/config/.htaccess
@@ -0,0 +1,4 @@
+<Files *>
+ Order Allow,Deny
+ Deny from All
+</Files>
diff --git a/phpBB/config/cron_tasks.yml b/phpBB/config/cron_tasks.yml
new file mode 100644
index 0000000000..74f57e449d
--- /dev/null
+++ b/phpBB/config/cron_tasks.yml
@@ -0,0 +1,75 @@
+services:
+ cron.task.core.prune_all_forums:
+ class: phpbb_cron_task_core_prune_all_forums
+ arguments:
+ - %core.root_path%
+ - %core.php_ext%
+ - @config
+ - @dbal.conn
+ tags:
+ - { name: cron.task }
+
+ cron.task.core.prune_forum:
+ class: phpbb_cron_task_core_prune_forum
+ arguments:
+ - %core.root_path%
+ - %core.php_ext%
+ - @config
+ - @dbal.conn
+ tags:
+ - { name: cron.task }
+
+ cron.task.core.queue:
+ class: phpbb_cron_task_core_queue
+ arguments:
+ - %core.root_path%
+ - %core.php_ext%
+ - @config
+ tags:
+ - { name: cron.task }
+
+ cron.task.core.tidy_cache:
+ class: phpbb_cron_task_core_tidy_cache
+ arguments:
+ - @config
+ - @cache.driver
+ tags:
+ - { name: cron.task }
+
+ cron.task.core.tidy_database:
+ class: phpbb_cron_task_core_tidy_database
+ arguments:
+ - %core.root_path%
+ - %core.php_ext%
+ - @config
+ tags:
+ - { name: cron.task }
+
+ cron.task.core.tidy_search:
+ class: phpbb_cron_task_core_tidy_search
+ arguments:
+ - %core.root_path%
+ - %core.php_ext%
+ - @auth
+ - @config
+ - @dbal.conn
+ - @user
+ tags:
+ - { name: cron.task }
+
+ cron.task.core.tidy_sessions:
+ class: phpbb_cron_task_core_tidy_sessions
+ arguments:
+ - @config
+ - @user
+ tags:
+ - { name: cron.task }
+
+ cron.task.core.tidy_warnings:
+ class: phpbb_cron_task_core_tidy_warnings
+ arguments:
+ - %core.root_path%
+ - %core.php_ext%
+ - @config
+ tags:
+ - { name: cron.task }
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
new file mode 100644
index 0000000000..c3d2494952
--- /dev/null
+++ b/phpBB/config/services.yml
@@ -0,0 +1,136 @@
+imports:
+ - { resource: tables.yml }
+ - { resource: cron_tasks.yml }
+
+services:
+ auth:
+ class: phpbb_auth
+
+ cache:
+ class: phpbb_cache_service
+ arguments:
+ - @cache.driver
+
+ cache.driver:
+ class: %cache.driver.class%
+
+ cache.driver.install:
+ class: phpbb_cache_driver_file
+
+ class_loader:
+ class: phpbb_class_loader
+ arguments:
+ - phpbb_
+ - %core.root_path%includes/
+ - .%core.php_ext%
+ calls:
+ - [register, []]
+ - [set_cache, [@cache.driver]]
+
+ class_loader.ext:
+ class: phpbb_class_loader
+ arguments:
+ - phpbb_ext_
+ - %core.root_path%ext/
+ - .%core.php_ext%
+ calls:
+ - [register, []]
+ - [set_cache, [@cache.driver]]
+
+ config:
+ class: phpbb_config_db
+ arguments:
+ - @dbal.conn
+ - @cache.driver
+ - %tables.config%
+
+ cron.task_provider:
+ class: phpbb_cron_task_provider
+ arguments:
+ - @container
+
+ cron.manager:
+ class: phpbb_cron_manager
+ arguments:
+ - @cron.task_provider
+ - %core.root_path%
+ - %core.php_ext%
+
+ cron.lock_db:
+ class: phpbb_lock_db
+ arguments:
+ - cron_lock
+ - @config
+ - @dbal.conn
+
+ dispatcher:
+ class: phpbb_event_dispatcher
+
+ dbal.conn:
+ class: %dbal.driver.class%
+ calls:
+ - [sql_connect, [%dbal.dbhost%, %dbal.dbuser%, %dbal.dbpasswd%, %dbal.dbname%, %dbal.dbport%, false, %dbal.new_link%]]
+
+ event.subscriber_loader:
+ class: phpbb_event_extension_subscriber_loader
+ arguments:
+ - @dispatcher
+ - @ext.manager
+ calls:
+ - [load, []]
+
+ ext.manager:
+ class: phpbb_extension_manager
+ arguments:
+ - @dbal.conn
+ - @config
+ - %tables.ext%
+ - %core.root_path%
+ - .%core.php_ext%
+ - @cache.driver
+
+ processor.ext:
+ class: phpbb_di_processor_ext
+ arguments:
+ - @ext.manager
+ tags:
+ - { name: container.processor }
+
+ request:
+ class: phpbb_request
+
+ style:
+ class: phpbb_style
+ arguments:
+ - %core.root_path%
+ - %core.php_ext%
+ - @config
+ - @user
+ - @style.resource_locator
+ - @style.path_provider_ext
+ - @template
+
+ style.resource_locator:
+ class: phpbb_style_resource_locator
+
+ style.path_provider_ext:
+ class: phpbb_style_extension_path_provider
+ arguments:
+ - @ext.manager
+ - @style.path_provider
+
+ style.path_provider:
+ class: phpbb_style_path_provider
+
+ template:
+ class: phpbb_template
+ arguments:
+ - %core.root_path%
+ - %core.php_ext%
+ - @config
+ - @user
+ - @style.resource_locator
+ - @style.path_provider_ext
+
+ user:
+ class: phpbb_user
diff --git a/phpBB/config/tables.yml b/phpBB/config/tables.yml
new file mode 100644
index 0000000000..cfc6dbcfed
--- /dev/null
+++ b/phpBB/config/tables.yml
@@ -0,0 +1,3 @@
+parameters:
+ tables.config: %core.table_prefix%config
+ tables.ext: %core.table_prefix%ext
diff --git a/phpBB/cron.php b/phpBB/cron.php
index 36b771f1b7..95d2f8f9b6 100644
--- a/phpBB/cron.php
+++ b/phpBB/cron.php
@@ -61,7 +61,7 @@ function do_cron($cron_lock, $run_tasks)
if ($config['use_system_cron'])
{
- $cron = new phpbb_cron_manager(new phpbb_cron_task_provider($phpbb_extension_manager), $cache->get_driver());
+ $cron = $phpbb_container->get('cron.manager');
}
else
{
@@ -71,7 +71,7 @@ else
output_image();
}
-$cron_lock = new phpbb_lock_db('cron_lock', $config, $db);
+$cron_lock = $phpbb_container->get('cron.lock_db');
if ($cron_lock->acquire())
{
if ($config['use_system_cron'])
diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php
index 0193e57f23..6eb4a80199 100644
--- a/phpBB/develop/create_schema_files.php
+++ b/phpBB/develop/create_schema_files.php
@@ -1461,6 +1461,7 @@ function get_schema_struct()
'field_default_value' => array('VCHAR_UNI', ''),
'field_validation' => array('VCHAR_UNI:20', ''),
'field_required' => array('BOOL', 0),
+ 'field_show_novalue' => array('BOOL', 0),
'field_show_on_reg' => array('BOOL', 0),
'field_show_on_pm' => array('BOOL', 0),
'field_show_on_vt' => array('BOOL', 0),
@@ -1794,8 +1795,7 @@ function get_schema_struct()
'user_inactive_time' => array('TIMESTAMP', 0),
'user_posts' => array('UINT', 0),
'user_lang' => array('VCHAR:30', ''),
- 'user_timezone' => array('DECIMAL', 0),
- 'user_dst' => array('BOOL', 0),
+ 'user_timezone' => array('VCHAR:100', 'UTC'),
'user_dateformat' => array('VCHAR_UNI:30', 'd M Y H:i'),
'user_style' => array('UINT', 0),
'user_rank' => array('UINT', 0),
diff --git a/phpBB/develop/mysql_upgrader.php b/phpBB/develop/mysql_upgrader.php
index 0498f826ab..7f82ebfeab 100644
--- a/phpBB/develop/mysql_upgrader.php
+++ b/phpBB/develop/mysql_upgrader.php
@@ -1229,8 +1229,7 @@ function get_schema_struct()
'user_inactive_time' => array('TIMESTAMP', 0),
'user_posts' => array('UINT', 0),
'user_lang' => array('VCHAR:30', ''),
- 'user_timezone' => array('DECIMAL', 0),
- 'user_dst' => array('BOOL', 0),
+ 'user_timezone' => array('VCHAR:100', 'UTC'),
'user_dateformat' => array('VCHAR_UNI:30', 'd M Y H:i'),
'user_style' => array('UINT', 0),
'user_rank' => array('UINT', 0),
diff --git a/phpBB/develop/repair_bots.php b/phpBB/develop/repair_bots.php
index 790d3d9f2f..2c6e9ce091 100644
--- a/phpBB/develop/repair_bots.php
+++ b/phpBB/develop/repair_bots.php
@@ -128,7 +128,7 @@ function add_bots($bots)
'user_email' => '',
'user_lang' => $config['default_lang'],
'user_style' => 1,
- 'user_timezone' => 0,
+ 'user_timezone' => 'UTC',
'user_allow_massemail' => 0,
);
diff --git a/phpBB/develop/search_fill.php b/phpBB/develop/search_fill.php
index 4c0b607778..2a4dfb212c 100644
--- a/phpBB/develop/search_fill.php
+++ b/phpBB/develop/search_fill.php
@@ -40,7 +40,7 @@ if (!class_exists($search_type))
}
$error = false;
-$search = new $search_type($error);
+$search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
if ($error)
{
diff --git a/phpBB/docs/AUTHORS b/phpBB/docs/AUTHORS
index f0b4e25549..c63bd743a7 100644
--- a/phpBB/docs/AUTHORS
+++ b/phpBB/docs/AUTHORS
@@ -22,15 +22,12 @@ involved in phpBB.
phpBB Lead Developer: naderman (Nils Adermann)
-phpBB Developers: Acyd Burn (Meik Sievertsen) [Lead 09/2005 - 01/2010]
- Arty (Vjacheslav Trushkin)
- bantu (Andreas Fischer)
- imkingdavid (David King)
+phpBB Developers: bantu (Andreas Fischer)
igorw (Igor Wiedler)
+ imkingdavid (David King)
nickvergessen (Joas Schilling)
Oleg (Oleg Pudeyev)
rxu (Ruslan Uzdenov)
- ToonArmy (Chris Smith)
Contributions by: leviatan21 (Gabriel Vazquez)
Raimon (Raimon Meuldijk)
@@ -39,13 +36,16 @@ Contributions by: leviatan21 (Gabriel Vazquez)
-- Former Contributors --
-phpBB Project Manager: theFinn (James Atkinson) [Founder - 04/2007]
+phpBB Project Manager: theFinn (James Atkinson) [Founder - 04/2007]
SHS` (Jonathan Stanley)
-phpBB Lead Developer: psoTFX (Paul S. Owen) [2001 - 09/2005]
+phpBB Lead Developer: Acyd Burn (Meik Sievertsen) [09/2005 - 01/2010]
+ psoTFX (Paul S. Owen) [2001 - 09/2005]
phpBB Developers: A_Jelly_Doughnut (Josh Woody) [01/2010 - 11/2010]
+ Acyd Burn (Meik Sievertsen) [02/2003 - 09/2005]
APTX (Marek A. Ruszczyński) [12/2007 - 04/2011]
+ Arty (Vjacheslav Trushkin) [02/2012 - 07/2012]
Ashe (Ludovic Arnaud) [10/2002 - 11/2003, 06/2006 - 10/2006]
BartVB (Bart van Bragt) [11/2000 - 03/2006]
ckwalsh (Cullen Walsh) [01/2010 - 07/2011]
@@ -54,6 +54,7 @@ phpBB Developers: A_Jelly_Doughnut (Josh Woody) [01/2010 - 11/2010]
GrahamJE (Graham Eames) [09/2005 - 11/2006]
kellanved (Henry Sudhof) [04/2007 - 03/2011]
TerraFrost (Jim Wigginton) [04/2009 - 01/2011]
+ ToonArmy (Chris Smith) [06/2008 - 11/2011]
Vic D'Elfant (Vic D'Elfant) [04/2007 - 04/2009]
-- Copyrights --
@@ -75,6 +76,7 @@ Jabber Class (c) 2006 Flyspray.org, http://www.flyspray.org/
Chora (c) 2000-2006, The Horde Project. http://horde.org/chora/
Horde Project (c) 2000-2006, The Horde Project. http://horde.org/
jQuery (c) 2011, John Resig. http://jquery.com/
+Sphinx Technologies Inc (c) 2001-2012 Andrew Aksyonoff, http://sphinxsearch.com/
PHP License, version 3.0:
Pear (c) 2001-2004 PHP Group, http://pear.php.net
diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html
index 0c56dbb2a3..942912a593 100644
--- a/phpBB/docs/CHANGELOG.html
+++ b/phpBB/docs/CHANGELOG.html
@@ -151,6 +151,14 @@
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10890">PHPBB3-10890</a>] - test_sql_fetchrow_returns_false_when_empty() fails on MSSQL and Oracle</li>
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10908">PHPBB3-10908</a>] - No remote avatar size limit results in files limited only by PHP memory limit</li>
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10913">PHPBB3-10913</a>] - Admin is logged out when accessing any url under adm/ without session id</li>
+<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10441">PHPBB3-10441</a>] - Update to docs/README.html</li>
+<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10773">PHPBB3-10773</a>] - ACP phpBB logo needs registered trademark symbol</li>
+<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10935">PHPBB3-10935</a>] - Limit number of PM rules per user</li>
+<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10937">PHPBB3-10937</a>] - Comment removal functions: Backward compatibility broken</li>
+<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10950">PHPBB3-10950</a>] - Deleting user with undelivered PMs causes SQL error</li>
+<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10952">PHPBB3-10952</a>] - includes/constants.php version number incorrect</li>
+<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10965">PHPBB3-10965</a>] - Dropdown CPF now shows in profile when no value is selected</li>
+<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10978">PHPBB3-10978</a>] - Typo in prosilvers ucp_groups_membership.html</li>
</ul>
<h4>Improvement</h4>
<ul>
@@ -181,6 +189,7 @@
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10891">PHPBB3-10891</a>] - Allow specifying test config file name via environment variable</li>
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10892">PHPBB3-10892</a>] - Cosmetic improvements to RUNNING_TESTS.txt</li>
<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10898">PHPBB3-10898</a>] - Do not write ?&gt; into config.php to avoid whitespace output</li>
+<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10925">PHPBB3-10925</a>] - Clarify that SQLite3 is not supported for phpBB 3.0.x</li>
</ul>
<h4>New Feature</h4>
<ul>
diff --git a/phpBB/docs/README.html b/phpBB/docs/README.html
index cecc996c9c..8f9e960275 100644
--- a/phpBB/docs/README.html
+++ b/phpBB/docs/README.html
@@ -47,7 +47,7 @@
<li><a href="#install">Installing phpBB3</a></li>
<li><a href="#run">Running phpBB3</a>
<ol style="list-style-type: lower-roman;">
- <li><a href="#i18n">Internationalisation (i18n)</a></li>
+ <li><a href="#i18n">Languages (Internationalisation - i18n)</a></li>
<li><a href="#styles">Styles</a></li>
<li><a href="#mods">Modifications</a></li>
</ol>
@@ -55,8 +55,9 @@
<li><a href="#help">Getting help with phpBB3</a>
<ol style="list-style-type: lower-roman;">
<li><a href="#docs">Documentation</a></li>
+ <li><a href="#kb">Knowledge Base</a></li>
<li><a href="#website">Community Forums</a></li>
- <li><a href="#irc">Internet Relay Chat</a></li>
+ <li><a href="#irc">Internet Relay Chat (IRC)</a></li>
</ol>
</li>
<li><a href="#status">Status of this version</a></li>
@@ -122,41 +123,41 @@
<div class="content">
- <p>Once installed phpBB is easily managed by both admin and moderator control panels. If you need help or advice with phpBB please see <a href="#help">Section 3</a> below.</p>
+ <p>Once installed, phpBB is easily managed via the Administration and Moderator Control Panels. If you need help or advice with phpBB, please see <a href="#help">Section 3</a> below.</p>
- <a name="i18n"></a><h3>2.i. Internationalisation (i18n)</h3>
+ <a name="i18n"></a><h3>2.i. Languages (Internationalisation - i18n)</h3>
- <p>A number of language packs and style localisations are available. You can find them on our official language packs page:</p>
+ <p>A number of language packs with included style localisations are available. You can find them listed in the <a href="http://www.phpbb.com/languages/">Language Packs</a> pages of our downloads section or from the <a href="http://www.phpbb.com/customise/db/language_packs-25/">Language Packs</a> section of the <a href="http://www.phpbb.com/customise/db/">Customisation Database</a>.</p>
- <p><a href="http://www.phpbb.com/languages/">http://www.phpbb.com/languages/</a></p>
+ <p>For more information about language packs, please see: <a href="http://www.phpbb.com/languages/">http://www.phpbb.com/languages/</a></p>
<p>This is the <em>official</em> location for all supported language sets. If you download a package from a 3rd party site you do so with the understanding that we cannot offer support. So please, do not ask for help in these cases!</p>
- <p>Installation of these packages is straightforward, simply download the required language pack and unarchive it into the <samp>languages/</samp> folder. Please ensure you retain the directory structure when doing this! Once uploaded go to the <code>Admin-&gt;System-&gt;Language Packs</code> and install the now appearing new language pack. To install the style imageset you should download the imageset for your language and unarchive the file/s into the relevant imageset directory (styles/prosilver/imageset or styles/subsilver2/imageset), again you must retain the directory structure. Once installed the imageset will become immediately available.</p>
+ <p>Installation of these packages is straightforward: simply download the required language pack, uncompress (unzip) it and via FTP transfer the included <code>language</code> and <code>styles</code> folders to the root of your board installation. The language can then be installed via the Administration Control Panel of your board: <code>System tab -&gt; General Tasks -&gt; Language packs</code>. A more detailed description of the process is in the Knowledge Base article, <a href="http://www.phpbb.com/kb/article/how-to-install-a-language-pack/">How to Install a Language Pack</a>.</p>
- <p>If your language is not available please visit our forums where you will find a topic listing translations currently available or in preparation. This topic also gives you information should you wish to volunteer to translate a language not currently listed.</p>
+ <p>If your language is not available, please visit our <a href="http://www.phpbb.com/community/viewforum.php?f=66">[3.0.x] Translations</a> forum where you will find topics on translations in progress. Should you wish to volunteer to translate a language not currently available or assist in maintaining an existing language pack, you can <a href="http://www.phpbb.com/languages/apply.php">Apply to become a translator</a>.</p>
<a name="styles"></a><h3>2.ii. Styles</h3>
- <p>Although phpBB Group are rather proud of the included styles we realise that they may not be to everyone's tastes. Therefore phpBB3 allows styles to be switched with relative ease. Firstly you need to locate and download a style you like. We maintain such a site at</p>
+ <p>Although the phpBB Group is rather proud of the included styles, we realise that they may not be to everyone's taste. Therefore, phpBB3 allows styles to be switched with relative ease. First, you need to locate and download a style you like. You can find them listed in the <a href="http://www.phpbb.com/customise/db/styles-2/">Styles</a> section of our <a href="http://www.phpbb.com/customise/db/">Customisation Database</a>.</p>
- <p><a href="http://www.phpbb.com/customise/db/styles-2/">http://www.phpbb.com/customise/db/styles-2/</a></p>
+ <p>For more information about styles, please see: <a href="http://www.phpbb.com/styles/">http://www.phpbb.com/styles/</a></p>
- <p><strong>Please note</strong> that 3rd party styles downloaded for versions of phpBB2 will <strong>not</strong> work in phpBB3.</p>
+ <p><strong>Please note</strong> that 3rd party styles downloaded for versions of phpBB2 will <strong>not</strong> work in phpBB3. It is also important to ensure that the style is updated to match the current version of the phpBB software you are using.</p>
- <p>Once you have downloaded a style the usual next step is to unarchive (or upload the unarchived contents of) the package into your <samp>styles/</samp> directory. You then need to visit <code>Administration -&gt; Styles</code>, you should see the new style available, click install and it will become available for all your users.</p>
+ <p>Once you have downloaded a style, the usual next step is to unarchive (or upload the unarchived contents of) the package into your <code>styles/</code> directory. You then need to visit <code>Administration Control Panel -&gt; Styles tab</code> where you should see the new style available. Click &quot;Install&quot; to install the style.</p>
- <p><strong>Please note</strong> that if you create your own style or modify existing ones, please remember to enable the &quot;Recompile stale style components&quot; setting within the <code>Admin-&gt;General-&gt;Load Settings</code> screen. This setting allows the cache to detect changes made to the style and automatically refresh it. If this setting is disabled, you will not see your changes taking effect.</p>
+ <p><strong>Please note</strong> that to improve efficiency, the software caches certain data. For this reason, if you create your own style or modify existing ones, please remember to &quot;Refresh&quot; the appropriate style components <code>Administration Control Panel -&gt; Styles tab -&gt; Style Components</code> screen. You may also need to reload the page you have changed in your web browser to overcome browser caching. If the changed components are not refreshed you will not see your changes taking effect.</p>
<a name="mods"></a><h3>2.iii. Modifications</h3>
- <p>Although not officially supported by phpBB Group, phpBB has a thriving modification scene. These third party modifications to the standard phpBB extend its capabilities still further and can be found at:</p>
+ <p>Although not officially supported by the phpBB Group, phpBB has a thriving modification scene. These third party modifications to the standard phpBB software, known as <strong>MODs</strong>, extend its capabilities still further. You can browse through many of the MODs in the <a href="http://www.phpbb.com/customise/db/modifications-1/">Modifications</a> section of our <a href="http://www.phpbb.com/customise/db/">Customisation Database</a>.</p>
- <p><a href="http://www.phpbb.com/customise/db/modifications-1/">http://www.phpbb.com/customise/db/modifications-1/</a></p>
+ <p>For more information about MODs, please see: <a href="http://www.phpbb.com/mods/">http://www.phpbb.com/mods/</a></p>
- <p><strong>Please remember</strong> that any bugs or other issues that occur after you have added any modification should <strong>NOT</strong> be reported to the bug tracker (see below). First remove the modification and see if the problem is resolved.</p>
+ <p><strong>Please remember</strong> that any bugs or other issues that occur after you have added any modification should <strong>NOT</strong> be reported to the bug tracker (see below). First remove the MOD and see if the problem is resolved. Any support for a MOD should only be sought in the &quot;Discussion/Support&quot; forum for that MOD.</p>
- <p>Also remember that any modifications which modify the database in any way may render upgrading your forum to future versions more difficult unless we state otherwise. With all this said many users have and continue to utilise many of the mods already available with great success.</p>
+ <p>Also remember that any modifications, particularly those which modify the database in any way, may render upgrading your forum to future versions more difficult. With all this said, many users have and continue to utilise many of the MODs already available with great success.</p>
</div>
@@ -184,17 +185,23 @@
<p>This covers everything from installation through setting permissions and managing users.</p>
- <a name="website"></a><h3>3.ii. Community Forums</h3>
+ <a name="kb"></a><h3>3.ii. Knowledge Base</h3>
- <p>phpBB Group maintains a thriving community where a number of people have generously decided to donate their time to help support users. This site can be found at:</p>
+ <p>The Knowledge Base consists of a number of detailed articles on some common issues phpBB users may encounter while using the product. The Knowledge Base can be found at:</p>
+
+ <p><a href="http://www.phpbb.com/kb/">http://www.phpbb.com/kb/</a></p>
+
+ <a name="website"></a><h3>3.iii. Community Forums</h3>
+
+ <p>The phpBB Group maintains a thriving community where a number of people have generously decided to donate their time to help support users. This site can be found at:</p>
<p><a href="http://www.phpbb.com/community/">http://www.phpbb.com/community/</a></p>
<p>If you do seek help via our forums please be sure to do a Search before posting. This may well save both you and us time and allow the developer, moderator and support groups to spend more time responding to people with unknown issues and problems. Please also remember that phpBB is an entirely volunteer effort, no one receives any compensation for the time they give, this includes moderators as well as developers. So please be respectful and mindful when awaiting responses.</p>
- <a name="irc"></a><h3>3.iii Internet Relay Chat</h3>
+ <a name="irc"></a><h3>3.iv Internet Relay Chat</h3>
- <p>Another place you may find help is our IRC channel. This operates on the Freenode IRC network, <em>irc.freenode.net</em> and the channel is <em>#phpbb</em> and can be accessed by any good IRC client such as mIRC, XChat, etc. Again, please do not abuse this service and be respectful of other users.</p>
+ <p>Another place you may find help is our IRC channel. This operates on the Freenode IRC network, <a href="irc://irc.freenode.net">irc.freenode.net</a> and the channel is <em>#phpbb</em> and can be accessed by any decent IRC client such as mIRC, XChat, etc. Again, please do not abuse this service and be respectful of other users.</p>
<p>There are other IRC channels available, please see <a href="http://www.phpbb.com/support/irc/">http://www.phpbb.com/support/irc/</a> for the complete list.</p>
@@ -220,7 +227,7 @@
<p><a href="http://area51.phpbb.com/phpBB/">http://area51.phpbb.com/phpBB/</a></p>
- <p>Please note that this forum should <strong>NOT</strong> be used to obtain support for phpBB, the main community forums are the place for this.</p>
+ <p>Please note that the development forums should <strong>NOT</strong> be used to seek support for phpBB, the main community forums are the place for this.</p>
</div>
@@ -245,13 +252,13 @@
<p>While we very much appreciate receiving bug reports (the more reports the more stable phpBB will be) we ask you carry out a few steps before adding new entries:</p>
<ul>
- <li>Firstly determine if your bug is reproduceable, how to determine this depends on the bug in question. Only if the bug is reproduceable it is likely to be a problem with phpBB3 (or in some way connected). If something cannot be reproduced it may turn out to have been your hosting provider working on something, a user doing something silly, etc. Bug reports for non-reproduceable events can slow down our attempts to fix real, reproduceable issues.<br /><br /></li>
- <li>Next please read or search through the existing bug reports to see if <em>your</em> bug (or one very similar to it) is already listed. If it is please add to that existing bug rather than creating a new duplicate entry (all this does is slow us down).<br /><br /></li>
- <li>Check the forums (use search!) to see if people have discussed anything that sounds similar to what you are seeing. However, as noted above please <strong>DO NOT</strong> post your particular bug to the forum unless it's non-reproduceable or you are sure it's related to something you have done rather phpBB3.<br /><br /></li>
- <li>If no existing bug exists then please feel free to add it.</li>
+ <li>First, determine if your bug is reproduceable; how to determine this depends on the bug in question. Only if the bug is reproduceable is it likely to be a problem with phpBB3 (or in some way connected). If something cannot be reproduced it may turn out to have been your hosting provider working on something, a user doing something silly, etc. Bug reports for non-reproduceable events can slow down our attempts to fix real, reproduceable issues<br /><br /></li>
+ <li>Next, please read or search through the existing bug reports to see if <em>your</em> bug (or one very similar to it) is already listed. If it is please add to that existing bug rather than creating a new duplicate entry (all this does is slow us down).<br /><br /></li>
+ <li>Check the forums (use search!) to see if people have discussed anything that sounds similar to what you are seeing. However, as noted above please <strong>DO NOT</strong> post your particular bug to the forum unless it's non-reproduceable or you are sure it&rsquo;s related to something you have done rather than phpBB3<br /><br /></li>
+ <li>If no existing bug exists then please feel free to add it</li>
</ul>
- <p>If you do post a new bug (i.e. one that isn't already listed in the bug tracker) firstly make sure you have logged in (your username and password are the same as for the community forums) then please include the following details:</p>
+ <p>If you do post a new bug (i.e. one that isn't already listed in the bug tracker) first make sure that you have logged in (your username and password are the same as for the community forums) then please include the following details:</p>
<ul>
<li>Your server type/version, e.g. Apache 2.2.3, IIS 7, Sambar, etc.</li>
@@ -289,7 +296,7 @@
<div class="content">
- <p>This list is not complete but does represent those bugs which may effect users on a wider scale. Other bugs listed in the tracker have typically been shown to be limited to certain setups or methods of installation, updating and/or conversions.</p>
+ <p>This list is not complete but does represent those bugs which may affect users on a wider scale. Other bugs listed in the tracker have typically been shown to be limited to certain setups or methods of installation, updating and/or conversions.</p>
<ul>
<li>Conversions may fail to complete on large boards under some hosts</li>
@@ -317,7 +324,11 @@
<p>Please remember that running any application on a developmental version of PHP can lead to strange/unexpected results which may appear to be bugs in the application (which may not be true). Therefore we recommend you upgrade to the newest stable version of PHP before running phpBB3. If you are running a developmental version of PHP please check any bugs you find on a system running a stable release before submitting.</p>
+<<<<<<< HEAD
<p>This board has been developed and tested under Linux and Windows (amongst others) running Apache using MySQL 3.23, 4.x, 5.x, MSSQL Server 2000, PostgreSQL 8.x, Oracle 8, SQLite and Firebird. Versions of PHP used range from 5.3.x to 5.4.x without problem.</p>
+=======
+ <p>This board has been developed and tested under Linux and Windows (amongst others) running Apache using MySQL 3.23, 4.x, 5.x, MSSQL Server 2000, PostgreSQL 7.x, Oracle 8, SQLite 2 and Firebird. Versions of PHP used range from 4.3.3 to 5.4.x without problem. </p>
+>>>>>>> develop-olympus
<a name="phpsec"></a><h3>7.i. Notice on PHP security issues</h3>
@@ -339,7 +350,7 @@
<div class="content">
- <p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-2.0.php">GNU General Public License v2</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright (c) <a href="http://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p>
+ <p>This application is opensource software released under the <a href="http://opensource.org/licenses/gpl-2.0.php">GNU General Public License v2</a>. Please see source code and the docs directory for more details. This package and its contents are Copyright &copy; <a href="http://www.phpbb.com/">phpBB Group</a>, All Rights Reserved.</p>
</div>
diff --git a/phpBB/docs/sphinx.sample.conf b/phpBB/docs/sphinx.sample.conf
new file mode 100644
index 0000000000..aa0e8d905d
--- /dev/null
+++ b/phpBB/docs/sphinx.sample.conf
@@ -0,0 +1,96 @@
+source source_phpbb_{SPHINX_ID}_main
+{
+ type = mysql #mysql or pgsql
+ sql_host = localhost #SQL server host sphinx connects to
+ sql_user = username
+ sql_pass = password
+ sql_db = db_name
+ sql_port = 3306 #optional, default is 3306 for mysql and 5432 for pgsql
+ sql_query_pre = SET NAMES 'utf8'
+ sql_query_pre = UPDATE phpbb_sphinx SET max_doc_id = MAX(post_id) WHERE counter_id = 1
+ sql_query_range = SELECT MIN(post_id), MAX(post_id) FROM phpbb_posts
+ sql_range_step = 5000
+ sql_query = SELECT \
+ p.post_id AS id, \
+ p.forum_id, \
+ p.topic_id, \
+ p.poster_id, \
+ CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post, \
+ p.post_time, \
+ p.post_subject, \
+ p.post_subject as title, \
+ p.post_text as data, \
+ t.topic_last_post_time, \
+ 0 as deleted \
+ FROM phpbb_posts p, phpbb_topics t \
+ WHERE \
+ p.topic_id = t.topic_id \
+ AND p.post_id >= $start AND p.post_id <= $end
+ sql_query_post =
+ sql_query_post_index = UPDATE phpbb_sphinx SET max_doc_id = $maxid WHERE counter_id = 1
+ sql_query_info = SELECT * FROM phpbb_posts WHERE post_id = $id
+ sql_attr_uint = forum_id
+ sql_attr_uint = topic_id
+ sql_attr_uint = poster_id
+ sql_attr_bool = topic_first_post
+ sql_attr_bool = deleted
+ sql_attr_timestamp = post_time
+ sql_attr_timestamp = topic_last_post_time
+ sql_attr_str2ordinal = post_subject
+}
+source source_phpbb_{SPHINX_ID}_delta : source_phpbb_{SPHINX_ID}_main
+{
+ sql_query_range =
+ sql_range_step =
+ sql_query = SELECT \
+ p.post_id AS id, \
+ p.forum_id, \
+ p.topic_id, \
+ p.poster_id, \
+ CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post, \
+ p.post_time, \
+ p.post_subject, \
+ p.post_subject as title, \
+ p.post_text as data, \
+ t.topic_last_post_time, \
+ 0 as deleted \
+ FROM phpbb_posts p, phpbb_topics t \
+ WHERE \
+ p.topic_id = t.topic_id \
+ AND p.post_id >= ( SELECT max_doc_id FROM phpbb_sphinx WHERE counter_id=1 )
+ sql_query_pre =
+}
+index index_phpbb_{SPHINX_ID}_main
+{
+ path = {DATA_PATH}/index_phpbb_{SPHINX_ID}_main
+ source = source_phpbb_{SPHINX_ID}_main
+ docinfo = extern
+ morphology = none
+ stopwords =
+ min_word_len = 2
+ charset_type = utf-8
+ charset_table = U+FF10..U+FF19->0..9, 0..9, U+FF41..U+FF5A->a..z, U+FF21..U+FF3A->a..z, A..Z->a..z, a..z, U+0149, U+017F, U+0138, U+00DF, U+00FF, U+00C0..U+00D6->U+00E0..U+00F6, U+00E0..U+00F6, U+00D8..U+00DE->U+00F8..U+00FE, U+00F8..U+00FE, U+0100->U+0101, U+0101, U+0102->U+0103, U+0103, U+0104->U+0105, U+0105, U+0106->U+0107, U+0107, U+0108->U+0109, U+0109, U+010A->U+010B, U+010B, U+010C->U+010D, U+010D, U+010E->U+010F, U+010F, U+0110->U+0111, U+0111, U+0112->U+0113, U+0113, U+0114->U+0115, U+0115, U+0116->U+0117, U+0117, U+0118->U+0119, U+0119, U+011A->U+011B, U+011B, U+011C->U+011D, U+011D, U+011E->U+011F, U+011F, U+0130->U+0131, U+0131, U+0132->U+0133, U+0133, U+0134->U+0135, U+0135, U+0136->U+0137, U+0137, U+0139->U+013A, U+013A, U+013B->U+013C, U+013C, U+013D->U+013E, U+013E, U+013F->U+0140, U+0140, U+0141->U+0142, U+0142, U+0143->U+0144, U+0144, U+0145->U+0146, U+0146, U+0147->U+0148, U+0148, U+014A->U+014B, U+014B, U+014C->U+014D, U+014D, U+014E->U+014F, U+014F, U+0150->U+0151, U+0151, U+0152->U+0153, U+0153, U+0154->U+0155, U+0155, U+0156->U+0157, U+0157, U+0158->U+0159, U+0159, U+015A->U+015B, U+015B, U+015C->U+015D, U+015D, U+015E->U+015F, U+015F, U+0160->U+0161, U+0161, U+0162->U+0163, U+0163, U+0164->U+0165, U+0165, U+0166->U+0167, U+0167, U+0168->U+0169, U+0169, U+016A->U+016B, U+016B, U+016C->U+016D, U+016D, U+016E->U+016F, U+016F, U+0170->U+0171, U+0171, U+0172->U+0173, U+0173, U+0174->U+0175, U+0175, U+0176->U+0177, U+0177, U+0178->U+00FF, U+00FF, U+0179->U+017A, U+017A, U+017B->U+017C, U+017C, U+017D->U+017E, U+017E, U+0410..U+042F->U+0430..U+044F, U+0430..U+044F, U+4E00..U+9FFF
+ min_prefix_len = 0
+ min_infix_len = 0
+}
+index index_phpbb_{SPHINX_ID}_delta : index_phpbb_{SPHINX_ID}_main
+{
+ path = {DATA_PATH}/index_phpbb_{SPHINX_ID}_delta
+ source = source_phpbb_{SPHINX_ID}_delta
+}
+indexer
+{
+ mem_limit = 512M
+}
+searchd
+{
+ compat_sphinxql_magics = 0
+ listen = localhost:9312
+ log = {DATA_PATH}/log/searchd.log
+ query_log = {DATA_PATH}/log/sphinx-query.log
+ read_timeout = 5
+ max_children = 30
+ pid_file = {DATA_PATH}/searchd.pid
+ max_matches = 20000
+ binlog_path = {DATA_PATH}
+}
diff --git a/phpBB/download/file.php b/phpBB/download/file.php
index c01b0789de..7ed53d54b6 100644
--- a/phpBB/download/file.php
+++ b/phpBB/download/file.php
@@ -7,6 +7,10 @@
*
*/
+use Symfony\Component\Config\FileLocator;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+
/**
* @ignore
*/
@@ -14,7 +18,6 @@ define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
-
// Thank you sun.
if (isset($_SERVER['CONTENT_TYPE']))
{
@@ -39,26 +42,31 @@ if (isset($_GET['avatar']))
}
require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
+ require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx);
+ require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx);
+
require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx);
require($phpbb_root_path . 'includes/constants.' . $phpEx);
require($phpbb_root_path . 'includes/functions.' . $phpEx);
require($phpbb_root_path . 'includes/functions_download' . '.' . $phpEx);
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
- $phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx");
- $phpbb_class_loader_ext->register();
- $phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx");
- $phpbb_class_loader->register();
+ $phpbb_container = new ContainerBuilder();
+ $loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config'));
+ $loader->load('services.yml');
+
+ $processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx);
+ $processor->process($phpbb_container);
+
+ $phpbb_class_loader = $phpbb_container->get('class_loader');
+ $phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext');
// set up caching
- $cache_factory = new phpbb_cache_factory($acm_type);
- $cache = $cache_factory->get_service();
- $phpbb_class_loader_ext->set_cache($cache->get_driver());
- $phpbb_class_loader->set_cache($cache->get_driver());
+ $cache = $phpbb_container->get('cache');
- $phpbb_dispatcher = new phpbb_event_dispatcher();
- $request = new phpbb_request();
- $db = new $sql_db();
+ $phpbb_dispatcher = $phpbb_container->get('dispatcher');
+ $request = $phpbb_container->get('request');
+ $db = $phpbb_container->get('dbal.conn');
// Connect to DB
if (!@$db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false))
@@ -69,18 +77,23 @@ if (isset($_GET['avatar']))
request_var('', 0, false, false, $request);
- // worst-case default
- $browser = strtolower($request->header('User-Agent', 'msie 6.0'));
-
- $config = new phpbb_config_db($db, $cache->get_driver(), CONFIG_TABLE);
+ $config = $phpbb_container->get('config');
set_config(null, null, null, $config);
set_config_count(null, null, null, $config);
// load extensions
- $phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx", $cache->get_driver());
+ $phpbb_extension_manager = $phpbb_container->get('ext.manager');
+ $phpbb_subscriber_loader = $phpbb_container->get('event.subscriber_loader');
- $phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager);
- $phpbb_subscriber_loader->load();
+ $ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor'));
+ foreach ($ids as $id)
+ {
+ $processor = $phpbb_container->get($id);
+ $processor->process($phpbb_container);
+ }
+
+ // worst-case default
+ $browser = strtolower($request->header('User-Agent', 'msie 6.0'));
$filename = request_var('avatar', '');
$avatar_group = false;
@@ -134,6 +147,9 @@ include($phpbb_root_path . 'common.' . $phpEx);
require($phpbb_root_path . 'includes/functions_download' . '.' . $phpEx);
$download_id = request_var('id', 0);
+$topic_id = $request->variable('topic_id', 0);
+$post_msg_id = $request->variable('post_msg_id', 0);
+$archive = $request->variable('archive', '.tar');
$mode = request_var('mode', '');
$thumbnail = request_var('t', false);
@@ -142,195 +158,268 @@ $user->session_begin(false);
$auth->acl($user->data);
$user->setup('viewtopic');
-if (!$download_id)
+if (!$config['allow_attachments'] && !$config['allow_pm_attach'])
{
send_status_line(404, 'Not Found');
- trigger_error('NO_ATTACHMENT_SELECTED');
+ trigger_error('ATTACHMENT_FUNCTIONALITY_DISABLED');
}
-if (!$config['allow_attachments'] && !$config['allow_pm_attach'])
+if ($download_id)
+{
+ // Attachment id (only 1 attachment)
+ $sql_where = "attach_id = $download_id";
+}
+else if ($post_msg_id)
+{
+ // Post id or private message id (multiple attachments)
+ $sql_where = "post_msg_id = $post_msg_id AND is_orphan = 0";
+}
+else if ($topic_id)
+{
+ // Topic id (multiple attachments)
+ $sql_where = "topic_id = $topic_id AND is_orphan = 0";
+}
+else
{
send_status_line(404, 'Not Found');
- trigger_error('ATTACHMENT_FUNCTIONALITY_DISABLED');
+ trigger_error('NO_ATTACHMENT_SELECTED');
}
-$sql = 'SELECT attach_id, in_message, post_msg_id, extension, is_orphan, poster_id, filetime
+$sql = 'SELECT attach_id, post_msg_id, topic_id, in_message, is_orphan, physical_filename, real_filename, extension, mimetype, filesize, filetime
FROM ' . ATTACHMENTS_TABLE . "
- WHERE attach_id = $download_id";
-$result = $db->sql_query_limit($sql, 1);
-$attachment = $db->sql_fetchrow($result);
+ WHERE $sql_where";
+$result = $db->sql_query($sql);
+
+$attachments = $attachment_ids = array();
+while ($row = $db->sql_fetchrow($result))
+{
+ $attachment_id = (int) $row['attach_id'];
+
+ $row['physical_filename'] = utf8_basename($row['physical_filename']);
+
+ $attachment_ids[$attachment_id] = $attachment_id;
+ $attachments[$attachment_id] = $row;
+}
$db->sql_freeresult($result);
-if (!$attachment)
+// Make $attachment the first of the attachments we fetched.
+$attachment = current($attachments);
+
+if (empty($attachments))
{
send_status_line(404, 'Not Found');
trigger_error('ERROR_NO_ATTACHMENT');
}
-
-if ((!$attachment['in_message'] && !$config['allow_attachments']) || ($attachment['in_message'] && !$config['allow_pm_attach']))
+else if (!download_allowed())
{
- send_status_line(404, 'Not Found');
- trigger_error('ATTACHMENT_FUNCTIONALITY_DISABLED');
+ send_status_line(403, 'Forbidden');
+ trigger_error($user->lang['LINKAGE_FORBIDDEN']);
}
-
-$row = array();
-
-if ($attachment['is_orphan'])
+else if ($download_id)
{
- // We allow admins having attachment permissions to see orphan attachments...
- $own_attachment = ($auth->acl_get('a_attach') || $attachment['poster_id'] == $user->data['user_id']) ? true : false;
+ // sizeof($attachments) == 1
- if (!$own_attachment || ($attachment['in_message'] && !$auth->acl_get('u_pm_download')) || (!$attachment['in_message'] && !$auth->acl_get('u_download')))
+ if (!$attachment['in_message'] && !$config['allow_attachments'] || $attachment['in_message'] && !$config['allow_pm_attach'])
{
send_status_line(404, 'Not Found');
- trigger_error('ERROR_NO_ATTACHMENT');
+ trigger_error('ATTACHMENT_FUNCTIONALITY_DISABLED');
}
- // Obtain all extensions...
- $extensions = $cache->obtain_attach_extensions(true);
-}
-else
-{
- if (!$attachment['in_message'])
+ if ($attachment['is_orphan'])
{
- //
- $sql = 'SELECT p.forum_id, f.forum_password, f.parent_id
- FROM ' . POSTS_TABLE . ' p, ' . FORUMS_TABLE . ' f
- WHERE p.post_id = ' . $attachment['post_msg_id'] . '
- AND p.forum_id = f.forum_id';
- $result = $db->sql_query_limit($sql, 1);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
-
- $f_download = $auth->acl_get('f_download', $row['forum_id']);
-
- if ($auth->acl_get('u_download') && $f_download)
- {
- if ($row && $row['forum_password'])
- {
- // Do something else ... ?
- login_forum_box($row);
- }
- }
- else
+ // We allow admins having attachment permissions to see orphan attachments...
+ $own_attachment = ($auth->acl_get('a_attach') || $attachment['poster_id'] == $user->data['user_id']) ? true : false;
+
+ if (!$own_attachment || ($attachment['in_message'] && !$auth->acl_get('u_pm_download')) || (!$attachment['in_message'] && !$auth->acl_get('u_download')))
{
- send_status_line(403, 'Forbidden');
- trigger_error('SORRY_AUTH_VIEW_ATTACH');
+ send_status_line(404, 'Not Found');
+ trigger_error('ERROR_NO_ATTACHMENT');
}
+
+ // Obtain all extensions...
+ $extensions = $cache->obtain_attach_extensions(true);
}
else
{
- $row['forum_id'] = false;
- if (!$auth->acl_get('u_pm_download'))
+ if (!$attachment['in_message'])
{
- send_status_line(403, 'Forbidden');
- trigger_error('SORRY_AUTH_VIEW_ATTACH');
+ phpbb_download_handle_forum_auth($db, $auth, $attachment['topic_id']);
+ }
+ else
+ {
+ // Attachment is in a private message.
+ $row['forum_id'] = false;
+ phpbb_download_handle_pm_auth($db, $auth, $user->data['user_id'], $attachment['post_msg_id']);
+ }
+
+ $extensions = array();
+ if (!extension_allowed($row['forum_id'], $attachment['extension'], $extensions))
+ {
+ send_status_line(404, 'Forbidden');
+ trigger_error(sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']));
}
+ }
+
+ $download_mode = (int) $extensions[$attachment['extension']]['download_mode'];
+ $display_cat = $extensions[$attachment['extension']]['display_cat'];
+
+ if (($display_cat == ATTACHMENT_CATEGORY_IMAGE || $display_cat == ATTACHMENT_CATEGORY_THUMB) && !$user->optionget('viewimg'))
+ {
+ $display_cat = ATTACHMENT_CATEGORY_NONE;
+ }
- // Check if the attachment is within the users scope...
- $sql = 'SELECT user_id, author_id
- FROM ' . PRIVMSGS_TO_TABLE . '
- WHERE msg_id = ' . $attachment['post_msg_id'];
- $result = $db->sql_query($sql);
+ if ($display_cat == ATTACHMENT_CATEGORY_FLASH && !$user->optionget('viewflash'))
+ {
+ $display_cat = ATTACHMENT_CATEGORY_NONE;
+ }
- $allowed = false;
- while ($user_row = $db->sql_fetchrow($result))
+ if ($thumbnail)
+ {
+ $attachment['physical_filename'] = 'thumb_' . $attachment['physical_filename'];
+ }
+ else if ($display_cat == ATTACHMENT_CATEGORY_NONE && !$attachment['is_orphan'] && !phpbb_http_byte_range($attachment['filesize']))
+ {
+ // Update download count
+ phpbb_increment_downloads($db, $attachment['attach_id']);
+ }
+
+ if ($display_cat == ATTACHMENT_CATEGORY_IMAGE && $mode === 'view' && (strpos($attachment['mimetype'], 'image') === 0) && ((strpos(strtolower($user->browser), 'msie') !== false) && (strpos(strtolower($user->browser), 'msie 8.0') === false)))
+ {
+ wrap_img_in_html(append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'id=' . $attachment['attach_id']), $attachment['real_filename']);
+ file_gc();
+ }
+ else
+ {
+ // Determine the 'presenting'-method
+ if ($download_mode == PHYSICAL_LINK)
{
- if ($user->data['user_id'] == $user_row['user_id'] || $user->data['user_id'] == $user_row['author_id'])
+ // This presenting method should no longer be used
+ if (!@is_dir($phpbb_root_path . $config['upload_path']))
{
- $allowed = true;
- break;
+ send_status_line(500, 'Internal Server Error');
+ trigger_error($user->lang['PHYSICAL_DOWNLOAD_NOT_POSSIBLE']);
}
- }
- $db->sql_freeresult($result);
- if (!$allowed)
+ redirect($phpbb_root_path . $config['upload_path'] . '/' . $attachment['physical_filename']);
+ file_gc();
+ }
+ else
{
- send_status_line(403, 'Forbidden');
- trigger_error('ERROR_NO_ATTACHMENT');
+ send_file_to_browser($attachment, $config['upload_path'], $display_cat);
+ file_gc();
}
}
+}
+else
+{
+ // sizeof($attachments) >= 1
+ if ($attachment['in_message'])
+ {
+ phpbb_download_handle_pm_auth($db, $auth, $user->data['user_id'], $attachment['post_msg_id']);
+ }
+ else
+ {
+ phpbb_download_handle_forum_auth($db, $auth, $attachment['topic_id']);
+ }
- // disallowed?
- $extensions = array();
- if (!extension_allowed($row['forum_id'], $attachment['extension'], $extensions))
+ if (!class_exists('compress'))
{
- send_status_line(404, 'Forbidden');
- trigger_error(sprintf($user->lang['EXTENSION_DISABLED_AFTER_POSTING'], $attachment['extension']));
+ require $phpbb_root_path . 'includes/functions_compress.' . $phpEx;
}
-}
-if (!download_allowed())
-{
- send_status_line(403, 'Forbidden');
- trigger_error($user->lang['LINKAGE_FORBIDDEN']);
-}
+ if (!in_array($archive, compress::methods()))
+ {
+ $archive = '.tar';
+ }
-$download_mode = (int) $extensions[$attachment['extension']]['download_mode'];
+ if ($post_msg_id)
+ {
+ if ($attachment['in_message'])
+ {
+ $sql = 'SELECT message_subject AS attach_subject
+ FROM ' . PRIVMSGS_TABLE . "
+ WHERE msg_id = $post_msg_id";
+ }
+ else
+ {
+ $sql = 'SELECT post_subject AS attach_subject, forum_id
+ FROM ' . POSTS_TABLE . "
+ WHERE post_id = $post_msg_id";
+ }
+ }
+ else
+ {
+ $sql = 'SELECT topic_title AS attach_subject, forum_id
+ FROM ' . TOPICS_TABLE . "
+ WHERE topic_id = $topic_id";
+ }
-// Fetching filename here to prevent sniffing of filename
-$sql = 'SELECT attach_id, is_orphan, in_message, post_msg_id, extension, physical_filename, real_filename, mimetype, filesize, filetime
- FROM ' . ATTACHMENTS_TABLE . "
- WHERE attach_id = $download_id";
-$result = $db->sql_query_limit($sql, 1);
-$attachment = $db->sql_fetchrow($result);
-$db->sql_freeresult($result);
+ $result = $db->sql_query($sql);
+ $row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
-if (!$attachment)
-{
- send_status_line(404, 'Not Found');
- trigger_error('ERROR_NO_ATTACHMENT');
-}
+ if (empty($row))
+ {
+ send_status_line(404, 'Not Found');
+ trigger_error('ERROR_NO_ATTACHMENT');
+ }
-$attachment['physical_filename'] = utf8_basename($attachment['physical_filename']);
-$display_cat = $extensions[$attachment['extension']]['display_cat'];
+ $clean_name = phpbb_download_clean_filename($row['attach_subject']);
+ $suffix = '_' . (($post_msg_id) ? $post_msg_id : $topic_id) . '_' . $clean_name;
+ $archive_name = 'attachments' . $suffix;
-if (($display_cat == ATTACHMENT_CATEGORY_IMAGE || $display_cat == ATTACHMENT_CATEGORY_THUMB) && !$user->optionget('viewimg'))
-{
- $display_cat = ATTACHMENT_CATEGORY_NONE;
-}
+ $store_name = 'att_' . time() . '_' . unique_id();
+ $archive_path = "{$phpbb_root_path}store/{$store_name}{$archive}";
-if ($display_cat == ATTACHMENT_CATEGORY_FLASH && !$user->optionget('viewflash'))
-{
- $display_cat = ATTACHMENT_CATEGORY_NONE;
-}
+ if ($archive === '.zip')
+ {
+ $compress = new compress_zip('w', $archive_path);
+ }
+ else
+ {
+ $compress = new compress_tar('w', $archive_path, $archive);
+ }
-if ($thumbnail)
-{
- $attachment['physical_filename'] = 'thumb_' . $attachment['physical_filename'];
-}
-else if (($display_cat == ATTACHMENT_CATEGORY_NONE/* || $display_cat == ATTACHMENT_CATEGORY_IMAGE*/) && !$attachment['is_orphan'] && !phpbb_http_byte_range($attachment['filesize']))
-{
- // Update download count
- $sql = 'UPDATE ' . ATTACHMENTS_TABLE . '
- SET download_count = download_count + 1
- WHERE attach_id = ' . $attachment['attach_id'];
- $db->sql_query($sql);
-}
+ $extensions = array();
+ $files_added = 0;
+ $forum_id = ($attachment['in_message']) ? false : (int) $row['forum_id'];
+ $disallowed = array();
-if ($display_cat == ATTACHMENT_CATEGORY_IMAGE && $mode === 'view' && (strpos($attachment['mimetype'], 'image') === 0) && ((strpos(strtolower($user->browser), 'msie') !== false) && (strpos(strtolower($user->browser), 'msie 8.0') === false)))
-{
- wrap_img_in_html(append_sid($phpbb_root_path . 'download/file.' . $phpEx, 'id=' . $attachment['attach_id']), $attachment['real_filename']);
- file_gc();
-}
-else
-{
- // Determine the 'presenting'-method
- if ($download_mode == PHYSICAL_LINK)
+ foreach ($attachments as $attach)
{
- // This presenting method should no longer be used
- if (!@is_dir($phpbb_root_path . $config['upload_path']))
+ if (!extension_allowed($forum_id, $attach['extension'], $extensions))
{
- send_status_line(500, 'Internal Server Error');
- trigger_error($user->lang['PHYSICAL_DOWNLOAD_NOT_POSSIBLE']);
+ $disallowed[$attach['extension']] = $attach['extension'];
+ continue;
+ }
+
+ $prefix = '';
+ if ($topic_id)
+ {
+ $prefix = $attach['post_msg_id'] . '_';
}
- redirect($phpbb_root_path . $config['upload_path'] . '/' . $attachment['physical_filename']);
- file_gc();
+ $compress->add_custom_file("{$phpbb_root_path}files/{$attach['physical_filename']}", "{$prefix}{$attach['real_filename']}");
+ $files_added++;
}
- else
+
+ $compress->close();
+
+ if ($files_added)
{
- send_file_to_browser($attachment, $config['upload_path'], $display_cat);
- file_gc();
+ phpbb_increment_downloads($db, $attachment_ids);
+ $compress->download($store_name, $archive_name);
}
+
+ unlink($archive_path);
+
+ if (!$files_added)
+ {
+ // None of the attachments had a valid extension
+ $disallowed = implode($user->lang['COMMA_SEPARATOR'], $disallowed);
+ send_status_line(404, 'Forbidden');
+ trigger_error($user->lang('EXTENSION_DISABLED_AFTER_POSTING', $disallowed));
+ }
+
+ file_gc();
}
diff --git a/phpBB/feed.php b/phpBB/feed.php
index fcf42a83ae..9b7ef3a575 100644
--- a/phpBB/feed.php
+++ b/phpBB/feed.php
@@ -254,16 +254,8 @@ function feed_format_date($time)
{
global $user;
- $zone_offset = (int) $user->timezone + (int) $user->dst;
-
- $sign = ($zone_offset < 0) ? '-' : '+';
- $time_offset = abs($zone_offset);
-
- $offset_seconds = $time_offset % 3600;
- $offset_minutes = $offset_seconds / 60;
- $offset_hours = ($time_offset - $offset_seconds) / 3600;
-
- $offset_string = sprintf("%s%02d:%02d", $sign, $offset_hours, $offset_minutes);
+ $zone_offset = $user->create_datetime()->getOffset();
+ $offset_string = phpbb_format_timezone_offset($zone_offset);
}
return gmdate("Y-m-d\TH:i:s", $time + $zone_offset) . $offset_string;
diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php
index abe304c282..eccc935a6e 100644
--- a/phpBB/includes/acp/acp_attachments.php
+++ b/phpBB/includes/acp/acp_attachments.php
@@ -98,7 +98,7 @@ class acp_attachments
}
$db->sql_freeresult($result);
- $l_legend_cat_images = $user->lang['SETTINGS_CAT_IMAGES'] . ' [' . $user->lang['ASSIGNED_GROUP'] . ': ' . ((!empty($s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE])) ? implode(', ', $s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE]) : $user->lang['NO_EXT_GROUP']) . ']';
+ $l_legend_cat_images = $user->lang['SETTINGS_CAT_IMAGES'] . ' [' . $user->lang['ASSIGNED_GROUP'] . ': ' . ((!empty($s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE])) ? implode($user->lang['COMMA_SEPARATOR'], $s_assigned_groups[ATTACHMENT_CATEGORY_IMAGE]) : $user->lang['NO_EXT_GROUP']) . ']';
$display_vars = array(
'title' => 'ACP_ATTACHMENT_SETTINGS',
@@ -917,7 +917,7 @@ class acp_attachments
$db->sql_query($sql);
add_log('admin', 'LOG_ATTACH_ORPHAN_DEL', implode(', ', $delete_files));
- $notify[] = sprintf($user->lang['LOG_ATTACH_ORPHAN_DEL'], implode(', ', $delete_files));
+ $notify[] = sprintf($user->lang['LOG_ATTACH_ORPHAN_DEL'], implode($user->lang['COMMA_SEPARATOR'], $delete_files));
}
$upload_list = array();
@@ -1074,7 +1074,7 @@ class acp_attachments
$error[] = $user->lang['FILES_GONE'];
}
add_log('admin', 'LOG_ATTACHMENTS_DELETED', implode(', ', $deleted_filenames));
- $notify[] = sprintf($user->lang['LOG_ATTACHMENTS_DELETED'], implode(', ', $deleted_filenames));
+ $notify[] = sprintf($user->lang['LOG_ATTACHMENTS_DELETED'], implode($user->lang['COMMA_SEPARATOR'], $deleted_filenames));
}
else
{
@@ -1222,12 +1222,14 @@ class acp_attachments
}
$db->sql_freeresult($result);
+ $base_url = $this->u_action . "&amp;$u_sort_param";
+ phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $num_files, $attachments_per_page, $start);
+
$template->assign_vars(array(
'TOTAL_FILES' => $num_files,
'TOTAL_SIZE' => get_formatted_filesize($total_size),
- 'PAGINATION' => generate_pagination($this->u_action . "&amp;$u_sort_param", $num_files, $attachments_per_page, $start, true),
- 'S_ON_PAGE' => on_page($num_files, $attachments_per_page, $start),
+ 'S_ON_PAGE' => phpbb_on_page($template, $user, $base_url, $num_files, $attachments_per_page, $start),
'S_LIMIT_DAYS' => $s_limit_days,
'S_SORT_KEY' => $s_sort_key,
'S_SORT_DIR' => $s_sort_dir)
diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php
index d537885ef1..322e1c55d8 100644
--- a/phpBB/includes/acp/acp_board.php
+++ b/phpBB/includes/acp/acp_board.php
@@ -53,12 +53,13 @@ class acp_board
'legend1' => 'ACP_BOARD_SETTINGS',
'sitename' => array('lang' => 'SITE_NAME', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => false),
'site_desc' => array('lang' => 'SITE_DESC', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => false),
+ 'site_home_url' => array('lang' => 'SITE_HOME_URL', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true),
+ 'site_home_text' => array('lang' => 'SITE_HOME_TEXT', 'validate' => 'string', 'type' => 'text:40:255', 'explain' => true),
'board_disable' => array('lang' => 'DISABLE_BOARD', 'validate' => 'bool', 'type' => 'custom', 'method' => 'board_disable', 'explain' => true),
'board_disable_msg' => false,
'default_lang' => array('lang' => 'DEFAULT_LANGUAGE', 'validate' => 'lang', 'type' => 'select', 'function' => 'language_select', 'params' => array('{CONFIG_VALUE}'), 'explain' => false),
'default_dateformat' => array('lang' => 'DEFAULT_DATE_FORMAT', 'validate' => 'string', 'type' => 'custom', 'method' => 'dateformat_select', 'explain' => true),
- 'board_timezone' => array('lang' => 'SYSTEM_TIMEZONE', 'validate' => 'string', 'type' => 'select', 'function' => 'tz_select', 'params' => array('{CONFIG_VALUE}', 1), 'explain' => true),
- 'board_dst' => array('lang' => 'SYSTEM_DST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
+ 'board_timezone' => array('lang' => 'SYSTEM_TIMEZONE', 'validate' => 'timezone', 'type' => 'custom', 'method' => 'timezone_select', 'explain' => true),
'default_style' => array('lang' => 'DEFAULT_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => false),
'override_user_style' => array('lang' => 'OVERRIDE_STYLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
@@ -897,6 +898,18 @@ class acp_board
'<br /><br /><input class="button2" type="submit" id="' . $key . '_enable" name="' . $key . '_enable" value="' . $user->lang['ALLOW_QUICK_REPLY_BUTTON'] . '" />';
}
+ /**
+ * Select guest timezone
+ */
+ function timezone_select($value, $key)
+ {
+ global $user;
+
+ $timezone_select = phpbb_timezone_select($user, $value, true);
+ $timezone_select['tz_select'];
+
+ return '<select name="config[' . $key . ']" id="' . $key . '">' . $timezone_select['tz_select'] . '</select>';
+ }
/**
* Select default dateformat
@@ -907,10 +920,14 @@ class acp_board
// Let the format_date function operate with the acp values
$old_tz = $user->timezone;
- $old_dst = $user->dst;
-
- $user->timezone = $config['board_timezone'] * 3600;
- $user->dst = $config['board_dst'] * 3600;
+ try
+ {
+ $user->timezone = new DateTimeZone($config['board_timezone']);
+ }
+ catch (Exception $e)
+ {
+ // If the board timezone is invalid, we just use the users timezone.
+ }
$dateformat_options = '';
@@ -930,7 +947,6 @@ class acp_board
// Reset users date options
$user->timezone = $old_tz;
- $user->dst = $old_dst;
return "<select name=\"dateoptions\" id=\"dateoptions\" onchange=\"if (this.value == 'custom') { document.getElementById('" . addslashes($key) . "').value = '" . addslashes($value) . "'; } else { document.getElementById('" . addslashes($key) . "').value = this.value; }\">$dateformat_options</select>
<input type=\"text\" name=\"config[$key]\" id=\"$key\" value=\"$value\" maxlength=\"30\" />";
diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php
new file mode 100644
index 0000000000..a0bcf62ecc
--- /dev/null
+++ b/phpBB/includes/acp/acp_extensions.php
@@ -0,0 +1,303 @@
+<?php
+/**
+*
+* @package acp
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* @package acp
+*/
+class acp_extensions
+{
+ var $u_action;
+
+ private $db;
+ private $config;
+ private $template;
+ private $user;
+
+ function main()
+ {
+ // Start the page
+ global $config, $user, $template, $request, $phpbb_extension_manager, $db, $phpbb_root_path, $phpEx;
+
+ $this->db = $db;
+ $this->config = $config;
+ $this->template = $template;
+ $this->user = $user;
+
+ $user->add_lang(array('install', 'acp/extensions'));
+
+ $this->page_title = 'ACP_EXTENSIONS';
+
+ $action = $request->variable('action', 'list');
+ $ext_name = $request->variable('ext_name', '');
+
+ // Cancel action
+ if ($request->is_set_post('cancel'))
+ {
+ $action = 'list';
+ $ext_name = '';
+ }
+
+ // If they've specified an extension, let's load the metadata manager and validate it.
+ if ($ext_name)
+ {
+ $md_manager = new phpbb_extension_metadata_manager($ext_name, $db, $phpbb_extension_manager, $phpbb_root_path, ".$phpEx", $template, $config);
+
+ try
+ {
+ $md_manager->get_metadata('all');
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ trigger_error($e);
+ }
+ }
+
+ // What are we doing?
+ switch ($action)
+ {
+ case 'list':
+ default:
+ $this->list_enabled_exts($phpbb_extension_manager);
+ $this->list_disabled_exts($phpbb_extension_manager);
+ $this->list_available_exts($phpbb_extension_manager);
+
+ $this->tpl_name = 'acp_ext_list';
+ break;
+
+ case 'enable_pre':
+ if (!$md_manager->validate_enable())
+ {
+ trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action));
+ }
+
+ if ($phpbb_extension_manager->enabled($ext_name))
+ {
+ redirect($this->u_action);
+ }
+
+ $this->tpl_name = 'acp_ext_enable';
+
+ $template->assign_vars(array(
+ 'PRE' => true,
+ 'U_ENABLE' => $this->u_action . '&amp;action=enable&amp;ext_name=' . urlencode($ext_name),
+ ));
+ break;
+
+ case 'enable':
+ if (!$md_manager->validate_enable())
+ {
+ trigger_error($user->lang['EXTENSION_NOT_AVAILABLE'] . adm_back_link($this->u_action));
+ }
+
+ if ($phpbb_extension_manager->enable_step($ext_name))
+ {
+ $template->assign_var('S_NEXT_STEP', true);
+
+ meta_refresh(0, $this->u_action . '&amp;action=enable&amp;ext_name=' . urlencode($ext_name));
+ }
+
+ $this->tpl_name = 'acp_ext_enable';
+
+ $template->assign_vars(array(
+ 'U_RETURN' => $this->u_action . '&amp;action=list',
+ ));
+ break;
+
+ case 'disable_pre':
+ if (!$phpbb_extension_manager->enabled($ext_name))
+ {
+ redirect($this->u_action);
+ }
+
+ $this->tpl_name = 'acp_ext_disable';
+
+ $template->assign_vars(array(
+ 'PRE' => true,
+ 'U_DISABLE' => $this->u_action . '&amp;action=disable&amp;ext_name=' . urlencode($ext_name),
+ ));
+ break;
+
+ case 'disable':
+ if ($phpbb_extension_manager->disable_step($ext_name))
+ {
+ $template->assign_var('S_NEXT_STEP', true);
+
+ meta_refresh(0, $this->u_action . '&amp;action=disable&amp;ext_name=' . urlencode($ext_name));
+ }
+
+ $this->tpl_name = 'acp_ext_disable';
+
+ $template->assign_vars(array(
+ 'U_RETURN' => $this->u_action . '&amp;action=list',
+ ));
+ break;
+
+ case 'purge_pre':
+ $this->tpl_name = 'acp_ext_purge';
+
+ $template->assign_vars(array(
+ 'PRE' => true,
+ 'U_PURGE' => $this->u_action . '&amp;action=purge&amp;ext_name=' . urlencode($ext_name),
+ ));
+ break;
+
+ case 'purge':
+ if ($phpbb_extension_manager->purge_step($ext_name))
+ {
+ $template->assign_var('S_NEXT_STEP', true);
+
+ meta_refresh(0, $this->u_action . '&amp;action=purge&amp;ext_name=' . urlencode($ext_name));
+ }
+
+ $this->tpl_name = 'acp_ext_purge';
+
+ $template->assign_vars(array(
+ 'U_RETURN' => $this->u_action . '&amp;action=list',
+ ));
+ break;
+
+ case 'details':
+ // Output it to the template
+ $md_manager->output_template_data();
+
+ $template->assign_var('U_BACK', $this->u_action . '&amp;action=list');
+
+ $this->tpl_name = 'acp_ext_details';
+ break;
+ }
+ }
+
+ /**
+ * Lists all the enabled extensions and dumps to the template
+ *
+ * @param $phpbb_extension_manager An instance of the extension manager
+ * @return null
+ */
+ public function list_enabled_exts(phpbb_extension_manager $phpbb_extension_manager)
+ {
+ foreach ($phpbb_extension_manager->all_enabled() as $name => $location)
+ {
+ $md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name, $this->template);
+
+ try
+ {
+ $this->template->assign_block_vars('enabled', array(
+ 'META_DISPLAY_NAME' => $md_manager->get_metadata('display-name'),
+
+ 'U_DETAILS' => $this->u_action . '&amp;action=details&amp;ext_name=' . urlencode($name),
+ ));
+
+ $this->output_actions('enabled', array(
+ 'DISABLE' => $this->u_action . '&amp;action=disable_pre&amp;ext_name=' . urlencode($name),
+ 'PURGE' => $this->u_action . '&amp;action=purge_pre&amp;ext_name=' . urlencode($name),
+ ));
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->template->assign_block_vars('disabled', array(
+ 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e),
+ ));
+ }
+ }
+ }
+
+ /**
+ * Lists all the disabled extensions and dumps to the template
+ *
+ * @param $phpbb_extension_manager An instance of the extension manager
+ * @return null
+ */
+ public function list_disabled_exts(phpbb_extension_manager $phpbb_extension_manager)
+ {
+ foreach ($phpbb_extension_manager->all_disabled() as $name => $location)
+ {
+ $md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name, $this->template);
+
+ try
+ {
+ $this->template->assign_block_vars('disabled', array(
+ 'META_DISPLAY_NAME' => $md_manager->get_metadata('display-name'),
+
+ 'U_DETAILS' => $this->u_action . '&amp;action=details&amp;ext_name=' . urlencode($name),
+ ));
+
+ $this->output_actions('disabled', array(
+ 'ENABLE' => $this->u_action . '&amp;action=enable_pre&amp;ext_name=' . urlencode($name),
+ 'PURGE' => $this->u_action . '&amp;action=purge_pre&amp;ext_name=' . urlencode($name),
+ ));
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->template->assign_block_vars('disabled', array(
+ 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e),
+ ));
+ }
+ }
+ }
+
+ /**
+ * Lists all the available extensions and dumps to the template
+ *
+ * @param $phpbb_extension_manager An instance of the extension manager
+ * @return null
+ */
+ public function list_available_exts(phpbb_extension_manager $phpbb_extension_manager)
+ {
+ $uninstalled = array_diff_key($phpbb_extension_manager->all_available(), $phpbb_extension_manager->all_configured());
+
+ foreach ($uninstalled as $name => $location)
+ {
+ $md_manager = $phpbb_extension_manager->create_extension_metadata_manager($name, $this->template);
+
+ try
+ {
+ $this->template->assign_block_vars('disabled', array(
+ 'META_DISPLAY_NAME' => $md_manager->get_metadata('display-name'),
+
+ 'U_DETAILS' => $this->u_action . '&amp;action=details&amp;ext_name=' . urlencode($name),
+ ));
+
+ $this->output_actions('disabled', array(
+ 'ENABLE' => $this->u_action . '&amp;action=enable_pre&amp;ext_name=' . urlencode($name),
+ ));
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->template->assign_block_vars('disabled', array(
+ 'META_DISPLAY_NAME' => $this->user->lang('EXTENSION_INVALID_LIST', $name, $e),
+ ));
+ }
+ }
+ }
+
+ /**
+ * Output actions to a block
+ *
+ * @param string $block
+ * @param array $actions
+ */
+ private function output_actions($block, $actions)
+ {
+ foreach ($actions as $lang => $url)
+ {
+ $this->template->assign_block_vars($block . '.actions', array(
+ 'L_ACTION' => $this->user->lang($lang),
+ 'U_ACTION' => $url,
+ ));
+ }
+ }
+}
diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php
index 3a3b2021eb..c6dbf5eb9c 100644
--- a/phpBB/includes/acp/acp_forums.php
+++ b/phpBB/includes/acp/acp_forums.php
@@ -25,7 +25,7 @@ class acp_forums
function main($id, $mode)
{
- global $db, $user, $auth, $template, $cache, $request;
+ global $db, $user, $auth, $template, $cache, $request, $phpbb_dispatcher;
global $config, $phpbb_admin_path, $phpbb_root_path, $phpEx;
$user->add_lang('acp/forums');
@@ -150,6 +150,17 @@ class acp_forums
'forum_password_unset' => request_var('forum_password_unset', false),
);
+ /**
+ * Request forum data and operate on it (parse texts, etc.)
+ *
+ * @event core.acp_manage_forums_request_data
+ * @var string action Type of the action: add|edit
+ * @var array forum_data Array with new forum data
+ * @since 3.1-A1
+ */
+ $vars = array('action', 'forum_data');
+ extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_request_data', compact($vars)));
+
// On add, add empty forum_options... else do not consider it (not updating it)
if ($action == 'add')
{
@@ -386,6 +397,9 @@ class acp_forums
$forum_data['forum_flags'] += (request_var('enable_quick_reply', false)) ? FORUM_FLAG_QUICK_REPLY : 0;
}
+ // Initialise $row, so we always have it in the event
+ $row = array();
+
// Show form to create/modify a forum
if ($action == 'edit')
{
@@ -453,6 +467,24 @@ class acp_forums
}
}
+ /**
+ * Initialise data before we display the add/edit form
+ *
+ * @event core.acp_manage_forums_initialise_data
+ * @var string action Type of the action: add|edit
+ * @var bool update Do we display the form only
+ * or did the user press submit
+ * @var int forum_id When editing: the forum id,
+ * when creating: the parent forum id
+ * @var array row Array with current forum data
+ * empty when creating new forum
+ * @var array forum_data Array with new forum data
+ * @var string parents_list List of parent options
+ * @since 3.1-A1
+ */
+ $vars = array('action', 'update', 'forum_id', 'row', 'forum_data', 'parents_list');
+ extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_initialise_data', compact($vars)));
+
$forum_rules_data = array(
'text' => $forum_data['forum_rules'],
'allow_bbcode' => true,
@@ -582,7 +614,7 @@ class acp_forums
$errors[] = $user->lang['FORUM_PASSWORD_OLD'];
}
- $template->assign_vars(array(
+ $template_data = array(
'S_EDIT_FORUM' => true,
'S_ERROR' => (sizeof($errors)) ? true : false,
'S_PARENT_ID' => $this->parent_id,
@@ -647,7 +679,31 @@ class acp_forums
'S_ENABLE_POST_REVIEW' => ($forum_data['forum_flags'] & FORUM_FLAG_POST_REVIEW) ? true : false,
'S_ENABLE_QUICK_REPLY' => ($forum_data['forum_flags'] & FORUM_FLAG_QUICK_REPLY) ? true : false,
'S_CAN_COPY_PERMISSIONS' => ($action != 'edit' || empty($forum_id) || ($auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth'))) ? true : false,
- ));
+ );
+
+ /**
+ * Modify forum template data before we display the form
+ *
+ * @event core.acp_manage_forums_display_form
+ * @var string action Type of the action: add|edit
+ * @var bool update Do we display the form only
+ * or did the user press submit
+ * @var int forum_id When editing: the forum id,
+ * when creating: the parent forum id
+ * @var array row Array with current forum data
+ * empty when creating new forum
+ * @var array forum_data Array with new forum data
+ * @var string parents_list List of parent options
+ * @var array errors Array of errors, if you add errors
+ * ensure to update the template variables
+ * S_ERROR and ERROR_MSG to display it
+ * @var array template_data Array with new forum data
+ * @since 3.1-A1
+ */
+ $vars = array('action', 'update', 'forum_id', 'row', 'forum_data', 'parents_list', 'errors', 'template_data');
+ extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_display_form', compact($vars)));
+
+ $template->assign_vars($template_data);
return;
@@ -872,10 +928,22 @@ class acp_forums
*/
function update_forum_data(&$forum_data)
{
- global $db, $user, $cache, $phpbb_root_path;
+ global $db, $user, $cache, $phpbb_root_path, $phpbb_dispatcher;
$errors = array();
+ /**
+ * Validate the forum data before we create/update the forum
+ *
+ * @event core.acp_manage_forums_validate_data
+ * @var array forum_data Array with new forum data
+ * @var array errors Array of errors, should be strings and not
+ * language key.
+ * @since 3.1-A1
+ */
+ $vars = array('forum_data', 'errors');
+ extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_validate_data', compact($vars)));
+
if ($forum_data['forum_name'] == '')
{
$errors[] = $user->lang['FORUM_NAME_EMPTY'];
@@ -968,7 +1036,22 @@ class acp_forums
}
unset($forum_data_sql['forum_password_unset']);
- if (!isset($forum_data_sql['forum_id']))
+ /**
+ * Remove invalid values from forum_data_sql that should not be updated
+ *
+ * @event core.acp_manage_forums_update_data_before
+ * @var array forum_data Array with forum data
+ * @var array forum_data_sql Array with data we are going to update
+ * If forum_data_sql[forum_id] is set, we update
+ * that forum, otherwise a new one is created.
+ * @since 3.1-A1
+ */
+ $vars = array('forum_data', 'forum_data_sql');
+ extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_before', compact($vars)));
+
+ $is_new_forum = !isset($forum_data_sql['forum_id']);
+
+ if ($is_new_forum)
{
// no forum_id means we're creating a new forum
unset($forum_data_sql['type_action']);
@@ -1239,6 +1322,22 @@ class acp_forums
add_log('admin', 'LOG_FORUM_EDIT', $forum_data['forum_name']);
}
+ /**
+ * Event after a forum was updated or created
+ *
+ * @event core.acp_manage_forums_update_data_after
+ * @var array forum_data Array with forum data
+ * @var array forum_data_sql Array with data we updated
+ * @var bool is_new_forum Did we create a forum or update one
+ * If you want to overwrite this value,
+ * ensure to set forum_data_sql[forum_id]
+ * @var array errors Array of errors, should be strings and not
+ * language key.
+ * @since 3.1-A1
+ */
+ $vars = array('forum_data', 'forum_data_sql', 'is_new_forum', 'errors');
+ extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_update_data_after', compact($vars)));
+
return $errors;
}
@@ -1247,7 +1346,7 @@ class acp_forums
*/
function move_forum($from_id, $to_id)
{
- global $db, $user;
+ global $db, $user, $phpbb_dispatcher;
$to_data = $moved_ids = $errors = array();
@@ -1259,10 +1358,30 @@ class acp_forums
if ($to_data['forum_type'] == FORUM_LINK)
{
$errors[] = $user->lang['PARENT_IS_LINK_FORUM'];
- return $errors;
}
}
+ /**
+ * Event when we move all children of one forum to another
+ *
+ * This event may be triggered, when a forum is deleted
+ *
+ * @event core.acp_manage_forums_move_children
+ * @var int from_id If of the current parent forum
+ * @var int to_id If of the new parent forum
+ * @var array errors Array of errors, should be strings and not
+ * language key.
+ * @since 3.1-A1
+ */
+ $vars = array('from_id', 'to_id', 'errors');
+ extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_children', compact($vars)));
+
+ // Return if there were errors
+ if (!empty($errors))
+ {
+ return $errors;
+ }
+
$moved_forums = get_forum_branch($from_id, 'children', 'descending');
$from_data = $moved_forums[0];
$diff = sizeof($moved_forums) * 2;
@@ -1342,7 +1461,30 @@ class acp_forums
*/
function move_forum_content($from_id, $to_id, $sync = true)
{
- global $db;
+ global $db, $phpbb_dispatcher;
+
+ $errors = array();
+
+ /**
+ * Event when we move content from one forum to another
+ *
+ * @event core.acp_manage_forums_move_children
+ * @var int from_id If of the current parent forum
+ * @var int to_id If of the new parent forum
+ * @var bool sync Shall we sync the "to"-forum's data
+ * @var array errors Array of errors, should be strings and not
+ * language key. If this array is not empty,
+ * The content will not be moved.
+ * @since 3.1-A1
+ */
+ $vars = array('from_id', 'to_id', 'sync', 'errors');
+ extract($phpbb_dispatcher->trigger_event('core.acp_manage_forums_move_content', compact($vars)));
+
+ // Return if there were errors
+ if (!empty($errors))
+ {
+ return $errors;
+ }
$table_ary = array(LOG_TABLE, POSTS_TABLE, TOPICS_TABLE, DRAFTS_TABLE, TOPICS_TRACK_TABLE);
diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php
index 607254adb5..f88fa76df1 100644
--- a/phpBB/includes/acp/acp_groups.php
+++ b/phpBB/includes/acp/acp_groups.php
@@ -682,13 +682,15 @@ class acp_groups
$s_action_options .= '<option value="' . $option . '">' . $user->lang['GROUP_' . $lang] . '</option>';
}
+ $base_url = $this->u_action . "&amp;action=$action&amp;g=$group_id";
+ phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total_members, $config['topics_per_page'], $start);
+
$template->assign_vars(array(
'S_LIST' => true,
'S_GROUP_SPECIAL' => ($group_row['group_type'] == GROUP_SPECIAL) ? true : false,
'S_ACTION_OPTIONS' => $s_action_options,
- 'S_ON_PAGE' => on_page($total_members, $config['topics_per_page'], $start),
- 'PAGINATION' => generate_pagination($this->u_action . "&amp;action=$action&amp;g=$group_id", $total_members, $config['topics_per_page'], $start, true),
+ 'S_ON_PAGE' => phpbb_on_page($template, $user, $base_url, $total_members, $config['topics_per_page'], $start),
'GROUP_NAME' => ($group_row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $group_row['group_name']] : $group_row['group_name'],
'U_ACTION' => $this->u_action . "&amp;g=$group_id",
diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php
index bfe17c5007..b7be92d477 100644
--- a/phpBB/includes/acp/acp_icons.php
+++ b/phpBB/includes/acp/acp_icons.php
@@ -927,10 +927,8 @@ class acp_icons
}
}
$db->sql_freeresult($result);
-
- $template->assign_var('PAGINATION',
- generate_pagination($this->u_action, $item_count, $config['smilies_per_page'], $pagination_start, true)
- );
+
+ phpbb_generate_template_pagination($template, $this->u_action, 'pagination', 'start', $item_count, $config['smilies_per_page'], $pagination_start);
}
/**
diff --git a/phpBB/includes/acp/acp_inactive.php b/phpBB/includes/acp/acp_inactive.php
index 78d6a0b2f3..1e23c2e6cf 100644
--- a/phpBB/includes/acp/acp_inactive.php
+++ b/phpBB/includes/acp/acp_inactive.php
@@ -136,6 +136,8 @@ class acp_inactive
add_log('admin', 'LOG_USER_ACTIVE', $row['username']);
add_log('user', $row['user_id'], 'LOG_USER_ACTIVE_USER');
}
+
+ trigger_error(sprintf($user->lang['LOG_INACTIVE_ACTIVATE'], implode($user->lang['COMMA_SEPARATOR'], $user_affected) . ' ' . adm_back_link($this->u_action)));
}
// For activate we really need to redirect, else a refresh can result in users being deactivated again
@@ -159,6 +161,8 @@ class acp_inactive
}
add_log('admin', 'LOG_INACTIVE_' . strtoupper($action), implode(', ', $user_affected));
+
+ trigger_error(sprintf($user->lang['LOG_INACTIVE_DELETE'], implode($user->lang['COMMA_SEPARATOR'], $user_affected) . ' ' . adm_back_link($this->u_action)));
}
else
{
@@ -230,7 +234,8 @@ class acp_inactive
$db->sql_query($sql);
add_log('admin', 'LOG_INACTIVE_REMIND', implode(', ', $usernames));
- unset($usernames);
+
+ trigger_error(sprintf($user->lang['LOG_INACTIVE_REMIND'], implode($user->lang['COMMA_SEPARATOR'], $usernames) . ' ' . adm_back_link($this->u_action)));
}
$db->sql_freeresult($result);
@@ -283,6 +288,9 @@ class acp_inactive
$option_ary += array('remind' => 'REMIND');
}
+ $base_url = $this->u_action . "&amp;$u_sort_param&amp;users_per_page=$per_page";
+ phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $inactive_count, $per_page, $start);
+
$template->assign_vars(array(
'S_INACTIVE_USERS' => true,
'S_INACTIVE_OPTIONS' => build_select($option_ary),
@@ -290,8 +298,8 @@ class acp_inactive
'S_LIMIT_DAYS' => $s_limit_days,
'S_SORT_KEY' => $s_sort_key,
'S_SORT_DIR' => $s_sort_dir,
- 'S_ON_PAGE' => on_page($inactive_count, $per_page, $start),
- 'PAGINATION' => generate_pagination($this->u_action . "&amp;$u_sort_param&amp;users_per_page=$per_page", $inactive_count, $per_page, $start, true),
+ 'S_ON_PAGE' => phpbb_on_page($template, $user, $base_url, $inactive_count, $per_page, $start),
+
'USERS_PER_PAGE' => $per_page,
'U_ACTION' => $this->u_action . "&amp;$u_sort_param&amp;users_per_page=$per_page&amp;start=$start",
diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php
index 2b19f93c75..2be1ccfc41 100644
--- a/phpBB/includes/acp/acp_language.php
+++ b/phpBB/includes/acp/acp_language.php
@@ -100,11 +100,25 @@ class acp_language
switch ($method)
{
case 'ftp':
- $transfer = new ftp(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', ''));
+ $transfer = new ftp(
+ request_var('host', ''),
+ request_var('username', ''),
+ htmlspecialchars_decode($request->untrimmed_variable('password', '')),
+ request_var('root_path', ''),
+ request_var('port', ''),
+ request_var('timeout', '')
+ );
break;
case 'ftp_fsock':
- $transfer = new ftp_fsock(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', ''));
+ $transfer = new ftp_fsock(
+ request_var('host', ''),
+ request_var('username', ''),
+ htmlspecialchars_decode($request->untrimmed_variable('password', '')),
+ request_var('root_path', ''),
+ request_var('port', ''),
+ request_var('timeout', '')
+ );
break;
default:
@@ -404,7 +418,14 @@ class acp_language
trigger_error($user->lang['INVALID_UPLOAD_METHOD'], E_USER_ERROR);
}
- $transfer = new $method(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', ''));
+ $transfer = new $method(
+ request_var('host', ''),
+ request_var('username', ''),
+ htmlspecialchars_decode($request->untrimmed_variable('password', '')),
+ request_var('root_path', ''),
+ request_var('port', ''),
+ request_var('timeout', '')
+ );
if (($result = $transfer->open_session()) !== true)
{
diff --git a/phpBB/includes/acp/acp_logs.php b/phpBB/includes/acp/acp_logs.php
index 6b67175220..4538633d6c 100644
--- a/phpBB/includes/acp/acp_logs.php
+++ b/phpBB/includes/acp/acp_logs.php
@@ -129,13 +129,15 @@ class acp_logs
$log_count = 0;
$start = view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, 0, 0, $sql_where, $sql_sort, $keywords);
+ $base_url = $this->u_action . "&amp;$u_sort_param$keywords_param";
+ phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start);
+
$template->assign_vars(array(
'L_TITLE' => $l_title,
'L_EXPLAIN' => $l_title_explain,
'U_ACTION' => $this->u_action . "&amp;$u_sort_param$keywords_param&amp;start=$start",
- 'S_ON_PAGE' => on_page($log_count, $config['topics_per_page'], $start),
- 'PAGINATION' => generate_pagination($this->u_action . "&amp;$u_sort_param$keywords_param", $log_count, $config['topics_per_page'], $start, true),
+ 'S_ON_PAGE' => phpbb_on_page($template, $user, $base_url, $log_count, $config['topics_per_page'], $start),
'S_LIMIT_DAYS' => $s_limit_days,
'S_SORT_KEY' => $s_sort_key,
diff --git a/phpBB/includes/acp/acp_permissions.php b/phpBB/includes/acp/acp_permissions.php
index d728744c04..dd071074de 100644
--- a/phpBB/includes/acp/acp_permissions.php
+++ b/phpBB/includes/acp/acp_permissions.php
@@ -497,7 +497,7 @@ class acp_permissions
$template->assign_vars(array(
'S_FORUM_NAMES' => (sizeof($forum_names)) ? true : false,
- 'FORUM_NAMES' => implode(', ', $forum_names))
+ 'FORUM_NAMES' => implode($user->lang['COMMA_SEPARATOR'], $forum_names))
);
}
diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php
index 3ffffd3047..849160f1fa 100644
--- a/phpBB/includes/acp/acp_profile.php
+++ b/phpBB/includes/acp/acp_profile.php
@@ -383,6 +383,7 @@ class acp_profile
$field_row = array_merge($default_values[$field_type], array(
'field_ident' => str_replace(' ', '_', utf8_clean_string(request_var('field_ident', '', true))),
'field_required' => 0,
+ 'field_show_novalue'=> 0,
'field_hide' => 0,
'field_show_profile'=> 0,
'field_no_view' => 0,
@@ -399,7 +400,7 @@ class acp_profile
// $exclude contains the data we gather in each step
$exclude = array(
- 1 => array('field_ident', 'lang_name', 'lang_explain', 'field_option_none', 'field_show_on_reg', 'field_show_on_pm', 'field_show_on_vt', 'field_required', 'field_hide', 'field_show_profile', 'field_no_view'),
+ 1 => array('field_ident', 'lang_name', 'lang_explain', 'field_option_none', 'field_show_on_reg', 'field_show_on_pm', 'field_show_on_vt', 'field_required', 'field_show_novalue', 'field_hide', 'field_show_profile', 'field_no_view'),
2 => array('field_length', 'field_maxlen', 'field_minlen', 'field_validation', 'field_novalue', 'field_default_value'),
3 => array('l_lang_name', 'l_lang_explain', 'l_lang_default_value', 'l_lang_options')
);
@@ -424,6 +425,7 @@ class acp_profile
// Visibility Options...
$visibility_ary = array(
'field_required',
+ 'field_show_novalue',
'field_show_on_reg',
'field_show_on_pm',
'field_show_on_vt',
@@ -779,6 +781,7 @@ class acp_profile
$template->assign_vars(array(
'S_STEP_ONE' => true,
'S_FIELD_REQUIRED' => ($cp->vars['field_required']) ? true : false,
+ 'S_FIELD_SHOW_NOVALUE'=> ($cp->vars['field_show_novalue']) ? true : false,
'S_SHOW_ON_REG' => ($cp->vars['field_show_on_reg']) ? true : false,
'S_SHOW_ON_PM' => ($cp->vars['field_show_on_pm']) ? true : false,
'S_SHOW_ON_VT' => ($cp->vars['field_show_on_vt']) ? true : false,
@@ -1096,6 +1099,7 @@ class acp_profile
'field_default_value' => $cp->vars['field_default_value'],
'field_validation' => $cp->vars['field_validation'],
'field_required' => $cp->vars['field_required'],
+ 'field_show_novalue' => $cp->vars['field_show_novalue'],
'field_show_on_reg' => $cp->vars['field_show_on_reg'],
'field_show_on_pm' => $cp->vars['field_show_on_pm'],
'field_show_on_vt' => $cp->vars['field_show_on_vt'],
diff --git a/phpBB/includes/acp/acp_reasons.php b/phpBB/includes/acp/acp_reasons.php
index 479fcfba81..71e9108c2c 100644
--- a/phpBB/includes/acp/acp_reasons.php
+++ b/phpBB/includes/acp/acp_reasons.php
@@ -113,7 +113,7 @@ class acp_reasons
$result = $db->sql_query($sql);
$max_order = (int) $db->sql_fetchfield('max_reason_order');
$db->sql_freeresult($result);
-
+
$sql_ary = array(
'reason_title' => (string) $reason_row['reason_title'],
'reason_description' => (string) $reason_row['reason_description'],
@@ -171,14 +171,14 @@ class acp_reasons
'U_ACTION' => $this->u_action . "&amp;id=$reason_id&amp;action=$action",
'U_BACK' => $this->u_action,
'ERROR_MSG' => (sizeof($error)) ? implode('<br />', $error) : '',
-
+
'REASON_TITLE' => $reason_row['reason_title'],
'REASON_DESCRIPTION' => $reason_row['reason_description'],
'TRANSLATED_TITLE' => ($translated) ? $user->lang['report_reasons']['TITLE'][strtoupper($reason_row['reason_title'])] : '',
'TRANSLATED_DESCRIPTION'=> ($translated) ? $user->lang['report_reasons']['DESCRIPTION'][strtoupper($reason_row['reason_title'])] : '',
- 'S_AVAILABLE_TITLES' => implode(', ', array_map('htmlspecialchars', array_keys($user->lang['report_reasons']['TITLE']))),
+ 'S_AVAILABLE_TITLES' => implode($user->lang['COMMA_SEPARATOR'], array_map('htmlspecialchars', array_keys($user->lang['report_reasons']['TITLE']))),
'S_EDIT_REASON' => true,
'S_TRANSLATED' => $translated,
'S_ERROR' => (sizeof($error)) ? true : false,
@@ -303,7 +303,7 @@ class acp_reasons
do
{
++$order;
-
+
if ($row['reason_order'] != $order)
{
$sql = 'UPDATE ' . REPORTS_REASONS_TABLE . "
diff --git a/phpBB/includes/acp/acp_search.php b/phpBB/includes/acp/acp_search.php
index 54a3e7aaa1..6618e2c3f9 100644
--- a/phpBB/includes/acp/acp_search.php
+++ b/phpBB/includes/acp/acp_search.php
@@ -596,16 +596,16 @@ class acp_search
*/
function init_search($type, &$search, &$error)
{
- global $phpbb_root_path, $phpEx, $user;
+ global $phpbb_root_path, $phpEx, $user, $auth, $config, $db;
- if (!class_exists($type) || !method_exists($type, 'get_name'))
+ if (!class_exists($type) || !method_exists($type, 'keyword_search'))
{
$error = $user->lang['NO_SUCH_SEARCH_MODULE'];
return $error;
}
$error = false;
- $search = new $type($error);
+ $search = new $type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
return $error;
}
diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php
index 943bfe6a6f..db77825ae7 100644
--- a/phpBB/includes/acp/acp_styles.php
+++ b/phpBB/includes/acp/acp_styles.php
@@ -36,7 +36,7 @@ class acp_styles
protected $cache;
protected $auth;
protected $phpbb_root_path;
- protected $phpEx;
+ protected $php_ext;
public function main($id, $mode)
{
@@ -50,12 +50,12 @@ class acp_styles
$this->auth = $auth;
$this->config = $config;
$this->phpbb_root_path = $phpbb_root_path;
- $this->phpEx = $phpEx;
+ $this->php_ext = $phpEx;
$this->default_style = $config['default_style'];
$this->styles_path = $this->phpbb_root_path . $this->styles_path_absolute . '/';
- $this->u_base_action = append_sid("{$phpbb_admin_path}index.$phpEx", "i={$id}");
+ $this->u_base_action = append_sid("{$phpbb_admin_path}index.{$this->php_ext}", "i={$id}");
$this->s_hidden_fields = array(
'mode' => $mode,
);
@@ -939,7 +939,7 @@ class acp_styles
// Preview
$actions[] = array(
- 'U_ACTION' => append_sid($this->phpbb_root_path . 'index.' . $this->phpEx, 'style=' . $style['style_id']),
+ 'U_ACTION' => append_sid($this->phpbb_root_path . 'index.' . $this->php_ext, 'style=' . $style['style_id']),
'L_ACTION' => $this->user->lang['PREVIEW']
);
}
diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php
index 17687b05c7..985a12d9ce 100644
--- a/phpBB/includes/acp/acp_users.php
+++ b/phpBB/includes/acp/acp_users.php
@@ -32,6 +32,7 @@ class acp_users
{
global $config, $db, $user, $auth, $template, $cache;
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $table_prefix, $file_uploads;
+ global $phpbb_dispatcher, $request;
$user->add_lang(array('posting', 'ucp', 'acp/users'));
$this->tpl_name = 'acp_users';
@@ -749,6 +750,19 @@ class acp_users
}
break;
+
+ default:
+ /**
+ * Run custom quicktool code
+ *
+ * @event core.acp_users_overview_run_quicktool
+ * @var array user_row Current user data
+ * @var string action Quick tool that should be run
+ * @since 3.1-A1
+ */
+ $vars = array('action', 'user_row');
+ extract($phpbb_dispatcher->trigger_event('core.acp_users_overview_run_quicktool', compact($vars)));
+ break;
}
// Handle registration info updates
@@ -756,8 +770,8 @@ class acp_users
'username' => utf8_normalize_nfc(request_var('user', $user_row['username'], true)),
'user_founder' => request_var('user_founder', ($user_row['user_type'] == USER_FOUNDER) ? 1 : 0),
'email' => strtolower(request_var('user_email', $user_row['user_email'])),
- 'new_password' => request_var('new_password', '', true),
- 'password_confirm' => request_var('password_confirm', '', true),
+ 'new_password' => $request->variable('new_password', '', true),
+ 'password_confirm' => $request->variable('password_confirm', '', true),
);
// Validation data - we do not check the password complexity setting here
@@ -855,6 +869,18 @@ class acp_users
}
}
+ /**
+ * Modify user data before we update it
+ *
+ * @event core.acp_users_overview_modify_data
+ * @var array user_row Current user data
+ * @var array data Submitted user data
+ * @var array sql_ary User data we udpate
+ * @since 3.1-A1
+ */
+ $vars = array('user_row', 'data', 'sql_ary');
+ extract($phpbb_dispatcher->trigger_event('core.acp_users_overview_modify_data', compact($vars)));
+
if ($update_username !== false)
{
$sql_ary['username'] = $update_username;
@@ -945,12 +971,6 @@ class acp_users
}
}
- $s_action_options = '<option class="sep" value="">' . $user->lang['SELECT_OPTION'] . '</option>';
- foreach ($quick_tool_ary as $value => $lang)
- {
- $s_action_options .= '<option value="' . $value . '">' . $user->lang['USER_ADMIN_' . $lang] . '</option>';
- }
-
if ($config['load_onlinetrack'])
{
$sql = 'SELECT MAX(session_time) AS session_time, MIN(session_viewonline) AS session_viewonline
@@ -965,6 +985,23 @@ class acp_users
unset($row);
}
+ /**
+ * Add additional quick tool options and overwrite user data
+ *
+ * @event core.acp_users_display_overview
+ * @var array user_row Array with user data
+ * @var array quick_tool_ary Ouick tool options
+ * @since 3.1-A1
+ */
+ $vars = array('user_row', 'quick_tool_ary');
+ extract($phpbb_dispatcher->trigger_event('core.acp_users_display_overview', compact($vars)));
+
+ $s_action_options = '<option class="sep" value="">' . $user->lang['SELECT_OPTION'] . '</option>';
+ foreach ($quick_tool_ary as $value => $lang)
+ {
+ $s_action_options .= '<option value="' . $value . '">' . $user->lang['USER_ADMIN_' . $lang] . '</option>';
+ }
+
$last_visit = (!empty($user_row['session_time'])) ? $user_row['session_time'] : $user_row['user_lastvisit'];
$inactive_reason = '';
@@ -1120,10 +1157,12 @@ class acp_users
$log_count = 0;
$start = view_log('user', $log_data, $log_count, $config['topics_per_page'], $start, 0, 0, $user_id, $sql_where, $sql_sort);
+ $base_url = $this->u_action . "&amp;u=$user_id&amp;$u_sort_param";
+ phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start);
+
$template->assign_vars(array(
'S_FEEDBACK' => true,
- 'S_ON_PAGE' => on_page($log_count, $config['topics_per_page'], $start),
- 'PAGINATION' => generate_pagination($this->u_action . "&amp;u=$user_id&amp;$u_sort_param", $log_count, $config['topics_per_page'], $start, true),
+ 'S_ON_PAGE' => phpbb_on_page($template, $user, $base_url, $log_count, $config['topics_per_page'], $start),
'S_LIMIT_DAYS' => $s_limit_days,
'S_SORT_KEY' => $s_sort_key,
@@ -1458,9 +1497,8 @@ class acp_users
$data = array(
'dateformat' => utf8_normalize_nfc(request_var('dateformat', $user_row['user_dateformat'], true)),
'lang' => basename(request_var('lang', $user_row['user_lang'])),
- 'tz' => request_var('tz', (float) $user_row['user_timezone']),
+ 'tz' => request_var('tz', $user_row['user_timezone']),
'style' => request_var('style', $user_row['user_style']),
- 'dst' => request_var('dst', $user_row['user_dst']),
'viewemail' => request_var('viewemail', $user_row['user_allow_viewemail']),
'massemail' => request_var('massemail', $user_row['user_allow_massemail']),
'hideonline' => request_var('hideonline', !$user_row['user_allow_viewonline']),
@@ -1495,7 +1533,7 @@ class acp_users
$error = validate_data($data, array(
'dateformat' => array('string', false, 1, 30),
'lang' => array('match', false, '#^[a-z_\-]{2,}$#i'),
- 'tz' => array('num', false, -14, 14),
+ 'tz' => array('timezone'),
'topic_sk' => array('string', false, 1, 1),
'topic_sd' => array('string', false, 1, 1),
@@ -1531,7 +1569,6 @@ class acp_users
'user_notify_type' => $data['notifymethod'],
'user_notify_pm' => $data['notifypm'],
- 'user_dst' => $data['dst'],
'user_dateformat' => $data['dateformat'],
'user_lang' => $data['lang'],
'user_timezone' => $data['tz'],
@@ -1641,6 +1678,7 @@ class acp_users
${'s_sort_' . $sort_option . '_dir'} .= '</select>';
}
+ $timezone_selects = phpbb_timezone_select($user, $data['tz'], true);
$template->assign_vars(array(
'S_PREFS' => true,
'S_JABBER_DISABLED' => ($config['jab_enable'] && $user_row['user_jabber'] && @extension_loaded('xml')) ? false : true,
@@ -1654,7 +1692,6 @@ class acp_users
'NOTIFY_BOTH' => ($data['notifymethod'] == NOTIFY_BOTH) ? true : false,
'NOTIFY_PM' => $data['notifypm'],
'POPUP_PM' => $data['popuppm'],
- 'DST' => $data['dst'],
'BBCODE' => $data['bbcode'],
'SMILIES' => $data['smilies'],
'ATTACH_SIG' => $data['sig'],
@@ -1681,7 +1718,8 @@ class acp_users
'S_LANG_OPTIONS' => language_select($data['lang']),
'S_STYLE_OPTIONS' => style_select($data['style']),
- 'S_TZ_OPTIONS' => tz_select($data['tz'], true),
+ 'S_TZ_OPTIONS' => $timezone_selects['tz_select'],
+ 'S_TZ_DATE_OPTIONS' => $timezone_selects['tz_dates'],
)
);
@@ -1942,7 +1980,7 @@ class acp_users
$message = (sizeof($log_attachments) == 1) ? $user->lang['ATTACHMENT_DELETED'] : $user->lang['ATTACHMENTS_DELETED'];
- add_log('admin', 'LOG_ATTACHMENTS_DELETED', implode(', ', $log_attachments));
+ add_log('admin', 'LOG_ATTACHMENTS_DELETED', implode($user->lang['COMMA_SEPARATOR'], $log_attachments));
trigger_error($message . adm_back_link($this->u_action . '&amp;u=' . $user_id));
}
else
@@ -2035,14 +2073,15 @@ class acp_users
}
$db->sql_freeresult($result);
+ $base_url = $this->u_action . "&amp;u=$user_id&amp;sk=$sort_key&amp;sd=$sort_dir";
+ phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start);
+
$template->assign_vars(array(
'S_ATTACHMENTS' => true,
- 'S_ON_PAGE' => on_page($num_attachments, $config['topics_per_page'], $start),
+ 'S_ON_PAGE' => phpbb_on_page($template, $user, $base_url, $num_attachments, $config['topics_per_page'], $start),
'S_SORT_KEY' => $s_sort_key,
'S_SORT_DIR' => $s_sort_dir,
-
- 'PAGINATION' => generate_pagination($this->u_action . "&amp;u=$user_id&amp;sk=$sort_key&amp;sd=$sort_dir", $num_attachments, $config['topics_per_page'], $start, true))
- );
+ ));
break;
diff --git a/phpBB/includes/acp/auth.php b/phpBB/includes/acp/auth.php
index 7d9fd267ff..6b1da46a12 100644
--- a/phpBB/includes/acp/auth.php
+++ b/phpBB/includes/acp/auth.php
@@ -529,8 +529,8 @@ class auth_admin extends phpbb_auth
'NAME' => $ug_name,
'CATEGORIES' => implode('</th><th>', $categories),
- 'USER_GROUPS_DEFAULT' => ($user_mode == 'user' && isset($user_groups_default[$ug_id]) && sizeof($user_groups_default[$ug_id])) ? implode(', ', $user_groups_default[$ug_id]) : '',
- 'USER_GROUPS_CUSTOM' => ($user_mode == 'user' && isset($user_groups_custom[$ug_id]) && sizeof($user_groups_custom[$ug_id])) ? implode(', ', $user_groups_custom[$ug_id]) : '',
+ 'USER_GROUPS_DEFAULT' => ($user_mode == 'user' && isset($user_groups_default[$ug_id]) && sizeof($user_groups_default[$ug_id])) ? implode($user->lang['COMMA_SEPARATOR'], $user_groups_default[$ug_id]) : '',
+ 'USER_GROUPS_CUSTOM' => ($user_mode == 'user' && isset($user_groups_custom[$ug_id]) && sizeof($user_groups_custom[$ug_id])) ? implode($user->lang['COMMA_SEPARATOR'], $user_groups_custom[$ug_id]) : '',
'L_ACL_TYPE' => $l_acl_type,
'S_LOCAL' => ($local) ? true : false,
diff --git a/phpBB/includes/acp/info/acp_extensions.php b/phpBB/includes/acp/info/acp_extensions.php
new file mode 100644
index 0000000000..f5953fb1dd
--- /dev/null
+++ b/phpBB/includes/acp/info/acp_extensions.php
@@ -0,0 +1,34 @@
+<?php
+/**
+*
+* @package acp
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @package module_install
+*/
+class acp_extensions_info
+{
+ function module()
+ {
+ return array(
+ 'filename' => 'acp_extensions',
+ 'title' => 'ACP_EXTENSIONS',
+ 'version' => '1.0.0',
+ 'modes' => array(
+ 'main' => array('title' => 'ACP_EXTENSIONS', 'auth' => 'acl_a_extensions', 'cat' => array('ACP_GENERAL_TASKS')),
+ ),
+ );
+ }
+
+ function install()
+ {
+ }
+
+ function uninstall()
+ {
+ }
+}
diff --git a/phpBB/includes/auth/auth_db.php b/phpBB/includes/auth/auth_db.php
index 76790e4dad..ac944532a5 100644
--- a/phpBB/includes/auth/auth_db.php
+++ b/phpBB/includes/auth/auth_db.php
@@ -41,6 +41,10 @@ function login_db($username, $password, $ip = '', $browser = '', $forwarded_for
global $db, $config;
global $request;
+ // Auth plugins get the password untrimmed.
+ // For compatibility we trim() here.
+ $password = trim($password);
+
// do not allow empty password
if (!$password)
{
diff --git a/phpBB/includes/cache/driver/file.php b/phpBB/includes/cache/driver/file.php
index 0d3b06f621..f64a9e3ea8 100644
--- a/phpBB/includes/cache/driver/file.php
+++ b/phpBB/includes/cache/driver/file.php
@@ -364,7 +364,7 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base
/**
* Save sql query
*/
- function sql_save($query, &$query_result, $ttl)
+ function sql_save($query, $query_result, $ttl)
{
global $db;
@@ -385,6 +385,8 @@ class phpbb_cache_driver_file extends phpbb_cache_driver_base
{
$query_result = $query_id;
}
+
+ return $query_id;
}
/**
diff --git a/phpBB/includes/cache/driver/interface.php b/phpBB/includes/cache/driver/interface.php
index 313a2d4b31..847ba97262 100644
--- a/phpBB/includes/cache/driver/interface.php
+++ b/phpBB/includes/cache/driver/interface.php
@@ -75,7 +75,7 @@ interface phpbb_cache_driver_interface
/**
* Save sql query
*/
- public function sql_save($query, &$query_result, $ttl);
+ public function sql_save($query, $query_result, $ttl);
/**
* Ceck if a given sql query exist in cache
diff --git a/phpBB/includes/cache/driver/memory.php b/phpBB/includes/cache/driver/memory.php
index e25c9229a1..e0771ab1d3 100644
--- a/phpBB/includes/cache/driver/memory.php
+++ b/phpBB/includes/cache/driver/memory.php
@@ -19,7 +19,7 @@ if (!defined('IN_PHPBB'))
* ACM Abstract Memory Class
* @package acm
*/
-class phpbb_cache_driver_memory extends phpbb_cache_driver_base
+abstract class phpbb_cache_driver_memory extends phpbb_cache_driver_base
{
var $key_prefix;
@@ -280,7 +280,7 @@ class phpbb_cache_driver_memory extends phpbb_cache_driver_base
/**
* Save sql query
*/
- function sql_save($query, &$query_result, $ttl)
+ function sql_save($query, $query_result, $ttl)
{
global $db;
@@ -335,6 +335,8 @@ class phpbb_cache_driver_memory extends phpbb_cache_driver_base
$this->_write('sql_' . $hash, $this->sql_rowset[$query_id], $ttl);
$query_result = $query_id;
+
+ return $query_id;
}
/**
diff --git a/phpBB/includes/cache/driver/null.php b/phpBB/includes/cache/driver/null.php
index c143803d0e..df2c6c026f 100644
--- a/phpBB/includes/cache/driver/null.php
+++ b/phpBB/includes/cache/driver/null.php
@@ -107,7 +107,7 @@ class phpbb_cache_driver_null extends phpbb_cache_driver_base
/**
* Save sql query
*/
- function sql_save($query, &$query_result, $ttl)
+ function sql_save($query, $query_result, $ttl)
{
}
diff --git a/phpBB/includes/cache/driver/redis.php b/phpBB/includes/cache/driver/redis.php
index a768885962..a768885962 100755..100644
--- a/phpBB/includes/cache/driver/redis.php
+++ b/phpBB/includes/cache/driver/redis.php
diff --git a/phpBB/includes/cache/factory.php b/phpBB/includes/cache/factory.php
deleted file mode 100644
index 01c4d0b901..0000000000
--- a/phpBB/includes/cache/factory.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-/**
-*
-* @package acm
-* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
-*
-*/
-
-/**
-* @ignore
-*/
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
-* @package acm
-*/
-class phpbb_cache_factory
-{
- private $acm_type;
-
- public function __construct($acm_type)
- {
- $this->acm_type = $acm_type;
- }
-
- public function get_driver()
- {
- $class_name = 'phpbb_cache_driver_' . $this->acm_type;
- return new $class_name();
- }
-
- public function get_service()
- {
- $driver = $this->get_driver();
- $service = new phpbb_cache_service($driver);
- return $service;
- }
-}
diff --git a/phpBB/includes/cache/service.php b/phpBB/includes/cache/service.php
index 37f32aa753..e63ec6e33a 100644
--- a/phpBB/includes/cache/service.php
+++ b/phpBB/includes/cache/service.php
@@ -332,27 +332,22 @@ class phpbb_cache_service
$parsed_array = array();
}
- $reparse = false;
$filename = $phpbb_root_path . 'styles/' . $style['style_path'] . '/style.cfg';
if (!file_exists($filename))
{
- continue;
+ return $parsed_array;
}
if (!isset($parsed_array['filetime']) || (($config['load_tplcompile'] && @filemtime($filename) > $parsed_array['filetime'])))
{
- $reparse = true;
- }
-
- // Re-parse cfg file
- if ($reparse)
- {
+ // Re-parse cfg file
$parsed_array = parse_cfg_file($filename);
$parsed_array['filetime'] = @filemtime($filename);
$this->driver->put('_cfg_' . $style['style_path'], $parsed_array);
}
+
return $parsed_array;
}
diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php
index 66d2a003c6..68af41ab20 100644
--- a/phpBB/includes/constants.php
+++ b/phpBB/includes/constants.php
@@ -260,6 +260,7 @@ define('SESSIONS_TABLE', $table_prefix . 'sessions');
define('SESSIONS_KEYS_TABLE', $table_prefix . 'sessions_keys');
define('SITELIST_TABLE', $table_prefix . 'sitelist');
define('SMILIES_TABLE', $table_prefix . 'smilies');
+define('SPHINX_TABLE', $table_prefix . 'sphinx');
define('STYLES_TABLE', $table_prefix . 'styles');
define('STYLES_TEMPLATE_TABLE', $table_prefix . 'styles_template');
define('STYLES_TEMPLATE_DATA_TABLE',$table_prefix . 'styles_template_data');
diff --git a/phpBB/includes/cron/manager.php b/phpBB/includes/cron/manager.php
index 7a78a1b054..ccaa4f3764 100644
--- a/phpBB/includes/cron/manager.php
+++ b/phpBB/includes/cron/manager.php
@@ -32,31 +32,35 @@ class phpbb_cron_manager
*/
protected $tasks = array();
+ protected $phpbb_root_path;
+ protected $php_ext;
+
/**
* Constructor. Loads all available tasks.
*
- * @param array|Traversable $task_names Provides an iterable set of task names
+ * @param array|Traversable $tasks Provides an iterable set of task names
*/
- public function __construct($task_names)
+ public function __construct($tasks, $phpbb_root_path, $php_ext)
{
- $this->load_tasks($task_names);
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $php_ext;
+
+ $this->load_tasks($tasks);
}
/**
* Loads tasks given by name, wraps them
* and puts them into $this->tasks.
*
- * @param array|Traversable $task_names Array of strings
+ * @param array|Traversable $tasks Array of instances of phpbb_cron_task
*
* @return void
*/
- public function load_tasks($task_names)
+ public function load_tasks($tasks)
{
- foreach ($task_names as $task_name)
+ foreach ($tasks as $task)
{
- $task = new $task_name();
- $wrapper = new phpbb_cron_task_wrapper($task);
- $this->tasks[] = $wrapper;
+ $this->tasks[] = $this->wrap_task($task);
}
}
@@ -122,25 +126,13 @@ class phpbb_cron_manager
}
/**
- * Creates an instance of parametrized cron task $name with args $args.
- * The constructed task is wrapped with cron task wrapper before being returned.
- *
- * @param string $name The task name, which is the same as cron task class name.
- * @param array $args Will be passed to the task class's constructor.
+ * Wraps a task inside an instance of phpbb_cron_task_wrapper.
*
- * @return phpbb_cron_task_wrapper|null
+ * @param phpbb_cron_task $task The task.
+ * @return phpbb_cron_task_wrapper The wrapped task.
*/
- public function instantiate_task($name, array $args)
+ public function wrap_task(phpbb_cron_task $task)
{
- $task = $this->find_task($name);
- if ($task)
- {
- // task here is actually an instance of cron task wrapper
- $class = $task->get_name();
- $task = new $class($args);
- // need to wrap the new task too
- $task = new phpbb_cron_task_wrapper($task);
- }
- return $task;
+ return new phpbb_cron_task_wrapper($task, $this->phpbb_root_path, $this->php_ext);
}
}
diff --git a/phpBB/includes/cron/task/base.php b/phpBB/includes/cron/task/base.php
index c05fb9a87c..94a2f267b4 100644
--- a/phpBB/includes/cron/task/base.php
+++ b/phpBB/includes/cron/task/base.php
@@ -28,6 +28,28 @@ if (!defined('IN_PHPBB'))
*/
abstract class phpbb_cron_task_base implements phpbb_cron_task
{
+ private $name;
+
+ /**
+ * Returns the name of the task.
+ *
+ * @return string Name of wrapped task.
+ */
+ public function get_name()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Sets the name of the task.
+ *
+ * @param string $name The task name
+ */
+ public function set_name($name)
+ {
+ $this->name = $name;
+ }
+
/**
* Returns whether this cron task can run, given current board configuration.
*
diff --git a/phpBB/includes/cron/task/core/prune_all_forums.php b/phpBB/includes/cron/task/core/prune_all_forums.php
index 15b93a9ca6..252e16e57d 100644
--- a/phpBB/includes/cron/task/core/prune_all_forums.php
+++ b/phpBB/includes/cron/task/core/prune_all_forums.php
@@ -26,6 +26,27 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base
{
+ protected $phpbb_root_path;
+ protected $php_ext;
+ protected $config;
+ protected $db;
+
+ /**
+ * Constructor.
+ *
+ * @param string $phpbb_root_path The root path
+ * @param string $php_ext The PHP extension
+ * @param phpbb_config $config The config
+ * @param dbal $db The db connection
+ */
+ public function __construct($phpbb_root_path, $php_ext, phpbb_config $config, dbal $db)
+ {
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $php_ext;
+ $this->config = $config;
+ $this->db = $db;
+ }
+
/**
* Runs this cron task.
*
@@ -33,19 +54,17 @@ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base
*/
public function run()
{
- global $phpbb_root_path, $phpEx, $db;
-
if (!function_exists('auto_prune'))
{
- include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
+ include($this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext);
}
$sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, forum_flags, prune_freq
FROM ' . FORUMS_TABLE . "
- WHERE enable_prune = 1
+ WHERE enable_prune = 1
AND prune_next < " . time();
- $result = $db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
{
if ($row['prune_days'])
{
@@ -57,7 +76,7 @@ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base
auto_prune($row['forum_id'], 'viewed', $row['forum_flags'], $row['prune_viewed'], $row['prune_freq']);
}
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
}
/**
@@ -69,7 +88,6 @@ class phpbb_cron_task_core_prune_all_forums extends phpbb_cron_task_base
*/
public function is_runnable()
{
- global $config;
- return (bool) $config['use_system_cron'];
+ return (bool) $this->config['use_system_cron'];
}
}
diff --git a/phpBB/includes/cron/task/core/prune_forum.php b/phpBB/includes/cron/task/core/prune_forum.php
index 7686fd4281..41d60af921 100644
--- a/phpBB/includes/cron/task/core/prune_forum.php
+++ b/phpBB/includes/cron/task/core/prune_forum.php
@@ -26,31 +26,45 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements phpbb_cron_task_parametrized
{
- private $forum_data;
+ protected $phpbb_root_path;
+ protected $php_ext;
+ protected $config;
+ protected $db;
/**
- * Constructor.
- *
* If $forum_data is given, it is assumed to contain necessary information
* about a single forum that is to be pruned.
*
* If $forum_data is not given, forum id will be retrieved via request_var
* and a database query will be performed to load the necessary information
* about the forum.
+ */
+ protected $forum_data;
+
+ /**
+ * Constructor.
+ *
+ * @param string $phpbb_root_path The root path
+ * @param string $php_ext The PHP extension
+ * @param phpbb_config $config The config
+ * @param dbal $db The db connection
+ */
+ public function __construct($phpbb_root_path, $php_ext, phpbb_config $config, dbal $db)
+ {
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $php_ext;
+ $this->config = $config;
+ $this->db = $db;
+ }
+
+ /**
+ * Manually set forum data.
*
* @param array $forum_data Information about a forum to be pruned.
*/
- public function __construct($forum_data = null)
+ public function set_forum_data($forum_data)
{
- global $db;
- if ($forum_data)
- {
- $this->forum_data = $forum_data;
- }
- else
- {
- $this->forum_data = null;
- }
+ $this->forum_data = $forum_data;
}
/**
@@ -60,10 +74,9 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p
*/
public function run()
{
- global $phpbb_root_path, $phpEx;
if (!function_exists('auto_prune'))
{
- include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
+ include($this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext);
}
if ($this->forum_data['prune_days'])
@@ -90,8 +103,7 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p
*/
public function is_runnable()
{
- global $config;
- return !$config['use_system_cron'] && $this->forum_data;
+ return !$this->config['use_system_cron'] && $this->forum_data;
}
/**
@@ -130,8 +142,6 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p
*/
public function parse_parameters(phpbb_request_interface $request)
{
- global $db;
-
$this->forum_data = null;
if ($request->is_set('f'))
{
@@ -140,9 +150,9 @@ class phpbb_cron_task_core_prune_forum extends phpbb_cron_task_base implements p
$sql = 'SELECT forum_id, prune_next, enable_prune, prune_days, prune_viewed, forum_flags, prune_freq
FROM ' . FORUMS_TABLE . "
WHERE forum_id = $forum_id";
- $result = $db->sql_query($sql);
- $row = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = $this->db->sql_query($sql);
+ $row = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
if ($row)
{
diff --git a/phpBB/includes/cron/task/core/queue.php b/phpBB/includes/cron/task/core/queue.php
index 1c72eec7c7..c765660906 100644
--- a/phpBB/includes/cron/task/core/queue.php
+++ b/phpBB/includes/cron/task/core/queue.php
@@ -22,6 +22,24 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cron_task_core_queue extends phpbb_cron_task_base
{
+ protected $phpbb_root_path;
+ protected $php_ext;
+ protected $config;
+
+ /**
+ * Constructor.
+ *
+ * @param string $phpbb_root_path The root path
+ * @param string $php_ext The PHP extension
+ * @param phpbb_config $config The config
+ */
+ public function __construct($phpbb_root_path, $php_ext, phpbb_config $config)
+ {
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $php_ext;
+ $this->config = $config;
+ }
+
/**
* Runs this cron task.
*
@@ -29,10 +47,9 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base
*/
public function run()
{
- global $phpbb_root_path, $phpEx;
if (!class_exists('queue'))
{
- include($phpbb_root_path . 'includes/functions_messenger.' . $phpEx);
+ include($this->phpbb_root_path . 'includes/functions_messenger.' . $this->php_ext);
}
$queue = new queue();
$queue->process();
@@ -47,8 +64,7 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base
*/
public function is_runnable()
{
- global $phpbb_root_path, $phpEx;
- return file_exists($phpbb_root_path . 'cache/queue.' . $phpEx);
+ return file_exists($this->phpbb_root_path . 'cache/queue.' . $this->php_ext);
}
/**
@@ -61,7 +77,6 @@ class phpbb_cron_task_core_queue extends phpbb_cron_task_base
*/
public function should_run()
{
- global $config;
- return $config['last_queue_run'] < time() - $config['queue_interval_config'];
+ return $this->config['last_queue_run'] < time() - $this->config['queue_interval_config'];
}
}
diff --git a/phpBB/includes/cron/task/core/tidy_cache.php b/phpBB/includes/cron/task/core/tidy_cache.php
index c9dc0bd9ae..6017eea561 100644
--- a/phpBB/includes/cron/task/core/tidy_cache.php
+++ b/phpBB/includes/cron/task/core/tidy_cache.php
@@ -22,6 +22,21 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base
{
+ protected $config;
+ protected $cache;
+
+ /**
+ * Constructor.
+ *
+ * @param phpbb_config $config The config
+ * @param phpbb_cache_driver_interface $cache The cache driver
+ */
+ public function __construct(phpbb_config $config, phpbb_cache_driver_interface $cache)
+ {
+ $this->config = $config;
+ $this->cache = $cache;
+ }
+
/**
* Runs this cron task.
*
@@ -29,8 +44,7 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base
*/
public function run()
{
- global $cache;
- $cache->tidy();
+ $this->cache->tidy();
}
/**
@@ -43,8 +57,7 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base
*/
public function is_runnable()
{
- global $cache;
- return method_exists($cache, 'tidy');
+ return true;
}
/**
@@ -58,7 +71,6 @@ class phpbb_cron_task_core_tidy_cache extends phpbb_cron_task_base
*/
public function should_run()
{
- global $config;
- return $config['cache_last_gc'] < time() - $config['cache_gc'];
+ return $this->config['cache_last_gc'] < time() - $this->config['cache_gc'];
}
}
diff --git a/phpBB/includes/cron/task/core/tidy_database.php b/phpBB/includes/cron/task/core/tidy_database.php
index 80a1901b1e..1d256f964f 100644
--- a/phpBB/includes/cron/task/core/tidy_database.php
+++ b/phpBB/includes/cron/task/core/tidy_database.php
@@ -22,6 +22,24 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cron_task_core_tidy_database extends phpbb_cron_task_base
{
+ protected $phpbb_root_path;
+ protected $php_ext;
+ protected $config;
+
+ /**
+ * Constructor.
+ *
+ * @param string $phpbb_root_path The root path
+ * @param string $php_ext The PHP extension
+ * @param phpbb_config $config The config
+ */
+ public function __construct($phpbb_root_path, $php_ext, phpbb_config $config)
+ {
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $php_ext;
+ $this->config = $config;
+ }
+
/**
* Runs this cron task.
*
@@ -29,10 +47,9 @@ class phpbb_cron_task_core_tidy_database extends phpbb_cron_task_base
*/
public function run()
{
- global $phpbb_root_path, $phpEx;
if (!function_exists('tidy_database'))
{
- include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
+ include($this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext);
}
tidy_database();
}
@@ -48,7 +65,6 @@ class phpbb_cron_task_core_tidy_database extends phpbb_cron_task_base
*/
public function should_run()
{
- global $config;
- return $config['database_last_gc'] < time() - $config['database_gc'];
+ return $this->config['database_last_gc'] < time() - $this->config['database_gc'];
}
}
diff --git a/phpBB/includes/cron/task/core/tidy_search.php b/phpBB/includes/cron/task/core/tidy_search.php
index 8a0b1b690a..2e5f3d79d5 100644
--- a/phpBB/includes/cron/task/core/tidy_search.php
+++ b/phpBB/includes/cron/task/core/tidy_search.php
@@ -24,6 +24,33 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base
{
+ protected $phpbb_root_path;
+ protected $php_ext;
+ protected $auth;
+ protected $config;
+ protected $db;
+ protected $user;
+
+ /**
+ * Constructor.
+ *
+ * @param string $phpbb_root_path The root path
+ * @param string $php_ext The PHP extension
+ * @param phpbb_auth $auth The auth
+ * @param phpbb_config $config The config
+ * @param dbal $db The db connection
+ * @param phpbb_user $user The user
+ */
+ public function __construct($phpbb_root_path, $php_ext, phpbb_auth $auth, phpbb_config $config, dbal $db, phpbb_user $user)
+ {
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $php_ext;
+ $this->auth = $auth;
+ $this->config = $config;
+ $this->db = $db;
+ $this->user = $user;
+ }
+
/**
* Runs this cron task.
*
@@ -31,19 +58,17 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base
*/
public function run()
{
- global $phpbb_root_path, $phpEx, $config, $error;
-
// Select the search method
- $search_type = basename($config['search_type']);
+ $search_type = basename($this->config['search_type']);
if (!class_exists($search_type))
{
- include("{$phpbb_root_path}includes/search/$search_type.$phpEx");
+ include($this->phpbb_root_path . "includes/search/$search_type." . $this->php_ext);
}
// We do some additional checks in the module to ensure it can actually be utilised
$error = false;
- $search = new $search_type($error);
+ $search = new $search_type($error, $this->phpbb_root_path, $this->php_ext, $this->auth, $this->config, $this->db, $this->user);
if (!$error)
{
@@ -62,12 +87,10 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base
*/
public function is_runnable()
{
- global $phpbb_root_path, $phpEx, $config;
-
// Select the search method
- $search_type = basename($config['search_type']);
+ $search_type = basename($this->config['search_type']);
- return file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx);
+ return file_exists($this->phpbb_root_path . 'includes/search/' . $search_type . '.' . $this->php_ext);
}
/**
@@ -81,7 +104,6 @@ class phpbb_cron_task_core_tidy_search extends phpbb_cron_task_base
*/
public function should_run()
{
- global $config;
- return $config['search_last_gc'] < time() - $config['search_gc'];
+ return $this->config['search_last_gc'] < time() - $this->config['search_gc'];
}
}
diff --git a/phpBB/includes/cron/task/core/tidy_sessions.php b/phpBB/includes/cron/task/core/tidy_sessions.php
index ae7bb242b8..13531aa30b 100644
--- a/phpBB/includes/cron/task/core/tidy_sessions.php
+++ b/phpBB/includes/cron/task/core/tidy_sessions.php
@@ -22,6 +22,21 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cron_task_core_tidy_sessions extends phpbb_cron_task_base
{
+ protected $config;
+ protected $user;
+
+ /**
+ * Constructor.
+ *
+ * @param phpbb_config $config The config
+ * @param phpbb_user $user The user
+ */
+ public function __construct(phpbb_config $config, phpbb_user $user)
+ {
+ $this->config = $config;
+ $this->user = $user;
+ }
+
/**
* Runs this cron task.
*
@@ -29,8 +44,7 @@ class phpbb_cron_task_core_tidy_sessions extends phpbb_cron_task_base
*/
public function run()
{
- global $user;
- $user->session_gc();
+ $this->user->session_gc();
}
/**
@@ -44,7 +58,6 @@ class phpbb_cron_task_core_tidy_sessions extends phpbb_cron_task_base
*/
public function should_run()
{
- global $config;
- return $config['session_last_gc'] < time() - $config['session_gc'];
+ return $this->config['session_last_gc'] < time() - $this->config['session_gc'];
}
}
diff --git a/phpBB/includes/cron/task/core/tidy_warnings.php b/phpBB/includes/cron/task/core/tidy_warnings.php
index e1434e7087..8dd0674fe5 100644
--- a/phpBB/includes/cron/task/core/tidy_warnings.php
+++ b/phpBB/includes/cron/task/core/tidy_warnings.php
@@ -24,6 +24,24 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base
{
+ protected $phpbb_root_path;
+ protected $php_ext;
+ protected $config;
+
+ /**
+ * Constructor.
+ *
+ * @param string $phpbb_root_path The root path
+ * @param string $php_ext The PHP extension
+ * @param phpbb_config $config The config
+ */
+ public function __construct($phpbb_root_path, $php_ext, phpbb_config $config)
+ {
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $php_ext;
+ $this->config = $config;
+ }
+
/**
* Runs this cron task.
*
@@ -31,10 +49,9 @@ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base
*/
public function run()
{
- global $phpbb_root_path, $phpEx;
if (!function_exists('tidy_warnings'))
{
- include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
+ include($this->phpbb_root_path . 'includes/functions_admin.' . $this->php_ext);
}
tidy_warnings();
}
@@ -48,8 +65,7 @@ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base
*/
public function is_runnable()
{
- global $config;
- return (bool) $config['warnings_expire_days'];
+ return (bool) $this->config['warnings_expire_days'];
}
/**
@@ -63,7 +79,6 @@ class phpbb_cron_task_core_tidy_warnings extends phpbb_cron_task_base
*/
public function should_run()
{
- global $config;
- return $config['warnings_last_gc'] < time() - $config['warnings_gc'];
+ return $this->config['warnings_last_gc'] < time() - $this->config['warnings_gc'];
}
}
diff --git a/phpBB/includes/cron/task/provider.php b/phpBB/includes/cron/task/provider.php
index 1482051699..134723ebd1 100644
--- a/phpBB/includes/cron/task/provider.php
+++ b/phpBB/includes/cron/task/provider.php
@@ -15,6 +15,8 @@ if (!defined('IN_PHPBB'))
exit;
}
+use Symfony\Component\DependencyInjection\TaggedContainerInterface;
+
/**
* Provides cron manager with tasks
*
@@ -22,27 +24,36 @@ if (!defined('IN_PHPBB'))
*
* @package phpBB3
*/
-class phpbb_cron_task_provider extends phpbb_extension_provider
+class phpbb_cron_task_provider implements IteratorAggregate
{
+ private $container;
+
+ public function __construct(TaggedContainerInterface $container)
+ {
+ $this->container = $container;
+ }
+
/**
- * Finds cron task names using the extension manager.
- *
- * All PHP files in includes/cron/task/core/ are considered tasks. Tasks
- * in extensions have to be located in a directory called cron or a subdir
- * of a directory called cron. The class and filename must end in a _task
- * suffix. Additionally all PHP files in includes/cron/task/core/ are
- * tasks.
+ * Retrieve an iterator over all items
*
- * @return array List of task names
+ * @return ArrayIterator An iterator for the array of cron tasks
*/
- protected function find()
+ public function getIterator()
{
- $finder = $this->extension_manager->get_finder();
+ $definitions = $this->container->findTaggedServiceIds('cron.task');
+
+ $tasks = array();
+ foreach ($definitions as $name => $definition)
+ {
+ $task = $this->container->get($name);
+ if ($task instanceof phpbb_cron_task_base)
+ {
+ $task->set_name($name);
+ }
+
+ $tasks[] = $task;
+ }
- return $finder
- ->extension_suffix('_task')
- ->extension_directory('/cron')
- ->core_path('includes/cron/task/core/')
- ->get_classes();
+ return new ArrayIterator($tasks);
}
}
diff --git a/phpBB/includes/cron/task/task.php b/phpBB/includes/cron/task/task.php
index 2f2a9e51f9..7b08fed413 100644
--- a/phpBB/includes/cron/task/task.php
+++ b/phpBB/includes/cron/task/task.php
@@ -22,6 +22,13 @@ if (!defined('IN_PHPBB'))
interface phpbb_cron_task
{
/**
+ * Returns the name of the task.
+ *
+ * @return string Name of wrapped task.
+ */
+ public function get_name();
+
+ /**
* Runs this cron task.
*
* @return void
diff --git a/phpBB/includes/cron/task/wrapper.php b/phpBB/includes/cron/task/wrapper.php
index 66c45189e5..386fb5b383 100644
--- a/phpBB/includes/cron/task/wrapper.php
+++ b/phpBB/includes/cron/task/wrapper.php
@@ -23,6 +23,10 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_cron_task_wrapper
{
+ protected $task;
+ protected $phpbb_root_path;
+ protected $php_ext;
+
/**
* Constructor.
*
@@ -30,9 +34,11 @@ class phpbb_cron_task_wrapper
*
* @param phpbb_cron_task $task The cron task to wrap.
*/
- public function __construct(phpbb_cron_task $task)
+ public function __construct(phpbb_cron_task $task, $phpbb_root_path, $php_ext)
{
$this->task = $task;
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $php_ext;
}
/**
@@ -62,16 +68,6 @@ class phpbb_cron_task_wrapper
}
/**
- * Returns the name of wrapped task. It is the same as the wrapped class's class name.
- *
- * @return string Class name of wrapped task.
- */
- public function get_name()
- {
- return get_class($this->task);
- }
-
- /**
* Returns a url through which this task may be invoked via web.
*
* When system cron is not in use, running a cron task is accomplished
@@ -82,8 +78,6 @@ class phpbb_cron_task_wrapper
*/
public function get_url()
{
- global $phpbb_root_path, $phpEx;
-
$name = $this->get_name();
if ($this->is_parametrized())
{
@@ -98,7 +92,7 @@ class phpbb_cron_task_wrapper
{
$extra = '';
}
- $url = append_sid($phpbb_root_path . 'cron.' . $phpEx, 'cron_type=' . $name . $extra);
+ $url = append_sid($this->phpbb_root_path . 'cron.' . $this->php_ext, 'cron_type=' . $name . $extra);
return $url;
}
diff --git a/phpBB/includes/datetime.php b/phpBB/includes/datetime.php
new file mode 100644
index 0000000000..b3462ddf67
--- /dev/null
+++ b/phpBB/includes/datetime.php
@@ -0,0 +1,158 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*/
+
+/**
+* phpBB custom extensions to the PHP DateTime class
+* This handles the relative formats phpBB employs
+*/
+class phpbb_datetime extends DateTime
+{
+ /**
+ * String used to wrap the date segment which should be replaced by today/tomorrow/yesterday
+ */
+ const RELATIVE_WRAPPER = '|';
+
+ /**
+ * @var user User who is the context for this DateTime instance
+ */
+ protected $user;
+
+ /**
+ * @var array Date formats are preprocessed by phpBB, to save constant recalculation they are cached.
+ */
+ static protected $format_cache = array();
+
+ /**
+ * Constructs a new instance of phpbb_datetime, expanded to include an argument to inject
+ * the user context and modify the timezone to the users selected timezone if one is not set.
+ *
+ * @param string $time String in a format accepted by strtotime().
+ * @param DateTimeZone $timezone Time zone of the time.
+ * @param user User object for context.
+ */
+ public function __construct($user, $time = 'now', DateTimeZone $timezone = null)
+ {
+ $this->user = $user;
+ $timezone = $timezone ?: $this->user->timezone;
+
+ parent::__construct($time, $timezone);
+ }
+
+ /**
+ * Formats the current date time into the specified format
+ *
+ * @param string $format Optional format to use for output, defaults to users chosen format
+ * @param boolean $force_absolute Force output of a non relative date
+ * @return string Formatted date time
+ */
+ public function format($format = '', $force_absolute = false)
+ {
+ $format = $format ? $format : $this->user->date_format;
+ $format = self::format_cache($format, $this->user);
+ $relative = ($format['is_short'] && !$force_absolute);
+ $now = new self($this->user, 'now', $this->user->timezone);
+
+ $timestamp = $this->getTimestamp();
+ $now_ts = $now->getTimeStamp();
+
+ $delta = $now_ts - $timestamp;
+
+ if ($relative)
+ {
+ /*
+ * Check the delta is less than or equal to 1 hour
+ * and the delta not more than a minute in the past
+ * and the delta is either greater than -5 seconds or timestamp
+ * and current time are of the same minute (they must be in the same hour already)
+ * finally check that relative dates are supported by the language pack
+ */
+ if ($delta <= 3600 && $delta > -60 &&
+ ($delta >= -5 || (($now_ts / 60) % 60) == (($timestamp / 60) % 60))
+ && isset($this->user->lang['datetime']['AGO']))
+ {
+ return $this->user->lang(array('datetime', 'AGO'), max(0, (int) floor($delta / 60)));
+ }
+ else
+ {
+ $midnight = clone $now;
+ $midnight->setTime(0, 0, 0);
+
+ $midnight = $midnight->getTimestamp();
+
+ $day = false;
+
+ if ($timestamp > $midnight + 86400)
+ {
+ $day = 'TOMORROW';
+ }
+ else if ($timestamp > $midnight)
+ {
+ $day = 'TODAY';
+ }
+ else if ($timestamp > $midnight - 86400)
+ {
+ $day = 'YESTERDAY';
+ }
+
+ if ($day !== false)
+ {
+ // Format using the short formatting and finally swap out the relative token placeholder with the correct value
+ return str_replace(self::RELATIVE_WRAPPER . self::RELATIVE_WRAPPER, $this->user->lang['datetime'][$day], strtr(parent::format($format['format_short']), $format['lang']));
+ }
+ }
+ }
+
+ return strtr(parent::format($format['format_long']), $format['lang']);
+ }
+
+ /**
+ * Magic method to convert DateTime object to string
+ *
+ * @return Formatted date time, according to the users default settings.
+ */
+ public function __toString()
+ {
+ return $this->format();
+ }
+
+ /**
+ * Pre-processes the specified date format
+ *
+ * @param string $format Output format
+ * @param user $user User object to use for localisation
+ * @return array Processed date format
+ */
+ static protected function format_cache($format, $user)
+ {
+ $lang = $user->lang_name;
+
+ if (!isset(self::$format_cache[$lang]))
+ {
+ self::$format_cache[$lang] = array();
+ }
+
+ if (!isset(self::$format_cache[$lang][$format]))
+ {
+ // Is the user requesting a friendly date format (i.e. 'Today 12:42')?
+ self::$format_cache[$lang][$format] = array(
+ 'is_short' => strpos($format, self::RELATIVE_WRAPPER) !== false,
+ 'format_short' => substr($format, 0, strpos($format, self::RELATIVE_WRAPPER)) . self::RELATIVE_WRAPPER . self::RELATIVE_WRAPPER . substr(strrchr($format, self::RELATIVE_WRAPPER), 1),
+ 'format_long' => str_replace(self::RELATIVE_WRAPPER, '', $format),
+ 'lang' => $user->lang['datetime'],
+ );
+
+ // Short representation of month in format? Some languages use different terms for the long and short format of May
+ if ((strpos($format, '\M') === false && strpos($format, 'M') !== false) || (strpos($format, '\r') === false && strpos($format, 'r') !== false))
+ {
+ self::$format_cache[$lang][$format]['lang']['May'] = $user->lang['datetime']['May_short'];
+ }
+ }
+
+ return self::$format_cache[$lang][$format];
+ }
+}
diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php
index 73eae4e967..6df3aac9ce 100644
--- a/phpBB/includes/db/db_tools.php
+++ b/phpBB/includes/db/db_tools.php
@@ -20,7 +20,6 @@ if (!defined('IN_PHPBB'))
* Currently not supported is returning SQL for creating tables.
*
* @package dbal
-* @note currently not used within phpBB3, but may be utilized later.
*/
class phpbb_db_tools
{
diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php
index cf54d455f7..1de236d3de 100644
--- a/phpBB/includes/db/dbal.php
+++ b/phpBB/includes/db/dbal.php
@@ -206,7 +206,7 @@ class dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_rowseek($rownum, $query_id);
}
@@ -256,7 +256,7 @@ class dbal
$this->sql_rowseek($rownum, $query_id);
}
- if (!is_object($query_id) && isset($cache->sql_rowset[$query_id]))
+ if (!is_object($query_id) && $cache->sql_exists($query_id))
{
return $cache->sql_fetchfield($query_id, $field);
}
@@ -284,6 +284,37 @@ class dbal
}
/**
+ * Build a case expression
+ *
+ * Note: The two statements action_true and action_false must have the same data type (int, vchar, ...) in the database!
+ *
+ * @param string $condition The condition which must be true, to use action_true rather then action_else
+ * @param string $action_true SQL expression that is used, if the condition is true
+ * @param string $action_else SQL expression that is used, if the condition is false, optional
+ * @return string CASE expression including the condition and statements
+ */
+ public function sql_case($condition, $action_true, $action_false = false)
+ {
+ $sql_case = 'CASE WHEN ' . $condition;
+ $sql_case .= ' THEN ' . $action_true;
+ $sql_case .= ($action_false !== false) ? ' ELSE ' . $action_false : '';
+ $sql_case .= ' END';
+ return $sql_case;
+ }
+
+ /**
+ * Build a concatenated expression
+ *
+ * @param string $expr1 Base SQL expression where we append the second one
+ * @param string $expr2 SQL expression that is appended to the first expression
+ * @return string Concatenated string
+ */
+ public function sql_concatenate($expr1, $expr2)
+ {
+ return $expr1 . ' || ' . $expr2;
+ }
+
+ /**
* Returns whether results of a query need to be buffered to run a transaction while iterating over them.
*
* @return bool Whether buffering is required.
diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php
index 7709e8fdf5..9f9b8a1abd 100644
--- a/phpBB/includes/db/firebird.php
+++ b/phpBB/includes/db/firebird.php
@@ -156,7 +156,7 @@ class dbal_firebird extends dbal
}
$this->last_query_text = $query;
- $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
+ $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
@@ -269,10 +269,10 @@ class dbal_firebird extends dbal
}
}
- if ($cache_ttl && method_exists($cache, 'sql_save'))
+ if ($cache_ttl)
{
$this->open_queries[(int) $this->query_result] = $this->query_result;
- $cache->sql_save($query, $this->query_result, $cache_ttl);
+ $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
}
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
{
@@ -332,7 +332,7 @@ class dbal_firebird extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_fetchrow($query_id);
}
@@ -398,7 +398,7 @@ class dbal_firebird extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}
diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php
index abeabc389f..bde283c3ea 100644
--- a/phpBB/includes/db/mssql.php
+++ b/phpBB/includes/db/mssql.php
@@ -92,6 +92,14 @@ class dbal_mssql extends dbal
}
/**
+ * {@inheritDoc}
+ */
+ public function sql_concatenate($expr1, $expr2)
+ {
+ return $expr1 . ' + ' . $expr2;
+ }
+
+ /**
* SQL Transaction
* @access private
*/
@@ -136,7 +144,7 @@ class dbal_mssql extends dbal
$this->sql_report('start', $query);
}
- $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
+ $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
@@ -151,10 +159,10 @@ class dbal_mssql extends dbal
$this->sql_report('stop', $query);
}
- if ($cache_ttl && method_exists($cache, 'sql_save'))
+ if ($cache_ttl)
{
$this->open_queries[(int) $this->query_result] = $this->query_result;
- $cache->sql_save($query, $this->query_result, $cache_ttl);
+ $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
}
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
{
@@ -226,7 +234,7 @@ class dbal_mssql extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_fetchrow($query_id);
}
@@ -263,7 +271,7 @@ class dbal_mssql extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_rowseek($rownum, $query_id);
}
@@ -302,7 +310,7 @@ class dbal_mssql extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}
diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php
index 6e24f4e9e8..687bc52abc 100644
--- a/phpBB/includes/db/mssql_odbc.php
+++ b/phpBB/includes/db/mssql_odbc.php
@@ -110,6 +110,14 @@ class dbal_mssql_odbc extends dbal
}
/**
+ * {@inheritDoc}
+ */
+ public function sql_concatenate($expr1, $expr2)
+ {
+ return $expr1 . ' + ' . $expr2;
+ }
+
+ /**
* SQL Transaction
* @access private
*/
@@ -155,7 +163,7 @@ class dbal_mssql_odbc extends dbal
}
$this->last_query_text = $query;
- $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
+ $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
@@ -170,10 +178,10 @@ class dbal_mssql_odbc extends dbal
$this->sql_report('stop', $query);
}
- if ($cache_ttl && method_exists($cache, 'sql_save'))
+ if ($cache_ttl)
{
$this->open_queries[(int) $this->query_result] = $this->query_result;
- $cache->sql_save($query, $this->query_result, $cache_ttl);
+ $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
}
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
{
@@ -246,7 +254,7 @@ class dbal_mssql_odbc extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_fetchrow($query_id);
}
@@ -287,7 +295,7 @@ class dbal_mssql_odbc extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}
diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php
index 8a4503f111..c31f7f6892 100644
--- a/phpBB/includes/db/mssqlnative.php
+++ b/phpBB/includes/db/mssqlnative.php
@@ -218,7 +218,6 @@ class dbal_mssqlnative extends dbal
$this->server = $sqlserver . (($port) ? $port_delimiter . $port : '');
//connect to database
- error_reporting(E_ALL);
$this->db_connect_id = sqlsrv_connect($this->server, array(
'Database' => $this->dbname,
'UID' => $this->user,
@@ -260,6 +259,14 @@ class dbal_mssqlnative extends dbal
/**
* {@inheritDoc}
*/
+ public function sql_concatenate($expr1, $expr2)
+ {
+ return $expr1 . ' + ' . $expr2;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
function sql_buffer_nested_transactions()
{
return true;
@@ -310,7 +317,7 @@ class dbal_mssqlnative extends dbal
}
$this->last_query_text = $query;
- $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
+ $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
@@ -327,10 +334,10 @@ class dbal_mssqlnative extends dbal
$this->sql_report('stop', $query);
}
- if ($cache_ttl && method_exists($cache, 'sql_save'))
+ if ($cache_ttl)
{
$this->open_queries[(int) $this->query_result] = $this->query_result;
- $cache->sql_save($query, $this->query_result, $cache_ttl);
+ $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
}
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
{
@@ -410,7 +417,7 @@ class dbal_mssqlnative extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_fetchrow($query_id);
}
@@ -435,7 +442,7 @@ class dbal_mssqlnative extends dbal
unset($row['line2'], $row['line3']);
}
}
- return $row;
+ return (sizeof($row)) ? $row : false;
}
/**
@@ -470,7 +477,7 @@ class dbal_mssqlnative extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}
diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php
index eb38e3e913..5b4ff86579 100644
--- a/phpBB/includes/db/mysql.php
+++ b/phpBB/includes/db/mysql.php
@@ -120,6 +120,14 @@ class dbal_mysql extends dbal
}
/**
+ * {@inheritDoc}
+ */
+ public function sql_concatenate($expr1, $expr2)
+ {
+ return 'CONCAT(' . $expr1 . ', ' . $expr2 . ')';
+ }
+
+ /**
* SQL Transaction
* @access private
*/
@@ -164,7 +172,7 @@ class dbal_mysql extends dbal
$this->sql_report('start', $query);
}
- $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
+ $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
@@ -179,10 +187,10 @@ class dbal_mysql extends dbal
$this->sql_report('stop', $query);
}
- if ($cache_ttl && method_exists($cache, 'sql_save'))
+ if ($cache_ttl)
{
$this->open_queries[(int) $this->query_result] = $this->query_result;
- $cache->sql_save($query, $this->query_result, $cache_ttl);
+ $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
}
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
{
@@ -241,7 +249,7 @@ class dbal_mysql extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_fetchrow($query_id);
}
@@ -262,7 +270,7 @@ class dbal_mysql extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_rowseek($rownum, $query_id);
}
@@ -290,7 +298,7 @@ class dbal_mysql extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}
diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php
index 4210a58002..1f13bd5459 100644
--- a/phpBB/includes/db/mysqli.php
+++ b/phpBB/includes/db/mysqli.php
@@ -123,6 +123,14 @@ class dbal_mysqli extends dbal
}
/**
+ * {@inheritDoc}
+ */
+ public function sql_concatenate($expr1, $expr2)
+ {
+ return 'CONCAT(' . $expr1 . ', ' . $expr2 . ')';
+ }
+
+ /**
* SQL Transaction
* @access private
*/
@@ -171,7 +179,7 @@ class dbal_mysqli extends dbal
$this->sql_report('start', $query);
}
- $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
+ $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
@@ -186,9 +194,9 @@ class dbal_mysqli extends dbal
$this->sql_report('stop', $query);
}
- if ($cache_ttl && method_exists($cache, 'sql_save'))
+ if ($cache_ttl)
{
- $cache->sql_save($query, $this->query_result, $cache_ttl);
+ $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
}
}
else if (defined('DEBUG_EXTRA'))
@@ -243,7 +251,7 @@ class dbal_mysqli extends dbal
$query_id = $this->query_result;
}
- if (!is_object($query_id) && isset($cache->sql_rowset[$query_id]))
+ if (!is_object($query_id) && $cache->sql_exists($query_id))
{
return $cache->sql_fetchrow($query_id);
}
@@ -270,7 +278,7 @@ class dbal_mysqli extends dbal
$query_id = $this->query_result;
}
- if (!is_object($query_id) && isset($cache->sql_rowset[$query_id]))
+ if (!is_object($query_id) && $cache->sql_exists($query_id))
{
return $cache->sql_rowseek($rownum, $query_id);
}
@@ -298,7 +306,7 @@ class dbal_mysqli extends dbal
$query_id = $this->query_result;
}
- if (!is_object($query_id) && isset($cache->sql_rowset[$query_id]))
+ if (!is_object($query_id) && $cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}
diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php
index 2e801532f0..de2729e973 100644
--- a/phpBB/includes/db/oracle.php
+++ b/phpBB/includes/db/oracle.php
@@ -242,7 +242,7 @@ class dbal_oracle extends dbal
}
$this->last_query_text = $query;
- $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
+ $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
@@ -418,10 +418,10 @@ class dbal_oracle extends dbal
$this->sql_report('stop', $query);
}
- if ($cache_ttl && method_exists($cache, 'sql_save'))
+ if ($cache_ttl)
{
$this->open_queries[(int) $this->query_result] = $this->query_result;
- $cache->sql_save($query, $this->query_result, $cache_ttl);
+ $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
}
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
{
@@ -473,7 +473,7 @@ class dbal_oracle extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_fetchrow($query_id);
}
@@ -525,7 +525,7 @@ class dbal_oracle extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_rowseek($rownum, $query_id);
}
@@ -594,7 +594,7 @@ class dbal_oracle extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}
diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php
index bf22cffafa..f0a4a7a7a2 100644
--- a/phpBB/includes/db/postgres.php
+++ b/phpBB/includes/db/postgres.php
@@ -200,7 +200,7 @@ class dbal_postgres extends dbal
}
$this->last_query_text = $query;
- $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
+ $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
@@ -215,10 +215,10 @@ class dbal_postgres extends dbal
$this->sql_report('stop', $query);
}
- if ($cache_ttl && method_exists($cache, 'sql_save'))
+ if ($cache_ttl)
{
$this->open_queries[(int) $this->query_result] = $this->query_result;
- $cache->sql_save($query, $this->query_result, $cache_ttl);
+ $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
}
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
{
@@ -285,7 +285,7 @@ class dbal_postgres extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_fetchrow($query_id);
}
@@ -306,7 +306,7 @@ class dbal_postgres extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_rowseek($rownum, $query_id);
}
@@ -355,7 +355,7 @@ class dbal_postgres extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}
diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php
index 86bfa75a13..2cf55b07e2 100644
--- a/phpBB/includes/db/sqlite.php
+++ b/phpBB/includes/db/sqlite.php
@@ -117,7 +117,7 @@ class dbal_sqlite extends dbal
$this->sql_report('start', $query);
}
- $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false;
+ $this->query_result = ($cache_ttl) ? $cache->sql_load($query) : false;
$this->sql_add_num_queries($this->query_result);
if ($this->query_result === false)
@@ -132,10 +132,10 @@ class dbal_sqlite extends dbal
$this->sql_report('stop', $query);
}
- if ($cache_ttl && method_exists($cache, 'sql_save'))
+ if ($cache_ttl)
{
$this->open_queries[(int) $this->query_result] = $this->query_result;
- $cache->sql_save($query, $this->query_result, $cache_ttl);
+ $this->query_result = $cache->sql_save($query, $this->query_result, $cache_ttl);
}
else if (strpos($query, 'SELECT') === 0 && $this->query_result)
{
@@ -193,7 +193,7 @@ class dbal_sqlite extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_fetchrow($query_id);
}
@@ -214,7 +214,7 @@ class dbal_sqlite extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_rowseek($rownum, $query_id);
}
@@ -242,7 +242,7 @@ class dbal_sqlite extends dbal
$query_id = $this->query_result;
}
- if (isset($cache->sql_rowset[$query_id]))
+ if ($cache->sql_exists($query_id))
{
return $cache->sql_freeresult($query_id);
}
diff --git a/phpBB/includes/di/processor/config.php b/phpBB/includes/di/processor/config.php
new file mode 100644
index 0000000000..22b6252a6d
--- /dev/null
+++ b/phpBB/includes/di/processor/config.php
@@ -0,0 +1,76 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+
+/**
+* Configure the container for phpBB's services though
+* user-defined parameters defined in the config.php file.
+*/
+class phpbb_di_processor_config implements phpbb_di_processor_interface
+{
+ private $config_file;
+ private $phpbb_root_path;
+ private $php_ext;
+
+ /**
+ * Constructor.
+ *
+ * @param string $config_file The config file
+ * @param string $phpbb_root_path The root path
+ * @param string $php_ext The PHP extension
+ */
+ public function __construct($config_file, $phpbb_root_path, $php_ext)
+ {
+ $this->config_file = $config_file;
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $php_ext;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function process(ContainerBuilder $container)
+ {
+ require $this->config_file;
+
+ $container->setParameter('core.root_path', $this->phpbb_root_path);
+ $container->setParameter('core.php_ext', $this->php_ext);
+
+ $container->setParameter('core.table_prefix', $table_prefix);
+ $container->setParameter('cache.driver.class', $this->fix_acm_type($acm_type));
+ $container->setParameter('dbal.driver.class', 'dbal_'.$dbms);
+ $container->setParameter('dbal.dbhost', $dbhost);
+ $container->setParameter('dbal.dbuser', $dbuser);
+ $container->setParameter('dbal.dbpasswd', $dbpasswd);
+ $container->setParameter('dbal.dbname', $dbname);
+ $container->setParameter('dbal.dbport', $dbport);
+ $container->setParameter('dbal.new_link', defined('PHPBB_DB_NEW_LINK') && PHPBB_DB_NEW_LINK);
+
+ $container->set('container', $container);
+ }
+
+ protected function fix_acm_type($acm_type)
+ {
+ if (preg_match('#^[a-z]+$#', $acm_type))
+ {
+ return 'phpbb_cache_driver_'.$acm_type;
+ }
+
+ return $acm_type;
+ }
+}
diff --git a/phpBB/includes/di/processor/ext.php b/phpBB/includes/di/processor/ext.php
new file mode 100644
index 0000000000..e69a3d73b3
--- /dev/null
+++ b/phpBB/includes/di/processor/ext.php
@@ -0,0 +1,54 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+use Symfony\Component\Config\FileLocator;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+
+/**
+* Load the service configurations from all extensions into the container.
+*/
+class phpbb_di_processor_ext implements phpbb_di_processor_interface
+{
+ private $extension_manager;
+
+ /**
+ * Constructor.
+ *
+ * @param string $extension_manager The extension manager
+ */
+ public function __construct($extension_manager)
+ {
+ $this->extension_manager = $extension_manager;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function process(ContainerBuilder $container)
+ {
+ $enabled_exts = $this->extension_manager->all_enabled();
+ foreach ($enabled_exts as $name => $path)
+ {
+ if (file_exists($path . '/config/services.yml'))
+ {
+ $loader = new YamlFileLoader($container, new FileLocator($path . '/config'));
+ $loader->load('services.yml');
+ }
+ }
+ }
+}
diff --git a/phpBB/includes/di/processor/interface.php b/phpBB/includes/di/processor/interface.php
new file mode 100644
index 0000000000..b8563791cc
--- /dev/null
+++ b/phpBB/includes/di/processor/interface.php
@@ -0,0 +1,28 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+
+interface phpbb_di_processor_interface
+{
+ /**
+ * Mutate the container.
+ *
+ * @param ContainerBuilder $container The container
+ */
+ public function process(ContainerBuilder $container);
+}
diff --git a/phpBB/includes/extension/controller.php b/phpBB/includes/extension/controller.php
index c7fd439a19..f97b69c7ed 100644
--- a/phpBB/includes/extension/controller.php
+++ b/phpBB/includes/extension/controller.php
@@ -23,37 +23,44 @@ if (!defined('IN_PHPBB'))
abstract class phpbb_extension_controller implements phpbb_extension_controller_interface
{
/**
- * @var phpbb_request Request class object
+ * Request class object
+ * @var phpbb_request
*/
protected $request;
/**
- * @var dbal DBAL class object
+ * DBAL class object
+ * @var dbal
*/
protected $db;
/**
- * @var user User class object
+ * User class object
+ * @var phpbb_user
*/
protected $user;
/**
- * @var phpbb_template Template class object
+ * Template class object
+ * @var phpbb_template
*/
protected $template;
/**
- * @var array Config array
+ * Config object
+ * @var phpbb_config
*/
protected $config;
/**
- * @var string PHP Extension
+ * PHP Extension
+ * @var string
*/
- protected $phpEx;
+ protected $php_ext;
/**
- * @var string Relative path to board root
+ * Relative path to board root
+ * @var string
*/
protected $phpbb_root_path;
@@ -71,7 +78,7 @@ abstract class phpbb_extension_controller implements phpbb_extension_controller_
$this->user = $user;
$this->template = $template;
$this->config = $config;
- $this->phpEx = $phpEx;
+ $this->php_ext = $phpEx;
$this->phpbb_root_path = $phpbb_root_path;
}
}
diff --git a/phpBB/includes/extension/exception.php b/phpBB/includes/extension/exception.php
new file mode 100644
index 0000000000..e08a8912ea
--- /dev/null
+++ b/phpBB/includes/extension/exception.php
@@ -0,0 +1,27 @@
+<?php
+/**
+*
+* @package extension
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+ * Exception class for metadata
+ */
+class phpbb_extension_exception extends UnexpectedValueException
+{
+ public function __toString()
+ {
+ return $this->getMessage();
+ }
+} \ No newline at end of file
diff --git a/phpBB/includes/extension/finder.php b/phpBB/includes/extension/finder.php
index 87ca40917d..fb19b98429 100644
--- a/phpBB/includes/extension/finder.php
+++ b/phpBB/includes/extension/finder.php
@@ -25,7 +25,7 @@ class phpbb_extension_finder
protected $extension_manager;
protected $phpbb_root_path;
protected $cache;
- protected $phpEx;
+ protected $php_ext;
/**
* The cache variable name used to store $this->cached_queries in $this->cache.
@@ -56,16 +56,16 @@ class phpbb_extension_finder
* extensions and their locations
* @param string $phpbb_root_path Path to the phpbb root directory
* @param phpbb_cache_driver_interface $cache A cache instance or null
- * @param string $phpEx php file extension
+ * @param string $php_ext php file extension
* @param string $cache_name The name of the cache variable, defaults to
* _ext_finder
*/
- public function __construct(phpbb_extension_manager $extension_manager, $phpbb_root_path = '', phpbb_cache_driver_interface $cache = null, $phpEx = '.php', $cache_name = '_ext_finder')
+ public function __construct(phpbb_extension_manager $extension_manager, $phpbb_root_path = '', phpbb_cache_driver_interface $cache = null, $php_ext = '.php', $cache_name = '_ext_finder')
{
$this->extension_manager = $extension_manager;
$this->phpbb_root_path = $phpbb_root_path;
$this->cache = $cache;
- $this->phpEx = $phpEx;
+ $this->php_ext = $php_ext;
$this->cache_name = $cache_name;
$this->query = array(
@@ -251,8 +251,8 @@ class phpbb_extension_finder
*/
public function get_classes($cache = true)
{
- $this->query['extension_suffix'] .= $this->phpEx;
- $this->query['core_suffix'] .= $this->phpEx;
+ $this->query['extension_suffix'] .= $this->php_ext;
+ $this->query['core_suffix'] .= $this->php_ext;
$files = $this->find($cache, false);
@@ -261,7 +261,7 @@ class phpbb_extension_finder
{
$file = preg_replace('#^includes/#', '', $file);
- $classes[] = 'phpbb_' . str_replace('/', '_', substr($file, 0, -strlen($this->phpEx)));
+ $classes[] = 'phpbb_' . str_replace('/', '_', substr($file, 0, -strlen($this->php_ext)));
}
return $classes;
}
diff --git a/phpBB/includes/extension/manager.php b/phpBB/includes/extension/manager.php
index 537c19aff8..9a518c215f 100644
--- a/phpBB/includes/extension/manager.php
+++ b/phpBB/includes/extension/manager.php
@@ -22,8 +22,10 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_extension_manager
{
+ protected $db;
+ protected $config;
protected $cache;
- protected $phpEx;
+ protected $php_ext;
protected $extensions;
protected $extension_table;
protected $phpbb_root_path;
@@ -33,18 +35,20 @@ class phpbb_extension_manager
* Creates a manager and loads information from database
*
* @param dbal $db A database connection
+ * @param phpbb_config $config phpbb_config
* @param string $extension_table The name of the table holding extensions
* @param string $phpbb_root_path Path to the phpbb includes directory.
- * @param string $phpEx php file extension
+ * @param string $php_ext php file extension
* @param phpbb_cache_driver_interface $cache A cache instance or null
* @param string $cache_name The name of the cache variable, defaults to _ext
*/
- public function __construct(dbal $db, $extension_table, $phpbb_root_path, $phpEx = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext')
+ public function __construct(dbal $db, phpbb_config $config, $extension_table, $phpbb_root_path, $php_ext = '.php', phpbb_cache_driver_interface $cache = null, $cache_name = '_ext')
{
$this->phpbb_root_path = $phpbb_root_path;
$this->db = $db;
+ $this->config = $config;
$this->cache = $cache;
- $this->phpEx = $phpEx;
+ $this->php_ext = $php_ext;
$this->extension_table = $extension_table;
$this->cache_name = $cache_name;
@@ -121,6 +125,18 @@ class phpbb_extension_manager
}
/**
+ * Instantiates the metadata manager for the extension with the given name
+ *
+ * @param string $name The extension name
+ * @param string $template The template manager
+ * @return phpbb_extension_metadata_manager Instance of the metadata manager
+ */
+ public function create_extension_metadata_manager($name, phpbb_template $template)
+ {
+ return new phpbb_extension_metadata_manager($name, $this->db, $this, $this->phpbb_root_path, $this->php_ext, $template, $this->config);
+ }
+
+ /**
* Runs a step of the extension enabling process.
*
* Allows the exentension to enable in a long running script that works
@@ -362,7 +378,7 @@ class phpbb_extension_manager
RecursiveIteratorIterator::SELF_FIRST);
foreach ($iterator as $file_info)
{
- if ($file_info->isFile() && $file_info->getFilename() == 'ext' . $this->phpEx)
+ if ($file_info->isFile() && $file_info->getFilename() == 'ext' . $this->php_ext)
{
$ext_name = $iterator->getInnerIterator()->getSubPath();
@@ -432,7 +448,7 @@ class phpbb_extension_manager
}
return $disabled;
}
-
+
/**
* Check to see if a given extension is available on the filesystem
*
@@ -462,6 +478,6 @@ class phpbb_extension_manager
*/
public function get_finder()
{
- return new phpbb_extension_finder($this, $this->phpbb_root_path, $this->cache, $this->phpEx, $this->cache_name . '_finder');
+ return new phpbb_extension_finder($this, $this->phpbb_root_path, $this->cache, $this->php_ext, $this->cache_name . '_finder');
}
}
diff --git a/phpBB/includes/extension/metadata_manager.php b/phpBB/includes/extension/metadata_manager.php
new file mode 100644
index 0000000000..ea85bd3c4e
--- /dev/null
+++ b/phpBB/includes/extension/metadata_manager.php
@@ -0,0 +1,338 @@
+<?php
+/**
+*
+* @package extension
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* The extension metadata manager validates and gets meta-data for extensions
+*
+* @package extension
+*/
+class phpbb_extension_metadata_manager
+{
+ protected $phpEx;
+ protected $extension_manager;
+ protected $db;
+ protected $phpbb_root_path;
+ protected $template;
+ protected $ext_name;
+ protected $metadata;
+ protected $metadata_file;
+
+ /**
+ * Creates the metadata manager
+ *
+ * @param dbal $db A database connection
+ * @param string $extension_manager An instance of the phpbb extension manager
+ * @param string $phpbb_root_path Path to the phpbb includes directory.
+ * @param string $phpEx php file extension
+ */
+ public function __construct($ext_name, dbal $db, phpbb_extension_manager $extension_manager, $phpbb_root_path, $phpEx = '.php', phpbb_template $template, phpbb_config $config)
+ {
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->db = $db;
+ $this->config = $config;
+ $this->phpEx = $phpEx;
+ $this->template = $template;
+ $this->extension_manager = $extension_manager;
+ $this->ext_name = $ext_name;
+ $this->metadata = array();
+ $this->metadata_file = '';
+ }
+
+ /**
+ * Processes and gets the metadata requested
+ *
+ * @param string $element All for all metadata that it has and is valid, otherwise specify which section you want by its shorthand term.
+ * @return array Contains all of the requested metadata, throws an exception on failure
+ */
+ public function get_metadata($element = 'all')
+ {
+ $this->set_metadata_file();
+
+ // Fetch the metadata
+ $this->fetch_metadata();
+
+ // Clean the metadata
+ $this->clean_metadata_array();
+
+ switch ($element)
+ {
+ case 'all':
+ default:
+ // Validate the metadata
+ if (!$this->validate())
+ {
+ return false;
+ }
+
+ return $this->metadata;
+ break;
+
+ case 'name':
+ return ($this->validate('name')) ? $this->metadata['name'] : false;
+ break;
+
+ case 'display-name':
+ if (isset($this->metadata['extra']['display-name']))
+ {
+ return $this->metadata['extra']['display-name'];
+ }
+ else
+ {
+ return ($this->validate('name')) ? $this->metadata['name'] : false;
+ }
+ break;
+ }
+ }
+
+ /**
+ * Sets the filepath of the metadata file
+ *
+ * @return boolean Set to true if it exists, throws an exception on failure
+ */
+ private function set_metadata_file()
+ {
+ $ext_filepath = $this->extension_manager->get_extension_path($this->ext_name);
+ $metadata_filepath = $this->phpbb_root_path . $ext_filepath . 'composer.json';
+
+ $this->metadata_file = $metadata_filepath;
+
+ if (!file_exists($this->metadata_file))
+ {
+ throw new phpbb_extension_exception('The required file does not exist: ' . $this->metadata_file);
+ }
+ }
+
+ /**
+ * Gets the contents of the composer.json file
+ *
+ * @return bool True if success, throws an exception on failure
+ */
+ private function fetch_metadata()
+ {
+ if (!file_exists($this->metadata_file))
+ {
+ throw new phpbb_extension_exception('The required file does not exist: ' . $this->metadata_file);
+ }
+ else
+ {
+ if (!($file_contents = file_get_contents($this->metadata_file)))
+ {
+ throw new phpbb_extension_exception('file_get_contents failed on ' . $this->metadata_file);
+ }
+
+ if (($metadata = json_decode($file_contents, true)) === NULL)
+ {
+ throw new phpbb_extension_exception('json_decode failed on ' . $this->metadata_file);
+ }
+
+ $this->metadata = $metadata;
+
+ return true;
+ }
+ }
+
+ /**
+ * This array handles the cleaning of the array
+ *
+ * @return array Contains the cleaned metadata array
+ */
+ private function clean_metadata_array()
+ {
+ return $this->metadata;
+ }
+
+ /**
+ * Validate fields
+ *
+ * @param string $name ("all" for display and enable validation
+ * "display" for name, type, and authors
+ * "name", "type")
+ * @return Bool True if valid, throws an exception if invalid
+ */
+ public function validate($name = 'display')
+ {
+ // Basic fields
+ $fields = array(
+ 'name' => '#^[a-zA-Z0-9_\x7f-\xff]{2,}/[a-zA-Z0-9_\x7f-\xff]{2,}$#',
+ 'type' => '#^phpbb3-extension$#',
+ 'licence' => '#.+#',
+ 'version' => '#.+#',
+ );
+
+ switch ($name)
+ {
+ case 'all':
+ $this->validate('display');
+
+ $this->validate_enable();
+ break;
+
+ case 'display':
+ foreach ($fields as $field => $data)
+ {
+ $this->validate($field);
+ }
+
+ $this->validate_authors();
+ break;
+
+ default:
+ if (isset($fields[$name]))
+ {
+ if (!isset($this->metadata[$name]))
+ {
+ throw new phpbb_extension_exception("Required meta field '$name' has not been set.");
+ }
+
+ if (!preg_match($fields[$name], $this->metadata[$name]))
+ {
+ throw new phpbb_extension_exception("Meta field '$name' is invalid.");
+ }
+ }
+ break;
+ }
+
+ return true;
+ }
+
+ /**
+ * Validates the contents of the authors field
+ *
+ * @return boolean True when passes validation, throws exception if invalid
+ */
+ public function validate_authors()
+ {
+ if (empty($this->metadata['authors']))
+ {
+ throw new phpbb_extension_exception("Required meta field 'authors' has not been set.");
+ }
+
+ foreach ($this->metadata['authors'] as $author)
+ {
+ if (!isset($author['name']))
+ {
+ throw new phpbb_extension_exception("Required meta field 'author name' has not been set.");
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * This array handles the verification that this extension can be enabled on this board
+ *
+ * @return bool True if validation succeeded, False if failed
+ */
+ public function validate_enable()
+ {
+ // Check for phpBB, PHP versions
+ if (!$this->validate_require_phpbb() || !$this->validate_require_php())
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+
+ /**
+ * Validates the contents of the phpbb requirement field
+ *
+ * @return boolean True when passes validation
+ */
+ public function validate_require_phpbb()
+ {
+ if (!isset($this->metadata['require']['phpbb']))
+ {
+ return true;
+ }
+
+ return $this->_validate_version($this->metadata['require']['phpbb'], $this->config['version']);
+ }
+
+ /**
+ * Validates the contents of the php requirement field
+ *
+ * @return boolean True when passes validation
+ */
+ public function validate_require_php()
+ {
+ if (!isset($this->metadata['require']['php']))
+ {
+ return true;
+ }
+
+ return $this->_validate_version($this->metadata['require']['php'], phpversion());
+ }
+
+ /**
+ * Version validation helper
+ *
+ * @param string $string The string for comparing to a version
+ * @param string $current_version The version to compare to
+ * @return bool True/False if meets version requirements
+ */
+ private function _validate_version($string, $current_version)
+ {
+ // Allow them to specify their own comparison operator (ex: <3.1.2, >=3.1.0)
+ $comparison_matches = false;
+ preg_match('#[=<>]+#', $string, $comparison_matches);
+
+ if (!empty($comparison_matches))
+ {
+ return version_compare($current_version, str_replace(array($comparison_matches[0], ' '), '', $string), $comparison_matches[0]);
+ }
+
+ return version_compare($current_version, $string, '>=');
+ }
+
+ /**
+ * Outputs the metadata into the template
+ *
+ * @return null
+ */
+ public function output_template_data()
+ {
+ $this->template->assign_vars(array(
+ 'META_NAME' => htmlspecialchars($this->metadata['name']),
+ 'META_TYPE' => htmlspecialchars($this->metadata['type']),
+ 'META_DESCRIPTION' => (isset($this->metadata['description'])) ? htmlspecialchars($this->metadata['description']) : '',
+ 'META_HOMEPAGE' => (isset($this->metadata['homepage'])) ? $this->metadata['homepage'] : '',
+ 'META_VERSION' => (isset($this->metadata['version'])) ? htmlspecialchars($this->metadata['version']) : '',
+ 'META_TIME' => (isset($this->metadata['time'])) ? htmlspecialchars($this->metadata['time']) : '',
+ 'META_LICENCE' => htmlspecialchars($this->metadata['licence']),
+
+ 'META_REQUIRE_PHP' => (isset($this->metadata['require']['php'])) ? htmlspecialchars($this->metadata['require']['php']) : '',
+ 'META_REQUIRE_PHP_FAIL' => !$this->validate_require_php(),
+
+ 'META_REQUIRE_PHPBB' => (isset($this->metadata['require']['phpbb'])) ? htmlspecialchars($this->metadata['require']['phpbb']) : '',
+ 'META_REQUIRE_PHPBB_FAIL' => !$this->validate_require_phpbb(),
+
+ 'META_DISPLAY_NAME' => (isset($this->metadata['extra']['display-name'])) ? htmlspecialchars($this->metadata['extra']['display-name']) : '',
+ ));
+
+ foreach ($this->metadata['authors'] as $author)
+ {
+ $this->template->assign_block_vars('meta_authors', array(
+ 'AUTHOR_NAME' => htmlspecialchars($author['name']),
+ 'AUTHOR_EMAIL' => (isset($author['email'])) ? $author['email'] : '',
+ 'AUTHOR_HOMEPAGE' => (isset($author['homepage'])) ? $author['homepage'] : '',
+ 'AUTHOR_ROLE' => (isset($author['role'])) ? htmlspecialchars($author['role']) : '',
+ ));
+ }
+ }
+}
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index e40df93194..0c9421c12f 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -1069,32 +1069,209 @@ function style_select($default = '', $all = false)
}
/**
+* Format the timezone offset with hours and minutes
+*
+* @param int $tz_offset Timezone offset in seconds
+* @return string Normalized offset string: -7200 => -02:00
+* 16200 => +04:30
+*/
+function phpbb_format_timezone_offset($tz_offset)
+{
+ $sign = ($tz_offset < 0) ? '-' : '+';
+ $time_offset = abs($tz_offset);
+
+ $offset_seconds = $time_offset % 3600;
+ $offset_minutes = $offset_seconds / 60;
+ $offset_hours = ($time_offset - $offset_seconds) / 3600;
+
+ $offset_string = sprintf("%s%02d:%02d", $sign, $offset_hours, $offset_minutes);
+ return $offset_string;
+}
+
+/**
+* Compares two time zone labels.
+* Arranges them in increasing order by timezone offset.
+* Places UTC before other timezones in the same offset.
+*/
+function phpbb_tz_select_compare($a, $b)
+{
+ $a_sign = $a[3];
+ $b_sign = $b[3];
+ if ($a_sign != $b_sign)
+ {
+ return $a_sign == '-' ? -1 : 1;
+ }
+
+ $a_offset = substr($a, 4, 5);
+ $b_offset = substr($b, 4, 5);
+ if ($a_offset == $b_offset)
+ {
+ $a_name = substr($a, 12);
+ $b_name = substr($b, 12);
+ if ($a_name == $b_name)
+ {
+ return 0;
+ }
+ else if ($a_name == 'UTC')
+ {
+ return -1;
+ }
+ else if ($b_name == 'UTC')
+ {
+ return 1;
+ }
+ else
+ {
+ return $a_name < $b_name ? -1 : 1;
+ }
+ }
+ else
+ {
+ if ($a_sign == '-')
+ {
+ return $a_offset > $b_offset ? -1 : 1;
+ }
+ else
+ {
+ return $a_offset < $b_offset ? -1 : 1;
+ }
+ }
+}
+
+/**
+* Return list of timezone identifiers
+* We also add the selected timezone if we can create an object with it.
+* DateTimeZone::listIdentifiers seems to not add all identifiers to the list,
+* because some are only kept for backward compatible reasons. If the user has
+* a deprecated value, we add it here, so it can still be kept. Once the user
+* changed his value, there is no way back to deprecated values.
+*
+* @param string $selected_timezone Additional timezone that shall
+* be added to the list of identiers
+* @return array DateTimeZone::listIdentifiers and additional
+* selected_timezone if it is a valid timezone.
+*/
+function phpbb_get_timezone_identifiers($selected_timezone)
+{
+ $timezones = DateTimeZone::listIdentifiers();
+
+ if (!in_array($selected_timezone, $timezones))
+ {
+ try
+ {
+ // Add valid timezones that are currently selected but not returned
+ // by DateTimeZone::listIdentifiers
+ $validate_timezone = new DateTimeZone($selected_timezone);
+ $timezones[] = $selected_timezone;
+ }
+ catch (Exception $e)
+ {
+ }
+ }
+
+ return $timezones;
+}
+
+/**
* Pick a timezone
+*
+* @param string $default A timezone to select
+* @param boolean $truncate Shall we truncate the options text
+*
+* @return string Returns the options for timezone selector only
+*
+* @deprecated
*/
function tz_select($default = '', $truncate = false)
{
global $user;
- $tz_select = '';
- foreach ($user->lang['tz_zones'] as $offset => $zone)
+ $timezone_select = phpbb_timezone_select($user, $default, $truncate);
+ return $timezone_select['tz_select'];
+}
+
+/**
+* Options to pick a timezone and date/time
+*
+* @param phpbb_user $user Object of the current user
+* @param string $default A timezone to select
+* @param boolean $truncate Shall we truncate the options text
+*
+* @return array Returns an array, also containing the options for the time selector.
+*/
+function phpbb_timezone_select($user, $default = '', $truncate = false)
+{
+ static $timezones;
+
+ $default_offset = '';
+ if (!isset($timezones))
{
- if ($truncate)
+ $unsorted_timezones = phpbb_get_timezone_identifiers($default);
+
+ $timezones = array();
+ foreach ($unsorted_timezones as $timezone)
+ {
+ $tz = new DateTimeZone($timezone);
+ $dt = new phpbb_datetime($user, 'now', $tz);
+ $offset = $dt->getOffset();
+ $current_time = $dt->format($user->lang['DATETIME_FORMAT'], true);
+ $offset_string = phpbb_format_timezone_offset($offset);
+ $timezones['GMT' . $offset_string . ' - ' . $timezone] = array(
+ 'tz' => $timezone,
+ 'offest' => 'GMT' . $offset_string,
+ 'current' => $current_time,
+ );
+ if ($timezone === $default)
+ {
+ $default_offset = 'GMT' . $offset_string;
+ }
+ }
+ unset($unsorted_timezones);
+
+ uksort($timezones, 'phpbb_tz_select_compare');
+ }
+
+ $tz_select = $tz_dates = $opt_group = '';
+
+ foreach ($timezones as $timezone)
+ {
+ if ($opt_group != $timezone['offest'])
+ {
+ $tz_select .= ($opt_group) ? '</optgroup>' : '';
+ $tz_select .= '<optgroup label="' . $timezone['offest'] . ' - ' . $timezone['current'] . '">';
+ $opt_group = $timezone['offest'];
+
+ $selected = ($default_offset == $timezone['offest']) ? ' selected="selected"' : '';
+ $tz_dates .= '<option value="' . $timezone['offest'] . ' - ' . $timezone['current'] . '"' . $selected . '>' . $timezone['offest'] . ' - ' . $timezone['current'] . '</option>';
+ }
+
+ if (isset($user->lang['timezones'][$timezone['tz']]))
{
- $zone_trunc = truncate_string($zone, 50, 255, false, '...');
+ $title = $label = $user->lang['timezones'][$timezone['tz']];
}
else
{
- $zone_trunc = $zone;
+ // No label, we'll figure one out
+ $bits = explode('/', str_replace('_', ' ', $timezone['tz']));
+
+ $label = implode(' - ', $bits);
+ $title = $timezone['offest'] . ' - ' . $label;
}
- if (is_numeric($offset))
+ if ($truncate)
{
- $selected = ($offset == $default) ? ' selected="selected"' : '';
- $tz_select .= '<option title="' . $zone . '" value="' . $offset . '"' . $selected . '>' . $zone_trunc . '</option>';
+ $label = truncate_string($label, 50, 255, false, '...');
}
+
+ $selected = ($timezone['tz'] === $default) ? ' selected="selected"' : '';
+ $tz_select .= '<option title="' . $title . '" value="' . $timezone['tz'] . '"' . $selected . '>' . $label . '</option>';
}
+ $tz_select .= '</optgroup>';
- return $tz_select;
+ return array(
+ 'tz_select' => $tz_select,
+ 'tz_dates' => $tz_dates,
+ );
}
// Functions handling topic/post tracking/marking
@@ -1881,105 +2058,152 @@ function tracking_unserialize($string, $max_depth = 3)
// Pagination functions
/**
-* Pagination routine, generates page number sequence
-* tpl_prefix is for using different pagination blocks at one page
+* Generate template rendered pagination
+* Allows full control of rendering of pagination with the template
+*
+* @param object $template the template object
+* @param string $base_url is url prepended to all links generated within the function
+* @param string $block_var_name is the name assigned to the pagination data block within the template (example: <!-- BEGIN pagination -->)
+* @param string $start_name is the name of the parameter containing the first item of the given page (example: start=20)
+* @param int $num_items the total number of items, posts, etc., used to determine the number of pages to produce
+* @param int $per_page the number of items, posts, etc. to display per page, used to determine the number of pages to produce
+* @param int $start_item the item which should be considered currently active, used to determine the page we're on
+* @param bool $reverse_count determines whether we weight display of the list towards the start (false) or end (true) of the list
+* @param bool $ignore_on_page decides whether we enable an active (unlinked) item, used primarily for embedded lists
+* @return null
*/
-function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = false, $tpl_prefix = '')
+function phpbb_generate_template_pagination($template, $base_url, $block_var_name, $start_name, $num_items, $per_page, $start_item = 1, $reverse_count = false, $ignore_on_page = false)
{
- global $template, $user;
-
// Make sure $per_page is a valid value
$per_page = ($per_page <= 0) ? 1 : $per_page;
-
- $separator = '<span class="page-sep">' . $user->lang['COMMA_SEPARATOR'] . '</span>';
$total_pages = ceil($num_items / $per_page);
if ($total_pages == 1 || !$num_items)
{
- return false;
+ return;
}
$on_page = floor($start_item / $per_page) + 1;
$url_delim = (strpos($base_url, '?') === false) ? '?' : ((strpos($base_url, '?') === strlen($base_url) - 1) ? '' : '&amp;');
- $page_string = ($on_page == 1) ? '<strong>1</strong>' : '<a href="' . $base_url . '">1</a>';
-
- if ($total_pages > 5)
+ if ($reverse_count)
{
- $start_cnt = min(max(1, $on_page - 4), $total_pages - 5);
- $end_cnt = max(min($total_pages, $on_page + 4), 6);
-
- $page_string .= ($start_cnt > 1) ? '<span class="page-dots"> ... </span>' : $separator;
-
- for ($i = $start_cnt + 1; $i < $end_cnt; $i++)
- {
- $page_string .= ($i == $on_page) ? '<strong>' . $i . '</strong>' : '<a href="' . $base_url . "{$url_delim}start=" . (($i - 1) * $per_page) . '">' . $i . '</a>';
- if ($i < $end_cnt - 1)
- {
- $page_string .= $separator;
- }
- }
-
- $page_string .= ($end_cnt < $total_pages) ? '<span class="page-dots"> ... </span>' : $separator;
+ $start_page = ($total_pages > 5) ? $total_pages - 4 : 1;
+ $end_page = $total_pages;
}
else
{
- $page_string .= $separator;
-
- for ($i = 2; $i < $total_pages; $i++)
- {
- $page_string .= ($i == $on_page) ? '<strong>' . $i . '</strong>' : '<a href="' . $base_url . "{$url_delim}start=" . (($i - 1) * $per_page) . '">' . $i . '</a>';
- if ($i < $total_pages)
- {
- $page_string .= $separator;
- }
- }
+ // What we're doing here is calculating what the "start" and "end" pages should be. We
+ // do this by assuming pagination is "centered" around the currently active page with
+ // the three previous and three next page links displayed. Anything more than that and
+ // we display the ellipsis, likewise anything less.
+ //
+ // $start_page is the page at which we start creating the list. When we have five or less
+ // pages we start at page 1 since there will be no ellipsis displayed. Anymore than that
+ // and we calculate the start based on the active page. This is the min/max calculation.
+ // First (max) would we end up starting on a page less than 1? Next (min) would we end
+ // up starting so close to the end that we'd not display our minimum number of pages.
+ //
+ // $end_page is the last page in the list to display. Like $start_page we use a min/max to
+ // determine this number. Again at most five pages? Then just display them all. More than
+ // five and we first (min) determine whether we'd end up listing more pages than exist.
+ // We then (max) ensure we're displaying the minimum number of pages.
+ $start_page = ($total_pages > 5) ? min(max(1, $on_page - 3), $total_pages - 4) : 1;
+ $end_page = ($total_pages > 5) ? max(min($total_pages, $on_page + 3), 5) : $total_pages;
+ }
+
+ if ($on_page != $total_pages)
+ {
+ $template->assign_block_vars($block_var_name, array(
+ 'PAGE_NUMBER' => '',
+ 'PAGE_URL' => $base_url . $url_delim . $start_name . '=' . ($on_page * $per_page),
+ 'S_IS_CURRENT' => false,
+ 'S_IS_PREV' => false,
+ 'S_IS_NEXT' => true,
+ 'S_IS_ELLIPSIS' => false,
+ ));
}
- $page_string .= ($on_page == $total_pages) ? '<strong>' . $total_pages . '</strong>' : '<a href="' . $base_url . "{$url_delim}start=" . (($total_pages - 1) * $per_page) . '">' . $total_pages . '</a>';
-
- if ($add_prevnext_text)
+ // This do...while exists purely to negate the need for start and end assign_block_vars, i.e.
+ // to display the first and last page in the list plus any ellipsis. We use this loop to jump
+ // around a little within the list depending on where we're starting (and ending).
+ $at_page = 1;
+ do
{
- if ($on_page != 1)
+ $page_url = $base_url . (($at_page == 1) ? '' : $url_delim . $start_name . '=' . (($at_page - 1) * $per_page));
+
+ // We decide whether to display the ellipsis during the loop. The ellipsis is always
+ // displayed as either the second or penultimate item in the list. So are we at either
+ // of those points and of course do we even need to display it, i.e. is the list starting
+ // on at least page 3 and ending three pages before the final item.
+ $template->assign_block_vars($block_var_name, array(
+ 'PAGE_NUMBER' => $at_page,
+ 'PAGE_URL' => $page_url,
+ 'S_IS_CURRENT' => (!$ignore_on_page && $at_page == $on_page),
+ 'S_IS_NEXT' => false,
+ 'S_IS_PREV' => false,
+ 'S_IS_ELLIPSIS' => ($at_page == 2 && $start_page > 2) || ($at_page == $total_pages - 1 && $end_page < $total_pages - 1),
+ ));
+
+ // We may need to jump around in the list depending on whether we have or need to display
+ // the ellipsis. Are we on page 2 and are we more than one page away from the start
+ // of the list? Yes? Then we jump to the start of the list. Likewise are we at the end of
+ // the list and are there more than two pages left in total? Yes? Then jump to the penultimate
+ // page (so we can display the ellipsis next pass). Else, increment the counter and keep
+ // going
+ if ($at_page == 2 && $at_page < $start_page - 1)
{
- $page_string = '<a href="' . $base_url . "{$url_delim}start=" . (($on_page - 2) * $per_page) . '">' . $user->lang['PREVIOUS'] . '</a>&nbsp;&nbsp;' . $page_string;
+ $at_page = $start_page;
}
-
- if ($on_page != $total_pages)
+ else if ($at_page == $end_page && $end_page < $total_pages - 1)
+ {
+ $at_page = $total_pages - 1;
+ }
+ else
{
- $page_string .= '&nbsp;&nbsp;<a href="' . $base_url . "{$url_delim}start=" . ($on_page * $per_page) . '">' . $user->lang['NEXT'] . '</a>';
+ $at_page++;
}
}
+ while ($at_page <= $total_pages);
- $template->assign_vars(array(
- $tpl_prefix . 'BASE_URL' => $base_url,
- 'A_' . $tpl_prefix . 'BASE_URL' => addslashes($base_url),
- $tpl_prefix . 'PER_PAGE' => $per_page,
-
- $tpl_prefix . 'PREVIOUS_PAGE' => ($on_page == 1) ? '' : $base_url . "{$url_delim}start=" . (($on_page - 2) * $per_page),
- $tpl_prefix . 'NEXT_PAGE' => ($on_page == $total_pages) ? '' : $base_url . "{$url_delim}start=" . ($on_page * $per_page),
- $tpl_prefix . 'TOTAL_PAGES' => $total_pages,
- $tpl_prefix . 'CURRENT_PAGE' => $on_page,
- ));
-
- return $page_string;
+ if ($on_page != 1)
+ {
+ $template->assign_block_vars($block_var_name, array(
+ 'PAGE_NUMBER' => '',
+ 'PAGE_URL' => $base_url . $url_delim . $start_name . '=' . (($on_page - 2) * $per_page),
+ 'S_IS_CURRENT' => false,
+ 'S_IS_PREV' => true,
+ 'S_IS_NEXT' => false,
+ 'S_IS_ELLIPSIS' => false,
+ ));
+ }
}
/**
-* Return current page (pagination)
+* Return current page
+* This function also sets certain specific template variables
+*
+* @param object $template the template object
+* @param object $user the user object
+* @param string $base_url the base url used to call this page, used by Javascript for popup jump to page
+* @param int $num_items the total number of items, posts, topics, etc.
+* @param int $per_page the number of items, posts, etc. per page
+* @param int $start the item which should be considered currently active, used to determine the page we're on
+* @return null
*/
-function on_page($num_items, $per_page, $start)
+function phpbb_on_page($template, $user, $base_url, $num_items, $per_page, $start)
{
- global $template, $user;
-
// Make sure $per_page is a valid value
$per_page = ($per_page <= 0) ? 1 : $per_page;
$on_page = floor($start / $per_page) + 1;
$template->assign_vars(array(
- 'ON_PAGE' => $on_page)
- );
+ 'PER_PAGE' => $per_page,
+ 'ON_PAGE' => $on_page,
+
+ 'A_BASE_URL' => addslashes($base_url),
+ ));
return sprintf($user->lang['PAGE_OF'], $on_page, max(ceil($num_items / $per_page), 1));
}
@@ -2007,6 +2231,7 @@ function on_page($num_items, $per_page, $start)
function append_sid($url, $params = false, $is_amp = true, $session_id = false)
{
global $_SID, $_EXTRA_URL, $phpbb_hook;
+ global $phpbb_dispatcher;
if ($params === '' || (is_array($params) && empty($params)))
{
@@ -2014,6 +2239,39 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false)
$params = false;
}
+ $append_sid_overwrite = false;
+
+ /**
+ * This event can either supplement or override the append_sid() function
+ *
+ * To override this function, the event must set $append_sid_overwrite to
+ * the new URL value, which will be returned following the event
+ *
+ * @event core.append_sid
+ * @var string url The url the session id needs
+ * to be appended to (can have
+ * params)
+ * @var mixed params String or array of additional
+ * url parameters
+ * @var bool is_amp Is url using &amp; (true) or
+ * & (false)
+ * @var bool|string session_id Possibility to use a custom
+ * session id (string) instead of
+ * the global one (false)
+ * @var bool|string append_sid_overwrite Overwrite function (string
+ * URL) or not (false)
+ * @since 3.1-A1
+ */
+ $vars = array('url', 'params', 'is_amp', 'session_id', 'append_sid_overwrite');
+ extract($phpbb_dispatcher->trigger_event('core.append_sid', compact($vars)));
+
+ if ($append_sid_overwrite)
+ {
+ return $append_sid_overwrite;
+ }
+
+ // The following hook remains for backwards compatibility, though use of
+ // the event above is preferred.
// Developers using the hook function need to globalise the $_SID and $_EXTRA_URL on their own and also handle it appropriately.
// They could mimic most of what is within this function
if (!empty($phpbb_hook) && $phpbb_hook->call_hook(__FUNCTION__, $url, $params, $is_amp, $session_id))
@@ -2597,7 +2855,7 @@ function check_form_key($form_name, $timespan = false, $return_page = '', $trigg
$diff = time() - $creation_time;
// If creation_time and the time() now is zero we can assume it was not a human doing this (the check for if ($diff)...
- if ($diff && ($diff <= $timespan || $timespan === -1))
+ if (defined('DEBUG_TEST') || $diff && ($diff <= $timespan || $timespan === -1))
{
$token_sid = ($user->data['user_id'] == ANONYMOUS && !empty($config['form_token_sid_guests'])) ? $user->session_id : '';
$key = sha1($creation_time . $user->data['user_form_salt'] . $form_name . $token_sid);
@@ -2786,11 +3044,11 @@ function login_box($redirect = '', $l_explain = '', $l_success = '', $admin = fa
trigger_error('NO_AUTH_ADMIN');
}
- $password = request_var('password_' . $credential, '', true);
+ $password = $request->untrimmed_variable('password_' . $credential, '', true);
}
else
{
- $password = request_var('password', '', true);
+ $password = $request->untrimmed_variable('password', '', true);
}
$username = request_var('username', '', true);
@@ -3119,7 +3377,7 @@ function parse_cfg_file($filename, $lines = false)
$parsed_items[$key] = $value;
}
-
+
if (isset($parsed_items['parent']) && isset($parsed_items['name']) && $parsed_items['parent'] == $parsed_items['name'])
{
unset($parsed_items['parent']);
@@ -3889,7 +4147,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline)
echo ' </div>';
echo ' </div>';
echo ' <div id="page-footer">';
- echo ' Powered by <a href="http://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group';
+ echo ' Powered by <a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group';
echo ' </div>';
echo '</div>';
echo '</body>';
@@ -4529,6 +4787,31 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
define('HEADER_INC', true);
+ // A listener can set this variable to `true` when it overrides this function
+ $page_header_override = false;
+
+ /**
+ * Execute code and/or overwrite page_header()
+ *
+ * @event core.page_header
+ * @var string page_title Page title
+ * @var bool display_online_list Do we display online users list
+ * @var string item Restrict online users to a certain
+ * session item, e.g. forum for
+ * session_forum_id
+ * @var int item_id Restrict online users to item id
+ * @var bool page_header_override Shall we return instead of running
+ * the rest of page_header()
+ * @since 3.1-A1
+ */
+ $vars = array('page_title', 'display_online_list', 'item_id', 'item', 'page_header_override');
+ extract($phpbb_dispatcher->trigger_event('core.page_header', compact($vars)));
+
+ if ($page_header_override)
+ {
+ return;
+ }
+
// gzip_compression
if ($config['gzip_compress'])
{
@@ -4654,9 +4937,6 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
$board_url = generate_board_url() . '/';
$web_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? $board_url : $phpbb_root_path;
- // Which timezone?
- $tz = ($user->data['user_id'] != ANONYMOUS) ? strval(doubleval($user->data['user_timezone'])) : strval(doubleval($config['board_timezone']));
-
// Send a proper content-language to the output
$user_lang = $user->lang['USER_LANG'];
if (strpos($user_lang, '-x-') !== false)
@@ -4679,6 +4959,14 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
}
}
+ $dt = new phpbb_datetime($user, 'now', $user->timezone);
+ $timezone_offset = 'GMT' . phpbb_format_timezone_offset($dt->getOffset());
+ $timezone_name = $user->timezone->getName();
+ if (isset($user->lang['timezones'][$timezone_name]))
+ {
+ $timezone_name = $user->lang['timezones'][$timezone_name];
+ }
+
// The following assigns all _common_ variables that may be used at any point in a template.
$template->assign_vars(array(
'SITENAME' => $config['sitename'],
@@ -4706,6 +4994,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'L_LOGIN_LOGOUT' => $l_login_logout,
'L_INDEX' => $user->lang['FORUM_INDEX'],
+ 'L_SITE_HOME' => ($config['site_home_text'] !== '') ? $config['site_home_text'] : $user->lang['HOME'],
'L_ONLINE_EXPLAIN' => $l_online_time,
'U_PRIVATEMSGS' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&amp;folder=inbox'),
@@ -4717,6 +5006,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'U_LOGIN_LOGOUT' => $u_login_logout,
'U_INDEX' => append_sid("{$phpbb_root_path}index.$phpEx"),
'U_SEARCH' => append_sid("{$phpbb_root_path}search.$phpEx"),
+ 'U_SITE_HOME' => $config['site_home_url'],
'U_REGISTER' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=register'),
'U_PROFILE' => append_sid("{$phpbb_root_path}ucp.$phpEx"),
'U_MODCP' => append_sid("{$phpbb_root_path}mcp.$phpEx", false, true, $user->session_id),
@@ -4746,7 +5036,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'S_CONTENT_FLOW_BEGIN' => ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right',
'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left',
'S_CONTENT_ENCODING' => 'UTF-8',
- 'S_TIMEZONE' => ($user->data['user_dst'] || ($user->data['user_id'] == ANONYMOUS && $config['board_dst'])) ? sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], $user->lang['tz']['dst']) : sprintf($user->lang['ALL_TIMES'], $user->lang['tz'][$tz], ''),
+ 'S_TIMEZONE' => sprintf($user->lang['ALL_TIMES'], $timezone_offset, $timezone_name),
'S_DISPLAY_ONLINE_LIST' => ($l_online_time) ? 1 : 0,
'S_DISPLAY_SEARCH' => (!$config['load_search']) ? 0 : (isset($auth) ? ($auth->acl_get('u_search') && $auth->acl_getf_global('f_search')) : 1),
'S_DISPLAY_PM' => ($config['allow_privmsg'] && !empty($user->data['is_registered']) && ($auth->acl_get('u_readpm') || $auth->acl_get('u_sendpm'))) ? true : false,
@@ -4804,9 +5094,6 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
'A_COOKIE_SETTINGS' => addslashes('; path=' . $config['cookie_path'] . ((!$config['cookie_domain'] || $config['cookie_domain'] == 'localhost' || $config['cookie_domain'] == '127.0.0.1') ? '' : '; domain=' . $config['cookie_domain']) . ((!$config['cookie_secure']) ? '' : '; secure')),
));
- $vars = array('page_title', 'display_online_list', 'item_id', 'item');
- extract($phpbb_dispatcher->trigger_event('core.page_header', compact($vars)));
-
// application/xhtml+xml not used because of IE
header('Content-type: text/html; charset=UTF-8');
@@ -4829,7 +5116,27 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
function page_footer($run_cron = true)
{
global $db, $config, $template, $user, $auth, $cache, $starttime, $phpbb_root_path, $phpEx;
- global $request;
+ global $request, $phpbb_dispatcher;
+
+ // A listener can set this variable to `true` when it overrides this function
+ $page_footer_override = false;
+
+ /**
+ * Execute code and/or overwrite page_footer()
+ *
+ * @event core.page_footer
+ * @var bool run_cron Shall we run cron tasks
+ * @var bool page_footer_override Shall we return instead of running
+ * the rest of page_footer()
+ * @since 3.1-A1
+ */
+ $vars = array('run_cron', 'page_footer_override');
+ extract($phpbb_dispatcher->trigger_event('core.page_footer', compact($vars)));
+
+ if ($page_footer_override)
+ {
+ return;
+ }
// Output page creation time
if (defined('DEBUG'))
@@ -4863,7 +5170,7 @@ function page_footer($run_cron = true)
$template->assign_vars(array(
'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '',
'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '',
- 'CREDIT_LINE' => $user->lang('POWERED_BY', '<a href="http://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group'),
+ 'CREDIT_LINE' => $user->lang('POWERED_BY', '<a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group'),
'U_ACP' => ($auth->acl_get('a_') && !empty($user->data['is_registered'])) ? append_sid("{$phpbb_root_path}adm/index.$phpEx", false, true, $user->session_id) : '')
);
@@ -4914,6 +5221,15 @@ function page_footer($run_cron = true)
function garbage_collection()
{
global $cache, $db;
+ global $phpbb_dispatcher;
+
+ /**
+ * Unload some objects, to free some memory, before we finish our task
+ *
+ * @event core.garbage_collection
+ * @since 3.1-A1
+ */
+ $phpbb_dispatcher->dispatch('core.garbage_collection');
// Unload cache, must be done before the DB connection if closed
if (!empty($cache))
diff --git a/phpBB/includes/functions_acp.php b/phpBB/includes/functions_acp.php
index dc61859363..11cc1f6dd8 100644
--- a/phpBB/includes/functions_acp.php
+++ b/phpBB/includes/functions_acp.php
@@ -22,6 +22,7 @@ function adm_page_header($page_title)
{
global $config, $db, $user, $template;
global $phpbb_root_path, $phpbb_admin_path, $phpEx, $SID, $_SID;
+ global $phpbb_dispatcher;
if (defined('HEADER_INC'))
{
@@ -30,6 +31,26 @@ function adm_page_header($page_title)
define('HEADER_INC', true);
+ // A listener can set this variable to `true` when it overrides this function
+ $adm_page_header_override = false;
+
+ /**
+ * Execute code and/or overwrite adm_page_header()
+ *
+ * @event core.adm_page_header
+ * @var string page_title Page title
+ * @var bool adm_page_header_override Shall we return instead of
+ * running the rest of adm_page_header()
+ * @since 3.1-A1
+ */
+ $vars = array('page_title', 'adm_page_header_override');
+ extract($phpbb_dispatcher->trigger_event('core.adm_page_header', compact($vars)));
+
+ if ($adm_page_header_override)
+ {
+ return;
+ }
+
// gzip_compression
if ($config['gzip_compress'])
{
@@ -96,7 +117,27 @@ function adm_page_footer($copyright_html = true)
{
global $db, $config, $template, $user, $auth, $cache;
global $starttime, $phpbb_root_path, $phpbb_admin_path, $phpEx;
- global $request;
+ global $request, $phpbb_dispatcher;
+
+ // A listener can set this variable to `true` when it overrides this function
+ $adm_page_footer_override = false;
+
+ /**
+ * Execute code and/or overwrite adm_page_footer()
+ *
+ * @event core.adm_page_footer
+ * @var bool copyright_html Shall we display the copyright?
+ * @var bool adm_page_footer_override Shall we return instead of
+ * running the rest of adm_page_footer()
+ * @since 3.1-A1
+ */
+ $vars = array('copyright_html', 'adm_page_footer_override');
+ extract($phpbb_dispatcher->trigger_event('core.adm_page_footer', compact($vars)));
+
+ if ($adm_page_footer_override)
+ {
+ return;
+ }
// Output page creation time
if (defined('DEBUG'))
@@ -131,7 +172,7 @@ function adm_page_footer($copyright_html = true)
'DEBUG_OUTPUT' => (defined('DEBUG')) ? $debug_output : '',
'TRANSLATION_INFO' => (!empty($user->lang['TRANSLATION_INFO'])) ? $user->lang['TRANSLATION_INFO'] : '',
'S_COPYRIGHT_HTML' => $copyright_html,
- 'CREDIT_LINE' => $user->lang('POWERED_BY', '<a href="http://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group'),
+ 'CREDIT_LINE' => $user->lang('POWERED_BY', '<a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group'),
'T_JQUERY_LINK' => ($config['load_jquery_cdn'] && !empty($config['load_jquery_url'])) ? $config['load_jquery_url'] : "{$phpbb_root_path}assets/javascript/jquery.js",
'S_JQUERY_FALLBACK' => ($config['load_jquery_cdn']) ? true : false,
'VERSION' => $config['version'])
@@ -193,7 +234,7 @@ function h_radio($name, $input_ary, $input_default = false, $id = false, $key =
*/
function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
{
- global $user, $module;
+ global $user, $module, $phpbb_dispatcher;
$tpl = '';
$name = 'config[' . $config_key . ']';
@@ -305,6 +346,24 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
$tpl .= $vars['append'];
}
+ /**
+ * Overwrite the html code we display for the config value
+ *
+ * @event core.build_config_template
+ * @var array tpl_type Config type array:
+ * 0 => data type
+ * 1 [optional] => string: size, int: minimum
+ * 2 [optional] => string: max. length, int: maximum
+ * @var string key Should be used for the id attribute in html
+ * @var array new Array with the config values we display
+ * @var string name Should be used for the name attribute
+ * @var array vars Array with the options for the config
+ * @var string tpl The resulting html code we display
+ * @since 3.1-A1
+ */
+ $vars = array('tpl_type', 'key', 'new', 'name', 'vars', 'tpl');
+ extract($phpbb_dispatcher->trigger_event('core.build_config_template', compact($vars)));
+
return $tpl;
}
@@ -314,7 +373,8 @@ function build_cfg_template($tpl_type, $key, &$new, $config_key, $vars)
*/
function validate_config_vars($config_vars, &$cfg_array, &$error)
{
- global $phpbb_root_path, $user;
+ global $phpbb_root_path, $user, $phpbb_dispatcher;
+
$type = 0;
$min = 1;
$max = 2;
@@ -489,6 +549,24 @@ function validate_config_vars($config_vars, &$cfg_array, &$error)
}
break;
+
+ default:
+ /**
+ * Validate a config value
+ *
+ * @event core.validate_config_variable
+ * @var array cfg_array Array with config values
+ * @var string config_name Name of the config we validate
+ * @var array config_definition Array with the options for
+ * this config
+ * @var array error Array of errors, the errors should
+ * be strings only, language keys are
+ * not replaced afterwards
+ * @since 3.1-A1
+ */
+ $vars = array('cfg_array', 'config_name', 'config_definition', 'error');
+ extract($phpbb_dispatcher->trigger_event('core.validate_config_variable', compact($vars)));
+ break;
}
}
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 3ebd6682a9..5e2ee8c8f6 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -723,7 +723,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s
*/
function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync = true, $post_count_sync = true, $call_delete_topics = true)
{
- global $db, $config, $phpbb_root_path, $phpEx;
+ global $db, $config, $phpbb_root_path, $phpEx, $auth, $user;
if ($where_type === 'range')
{
@@ -855,7 +855,7 @@ function delete_posts($where_type, $where_ids, $auto_sync = true, $posted_sync =
}
$error = false;
- $search = new $search_type($error);
+ $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
if ($error)
{
@@ -2292,21 +2292,6 @@ function auto_prune($forum_id, $prune_mode, $prune_flags, $prune_days, $prune_fr
}
/**
-* remove_comments will strip the sql comment lines out of an uploaded sql file
-* specifically for mssql and postgres type files in the install....
-*
-* @deprecated Use phpbb_remove_comments() instead.
-*/
-function remove_comments(&$output)
-{
- // Remove /* */ comments (http://ostermiller.org/findcomment.html)
- $output = preg_replace('#/\*(.|[\r\n])*?\*/#', "\n", $output);
-
- // Return by reference and value.
- return $output;
-}
-
-/**
* Cache moderators, called whenever permissions are changed via admin_permissions. Changes of username
* and group names must be carried through for the moderators table
*/
diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php
index 72d8eabe76..4675394633 100644
--- a/phpBB/includes/functions_compress.php
+++ b/phpBB/includes/functions_compress.php
@@ -24,6 +24,11 @@ class compress
var $fp = 0;
/**
+ * @var array
+ */
+ protected $filelist = array();
+
+ /**
* Add file to archive
*/
function add_file($src, $src_rm_prefix = '', $src_add_prefix = '', $skip_files = '')
@@ -123,9 +128,41 @@ class compress
}
/**
+ * Checks if a file by that name as already been added and, if it has,
+ * returns a new, unique name.
+ *
+ * @param string $name The filename
+ * @return string A unique filename
+ */
+ protected function unique_filename($name)
+ {
+ if (isset($this->filelist[$name]))
+ {
+ $start = $name;
+ $ext = '';
+ $this->filelist[$name]++;
+
+ // Separate the extension off the end of the filename to preserve it
+ $pos = strrpos($name, '.');
+ if ($pos !== false)
+ {
+ $start = substr($name, 0, $pos);
+ $ext = substr($name, $pos);
+ }
+
+ return $start . '_' . $this->filelist[$name] . $ext;
+ }
+
+ $this->filelist[$name] = 0;
+ return $name;
+ }
+
+ /**
* Return available methods
+ *
+ * @return array Array of strings of available compression methods (.tar, .tar.gz, .zip, etc.)
*/
- function methods()
+ public static function methods()
{
$methods = array('.tar');
$available_methods = array('.tar.gz' => 'zlib', '.tar.bz2' => 'bz2', '.zip' => 'zlib');
@@ -361,6 +398,7 @@ class compress_zip extends compress
function data($name, $data, $is_dir = false, $stat)
{
$name = str_replace('\\', '/', $name);
+ $name = $this->unique_filename($name);
$hexdtime = pack('V', $this->unix_to_dos_time($stat[9]));
@@ -633,6 +671,7 @@ class compress_tar extends compress
*/
function data($name, $data, $is_dir = false, $stat)
{
+ $name = $this->unique_filename($name);
$this->wrote = true;
$fzwrite = ($this->isbz && function_exists('bzwrite')) ? 'bzwrite' : (($this->isgz && @extension_loaded('zlib')) ? 'gzwrite' : 'fwrite');
diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php
index 6b2ee98d7a..e7772e14fe 100644
--- a/phpBB/includes/functions_content.php
+++ b/phpBB/includes/functions_content.php
@@ -411,13 +411,33 @@ function strip_bbcode(&$text, $uid = '')
function generate_text_for_display($text, $uid, $bitfield, $flags)
{
static $bbcode;
+ global $phpbb_dispatcher;
if (!$text)
{
return '';
}
- $text = censor_text($text);
+ $censor_text = true;
+
+ /**
+ * Use this event to modify the text before it is parsed
+ *
+ * @event core.modify_text_for_display_before
+ * @var string text The text to parse
+ * @var string uid The BBCode UID
+ * @var string bitfield The BBCode Bitfield
+ * @var int flags The BBCode Flags
+ * @var bool censor_text Whether or not to apply word censors
+ * @since 3.1-A1
+ */
+ $vars = array('text', 'uid', 'bitfield', 'flags', 'censor_text');
+ extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_before', compact($vars)));
+
+ if ($censor_text)
+ {
+ $text = censor_text($text);
+ }
// Parse bbcode if bbcode uid stored and bbcode enabled
if ($uid && ($flags & OPTION_FLAG_BBCODE))
@@ -443,6 +463,19 @@ function generate_text_for_display($text, $uid, $bitfield, $flags)
$text = bbcode_nl2br($text);
$text = smiley_text($text, !($flags & OPTION_FLAG_SMILIES));
+ /**
+ * Use this event to modify the text after it is parsed
+ *
+ * @event core.modify_text_for_display_after
+ * @var string text The text to parse
+ * @var string uid The BBCode UID
+ * @var string bitfield The BBCode Bitfield
+ * @var int flags The BBCode Flags
+ * @since 3.1-A1
+ */
+ $vars = array('text', 'uid', 'bitfield', 'flags');
+ extract($phpbb_dispatcher->trigger_event('core.modify_text_for_display_after', compact($vars)));
+
return $text;
}
@@ -453,7 +486,23 @@ function generate_text_for_display($text, $uid, $bitfield, $flags)
*/
function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bbcode = false, $allow_urls = false, $allow_smilies = false)
{
- global $phpbb_root_path, $phpEx;
+ global $phpbb_root_path, $phpEx, $phpbb_dispatcher;
+
+ /**
+ * Use this event to modify the text before it is prepared for storage
+ *
+ * @event core.modify_text_for_storage_before
+ * @var string text The text to parse
+ * @var string uid The BBCode UID
+ * @var string bitfield The BBCode Bitfield
+ * @var int flags The BBCode Flags
+ * @var bool allow_bbcode Whether or not to parse BBCode
+ * @var bool allow_urls Whether or not to parse URLs
+ * @var bool allow_smilies Whether or not to parse Smilies
+ * @since 3.1-A1
+ */
+ $vars = array('text', 'uid', 'bitfield', 'flags', 'allow_bbcode', 'allow_urls', 'allow_smilies');
+ extract($phpbb_dispatcher->trigger_event('core.modify_text_for_storage_before', compact($vars)));
$uid = $bitfield = '';
$flags = (($allow_bbcode) ? OPTION_FLAG_BBCODE : 0) + (($allow_smilies) ? OPTION_FLAG_SMILIES : 0) + (($allow_urls) ? OPTION_FLAG_LINKS : 0);
@@ -482,6 +531,19 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb
$bitfield = $message_parser->bbcode_bitfield;
+ /**
+ * Use this event to modify the text after it is prepared for storage
+ *
+ * @event core.modify_text_for_storage_after
+ * @var string text The text to parse
+ * @var string uid The BBCode UID
+ * @var string bitfield The BBCode Bitfield
+ * @var int flags The BBCode Flags
+ * @since 3.1-A1
+ */
+ $vars = array('text', 'uid', 'bitfield', 'flags');
+ extract($phpbb_dispatcher->trigger_event('core.modify_text_for_storage_after', compact($vars)));
+
return;
}
@@ -491,10 +553,33 @@ function generate_text_for_storage(&$text, &$uid, &$bitfield, &$flags, $allow_bb
*/
function generate_text_for_edit($text, $uid, $flags)
{
- global $phpbb_root_path, $phpEx;
+ global $phpbb_root_path, $phpEx, $phpbb_dispatcher;
+
+ /**
+ * Use this event to modify the text before it is decoded for editing
+ *
+ * @event core.modify_text_for_edit_before
+ * @var string text The text to parse
+ * @var string uid The BBCode UID
+ * @var int flags The BBCode Flags
+ * @since 3.1-A1
+ */
+ $vars = array('text', 'uid', 'flags');
+ extract($phpbb_dispatcher->trigger_event('core.modify_text_for_edit_before', compact($vars)));
decode_message($text, $uid);
+ /**
+ * Use this event to modify the text after it is decoded for editing
+ *
+ * @event core.modify_text_for_edit_after
+ * @var string text The text to parse
+ * @var int flags The BBCode Flags
+ * @since 3.1-A1
+ */
+ $vars = array('text', 'flags');
+ extract($phpbb_dispatcher->trigger_event('core.modify_text_for_edit_after', compact($vars)));
+
return array(
'allow_bbcode' => ($flags & OPTION_FLAG_BBCODE) ? 1 : 0,
'allow_smilies' => ($flags & OPTION_FLAG_SMILIES) ? 1 : 0,
@@ -1175,6 +1260,7 @@ function truncate_string($string, $max_length = 60, $max_store_length = 255, $al
function get_username_string($mode, $user_id, $username, $username_colour = '', $guest_username = false, $custom_profile_url = false)
{
static $_profile_cache;
+ global $phpbb_dispatcher;
// We cache some common variables we need within this function
if (empty($_profile_cache))
@@ -1252,10 +1338,34 @@ function get_username_string($mode, $user_id, $username, $username_colour = '',
if (($mode == 'full' && !$profile_url) || $mode == 'no_profile')
{
- return str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_noprofile'] : $_profile_cache['tpl_noprofile_colour']);
+ $username_string = str_replace(array('{USERNAME_COLOUR}', '{USERNAME}'), array($username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_noprofile'] : $_profile_cache['tpl_noprofile_colour']);
+ }
+ else
+ {
+ $username_string = str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_profile'] : $_profile_cache['tpl_profile_colour']);
}
+
+ /**
+ * Use this event to change the output of get_username_string()
+ *
+ * @event core.modify_username_string
+ * @var string mode profile|username|colour|full|no_profile
+ * @var int user_id String or array of additional url
+ * parameters
+ * @var string username The user's username
+ * @var string username_colour The user's colour
+ * @var string guest_username Optional parameter to specify the
+ * guest username.
+ * @var string custom_profile_url Optional parameter to specify a
+ * profile url.
+ * @var string username_string The string that has been generated
+ * @var array _profile_cache Array of original return templates
+ * @since 3.1-A1
+ */
+ $vars = array('mode', 'user_id', 'username', 'username_colour', 'guest_username', 'custom_profile_url', 'username_string', '_profile_cache');
+ extract($phpbb_dispatcher->trigger_event('core.modify_username_string', compact($vars)));
- return str_replace(array('{PROFILE_URL}', '{USERNAME_COLOUR}', '{USERNAME}'), array($profile_url, $username_colour, $username), (!$username_colour) ? $_profile_cache['tpl_profile'] : $_profile_cache['tpl_profile_colour']);
+ return $username_string;
}
/**
diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php
index e9ec153c50..ac791e0d9b 100644
--- a/phpBB/includes/functions_convert.php
+++ b/phpBB/includes/functions_convert.php
@@ -1884,7 +1884,7 @@ function add_bots()
'user_email' => '',
'user_lang' => $config['default_lang'],
'user_style' => 1,
- 'user_timezone' => 0,
+ 'user_timezone' => 'UTC',
'user_allow_massemail' => 0,
);
diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index 545f75ad67..8328b9ee7a 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -22,7 +22,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
{
global $db, $auth, $user, $template;
global $phpbb_root_path, $phpEx, $config;
- global $request;
+ global $request, $phpbb_dispatcher;
$forum_rows = $subforums = $forum_ids = $forum_ids_moderator = $forum_moderators = $active_forum_ary = array();
$parent_id = $visible_forums = 0;
@@ -119,6 +119,16 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
'ORDER_BY' => 'f.left_id',
);
+ /**
+ * Event to modify the SQL query before the forum data is queried
+ *
+ * @event core.display_forums_modify_sql
+ * @var array sql_ary The SQL array to get the data of the forums
+ * @since 3.1-A1
+ */
+ $vars = array('sql_ary');
+ extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_sql', compact($vars)));
+
$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql);
@@ -127,6 +137,19 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
while ($row = $db->sql_fetchrow($result))
{
+ /**
+ * Event to modify the data set of a forum
+ *
+ * This event is triggered once per forum
+ *
+ * @event core.display_forums_modify_row
+ * @var int branch_root_id Last top-level forum
+ * @var array row The data of the forum
+ * @since 3.1-A1
+ */
+ $vars = array('branch_root_id', 'row');
+ extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_row', compact($vars)));
+
$forum_id = $row['forum_id'];
// Mark forums read?
@@ -260,6 +283,22 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
$forum_rows[$parent_id]['forum_id_last_post'] = $forum_id;
}
}
+
+ /**
+ * Event to modify the forum rows data set
+ *
+ * This event is triggered once per forum
+ *
+ * @event core.display_forums_modify_forum_rows
+ * @var array forum_rows Data array of all forums we display
+ * @var array subforums Data array of all subforums we display
+ * @var int branch_root_id Current top-level forum
+ * @var int parent_id Current parent forum
+ * @var array row The data of the forum
+ * @since 3.1-A1
+ */
+ $vars = array('forum_rows', 'subforums', 'branch_root_id', 'parent_id', 'row');
+ extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_forum_rows', compact($vars)));
}
$db->sql_freeresult($result);
@@ -411,7 +450,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
if ($display_moderators && !empty($forum_moderators[$forum_id]))
{
$l_moderator = (sizeof($forum_moderators[$forum_id]) == 1) ? $user->lang['MODERATOR'] : $user->lang['MODERATORS'];
- $moderators_list = implode(', ', $forum_moderators[$forum_id]);
+ $moderators_list = implode($user->lang['COMMA_SEPARATOR'], $forum_moderators[$forum_id]);
}
$l_post_click_count = ($row['forum_type'] == FORUM_LINK) ? 'CLICKS' : 'POSTS';
@@ -422,7 +461,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
{
$s_subforums_list[] = '<a href="' . $subforum['link'] . '" class="subforum ' . (($subforum['unread']) ? 'unread' : 'read') . '" title="' . (($subforum['unread']) ? $user->lang['UNREAD_POSTS'] : $user->lang['NO_UNREAD_POSTS']) . '">' . $subforum['name'] . '</a>';
}
- $s_subforums_list = (string) implode(', ', $s_subforums_list);
+ $s_subforums_list = (string) implode($user->lang['COMMA_SEPARATOR'], $s_subforums_list);
$catless = ($row['parent_id'] == $root_data['forum_id']) ? true : false;
if ($row['forum_type'] != FORUM_LINK)
@@ -443,7 +482,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
}
}
- $template->assign_block_vars('forumrow', array(
+ $forum_row = array(
'S_IS_CAT' => false,
'S_NO_CAT' => $catless && !$last_catless,
'S_IS_LINK' => ($row['forum_type'] == FORUM_LINK) ? true : false,
@@ -480,9 +519,24 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod
'U_UNAPPROVED_TOPICS' => ($row['forum_id_unapproved_topics']) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=unapproved_topics&amp;f=' . $row['forum_id_unapproved_topics']) : '',
'U_VIEWFORUM' => $u_viewforum,
'U_LAST_POSTER' => get_username_string('profile', $row['forum_last_poster_id'], $row['forum_last_poster_name'], $row['forum_last_poster_colour']),
- 'U_LAST_POST' => $last_post_url)
+ 'U_LAST_POST' => $last_post_url,
);
+ /**
+ * Modify the template data block of the forum
+ *
+ * This event is triggered once per forum
+ *
+ * @event core.display_forums_modify_template_vars
+ * @var array forum_row Template data of the forum
+ * @var array row The data of the forum
+ * @since 3.1-A1
+ */
+ $vars = array('forum_row', 'row');
+ extract($phpbb_dispatcher->trigger_event('core.display_forums_modify_template_vars', compact($vars)));
+
+ $template->assign_block_vars('forumrow', $forum_row);
+
// Assign subforums loop for style authors
foreach ($subforums_list as $subforum)
{
@@ -640,48 +694,6 @@ function get_forum_parents(&$forum_data)
}
/**
-* Generate topic pagination
-*/
-function topic_generate_pagination($replies, $url)
-{
- global $config, $user;
-
- // Make sure $per_page is a valid value
- $per_page = ($config['posts_per_page'] <= 0) ? 1 : $config['posts_per_page'];
-
- if (($replies + 1) > $per_page)
- {
- $total_pages = ceil(($replies + 1) / $per_page);
- $pagination = '';
-
- $times = 1;
- for ($j = 0; $j < $replies + 1; $j += $per_page)
- {
- $pagination .= '<a href="' . $url . ($j == 0 ? '' : '&amp;start=' . $j) . '">' . $times . '</a>';
- if ($times == 1 && $total_pages > 5)
- {
- $pagination .= '<span class="page-dots"> ... </span>';
-
- // Display the last three pages
- $times = $total_pages - 3;
- $j += ($total_pages - 4) * $per_page;
- }
- else if ($times < $total_pages)
- {
- $pagination .= '<span class="page-sep">' . $user->lang['COMMA_SEPARATOR'] . '</span>';
- }
- $times++;
- }
- }
- else
- {
- $pagination = '';
- }
-
- return $pagination;
-}
-
-/**
* Obtain list of moderators of each forum
*/
function get_moderators(&$forum_moderators, $forum_id = false)
@@ -872,7 +884,7 @@ function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$fold
*/
function display_custom_bbcodes()
{
- global $db, $template, $user;
+ global $db, $template, $user, $phpbb_dispatcher;
// Start counting from 22 for the bbcode ids (every bbcode takes two ids - opening/closing)
$num_predefined_bbcodes = 22;
@@ -892,17 +904,40 @@ function display_custom_bbcodes()
$row['bbcode_helpline'] = $user->lang[strtoupper($row['bbcode_helpline'])];
}
- $template->assign_block_vars('custom_tags', array(
+ $custom_tags = array(
'BBCODE_NAME' => "'[{$row['bbcode_tag']}]', '[/" . str_replace('=', '', $row['bbcode_tag']) . "]'",
'BBCODE_ID' => $num_predefined_bbcodes + ($i * 2),
'BBCODE_TAG' => $row['bbcode_tag'],
'BBCODE_HELPLINE' => $row['bbcode_helpline'],
'A_BBCODE_HELPLINE' => str_replace(array('&amp;', '&quot;', "'", '&lt;', '&gt;'), array('&', '"', "\'", '<', '>'), $row['bbcode_helpline']),
- ));
+ );
+
+ /**
+ * Modify the template data block of a bbcode
+ *
+ * This event is triggered once per bbcode
+ *
+ * @event core.display_custom_bbcodes_modify_row
+ * @var array custom_tags Template data of the bbcode
+ * @var array row The data of the bbcode
+ * @since 3.1-A1
+ */
+ $vars = array('custom_tags', 'row');
+ extract($phpbb_dispatcher->trigger_event('core.display_custom_bbcodes_modify_row', compact($vars)));
+
+ $template->assign_block_vars('custom_tags', $custom_tags);
$i++;
}
$db->sql_freeresult($result);
+
+ /**
+ * Display custom bbcodes
+ *
+ * @event core.display_custom_bbcodes
+ * @since 3.1-A1
+ */
+ $phpbb_dispatcher->dispatch('core.display_custom_bbcodes');
}
/**
@@ -1290,6 +1325,31 @@ function get_user_rank($user_rank, $user_posts, &$rank_title, &$rank_img, &$rank
function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $alt = 'USER_AVATAR', $ignore_config = false)
{
global $user, $config, $phpbb_root_path, $phpEx;
+ global $phpbb_dispatcher;
+
+ $overwrite_avatar = '';
+
+ /**
+ * Overwrite users avatar
+ *
+ * @event core.display_custom_bbcodes_modify_row
+ * @var string avatar Users assigned avatar name
+ * @var int avatar_type Type of avatar
+ * @var string avatar_width Width of users avatar
+ * @var string avatar_height Height of users avatar
+ * @var string alt Language string for alt tag within image
+ * Can be a language key or text
+ * @var bool ignore_config Ignores config and force displaying avatar
+ * @var string overwrite_avatar If set, this string will be the avatar
+ * @since 3.1-A1
+ */
+ $vars = array('avatar', 'avatar_type', 'avatar_width', 'avatar_height', 'alt', 'ignore_config', 'overwrite_avatar');
+ extract($phpbb_dispatcher->trigger_event('core.user_get_avatar', compact($vars)));
+
+ if ($overwrite_avatar)
+ {
+ return $overwrite_avatar;
+ }
if (empty($avatar) || !$avatar_type || (!$config['allow_avatar'] && !$ignore_config))
{
@@ -1327,3 +1387,39 @@ function get_user_avatar($avatar, $avatar_type, $avatar_width, $avatar_height, $
$avatar_img .= $avatar;
return '<img src="' . (str_replace(' ', '%20', $avatar_img)) . '" width="' . $avatar_width . '" height="' . $avatar_height . '" alt="' . ((!empty($user->lang[$alt])) ? $user->lang[$alt] : $alt) . '" />';
}
+
+/**
+* Generate a list of archive types available for compressing attachments
+*
+* @param string $param_key Either topic_id or post_id
+* @param string $param_val The value of the topic or post id
+* @param string $phpbb_root_path The root path of the phpBB installation
+* @param string $phpEx The PHP extension
+*
+* @return array Array containing the link and the type of compression
+*/
+function phpbb_gen_download_links($param_key, $param_val, $phpbb_root_path, $phpEx)
+{
+ if (!class_exists('compress'))
+ {
+ require $phpbb_root_path . 'includes/functions_compress.' . $phpEx;
+ }
+
+ $methods = compress::methods();
+ $links = array();
+
+ foreach ($methods as $method)
+ {
+ $exploded = explode('.', $method);
+ $type = array_pop($exploded);
+ $params = array('archive' => $method);
+ $params[$param_key] = $param_val;
+
+ $links[] = array(
+ 'LINK' => append_sid("{$phpbb_root_path}download/file.$phpEx", $params),
+ 'TYPE' => $type,
+ );
+ }
+
+ return $links;
+}
diff --git a/phpBB/includes/functions_download.php b/phpBB/includes/functions_download.php
index 1486113013..b6371dbecc 100644
--- a/phpBB/includes/functions_download.php
+++ b/phpBB/includes/functions_download.php
@@ -592,3 +592,132 @@ function phpbb_parse_range_request($request_array, $filesize)
);
}
}
+
+/**
+* Increments the download count of all provided attachments
+*
+* @param dbal $db The database object
+* @param array|int $ids The attach_id of each attachment
+*
+* @return null
+*/
+function phpbb_increment_downloads($db, $ids)
+{
+ if (!is_array($ids))
+ {
+ $ids = array($ids);
+ }
+
+ $sql = 'UPDATE ' . ATTACHMENTS_TABLE . '
+ SET download_count = download_count + 1
+ WHERE ' . $db->sql_in_set('attach_id', $ids);
+ $db->sql_query($sql);
+}
+
+/**
+* Handles authentication when downloading attachments from a post or topic
+*
+* @param dbal $db The database object
+* @param phpbb_auth $auth The authentication object
+* @param int $topic_id The id of the topic that we are downloading from
+*
+* @return null
+*/
+function phpbb_download_handle_forum_auth($db, $auth, $topic_id)
+{
+ $sql = 'SELECT t.forum_id, f.forum_password, f.parent_id
+ FROM ' . TOPICS_TABLE . ' t, ' . FORUMS_TABLE . " f
+ WHERE t.topic_id = " . (int) $topic_id . "
+ AND t.forum_id = f.forum_id";
+ $result = $db->sql_query($sql);
+ $row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ if ($auth->acl_get('u_download') && $auth->acl_get('f_download', $row['forum_id']))
+ {
+ if ($row && $row['forum_password'])
+ {
+ // Do something else ... ?
+ login_forum_box($row);
+ }
+ }
+ else
+ {
+ send_status_line(403, 'Forbidden');
+ trigger_error('SORRY_AUTH_VIEW_ATTACH');
+ }
+}
+
+/**
+* Handles authentication when downloading attachments from PMs
+*
+* @param dbal $db The database object
+* @param phpbb_auth $auth The authentication object
+* @param int $user_id The user id
+* @param int $msg_id The id of the PM that we are downloading from
+*
+* @return null
+*/
+function phpbb_download_handle_pm_auth($db, $auth, $user_id, $msg_id)
+{
+ if (!$auth->acl_get('u_pm_download'))
+ {
+ send_status_line(403, 'Forbidden');
+ trigger_error('SORRY_AUTH_VIEW_ATTACH');
+ }
+
+ $allowed = phpbb_download_check_pm_auth($db, $user_id, $msg_id);
+
+ if (!$allowed)
+ {
+ send_status_line(403, 'Forbidden');
+ trigger_error('ERROR_NO_ATTACHMENT');
+ }
+}
+
+/**
+* Checks whether a user can download from a particular PM
+*
+* @param dbal $db The database object
+* @param int $user_id The user id
+* @param int $msg_id The id of the PM that we are downloading from
+*
+* @return bool Whether the user is allowed to download from that PM or not
+*/
+function phpbb_download_check_pm_auth($db, $user_id, $msg_id)
+{
+ // Check if the attachment is within the users scope...
+ $sql = 'SELECT msg_id
+ FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE msg_id = ' . (int) $msg_id . '
+ AND (
+ user_id = ' . (int) $user_id . '
+ OR author_id = ' . (int) $user_id . '
+ )';
+ $result = $db->sql_query_limit($sql, 1);
+ $allowed = (bool) $db->sql_fetchfield('msg_id');
+ $db->sql_freeresult($result);
+
+ return $allowed;
+}
+
+/**
+* Cleans a filename of any characters that could potentially cause a problem on
+* a user's filesystem.
+*
+* @param string $filename The filename to clean
+*
+* @return string The cleaned filename
+*/
+function phpbb_download_clean_filename($filename)
+{
+ $bad_chars = array("'", "\\", ' ', '/', ':', '*', '?', '"', '<', '>', '|');
+
+ // rawurlencode to convert any potentially 'bad' characters that we missed
+ $filename = rawurlencode(str_replace($bad_chars, '_', $filename));
+
+ // Turn the %xx entities created by rawurlencode to _
+ $filename = preg_replace("/%(\w{2})/", '_', $filename);
+
+ return $filename;
+}
diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php
index 80f2bf940d..10ec13669b 100644
--- a/phpBB/includes/functions_install.php
+++ b/phpBB/includes/functions_install.php
@@ -49,7 +49,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'firebird',
'MODULE' => 'interbase',
'DELIM' => ';;',
- 'COMMENTS' => 'remove_remarks',
'DRIVER' => 'firebird',
'AVAILABLE' => true,
'2.0.x' => false,
@@ -59,7 +58,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'mysql_41',
'MODULE' => 'mysqli',
'DELIM' => ';',
- 'COMMENTS' => 'remove_remarks',
'DRIVER' => 'mysqli',
'AVAILABLE' => true,
'2.0.x' => true,
@@ -69,7 +67,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'mysql',
'MODULE' => 'mysql',
'DELIM' => ';',
- 'COMMENTS' => 'remove_remarks',
'DRIVER' => 'mysql',
'AVAILABLE' => true,
'2.0.x' => true,
@@ -79,7 +76,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'mssql',
'MODULE' => 'mssql',
'DELIM' => 'GO',
- 'COMMENTS' => 'remove_comments',
'DRIVER' => 'mssql',
'AVAILABLE' => true,
'2.0.x' => true,
@@ -89,7 +85,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'mssql',
'MODULE' => 'odbc',
'DELIM' => 'GO',
- 'COMMENTS' => 'remove_comments',
'DRIVER' => 'mssql_odbc',
'AVAILABLE' => true,
'2.0.x' => true,
@@ -99,7 +94,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'mssql',
'MODULE' => 'sqlsrv',
'DELIM' => 'GO',
- 'COMMENTS' => 'remove_comments',
'DRIVER' => 'mssqlnative',
'AVAILABLE' => true,
'2.0.x' => false,
@@ -109,7 +103,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'oracle',
'MODULE' => 'oci8',
'DELIM' => '/',
- 'COMMENTS' => 'remove_comments',
'DRIVER' => 'oracle',
'AVAILABLE' => true,
'2.0.x' => false,
@@ -119,7 +112,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'postgres',
'MODULE' => 'pgsql',
'DELIM' => ';',
- 'COMMENTS' => 'remove_comments',
'DRIVER' => 'postgres',
'AVAILABLE' => true,
'2.0.x' => true,
@@ -129,7 +121,6 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'SCHEMA' => 'sqlite',
'MODULE' => 'sqlite',
'DELIM' => ';',
- 'COMMENTS' => 'remove_remarks',
'DRIVER' => 'sqlite',
'AVAILABLE' => true,
'2.0.x' => false,
@@ -472,19 +463,6 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix,
}
/**
-* Removes comments from schema files
-*
-* @deprecated Use phpbb_remove_comments() instead.
-*/
-function remove_remarks(&$sql)
-{
- // Remove # style comments
- $sql = preg_replace('/\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $sql));
-
- // Return by reference
-}
-
-/**
* Removes "/* style" as well as "# style" comments from $input.
*
* @param string $input Input string
@@ -493,17 +471,11 @@ function remove_remarks(&$sql)
*/
function phpbb_remove_comments($input)
{
- if (!function_exists('remove_comments'))
- {
- global $phpbb_root_path, $phpEx;
- require($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
- }
-
- // Remove /* */ comments
- remove_comments($input);
+ // Remove /* */ comments (http://ostermiller.org/findcomment.html)
+ $input = preg_replace('#/\*(.|[\r\n])*?\*/#', "\n", $input);
// Remove # style comments
- remove_remarks($input);
+ $input = preg_replace('/\n{2,}/', "\n", preg_replace('/^#.*$/m', "\n", $input));
return $input;
}
@@ -550,10 +522,12 @@ function adjust_language_keys_callback($matches)
* @param string $dbms The name of the DBAL class to use
* @param array $load_extensions Array of additional extensions that should be loaded
* @param bool $debug If the debug constants should be enabled by default or not
+* @param bool $debug_test If the DEBUG_TEST constant should be added
+* NOTE: Only for use within the testing framework
*
* @return string The output to write to the file
*/
-function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug = false)
+function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug = false, $debug_test = false)
{
$load_extensions = implode(',', $load_extensions);
@@ -568,7 +542,7 @@ function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug =
'dbuser' => $data['dbuser'],
'dbpasswd' => htmlspecialchars_decode($data['dbpasswd']),
'table_prefix' => $data['table_prefix'],
- 'acm_type' => 'file',
+ 'acm_type' => 'phpbb_cache_driver_file',
'load_extensions' => $load_extensions,
);
@@ -590,5 +564,10 @@ function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug =
$config_data .= "// @define('DEBUG_EXTRA', true);\n";
}
+ if ($debug_test)
+ {
+ $config_data .= "@define('DEBUG_TEST', true);\n";
+ }
+
return $config_data;
}
diff --git a/phpBB/includes/functions_jabber.php b/phpBB/includes/functions_jabber.php
index d76309d5bb..3d8e403f4b 100644
--- a/phpBB/includes/functions_jabber.php
+++ b/phpBB/includes/functions_jabber.php
@@ -68,7 +68,7 @@ class jabber
}
$this->password = $password;
- $this->use_ssl = ($use_ssl && $this->can_use_ssl()) ? true : false;
+ $this->use_ssl = ($use_ssl && self::can_use_ssl()) ? true : false;
// Change port if we use SSL
if ($this->port == 5222 && $this->use_ssl)
@@ -83,7 +83,7 @@ class jabber
/**
* Able to use the SSL functionality?
*/
- function can_use_ssl()
+ static public function can_use_ssl()
{
// Will not work with PHP >= 5.2.1 or < 5.2.3RC2 until timeout problem with ssl hasn't been fixed (http://bugs.php.net/41236)
return ((version_compare(PHP_VERSION, '5.2.1', '<') || version_compare(PHP_VERSION, '5.2.3RC2', '>=')) && @extension_loaded('openssl')) ? true : false;
@@ -92,7 +92,7 @@ class jabber
/**
* Able to use TLS?
*/
- function can_use_tls()
+ static public function can_use_tls()
{
if (!@extension_loaded('openssl') || !function_exists('stream_socket_enable_crypto') || !function_exists('stream_get_meta_data') || !function_exists('socket_set_blocking') || !function_exists('stream_get_wrappers'))
{
@@ -442,7 +442,7 @@ class jabber
}
// Let's use TLS if SSL is not enabled and we can actually use it
- if (!$this->session['ssl'] && $this->can_use_tls() && $this->can_use_ssl() && isset($xml['stream:features'][0]['#']['starttls']))
+ if (!$this->session['ssl'] && self::can_use_tls() && self::can_use_ssl() && isset($xml['stream:features'][0]['#']['starttls']))
{
$this->add_to_log('Switching to TLS.');
$this->send("<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>\n");
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index c549f99091..171cf988ce 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -20,7 +20,7 @@ if (!defined('IN_PHPBB'))
*/
function generate_smilies($mode, $forum_id)
{
- global $db, $user, $config, $template;
+ global $db, $user, $config, $template, $phpbb_dispatcher;
global $phpEx, $phpbb_root_path;
$start = request_var('start', 0);
@@ -61,10 +61,7 @@ function generate_smilies($mode, $forum_id)
'body' => 'posting_smilies.html')
);
- $template->assign_var('PAGINATION',
- generate_pagination(append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=smilies&amp;f=' . $forum_id),
- $smiley_count, $config['smilies_per_page'], $start, true)
- );
+ generate_pagination(append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=smilies&amp;f=' . $forum_id), $smiley_count, $config['smilies_per_page'], $start);
}
$display_link = false;
@@ -126,6 +123,18 @@ function generate_smilies($mode, $forum_id)
}
}
+ /**
+ * This event is called after the smilies are populated
+ *
+ * @event core.generate_smilies_after
+ * @var string mode Mode of the smilies: window|inline
+ * @var int forum_id The forum ID we are currently in
+ * @var bool display_link Shall we display the "more smilies" link?
+ * @since 3.1-A1
+ */
+ $vars = array('mode', 'forum_id', 'display_link');
+ extract($phpbb_dispatcher->trigger_event('core.generate_smilies_after', compact($vars)));
+
if ($mode == 'inline' && $display_link)
{
$template->assign_vars(array(
@@ -287,13 +296,15 @@ function posting_gen_topic_icons($mode, $icon_id)
if (sizeof($icons))
{
+ $root_path = (defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH) ? generate_board_url() . '/' : $phpbb_root_path;
+
foreach ($icons as $id => $data)
{
if ($data['display'])
{
$template->assign_block_vars('topic_icon', array(
'ICON_ID' => $id,
- 'ICON_IMG' => $phpbb_root_path . $config['icons_path'] . '/' . $data['img'],
+ 'ICON_IMG' => $root_path . $config['icons_path'] . '/' . $data['img'],
'ICON_WIDTH' => $data['width'],
'ICON_HEIGHT' => $data['height'],
@@ -1167,7 +1178,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id
/**
* User Notification
*/
-function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id, $topic_id, $post_id)
+function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id, $topic_id, $post_id, $author_name = '')
{
global $db, $user, $config, $phpbb_root_path, $phpEx, $auth;
@@ -1338,6 +1349,7 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id
'USERNAME' => htmlspecialchars_decode($addr['name']),
'TOPIC_TITLE' => htmlspecialchars_decode($topic_title),
'FORUM_NAME' => htmlspecialchars_decode($forum_name),
+ 'AUTHOR_NAME' => htmlspecialchars_decode($author_name),
'U_FORUM' => generate_board_url() . "/viewforum.$phpEx?f=$forum_id",
'U_TOPIC' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id",
@@ -2373,7 +2385,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
}
$error = false;
- $search = new $search_type($error);
+ $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
if ($error)
{
@@ -2443,7 +2455,8 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
// Send Notifications
if (($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_approval)
{
- user_notification($mode, $subject, $data['topic_title'], $data['forum_name'], $data['forum_id'], $data['topic_id'], $data['post_id']);
+ $username = ($username) ? $username : $user->data['username'];
+ user_notification($mode, $subject, $data['topic_title'], $data['forum_name'], $data['forum_id'], $data['topic_id'], $data['post_id'], $username);
}
$params = $add_anchor = '';
diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php
index 8542e3ab0a..9e055a319f 100644
--- a/phpBB/includes/functions_privmsgs.php
+++ b/phpBB/includes/functions_privmsgs.php
@@ -1147,127 +1147,166 @@ function phpbb_delete_user_pms($user_id)
// Get PM Information for later deleting
// The two queries where split, so we can use our indexes
+ $undelivered_msg = $delete_ids = array();
+
// Part 1: get PMs the user received
- $sql = 'SELECT msg_id, author_id, folder_id, pm_unread, pm_new
+ $sql = 'SELECT msg_id
FROM ' . PRIVMSGS_TO_TABLE . '
WHERE user_id = ' . $user_id;
$result = $db->sql_query($sql);
- $undelivered_msg = $undelivered_user = $delete_ids = array();
while ($row = $db->sql_fetchrow($result))
{
- if ($row['author_id'] == $user_id && $row['folder_id'] == PRIVMSGS_NO_BOX)
- {
- // Undelivered messages
- $undelivered_msg[] = $row['msg_id'];
-
- if (isset($undelivered_user[$row['user_id']]))
- {
- ++$undelivered_user[$row['user_id']];
- }
- else
- {
- $undelivered_user[$row['user_id']] = 1;
- }
- }
-
- $delete_ids[(int) $row['msg_id']] = (int) $row['msg_id'];
+ $msg_id = (int) $row['msg_id'];
+ $delete_ids[$msg_id] = $msg_id;
}
$db->sql_freeresult($result);
- // Part 2: get PMs the user sent
- $sql = 'SELECT msg_id, author_id, folder_id, pm_unread, pm_new
+ // Part 2: get PMs the user sent, but have yet to be received
+ // We cannot simply delete them. First we have to check,
+ // whether another user already received and read the message.
+ $sql = 'SELECT msg_id
FROM ' . PRIVMSGS_TO_TABLE . '
WHERE author_id = ' . $user_id . '
- AND folder_id = ' . PRIVMSGS_NO_BOX;
+ AND folder_id = ' . PRIVMSGS_NO_BOX;
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
- if ($row['author_id'] == $user_id && $row['folder_id'] == PRIVMSGS_NO_BOX)
- {
- // Undelivered messages
- $undelivered_msg[] = $row['msg_id'];
-
- if (isset($undelivered_user[$row['user_id']]))
- {
- ++$undelivered_user[$row['user_id']];
- }
- else
- {
- $undelivered_user[$row['user_id']] = 1;
- }
- }
-
- $delete_ids[(int) $row['msg_id']] = (int) $row['msg_id'];
+ $msg_id = (int) $row['msg_id'];
+ $undelivered_msg[$msg_id] = $msg_id;
}
$db->sql_freeresult($result);
- if (empty($delete_ids))
+ if (empty($delete_ids) && empty($undelivered_msg))
{
return false;
}
$db->sql_transaction('begin');
- if (sizeof($undelivered_msg))
- {
- $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
- WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg);
- $db->sql_query($sql);
- }
+ if (!empty($undelivered_msg))
+ {
+ // A pm is delivered, if for any recipient the message was moved
+ // from their NO_BOX to another folder. We do not delete such
+ // messages, but only delete them for users, who have not yet
+ // received them.
+ $sql = 'SELECT msg_id
+ FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE author_id = ' . $user_id . '
+ AND folder_id <> ' . PRIVMSGS_NO_BOX . '
+ AND folder_id <> ' . PRIVMSGS_OUTBOX . '
+ AND folder_id <> ' . PRIVMSGS_SENTBOX;
+ $result = $db->sql_query($sql);
- // Reset the user´s pm count to 0
- if (isset($undelivered_user[$user_id]))
- {
- $sql = 'UPDATE ' . USERS_TABLE . '
- SET user_new_privmsg = 0,
- user_unread_privmsg = 0
- WHERE user_id = ' . $user_id;
- $db->sql_query($sql);
- unset($undelivered_user[$user_id]);
- }
+ $delivered_msg = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $msg_id = (int) $row['msg_id'];
+ $delivered_msg[$msg_id] = $msg_id;
+ unset($undelivered_msg[$msg_id]);
+ }
+ $db->sql_freeresult($result);
- foreach ($undelivered_user as $_user_id => $count)
- {
- $sql = 'UPDATE ' . USERS_TABLE . '
- SET user_new_privmsg = user_new_privmsg - ' . $count . ',
- user_unread_privmsg = user_unread_privmsg - ' . $count . '
- WHERE user_id = ' . $_user_id;
- $db->sql_query($sql);
- }
+ $undelivered_user = array();
- // Delete private message data
- $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . "
- WHERE user_id = $user_id
- AND " . $db->sql_in_set('msg_id', $delete_ids);
- $db->sql_query($sql);
+ // Count the messages we delete, so we can correct the user pm data
+ $sql = 'SELECT user_id, COUNT(msg_id) as num_undelivered_privmsgs
+ FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE author_id = ' . $user_id . '
+ AND folder_id = ' . PRIVMSGS_NO_BOX . '
+ AND ' . $db->sql_in_set('msg_id', array_merge($undelivered_msg, $delivered_msg)) . '
+ GROUP BY user_id';
+ $result = $db->sql_query($sql);
- // Now we have to check which messages we can delete completely
- $sql = 'SELECT msg_id
- FROM ' . PRIVMSGS_TO_TABLE . '
- WHERE ' . $db->sql_in_set('msg_id', $delete_ids);
- $result = $db->sql_query($sql);
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $num_pms = (int) $row['num_undelivered_privmsgs'];
+ $undelivered_user[$num_pms][] = (int) $row['user_id'];
- while ($row = $db->sql_fetchrow($result))
- {
- unset($delete_ids[$row['msg_id']]);
+ if (sizeof($undelivered_user[$num_pms]) > 50)
+ {
+ // If there are too many users affected the query might get
+ // too long, so we update the value for the first bunch here.
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET user_new_privmsg = user_new_privmsg - ' . $num_pms . ',
+ user_unread_privmsg = user_unread_privmsg - ' . $num_pms . '
+ WHERE ' . $db->sql_in_set('user_id', $undelivered_user[$num_pms]);
+ $db->sql_query($sql);
+ unset($undelivered_user[$num_pms]);
+ }
+ }
+ $db->sql_freeresult($result);
+
+ foreach ($undelivered_user as $num_pms => $undelivered_user_set)
+ {
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET user_new_privmsg = user_new_privmsg - ' . $num_pms . ',
+ user_unread_privmsg = user_unread_privmsg - ' . $num_pms . '
+ WHERE ' . $db->sql_in_set('user_id', $undelivered_user_set);
+ $db->sql_query($sql);
+ }
+
+ if (!empty($delivered_msg))
+ {
+ $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE folder_id = ' . PRIVMSGS_NO_BOX . '
+ AND ' . $db->sql_in_set('msg_id', $delivered_msg);
+ $db->sql_query($sql);
+ }
+
+ if (!empty($undelivered_msg))
+ {
+ $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg);
+ $db->sql_query($sql);
+
+ $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
+ WHERE ' . $db->sql_in_set('msg_id', $undelivered_msg);
+ $db->sql_query($sql);
+ }
}
- $db->sql_freeresult($result);
+
+ // Reset the user's pm count to 0
+ $sql = 'UPDATE ' . USERS_TABLE . '
+ SET user_new_privmsg = 0,
+ user_unread_privmsg = 0
+ WHERE user_id = ' . $user_id;
+ $db->sql_query($sql);
+
+ // Delete private message data of the user
+ $sql = 'DELETE FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE user_id = ' . (int) $user_id;
+ $db->sql_query($sql);
if (!empty($delete_ids))
{
- // Check if there are any attachments we need to remove
- if (!function_exists('delete_attachments'))
+ // Now we have to check which messages we can delete completely
+ $sql = 'SELECT msg_id
+ FROM ' . PRIVMSGS_TO_TABLE . '
+ WHERE ' . $db->sql_in_set('msg_id', $delete_ids);
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
{
- include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
+ unset($delete_ids[$row['msg_id']]);
}
+ $db->sql_freeresult($result);
- delete_attachments('message', $delete_ids, false);
+ if (!empty($delete_ids))
+ {
+ // Check if there are any attachments we need to remove
+ if (!function_exists('delete_attachments'))
+ {
+ include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
+ }
- $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
- WHERE ' . $db->sql_in_set('msg_id', $delete_ids);
- $db->sql_query($sql);
+ delete_attachments('message', $delete_ids, false);
+
+ $sql = 'DELETE FROM ' . PRIVMSGS_TABLE . '
+ WHERE ' . $db->sql_in_set('msg_id', $delete_ids);
+ $db->sql_query($sql);
+ }
}
// Set the remaining author id to anonymous
@@ -2045,7 +2084,7 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode
'SUBJECT' => $subject,
'SENT_DATE' => $user->format_date($row['message_time']),
'MESSAGE' => $message,
- 'FOLDER' => implode(', ', $row['folder']),
+ 'FOLDER' => implode($user->lang['COMMA_SEPARATOR'], $row['folder']),
'DECODED_MESSAGE' => $decoded_message,
'S_CURRENT_MSG' => ($row['msg_id'] == $msg_id),
diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php
index 3399334f94..10af997bff 100644
--- a/phpBB/includes/functions_profile_fields.php
+++ b/phpBB/includes/functions_profile_fields.php
@@ -121,7 +121,7 @@ class custom_profile
case FIELD_BOOL:
$field_value = (bool) $field_value;
-
+
if (!$field_value && $field_data['field_required'])
{
return 'FIELD_REQUIRED';
@@ -133,7 +133,7 @@ class custom_profile
{
return false;
}
-
+
$field_value = (int) $field_value;
if ($field_value < $field_data['field_minlen'])
@@ -455,6 +455,8 @@ class custom_profile
$user_fields = array();
+ $user_ids = $user_id;
+
// Go through the fields in correct order
foreach (array_keys($this->profile_cache) as $used_ident)
{
@@ -463,6 +465,15 @@ class custom_profile
$user_fields[$user_id][$used_ident]['value'] = $row['pf_' . $used_ident];
$user_fields[$user_id][$used_ident]['data'] = $this->profile_cache[$used_ident];
}
+
+ foreach ($user_ids as $user_id)
+ {
+ if (!isset($user_fields[$user_id][$used_ident]) && $this->profile_cache[$used_ident]['field_show_novalue'])
+ {
+ $user_fields[$user_id][$used_ident]['value'] = '';
+ $user_fields[$user_id][$used_ident]['data'] = $this->profile_cache[$used_ident];
+ }
+ }
}
return $user_fields;
@@ -520,7 +531,7 @@ class custom_profile
switch ($this->profile_types[$field_type])
{
case 'int':
- if ($value === '')
+ if ($value === '' && !$ident_ary['data']['field_show_novalue'])
{
return NULL;
}
@@ -529,7 +540,7 @@ class custom_profile
case 'string':
case 'text':
- if (!$value)
+ if (!$value && !$ident_ary['data']['field_show_novalue'])
{
return NULL;
}
@@ -547,16 +558,19 @@ class custom_profile
$month = (isset($date[1])) ? (int) $date[1] : 0;
$year = (isset($date[2])) ? (int) $date[2] : 0;
- if (!$day && !$month && !$year)
+ if (!$day && !$month && !$year && !$ident_ary['data']['field_show_novalue'])
{
return NULL;
}
else if ($day && $month && $year)
{
global $user;
- // Date should display as the same date for every user regardless of timezone, so remove offset
- // to compensate for the offset added by phpbb_user::format_date()
- return $user->format_date(gmmktime(0, 0, 0, $month, $day, $year) - ($user->timezone + $user->dst), $user->lang['DATE_FORMAT'], true);
+ // Date should display as the same date for every user regardless of timezone
+
+ return $user->create_datetime()
+ ->setDate($year, $month, $day)
+ ->setTime(0, 0, 0)
+ ->format($user->lang['DATE_FORMAT'], true);
}
return $value;
@@ -570,12 +584,7 @@ class custom_profile
$this->get_option_lang($field_id, $lang_id, FIELD_DROPDOWN, false);
}
- // If a dropdown field is required, users
- // cannot choose the "no value" option.
- // They must choose one of the other options.
- // Therefore, here we treat a value equal to
- // the "no value" as a lack of value, i.e. NULL.
- if ($value == $ident_ary['data']['field_novalue'] && $ident_ary['data']['field_required'])
+ if ($value == $ident_ary['data']['field_novalue'] && !$ident_ary['data']['field_show_novalue'])
{
return NULL;
}
@@ -585,7 +594,14 @@ class custom_profile
// User not having a value assigned
if (!isset($this->options_lang[$field_id][$lang_id][$value]))
{
- return NULL;
+ if ($ident_ary['data']['field_show_novalue'])
+ {
+ $value = $ident_ary['data']['field_novalue'];
+ }
+ else
+ {
+ return NULL;
+ }
}
return $this->options_lang[$field_id][$lang_id][$value];
@@ -599,6 +615,11 @@ class custom_profile
$this->get_option_lang($field_id, $lang_id, FIELD_BOOL, false);
}
+ if (!$value && $ident_ary['data']['field_show_novalue'])
+ {
+ $value = $ident_ary['data']['field_default_value'];
+ }
+
if ($ident_ary['data']['field_length'] == 1)
{
return (isset($this->options_lang[$field_id][$lang_id][(int) $value])) ? $this->options_lang[$field_id][$lang_id][(int) $value] : NULL;
diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php
index 33cb585b19..d4c6b42cf4 100644
--- a/phpBB/includes/functions_upload.php
+++ b/phpBB/includes/functions_upload.php
@@ -151,8 +151,7 @@ class filespec
*/
function is_image()
{
- $mimetype = $this->get_mimetype($this->filename);
- return (strpos($mimetype, 'image/') === 0);
+ return (strpos($this->mimetype, 'image/') === 0);
}
/**
@@ -201,12 +200,17 @@ class filespec
}
/**
- * Get mimetype. Utilises the finfo class.
+ * Get mimetype. Utilize mime_content_type if the function exist.
+ * Not used at the moment...
*/
function get_mimetype($filename)
{
- $finfo = new finfo(FILEINFO_MIME_TYPE);
- $mimetype = $finfo->file($filename);
+ $mimetype = '';
+
+ if (function_exists('mime_content_type'))
+ {
+ $mimetype = mime_content_type($filename);
+ }
// Some browsers choke on a mimetype of application/octet-stream
if (!$mimetype || $mimetype == 'application/octet-stream')
@@ -338,7 +342,6 @@ class filespec
// Remove temporary filename
@unlink($this->filename);
- $this->filename = $this->destination_file;
if (sizeof($this->error))
{
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 9b102b7387..f843902dd5 100644
--- a/phpBB/includes/functions_user.php
+++ b/phpBB/includes/functions_user.php
@@ -112,7 +112,7 @@ function update_last_username()
*/
function user_update_name($old_name, $new_name)
{
- global $config, $db, $cache;
+ global $config, $db, $cache, $phpbb_dispatcher;
$update_ary = array(
FORUMS_TABLE => array('forum_last_poster_name'),
@@ -137,6 +137,17 @@ function user_update_name($old_name, $new_name)
set_config('newest_username', $new_name, true);
}
+ /**
+ * Update a username when it is changed
+ *
+ * @event core.update_username
+ * @var string old_name The old username that is replaced
+ * @var string new_name The new username
+ * @since 3.1-A1
+ */
+ $vars = array('old_name', 'new_name');
+ extract($phpbb_dispatcher->trigger_event('core.update_username', compact($vars)));
+
// Because some tables/caches use username-specific data we need to purge this here.
$cache->destroy('sql', MODERATOR_CACHE_TABLE);
}
@@ -151,6 +162,7 @@ function user_update_name($old_name, $new_name)
function user_add($user_row, $cp_data = false)
{
global $db, $user, $auth, $config, $phpbb_root_path, $phpEx;
+ global $phpbb_dispatcher;
if (empty($user_row['username']) || !isset($user_row['group_id']) || !isset($user_row['user_email']) || !isset($user_row['user_type']))
{
@@ -197,7 +209,6 @@ function user_add($user_row, $cp_data = false)
'user_lastpost_time' => 0,
'user_lastpage' => '',
'user_posts' => 0,
- 'user_dst' => (int) $config['board_dst'],
'user_colour' => '',
'user_occ' => '',
'user_interests' => '',
@@ -245,6 +256,16 @@ function user_add($user_row, $cp_data = false)
}
}
+ /**
+ * Use this event to modify the values to be inserted when a user is added
+ *
+ * @event core.user_add_modify_data
+ * @var array sql_ary Array of data to be inserted when a user is added
+ * @since 3.1-A1
+ */
+ $vars = array('sql_ary');
+ extract($phpbb_dispatcher->trigger_event('core.user_add_modify_data', compact($vars)));
+
$sql = 'INSERT INTO ' . USERS_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary);
$db->sql_query($sql);
@@ -332,7 +353,7 @@ function user_add($user_row, $cp_data = false)
*/
function user_delete($mode, $user_id, $post_username = false)
{
- global $cache, $config, $db, $user, $auth;
+ global $cache, $config, $db, $user, $auth, $phpbb_dispatcher;
global $phpbb_root_path, $phpEx;
$sql = 'SELECT *
@@ -347,6 +368,18 @@ function user_delete($mode, $user_id, $post_username = false)
return false;
}
+ /**
+ * Event before a user is deleted
+ *
+ * @event core.delete_user_before
+ * @var string mode Mode of deletion (retain/delete posts)
+ * @var int user_id ID of the deleted user
+ * @var mixed post_username Guest username that is being used or false
+ * @since 3.1-A1
+ */
+ $vars = array('mode', 'user_id', 'post_username');
+ extract($phpbb_dispatcher->trigger_event('core.delete_user_before', compact($vars)));
+
// Before we begin, we will remove the reports the user issued.
$sql = 'SELECT r.post_id, p.topic_id
FROM ' . REPORTS_TABLE . ' r, ' . POSTS_TABLE . ' p
@@ -536,6 +569,18 @@ function user_delete($mode, $user_id, $post_username = false)
$db->sql_transaction('commit');
+ /**
+ * Event after a user is deleted
+ *
+ * @event core.delete_user_after
+ * @var string mode Mode of deletion (retain/delete posts)
+ * @var int user_id ID of the deleted user
+ * @var mixed post_username Guest username that is being used or false
+ * @since 3.1-A1
+ */
+ $vars = array('mode', 'user_id', 'post_username');
+ extract($phpbb_dispatcher->trigger_event('core.delete_user_after', compact($vars)));
+
// Reset newest user info if appropriate
if ($config['newest_user_id'] == $user_id)
{
@@ -677,8 +722,10 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas
if (sizeof($ban_other) == 3 && ((int)$ban_other[0] < 9999) &&
(strlen($ban_other[0]) == 4) && (strlen($ban_other[1]) == 2) && (strlen($ban_other[2]) == 2))
{
- $time_offset = (isset($user->timezone) && isset($user->dst)) ? (int) $user->timezone + (int) $user->dst : 0;
- $ban_end = max($current_time, gmmktime(0, 0, 0, (int)$ban_other[1], (int)$ban_other[2], (int)$ban_other[0]) - $time_offset);
+ $ban_end = max($current_time, $user->create_datetime()
+ ->setDate((int) $ban_other[0], (int) $ban_other[1], (int) $ban_other[2])
+ ->setTime(0, 0, 0)
+ ->getTimestamp() + $user->timezone->getOffset(new DateTime('UTC')));
}
else
{
@@ -1247,10 +1294,21 @@ function validate_data($data, $val_ary)
$function = array_shift($validate);
array_unshift($validate, $data[$var]);
- if ($result = call_user_func_array('validate_' . $function, $validate))
+ if (function_exists('phpbb_validate_' . $function))
{
- // Since errors are checked later for their language file existence, we need to make sure custom errors are not adjusted.
- $error[] = (empty($user->lang[$result . '_' . strtoupper($var)])) ? $result : $result . '_' . strtoupper($var);
+ if ($result = call_user_func_array('phpbb_validate_' . $function, $validate))
+ {
+ // Since errors are checked later for their language file existence, we need to make sure custom errors are not adjusted.
+ $error[] = (empty($user->lang[$result . '_' . strtoupper($var)])) ? $result : $result . '_' . strtoupper($var);
+ }
+ }
+ else
+ {
+ if ($result = call_user_func_array('validate_' . $function, $validate))
+ {
+ // Since errors are checked later for their language file existence, we need to make sure custom errors are not adjusted.
+ $error[] = (empty($user->lang[$result . '_' . strtoupper($var)])) ? $result : $result . '_' . strtoupper($var);
+ }
}
}
}
@@ -1396,6 +1454,22 @@ function validate_language_iso_name($lang_iso)
}
/**
+* Validate Timezone Name
+*
+* Tests whether a timezone name is valid
+*
+* @param string $timezone The timezone string to test
+*
+* @return bool|string Either false if validation succeeded or
+* a string which will be used as the error message
+* (with the variable name appended)
+*/
+function phpbb_validate_timezone($timezone)
+{
+ return (in_array($timezone, phpbb_get_timezone_identifiers($timezone))) ? false : 'TIMEZONE_INVALID';
+}
+
+/**
* Check to see if the username has been taken, or if it is disallowed.
* Also checks if it includes the " character, which we don't allow in usernames.
* Used for registering, changing names, and posting anonymously with a username
@@ -2731,7 +2805,7 @@ function avatar_remove_db($avatar_name)
*/
function group_delete($group_id, $group_name = false)
{
- global $db, $phpbb_root_path, $phpEx;
+ global $db, $phpbb_root_path, $phpEx, $phpbb_dispatcher;
if (!$group_name)
{
@@ -2790,6 +2864,17 @@ function group_delete($group_id, $group_name = false)
WHERE group_id = $group_id";
$db->sql_query($sql);
+ /**
+ * Event after a group is deleted
+ *
+ * @event core.delete_group_after
+ * @var int group_id ID of the deleted group
+ * @var string group_name Name of the deleted group
+ * @since 3.1-A1
+ */
+ $vars = array('group_id', 'group_name');
+ extract($phpbb_dispatcher->trigger_event('core.delete_group_after', compact($vars)));
+
// Re-cache moderators
if (!function_exists('cache_moderators'))
{
@@ -2912,7 +2997,7 @@ function group_user_add($group_id, $user_id_ary = false, $username_ary = false,
*/
function group_user_del($group_id, $user_id_ary = false, $username_ary = false, $group_name = false)
{
- global $db, $auth, $config;
+ global $db, $auth, $config, $phpbb_dispatcher;
if ($config['coppa_enable'])
{
@@ -3011,6 +3096,19 @@ function group_user_del($group_id, $user_id_ary = false, $username_ary = false,
}
unset($special_group_data);
+ /**
+ * Event before users are removed from a group
+ *
+ * @event core.group_delete_user_before
+ * @var int group_id ID of the group from which users are deleted
+ * @var string group_name Name of the group
+ * @var array user_id_ary IDs of the users which are removed
+ * @var array username_ary names of the users which are removed
+ * @since 3.1-A1
+ */
+ $vars = array('group_id', 'group_name', 'user_id_ary', 'username_ary');
+ extract($phpbb_dispatcher->trigger_event('core.group_delete_user_before', compact($vars)));
+
$sql = 'DELETE FROM ' . USER_GROUP_TABLE . "
WHERE group_id = $group_id
AND " . $db->sql_in_set('user_id', $user_id_ary);
@@ -3328,7 +3426,7 @@ function group_validate_groupname($group_id, $group_name)
*/
function group_set_user_default($group_id, $user_id_ary, $group_attributes = false, $update_listing = false)
{
- global $cache, $db;
+ global $cache, $db, $phpbb_dispatcher;
if (empty($user_id_ary))
{
@@ -3424,6 +3522,20 @@ function group_set_user_default($group_id, $user_id_ary, $group_attributes = fal
}
}
+ /**
+ * Event when the default group is set for an array of users
+ *
+ * @event core.user_set_default_group
+ * @var int group_id ID of the group
+ * @var array user_id_ary IDs of the users
+ * @var array group_attributes Group attributes which were changed
+ * @var array update_listing Update the list of moderators and foes
+ * @var array sql_ary User attributes which were changed
+ * @since 3.1-A1
+ */
+ $vars = array('group_id', 'user_id_ary', 'group_attributes', 'update_listing', 'sql_ary');
+ extract($phpbb_dispatcher->trigger_event('core.user_set_default_group', compact($vars)));
+
if ($update_listing)
{
group_update_listings($group_id);
diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php
index fec1edc872..7b3bc82093 100644
--- a/phpBB/includes/mcp/mcp_forum.php
+++ b/phpBB/includes/mcp/mcp_forum.php
@@ -22,7 +22,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
{
global $template, $db, $user, $auth, $cache, $module;
global $phpEx, $phpbb_root_path, $config;
- global $request;
+ global $request, $phpbb_dispatcher;
$user->add_lang(array('viewtopic', 'viewforum'));
@@ -101,6 +101,9 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
$forum_topics = ($total == -1) ? $forum_info['forum_topics'] : $total;
$limit_time_sql = ($sort_days) ? 'AND t.topic_last_post_time >= ' . (time() - ($sort_days * 86400)) : '';
+ $base_url = $url . "&amp;i=$id&amp;action=$action&amp;mode=$mode&amp;sd=$sort_dir&amp;sk=$sort_key&amp;st=$sort_days" . (($merge_select) ? $selected_ids : '');
+ phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $forum_topics, $topics_per_page, $start);
+
$template->assign_vars(array(
'ACTION' => $action,
'FORUM_NAME' => $forum_info['forum_name'],
@@ -129,8 +132,7 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
'S_MCP_ACTION' => $url . "&amp;i=$id&amp;forum_action=$action&amp;mode=$mode&amp;start=$start" . (($merge_select) ? $selected_ids : ''),
- 'PAGINATION' => generate_pagination($url . "&amp;i=$id&amp;action=$action&amp;mode=$mode&amp;sd=$sort_dir&amp;sk=$sort_key&amp;st=$sort_days" . (($merge_select) ? $selected_ids : ''), $forum_topics, $topics_per_page, $start),
- 'PAGE_NUMBER' => on_page($forum_topics, $topics_per_page, $start),
+ 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $forum_topics, $topics_per_page, $start),
'TOTAL_TOPICS' => $user->lang('VIEW_FORUM_TOPICS', (int) $forum_topics),
));
@@ -286,6 +288,17 @@ function mcp_forum_view($id, $mode, $action, $forum_info)
));
}
+ /**
+ * Modify the topic data before it is assigned to the template in MCP
+ *
+ * @event core.mcp_view_forum_modify_topicrow
+ * @var array row Array with topic data
+ * @var array topic_row Template array with topic data
+ * @since 3.1-A1
+ */
+ $vars = array('row', 'topic_row');
+ extract($phpbb_dispatcher->trigger_event('core.mcp_view_forum_modify_topicrow', compact($vars)));
+
$template->assign_block_vars('topicrow', $topic_row);
}
unset($topic_rows);
diff --git a/phpBB/includes/mcp/mcp_front.php b/phpBB/includes/mcp/mcp_front.php
index 13398e62bc..ba4b15895a 100644
--- a/phpBB/includes/mcp/mcp_front.php
+++ b/phpBB/includes/mcp/mcp_front.php
@@ -251,7 +251,7 @@ function mcp_front_view($id, $mode, $action)
'ORDER_BY' => 'p.message_time DESC',
);
- $sql_ary = $db->sql_build_query('SELECT', $sql_ary);
+ $sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query_limit($sql, 5);
$pm_by_id = $pm_list = array();
diff --git a/phpBB/includes/mcp/mcp_logs.php b/phpBB/includes/mcp/mcp_logs.php
index 848bad40a3..c1724b20d9 100644
--- a/phpBB/includes/mcp/mcp_logs.php
+++ b/phpBB/includes/mcp/mcp_logs.php
@@ -171,10 +171,12 @@ class mcp_logs
$log_count = 0;
$start = view_log('mod', $log_data, $log_count, $config['topics_per_page'], $start, $forum_list, $topic_id, 0, $sql_where, $sql_sort, $keywords);
+ $base_url = $this->u_action . "&amp;$u_sort_param$keywords_param";
+ phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start);
+
$template->assign_vars(array(
- 'PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start),
+ 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $log_count, $config['topics_per_page'], $start),
'TOTAL' => $user->lang('TOTAL_LOGS', (int) $log_count),
- 'PAGINATION' => generate_pagination($this->u_action . "&amp;$u_sort_param$keywords_param", $log_count, $config['topics_per_page'], $start),
'L_TITLE' => $user->lang['MCP_LOGS'],
diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php
index a21c67924d..95ca7c2e1b 100644
--- a/phpBB/includes/mcp/mcp_main.php
+++ b/phpBB/includes/mcp/mcp_main.php
@@ -915,7 +915,7 @@ function mcp_fork_topic($topic_ids)
}
$error = false;
- $search = new $search_type($error);
+ $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
$search_mode = 'post';
if ($error)
diff --git a/phpBB/includes/mcp/mcp_notes.php b/phpBB/includes/mcp/mcp_notes.php
index 99dbb8d86d..bbf618ebef 100644
--- a/phpBB/includes/mcp/mcp_notes.php
+++ b/phpBB/includes/mcp/mcp_notes.php
@@ -215,6 +215,9 @@ class mcp_notes
}
}
+ $base_url = $this->u_action . "&amp;$u_sort_param$keywords_param";
+ phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $log_count, $config['topics_per_page'], $start);
+
$template->assign_vars(array(
'U_POST_ACTION' => $this->u_action,
'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false,
@@ -225,8 +228,7 @@ class mcp_notes
'L_TITLE' => $user->lang['MCP_NOTES_USER'],
- 'PAGE_NUMBER' => on_page($log_count, $config['topics_per_page'], $start),
- 'PAGINATION' => generate_pagination($this->u_action . "&amp;$u_sort_param$keywords_param", $log_count, $config['topics_per_page'], $start),
+ 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $log_count, $config['topics_per_page'], $start),
'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $log_count),
'RANK_TITLE' => $rank_title,
diff --git a/phpBB/includes/mcp/mcp_pm_reports.php b/phpBB/includes/mcp/mcp_pm_reports.php
index d242929a80..24e531517c 100644
--- a/phpBB/includes/mcp/mcp_pm_reports.php
+++ b/phpBB/includes/mcp/mcp_pm_reports.php
@@ -291,13 +291,16 @@ class mcp_pm_reports
'REPORT_ID' => $row['report_id'],
'REPORT_TIME' => $user->format_date($row['report_time']),
- 'RECIPIENTS' => implode(', ', $address_list[$row['msg_id']]),
+ 'RECIPIENTS' => implode($user->lang['COMMA_SEPARATOR'], $address_list[$row['msg_id']]),
'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $row['message_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
));
}
}
}
-
+
+ $base_url = $this->u_action . "&amp;st=$sort_days&amp;sk=$sort_key&amp;sd=$sort_dir";
+ phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start);
+
// Now display the page
$template->assign_vars(array(
'L_EXPLAIN' => ($mode == 'pm_reports') ? $user->lang['MCP_PM_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_PM_REPORTS_CLOSED_EXPLAIN'],
@@ -307,8 +310,7 @@ class mcp_pm_reports
'S_MCP_ACTION' => $this->u_action,
'S_CLOSED' => ($mode == 'pm_reports_closed') ? true : false,
- 'PAGINATION' => generate_pagination($this->u_action . "&amp;st=$sort_days&amp;sk=$sort_key&amp;sd=$sort_dir", $total, $config['topics_per_page'], $start),
- 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start),
+ 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $total, $config['topics_per_page'], $start),
'TOTAL' => $total,
'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $total),
)
diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php
index 2a52a858b3..520c964228 100644
--- a/phpBB/includes/mcp/mcp_post.php
+++ b/phpBB/includes/mcp/mcp_post.php
@@ -393,7 +393,7 @@ function mcp_post_details($id, $mode, $action)
*/
function change_poster(&$post_info, $userdata)
{
- global $auth, $db, $config, $phpbb_root_path, $phpEx;
+ global $auth, $db, $config, $phpbb_root_path, $phpEx, $user;
if (empty($userdata) || $userdata['user_id'] == $post_info['user_id'])
{
@@ -470,7 +470,7 @@ function change_poster(&$post_info, $userdata)
{
// We do some additional checks in the module to ensure it can actually be utilised
$error = false;
- $search = new $search_type($error);
+ $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
if (!$error && method_exists($search, 'destroy_cache'))
{
diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php
index 4d720a435c..b44685b8a3 100644
--- a/phpBB/includes/mcp/mcp_queue.php
+++ b/phpBB/includes/mcp/mcp_queue.php
@@ -419,6 +419,9 @@ class mcp_queue
}
unset($rowset, $forum_names);
+ $base_url = $this->u_action . "&amp;f=$forum_id&amp;st=$sort_days&amp;sk=$sort_key&amp;sd=$sort_dir";
+ phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start);
+
// Now display the page
$template->assign_vars(array(
'L_DISPLAY_ITEMS' => ($mode == 'unapproved_posts') ? $user->lang['DISPLAY_POSTS'] : $user->lang['DISPLAY_TOPICS'],
@@ -430,8 +433,7 @@ class mcp_queue
'S_MCP_ACTION' => build_url(array('t', 'f', 'sd', 'st', 'sk')),
'S_TOPICS' => ($mode == 'unapproved_posts') ? false : true,
- 'PAGINATION' => generate_pagination($this->u_action . "&amp;f=$forum_id&amp;st=$sort_days&amp;sk=$sort_key&amp;sd=$sort_dir", $total, $config['topics_per_page'], $start),
- 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start),
+ 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $total, $config['topics_per_page'], $start),
'TOPIC_ID' => $topic_id,
'TOTAL' => $user->lang((($mode == 'unapproved_posts') ? 'VIEW_TOPIC_POSTS' : 'VIEW_FORUM_TOPICS'), (int) $total),
));
diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php
index 69c6a4cfff..2890cd56e2 100644
--- a/phpBB/includes/mcp/mcp_reports.php
+++ b/phpBB/includes/mcp/mcp_reports.php
@@ -411,6 +411,9 @@ class mcp_reports
unset($report_ids, $row);
}
+ $base_url = $this->u_action . "&amp;f=$forum_id&amp;t=$topic_id&amp;st=$sort_days&amp;sk=$sort_key&amp;sd=$sort_dir";
+ phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $config['topics_per_page'], $start);
+
// Now display the page
$template->assign_vars(array(
'L_EXPLAIN' => ($mode == 'reports') ? $user->lang['MCP_REPORTS_OPEN_EXPLAIN'] : $user->lang['MCP_REPORTS_CLOSED_EXPLAIN'],
@@ -421,8 +424,7 @@ class mcp_reports
'S_FORUM_OPTIONS' => $forum_options,
'S_CLOSED' => ($mode == 'reports_closed') ? true : false,
- 'PAGINATION' => generate_pagination($this->u_action . "&amp;f=$forum_id&amp;t=$topic_id&amp;st=$sort_days&amp;sk=$sort_key&amp;sd=$sort_dir", $total, $config['topics_per_page'], $start),
- 'PAGE_NUMBER' => on_page($total, $config['topics_per_page'], $start),
+ 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $total, $config['topics_per_page'], $start),
'TOPIC_ID' => $topic_id,
'TOTAL' => $total,
'TOTAL_REPORTS' => $user->lang('LIST_REPORTS', (int) $total),
diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php
index d4ba89b04c..e39e553ab6 100644
--- a/phpBB/includes/mcp/mcp_topic.php
+++ b/phpBB/includes/mcp/mcp_topic.php
@@ -306,6 +306,12 @@ function mcp_topic_view($id, $mode, $action)
'post_ids' => $post_id_list,
));
+ $base_url = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&amp;t={$topic_info['topic_id']}&amp;mode=$mode&amp;action=$action&amp;to_topic_id=$to_topic_id&amp;posts_per_page=$posts_per_page&amp;st=$sort_days&amp;sk=$sort_key&amp;sd=$sort_dir");
+ if ($posts_per_page)
+ {
+ phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total, $posts_per_page, $start);
+ }
+
$template->assign_vars(array(
'TOPIC_TITLE' => $topic_info['topic_title'],
'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $topic_info['forum_id'] . '&amp;t=' . $topic_info['topic_id']),
@@ -344,8 +350,7 @@ function mcp_topic_view($id, $mode, $action)
'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f={$topic_info['forum_id']}&amp;t={$topic_info['topic_id']}&amp;start=$start") . '">', '</a>'),
'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '<a href="' . append_sid("{$phpbb_root_path}viewforum.$phpEx", "f={$topic_info['forum_id']}&amp;start=$start") . '">', '</a>'),
- 'PAGE_NUMBER' => on_page($total, $posts_per_page, $start),
- 'PAGINATION' => (!$posts_per_page) ? '' : generate_pagination(append_sid("{$phpbb_root_path}mcp.$phpEx", "i=$id&amp;t={$topic_info['topic_id']}&amp;mode=$mode&amp;action=$action&amp;to_topic_id=$to_topic_id&amp;posts_per_page=$posts_per_page&amp;st=$sort_days&amp;sk=$sort_key&amp;sd=$sort_dir"), $total, $posts_per_page, $start),
+ 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $total, $posts_per_page, $start),
'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $total),
));
}
diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php
index c614beea3b..aefddb7c01 100644
--- a/phpBB/includes/mcp/mcp_warn.php
+++ b/phpBB/includes/mcp/mcp_warn.php
@@ -175,6 +175,9 @@ class mcp_warn
));
}
+ $base_url = append_sid("{$phpbb_root_path}mcp.$phpEx", "i=warn&amp;mode=list&amp;st=$st&amp;sk=$sk&amp;sd=$sd");
+ phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $user_count, $config['topics_per_page'], $start);
+
$template->assign_vars(array(
'U_POST_ACTION' => $this->u_action,
'S_CLEAR_ALLOWED' => ($auth->acl_get('a_clearlogs')) ? true : false,
@@ -182,8 +185,7 @@ class mcp_warn
'S_SELECT_SORT_KEY' => $s_sort_key,
'S_SELECT_SORT_DAYS' => $s_limit_days,
- 'PAGE_NUMBER' => on_page($user_count, $config['topics_per_page'], $start),
- 'PAGINATION' => generate_pagination(append_sid("{$phpbb_root_path}mcp.$phpEx", "i=warn&amp;mode=list&amp;st=$st&amp;sk=$sk&amp;sd=$sd"), $user_count, $config['topics_per_page'], $start),
+ 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $user_count, $config['topics_per_page'], $start),
'TOTAL_USERS' => $user->lang('LIST_USERS', (int) $user_count),
));
}
diff --git a/phpBB/includes/questionnaire/questionnaire.php b/phpBB/includes/questionnaire/questionnaire.php
index 46a743d7e9..5cb441d536 100644
--- a/phpBB/includes/questionnaire/questionnaire.php
+++ b/phpBB/includes/questionnaire/questionnaire.php
@@ -304,7 +304,6 @@ class phpbb_questionnaire_phpbb_data_provider
'avatar_max_width' => true,
'avatar_min_height' => true,
'avatar_min_width' => true,
- 'board_dst' => true,
'board_email_form' => true,
'board_hide_emails' => true,
'board_timezone' => true,
diff --git a/phpBB/includes/request/request.php b/phpBB/includes/request/request.php
index 4e425dbd27..a06fc0d85d 100644
--- a/phpBB/includes/request/request.php
+++ b/phpBB/includes/request/request.php
@@ -200,46 +200,31 @@ class phpbb_request implements phpbb_request_interface
*/
public function variable($var_name, $default, $multibyte = false, $super_global = phpbb_request_interface::REQUEST)
{
- $path = false;
-
- // deep direct access to multi dimensional arrays
- if (is_array($var_name))
- {
- $path = $var_name;
- // make sure at least the variable name is specified
- if (empty($path))
- {
- return (is_array($default)) ? array() : $default;
- }
- // the variable name is the first element on the path
- $var_name = array_shift($path);
- }
-
- if (!isset($this->input[$super_global][$var_name]))
- {
- return (is_array($default)) ? array() : $default;
- }
- $var = $this->input[$super_global][$var_name];
-
- if ($path)
- {
- // walk through the array structure and find the element we are looking for
- foreach ($path as $key)
- {
- if (is_array($var) && isset($var[$key]))
- {
- $var = $var[$key];
- }
- else
- {
- return (is_array($default)) ? array() : $default;
- }
- }
- }
-
- $this->type_cast_helper->recursive_set_var($var, $default, $multibyte);
+ return $this->_variable($var_name, $default, $multibyte, $super_global, true);
+ }
- return $var;
+ /**
+ * Get a variable, but without trimming strings.
+ * Same functionality as variable(), except does not run trim() on strings.
+ * This method should be used when handling passwords.
+ *
+ * @param string|array $var_name The form variable's name from which data shall be retrieved.
+ * If the value is an array this may be an array of indizes which will give
+ * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a")
+ * then specifying array("var", 1) as the name will return "a".
+ * @param mixed $default A default value that is returned if the variable was not set.
+ * This function will always return a value of the same type as the default.
+ * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters
+ * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks
+ * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global
+ * Specifies which super global should be used
+ *
+ * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
+ * the same as that of $default. If the variable is not set $default is returned.
+ */
+ public function untrimmed_variable($var_name, $default, $multibyte, $super_global = phpbb_request_interface::REQUEST)
+ {
+ return $this->_variable($var_name, $default, $multibyte, $super_global, false);
}
/**
@@ -351,4 +336,66 @@ class phpbb_request implements phpbb_request_interface
return array_keys($this->input[$super_global]);
}
+
+ /**
+ * Helper function used by variable() and untrimmed_variable().
+ *
+ * @param string|array $var_name The form variable's name from which data shall be retrieved.
+ * If the value is an array this may be an array of indizes which will give
+ * direct access to a value at any depth. E.g. if the value of "var" is array(1 => "a")
+ * then specifying array("var", 1) as the name will return "a".
+ * @param mixed $default A default value that is returned if the variable was not set.
+ * This function will always return a value of the same type as the default.
+ * @param bool $multibyte If $default is a string this paramater has to be true if the variable may contain any UTF-8 characters
+ * Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks
+ * @param phpbb_request_interface::POST|GET|REQUEST|COOKIE $super_global
+ * Specifies which super global should be used
+ * @param bool $trim Indicates whether trim() should be applied to string values.
+ *
+ * @return mixed The value of $_REQUEST[$var_name] run through {@link set_var set_var} to ensure that the type is the
+ * the same as that of $default. If the variable is not set $default is returned.
+ */
+ protected function _variable($var_name, $default, $multibyte = false, $super_global = phpbb_request_interface::REQUEST, $trim = true)
+ {
+ $path = false;
+
+ // deep direct access to multi dimensional arrays
+ if (is_array($var_name))
+ {
+ $path = $var_name;
+ // make sure at least the variable name is specified
+ if (empty($path))
+ {
+ return (is_array($default)) ? array() : $default;
+ }
+ // the variable name is the first element on the path
+ $var_name = array_shift($path);
+ }
+
+ if (!isset($this->input[$super_global][$var_name]))
+ {
+ return (is_array($default)) ? array() : $default;
+ }
+ $var = $this->input[$super_global][$var_name];
+
+ if ($path)
+ {
+ // walk through the array structure and find the element we are looking for
+ foreach ($path as $key)
+ {
+ if (is_array($var) && isset($var[$key]))
+ {
+ $var = $var[$key];
+ }
+ else
+ {
+ return (is_array($default)) ? array() : $default;
+ }
+ }
+ }
+
+ $this->type_cast_helper->recursive_set_var($var, $default, $multibyte, $trim);
+
+ return $var;
+ }
}
diff --git a/phpBB/includes/request/type_cast_helper.php b/phpBB/includes/request/type_cast_helper.php
index 561e8fc251..1a5274ed14 100644
--- a/phpBB/includes/request/type_cast_helper.php
+++ b/phpBB/includes/request/type_cast_helper.php
@@ -93,15 +93,23 @@ class phpbb_request_type_cast_helper implements phpbb_request_type_cast_helper_i
* @param mixed $type The variable type. Will be used with {@link settype()}
* @param bool $multibyte Indicates whether string values may contain UTF-8 characters.
* Default is false, causing all bytes outside the ASCII range (0-127) to be replaced with question marks.
+ * @param bool $trim Indicates whether trim() should be applied to string values.
+ * Default is true.
*/
- public function set_var(&$result, $var, $type, $multibyte = false)
+ public function set_var(&$result, $var, $type, $multibyte = false, $trim = true)
{
settype($var, $type);
$result = $var;
if ($type == 'string')
{
- $result = trim(str_replace(array("\r\n", "\r", "\0"), array("\n", "\n", ''), $result));
+ $result = str_replace(array("\r\n", "\r", "\0"), array("\n", "\n", ''), $result);
+
+ if ($trim)
+ {
+ $result = trim($result);
+ }
+
$result = htmlspecialchars($result, ENT_COMPAT, 'UTF-8');
if ($multibyte)
@@ -141,8 +149,10 @@ class phpbb_request_type_cast_helper implements phpbb_request_type_cast_helper_i
* @param bool $multibyte Indicates whether string keys and values may contain UTF-8 characters.
* Default is false, causing all bytes outside the ASCII range (0-127) to
* be replaced with question marks.
+ * @param bool $trim Indicates whether trim() should be applied to string values.
+ * Default is true.
*/
- public function recursive_set_var(&$var, $default, $multibyte)
+ public function recursive_set_var(&$var, $default, $multibyte, $trim = true)
{
if (is_array($var) !== is_array($default))
{
@@ -153,7 +163,7 @@ class phpbb_request_type_cast_helper implements phpbb_request_type_cast_helper_i
if (!is_array($default))
{
$type = gettype($default);
- $this->set_var($var, $var, $type, $multibyte);
+ $this->set_var($var, $var, $type, $multibyte, $trim);
}
else
{
@@ -174,9 +184,9 @@ class phpbb_request_type_cast_helper implements phpbb_request_type_cast_helper_i
foreach ($_var as $k => $v)
{
- $this->set_var($k, $k, $key_type, $multibyte, $multibyte);
+ $this->set_var($k, $k, $key_type, $multibyte);
- $this->recursive_set_var($v, $default_value, $multibyte);
+ $this->recursive_set_var($v, $default_value, $multibyte, $trim);
$var[$k] = $v;
}
}
diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php
index 20dcb74c0d..7cd06dee19 100644
--- a/phpBB/includes/search/fulltext_mysql.php
+++ b/phpBB/includes/search/fulltext_mysql.php
@@ -22,17 +22,28 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_search_fulltext_mysql extends phpbb_search_base
{
- var $stats = array();
- var $word_length = array();
- var $split_words = array();
- var $search_query;
- var $common_words = array();
+ protected $stats = array();
+ protected $split_words = array();
+ protected $config;
+ protected $db;
+ protected $user;
+ protected $word_length = array();
+ protected $search_query;
+ protected $common_words = array();
- public function __construct(&$error)
+ /**
+ * Constructor
+ * Creates a new phpbb_search_fulltext_mysql, which is used as a search backend.
+ *
+ * @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false
+ */
+ public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user)
{
- global $config;
+ $this->config = $config;
+ $this->db = $db;
+ $this->user = $user;
- $this->word_length = array('min' => $config['fulltext_mysql_min_word_len'], 'max' => $config['fulltext_mysql_max_word_len']);
+ $this->word_length = array('min' => $this->config['fulltext_mysql_min_word_len'], 'max' => $this->config['fulltext_mysql_max_word_len']);
$error = false;
}
@@ -48,20 +59,50 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
}
/**
+ * Returns the search_query
+ *
+ * @return string search query
+ */
+ public function get_search_query()
+ {
+ return $this->search_query;
+ }
+
+ /**
+ * Returns the common_words array
+ *
+ * @return array common words that are ignored by search backend
+ */
+ public function get_common_words()
+ {
+ return $this->common_words;
+ }
+
+ /**
+ * Returns the word_length array
+ *
+ * @return array min and max word length for searching
+ */
+ public function get_word_length()
+ {
+ return $this->word_length;
+ }
+
+ /**
* Checks for correct MySQL version and stores min/max word length in the config
+ *
+ * @return string|bool Language key of the error/incompatiblity occured
*/
- function init()
+ public function init()
{
- global $db, $user;
-
- if ($db->sql_layer != 'mysql4' && $db->sql_layer != 'mysqli')
+ if ($this->db->sql_layer != 'mysql4' && $this->db->sql_layer != 'mysqli')
{
- return $user->lang['FULLTEXT_MYSQL_INCOMPATIBLE_DATABASE'];
+ return $this->user->lang['FULLTEXT_MYSQL_INCOMPATIBLE_DATABASE'];
}
- $result = $db->sql_query('SHOW TABLE STATUS LIKE \'' . POSTS_TABLE . '\'');
- $info = $db->sql_fetchrow($result);
- $db->sql_freeresult($result);
+ $result = $this->db->sql_query('SHOW TABLE STATUS LIKE \'' . POSTS_TABLE . '\'');
+ $info = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
$engine = '';
if (isset($info['Engine']))
@@ -75,19 +116,19 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
if ($engine != 'MyISAM')
{
- return $user->lang['FULLTEXT_MYSQL_NOT_MYISAM'];
+ return $this->user->lang['FULLTEXT_MYSQL_NOT_MYISAM'];
}
$sql = 'SHOW VARIABLES
LIKE \'ft\_%\'';
- $result = $db->sql_query($sql);
+ $result = $this->db->sql_query($sql);
$mysql_info = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
$mysql_info[$row['Variable_name']] = $row['Value'];
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
set_config('fulltext_mysql_max_word_len', $mysql_info['ft_max_word_len']);
set_config('fulltext_mysql_min_word_len', $mysql_info['ft_min_word_len']);
@@ -103,10 +144,8 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
* @param string $terms is either 'all' or 'any'
* @return bool false if no valid keywords were found and otherwise true
*/
- function split_keywords(&$keywords, $terms)
+ public function split_keywords(&$keywords, $terms)
{
- global $config, $user;
-
if ($terms == 'all')
{
$match = array('#\sand\s#iu', '#\sor\s#iu', '#\snot\s#iu', '#(^|\s)\+#', '#(^|\s)-#', '#(^|\s)\|#');
@@ -125,9 +164,9 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
$this->split_words = $matches[1];
// We limit the number of allowed keywords to minimize load on the database
- if ($config['max_num_search_keywords'] && sizeof($this->split_words) > $config['max_num_search_keywords'])
+ if ($this->config['max_num_search_keywords'] && sizeof($this->split_words) > $this->config['max_num_search_keywords'])
{
- trigger_error($user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', $config['max_num_search_keywords'], sizeof($this->split_words)));
+ trigger_error($this->user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', $this->config['max_num_search_keywords'], sizeof($this->split_words)));
}
// to allow phrase search, we need to concatenate quoted words
@@ -169,7 +208,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
// check word length
$clean_len = utf8_strlen(str_replace('*', '', $clean_word));
- if (($clean_len < $config['fulltext_mysql_min_word_len']) || ($clean_len > $config['fulltext_mysql_max_word_len']))
+ if (($clean_len < $this->config['fulltext_mysql_min_word_len']) || ($clean_len > $this->config['fulltext_mysql_max_word_len']))
{
$this->common_words[] = $word;
unset($this->split_words[$i]);
@@ -221,11 +260,10 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
/**
* Turns text into an array of words
+ * @param string $text contains post text/subject
*/
- function split_message($text)
+ public function split_message($text)
{
- global $config;
-
// Split words
$text = preg_replace('#([^\p{L}\p{N}\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text)));
$matches = array();
@@ -237,7 +275,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
for ($i = 0, $n = sizeof($text); $i < $n; $i++)
{
$text[$i] = trim($text[$i]);
- if (utf8_strlen($text[$i]) < $config['fulltext_mysql_min_word_len'] || utf8_strlen($text[$i]) > $config['fulltext_mysql_max_word_len'])
+ if (utf8_strlen($text[$i]) < $this->config['fulltext_mysql_min_word_len'] || utf8_strlen($text[$i]) > $this->config['fulltext_mysql_max_word_len'])
{
unset($text[$i]);
}
@@ -265,13 +303,9 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
* @param int $start indicates the first index of the page
* @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results
- *
- * @access public
*/
- function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
+ public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
{
- global $config, $db;
-
// No keywords? No posts.
if (!$this->search_query)
{
@@ -360,7 +394,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
}
else
{
- $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')';
+ $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $this->db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')';
}
$sql_select = (!$result_count) ? 'SQL_CALC_FOUND_ROWS ' : '';
@@ -370,11 +404,11 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
if (sizeof($author_ary) && $author_name)
{
// first one matches post of registered users, second one guests and deleted users
- $sql_author = ' AND (' . $db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')';
+ $sql_author = ' AND (' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')';
}
else if (sizeof($author_ary))
{
- $sql_author = ' AND ' . $db->sql_in_set('p.poster_id', $author_ary);
+ $sql_author = ' AND ' . $this->db->sql_in_set('p.poster_id', $author_ary);
}
else
{
@@ -384,7 +418,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
$sql_where_options = $sql_sort_join;
$sql_where_options .= ($topic_id) ? ' AND p.topic_id = ' . $topic_id : '';
$sql_where_options .= ($join_topic) ? ' AND t.topic_id = p.topic_id' : '';
- $sql_where_options .= (sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
+ $sql_where_options .= (sizeof($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
$sql_where_options .= $m_approve_fid_sql;
$sql_where_options .= $sql_author;
$sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
@@ -392,16 +426,16 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
$sql = "SELECT $sql_select
FROM $sql_from$sql_sort_table" . POSTS_TABLE . " p
- WHERE MATCH ($sql_match) AGAINST ('" . $db->sql_escape(htmlspecialchars_decode($this->search_query)) . "' IN BOOLEAN MODE)
+ WHERE MATCH ($sql_match) AGAINST ('" . $this->db->sql_escape(htmlspecialchars_decode($this->search_query)) . "' IN BOOLEAN MODE)
$sql_where_options
ORDER BY $sql_sort";
- $result = $db->sql_query_limit($sql, $config['search_block_size'], $start);
+ $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
$id_ary[] = (int) $row[$field];
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
$id_ary = array_unique($id_ary);
@@ -414,9 +448,9 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
if (!$result_count)
{
$sql = 'SELECT FOUND_ROWS() as result_count';
- $result = $db->sql_query($sql);
- $result_count = (int) $db->sql_fetchfield('result_count');
- $db->sql_freeresult($result);
+ $result = $this->db->sql_query($sql);
+ $result_count = (int) $this->db->sql_fetchfield('result_count');
+ $this->db->sql_freeresult($result);
if (!$result_count)
{
@@ -449,13 +483,9 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
* @param int $start indicates the first index of the page
* @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results
- *
- * @access public
*/
- function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
+ public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
{
- global $config, $db;
-
// No author? No posts.
if (!sizeof($author_ary))
{
@@ -491,13 +521,13 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
if ($author_name)
{
// first one matches post of registered users, second one guests and deleted users
- $sql_author = '(' . $db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')';
+ $sql_author = '(' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')';
}
else
{
- $sql_author = $db->sql_in_set('p.poster_id', $author_ary);
+ $sql_author = $this->db->sql_in_set('p.poster_id', $author_ary);
}
- $sql_fora = (sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
+ $sql_fora = (sizeof($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
$sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : '';
$sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
$sql_firstpost = ($firstpost_only) ? ' AND p.post_id = t.topic_first_post_id' : '';
@@ -533,7 +563,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
}
else
{
- $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')';
+ $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $this->db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')';
}
// If the cache was completely empty count the results
@@ -572,21 +602,21 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
}
// Only read one block of posts from the db and then cache it
- $result = $db->sql_query_limit($sql, $config['search_block_size'], $start);
+ $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
$id_ary[] = (int) $row[$field];
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
// retrieve the total result count if needed
if (!$result_count)
{
$sql = 'SELECT FOUND_ROWS() as result_count';
- $result = $db->sql_query($sql);
- $result_count = (int) $db->sql_fetchfield('result_count');
- $db->sql_freeresult($result);
+ $result = $this->db->sql_query($sql);
+ $result_count = (int) $this->db->sql_fetchfield('result_count');
+ $this->db->sql_freeresult($result);
if (!$result_count)
{
@@ -607,12 +637,15 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
/**
* Destroys cached search results, that contained one of the new words in a post so the results won't be outdated.
*
- * @param string $mode contains the post mode: edit, post, reply, quote ...
+ * @param string $mode contains the post mode: edit, post, reply, quote ...
+ * @param int $post_id contains the post id of the post to index
+ * @param string $message contains the post text of the post
+ * @param string $subject contains the subject of the post to index
+ * @param int $poster_id contains the user id of the poster
+ * @param int $forum_id contains the forum id of parent forum of the post
*/
- function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id)
+ public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id)
{
- global $db;
-
// Split old and new post/subject to obtain array of words
$split_text = $this->split_message($message);
$split_title = ($subject) ? $this->split_message($subject) : array();
@@ -631,7 +664,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
/**
* Destroy cached results, that might be outdated after deleting a post
*/
- function index_remove($post_ids, $author_ids, $forum_ids)
+ public function index_remove($post_ids, $author_ids, $forum_ids)
{
$this->destroy_cache(array(), array_unique($author_ids));
}
@@ -639,10 +672,8 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
/**
* Destroy old cache entries
*/
- function tidy()
+ public function tidy()
{
- global $db, $config;
-
// destroy too old cached search results
$this->destroy_cache(array());
@@ -651,11 +682,11 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
/**
* Create fulltext index
+ *
+ * @return string|bool error string is returned incase of errors otherwise false
*/
- function create_index($acp_module, $u_action)
+ public function create_index($acp_module, $u_action)
{
- global $db;
-
// Make sure we can actually use MySQL with fulltext indexes
if ($error = $this->init())
{
@@ -671,7 +702,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
if (!isset($this->stats['post_subject']))
{
- if ($db->sql_layer == 'mysqli' || version_compare($db->sql_server_info(true), '4.1.3', '>='))
+ if ($this->db->sql_layer == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>='))
{
$alter[] = 'MODIFY post_subject varchar(255) COLLATE utf8_unicode_ci DEFAULT \'\' NOT NULL';
}
@@ -684,7 +715,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
if (!isset($this->stats['post_text']))
{
- if ($db->sql_layer == 'mysqli' || version_compare($db->sql_server_info(true), '4.1.3', '>='))
+ if ($this->db->sql_layer == 'mysqli' || version_compare($this->db->sql_server_info(true), '4.1.3', '>='))
{
$alter[] = 'MODIFY post_text mediumtext COLLATE utf8_unicode_ci NOT NULL';
}
@@ -702,21 +733,21 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
if (sizeof($alter))
{
- $db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter));
+ $this->db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter));
}
- $db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
+ $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
return false;
}
/**
* Drop fulltext index
+ *
+ * @return string|bool error string is returned incase of errors otherwise false
*/
- function delete_index($acp_module, $u_action)
+ public function delete_index($acp_module, $u_action)
{
- global $db;
-
// Make sure we can actually use MySQL with fulltext indexes
if ($error = $this->init())
{
@@ -747,10 +778,10 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
if (sizeof($alter))
{
- $db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter));
+ $this->db->sql_query('ALTER TABLE ' . POSTS_TABLE . ' ' . implode(', ', $alter));
}
- $db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
+ $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
return false;
}
@@ -758,7 +789,7 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
/**
* Returns true if both FULLTEXT indexes exist
*/
- function index_created()
+ public function index_created()
{
if (empty($this->stats))
{
@@ -771,25 +802,24 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
/**
* Returns an associative array containing information about the indexes
*/
- function index_stats()
+ public function index_stats()
{
- global $user;
-
if (empty($this->stats))
{
$this->get_stats();
}
return array(
- $user->lang['FULLTEXT_MYSQL_TOTAL_POSTS'] => ($this->index_created()) ? $this->stats['total_posts'] : 0,
+ $this->user->lang['FULLTEXT_MYSQL_TOTAL_POSTS'] => ($this->index_created()) ? $this->stats['total_posts'] : 0,
);
}
- function get_stats()
+ /**
+ * Computes the stats and store them in the $this->stats associative array
+ */
+ protected function get_stats()
{
- global $db;
-
- if (strpos($db->sql_layer, 'mysql') === false)
+ if (strpos($this->db->sql_layer, 'mysql') === false)
{
$this->stats = array();
return;
@@ -797,9 +827,9 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
$sql = 'SHOW INDEX
FROM ' . POSTS_TABLE;
- $result = $db->sql_query($sql);
+ $result = $this->db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
// deal with older MySQL versions which didn't use Index_type
$index_type = (isset($row['Index_type'])) ? $row['Index_type'] : $row['Comment'];
@@ -820,26 +850,26 @@ class phpbb_search_fulltext_mysql extends phpbb_search_base
}
}
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
- $this->stats['total_posts'] = empty($this->stats) ? 0 : $db->get_estimated_row_count(POSTS_TABLE);
+ $this->stats['total_posts'] = empty($this->stats) ? 0 : $this->db->get_estimated_row_count(POSTS_TABLE);
}
/**
* Display a note, that UTF-8 support is not available with certain versions of PHP
+ *
+ * @return associative array containing template and config variables
*/
- function acp()
+ public function acp()
{
- global $user, $config;
-
$tpl = '
<dl>
- <dt><label>' . $user->lang['MIN_SEARCH_CHARS'] . ':</label><br /><span>' . $user->lang['FULLTEXT_MYSQL_MIN_SEARCH_CHARS_EXPLAIN'] . '</span></dt>
- <dd>' . $config['fulltext_mysql_min_word_len'] . '</dd>
+ <dt><label>' . $this->user->lang['MIN_SEARCH_CHARS'] . ':</label><br /><span>' . $this->user->lang['FULLTEXT_MYSQL_MIN_SEARCH_CHARS_EXPLAIN'] . '</span></dt>
+ <dd>' . $this->config['fulltext_mysql_min_word_len'] . '</dd>
</dl>
<dl>
- <dt><label>' . $user->lang['MAX_SEARCH_CHARS'] . ':</label><br /><span>' . $user->lang['FULLTEXT_MYSQL_MAX_SEARCH_CHARS_EXPLAIN'] . '</span></dt>
- <dd>' . $config['fulltext_mysql_max_word_len'] . '</dd>
+ <dt><label>' . $this->user->lang['MAX_SEARCH_CHARS'] . ':</label><br /><span>' . $this->user->lang['FULLTEXT_MYSQL_MAX_SEARCH_CHARS_EXPLAIN'] . '</span></dt>
+ <dd>' . $this->config['fulltext_mysql_max_word_len'] . '</dd>
</dl>
';
diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php
index 3e029c86d0..bbc2236b3c 100644
--- a/phpBB/includes/search/fulltext_native.php
+++ b/phpBB/includes/search/fulltext_native.php
@@ -22,32 +22,42 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_search_fulltext_native extends phpbb_search_base
{
- var $stats = array();
- var $word_length = array();
- var $search_query;
- var $common_words = array();
+ protected $stats = array();
+ protected $word_length = array();
+ protected $search_query;
+ protected $common_words = array();
- var $must_contain_ids = array();
- var $must_not_contain_ids = array();
- var $must_exclude_one_ids = array();
+ protected $must_contain_ids = array();
+ protected $must_not_contain_ids = array();
+ protected $must_exclude_one_ids = array();
+
+ protected $phpbb_root_path;
+ protected $php_ext;
+ protected $config;
+ protected $db;
+ protected $user;
/**
* Initialises the fulltext_native search backend with min/max word length and makes sure the UTF-8 normalizer is loaded.
*
* @param boolean|string &$error is passed by reference and should either be set to false on success or an error message on failure.
*/
- public function __construct(&$error)
+ public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user)
{
- global $phpbb_root_path, $phpEx, $config;
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $phpEx;
+ $this->config = $config;
+ $this->db = $db;
+ $this->user = $user;
- $this->word_length = array('min' => $config['fulltext_native_min_chars'], 'max' => $config['fulltext_native_max_chars']);
+ $this->word_length = array('min' => $this->config['fulltext_native_min_chars'], 'max' => $this->config['fulltext_native_max_chars']);
/**
* Load the UTF tools
*/
if (!class_exists('utf_normalizer'))
{
- include($phpbb_root_path . 'includes/utf/utf_normalizer.' . $phpEx);
+ include($this->phpbb_root_path . 'includes/utf/utf_normalizer.' . $this->php_ext);
}
$error = false;
@@ -64,6 +74,36 @@ class phpbb_search_fulltext_native extends phpbb_search_base
}
/**
+ * Returns the search_query
+ *
+ * @return string search query
+ */
+ public function get_search_query()
+ {
+ return $this->search_query;
+ }
+
+ /**
+ * Returns the common_words array
+ *
+ * @return array common words that are ignored by search backend
+ */
+ public function get_common_words()
+ {
+ return $this->common_words;
+ }
+
+ /**
+ * Returns the word_length array
+ *
+ * @return array min and max word length for searching
+ */
+ public function get_word_length()
+ {
+ return $this->word_length;
+ }
+
+ /**
* This function fills $this->search_query with the cleaned user search query.
*
* If $terms is 'any' then the words will be extracted from the search query
@@ -77,13 +117,9 @@ class phpbb_search_fulltext_native extends phpbb_search_base
* @param string $terms is either 'all' (use search query as entered, default words to 'must be contained in post')
* or 'any' (find all posts containing at least one of the given words)
* @return boolean false if no valid keywords were found and otherwise true
- *
- * @access public
*/
- function split_keywords($keywords, $terms)
+ public function split_keywords($keywords, $terms)
{
- global $db, $user, $config;
-
$tokens = '+-|()*';
$keywords = trim($this->cleanup($keywords, $tokens));
@@ -182,9 +218,9 @@ class phpbb_search_fulltext_native extends phpbb_search_base
$num_keywords = sizeof(explode(' ', $keywords));
// We limit the number of allowed keywords to minimize load on the database
- if ($config['max_num_search_keywords'] && $num_keywords > $config['max_num_search_keywords'])
+ if ($this->config['max_num_search_keywords'] && $num_keywords > $this->config['max_num_search_keywords'])
{
- trigger_error($user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', $config['max_num_search_keywords'], $num_keywords));
+ trigger_error($this->user->lang('MAX_NUM_SEARCH_KEYWORDS_REFINE', $this->config['max_num_search_keywords'], $num_keywords));
}
// $keywords input format: each word separated by a space, words in a bracket are not separated
@@ -214,12 +250,12 @@ class phpbb_search_fulltext_native extends phpbb_search_base
{
$sql = 'SELECT word_id, word_text, word_common
FROM ' . SEARCH_WORDLIST_TABLE . '
- WHERE ' . $db->sql_in_set('word_text', $exact_words) . '
+ WHERE ' . $this->db->sql_in_set('word_text', $exact_words) . '
ORDER BY word_count ASC';
- $result = $db->sql_query($sql);
+ $result = $this->db->sql_query($sql);
// store an array of words and ids, remove common words
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
if ($row['word_common'])
{
@@ -230,7 +266,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
$words[$row['word_text']] = (int) $row['word_id'];
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
}
unset($exact_words);
@@ -301,7 +337,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
{
if (strpos($word_part, '*') !== false)
{
- $id_words[] = '\'' . $db->sql_escape(str_replace('*', '%', $word_part)) . '\'';
+ $id_words[] = '\'' . $this->db->sql_escape(str_replace('*', '%', $word_part)) . '\'';
$non_common_words[] = $word_part;
}
else if (isset($words[$word_part]))
@@ -334,7 +370,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
// throw an error if we shall not ignore unexistant words
else if (!$ignore_no_id && sizeof($non_common_words))
{
- trigger_error(sprintf($user->lang['WORDS_IN_NO_POST'], implode(', ', $non_common_words)));
+ trigger_error(sprintf($user->lang['WORDS_IN_NO_POST'], implode($user->lang['COMMA_SEPARATOR'], $non_common_words)));
}
unset($non_common_words);
}
@@ -346,7 +382,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
$len = utf8_strlen(str_replace('*', '', $word));
if ($len >= $this->word_length['min'] && $len <= $this->word_length['max'])
{
- $this->{$mode . '_ids'}[] = '\'' . $db->sql_escape(str_replace('*', '%', $word)) . '\'';
+ $this->{$mode . '_ids'}[] = '\'' . $this->db->sql_escape(str_replace('*', '%', $word)) . '\'';
}
else
{
@@ -366,7 +402,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
$len = utf8_strlen($word);
if ($len >= $this->word_length['min'] && $len <= $this->word_length['max'])
{
- trigger_error(sprintf($user->lang['WORD_IN_NO_POST'], $word));
+ trigger_error(sprintf($this->user->lang['WORD_IN_NO_POST'], $word));
}
else
{
@@ -416,13 +452,9 @@ class phpbb_search_fulltext_native extends phpbb_search_base
* @param int $start indicates the first index of the page
* @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results
- *
- * @access public
*/
- function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
+ public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
{
- global $config, $db;
-
// No keywords? No posts.
if (empty($this->search_query))
{
@@ -537,7 +569,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
}
}
- $sql_where[] = $db->sql_in_set("m$m_num.word_id", $word_ids);
+ $sql_where[] = $this->db->sql_in_set("m$m_num.word_id", $word_ids);
unset($word_id_sql);
unset($word_ids);
@@ -591,7 +623,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
{
$sql_array['LEFT_JOIN'][] = array(
'FROM' => array(SEARCH_WORDMATCH_TABLE => 'm' . $m_num),
- 'ON' => $db->sql_in_set("m$m_num.word_id", $this->must_not_contain_ids) . (($title_match) ? " AND m$m_num.$title_match" : '') . " AND m$m_num.post_id = m0.post_id"
+ 'ON' => $this->db->sql_in_set("m$m_num.word_id", $this->must_not_contain_ids) . (($title_match) ? " AND m$m_num.$title_match" : '') . " AND m$m_num.post_id = m0.post_id"
);
$sql_where[] = "m$m_num.word_id IS NULL";
@@ -632,7 +664,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
}
else if ($m_approve_fid_ary !== array(-1))
{
- $sql_where[] = '(p.post_approved = 1 OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')';
+ $sql_where[] = '(p.post_approved = 1 OR ' . $this->db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')';
}
if ($topic_id)
@@ -645,18 +677,18 @@ class phpbb_search_fulltext_native extends phpbb_search_base
if ($author_name)
{
// first one matches post of registered users, second one guests and deleted users
- $sql_author = '(' . $db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')';
+ $sql_author = '(' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')';
}
else
{
- $sql_author = $db->sql_in_set('p.poster_id', $author_ary);
+ $sql_author = $this->db->sql_in_set('p.poster_id', $author_ary);
}
$sql_where[] = $sql_author;
}
if (sizeof($ex_fid_ary))
{
- $sql_where[] = $db->sql_in_set('p.forum_id', $ex_fid_ary, true);
+ $sql_where[] = $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true);
}
if ($sort_days)
@@ -681,7 +713,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
);
}
- switch ($db->sql_layer)
+ switch ($this->db->sql_layer)
{
case 'mysql4':
case 'mysqli':
@@ -695,17 +727,17 @@ class phpbb_search_fulltext_native extends phpbb_search_base
case 'sqlite':
$sql_array_count['SELECT'] = ($type == 'posts') ? 'DISTINCT p.post_id' : 'DISTINCT p.topic_id';
$sql = 'SELECT COUNT(' . (($type == 'posts') ? 'post_id' : 'topic_id') . ') as total_results
- FROM (' . $db->sql_build_query('SELECT', $sql_array_count) . ')';
+ FROM (' . $this->db->sql_build_query('SELECT', $sql_array_count) . ')';
// no break
default:
$sql_array_count['SELECT'] = ($type == 'posts') ? 'COUNT(DISTINCT p.post_id) AS total_results' : 'COUNT(DISTINCT p.topic_id) AS total_results';
- $sql = (!$sql) ? $db->sql_build_query('SELECT', $sql_array_count) : $sql;
+ $sql = (!$sql) ? $this->db->sql_build_query('SELECT', $sql_array_count) : $sql;
- $result = $db->sql_query($sql);
- $total_results = (int) $db->sql_fetchfield('total_results');
- $db->sql_freeresult($result);
+ $result = $this->db->sql_query($sql);
+ $total_results = (int) $this->db->sql_fetchfield('total_results');
+ $this->db->sql_freeresult($result);
if (!$total_results)
{
@@ -751,14 +783,14 @@ class phpbb_search_fulltext_native extends phpbb_search_base
unset($sql_where, $sql_sort, $group_by);
- $sql = $db->sql_build_query('SELECT', $sql_array);
- $result = $db->sql_query_limit($sql, $config['search_block_size'], $start);
+ $sql = $this->db->sql_build_query('SELECT', $sql_array);
+ $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
$id_ary[] = (int) $row[(($type == 'posts') ? 'post_id' : 'topic_id')];
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
if (!sizeof($id_ary))
{
@@ -772,16 +804,16 @@ class phpbb_search_fulltext_native extends phpbb_search_base
$sql_array_copy = $sql_array;
$sql_array_copy['SELECT'] = 'SQL_CALC_FOUND_ROWS p.post_id ';
- $sql = $db->sql_build_query('SELECT', $sql_array_copy);
+ $sql = $this->db->sql_build_query('SELECT', $sql_array_copy);
unset($sql_array_copy);
- $db->sql_query($sql);
- $db->sql_freeresult($result);
+ $this->db->sql_query($sql);
+ $this->db->sql_freeresult($result);
$sql = 'SELECT FOUND_ROWS() as total_results';
- $result = $db->sql_query($sql);
- $total_results = (int) $db->sql_fetchfield('total_results');
- $db->sql_freeresult($result);
+ $result = $this->db->sql_query($sql);
+ $total_results = (int) $this->db->sql_fetchfield('total_results');
+ $this->db->sql_freeresult($result);
if (!$total_results)
{
@@ -814,13 +846,9 @@ class phpbb_search_fulltext_native extends phpbb_search_base
* @param int $start indicates the first index of the page
* @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results
- *
- * @access public
*/
- function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
+ public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
{
- global $config, $db;
-
// No author? No posts.
if (!sizeof($author_ary))
{
@@ -856,13 +884,13 @@ class phpbb_search_fulltext_native extends phpbb_search_base
if ($author_name)
{
// first one matches post of registered users, second one guests and deleted users
- $sql_author = '(' . $db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')';
+ $sql_author = '(' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')';
}
else
{
- $sql_author = $db->sql_in_set('p.poster_id', $author_ary);
+ $sql_author = $this->db->sql_in_set('p.poster_id', $author_ary);
}
- $sql_fora = (sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
+ $sql_fora = (sizeof($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
$sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
$sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : '';
$sql_firstpost = ($firstpost_only) ? ' AND p.post_id = t.topic_first_post_id' : '';
@@ -898,7 +926,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
}
else
{
- $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')';
+ $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $this->db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')';
}
$select = ($type == 'posts') ? 'p.post_id' : 't.topic_id';
@@ -907,7 +935,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
// If the cache was completely empty count the results
if (!$total_results)
{
- switch ($db->sql_layer)
+ switch ($this->db->sql_layer)
{
case 'mysql4':
case 'mysqli':
@@ -929,7 +957,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
}
else
{
- if ($db->sql_layer == 'sqlite')
+ if ($this->db->sql_layer == 'sqlite')
{
$sql = 'SELECT COUNT(topic_id) as total_results
FROM (SELECT DISTINCT t.topic_id';
@@ -946,12 +974,12 @@ class phpbb_search_fulltext_native extends phpbb_search_base
$m_approve_fid_sql
$sql_fora
AND t.topic_id = p.topic_id
- $sql_time" . (($db->sql_layer == 'sqlite') ? ')' : '');
+ $sql_time" . (($this->db->sql_layer == 'sqlite') ? ')' : '');
}
- $result = $db->sql_query($sql);
+ $result = $this->db->sql_query($sql);
- $total_results = (int) $db->sql_fetchfield('total_results');
- $db->sql_freeresult($result);
+ $total_results = (int) $this->db->sql_fetchfield('total_results');
+ $this->db->sql_freeresult($result);
if (!$total_results)
{
@@ -994,26 +1022,26 @@ class phpbb_search_fulltext_native extends phpbb_search_base
}
// Only read one block of posts from the db and then cache it
- $result = $db->sql_query_limit($sql, $config['search_block_size'], $start);
+ $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
$id_ary[] = (int) $row[$field];
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
if (!$total_results && $is_mysql)
{
// Count rows for the executed queries. Replace $select within $sql with SQL_CALC_FOUND_ROWS, and run it.
$sql = str_replace('SELECT ' . $select, 'SELECT DISTINCT SQL_CALC_FOUND_ROWS p.post_id', $sql);
- $db->sql_query($sql);
- $db->sql_freeresult($result);
+ $this->db->sql_query($sql);
+ $this->db->sql_freeresult($result);
$sql = 'SELECT FOUND_ROWS() as total_results';
- $result = $db->sql_query($sql);
- $total_results = (int) $db->sql_fetchfield('total_results');
- $db->sql_freeresult($result);
+ $result = $this->db->sql_query($sql);
+ $total_results = (int) $this->db->sql_fetchfield('total_results');
+ $this->db->sql_freeresult($result);
if (!$total_results)
{
@@ -1041,13 +1069,9 @@ class phpbb_search_fulltext_native extends phpbb_search_base
*
* @param string $text Text to split, encoded in UTF-8
* @return array Array of UTF-8 words
- *
- * @access private
*/
- function split_message($text)
+ public function split_message($text)
{
- global $phpbb_root_path, $phpEx, $user;
-
$match = $words = array();
/**
@@ -1120,14 +1144,10 @@ class phpbb_search_fulltext_native extends phpbb_search_base
* @param string &$subject New or updated post subject
* @param int $poster_id Post author's user id
* @param int $forum_id The id of the forum in which the post is located
- *
- * @access public
*/
- function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id)
+ public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id)
{
- global $config, $db, $user;
-
- if (!$config['fulltext_native_load_upd'])
+ if (!$this->config['fulltext_native_load_upd'])
{
/**
* The search indexer is disabled, return
@@ -1153,14 +1173,14 @@ class phpbb_search_fulltext_native extends phpbb_search_base
FROM ' . SEARCH_WORDLIST_TABLE . ' w, ' . SEARCH_WORDMATCH_TABLE . " m
WHERE m.post_id = $post_id
AND w.word_id = m.word_id";
- $result = $db->sql_query($sql);
+ $result = $this->db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
$which = ($row['title_match']) ? 'title' : 'post';
$cur_words[$which][$row['word_text']] = $row['word_id'];
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
$words['add']['post'] = array_diff($split_text, array_keys($cur_words['post']));
$words['add']['title'] = array_diff($split_title, array_keys($cur_words['title']));
@@ -1188,18 +1208,18 @@ class phpbb_search_fulltext_native extends phpbb_search_base
{
$sql = 'SELECT word_id, word_text
FROM ' . SEARCH_WORDLIST_TABLE . '
- WHERE ' . $db->sql_in_set('word_text', $unique_add_words);
- $result = $db->sql_query($sql);
+ WHERE ' . $this->db->sql_in_set('word_text', $unique_add_words);
+ $result = $this->db->sql_query($sql);
$word_ids = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
$word_ids[$row['word_text']] = $row['word_id'];
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
$new_words = array_diff($unique_add_words, array_keys($word_ids));
- $db->sql_transaction('begin');
+ $this->db->sql_transaction('begin');
if (sizeof($new_words))
{
$sql_ary = array();
@@ -1208,15 +1228,15 @@ class phpbb_search_fulltext_native extends phpbb_search_base
{
$sql_ary[] = array('word_text' => (string) $word, 'word_count' => 0);
}
- $db->sql_return_on_error(true);
- $db->sql_multi_insert(SEARCH_WORDLIST_TABLE, $sql_ary);
- $db->sql_return_on_error(false);
+ $this->db->sql_return_on_error(true);
+ $this->db->sql_multi_insert(SEARCH_WORDLIST_TABLE, $sql_ary);
+ $this->db->sql_return_on_error(false);
}
unset($new_words, $sql_ary);
}
else
{
- $db->sql_transaction('begin');
+ $this->db->sql_transaction('begin');
}
// now update the search match table, remove links to removed words and add links to new words
@@ -1233,22 +1253,22 @@ class phpbb_search_fulltext_native extends phpbb_search_base
}
$sql = 'DELETE FROM ' . SEARCH_WORDMATCH_TABLE . '
- WHERE ' . $db->sql_in_set('word_id', $sql_in) . '
+ WHERE ' . $this->db->sql_in_set('word_id', $sql_in) . '
AND post_id = ' . intval($post_id) . "
AND title_match = $title_match";
- $db->sql_query($sql);
+ $this->db->sql_query($sql);
$sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . '
SET word_count = word_count - 1
- WHERE ' . $db->sql_in_set('word_id', $sql_in) . '
+ WHERE ' . $this->db->sql_in_set('word_id', $sql_in) . '
AND word_count > 0';
- $db->sql_query($sql);
+ $this->db->sql_query($sql);
unset($sql_in);
}
}
- $db->sql_return_on_error(true);
+ $this->db->sql_return_on_error(true);
foreach ($words['add'] as $word_in => $word_ary)
{
$title_match = ($word_in == 'title') ? 1 : 0;
@@ -1258,18 +1278,18 @@ class phpbb_search_fulltext_native extends phpbb_search_base
$sql = 'INSERT INTO ' . SEARCH_WORDMATCH_TABLE . ' (post_id, word_id, title_match)
SELECT ' . (int) $post_id . ', word_id, ' . (int) $title_match . '
FROM ' . SEARCH_WORDLIST_TABLE . '
- WHERE ' . $db->sql_in_set('word_text', $word_ary);
- $db->sql_query($sql);
+ WHERE ' . $this->db->sql_in_set('word_text', $word_ary);
+ $this->db->sql_query($sql);
$sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . '
SET word_count = word_count + 1
- WHERE ' . $db->sql_in_set('word_text', $word_ary);
- $db->sql_query($sql);
+ WHERE ' . $this->db->sql_in_set('word_text', $word_ary);
+ $this->db->sql_query($sql);
}
}
- $db->sql_return_on_error(false);
+ $this->db->sql_return_on_error(false);
- $db->sql_transaction('commit');
+ $this->db->sql_transaction('commit');
// destroy cached search results containing any of the words removed or added
$this->destroy_cache(array_unique(array_merge($words['add']['post'], $words['add']['title'], $words['del']['post'], $words['del']['title'])), array($poster_id));
@@ -1282,20 +1302,18 @@ class phpbb_search_fulltext_native extends phpbb_search_base
/**
* Removes entries from the wordmatch table for the specified post_ids
*/
- function index_remove($post_ids, $author_ids, $forum_ids)
+ public function index_remove($post_ids, $author_ids, $forum_ids)
{
- global $db;
-
if (sizeof($post_ids))
{
$sql = 'SELECT w.word_id, w.word_text, m.title_match
FROM ' . SEARCH_WORDMATCH_TABLE . ' m, ' . SEARCH_WORDLIST_TABLE . ' w
- WHERE ' . $db->sql_in_set('m.post_id', $post_ids) . '
+ WHERE ' . $this->db->sql_in_set('m.post_id', $post_ids) . '
AND w.word_id = m.word_id';
- $result = $db->sql_query($sql);
+ $result = $this->db->sql_query($sql);
$message_word_ids = $title_word_ids = $word_texts = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
if ($row['title_match'])
{
@@ -1307,32 +1325,32 @@ class phpbb_search_fulltext_native extends phpbb_search_base
}
$word_texts[] = $row['word_text'];
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
if (sizeof($title_word_ids))
{
$sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . '
SET word_count = word_count - 1
- WHERE ' . $db->sql_in_set('word_id', $title_word_ids) . '
+ WHERE ' . $this->db->sql_in_set('word_id', $title_word_ids) . '
AND word_count > 0';
- $db->sql_query($sql);
+ $this->db->sql_query($sql);
}
if (sizeof($message_word_ids))
{
$sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . '
SET word_count = word_count - 1
- WHERE ' . $db->sql_in_set('word_id', $message_word_ids) . '
+ WHERE ' . $this->db->sql_in_set('word_id', $message_word_ids) . '
AND word_count > 0';
- $db->sql_query($sql);
+ $this->db->sql_query($sql);
}
unset($title_word_ids);
unset($message_word_ids);
$sql = 'DELETE FROM ' . SEARCH_WORDMATCH_TABLE . '
- WHERE ' . $db->sql_in_set('post_id', $post_ids);
- $db->sql_query($sql);
+ WHERE ' . $this->db->sql_in_set('post_id', $post_ids);
+ $this->db->sql_query($sql);
}
$this->destroy_cache(array_unique($word_texts), array_unique($author_ids));
@@ -1342,13 +1360,11 @@ class phpbb_search_fulltext_native extends phpbb_search_base
* Tidy up indexes: Tag 'common words' and remove
* words no longer referenced in the match table
*/
- function tidy()
+ public function tidy()
{
- global $db, $config;
-
// Is the fulltext indexer disabled? If yes then we need not
// carry on ... it's okay ... I know when I'm not wanted boo hoo
- if (!$config['fulltext_native_load_upd'])
+ if (!$this->config['fulltext_native_load_upd'])
{
set_config('search_last_gc', time(), true);
return;
@@ -1357,31 +1373,31 @@ class phpbb_search_fulltext_native extends phpbb_search_base
$destroy_cache_words = array();
// Remove common words
- if ($config['num_posts'] >= 100 && $config['fulltext_native_common_thres'])
+ if ($this->config['num_posts'] >= 100 && $this->config['fulltext_native_common_thres'])
{
- $common_threshold = ((double) $config['fulltext_native_common_thres']) / 100.0;
+ $common_threshold = ((double) $this->config['fulltext_native_common_thres']) / 100.0;
// First, get the IDs of common words
$sql = 'SELECT word_id, word_text
FROM ' . SEARCH_WORDLIST_TABLE . '
- WHERE word_count > ' . floor($config['num_posts'] * $common_threshold) . '
+ WHERE word_count > ' . floor($this->config['num_posts'] * $common_threshold) . '
OR word_common = 1';
- $result = $db->sql_query($sql);
+ $result = $this->db->sql_query($sql);
$sql_in = array();
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
$sql_in[] = $row['word_id'];
$destroy_cache_words[] = $row['word_text'];
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
if (sizeof($sql_in))
{
// Flag the words
$sql = 'UPDATE ' . SEARCH_WORDLIST_TABLE . '
SET word_common = 1
- WHERE ' . $db->sql_in_set('word_id', $sql_in);
- $db->sql_query($sql);
+ WHERE ' . $this->db->sql_in_set('word_id', $sql_in);
+ $this->db->sql_query($sql);
// by setting search_last_gc to the new time here we make sure that if a user reloads because the
// following query takes too long, he won't run into it again
@@ -1389,8 +1405,8 @@ class phpbb_search_fulltext_native extends phpbb_search_base
// Delete the matches
$sql = 'DELETE FROM ' . SEARCH_WORDMATCH_TABLE . '
- WHERE ' . $db->sql_in_set('word_id', $sql_in);
- $db->sql_query($sql);
+ WHERE ' . $this->db->sql_in_set('word_id', $sql_in);
+ $this->db->sql_query($sql);
}
unset($sql_in);
}
@@ -1407,23 +1423,21 @@ class phpbb_search_fulltext_native extends phpbb_search_base
/**
* Deletes all words from the index
*/
- function delete_index($acp_module, $u_action)
+ public function delete_index($acp_module, $u_action)
{
- global $db;
-
- switch ($db->sql_layer)
+ switch ($this->db->sql_layer)
{
case 'sqlite':
case 'firebird':
- $db->sql_query('DELETE FROM ' . SEARCH_WORDLIST_TABLE);
- $db->sql_query('DELETE FROM ' . SEARCH_WORDMATCH_TABLE);
- $db->sql_query('DELETE FROM ' . SEARCH_RESULTS_TABLE);
+ $this->db->sql_query('DELETE FROM ' . SEARCH_WORDLIST_TABLE);
+ $this->db->sql_query('DELETE FROM ' . SEARCH_WORDMATCH_TABLE);
+ $this->db->sql_query('DELETE FROM ' . SEARCH_RESULTS_TABLE);
break;
default:
- $db->sql_query('TRUNCATE TABLE ' . SEARCH_WORDLIST_TABLE);
- $db->sql_query('TRUNCATE TABLE ' . SEARCH_WORDMATCH_TABLE);
- $db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
+ $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_WORDLIST_TABLE);
+ $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_WORDMATCH_TABLE);
+ $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
break;
}
}
@@ -1431,7 +1445,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
/**
* Returns true if both FULLTEXT indexes exist
*/
- function index_created()
+ public function index_created()
{
if (!sizeof($this->stats))
{
@@ -1444,26 +1458,22 @@ class phpbb_search_fulltext_native extends phpbb_search_base
/**
* Returns an associative array containing information about the indexes
*/
- function index_stats()
+ public function index_stats()
{
- global $user;
-
if (!sizeof($this->stats))
{
$this->get_stats();
}
return array(
- $user->lang['TOTAL_WORDS'] => $this->stats['total_words'],
- $user->lang['TOTAL_MATCHES'] => $this->stats['total_matches']);
+ $this->user->lang['TOTAL_WORDS'] => $this->stats['total_words'],
+ $this->user->lang['TOTAL_MATCHES'] => $this->stats['total_matches']);
}
- function get_stats()
+ protected function get_stats()
{
- global $db;
-
- $this->stats['total_words'] = $db->get_estimated_row_count(SEARCH_WORDLIST_TABLE);
- $this->stats['total_matches'] = $db->get_estimated_row_count(SEARCH_WORDMATCH_TABLE);
+ $this->stats['total_words'] = $this->db->get_estimated_row_count(SEARCH_WORDLIST_TABLE);
+ $this->stats['total_matches'] = $this->db->get_estimated_row_count(SEARCH_WORDMATCH_TABLE);
}
/**
@@ -1481,9 +1491,8 @@ class phpbb_search_fulltext_native extends phpbb_search_base
*
* @todo normalizer::cleanup being able to be used?
*/
- function cleanup($text, $allowed_chars = null, $encoding = 'utf-8')
+ protected function cleanup($text, $allowed_chars = null, $encoding = 'utf-8')
{
- global $phpbb_root_path, $phpEx;
static $conv = array(), $conv_loaded = array();
$words = $allow = array();
@@ -1680,7 +1689,7 @@ class phpbb_search_fulltext_native extends phpbb_search_base
if (!isset($conv_loaded[$idx]))
{
$conv_loaded[$idx] = 1;
- $file = $phpbb_root_path . 'includes/utf/data/search_indexer_' . $idx . '.' . $phpEx;
+ $file = $this->phpbb_root_path . 'includes/utf/data/search_indexer_' . $idx . '.' . $this->php_ext;
if (file_exists($file))
{
@@ -1711,31 +1720,28 @@ class phpbb_search_fulltext_native extends phpbb_search_base
/**
* Returns a list of options for the ACP to display
*/
- function acp()
+ public function acp()
{
- global $user, $config;
-
-
/**
* if we need any options, copied from fulltext_native for now, will have to be adjusted or removed
*/
$tpl = '
<dl>
- <dt><label for="fulltext_native_load_upd">' . $user->lang['YES_SEARCH_UPDATE'] . ':</label><br /><span>' . $user->lang['YES_SEARCH_UPDATE_EXPLAIN'] . '</span></dt>
- <dd><label><input type="radio" id="fulltext_native_load_upd" name="config[fulltext_native_load_upd]" value="1"' . (($config['fulltext_native_load_upd']) ? ' checked="checked"' : '') . ' class="radio" /> ' . $user->lang['YES'] . '</label><label><input type="radio" name="config[fulltext_native_load_upd]" value="0"' . ((!$config['fulltext_native_load_upd']) ? ' checked="checked"' : '') . ' class="radio" /> ' . $user->lang['NO'] . '</label></dd>
+ <dt><label for="fulltext_native_load_upd">' . $this->user->lang['YES_SEARCH_UPDATE'] . ':</label><br /><span>' . $this->user->lang['YES_SEARCH_UPDATE_EXPLAIN'] . '</span></dt>
+ <dd><label><input type="radio" id="fulltext_native_load_upd" name="config[fulltext_native_load_upd]" value="1"' . (($this->config['fulltext_native_load_upd']) ? ' checked="checked"' : '') . ' class="radio" /> ' . $this->user->lang['YES'] . '</label><label><input type="radio" name="config[fulltext_native_load_upd]" value="0"' . ((!$this->config['fulltext_native_load_upd']) ? ' checked="checked"' : '') . ' class="radio" /> ' . $this->user->lang['NO'] . '</label></dd>
</dl>
<dl>
- <dt><label for="fulltext_native_min_chars">' . $user->lang['MIN_SEARCH_CHARS'] . ':</label><br /><span>' . $user->lang['MIN_SEARCH_CHARS_EXPLAIN'] . '</span></dt>
- <dd><input id="fulltext_native_min_chars" type="text" size="3" maxlength="3" name="config[fulltext_native_min_chars]" value="' . (int) $config['fulltext_native_min_chars'] . '" /></dd>
+ <dt><label for="fulltext_native_min_chars">' . $this->user->lang['MIN_SEARCH_CHARS'] . ':</label><br /><span>' . $this->user->lang['MIN_SEARCH_CHARS_EXPLAIN'] . '</span></dt>
+ <dd><input id="fulltext_native_min_chars" type="text" size="3" maxlength="3" name="config[fulltext_native_min_chars]" value="' . (int) $this->config['fulltext_native_min_chars'] . '" /></dd>
</dl>
<dl>
- <dt><label for="fulltext_native_max_chars">' . $user->lang['MAX_SEARCH_CHARS'] . ':</label><br /><span>' . $user->lang['MAX_SEARCH_CHARS_EXPLAIN'] . '</span></dt>
- <dd><input id="fulltext_native_max_chars" type="text" size="3" maxlength="3" name="config[fulltext_native_max_chars]" value="' . (int) $config['fulltext_native_max_chars'] . '" /></dd>
+ <dt><label for="fulltext_native_max_chars">' . $this->user->lang['MAX_SEARCH_CHARS'] . ':</label><br /><span>' . $this->user->lang['MAX_SEARCH_CHARS_EXPLAIN'] . '</span></dt>
+ <dd><input id="fulltext_native_max_chars" type="text" size="3" maxlength="3" name="config[fulltext_native_max_chars]" value="' . (int) $this->config['fulltext_native_max_chars'] . '" /></dd>
</dl>
<dl>
- <dt><label for="fulltext_native_common_thres">' . $user->lang['COMMON_WORD_THRESHOLD'] . ':</label><br /><span>' . $user->lang['COMMON_WORD_THRESHOLD_EXPLAIN'] . '</span></dt>
- <dd><input id="fulltext_native_common_thres" type="text" size="3" maxlength="3" name="config[fulltext_native_common_thres]" value="' . (double) $config['fulltext_native_common_thres'] . '" /> %</dd>
+ <dt><label for="fulltext_native_common_thres">' . $this->user->lang['COMMON_WORD_THRESHOLD'] . ':</label><br /><span>' . $this->user->lang['COMMON_WORD_THRESHOLD_EXPLAIN'] . '</span></dt>
+ <dd><input id="fulltext_native_common_thres" type="text" size="3" maxlength="3" name="config[fulltext_native_common_thres]" value="' . (double) $this->config['fulltext_native_common_thres'] . '" /> %</dd>
</dl>
';
diff --git a/phpBB/includes/search/fulltext_postgres.php b/phpBB/includes/search/fulltext_postgres.php
index 84ce674564..38989a9d9a 100644
--- a/phpBB/includes/search/fulltext_postgres.php
+++ b/phpBB/includes/search/fulltext_postgres.php
@@ -22,15 +22,18 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_search_fulltext_postgres extends phpbb_search_base
{
- private $stats = array();
- private $split_words = array();
- private $tsearch_usable = false;
- private $version;
- private $tsearch_query;
- private $phrase_search = false;
- public $search_query;
- public $common_words = array();
- public $word_length = array();
+ protected $stats = array();
+ protected $split_words = array();
+ protected $tsearch_usable = false;
+ protected $version;
+ protected $tsearch_query;
+ protected $phrase_search = false;
+ protected $config;
+ protected $db;
+ protected $user;
+ protected $search_query;
+ protected $common_words = array();
+ protected $word_length = array();
/**
* Constructor
@@ -38,16 +41,17 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
*
* @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false
*/
- public function __construct(&$error)
+ public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user)
{
- global $db, $config;
+ $this->config = $config;
+ $this->db = $db;
+ $this->user = $user;
- $this->word_length = array('min' => $config['fulltext_postgres_min_word_len'], 'max' => $config['fulltext_postgres_max_word_len']);
+ $this->word_length = array('min' => $this->config['fulltext_postgres_min_word_len'], 'max' => $this->config['fulltext_postgres_max_word_len']);
-
- if ($db->sql_layer == 'postgres')
+ if ($this->db->sql_layer == 'postgres')
{
- $pgsql_version = explode(',', substr($db->sql_server_info(), 10));
+ $pgsql_version = explode(',', substr($this->db->sql_server_info(), 10));
$this->version = trim($pgsql_version[0]);
if (version_compare($this->version, '8.3', '>='))
{
@@ -62,8 +66,6 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
* Returns the name of this search backend to be displayed to administrators
*
* @return string Name
- *
- * @access public
*/
public function get_name()
{
@@ -71,11 +73,39 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
}
/**
+ * Returns the search_query
+ *
+ * @return string search query
+ */
+ public function get_search_query()
+ {
+ return $this->search_query;
+ }
+
+ /**
+ * Returns the common_words array
+ *
+ * @return array common words that are ignored by search backend
+ */
+ public function get_common_words()
+ {
+ return $this->common_words;
+ }
+
+ /**
+ * Returns the word_length array
+ *
+ * @return array min and max word length for searching
+ */
+ public function get_word_length()
+ {
+ return $this->word_length;
+ }
+
+ /**
* Returns if phrase search is supported or not
*
* @return bool
- *
- * @access public
*/
public function supports_phrase_search()
{
@@ -86,21 +116,17 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
* Checks for correct PostgreSQL version and stores min/max word length in the config
*
* @return string|bool Language key of the error/incompatiblity occured
- *
- * @access public
*/
- function init()
+ public function init()
{
- global $db, $user;
-
- if ($db->sql_layer != 'postgres')
+ if ($this->db->sql_layer != 'postgres')
{
- return $user->lang['FULLTEXT_POSTGRES_INCOMPATIBLE_DATABASE'];
+ return $this->user->lang['FULLTEXT_POSTGRES_INCOMPATIBLE_DATABASE'];
}
if (!$this->tsearch_usable)
{
- return $user->lang['FULLTEXT_POSTGRES_TS_NOT_USABLE'];
+ return $this->user->lang['FULLTEXT_POSTGRES_TS_NOT_USABLE'];
}
return false;
@@ -113,13 +139,9 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
* @param string &$keywords Contains the keyword as entered by the user
* @param string $terms is either 'all' or 'any'
* @return bool false if no valid keywords were found and otherwise true
- *
- * @access public
*/
- function split_keywords(&$keywords, $terms)
+ public function split_keywords(&$keywords, $terms)
{
- global $config;
-
if ($terms == 'all')
{
$match = array('#\sand\s#iu', '#\sor\s#iu', '#\snot\s#iu', '#\+#', '#-#', '#\|#');
@@ -143,7 +165,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
// check word length
$clean_len = utf8_strlen(str_replace('*', '', $clean_word));
- if (($clean_len < $config['fulltext_postgres_min_word_len']) || ($clean_len > $config['fulltext_postgres_max_word_len']))
+ if (($clean_len < $this->config['fulltext_postgres_min_word_len']) || ($clean_len > $this->config['fulltext_postgres_max_word_len']))
{
$this->common_words[] = $word;
unset($this->split_words[$i]);
@@ -208,13 +230,9 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
/**
* Turns text into an array of words
* @param string $text contains post text/subject
- *
- * @access public
*/
- function split_message($text)
+ public function split_message($text)
{
- global $config;
-
// Split words
$text = preg_replace('#([^\p{L}\p{N}\'*])#u', '$1$1', str_replace('\'\'', '\' \'', trim($text)));
$matches = array();
@@ -226,7 +244,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
for ($i = 0, $n = sizeof($text); $i < $n; $i++)
{
$text[$i] = trim($text[$i]);
- if (utf8_strlen($text[$i]) < $config['fulltext_postgres_min_word_len'] || utf8_strlen($text[$i]) > $config['fulltext_postgres_max_word_len'])
+ if (utf8_strlen($text[$i]) < $this->config['fulltext_postgres_min_word_len'] || utf8_strlen($text[$i]) > $this->config['fulltext_postgres_max_word_len'])
{
unset($text[$i]);
}
@@ -254,13 +272,9 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
* @param int $start indicates the first index of the page
* @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results
- *
- * @access public
*/
- function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
+ public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
{
- global $config, $db;
-
// No keywords? No posts.
if (!$this->search_query)
{
@@ -349,7 +363,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
}
else
{
- $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')';
+ $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $this->db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')';
}
$sql_select = ($type == 'posts') ? 'p.post_id' : 'DISTINCT t.topic_id';
@@ -360,11 +374,11 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
if (sizeof($author_ary) && $author_name)
{
// first one matches post of registered users, second one guests and deleted users
- $sql_author = '(' . $db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')';
+ $sql_author = '(' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')';
}
else if (sizeof($author_ary))
{
- $sql_author = ' AND ' . $db->sql_in_set('p.poster_id', $author_ary);
+ $sql_author = ' AND ' . $this->db->sql_in_set('p.poster_id', $author_ary);
}
else
{
@@ -374,7 +388,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
$sql_where_options = $sql_sort_join;
$sql_where_options .= ($topic_id) ? ' AND p.topic_id = ' . $topic_id : '';
$sql_where_options .= ($join_topic) ? ' AND t.topic_id = p.topic_id' : '';
- $sql_where_options .= (sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
+ $sql_where_options .= (sizeof($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
$sql_where_options .= $m_approve_fid_sql;
$sql_where_options .= $sql_author;
$sql_where_options .= ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
@@ -383,7 +397,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
$tmp_sql_match = array();
foreach (explode(',', $sql_match) as $sql_match_column)
{
- $tmp_sql_match[] = "to_tsvector ('" . $db->sql_escape($config['fulltext_postgres_ts_name']) . "', " . $sql_match_column . ") @@ to_tsquery ('" . $db->sql_escape($config['fulltext_postgres_ts_name']) . "', '" . $db->sql_escape($this->tsearch_query) . "')";
+ $tmp_sql_match[] = "to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', " . $sql_match_column . ") @@ to_tsquery ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', '" . $this->db->sql_escape($this->tsearch_query) . "')";
}
$sql = "SELECT $sql_select
@@ -391,13 +405,13 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
WHERE (" . implode(' OR ', $tmp_sql_match) . ")
$sql_where_options
ORDER BY $sql_sort";
- $result = $db->sql_query_limit($sql, $config['search_block_size'], $start);
+ $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
$id_ary[] = $row[$field];
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
$id_ary = array_unique($id_ary);
@@ -442,13 +456,9 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
* @param int $start indicates the first index of the page
* @param int $per_page number of ids each page is supposed to contain
* @return boolean|int total number of results
- *
- * @access public
*/
- function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
+ public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
{
- global $config, $db;
-
// No author? No posts.
if (!sizeof($author_ary))
{
@@ -484,13 +494,13 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
if ($author_name)
{
// first one matches post of registered users, second one guests and deleted users
- $sql_author = '(' . $db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')';
+ $sql_author = '(' . $this->db->sql_in_set('p.poster_id', array_diff($author_ary, array(ANONYMOUS)), false, true) . ' OR p.post_username ' . $author_name . ')';
}
else
{
- $sql_author = $db->sql_in_set('p.poster_id', $author_ary);
+ $sql_author = $this->db->sql_in_set('p.poster_id', $author_ary);
}
- $sql_fora = (sizeof($ex_fid_ary)) ? ' AND ' . $db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
+ $sql_fora = (sizeof($ex_fid_ary)) ? ' AND ' . $this->db->sql_in_set('p.forum_id', $ex_fid_ary, true) : '';
$sql_topic_id = ($topic_id) ? ' AND p.topic_id = ' . (int) $topic_id : '';
$sql_time = ($sort_days) ? ' AND p.post_time >= ' . (time() - ($sort_days * 86400)) : '';
$sql_firstpost = ($firstpost_only) ? ' AND p.post_id = t.topic_first_post_id' : '';
@@ -526,7 +536,7 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
}
else
{
- $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')';
+ $m_approve_fid_sql = ' AND (p.post_approved = 1 OR ' . $this->db->sql_in_set('p.forum_id', $m_approve_fid_ary, true) . ')';
}
// Build the query for really selecting the post_ids
@@ -562,13 +572,13 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
}
// Only read one block of posts from the db and then cache it
- $result = $db->sql_query_limit($sql, $config['search_block_size'], $start);
+ $result = $this->db->sql_query_limit($sql, $this->config['search_block_size'], $start);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
$id_ary[] = $row[$field];
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
// retrieve the total result count if needed
if (!$result_count)
@@ -600,13 +610,9 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
* @param string $subject contains the subject of the post to index
* @param int $poster_id contains the user id of the poster
* @param int $forum_id contains the forum id of parent forum of the post
- *
- * @access public
*/
- function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id)
+ public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id)
{
- global $db;
-
// Split old and new post/subject to obtain array of words
$split_text = $this->split_message($message);
$split_title = ($subject) ? $this->split_message($subject) : array();
@@ -624,23 +630,17 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
/**
* Destroy cached results, that might be outdated after deleting a post
- *
- * @access public
*/
- function index_remove($post_ids, $author_ids, $forum_ids)
+ public function index_remove($post_ids, $author_ids, $forum_ids)
{
$this->destroy_cache(array(), $author_ids);
}
/**
* Destroy old cache entries
- *
- * @access public
*/
- function tidy()
+ public function tidy()
{
- global $db, $config;
-
// destroy too old cached search results
$this->destroy_cache(array());
@@ -651,13 +651,9 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
* Create fulltext index
*
* @return string|bool error string is returned incase of errors otherwise false
- *
- * @access public
*/
- function create_index($acp_module, $u_action)
+ public function create_index($acp_module, $u_action)
{
- global $db, $config;
-
// Make sure we can actually use PostgreSQL with fulltext indexes
if ($error = $this->init())
{
@@ -671,15 +667,15 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
if (!isset($this->stats['post_subject']))
{
- $db->sql_query("CREATE INDEX " . POSTS_TABLE . "_" . $config['fulltext_postgres_ts_name'] . "_post_subject ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $db->sql_escape($config['fulltext_postgres_ts_name']) . "', post_subject))");
+ $this->db->sql_query("CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_subject ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_subject))");
}
if (!isset($this->stats['post_text']))
{
- $db->sql_query("CREATE INDEX " . POSTS_TABLE . "_" . $config['fulltext_postgres_ts_name'] . "_post_text ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $db->sql_escape($config['fulltext_postgres_ts_name']) . "', post_text))");
+ $this->db->sql_query("CREATE INDEX " . POSTS_TABLE . "_" . $this->config['fulltext_postgres_ts_name'] . "_post_text ON " . POSTS_TABLE . " USING gin (to_tsvector ('" . $this->db->sql_escape($this->config['fulltext_postgres_ts_name']) . "', post_text))");
}
- $db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
+ $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
return false;
}
@@ -688,13 +684,9 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
* Drop fulltext index
*
* @return string|bool error string is returned incase of errors otherwise false
- *
- * @access public
*/
- function delete_index($acp_module, $u_action)
+ public function delete_index($acp_module, $u_action)
{
- global $db;
-
// Make sure we can actually use PostgreSQL with fulltext indexes
if ($error = $this->init())
{
@@ -708,25 +700,23 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
if (isset($this->stats['post_subject']))
{
- $db->sql_query('DROP INDEX ' . $this->stats['post_subject']['relname']);
+ $this->db->sql_query('DROP INDEX ' . $this->stats['post_subject']['relname']);
}
if (isset($this->stats['post_text']))
{
- $db->sql_query('DROP INDEX ' . $this->stats['post_text']['relname']);
+ $this->db->sql_query('DROP INDEX ' . $this->stats['post_text']['relname']);
}
- $db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
+ $this->db->sql_query('TRUNCATE TABLE ' . SEARCH_RESULTS_TABLE);
return false;
}
/**
* Returns true if both FULLTEXT indexes exist
- *
- * @access public
*/
- function index_created()
+ public function index_created()
{
if (empty($this->stats))
{
@@ -738,33 +728,25 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
/**
* Returns an associative array containing information about the indexes
- *
- * @access public
*/
- function index_stats()
+ public function index_stats()
{
- global $user;
-
if (empty($this->stats))
{
$this->get_stats();
}
return array(
- $user->lang['FULLTEXT_POSTGRES_TOTAL_POSTS'] => ($this->index_created()) ? $this->stats['total_posts'] : 0,
+ $this->user->lang['FULLTEXT_POSTGRES_TOTAL_POSTS'] => ($this->index_created()) ? $this->stats['total_posts'] : 0,
);
}
/**
* Computes the stats and store them in the $this->stats associative array
- *
- * @access private
*/
- function get_stats()
+ protected function get_stats()
{
- global $db, $config;
-
- if ($db->sql_layer != 'postgres')
+ if ($this->db->sql_layer != 'postgres')
{
$this->stats = array();
return;
@@ -776,74 +758,70 @@ class phpbb_search_fulltext_postgres extends phpbb_search_base
AND pg_catalog.pg_table_is_visible(c1.oid)
AND c1.oid = i.indrelid
AND i.indexrelid = c2.oid";
- $result = $db->sql_query($sql);
+ $result = $this->db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
// deal with older PostgreSQL versions which didn't use Index_type
if (strpos($row['indexdef'], 'to_tsvector') !== false)
{
- if ($row['relname'] == POSTS_TABLE . '_' . $config['fulltext_postgres_ts_name'] . '_post_text' || $row['relname'] == POSTS_TABLE . '_post_text')
+ if ($row['relname'] == POSTS_TABLE . '_' . $this->config['fulltext_postgres_ts_name'] . '_post_text' || $row['relname'] == POSTS_TABLE . '_post_text')
{
$this->stats['post_text'] = $row;
}
- else if ($row['relname'] == POSTS_TABLE . '_' . $config['fulltext_postgres_ts_name'] . '_post_subject' || $row['relname'] == POSTS_TABLE . '_post_subject')
+ else if ($row['relname'] == POSTS_TABLE . '_' . $this->config['fulltext_postgres_ts_name'] . '_post_subject' || $row['relname'] == POSTS_TABLE . '_post_subject')
{
$this->stats['post_subject'] = $row;
}
}
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
- $this->stats['total_posts'] = $config['num_posts'];
+ $this->stats['total_posts'] = $this->config['num_posts'];
}
/**
* Display various options that can be configured for the backend from the acp
*
* @return associative array containing template and config variables
- *
- * @access public
*/
- function acp()
+ public function acp()
{
- global $user, $config, $db;
-
$tpl = '
<dl>
- <dt><label>' . $user->lang['FULLTEXT_POSTGRES_VERSION_CHECK'] . '</label><br /><span>' . $user->lang['FULLTEXT_POSTGRES_VERSION_CHECK_EXPLAIN'] . '</span></dt>
- <dd>' . (($this->tsearch_usable) ? $user->lang['YES'] : $user->lang['NO']) . ' (PostgreSQL ' . $this->version . ')</dd>
+ <dt><label>' . $this->user->lang['FULLTEXT_POSTGRES_VERSION_CHECK'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_POSTGRES_VERSION_CHECK_EXPLAIN'] . '</span></dt>
+ <dd>' . (($this->tsearch_usable) ? $this->user->lang['YES'] : $this->user->lang['NO']) . ' (PostgreSQL ' . $this->version . ')</dd>
</dl>
<dl>
- <dt><label>' . $user->lang['FULLTEXT_POSTGRES_TS_NAME'] . '</label><br /><span>' . $user->lang['FULLTEXT_POSTGRES_TS_NAME_EXPLAIN'] . '</span></dt>
+ <dt><label>' . $this->user->lang['FULLTEXT_POSTGRES_TS_NAME'] . '</label><br /><span>' . $this->user->lang['FULLTEXT_POSTGRES_TS_NAME_EXPLAIN'] . '</span></dt>
<dd><select name="config[fulltext_postgres_ts_name]">';
- if ($db->sql_layer == 'postgres' && $this->tsearch_usable)
+ if ($this->db->sql_layer == 'postgres' && $this->tsearch_usable)
{
$sql = 'SELECT cfgname AS ts_name
FROM pg_ts_config';
- $result = $db->sql_query($sql);
+ $result = $this->db->sql_query($sql);
- while ($row = $db->sql_fetchrow($result))
+ while ($row = $this->db->sql_fetchrow($result))
{
- $tpl .= '<option value="' . $row['ts_name'] . '"' . ($row['ts_name'] === $config['fulltext_postgres_ts_name'] ? ' selected="selected"' : '') . '>' . $row['ts_name'] . '</option>';
+ $tpl .= '<option value="' . $row['ts_name'] . '"' . ($row['ts_name'] === $this->config['fulltext_postgres_ts_name'] ? ' selected="selected"' : '') . '>' . $row['ts_name'] . '</option>';
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
}
else
{
- $tpl .= '<option value="' . $config['fulltext_postgres_ts_name'] . '" selected="selected">' . $config['fulltext_postgres_ts_name'] . '</option>';
+ $tpl .= '<option value="' . $this->config['fulltext_postgres_ts_name'] . '" selected="selected">' . $this->config['fulltext_postgres_ts_name'] . '</option>';
}
$tpl .= '</select></dd>
</dl>
<dl>
- <dt><label for="fulltext_postgres_min_word_len">' . $user->lang['FULLTEXT_POSTGRES_MIN_WORD_LEN'] . ':</label><br /><span>' . $user->lang['FULLTEXT_POSTGRES_MIN_WORD_LEN_EXPLAIN'] . '</span></dt>
- <dd><input id="fulltext_postgres_min_word_len" type="text" size="3" maxlength="3" name="config[fulltext_postgres_min_word_len]" value="' . (int) $config['fulltext_postgres_min_word_len'] . '" /></dd>
+ <dt><label for="fulltext_postgres_min_word_len">' . $this->user->lang['FULLTEXT_POSTGRES_MIN_WORD_LEN'] . ':</label><br /><span>' . $this->user->lang['FULLTEXT_POSTGRES_MIN_WORD_LEN_EXPLAIN'] . '</span></dt>
+ <dd><input id="fulltext_postgres_min_word_len" type="text" size="3" maxlength="3" name="config[fulltext_postgres_min_word_len]" value="' . (int) $this->config['fulltext_postgres_min_word_len'] . '" /></dd>
</dl>
<dl>
- <dt><label for="fulltext_postgres_max_word_len">' . $user->lang['FULLTEXT_POSTGRES_MAX_WORD_LEN'] . ':</label><br /><span>' . $user->lang['FULLTEXT_POSTGRES_MAX_WORD_LEN_EXPLAIN'] . '</span></dt>
- <dd><input id="fulltext_postgres_max_word_len" type="text" size="3" maxlength="3" name="config[fulltext_postgres_max_word_len]" value="' . (int) $config['fulltext_postgres_max_word_len'] . '" /></dd>
+ <dt><label for="fulltext_postgres_max_word_len">' . $this->user->lang['FULLTEXT_POSTGRES_MAX_WORD_LEN'] . ':</label><br /><span>' . $this->user->lang['FULLTEXT_POSTGRES_MAX_WORD_LEN_EXPLAIN'] . '</span></dt>
+ <dd><input id="fulltext_postgres_max_word_len" type="text" size="3" maxlength="3" name="config[fulltext_postgres_max_word_len]" value="' . (int) $this->config['fulltext_postgres_max_word_len'] . '" /></dd>
</dl>
';
diff --git a/phpBB/includes/search/fulltext_sphinx.php b/phpBB/includes/search/fulltext_sphinx.php
new file mode 100644
index 0000000000..0a230f0e98
--- /dev/null
+++ b/phpBB/includes/search/fulltext_sphinx.php
@@ -0,0 +1,817 @@
+<?php
+/**
+*
+* @package search
+* @copyright (c) 2005 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* @ignore
+*/
+define('SPHINX_MAX_MATCHES', 20000);
+define('SPHINX_CONNECT_RETRIES', 3);
+define('SPHINX_CONNECT_WAIT_TIME', 300);
+
+/**
+* fulltext_sphinx
+* Fulltext search based on the sphinx search deamon
+* @package search
+*/
+class phpbb_search_fulltext_sphinx
+{
+ protected $stats = array();
+ protected $split_words = array();
+ protected $id;
+ protected $indexes;
+ protected $sphinx;
+ protected $phpbb_root_path;
+ protected $php_ext;
+ protected $auth;
+ protected $config;
+ protected $db;
+ protected $db_tools;
+ protected $dbtype;
+ protected $user;
+ protected $config_file_data = '';
+ protected $search_query;
+ protected $common_words = array();
+
+ /**
+ * Constructor
+ * Creates a new phpbb_search_fulltext_postgres, which is used as a search backend.
+ *
+ * @param string|bool $error Any error that occurs is passed on through this reference variable otherwise false
+ */
+ public function __construct(&$error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user)
+ {
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $phpEx;
+ $this->config = $config;
+ $this->user = $user;
+ $this->db = $db;
+ $this->auth = $auth;
+
+ if (!class_exists('phpbb_db_tools'))
+ {
+ require($this->phpbb_root_path . 'includes/db/db_tools.' . $this->php_ext);
+ }
+
+ // Initialize phpbb_db_tools object
+ $this->db_tools = new phpbb_db_tools($this->db);
+
+ if(!$this->config['fulltext_sphinx_id'])
+ {
+ set_config('fulltext_sphinx_id', unique_id());
+ }
+ $this->id = $this->config['fulltext_sphinx_id'];
+ $this->indexes = 'index_phpbb_' . $this->id . '_delta;index_phpbb_' . $this->id . '_main';
+
+ if (!class_exists('SphinxClient'))
+ {
+ require($this->phpbb_root_path . 'includes/sphinxapi.' . $this->php_ext);
+ }
+
+ // Initialize sphinx client
+ $this->sphinx = new SphinxClient();
+
+ $this->sphinx->SetServer(($this->config['fulltext_sphinx_host'] ? $this->config['fulltext_sphinx_host'] : 'localhost'), ($this->config['fulltext_sphinx_port'] ? (int) $this->config['fulltext_sphinx_port'] : 9312));
+
+ $error = false;
+ }
+
+ /**
+ * Returns the name of this search backend to be displayed to administrators
+ *
+ * @return string Name
+ */
+ public function get_name()
+ {
+ return 'Sphinx Fulltext';
+ }
+
+ /**
+ * Returns the search_query
+ *
+ * @return string search query
+ */
+ public function get_search_query()
+ {
+ return $this->search_query;
+ }
+
+ /**
+ * Returns false as there is no word_len array
+ *
+ * @return false
+ */
+ public function get_word_length()
+ {
+ return false;
+ }
+
+ /**
+ * Returns the common_words array
+ *
+ * @return array common words that are ignored by search backend
+ */
+ public function get_common_words()
+ {
+ return $this->common_words;
+ }
+
+ /**
+ * Checks permissions and paths, if everything is correct it generates the config file
+ *
+ * @return string|bool Language key of the error/incompatiblity encountered, or false if successful
+ */
+ public function init()
+ {
+ if ($this->db->sql_layer != 'mysql' && $this->db->sql_layer != 'mysql4' && $this->db->sql_layer != 'mysqli' && $this->db->sql_layer != 'postgres')
+ {
+ return $this->user->lang['FULLTEXT_SPHINX_WRONG_DATABASE'];
+ }
+
+ // Move delta to main index each hour
+ set_config('search_gc', 3600);
+
+ return false;
+ }
+
+ /**
+ * Generates content of sphinx.conf
+ *
+ * @return bool True if sphinx.conf content is correctly generated, false otherwise
+ */
+ protected function config_generate()
+ {
+ // Check if Database is supported by Sphinx
+ if ($this->db->sql_layer =='mysql' || $this->db->sql_layer == 'mysql4' || $this->db->sql_layer == 'mysqli')
+ {
+ $this->dbtype = 'mysql';
+ }
+ else if ($this->db->sql_layer == 'postgres')
+ {
+ $this->dbtype = 'pgsql';
+ }
+ else
+ {
+ $this->config_file_data = $this->user->lang('FULLTEXT_SPHINX_WRONG_DATABASE');
+ return false;
+ }
+
+ // Check if directory paths have been filled
+ if (!$this->config['fulltext_sphinx_data_path'])
+ {
+ $this->config_file_data = $this->user->lang('FULLTEXT_SPHINX_NO_CONFIG_DATA');
+ return false;
+ }
+
+ include($this->phpbb_root_path . 'config.' . $this->php_ext);
+
+ /* Now that we're sure everything was entered correctly,
+ generate a config for the index. We use a config value
+ fulltext_sphinx_id for this, as it should be unique. */
+ $config_object = new phpbb_search_sphinx_config($this->config_file_data);
+ $config_data = array(
+ 'source source_phpbb_' . $this->id . '_main' => array(
+ array('type', $this->dbtype),
+ // This config value sql_host needs to be changed incase sphinx and sql are on different servers
+ array('sql_host', $dbhost),
+ array('sql_user', $dbuser),
+ array('sql_pass', $dbpasswd),
+ array('sql_db', $dbname),
+ array('sql_port', $dbport),
+ array('sql_query_pre', 'SET NAMES \'utf8\''),
+ array('sql_query_pre', 'UPDATE ' . SPHINX_TABLE . ' SET max_doc_id = (SELECT MAX(post_id) FROM ' . POSTS_TABLE . ') WHERE counter_id = 1'),
+ array('sql_query_range', 'SELECT MIN(post_id), MAX(post_id) FROM ' . POSTS_TABLE . ''),
+ array('sql_range_step', '5000'),
+ array('sql_query', 'SELECT
+ p.post_id AS id,
+ p.forum_id,
+ p.topic_id,
+ p.poster_id,
+ CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post,
+ p.post_time,
+ p.post_subject,
+ p.post_subject as title,
+ p.post_text as data,
+ t.topic_last_post_time,
+ 0 as deleted
+ FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t
+ WHERE
+ p.topic_id = t.topic_id
+ AND p.post_id >= $start AND p.post_id <= $end'),
+ array('sql_query_post', ''),
+ array('sql_query_post_index', 'UPDATE ' . SPHINX_TABLE . ' SET max_doc_id = $maxid WHERE counter_id = 1'),
+ array('sql_query_info', 'SELECT * FROM ' . POSTS_TABLE . ' WHERE post_id = $id'),
+ array('sql_attr_uint', 'forum_id'),
+ array('sql_attr_uint', 'topic_id'),
+ array('sql_attr_uint', 'poster_id'),
+ array('sql_attr_bool', 'topic_first_post'),
+ array('sql_attr_bool', 'deleted'),
+ array('sql_attr_timestamp' , 'post_time'),
+ array('sql_attr_timestamp' , 'topic_last_post_time'),
+ array('sql_attr_str2ordinal', 'post_subject'),
+ ),
+ 'source source_phpbb_' . $this->id . '_delta : source_phpbb_' . $this->id . '_main' => array(
+ array('sql_query_pre', ''),
+ array('sql_query_range', ''),
+ array('sql_range_step', ''),
+ array('sql_query', 'SELECT
+ p.post_id AS id,
+ p.forum_id,
+ p.topic_id,
+ p.poster_id,
+ CASE WHEN p.post_id = t.topic_first_post_id THEN 1 ELSE 0 END as topic_first_post,
+ p.post_time,
+ p.post_subject,
+ p.post_subject as title,
+ p.post_text as data,
+ t.topic_last_post_time,
+ 0 as deleted
+ FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t
+ WHERE
+ p.topic_id = t.topic_id
+ AND p.post_id >= ( SELECT max_doc_id FROM ' . SPHINX_TABLE . ' WHERE counter_id=1 )'),
+ ),
+ 'index index_phpbb_' . $this->id . '_main' => array(
+ array('path', $this->config['fulltext_sphinx_data_path'] . 'index_phpbb_' . $this->id . '_main'),
+ array('source', 'source_phpbb_' . $this->id . '_main'),
+ array('docinfo', 'extern'),
+ array('morphology', 'none'),
+ array('stopwords', ''),
+ array('min_word_len', '2'),
+ array('charset_type', 'utf-8'),
+ array('charset_table', 'U+FF10..U+FF19->0..9, 0..9, U+FF41..U+FF5A->a..z, U+FF21..U+FF3A->a..z, A..Z->a..z, a..z, U+0149, U+017F, U+0138, U+00DF, U+00FF, U+00C0..U+00D6->U+00E0..U+00F6, U+00E0..U+00F6, U+00D8..U+00DE->U+00F8..U+00FE, U+00F8..U+00FE, U+0100->U+0101, U+0101, U+0102->U+0103, U+0103, U+0104->U+0105, U+0105, U+0106->U+0107, U+0107, U+0108->U+0109, U+0109, U+010A->U+010B, U+010B, U+010C->U+010D, U+010D, U+010E->U+010F, U+010F, U+0110->U+0111, U+0111, U+0112->U+0113, U+0113, U+0114->U+0115, U+0115, U+0116->U+0117, U+0117, U+0118->U+0119, U+0119, U+011A->U+011B, U+011B, U+011C->U+011D, U+011D, U+011E->U+011F, U+011F, U+0130->U+0131, U+0131, U+0132->U+0133, U+0133, U+0134->U+0135, U+0135, U+0136->U+0137, U+0137, U+0139->U+013A, U+013A, U+013B->U+013C, U+013C, U+013D->U+013E, U+013E, U+013F->U+0140, U+0140, U+0141->U+0142, U+0142, U+0143->U+0144, U+0144, U+0145->U+0146, U+0146, U+0147->U+0148, U+0148, U+014A->U+014B, U+014B, U+014C->U+014D, U+014D, U+014E->U+014F, U+014F, U+0150->U+0151, U+0151, U+0152->U+0153, U+0153, U+0154->U+0155, U+0155, U+0156->U+0157, U+0157, U+0158->U+0159, U+0159, U+015A->U+015B, U+015B, U+015C->U+015D, U+015D, U+015E->U+015F, U+015F, U+0160->U+0161, U+0161, U+0162->U+0163, U+0163, U+0164->U+0165, U+0165, U+0166->U+0167, U+0167, U+0168->U+0169, U+0169, U+016A->U+016B, U+016B, U+016C->U+016D, U+016D, U+016E->U+016F, U+016F, U+0170->U+0171, U+0171, U+0172->U+0173, U+0173, U+0174->U+0175, U+0175, U+0176->U+0177, U+0177, U+0178->U+00FF, U+00FF, U+0179->U+017A, U+017A, U+017B->U+017C, U+017C, U+017D->U+017E, U+017E, U+0410..U+042F->U+0430..U+044F, U+0430..U+044F, U+4E00..U+9FFF'),
+ array('min_prefix_len', '0'),
+ array('min_infix_len', '0'),
+ ),
+ 'index index_phpbb_' . $this->id . '_delta : index_phpbb_' . $this->id . '_main' => array(
+ array('path', $this->config['fulltext_sphinx_data_path'] . 'index_phpbb_' . $this->id . '_delta'),
+ array('source', 'source_phpbb_' . $this->id . '_delta'),
+ ),
+ 'indexer' => array(
+ array('mem_limit', $this->config['fulltext_sphinx_indexer_mem_limit'] . 'M'),
+ ),
+ 'searchd' => array(
+ array('compat_sphinxql_magics' , '0'),
+ array('listen' , ($this->config['fulltext_sphinx_host'] ? $this->config['fulltext_sphinx_host'] : 'localhost') . ':' . ($this->config['fulltext_sphinx_port'] ? $this->config['fulltext_sphinx_port'] : '9312')),
+ array('log', $this->config['fulltext_sphinx_data_path'] . 'log/searchd.log'),
+ array('query_log', $this->config['fulltext_sphinx_data_path'] . 'log/sphinx-query.log'),
+ array('read_timeout', '5'),
+ array('max_children', '30'),
+ array('pid_file', $this->config['fulltext_sphinx_data_path'] . 'searchd.pid'),
+ array('max_matches', (string) SPHINX_MAX_MATCHES),
+ array('binlog_path', $this->config['fulltext_sphinx_data_path']),
+ ),
+ );
+
+ $non_unique = array('sql_query_pre' => true, 'sql_attr_uint' => true, 'sql_attr_timestamp' => true, 'sql_attr_str2ordinal' => true, 'sql_attr_bool' => true);
+ $delete = array('sql_group_column' => true, 'sql_date_column' => true, 'sql_str2ordinal_column' => true);
+ foreach ($config_data as $section_name => $section_data)
+ {
+ $section = $config_object->get_section_by_name($section_name);
+ if (!$section)
+ {
+ $section = $config_object->add_section($section_name);
+ }
+
+ foreach ($delete as $key => $void)
+ {
+ $section->delete_variables_by_name($key);
+ }
+
+ foreach ($non_unique as $key => $void)
+ {
+ $section->delete_variables_by_name($key);
+ }
+
+ foreach ($section_data as $entry)
+ {
+ $key = $entry[0];
+ $value = $entry[1];
+
+ if (!isset($non_unique[$key]))
+ {
+ $variable = $section->get_variable_by_name($key);
+ if (!$variable)
+ {
+ $variable = $section->create_variable($key, $value);
+ }
+ else
+ {
+ $variable->set_value($value);
+ }
+ }
+ else
+ {
+ $variable = $section->create_variable($key, $value);
+ }
+ }
+ }
+ $this->config_file_data = $config_object->get_data();
+
+ return true;
+ }
+
+ /**
+ * Splits keywords entered by a user into an array of words stored in $this->split_words
+ * Stores the tidied search query in $this->search_query
+ *
+ * @param string $keywords Contains the keyword as entered by the user
+ * @param string $terms is either 'all' or 'any'
+ * @return false if no valid keywords were found and otherwise true
+ */
+ public function split_keywords(&$keywords, $terms)
+ {
+ if ($terms == 'all')
+ {
+ $match = array('#\sand\s#i', '#\sor\s#i', '#\snot\s#i', '#\+#', '#-#', '#\|#', '#@#');
+ $replace = array(' & ', ' | ', ' - ', ' +', ' -', ' |', '');
+
+ $replacements = 0;
+ $keywords = preg_replace($match, $replace, $keywords);
+ $this->sphinx->SetMatchMode(SPH_MATCH_EXTENDED);
+ }
+ else
+ {
+ $this->sphinx->SetMatchMode(SPH_MATCH_ANY);
+ }
+
+ // Keep quotes and new lines
+ $keywords = str_replace(array('&quot;', "\n"), array('"', ' '), trim($keywords));
+
+ if (strlen($keywords) > 0)
+ {
+ $this->search_query = str_replace('"', '&quot;', $keywords);
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Performs a search on keywords depending on display specific params. You have to run split_keywords() first.
+ *
+ * @param string $type contains either posts or topics depending on what should be searched for
+ * @param string $fields contains either titleonly (topic titles should be searched), msgonly (only message bodies should be searched), firstpost (only subject and body of the first post should be searched) or all (all post bodies and subjects should be searched)
+ * @param string $terms is either 'all' (use query as entered, words without prefix should default to "have to be in field") or 'any' (ignore search query parts and just return all posts that contain any of the specified words)
+ * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query
+ * @param string $sort_key is the key of $sort_by_sql for the selected sorting
+ * @param string $sort_dir is either a or d representing ASC and DESC
+ * @param string $sort_days specifies the maximum amount of days a post may be old
+ * @param array $ex_fid_ary specifies an array of forum ids which should not be searched
+ * @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts
+ * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched
+ * @param array $author_ary an array of author ids if the author should be ignored during the search the array is empty
+ * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match
+ * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered
+ * @param int $start indicates the first index of the page
+ * @param int $per_page number of ids each page is supposed to contain
+ * @return boolean|int total number of results
+ */
+ public function keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
+ {
+ // No keywords? No posts.
+ if (!strlen($this->search_query) && !sizeof($author_ary))
+ {
+ return false;
+ }
+
+ $id_ary = array();
+
+ $join_topic = ($type != 'posts');
+
+ // Sorting
+
+ if ($type == 'topics')
+ {
+ switch ($sort_key)
+ {
+ case 'a':
+ $this->sphinx->SetGroupBy('topic_id', SPH_GROUPBY_ATTR, 'poster_id ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'));
+ break;
+
+ case 'f':
+ $this->sphinx->SetGroupBy('topic_id', SPH_GROUPBY_ATTR, 'forum_id ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'));
+ break;
+
+ case 'i':
+
+ case 's':
+ $this->sphinx->SetGroupBy('topic_id', SPH_GROUPBY_ATTR, 'post_subject ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'));
+ break;
+
+ case 't':
+
+ default:
+ $this->sphinx->SetGroupBy('topic_id', SPH_GROUPBY_ATTR, 'topic_last_post_time ' . (($sort_dir == 'a') ? 'ASC' : 'DESC'));
+ break;
+ }
+ }
+ else
+ {
+ switch ($sort_key)
+ {
+ case 'a':
+ $this->sphinx->SetSortMode(($sort_dir == 'a') ? SPH_SORT_ATTR_ASC : SPH_SORT_ATTR_DESC, 'poster_id');
+ break;
+
+ case 'f':
+ $this->sphinx->SetSortMode(($sort_dir == 'a') ? SPH_SORT_ATTR_ASC : SPH_SORT_ATTR_DESC, 'forum_id');
+ break;
+
+ case 'i':
+
+ case 's':
+ $this->sphinx->SetSortMode(($sort_dir == 'a') ? SPH_SORT_ATTR_ASC : SPH_SORT_ATTR_DESC, 'post_subject');
+ break;
+
+ case 't':
+
+ default:
+ $this->sphinx->SetSortMode(($sort_dir == 'a') ? SPH_SORT_ATTR_ASC : SPH_SORT_ATTR_DESC, 'post_time');
+ break;
+ }
+ }
+
+ // Most narrow filters first
+ if ($topic_id)
+ {
+ $this->sphinx->SetFilter('topic_id', array($topic_id));
+ }
+
+ $search_query_prefix = '';
+
+ switch ($fields)
+ {
+ case 'titleonly':
+ // Only search the title
+ if ($terms == 'all')
+ {
+ $search_query_prefix = '@title ';
+ }
+ // Weight for the title
+ $this->sphinx->SetFieldWeights(array("title" => 5, "data" => 1));
+ // 1 is first_post, 0 is not first post
+ $this->sphinx->SetFilter('topic_first_post', array(1));
+ break;
+
+ case 'msgonly':
+ // Only search the body
+ if ($terms == 'all')
+ {
+ $search_query_prefix = '@data ';
+ }
+ // Weight for the body
+ $this->sphinx->SetFieldWeights(array("title" => 1, "data" => 5));
+ break;
+
+ case 'firstpost':
+ // More relative weight for the title, also search the body
+ $this->sphinx->SetFieldWeights(array("title" => 5, "data" => 1));
+ // 1 is first_post, 0 is not first post
+ $this->sphinx->SetFilter('topic_first_post', array(1));
+ break;
+
+ default:
+ // More relative weight for the title, also search the body
+ $this->sphinx->SetFieldWeights(array("title" => 5, "data" => 1));
+ break;
+ }
+
+ if (sizeof($author_ary))
+ {
+ $this->sphinx->SetFilter('poster_id', $author_ary);
+ }
+
+ if (sizeof($ex_fid_ary))
+ {
+ // All forums that a user is allowed to access
+ $fid_ary = array_unique(array_intersect(array_keys($this->auth->acl_getf('f_read', true)), array_keys($this->auth->acl_getf('f_search', true))));
+ // All forums that the user wants to and can search in
+ $search_forums = array_diff($fid_ary, $ex_fid_ary);
+
+ if (sizeof($search_forums))
+ {
+ $this->sphinx->SetFilter('forum_id', $search_forums);
+ }
+ }
+
+ $this->sphinx->SetFilter('deleted', array(0));
+
+ $this->sphinx->SetLimits($start, (int) $per_page, SPHINX_MAX_MATCHES);
+ $result = $this->sphinx->Query($search_query_prefix . str_replace('&quot;', '"', $this->search_query), $this->indexes);
+
+ // Could be connection to localhost:9312 failed (errno=111,
+ // msg=Connection refused) during rotate, retry if so
+ $retries = SPHINX_CONNECT_RETRIES;
+ while (!$result && (strpos($this->sphinx->GetLastError(), "errno=111,") !== false) && $retries--)
+ {
+ usleep(SPHINX_CONNECT_WAIT_TIME);
+ $result = $this->sphinx->Query($search_query_prefix . str_replace('&quot;', '"', $this->search_query), $this->indexes);
+ }
+
+ if ($this->sphinx->GetLastError())
+ {
+ add_log('critical', 'LOG_SPHINX_ERROR', $this->sphinx->GetLastError());
+ if ($this->auth->acl_get('a_'))
+ {
+ trigger_error($this->user->lang('SPHINX_SEARCH_FAILED', $this->sphinx->GetLastError()));
+ }
+ else
+ {
+ trigger_error($this->user->lang('SPHINX_SEARCH_FAILED_LOG'));
+ }
+ }
+
+ $id_ary = array();
+ if (isset($result['matches']))
+ {
+ if ($type == 'posts')
+ {
+ $id_ary = array_keys($result['matches']);
+ }
+ else
+ {
+ foreach ($result['matches'] as $key => $value)
+ {
+ $id_ary[] = $value['attrs']['topic_id'];
+ }
+ }
+ }
+ else
+ {
+ return false;
+ }
+
+ $result_count = $result['total_found'];
+
+ $id_ary = array_slice($id_ary, 0, (int) $per_page);
+
+ return $result_count;
+ }
+
+ /**
+ * Performs a search on an author's posts without caring about message contents. Depends on display specific params
+ *
+ * @param string $type contains either posts or topics depending on what should be searched for
+ * @param boolean $firstpost_only if true, only topic starting posts will be considered
+ * @param array $sort_by_sql contains SQL code for the ORDER BY part of a query
+ * @param string $sort_key is the key of $sort_by_sql for the selected sorting
+ * @param string $sort_dir is either a or d representing ASC and DESC
+ * @param string $sort_days specifies the maximum amount of days a post may be old
+ * @param array $ex_fid_ary specifies an array of forum ids which should not be searched
+ * @param array $m_approve_fid_ary specifies an array of forum ids in which the searcher is allowed to view unapproved posts
+ * @param int $topic_id is set to 0 or a topic id, if it is not 0 then only posts in this topic should be searched
+ * @param array $author_ary an array of author ids
+ * @param string $author_name specifies the author match, when ANONYMOUS is also a search-match
+ * @param array &$id_ary passed by reference, to be filled with ids for the page specified by $start and $per_page, should be ordered
+ * @param int $start indicates the first index of the page
+ * @param int $per_page number of ids each page is supposed to contain
+ * @return boolean|int total number of results
+ */
+ public function author_search($type, $firstpost_only, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, &$id_ary, $start, $per_page)
+ {
+ $this->search_query = '';
+
+ $this->sphinx->SetMatchMode(SPH_MATCH_FULLSCAN);
+ $fields = ($firstpost_only) ? 'firstpost' : 'all';
+ $terms = 'all';
+ return $this->keyword_search($type, $fields, $terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_ary, $author_name, $id_ary, $start, $per_page);
+ }
+
+ /**
+ * Updates wordlist and wordmatch tables when a message is posted or changed
+ *
+ * @param string $mode Contains the post mode: edit, post, reply, quote
+ * @param int $post_id The id of the post which is modified/created
+ * @param string &$message New or updated post content
+ * @param string &$subject New or updated post subject
+ * @param int $poster_id Post author's user id
+ * @param int $forum_id The id of the forum in which the post is located
+ */
+ public function index($mode, $post_id, &$message, &$subject, $poster_id, $forum_id)
+ {
+ if ($mode == 'edit')
+ {
+ $this->sphinx->UpdateAttributes($this->indexes, array('forum_id', 'poster_id'), array((int)$post_id => array((int)$forum_id, (int)$poster_id)));
+ }
+ else if ($mode != 'post' && $post_id)
+ {
+ // Update topic_last_post_time for full topic
+ $sql_array = array(
+ 'SELECT' => 'p1.post_id',
+ 'FROM' => array(
+ POSTS_TABLE => 'p1',
+ ),
+ 'LEFT_JOIN' => array(array(
+ 'FROM' => array(
+ POSTS_TABLE => 'p2'
+ ),
+ 'ON' => 'p1.topic_id = p2.topic_id',
+ )),
+ );
+
+ $sql = $this->db->sql_build_query('SELECT', $sql_array);
+ $result = $this->db->sql_query($sql);
+
+ $post_updates = array();
+ $post_time = time();
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $post_updates[(int)$row['post_id']] = array($post_time);
+ }
+ $this->db->sql_freeresult($result);
+
+ if (sizeof($post_updates))
+ {
+ $this->sphinx->UpdateAttributes($this->indexes, array('topic_last_post_time'), $post_updates);
+ }
+ }
+ }
+
+ /**
+ * Delete a post from the index after it was deleted
+ */
+ public function index_remove($post_ids, $author_ids, $forum_ids)
+ {
+ $values = array();
+ foreach ($post_ids as $post_id)
+ {
+ $values[$post_id] = array(1);
+ }
+
+ $this->sphinx->UpdateAttributes($this->indexes, array('deleted'), $values);
+ }
+
+ /**
+ * Nothing needs to be destroyed
+ */
+ public function tidy($create = false)
+ {
+ set_config('search_last_gc', time(), true);
+ }
+
+ /**
+ * Create sphinx table
+ *
+ * @return string|bool error string is returned incase of errors otherwise false
+ */
+ public function create_index($acp_module, $u_action)
+ {
+ if (!$this->index_created())
+ {
+ $table_data = array(
+ 'COLUMNS' => array(
+ 'counter_id' => array('UINT', 0),
+ 'max_doc_id' => array('UINT', 0),
+ ),
+ 'PRIMARY_KEY' => 'counter_id',
+ );
+ $this->db_tools->sql_create_table(SPHINX_TABLE, $table_data);
+
+ $sql = 'TRUNCATE TABLE ' . SPHINX_TABLE;
+ $this->db->sql_query($sql);
+
+ $data = array(
+ 'counter_id' => '1',
+ 'max_doc_id' => '0',
+ );
+ $sql = 'INSERT INTO ' . SPHINX_TABLE . ' ' . $this->db->sql_build_array('INSERT', $data);
+ $this->db->sql_query($sql);
+ }
+
+ return false;
+ }
+
+ /**
+ * Drop sphinx table
+ *
+ * @return string|bool error string is returned incase of errors otherwise false
+ */
+ public function delete_index($acp_module, $u_action)
+ {
+ if (!$this->index_created())
+ {
+ return false;
+ }
+
+ $this->db_tools->sql_table_drop(SPHINX_TABLE);
+
+ return false;
+ }
+
+ /**
+ * Returns true if the sphinx table was created
+ *
+ * @return bool true if sphinx table was created
+ */
+ public function index_created($allow_new_files = true)
+ {
+ $created = false;
+
+ if ($this->db_tools->sql_table_exists(SPHINX_TABLE))
+ {
+ $created = true;
+ }
+
+ return $created;
+ }
+
+ /**
+ * Returns an associative array containing information about the indexes
+ *
+ * @return string|bool Language string of error false otherwise
+ */
+ public function index_stats()
+ {
+ if (empty($this->stats))
+ {
+ $this->get_stats();
+ }
+
+ return array(
+ $this->user->lang['FULLTEXT_SPHINX_MAIN_POSTS'] => ($this->index_created()) ? $this->stats['main_posts'] : 0,
+ $this->user->lang['FULLTEXT_SPHINX_DELTA_POSTS'] => ($this->index_created()) ? $this->stats['total_posts'] - $this->stats['main_posts'] : 0,
+ $this->user->lang['FULLTEXT_MYSQL_TOTAL_POSTS'] => ($this->index_created()) ? $this->stats['total_posts'] : 0,
+ );
+ }
+
+ /**
+ * Collects stats that can be displayed on the index maintenance page
+ */
+ protected function get_stats()
+ {
+ if ($this->index_created())
+ {
+ $sql = 'SELECT COUNT(post_id) as total_posts
+ FROM ' . POSTS_TABLE;
+ $result = $this->db->sql_query($sql);
+ $this->stats['total_posts'] = (int) $this->db->sql_fetchfield('total_posts');
+ $this->db->sql_freeresult($result);
+
+ $sql = 'SELECT COUNT(p.post_id) as main_posts
+ FROM ' . POSTS_TABLE . ' p, ' . SPHINX_TABLE . ' m
+ WHERE p.post_id <= m.max_doc_id
+ AND m.counter_id = 1';
+ $result = $this->db->sql_query($sql);
+ $this->stats['main_posts'] = (int) $this->db->sql_fetchfield('main_posts');
+ $this->db->sql_freeresult($result);
+ }
+ }
+
+ /**
+ * Returns a list of options for the ACP to display
+ *
+ * @return associative array containing template and config variables
+ */
+ public function acp()
+ {
+ $config_vars = array(
+ 'fulltext_sphinx_data_path' => 'string',
+ 'fulltext_sphinx_host' => 'string',
+ 'fulltext_sphinx_port' => 'string',
+ 'fulltext_sphinx_indexer_mem_limit' => 'int',
+ );
+
+ $tpl = '
+ <span class="error">' . $this->user->lang['FULLTEXT_SPHINX_CONFIGURE']. '</span>
+ <dl>
+ <dt><label for="fulltext_sphinx_data_path">' . $this->user->lang['FULLTEXT_SPHINX_DATA_PATH'] . ':</label><br /><span>' . $this->user->lang['FULLTEXT_SPHINX_DATA_PATH_EXPLAIN'] . '</span></dt>
+ <dd><input id="fulltext_sphinx_data_path" type="text" size="40" maxlength="255" name="config[fulltext_sphinx_data_path]" value="' . $this->config['fulltext_sphinx_data_path'] . '" /></dd>
+ </dl>
+ <dl>
+ <dt><label for="fulltext_sphinx_host">' . $this->user->lang['FULLTEXT_SPHINX_HOST'] . ':</label><br /><span>' . $this->user->lang['FULLTEXT_SPHINX_HOST_EXPLAIN'] . '</span></dt>
+ <dd><input id="fulltext_sphinx_host" type="text" size="40" maxlength="255" name="config[fulltext_sphinx_host]" value="' . $this->config['fulltext_sphinx_host'] . '" /></dd>
+ </dl>
+ <dl>
+ <dt><label for="fulltext_sphinx_port">' . $this->user->lang['FULLTEXT_SPHINX_PORT'] . ':</label><br /><span>' . $this->user->lang['FULLTEXT_SPHINX_PORT_EXPLAIN'] . '</span></dt>
+ <dd><input id="fulltext_sphinx_port" type="text" size="4" maxlength="10" name="config[fulltext_sphinx_port]" value="' . $this->config['fulltext_sphinx_port'] . '" /></dd>
+ </dl>
+ <dl>
+ <dt><label for="fulltext_sphinx_indexer_mem_limit">' . $this->user->lang['FULLTEXT_SPHINX_INDEXER_MEM_LIMIT'] . ':</label><br /><span>' . $this->user->lang['FULLTEXT_SPHINX_INDEXER_MEM_LIMIT_EXPLAIN'] . '</span></dt>
+ <dd><input id="fulltext_sphinx_indexer_mem_limit" type="text" size="4" maxlength="10" name="config[fulltext_sphinx_indexer_mem_limit]" value="' . $this->config['fulltext_sphinx_indexer_mem_limit'] . '" />' . $this->user->lang['MIB'] . '</dd>
+ </dl>
+ <dl>
+ <dt><label for="fulltext_sphinx_config_file">' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE'] . ':</label><br /><span>' . $this->user->lang['FULLTEXT_SPHINX_CONFIG_FILE_EXPLAIN'] . '</dt>
+ <dd>' . (($this->config_generate()) ? '<textarea readonly="readonly" rows="6">' . $this->config_file_data . '</textarea>' : $this->config_file_data) . '</dd>
+ <dl>
+ ';
+
+ // These are fields required in the config table
+ return array(
+ 'tpl' => $tpl,
+ 'config' => $config_vars
+ );
+ }
+}
diff --git a/phpBB/includes/search/sphinx/config.php b/phpBB/includes/search/sphinx/config.php
new file mode 100644
index 0000000000..f1864f0c8c
--- /dev/null
+++ b/phpBB/includes/search/sphinx/config.php
@@ -0,0 +1,288 @@
+<?php
+/**
+*
+* @package search
+* @copyright (c) 2005 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* phpbb_search_sphinx_config
+* An object representing the sphinx configuration
+* Can read it from file and write it back out after modification
+* @package search
+*/
+class phpbb_search_sphinx_config
+{
+ private $sections = array();
+
+ /**
+ * Constructor which optionally loads data from a variable
+ *
+ * @param string $config_data Variable containing the sphinx configuration data
+ *
+ * @access public
+ */
+ function __construct($config_data)
+ {
+ if ($config_data != '')
+ {
+ $this->read($config_data);
+ }
+ }
+
+ /**
+ * Get a section object by its name
+ *
+ * @param string $name The name of the section that shall be returned
+ * @return phpbb_search_sphinx_config_section The section object or null if none was found
+ *
+ * @access public
+ */
+ function get_section_by_name($name)
+ {
+ for ($i = 0, $size = sizeof($this->sections); $i < $size; $i++)
+ {
+ // Make sure this is really a section object and not a comment
+ if (($this->sections[$i] instanceof phpbb_search_sphinx_config_section) && $this->sections[$i]->get_name() == $name)
+ {
+ return $this->sections[$i];
+ }
+ }
+ }
+
+ /**
+ * Appends a new empty section to the end of the config
+ *
+ * @param string $name The name for the new section
+ * @return phpbb_search_sphinx_config_section The newly created section object
+ *
+ * @access public
+ */
+ function add_section($name)
+ {
+ $this->sections[] = new phpbb_search_sphinx_config_section($name, '');
+ return $this->sections[sizeof($this->sections) - 1];
+ }
+
+ /**
+ * Reads the config file data
+ *
+ * @param string $config_data The config file data
+ *
+ * @access private
+ */
+ function read($config_data)
+ {
+ $this->sections = array();
+
+ $section = null;
+ $found_opening_bracket = false;
+ $in_value = false;
+
+ foreach ($config_data as $i => $line)
+ {
+ // If the value of a variable continues to the next line because the line
+ // break was escaped then we don't trim leading space but treat it as a part of the value
+ if ($in_value)
+ {
+ $line = rtrim($line);
+ }
+ else
+ {
+ $line = trim($line);
+ }
+
+ // If we're not inside a section look for one
+ if (!$section)
+ {
+ // Add empty lines and comments as comment objects to the section list
+ // that way they're not deleted when reassembling the file from the sections
+ if (!$line || $line[0] == '#')
+ {
+ $this->sections[] = new phpbb_search_sphinx_config_comment($config_file[$i]);
+ continue;
+ }
+ else
+ {
+ // Otherwise we scan the line reading the section name until we find
+ // an opening curly bracket or a comment
+ $section_name = '';
+ $section_name_comment = '';
+ $found_opening_bracket = false;
+ for ($j = 0, $length = strlen($line); $j < $length; $j++)
+ {
+ if ($line[$j] == '#')
+ {
+ $section_name_comment = substr($line, $j);
+ break;
+ }
+
+ if ($found_opening_bracket)
+ {
+ continue;
+ }
+
+ if ($line[$j] == '{')
+ {
+ $found_opening_bracket = true;
+ continue;
+ }
+
+ $section_name .= $line[$j];
+ }
+
+ // And then we create the new section object
+ $section_name = trim($section_name);
+ $section = new phpbb_search_sphinx_config_section($section_name, $section_name_comment);
+ }
+ }
+ else
+ {
+ // If we're looking for variables inside a section
+ $skip_first = false;
+
+ // If we're not in a value continuing over the line feed
+ if (!$in_value)
+ {
+ // Then add empty lines and comments as comment objects to the variable list
+ // of this section so they're not deleted on reassembly
+ if (!$line || $line[0] == '#')
+ {
+ $section->add_variable(new phpbb_search_sphinx_config_comment($config_file[$i]));
+ continue;
+ }
+
+ // As long as we haven't yet actually found an opening bracket for this section
+ // we treat everything as comments so it's not deleted either
+ if (!$found_opening_bracket)
+ {
+ if ($line[0] == '{')
+ {
+ $skip_first = true;
+ $line = substr($line, 1);
+ $found_opening_bracket = true;
+ }
+ else
+ {
+ $section->add_variable(new phpbb_search_sphinx_config_comment($config_file[$i]));
+ continue;
+ }
+ }
+ }
+
+ // If we did not find a comment in this line or still add to the previous
+ // line's value ...
+ if ($line || $in_value)
+ {
+ if (!$in_value)
+ {
+ $name = '';
+ $value = '';
+ $comment = '';
+ $found_assignment = false;
+ }
+ $in_value = false;
+ $end_section = false;
+
+ /* ... then we should prase this line char by char:
+ - first there's the variable name
+ - then an equal sign
+ - the variable value
+ - possibly a backslash before the linefeed in this case we need to continue
+ parsing the value in the next line
+ - a # indicating that the rest of the line is a comment
+ - a closing curly bracket indicating the end of this section*/
+ for ($j = 0, $length = strlen($line); $j < $length; $j++)
+ {
+ if ($line[$j] == '#')
+ {
+ $comment = substr($line, $j);
+ break;
+ }
+ else if ($line[$j] == '}')
+ {
+ $comment = substr($line, $j + 1);
+ $end_section = true;
+ break;
+ }
+ else if (!$found_assignment)
+ {
+ if ($line[$j] == '=')
+ {
+ $found_assignment = true;
+ }
+ else
+ {
+ $name .= $line[$j];
+ }
+ }
+ else
+ {
+ if ($line[$j] == '\\' && $j == $length - 1)
+ {
+ $value .= "\n";
+ $in_value = true;
+ // Go to the next line and keep processing the value in there
+ continue 2;
+ }
+ $value .= $line[$j];
+ }
+ }
+
+ // If a name and an equal sign were found then we have append a
+ // new variable object to the section
+ if ($name && $found_assignment)
+ {
+ $section->add_variable(new phpbb_search_sphinx_config_variable(trim($name), trim($value), ($end_section) ? '' : $comment));
+ continue;
+ }
+
+ /* If we found a closing curly bracket this section has been completed
+ and we can append it to the section list and continue with looking for
+ the next section */
+ if ($end_section)
+ {
+ $section->set_end_comment($comment);
+ $this->sections[] = $section;
+ $section = null;
+ continue;
+ }
+ }
+
+ // If we did not find anything meaningful up to here, then just treat it
+ // as a comment
+ $comment = ($skip_first) ? "\t" . substr(ltrim($config_file[$i]), 1) : $config_file[$i];
+ $section->add_variable(new phpbb_search_sphinx_config_comment($comment));
+ }
+ }
+
+ }
+
+ /**
+ * Returns the config data
+ *
+ * @return string $data The config data that is generated
+ *
+ * @access public
+ */
+ function get_data()
+ {
+ $data = "";
+ foreach ($this->sections as $section)
+ {
+ $data .= $section->to_string();
+ }
+
+ return $data;
+ }
+}
diff --git a/phpBB/includes/search/sphinx/config_comment.php b/phpBB/includes/search/sphinx/config_comment.php
new file mode 100644
index 0000000000..7f695dbf0c
--- /dev/null
+++ b/phpBB/includes/search/sphinx/config_comment.php
@@ -0,0 +1,49 @@
+<?php
+/**
+*
+* @package search
+* @copyright (c) 2005 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* phpbb_search_sphinx_config_comment
+* Represents a comment inside the sphinx configuration
+*/
+class phpbb_search_sphinx_config_comment
+{
+ private $exact_string;
+
+ /**
+ * Create a new comment
+ *
+ * @param string $exact_string The content of the comment including newlines, leading whitespace, etc.
+ *
+ * @access public
+ */
+ function __construct($exact_string)
+ {
+ $this->exact_string = $exact_string;
+ }
+
+ /**
+ * Simply returns the comment as it was created
+ *
+ * @return string The exact string that was specified in the constructor
+ *
+ * @access public
+ */
+ function to_string()
+ {
+ return $this->exact_string;
+ }
+}
diff --git a/phpBB/includes/search/sphinx/config_section.php b/phpBB/includes/search/sphinx/config_section.php
new file mode 100644
index 0000000000..79c9c8563d
--- /dev/null
+++ b/phpBB/includes/search/sphinx/config_section.php
@@ -0,0 +1,162 @@
+<?php
+/**
+*
+* @package search
+* @copyright (c) 2005 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* phpbb_search_sphinx_config_section
+* Represents a single section inside the sphinx configuration
+*/
+class phpbb_search_sphinx_config_section
+{
+ private $name;
+ private $comment;
+ private $end_comment;
+ private $variables = array();
+
+ /**
+ * Construct a new section
+ *
+ * @param string $name Name of the section
+ * @param string $comment Comment that should be appended after the name in the
+ * textual format.
+ *
+ * @access public
+ */
+ function __construct($name, $comment)
+ {
+ $this->name = $name;
+ $this->comment = $comment;
+ $this->end_comment = '';
+ }
+
+ /**
+ * Add a variable object to the list of variables in this section
+ *
+ * @param phpbb_search_sphinx_config_variable $variable The variable object
+ *
+ * @access public
+ */
+ function add_variable($variable)
+ {
+ $this->variables[] = $variable;
+ }
+
+ /**
+ * Adds a comment after the closing bracket in the textual representation
+ *
+ * @param string $end_comment
+ *
+ * @access public
+ */
+ function set_end_comment($end_comment)
+ {
+ $this->end_comment = $end_comment;
+ }
+
+ /**
+ * Getter for the name of this section
+ *
+ * @return string Section's name
+ *
+ * @access public
+ */
+ function get_name()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Get a variable object by its name
+ *
+ * @param string $name The name of the variable that shall be returned
+ * @return phpbb_search_sphinx_config_section The first variable object from this section with the
+ * given name or null if none was found
+ *
+ * @access public
+ */
+ function get_variable_by_name($name)
+ {
+ for ($i = 0, $size = sizeof($this->variables); $i < $size; $i++)
+ {
+ // Make sure this is a variable object and not a comment
+ if (($this->variables[$i] instanceof phpbb_search_sphinx_config_variable) && $this->variables[$i]->get_name() == $name)
+ {
+ return $this->variables[$i];
+ }
+ }
+ }
+
+ /**
+ * Deletes all variables with the given name
+ *
+ * @param string $name The name of the variable objects that are supposed to be removed
+ *
+ * @access public
+ */
+ function delete_variables_by_name($name)
+ {
+ for ($i = 0, $size = sizeof($this->variables); $i < $size; $i++)
+ {
+ // Make sure this is a variable object and not a comment
+ if (($this->variables[$i] instanceof phpbb_search_sphinx_config_variable) && $this->variables[$i]->get_name() == $name)
+ {
+ array_splice($this->variables, $i, 1);
+ $i--;
+ }
+ }
+ }
+
+ /**
+ * Create a new variable object and append it to the variable list of this section
+ *
+ * @param string $name The name for the new variable
+ * @param string $value The value for the new variable
+ * @return phpbb_search_sphinx_config_variable Variable object that was created
+ *
+ * @access public
+ */
+ function create_variable($name, $value)
+ {
+ $this->variables[] = new phpbb_search_sphinx_config_variable($name, $value, '');
+ return $this->variables[sizeof($this->variables) - 1];
+ }
+
+ /**
+ * Turns this object into a string which can be written to a config file
+ *
+ * @return string Config data in textual form, parsable for sphinx
+ *
+ * @access public
+ */
+ function to_string()
+ {
+ $content = $this->name . ' ' . $this->comment . "\n{\n";
+
+ // Make sure we don't get too many newlines after the opening bracket
+ while (trim($this->variables[0]->to_string()) == '')
+ {
+ array_shift($this->variables);
+ }
+
+ foreach ($this->variables as $variable)
+ {
+ $content .= $variable->to_string();
+ }
+ $content .= '}' . $this->end_comment . "\n";
+
+ return $content;
+ }
+}
diff --git a/phpBB/includes/search/sphinx/config_variable.php b/phpBB/includes/search/sphinx/config_variable.php
new file mode 100644
index 0000000000..35abe281cb
--- /dev/null
+++ b/phpBB/includes/search/sphinx/config_variable.php
@@ -0,0 +1,80 @@
+<?php
+/**
+*
+* @package search
+* @copyright (c) 2005 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* phpbb_search_sphinx_config_variable
+* Represents a single variable inside the sphinx configuration
+*/
+class phpbb_search_sphinx_config_variable
+{
+ private $name;
+ private $value;
+ private $comment;
+
+ /**
+ * Constructs a new variable object
+ *
+ * @param string $name Name of the variable
+ * @param string $value Value of the variable
+ * @param string $comment Optional comment after the variable in the
+ * config file
+ *
+ * @access public
+ */
+ function __construct($name, $value, $comment)
+ {
+ $this->name = $name;
+ $this->value = $value;
+ $this->comment = $comment;
+ }
+
+ /**
+ * Getter for the variable's name
+ *
+ * @return string The variable object's name
+ *
+ * @access public
+ */
+ function get_name()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Allows changing the variable's value
+ *
+ * @param string $value New value for this variable
+ *
+ * @access public
+ */
+ function set_value($value)
+ {
+ $this->value = $value;
+ }
+
+ /**
+ * Turns this object into a string readable by sphinx
+ *
+ * @return string Config data in textual form
+ *
+ * @access public
+ */
+ function to_string()
+ {
+ return "\t" . $this->name . ' = ' . str_replace("\n", "\\\n", $this->value) . ' ' . $this->comment . "\n";
+ }
+}
diff --git a/phpBB/includes/sphinxapi.php b/phpBB/includes/sphinxapi.php
new file mode 100644
index 0000000000..bd83b1d2e0
--- /dev/null
+++ b/phpBB/includes/sphinxapi.php
@@ -0,0 +1,1712 @@
+<?php
+
+//
+// $Id: sphinxapi.php 3087 2012-01-30 23:07:35Z shodan $
+//
+
+//
+// Copyright (c) 2001-2012, Andrew Aksyonoff
+// Copyright (c) 2008-2012, Sphinx Technologies Inc
+// All rights reserved
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License. You should have
+// received a copy of the GPL license along with this program; if you
+// did not, you can find it at http://www.gnu.org/
+//
+
+/////////////////////////////////////////////////////////////////////////////
+// PHP version of Sphinx searchd client (PHP API)
+/////////////////////////////////////////////////////////////////////////////
+
+/// known searchd commands
+define ( "SEARCHD_COMMAND_SEARCH", 0 );
+define ( "SEARCHD_COMMAND_EXCERPT", 1 );
+define ( "SEARCHD_COMMAND_UPDATE", 2 );
+define ( "SEARCHD_COMMAND_KEYWORDS", 3 );
+define ( "SEARCHD_COMMAND_PERSIST", 4 );
+define ( "SEARCHD_COMMAND_STATUS", 5 );
+define ( "SEARCHD_COMMAND_FLUSHATTRS", 7 );
+
+/// current client-side command implementation versions
+define ( "VER_COMMAND_SEARCH", 0x119 );
+define ( "VER_COMMAND_EXCERPT", 0x104 );
+define ( "VER_COMMAND_UPDATE", 0x102 );
+define ( "VER_COMMAND_KEYWORDS", 0x100 );
+define ( "VER_COMMAND_STATUS", 0x100 );
+define ( "VER_COMMAND_QUERY", 0x100 );
+define ( "VER_COMMAND_FLUSHATTRS", 0x100 );
+
+/// known searchd status codes
+define ( "SEARCHD_OK", 0 );
+define ( "SEARCHD_ERROR", 1 );
+define ( "SEARCHD_RETRY", 2 );
+define ( "SEARCHD_WARNING", 3 );
+
+/// known match modes
+define ( "SPH_MATCH_ALL", 0 );
+define ( "SPH_MATCH_ANY", 1 );
+define ( "SPH_MATCH_PHRASE", 2 );
+define ( "SPH_MATCH_BOOLEAN", 3 );
+define ( "SPH_MATCH_EXTENDED", 4 );
+define ( "SPH_MATCH_FULLSCAN", 5 );
+define ( "SPH_MATCH_EXTENDED2", 6 ); // extended engine V2 (TEMPORARY, WILL BE REMOVED)
+
+/// known ranking modes (ext2 only)
+define ( "SPH_RANK_PROXIMITY_BM25", 0 ); ///< default mode, phrase proximity major factor and BM25 minor one
+define ( "SPH_RANK_BM25", 1 ); ///< statistical mode, BM25 ranking only (faster but worse quality)
+define ( "SPH_RANK_NONE", 2 ); ///< no ranking, all matches get a weight of 1
+define ( "SPH_RANK_WORDCOUNT", 3 ); ///< simple word-count weighting, rank is a weighted sum of per-field keyword occurence counts
+define ( "SPH_RANK_PROXIMITY", 4 );
+define ( "SPH_RANK_MATCHANY", 5 );
+define ( "SPH_RANK_FIELDMASK", 6 );
+define ( "SPH_RANK_SPH04", 7 );
+define ( "SPH_RANK_EXPR", 8 );
+define ( "SPH_RANK_TOTAL", 9 );
+
+/// known sort modes
+define ( "SPH_SORT_RELEVANCE", 0 );
+define ( "SPH_SORT_ATTR_DESC", 1 );
+define ( "SPH_SORT_ATTR_ASC", 2 );
+define ( "SPH_SORT_TIME_SEGMENTS", 3 );
+define ( "SPH_SORT_EXTENDED", 4 );
+define ( "SPH_SORT_EXPR", 5 );
+
+/// known filter types
+define ( "SPH_FILTER_VALUES", 0 );
+define ( "SPH_FILTER_RANGE", 1 );
+define ( "SPH_FILTER_FLOATRANGE", 2 );
+
+/// known attribute types
+define ( "SPH_ATTR_INTEGER", 1 );
+define ( "SPH_ATTR_TIMESTAMP", 2 );
+define ( "SPH_ATTR_ORDINAL", 3 );
+define ( "SPH_ATTR_BOOL", 4 );
+define ( "SPH_ATTR_FLOAT", 5 );
+define ( "SPH_ATTR_BIGINT", 6 );
+define ( "SPH_ATTR_STRING", 7 );
+define ( "SPH_ATTR_MULTI", 0x40000001 );
+define ( "SPH_ATTR_MULTI64", 0x40000002 );
+
+/// known grouping functions
+define ( "SPH_GROUPBY_DAY", 0 );
+define ( "SPH_GROUPBY_WEEK", 1 );
+define ( "SPH_GROUPBY_MONTH", 2 );
+define ( "SPH_GROUPBY_YEAR", 3 );
+define ( "SPH_GROUPBY_ATTR", 4 );
+define ( "SPH_GROUPBY_ATTRPAIR", 5 );
+
+// important properties of PHP's integers:
+// - always signed (one bit short of PHP_INT_SIZE)
+// - conversion from string to int is saturated
+// - float is double
+// - div converts arguments to floats
+// - mod converts arguments to ints
+
+// the packing code below works as follows:
+// - when we got an int, just pack it
+// if performance is a problem, this is the branch users should aim for
+//
+// - otherwise, we got a number in string form
+// this might be due to different reasons, but we assume that this is
+// because it didn't fit into PHP int
+//
+// - factor the string into high and low ints for packing
+// - if we have bcmath, then it is used
+// - if we don't, we have to do it manually (this is the fun part)
+//
+// - x64 branch does factoring using ints
+// - x32 (ab)uses floats, since we can't fit unsigned 32-bit number into an int
+//
+// unpacking routines are pretty much the same.
+// - return ints if we can
+// - otherwise format number into a string
+
+/// pack 64-bit signed
+function sphPackI64 ( $v )
+{
+ assert ( is_numeric($v) );
+
+ // x64
+ if ( PHP_INT_SIZE>=8 )
+ {
+ $v = (int)$v;
+ return pack ( "NN", $v>>32, $v&0xFFFFFFFF );
+ }
+
+ // x32, int
+ if ( is_int($v) )
+ return pack ( "NN", $v < 0 ? -1 : 0, $v );
+
+ // x32, bcmath
+ if ( function_exists("bcmul") )
+ {
+ if ( bccomp ( $v, 0 ) == -1 )
+ $v = bcadd ( "18446744073709551616", $v );
+ $h = bcdiv ( $v, "4294967296", 0 );
+ $l = bcmod ( $v, "4294967296" );
+ return pack ( "NN", (float)$h, (float)$l ); // conversion to float is intentional; int would lose 31st bit
+ }
+
+ // x32, no-bcmath
+ $p = max(0, strlen($v) - 13);
+ $lo = abs((float)substr($v, $p));
+ $hi = abs((float)substr($v, 0, $p));
+
+ $m = $lo + $hi*1316134912.0; // (10 ^ 13) % (1 << 32) = 1316134912
+ $q = floor($m/4294967296.0);
+ $l = $m - ($q*4294967296.0);
+ $h = $hi*2328.0 + $q; // (10 ^ 13) / (1 << 32) = 2328
+
+ if ( $v<0 )
+ {
+ if ( $l==0 )
+ $h = 4294967296.0 - $h;
+ else
+ {
+ $h = 4294967295.0 - $h;
+ $l = 4294967296.0 - $l;
+ }
+ }
+ return pack ( "NN", $h, $l );
+}
+
+/// pack 64-bit unsigned
+function sphPackU64 ( $v )
+{
+ assert ( is_numeric($v) );
+
+ // x64
+ if ( PHP_INT_SIZE>=8 )
+ {
+ assert ( $v>=0 );
+
+ // x64, int
+ if ( is_int($v) )
+ return pack ( "NN", $v>>32, $v&0xFFFFFFFF );
+
+ // x64, bcmath
+ if ( function_exists("bcmul") )
+ {
+ $h = bcdiv ( $v, 4294967296, 0 );
+ $l = bcmod ( $v, 4294967296 );
+ return pack ( "NN", $h, $l );
+ }
+
+ // x64, no-bcmath
+ $p = max ( 0, strlen($v) - 13 );
+ $lo = (int)substr ( $v, $p );
+ $hi = (int)substr ( $v, 0, $p );
+
+ $m = $lo + $hi*1316134912;
+ $l = $m % 4294967296;
+ $h = $hi*2328 + (int)($m/4294967296);
+
+ return pack ( "NN", $h, $l );
+ }
+
+ // x32, int
+ if ( is_int($v) )
+ return pack ( "NN", 0, $v );
+
+ // x32, bcmath
+ if ( function_exists("bcmul") )
+ {
+ $h = bcdiv ( $v, "4294967296", 0 );
+ $l = bcmod ( $v, "4294967296" );
+ return pack ( "NN", (float)$h, (float)$l ); // conversion to float is intentional; int would lose 31st bit
+ }
+
+ // x32, no-bcmath
+ $p = max(0, strlen($v) - 13);
+ $lo = (float)substr($v, $p);
+ $hi = (float)substr($v, 0, $p);
+
+ $m = $lo + $hi*1316134912.0;
+ $q = floor($m / 4294967296.0);
+ $l = $m - ($q * 4294967296.0);
+ $h = $hi*2328.0 + $q;
+
+ return pack ( "NN", $h, $l );
+}
+
+// unpack 64-bit unsigned
+function sphUnpackU64 ( $v )
+{
+ list ( $hi, $lo ) = array_values ( unpack ( "N*N*", $v ) );
+
+ if ( PHP_INT_SIZE>=8 )
+ {
+ if ( $hi<0 ) $hi += (1<<32); // because php 5.2.2 to 5.2.5 is totally fucked up again
+ if ( $lo<0 ) $lo += (1<<32);
+
+ // x64, int
+ if ( $hi<=2147483647 )
+ return ($hi<<32) + $lo;
+
+ // x64, bcmath
+ if ( function_exists("bcmul") )
+ return bcadd ( $lo, bcmul ( $hi, "4294967296" ) );
+
+ // x64, no-bcmath
+ $C = 100000;
+ $h = ((int)($hi / $C) << 32) + (int)($lo / $C);
+ $l = (($hi % $C) << 32) + ($lo % $C);
+ if ( $l>$C )
+ {
+ $h += (int)($l / $C);
+ $l = $l % $C;
+ }
+
+ if ( $h==0 )
+ return $l;
+ return sprintf ( "%d%05d", $h, $l );
+ }
+
+ // x32, int
+ if ( $hi==0 )
+ {
+ if ( $lo>0 )
+ return $lo;
+ return sprintf ( "%u", $lo );
+ }
+
+ $hi = sprintf ( "%u", $hi );
+ $lo = sprintf ( "%u", $lo );
+
+ // x32, bcmath
+ if ( function_exists("bcmul") )
+ return bcadd ( $lo, bcmul ( $hi, "4294967296" ) );
+
+ // x32, no-bcmath
+ $hi = (float)$hi;
+ $lo = (float)$lo;
+
+ $q = floor($hi/10000000.0);
+ $r = $hi - $q*10000000.0;
+ $m = $lo + $r*4967296.0;
+ $mq = floor($m/10000000.0);
+ $l = $m - $mq*10000000.0;
+ $h = $q*4294967296.0 + $r*429.0 + $mq;
+
+ $h = sprintf ( "%.0f", $h );
+ $l = sprintf ( "%07.0f", $l );
+ if ( $h=="0" )
+ return sprintf( "%.0f", (float)$l );
+ return $h . $l;
+}
+
+// unpack 64-bit signed
+function sphUnpackI64 ( $v )
+{
+ list ( $hi, $lo ) = array_values ( unpack ( "N*N*", $v ) );
+
+ // x64
+ if ( PHP_INT_SIZE>=8 )
+ {
+ if ( $hi<0 ) $hi += (1<<32); // because php 5.2.2 to 5.2.5 is totally fucked up again
+ if ( $lo<0 ) $lo += (1<<32);
+
+ return ($hi<<32) + $lo;
+ }
+
+ // x32, int
+ if ( $hi==0 )
+ {
+ if ( $lo>0 )
+ return $lo;
+ return sprintf ( "%u", $lo );
+ }
+ // x32, int
+ elseif ( $hi==-1 )
+ {
+ if ( $lo<0 )
+ return $lo;
+ return sprintf ( "%.0f", $lo - 4294967296.0 );
+ }
+
+ $neg = "";
+ $c = 0;
+ if ( $hi<0 )
+ {
+ $hi = ~$hi;
+ $lo = ~$lo;
+ $c = 1;
+ $neg = "-";
+ }
+
+ $hi = sprintf ( "%u", $hi );
+ $lo = sprintf ( "%u", $lo );
+
+ // x32, bcmath
+ if ( function_exists("bcmul") )
+ return $neg . bcadd ( bcadd ( $lo, bcmul ( $hi, "4294967296" ) ), $c );
+
+ // x32, no-bcmath
+ $hi = (float)$hi;
+ $lo = (float)$lo;
+
+ $q = floor($hi/10000000.0);
+ $r = $hi - $q*10000000.0;
+ $m = $lo + $r*4967296.0;
+ $mq = floor($m/10000000.0);
+ $l = $m - $mq*10000000.0 + $c;
+ $h = $q*4294967296.0 + $r*429.0 + $mq;
+ if ( $l==10000000 )
+ {
+ $l = 0;
+ $h += 1;
+ }
+
+ $h = sprintf ( "%.0f", $h );
+ $l = sprintf ( "%07.0f", $l );
+ if ( $h=="0" )
+ return $neg . sprintf( "%.0f", (float)$l );
+ return $neg . $h . $l;
+}
+
+
+function sphFixUint ( $value )
+{
+ if ( PHP_INT_SIZE>=8 )
+ {
+ // x64 route, workaround broken unpack() in 5.2.2+
+ if ( $value<0 ) $value += (1<<32);
+ return $value;
+ }
+ else
+ {
+ // x32 route, workaround php signed/unsigned braindamage
+ return sprintf ( "%u", $value );
+ }
+}
+
+
+/// sphinx searchd client class
+class SphinxClient
+{
+ var $_host; ///< searchd host (default is "localhost")
+ var $_port; ///< searchd port (default is 9312)
+ var $_offset; ///< how many records to seek from result-set start (default is 0)
+ var $_limit; ///< how many records to return from result-set starting at offset (default is 20)
+ var $_mode; ///< query matching mode (default is SPH_MATCH_ALL)
+ var $_weights; ///< per-field weights (default is 1 for all fields)
+ var $_sort; ///< match sorting mode (default is SPH_SORT_RELEVANCE)
+ var $_sortby; ///< attribute to sort by (defualt is "")
+ var $_min_id; ///< min ID to match (default is 0, which means no limit)
+ var $_max_id; ///< max ID to match (default is 0, which means no limit)
+ var $_filters; ///< search filters
+ var $_groupby; ///< group-by attribute name
+ var $_groupfunc; ///< group-by function (to pre-process group-by attribute value with)
+ var $_groupsort; ///< group-by sorting clause (to sort groups in result set with)
+ var $_groupdistinct;///< group-by count-distinct attribute
+ var $_maxmatches; ///< max matches to retrieve
+ var $_cutoff; ///< cutoff to stop searching at (default is 0)
+ var $_retrycount; ///< distributed retries count
+ var $_retrydelay; ///< distributed retries delay
+ var $_anchor; ///< geographical anchor point
+ var $_indexweights; ///< per-index weights
+ var $_ranker; ///< ranking mode (default is SPH_RANK_PROXIMITY_BM25)
+ var $_rankexpr; ///< ranking mode expression (for SPH_RANK_EXPR)
+ var $_maxquerytime; ///< max query time, milliseconds (default is 0, do not limit)
+ var $_fieldweights; ///< per-field-name weights
+ var $_overrides; ///< per-query attribute values overrides
+ var $_select; ///< select-list (attributes or expressions, with optional aliases)
+
+ var $_error; ///< last error message
+ var $_warning; ///< last warning message
+ var $_connerror; ///< connection error vs remote error flag
+
+ var $_reqs; ///< requests array for multi-query
+ var $_mbenc; ///< stored mbstring encoding
+ var $_arrayresult; ///< whether $result["matches"] should be a hash or an array
+ var $_timeout; ///< connect timeout
+
+ /////////////////////////////////////////////////////////////////////////////
+ // common stuff
+ /////////////////////////////////////////////////////////////////////////////
+
+ /// create a new client object and fill defaults
+ function SphinxClient ()
+ {
+ // per-client-object settings
+ $this->_host = "localhost";
+ $this->_port = 9312;
+ $this->_path = false;
+ $this->_socket = false;
+
+ // per-query settings
+ $this->_offset = 0;
+ $this->_limit = 20;
+ $this->_mode = SPH_MATCH_ALL;
+ $this->_weights = array ();
+ $this->_sort = SPH_SORT_RELEVANCE;
+ $this->_sortby = "";
+ $this->_min_id = 0;
+ $this->_max_id = 0;
+ $this->_filters = array ();
+ $this->_groupby = "";
+ $this->_groupfunc = SPH_GROUPBY_DAY;
+ $this->_groupsort = "@group desc";
+ $this->_groupdistinct= "";
+ $this->_maxmatches = 1000;
+ $this->_cutoff = 0;
+ $this->_retrycount = 0;
+ $this->_retrydelay = 0;
+ $this->_anchor = array ();
+ $this->_indexweights= array ();
+ $this->_ranker = SPH_RANK_PROXIMITY_BM25;
+ $this->_rankexpr = "";
+ $this->_maxquerytime= 0;
+ $this->_fieldweights= array();
+ $this->_overrides = array();
+ $this->_select = "*";
+
+ $this->_error = ""; // per-reply fields (for single-query case)
+ $this->_warning = "";
+ $this->_connerror = false;
+
+ $this->_reqs = array (); // requests storage (for multi-query case)
+ $this->_mbenc = "";
+ $this->_arrayresult = false;
+ $this->_timeout = 0;
+ }
+
+ function __destruct()
+ {
+ if ( $this->_socket !== false )
+ fclose ( $this->_socket );
+ }
+
+ /// get last error message (string)
+ function GetLastError ()
+ {
+ return $this->_error;
+ }
+
+ /// get last warning message (string)
+ function GetLastWarning ()
+ {
+ return $this->_warning;
+ }
+
+ /// get last error flag (to tell network connection errors from searchd errors or broken responses)
+ function IsConnectError()
+ {
+ return $this->_connerror;
+ }
+
+ /// set searchd host name (string) and port (integer)
+ function SetServer ( $host, $port = 0 )
+ {
+ assert ( is_string($host) );
+ if ( $host[0] == '/')
+ {
+ $this->_path = 'unix://' . $host;
+ return;
+ }
+ if ( substr ( $host, 0, 7 )=="unix://" )
+ {
+ $this->_path = $host;
+ return;
+ }
+
+ assert ( is_int($port) );
+ $this->_host = $host;
+ $this->_port = $port;
+ $this->_path = '';
+
+ }
+
+ /// set server connection timeout (0 to remove)
+ function SetConnectTimeout ( $timeout )
+ {
+ assert ( is_numeric($timeout) );
+ $this->_timeout = $timeout;
+ }
+
+
+ function _Send ( $handle, $data, $length )
+ {
+ if ( feof($handle) || fwrite ( $handle, $data, $length ) !== $length )
+ {
+ $this->_error = 'connection unexpectedly closed (timed out?)';
+ $this->_connerror = true;
+ return false;
+ }
+ return true;
+ }
+
+ /////////////////////////////////////////////////////////////////////////////
+
+ /// enter mbstring workaround mode
+ function _MBPush ()
+ {
+ $this->_mbenc = "";
+ if ( ini_get ( "mbstring.func_overload" ) & 2 )
+ {
+ $this->_mbenc = mb_internal_encoding();
+ mb_internal_encoding ( "latin1" );
+ }
+ }
+
+ /// leave mbstring workaround mode
+ function _MBPop ()
+ {
+ if ( $this->_mbenc )
+ mb_internal_encoding ( $this->_mbenc );
+ }
+
+ /// connect to searchd server
+ function _Connect ()
+ {
+ if ( $this->_socket!==false )
+ {
+ // we are in persistent connection mode, so we have a socket
+ // however, need to check whether it's still alive
+ if ( !@feof ( $this->_socket ) )
+ return $this->_socket;
+
+ // force reopen
+ $this->_socket = false;
+ }
+
+ $errno = 0;
+ $errstr = "";
+ $this->_connerror = false;
+
+ if ( $this->_path )
+ {
+ $host = $this->_path;
+ $port = 0;
+ }
+ else
+ {
+ $host = $this->_host;
+ $port = $this->_port;
+ }
+
+ if ( $this->_timeout<=0 )
+ $fp = @fsockopen ( $host, $port, $errno, $errstr );
+ else
+ $fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout );
+
+ if ( !$fp )
+ {
+ if ( $this->_path )
+ $location = $this->_path;
+ else
+ $location = "{$this->_host}:{$this->_port}";
+
+ $errstr = trim ( $errstr );
+ $this->_error = "connection to $location failed (errno=$errno, msg=$errstr)";
+ $this->_connerror = true;
+ return false;
+ }
+
+ // send my version
+ // this is a subtle part. we must do it before (!) reading back from searchd.
+ // because otherwise under some conditions (reported on FreeBSD for instance)
+ // TCP stack could throttle write-write-read pattern because of Nagle.
+ if ( !$this->_Send ( $fp, pack ( "N", 1 ), 4 ) )
+ {
+ fclose ( $fp );
+ $this->_error = "failed to send client protocol version";
+ return false;
+ }
+
+ // check version
+ list(,$v) = unpack ( "N*", fread ( $fp, 4 ) );
+ $v = (int)$v;
+ if ( $v<1 )
+ {
+ fclose ( $fp );
+ $this->_error = "expected searchd protocol version 1+, got version '$v'";
+ return false;
+ }
+
+ return $fp;
+ }
+
+ /// get and check response packet from searchd server
+ function _GetResponse ( $fp, $client_ver )
+ {
+ $response = "";
+ $len = 0;
+
+ $header = fread ( $fp, 8 );
+ if ( strlen($header)==8 )
+ {
+ list ( $status, $ver, $len ) = array_values ( unpack ( "n2a/Nb", $header ) );
+ $left = $len;
+ while ( $left>0 && !feof($fp) )
+ {
+ $chunk = fread ( $fp, min ( 8192, $left ) );
+ if ( $chunk )
+ {
+ $response .= $chunk;
+ $left -= strlen($chunk);
+ }
+ }
+ }
+ if ( $this->_socket === false )
+ fclose ( $fp );
+
+ // check response
+ $read = strlen ( $response );
+ if ( !$response || $read!=$len )
+ {
+ $this->_error = $len
+ ? "failed to read searchd response (status=$status, ver=$ver, len=$len, read=$read)"
+ : "received zero-sized searchd response";
+ return false;
+ }
+
+ // check status
+ if ( $status==SEARCHD_WARNING )
+ {
+ list(,$wlen) = unpack ( "N*", substr ( $response, 0, 4 ) );
+ $this->_warning = substr ( $response, 4, $wlen );
+ return substr ( $response, 4+$wlen );
+ }
+ if ( $status==SEARCHD_ERROR )
+ {
+ $this->_error = "searchd error: " . substr ( $response, 4 );
+ return false;
+ }
+ if ( $status==SEARCHD_RETRY )
+ {
+ $this->_error = "temporary searchd error: " . substr ( $response, 4 );
+ return false;
+ }
+ if ( $status!=SEARCHD_OK )
+ {
+ $this->_error = "unknown status code '$status'";
+ return false;
+ }
+
+ // check version
+ if ( $ver<$client_ver )
+ {
+ $this->_warning = sprintf ( "searchd command v.%d.%d older than client's v.%d.%d, some options might not work",
+ $ver>>8, $ver&0xff, $client_ver>>8, $client_ver&0xff );
+ }
+
+ return $response;
+ }
+
+ /////////////////////////////////////////////////////////////////////////////
+ // searching
+ /////////////////////////////////////////////////////////////////////////////
+
+ /// set offset and count into result set,
+ /// and optionally set max-matches and cutoff limits
+ function SetLimits ( $offset, $limit, $max=0, $cutoff=0 )
+ {
+ assert ( is_int($offset) );
+ assert ( is_int($limit) );
+ assert ( $offset>=0 );
+ assert ( $limit>0 );
+ assert ( $max>=0 );
+ $this->_offset = $offset;
+ $this->_limit = $limit;
+ if ( $max>0 )
+ $this->_maxmatches = $max;
+ if ( $cutoff>0 )
+ $this->_cutoff = $cutoff;
+ }
+
+ /// set maximum query time, in milliseconds, per-index
+ /// integer, 0 means "do not limit"
+ function SetMaxQueryTime ( $max )
+ {
+ assert ( is_int($max) );
+ assert ( $max>=0 );
+ $this->_maxquerytime = $max;
+ }
+
+ /// set matching mode
+ function SetMatchMode ( $mode )
+ {
+ assert ( $mode==SPH_MATCH_ALL
+ || $mode==SPH_MATCH_ANY
+ || $mode==SPH_MATCH_PHRASE
+ || $mode==SPH_MATCH_BOOLEAN
+ || $mode==SPH_MATCH_EXTENDED
+ || $mode==SPH_MATCH_FULLSCAN
+ || $mode==SPH_MATCH_EXTENDED2 );
+ $this->_mode = $mode;
+ }
+
+ /// set ranking mode
+ function SetRankingMode ( $ranker, $rankexpr="" )
+ {
+ assert ( $ranker>=0 && $ranker<SPH_RANK_TOTAL );
+ assert ( is_string($rankexpr) );
+ $this->_ranker = $ranker;
+ $this->_rankexpr = $rankexpr;
+ }
+
+ /// set matches sorting mode
+ function SetSortMode ( $mode, $sortby="" )
+ {
+ assert (
+ $mode==SPH_SORT_RELEVANCE ||
+ $mode==SPH_SORT_ATTR_DESC ||
+ $mode==SPH_SORT_ATTR_ASC ||
+ $mode==SPH_SORT_TIME_SEGMENTS ||
+ $mode==SPH_SORT_EXTENDED ||
+ $mode==SPH_SORT_EXPR );
+ assert ( is_string($sortby) );
+ assert ( $mode==SPH_SORT_RELEVANCE || strlen($sortby)>0 );
+
+ $this->_sort = $mode;
+ $this->_sortby = $sortby;
+ }
+
+ /// bind per-field weights by order
+ /// DEPRECATED; use SetFieldWeights() instead
+ function SetWeights ( $weights )
+ {
+ assert ( is_array($weights) );
+ foreach ( $weights as $weight )
+ assert ( is_int($weight) );
+
+ $this->_weights = $weights;
+ }
+
+ /// bind per-field weights by name
+ function SetFieldWeights ( $weights )
+ {
+ assert ( is_array($weights) );
+ foreach ( $weights as $name=>$weight )
+ {
+ assert ( is_string($name) );
+ assert ( is_int($weight) );
+ }
+ $this->_fieldweights = $weights;
+ }
+
+ /// bind per-index weights by name
+ function SetIndexWeights ( $weights )
+ {
+ assert ( is_array($weights) );
+ foreach ( $weights as $index=>$weight )
+ {
+ assert ( is_string($index) );
+ assert ( is_int($weight) );
+ }
+ $this->_indexweights = $weights;
+ }
+
+ /// set IDs range to match
+ /// only match records if document ID is beetwen $min and $max (inclusive)
+ function SetIDRange ( $min, $max )
+ {
+ assert ( is_numeric($min) );
+ assert ( is_numeric($max) );
+ assert ( $min<=$max );
+ $this->_min_id = $min;
+ $this->_max_id = $max;
+ }
+
+ /// set values set filter
+ /// only match records where $attribute value is in given set
+ function SetFilter ( $attribute, $values, $exclude=false )
+ {
+ assert ( is_string($attribute) );
+ assert ( is_array($values) );
+ assert ( count($values) );
+
+ if ( is_array($values) && count($values) )
+ {
+ foreach ( $values as $value )
+ assert ( is_numeric($value) );
+
+ $this->_filters[] = array ( "type"=>SPH_FILTER_VALUES, "attr"=>$attribute, "exclude"=>$exclude, "values"=>$values );
+ }
+ }
+
+ /// set range filter
+ /// only match records if $attribute value is beetwen $min and $max (inclusive)
+ function SetFilterRange ( $attribute, $min, $max, $exclude=false )
+ {
+ assert ( is_string($attribute) );
+ assert ( is_numeric($min) );
+ assert ( is_numeric($max) );
+ assert ( $min<=$max );
+
+ $this->_filters[] = array ( "type"=>SPH_FILTER_RANGE, "attr"=>$attribute, "exclude"=>$exclude, "min"=>$min, "max"=>$max );
+ }
+
+ /// set float range filter
+ /// only match records if $attribute value is beetwen $min and $max (inclusive)
+ function SetFilterFloatRange ( $attribute, $min, $max, $exclude=false )
+ {
+ assert ( is_string($attribute) );
+ assert ( is_float($min) );
+ assert ( is_float($max) );
+ assert ( $min<=$max );
+
+ $this->_filters[] = array ( "type"=>SPH_FILTER_FLOATRANGE, "attr"=>$attribute, "exclude"=>$exclude, "min"=>$min, "max"=>$max );
+ }
+
+ /// setup anchor point for geosphere distance calculations
+ /// required to use @geodist in filters and sorting
+ /// latitude and longitude must be in radians
+ function SetGeoAnchor ( $attrlat, $attrlong, $lat, $long )
+ {
+ assert ( is_string($attrlat) );
+ assert ( is_string($attrlong) );
+ assert ( is_float($lat) );
+ assert ( is_float($long) );
+
+ $this->_anchor = array ( "attrlat"=>$attrlat, "attrlong"=>$attrlong, "lat"=>$lat, "long"=>$long );
+ }
+
+ /// set grouping attribute and function
+ function SetGroupBy ( $attribute, $func, $groupsort="@group desc" )
+ {
+ assert ( is_string($attribute) );
+ assert ( is_string($groupsort) );
+ assert ( $func==SPH_GROUPBY_DAY
+ || $func==SPH_GROUPBY_WEEK
+ || $func==SPH_GROUPBY_MONTH
+ || $func==SPH_GROUPBY_YEAR
+ || $func==SPH_GROUPBY_ATTR
+ || $func==SPH_GROUPBY_ATTRPAIR );
+
+ $this->_groupby = $attribute;
+ $this->_groupfunc = $func;
+ $this->_groupsort = $groupsort;
+ }
+
+ /// set count-distinct attribute for group-by queries
+ function SetGroupDistinct ( $attribute )
+ {
+ assert ( is_string($attribute) );
+ $this->_groupdistinct = $attribute;
+ }
+
+ /// set distributed retries count and delay
+ function SetRetries ( $count, $delay=0 )
+ {
+ assert ( is_int($count) && $count>=0 );
+ assert ( is_int($delay) && $delay>=0 );
+ $this->_retrycount = $count;
+ $this->_retrydelay = $delay;
+ }
+
+ /// set result set format (hash or array; hash by default)
+ /// PHP specific; needed for group-by-MVA result sets that may contain duplicate IDs
+ function SetArrayResult ( $arrayresult )
+ {
+ assert ( is_bool($arrayresult) );
+ $this->_arrayresult = $arrayresult;
+ }
+
+ /// set attribute values override
+ /// there can be only one override per attribute
+ /// $values must be a hash that maps document IDs to attribute values
+ function SetOverride ( $attrname, $attrtype, $values )
+ {
+ assert ( is_string ( $attrname ) );
+ assert ( in_array ( $attrtype, array ( SPH_ATTR_INTEGER, SPH_ATTR_TIMESTAMP, SPH_ATTR_BOOL, SPH_ATTR_FLOAT, SPH_ATTR_BIGINT ) ) );
+ assert ( is_array ( $values ) );
+
+ $this->_overrides[$attrname] = array ( "attr"=>$attrname, "type"=>$attrtype, "values"=>$values );
+ }
+
+ /// set select-list (attributes or expressions), SQL-like syntax
+ function SetSelect ( $select )
+ {
+ assert ( is_string ( $select ) );
+ $this->_select = $select;
+ }
+
+ //////////////////////////////////////////////////////////////////////////////
+
+ /// clear all filters (for multi-queries)
+ function ResetFilters ()
+ {
+ $this->_filters = array();
+ $this->_anchor = array();
+ }
+
+ /// clear groupby settings (for multi-queries)
+ function ResetGroupBy ()
+ {
+ $this->_groupby = "";
+ $this->_groupfunc = SPH_GROUPBY_DAY;
+ $this->_groupsort = "@group desc";
+ $this->_groupdistinct= "";
+ }
+
+ /// clear all attribute value overrides (for multi-queries)
+ function ResetOverrides ()
+ {
+ $this->_overrides = array ();
+ }
+
+ //////////////////////////////////////////////////////////////////////////////
+
+ /// connect to searchd server, run given search query through given indexes,
+ /// and return the search results
+ function Query ( $query, $index="*", $comment="" )
+ {
+ assert ( empty($this->_reqs) );
+
+ $this->AddQuery ( $query, $index, $comment );
+ $results = $this->RunQueries ();
+ $this->_reqs = array (); // just in case it failed too early
+
+ if ( !is_array($results) )
+ return false; // probably network error; error message should be already filled
+
+ $this->_error = $results[0]["error"];
+ $this->_warning = $results[0]["warning"];
+ if ( $results[0]["status"]==SEARCHD_ERROR )
+ return false;
+ else
+ return $results[0];
+ }
+
+ /// helper to pack floats in network byte order
+ function _PackFloat ( $f )
+ {
+ $t1 = pack ( "f", $f ); // machine order
+ list(,$t2) = unpack ( "L*", $t1 ); // int in machine order
+ return pack ( "N", $t2 );
+ }
+
+ /// add query to multi-query batch
+ /// returns index into results array from RunQueries() call
+ function AddQuery ( $query, $index="*", $comment="" )
+ {
+ // mbstring workaround
+ $this->_MBPush ();
+
+ // build request
+ $req = pack ( "NNNN", $this->_offset, $this->_limit, $this->_mode, $this->_ranker );
+ if ( $this->_ranker==SPH_RANK_EXPR )
+ $req .= pack ( "N", strlen($this->_rankexpr) ) . $this->_rankexpr;
+ $req .= pack ( "N", $this->_sort ); // (deprecated) sort mode
+ $req .= pack ( "N", strlen($this->_sortby) ) . $this->_sortby;
+ $req .= pack ( "N", strlen($query) ) . $query; // query itself
+ $req .= pack ( "N", count($this->_weights) ); // weights
+ foreach ( $this->_weights as $weight )
+ $req .= pack ( "N", (int)$weight );
+ $req .= pack ( "N", strlen($index) ) . $index; // indexes
+ $req .= pack ( "N", 1 ); // id64 range marker
+ $req .= sphPackU64 ( $this->_min_id ) . sphPackU64 ( $this->_max_id ); // id64 range
+
+ // filters
+ $req .= pack ( "N", count($this->_filters) );
+ foreach ( $this->_filters as $filter )
+ {
+ $req .= pack ( "N", strlen($filter["attr"]) ) . $filter["attr"];
+ $req .= pack ( "N", $filter["type"] );
+ switch ( $filter["type"] )
+ {
+ case SPH_FILTER_VALUES:
+ $req .= pack ( "N", count($filter["values"]) );
+ foreach ( $filter["values"] as $value )
+ $req .= sphPackI64 ( $value );
+ break;
+
+ case SPH_FILTER_RANGE:
+ $req .= sphPackI64 ( $filter["min"] ) . sphPackI64 ( $filter["max"] );
+ break;
+
+ case SPH_FILTER_FLOATRANGE:
+ $req .= $this->_PackFloat ( $filter["min"] ) . $this->_PackFloat ( $filter["max"] );
+ break;
+
+ default:
+ assert ( 0 && "internal error: unhandled filter type" );
+ }
+ $req .= pack ( "N", $filter["exclude"] );
+ }
+
+ // group-by clause, max-matches count, group-sort clause, cutoff count
+ $req .= pack ( "NN", $this->_groupfunc, strlen($this->_groupby) ) . $this->_groupby;
+ $req .= pack ( "N", $this->_maxmatches );
+ $req .= pack ( "N", strlen($this->_groupsort) ) . $this->_groupsort;
+ $req .= pack ( "NNN", $this->_cutoff, $this->_retrycount, $this->_retrydelay );
+ $req .= pack ( "N", strlen($this->_groupdistinct) ) . $this->_groupdistinct;
+
+ // anchor point
+ if ( empty($this->_anchor) )
+ {
+ $req .= pack ( "N", 0 );
+ } else
+ {
+ $a =& $this->_anchor;
+ $req .= pack ( "N", 1 );
+ $req .= pack ( "N", strlen($a["attrlat"]) ) . $a["attrlat"];
+ $req .= pack ( "N", strlen($a["attrlong"]) ) . $a["attrlong"];
+ $req .= $this->_PackFloat ( $a["lat"] ) . $this->_PackFloat ( $a["long"] );
+ }
+
+ // per-index weights
+ $req .= pack ( "N", count($this->_indexweights) );
+ foreach ( $this->_indexweights as $idx=>$weight )
+ $req .= pack ( "N", strlen($idx) ) . $idx . pack ( "N", $weight );
+
+ // max query time
+ $req .= pack ( "N", $this->_maxquerytime );
+
+ // per-field weights
+ $req .= pack ( "N", count($this->_fieldweights) );
+ foreach ( $this->_fieldweights as $field=>$weight )
+ $req .= pack ( "N", strlen($field) ) . $field . pack ( "N", $weight );
+
+ // comment
+ $req .= pack ( "N", strlen($comment) ) . $comment;
+
+ // attribute overrides
+ $req .= pack ( "N", count($this->_overrides) );
+ foreach ( $this->_overrides as $key => $entry )
+ {
+ $req .= pack ( "N", strlen($entry["attr"]) ) . $entry["attr"];
+ $req .= pack ( "NN", $entry["type"], count($entry["values"]) );
+ foreach ( $entry["values"] as $id=>$val )
+ {
+ assert ( is_numeric($id) );
+ assert ( is_numeric($val) );
+
+ $req .= sphPackU64 ( $id );
+ switch ( $entry["type"] )
+ {
+ case SPH_ATTR_FLOAT: $req .= $this->_PackFloat ( $val ); break;
+ case SPH_ATTR_BIGINT: $req .= sphPackI64 ( $val ); break;
+ default: $req .= pack ( "N", $val ); break;
+ }
+ }
+ }
+
+ // select-list
+ $req .= pack ( "N", strlen($this->_select) ) . $this->_select;
+
+ // mbstring workaround
+ $this->_MBPop ();
+
+ // store request to requests array
+ $this->_reqs[] = $req;
+ return count($this->_reqs)-1;
+ }
+
+ /// connect to searchd, run queries batch, and return an array of result sets
+ function RunQueries ()
+ {
+ if ( empty($this->_reqs) )
+ {
+ $this->_error = "no queries defined, issue AddQuery() first";
+ return false;
+ }
+
+ // mbstring workaround
+ $this->_MBPush ();
+
+ if (!( $fp = $this->_Connect() ))
+ {
+ $this->_MBPop ();
+ return false;
+ }
+
+ // send query, get response
+ $nreqs = count($this->_reqs);
+ $req = join ( "", $this->_reqs );
+ $len = 8+strlen($req);
+ $req = pack ( "nnNNN", SEARCHD_COMMAND_SEARCH, VER_COMMAND_SEARCH, $len, 0, $nreqs ) . $req; // add header
+
+ if ( !( $this->_Send ( $fp, $req, $len+8 ) ) ||
+ !( $response = $this->_GetResponse ( $fp, VER_COMMAND_SEARCH ) ) )
+ {
+ $this->_MBPop ();
+ return false;
+ }
+
+ // query sent ok; we can reset reqs now
+ $this->_reqs = array ();
+
+ // parse and return response
+ return $this->_ParseSearchResponse ( $response, $nreqs );
+ }
+
+ /// parse and return search query (or queries) response
+ function _ParseSearchResponse ( $response, $nreqs )
+ {
+ $p = 0; // current position
+ $max = strlen($response); // max position for checks, to protect against broken responses
+
+ $results = array ();
+ for ( $ires=0; $ires<$nreqs && $p<$max; $ires++ )
+ {
+ $results[] = array();
+ $result =& $results[$ires];
+
+ $result["error"] = "";
+ $result["warning"] = "";
+
+ // extract status
+ list(,$status) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
+ $result["status"] = $status;
+ if ( $status!=SEARCHD_OK )
+ {
+ list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
+ $message = substr ( $response, $p, $len ); $p += $len;
+
+ if ( $status==SEARCHD_WARNING )
+ {
+ $result["warning"] = $message;
+ } else
+ {
+ $result["error"] = $message;
+ continue;
+ }
+ }
+
+ // read schema
+ $fields = array ();
+ $attrs = array ();
+
+ list(,$nfields) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
+ while ( $nfields-->0 && $p<$max )
+ {
+ list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
+ $fields[] = substr ( $response, $p, $len ); $p += $len;
+ }
+ $result["fields"] = $fields;
+
+ list(,$nattrs) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
+ while ( $nattrs-->0 && $p<$max )
+ {
+ list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
+ $attr = substr ( $response, $p, $len ); $p += $len;
+ list(,$type) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
+ $attrs[$attr] = $type;
+ }
+ $result["attrs"] = $attrs;
+
+ // read match count
+ list(,$count) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
+ list(,$id64) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
+
+ // read matches
+ $idx = -1;
+ while ( $count-->0 && $p<$max )
+ {
+ // index into result array
+ $idx++;
+
+ // parse document id and weight
+ if ( $id64 )
+ {
+ $doc = sphUnpackU64 ( substr ( $response, $p, 8 ) ); $p += 8;
+ list(,$weight) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
+ }
+ else
+ {
+ list ( $doc, $weight ) = array_values ( unpack ( "N*N*",
+ substr ( $response, $p, 8 ) ) );
+ $p += 8;
+ $doc = sphFixUint($doc);
+ }
+ $weight = sprintf ( "%u", $weight );
+
+ // create match entry
+ if ( $this->_arrayresult )
+ $result["matches"][$idx] = array ( "id"=>$doc, "weight"=>$weight );
+ else
+ $result["matches"][$doc]["weight"] = $weight;
+
+ // parse and create attributes
+ $attrvals = array ();
+ foreach ( $attrs as $attr=>$type )
+ {
+ // handle 64bit ints
+ if ( $type==SPH_ATTR_BIGINT )
+ {
+ $attrvals[$attr] = sphUnpackI64 ( substr ( $response, $p, 8 ) ); $p += 8;
+ continue;
+ }
+
+ // handle floats
+ if ( $type==SPH_ATTR_FLOAT )
+ {
+ list(,$uval) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
+ list(,$fval) = unpack ( "f*", pack ( "L", $uval ) );
+ $attrvals[$attr] = $fval;
+ continue;
+ }
+
+ // handle everything else as unsigned ints
+ list(,$val) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
+ if ( $type==SPH_ATTR_MULTI )
+ {
+ $attrvals[$attr] = array ();
+ $nvalues = $val;
+ while ( $nvalues-->0 && $p<$max )
+ {
+ list(,$val) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
+ $attrvals[$attr][] = sphFixUint($val);
+ }
+ } else if ( $type==SPH_ATTR_MULTI64 )
+ {
+ $attrvals[$attr] = array ();
+ $nvalues = $val;
+ while ( $nvalues>0 && $p<$max )
+ {
+ $attrvals[$attr][] = sphUnpackU64 ( substr ( $response, $p, 8 ) ); $p += 8;
+ $nvalues -= 2;
+ }
+ } else if ( $type==SPH_ATTR_STRING )
+ {
+ $attrvals[$attr] = substr ( $response, $p, $val );
+ $p += $val;
+ } else
+ {
+ $attrvals[$attr] = sphFixUint($val);
+ }
+ }
+
+ if ( $this->_arrayresult )
+ $result["matches"][$idx]["attrs"] = $attrvals;
+ else
+ $result["matches"][$doc]["attrs"] = $attrvals;
+ }
+
+ list ( $total, $total_found, $msecs, $words ) =
+ array_values ( unpack ( "N*N*N*N*", substr ( $response, $p, 16 ) ) );
+ $result["total"] = sprintf ( "%u", $total );
+ $result["total_found"] = sprintf ( "%u", $total_found );
+ $result["time"] = sprintf ( "%.3f", $msecs/1000 );
+ $p += 16;
+
+ while ( $words-->0 && $p<$max )
+ {
+ list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
+ $word = substr ( $response, $p, $len ); $p += $len;
+ list ( $docs, $hits ) = array_values ( unpack ( "N*N*", substr ( $response, $p, 8 ) ) ); $p += 8;
+ $result["words"][$word] = array (
+ "docs"=>sprintf ( "%u", $docs ),
+ "hits"=>sprintf ( "%u", $hits ) );
+ }
+ }
+
+ $this->_MBPop ();
+ return $results;
+ }
+
+ /////////////////////////////////////////////////////////////////////////////
+ // excerpts generation
+ /////////////////////////////////////////////////////////////////////////////
+
+ /// connect to searchd server, and generate exceprts (snippets)
+ /// of given documents for given query. returns false on failure,
+ /// an array of snippets on success
+ function BuildExcerpts ( $docs, $index, $words, $opts=array() )
+ {
+ assert ( is_array($docs) );
+ assert ( is_string($index) );
+ assert ( is_string($words) );
+ assert ( is_array($opts) );
+
+ $this->_MBPush ();
+
+ if (!( $fp = $this->_Connect() ))
+ {
+ $this->_MBPop();
+ return false;
+ }
+
+ /////////////////
+ // fixup options
+ /////////////////
+
+ if ( !isset($opts["before_match"]) ) $opts["before_match"] = "<b>";
+ if ( !isset($opts["after_match"]) ) $opts["after_match"] = "</b>";
+ if ( !isset($opts["chunk_separator"]) ) $opts["chunk_separator"] = " ... ";
+ if ( !isset($opts["limit"]) ) $opts["limit"] = 256;
+ if ( !isset($opts["limit_passages"]) ) $opts["limit_passages"] = 0;
+ if ( !isset($opts["limit_words"]) ) $opts["limit_words"] = 0;
+ if ( !isset($opts["around"]) ) $opts["around"] = 5;
+ if ( !isset($opts["exact_phrase"]) ) $opts["exact_phrase"] = false;
+ if ( !isset($opts["single_passage"]) ) $opts["single_passage"] = false;
+ if ( !isset($opts["use_boundaries"]) ) $opts["use_boundaries"] = false;
+ if ( !isset($opts["weight_order"]) ) $opts["weight_order"] = false;
+ if ( !isset($opts["query_mode"]) ) $opts["query_mode"] = false;
+ if ( !isset($opts["force_all_words"]) ) $opts["force_all_words"] = false;
+ if ( !isset($opts["start_passage_id"]) ) $opts["start_passage_id"] = 1;
+ if ( !isset($opts["load_files"]) ) $opts["load_files"] = false;
+ if ( !isset($opts["html_strip_mode"]) ) $opts["html_strip_mode"] = "index";
+ if ( !isset($opts["allow_empty"]) ) $opts["allow_empty"] = false;
+ if ( !isset($opts["passage_boundary"]) ) $opts["passage_boundary"] = "none";
+ if ( !isset($opts["emit_zones"]) ) $opts["emit_zones"] = false;
+ if ( !isset($opts["load_files_scattered"]) ) $opts["load_files_scattered"] = false;
+
+
+ /////////////////
+ // build request
+ /////////////////
+
+ // v.1.2 req
+ $flags = 1; // remove spaces
+ if ( $opts["exact_phrase"] ) $flags |= 2;
+ if ( $opts["single_passage"] ) $flags |= 4;
+ if ( $opts["use_boundaries"] ) $flags |= 8;
+ if ( $opts["weight_order"] ) $flags |= 16;
+ if ( $opts["query_mode"] ) $flags |= 32;
+ if ( $opts["force_all_words"] ) $flags |= 64;
+ if ( $opts["load_files"] ) $flags |= 128;
+ if ( $opts["allow_empty"] ) $flags |= 256;
+ if ( $opts["emit_zones"] ) $flags |= 512;
+ if ( $opts["load_files_scattered"] ) $flags |= 1024;
+ $req = pack ( "NN", 0, $flags ); // mode=0, flags=$flags
+ $req .= pack ( "N", strlen($index) ) . $index; // req index
+ $req .= pack ( "N", strlen($words) ) . $words; // req words
+
+ // options
+ $req .= pack ( "N", strlen($opts["before_match"]) ) . $opts["before_match"];
+ $req .= pack ( "N", strlen($opts["after_match"]) ) . $opts["after_match"];
+ $req .= pack ( "N", strlen($opts["chunk_separator"]) ) . $opts["chunk_separator"];
+ $req .= pack ( "NN", (int)$opts["limit"], (int)$opts["around"] );
+ $req .= pack ( "NNN", (int)$opts["limit_passages"], (int)$opts["limit_words"], (int)$opts["start_passage_id"] ); // v.1.2
+ $req .= pack ( "N", strlen($opts["html_strip_mode"]) ) . $opts["html_strip_mode"];
+ $req .= pack ( "N", strlen($opts["passage_boundary"]) ) . $opts["passage_boundary"];
+
+ // documents
+ $req .= pack ( "N", count($docs) );
+ foreach ( $docs as $doc )
+ {
+ assert ( is_string($doc) );
+ $req .= pack ( "N", strlen($doc) ) . $doc;
+ }
+
+ ////////////////////////////
+ // send query, get response
+ ////////////////////////////
+
+ $len = strlen($req);
+ $req = pack ( "nnN", SEARCHD_COMMAND_EXCERPT, VER_COMMAND_EXCERPT, $len ) . $req; // add header
+ if ( !( $this->_Send ( $fp, $req, $len+8 ) ) ||
+ !( $response = $this->_GetResponse ( $fp, VER_COMMAND_EXCERPT ) ) )
+ {
+ $this->_MBPop ();
+ return false;
+ }
+
+ //////////////////
+ // parse response
+ //////////////////
+
+ $pos = 0;
+ $res = array ();
+ $rlen = strlen($response);
+ for ( $i=0; $i<count($docs); $i++ )
+ {
+ list(,$len) = unpack ( "N*", substr ( $response, $pos, 4 ) );
+ $pos += 4;
+
+ if ( $pos+$len > $rlen )
+ {
+ $this->_error = "incomplete reply";
+ $this->_MBPop ();
+ return false;
+ }
+ $res[] = $len ? substr ( $response, $pos, $len ) : "";
+ $pos += $len;
+ }
+
+ $this->_MBPop ();
+ return $res;
+ }
+
+
+ /////////////////////////////////////////////////////////////////////////////
+ // keyword generation
+ /////////////////////////////////////////////////////////////////////////////
+
+ /// connect to searchd server, and generate keyword list for a given query
+ /// returns false on failure,
+ /// an array of words on success
+ function BuildKeywords ( $query, $index, $hits )
+ {
+ assert ( is_string($query) );
+ assert ( is_string($index) );
+ assert ( is_bool($hits) );
+
+ $this->_MBPush ();
+
+ if (!( $fp = $this->_Connect() ))
+ {
+ $this->_MBPop();
+ return false;
+ }
+
+ /////////////////
+ // build request
+ /////////////////
+
+ // v.1.0 req
+ $req = pack ( "N", strlen($query) ) . $query; // req query
+ $req .= pack ( "N", strlen($index) ) . $index; // req index
+ $req .= pack ( "N", (int)$hits );
+
+ ////////////////////////////
+ // send query, get response
+ ////////////////////////////
+
+ $len = strlen($req);
+ $req = pack ( "nnN", SEARCHD_COMMAND_KEYWORDS, VER_COMMAND_KEYWORDS, $len ) . $req; // add header
+ if ( !( $this->_Send ( $fp, $req, $len+8 ) ) ||
+ !( $response = $this->_GetResponse ( $fp, VER_COMMAND_KEYWORDS ) ) )
+ {
+ $this->_MBPop ();
+ return false;
+ }
+
+ //////////////////
+ // parse response
+ //////////////////
+
+ $pos = 0;
+ $res = array ();
+ $rlen = strlen($response);
+ list(,$nwords) = unpack ( "N*", substr ( $response, $pos, 4 ) );
+ $pos += 4;
+ for ( $i=0; $i<$nwords; $i++ )
+ {
+ list(,$len) = unpack ( "N*", substr ( $response, $pos, 4 ) ); $pos += 4;
+ $tokenized = $len ? substr ( $response, $pos, $len ) : "";
+ $pos += $len;
+
+ list(,$len) = unpack ( "N*", substr ( $response, $pos, 4 ) ); $pos += 4;
+ $normalized = $len ? substr ( $response, $pos, $len ) : "";
+ $pos += $len;
+
+ $res[] = array ( "tokenized"=>$tokenized, "normalized"=>$normalized );
+
+ if ( $hits )
+ {
+ list($ndocs,$nhits) = array_values ( unpack ( "N*N*", substr ( $response, $pos, 8 ) ) );
+ $pos += 8;
+ $res [$i]["docs"] = $ndocs;
+ $res [$i]["hits"] = $nhits;
+ }
+
+ if ( $pos > $rlen )
+ {
+ $this->_error = "incomplete reply";
+ $this->_MBPop ();
+ return false;
+ }
+ }
+
+ $this->_MBPop ();
+ return $res;
+ }
+
+ function EscapeString ( $string )
+ {
+ $from = array ( '\\', '(',')','|','-','!','@','~','"','&', '/', '^', '$', '=' );
+ $to = array ( '\\\\', '\(','\)','\|','\-','\!','\@','\~','\"', '\&', '\/', '\^', '\$', '\=' );
+
+ return str_replace ( $from, $to, $string );
+ }
+
+ /////////////////////////////////////////////////////////////////////////////
+ // attribute updates
+ /////////////////////////////////////////////////////////////////////////////
+
+ /// batch update given attributes in given rows in given indexes
+ /// returns amount of updated documents (0 or more) on success, or -1 on failure
+ function UpdateAttributes ( $index, $attrs, $values, $mva=false )
+ {
+ // verify everything
+ assert ( is_string($index) );
+ assert ( is_bool($mva) );
+
+ assert ( is_array($attrs) );
+ foreach ( $attrs as $attr )
+ assert ( is_string($attr) );
+
+ assert ( is_array($values) );
+ foreach ( $values as $id=>$entry )
+ {
+ assert ( is_numeric($id) );
+ assert ( is_array($entry) );
+ assert ( count($entry)==count($attrs) );
+ foreach ( $entry as $v )
+ {
+ if ( $mva )
+ {
+ assert ( is_array($v) );
+ foreach ( $v as $vv )
+ assert ( is_int($vv) );
+ } else
+ assert ( is_int($v) );
+ }
+ }
+
+ // build request
+ $this->_MBPush ();
+ $req = pack ( "N", strlen($index) ) . $index;
+
+ $req .= pack ( "N", count($attrs) );
+ foreach ( $attrs as $attr )
+ {
+ $req .= pack ( "N", strlen($attr) ) . $attr;
+ $req .= pack ( "N", $mva ? 1 : 0 );
+ }
+
+ $req .= pack ( "N", count($values) );
+ foreach ( $values as $id=>$entry )
+ {
+ $req .= sphPackU64 ( $id );
+ foreach ( $entry as $v )
+ {
+ $req .= pack ( "N", $mva ? count($v) : $v );
+ if ( $mva )
+ foreach ( $v as $vv )
+ $req .= pack ( "N", $vv );
+ }
+ }
+
+ // connect, send query, get response
+ if (!( $fp = $this->_Connect() ))
+ {
+ $this->_MBPop ();
+ return -1;
+ }
+
+ $len = strlen($req);
+ $req = pack ( "nnN", SEARCHD_COMMAND_UPDATE, VER_COMMAND_UPDATE, $len ) . $req; // add header
+ if ( !$this->_Send ( $fp, $req, $len+8 ) )
+ {
+ $this->_MBPop ();
+ return -1;
+ }
+
+ if (!( $response = $this->_GetResponse ( $fp, VER_COMMAND_UPDATE ) ))
+ {
+ $this->_MBPop ();
+ return -1;
+ }
+
+ // parse response
+ list(,$updated) = unpack ( "N*", substr ( $response, 0, 4 ) );
+ $this->_MBPop ();
+ return $updated;
+ }
+
+ /////////////////////////////////////////////////////////////////////////////
+ // persistent connections
+ /////////////////////////////////////////////////////////////////////////////
+
+ function Open()
+ {
+ if ( $this->_socket !== false )
+ {
+ $this->_error = 'already connected';
+ return false;
+ }
+ if ( !$fp = $this->_Connect() )
+ return false;
+
+ // command, command version = 0, body length = 4, body = 1
+ $req = pack ( "nnNN", SEARCHD_COMMAND_PERSIST, 0, 4, 1 );
+ if ( !$this->_Send ( $fp, $req, 12 ) )
+ return false;
+
+ $this->_socket = $fp;
+ return true;
+ }
+
+ function Close()
+ {
+ if ( $this->_socket === false )
+ {
+ $this->_error = 'not connected';
+ return false;
+ }
+
+ fclose ( $this->_socket );
+ $this->_socket = false;
+
+ return true;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // status
+ //////////////////////////////////////////////////////////////////////////
+
+ function Status ()
+ {
+ $this->_MBPush ();
+ if (!( $fp = $this->_Connect() ))
+ {
+ $this->_MBPop();
+ return false;
+ }
+
+ $req = pack ( "nnNN", SEARCHD_COMMAND_STATUS, VER_COMMAND_STATUS, 4, 1 ); // len=4, body=1
+ if ( !( $this->_Send ( $fp, $req, 12 ) ) ||
+ !( $response = $this->_GetResponse ( $fp, VER_COMMAND_STATUS ) ) )
+ {
+ $this->_MBPop ();
+ return false;
+ }
+
+ $res = substr ( $response, 4 ); // just ignore length, error handling, etc
+ $p = 0;
+ list ( $rows, $cols ) = array_values ( unpack ( "N*N*", substr ( $response, $p, 8 ) ) ); $p += 8;
+
+ $res = array();
+ for ( $i=0; $i<$rows; $i++ )
+ for ( $j=0; $j<$cols; $j++ )
+ {
+ list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4;
+ $res[$i][] = substr ( $response, $p, $len ); $p += $len;
+ }
+
+ $this->_MBPop ();
+ return $res;
+ }
+
+ //////////////////////////////////////////////////////////////////////////
+ // flush
+ //////////////////////////////////////////////////////////////////////////
+
+ function FlushAttributes ()
+ {
+ $this->_MBPush ();
+ if (!( $fp = $this->_Connect() ))
+ {
+ $this->_MBPop();
+ return -1;
+ }
+
+ $req = pack ( "nnN", SEARCHD_COMMAND_FLUSHATTRS, VER_COMMAND_FLUSHATTRS, 0 ); // len=0
+ if ( !( $this->_Send ( $fp, $req, 8 ) ) ||
+ !( $response = $this->_GetResponse ( $fp, VER_COMMAND_FLUSHATTRS ) ) )
+ {
+ $this->_MBPop ();
+ return -1;
+ }
+
+ $tag = -1;
+ if ( strlen($response)==4 )
+ list(,$tag) = unpack ( "N*", $response );
+ else
+ $this->_error = "unexpected response length";
+
+ $this->_MBPop ();
+ return $tag;
+ }
+}
+
+//
+// $Id: sphinxapi.php 3087 2012-01-30 23:07:35Z shodan $
+//
diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php
index 22e0f1d67a..6b7cd31cb3 100644
--- a/phpBB/includes/style/style.php
+++ b/phpBB/includes/style/style.php
@@ -38,7 +38,7 @@ class phpbb_style
* PHP file extension
* @var string
*/
- private $phpEx;
+ private $php_ext;
/**
* phpBB config instance
@@ -73,10 +73,10 @@ class phpbb_style
* @param phpbb_style_path_provider $provider style path provider
* @param phpbb_template $template template
*/
- public function __construct($phpbb_root_path, $phpEx, $config, $user, phpbb_style_resource_locator $locator, phpbb_style_path_provider_interface $provider, phpbb_template $template)
+ public function __construct($phpbb_root_path, $php_ext, $config, $user, phpbb_style_resource_locator $locator, phpbb_style_path_provider_interface $provider, phpbb_template $template)
{
$this->phpbb_root_path = $phpbb_root_path;
- $this->phpEx = $phpEx;
+ $this->php_ext = $php_ext;
$this->config = $config;
$this->user = $user;
$this->locator = $locator;
diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php
index ad2e35de6a..abee32c8f7 100644
--- a/phpBB/includes/template/filter.php
+++ b/phpBB/includes/template/filter.php
@@ -209,7 +209,7 @@ class phpbb_template_filter extends php_user_filter
*/
- $data = preg_replace('~(?<!^)(<\?php(?:(?<!\?>).)+(?<!/\*\*/)\?>)$~m', "$1\n", $data);
+ $data = preg_replace('~(?<!^)(<\?php.+(?<!/\*\*/)\?>)$~m', "$1\n", $data);
$data = str_replace('/**/?>', "?>\n", $data);
$data = str_replace('?><?php', '', $data);
return $data;
diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php
index 8ab3c44be3..b7c3e00dee 100644
--- a/phpBB/includes/template/template.php
+++ b/phpBB/includes/template/template.php
@@ -54,7 +54,7 @@ class phpbb_template
* PHP file extension
* @var string
*/
- private $phpEx;
+ private $php_ext;
/**
* phpBB config instance
@@ -87,10 +87,10 @@ class phpbb_template
* @param user $user current user
* @param phpbb_template_locator $locator template locator
*/
- public function __construct($phpbb_root_path, $phpEx, $config, $user, phpbb_template_locator $locator)
+ public function __construct($phpbb_root_path, $php_ext, $config, $user, phpbb_template_locator $locator)
{
$this->phpbb_root_path = $phpbb_root_path;
- $this->phpEx = $phpEx;
+ $this->php_ext = $php_ext;
$this->config = $config;
$this->user = $user;
$this->locator = $locator;
@@ -139,7 +139,7 @@ class phpbb_template
*/
public function display($handle)
{
- $result = $this->call_hook($handle);
+ $result = $this->call_hook($handle, __FUNCTION__);
if ($result !== false)
{
return $result[0];
@@ -174,16 +174,17 @@ class phpbb_template
* Calls hook if any is defined.
*
* @param string $handle Template handle being displayed.
+ * @param string $method Method name of the caller.
*/
- private function call_hook($handle)
+ private function call_hook($handle, $method)
{
global $phpbb_hook;
- if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, __FUNCTION__), $handle, $this))
+ if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, $method), $handle, $this))
{
- if ($phpbb_hook->hook_return(array(__CLASS__, __FUNCTION__)))
+ if ($phpbb_hook->hook_return(array(__CLASS__, $method)))
{
- $result = $phpbb_hook->hook_return_result(array(__CLASS__, __FUNCTION__));
+ $result = $phpbb_hook->hook_return_result(array(__CLASS__, $method));
return array($result);
}
}
@@ -313,7 +314,7 @@ class phpbb_template
private function _compiled_file_for_handle($handle)
{
$source_file = $this->locator->get_filename_for_handle($handle);
- $compiled_file = $this->cachepath . str_replace('/', '.', $source_file) . '.' . $this->phpEx;
+ $compiled_file = $this->cachepath . str_replace('/', '.', $source_file) . '.' . $this->php_ext;
return $compiled_file;
}
diff --git a/phpBB/includes/ucp/ucp_attachments.php b/phpBB/includes/ucp/ucp_attachments.php
index 836185f105..e4c351709b 100644
--- a/phpBB/includes/ucp/ucp_attachments.php
+++ b/phpBB/includes/ucp/ucp_attachments.php
@@ -170,9 +170,11 @@ class ucp_attachments
}
$db->sql_freeresult($result);
+ $base_url = $this->u_action . "&amp;sk=$sort_key&amp;sd=$sort_dir";
+ phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $num_attachments, $config['topics_per_page'], $start);
+
$template->assign_vars(array(
- 'PAGE_NUMBER' => on_page($num_attachments, $config['topics_per_page'], $start),
- 'PAGINATION' => generate_pagination($this->u_action . "&amp;sk=$sort_key&amp;sd=$sort_dir", $num_attachments, $config['topics_per_page'], $start),
+ 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $num_attachments, $config['topics_per_page'], $start),
'TOTAL_ATTACHMENTS' => $num_attachments,
'L_TITLE' => $user->lang['UCP_ATTACHMENTS'],
diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php
index a7c6479759..65ab92e78e 100644
--- a/phpBB/includes/ucp/ucp_groups.php
+++ b/phpBB/includes/ucp/ucp_groups.php
@@ -844,11 +844,13 @@ class ucp_groups
$s_action_options .= '<option value="' . $option . '">' . $user->lang['GROUP_' . $lang] . '</option>';
}
+ $base_url = $this->u_action . "&amp;action=$action&amp;g=$group_id";
+ phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total_members, $config['topics_per_page'], $start);
+
$template->assign_vars(array(
'S_LIST' => true,
'S_ACTION_OPTIONS' => $s_action_options,
- 'S_ON_PAGE' => on_page($total_members, $config['topics_per_page'], $start),
- 'PAGINATION' => generate_pagination($this->u_action . "&amp;action=$action&amp;g=$group_id", $total_members, $config['topics_per_page'], $start),
+ 'S_ON_PAGE' => phpbb_on_page($template, $user, $base_url, $total_members, $config['topics_per_page'], $start),
'U_ACTION' => $this->u_action . "&amp;g=$group_id",
'S_UCP_ACTION' => $this->u_action . "&amp;g=$group_id",
@@ -1067,7 +1069,8 @@ class ucp_groups
'mode' => $mode,
'action' => $action
);
- confirm_box(false, $user->lang('GROUP_CONFIRM_ADD_USERS', sizeof($name_ary), implode(', ', $name_ary)), build_hidden_fields($s_hidden_fields));
+
+ confirm_box(false, $user->lang('GROUP_CONFIRM_ADD_USERS', sizeof($name_ary), implode($user->lang['COMMA_SEPARATOR'], $name_ary)), build_hidden_fields($s_hidden_fields));
}
trigger_error($user->lang['NO_USERS_ADDED'] . '<br /><br />' . sprintf($user->lang['RETURN_PAGE'], '<a href="' . $this->u_action . '&amp;action=list&amp;g=' . $group_id . '">', '</a>'));
diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php
index 00b7b55f27..94fd59433b 100644
--- a/phpBB/includes/ucp/ucp_main.php
+++ b/phpBB/includes/ucp/ucp_main.php
@@ -69,17 +69,16 @@ class ucp_main
// Get cleaned up list... return only those forums having the f_read permission
$forum_ary = $auth->acl_getf('f_read', true);
$forum_ary = array_unique(array_keys($forum_ary));
-
- $sql = "SELECT t.* $sql_select
- FROM $sql_from
- WHERE t.topic_type = " . POST_GLOBAL . '
- AND ' . $db->sql_in_set('t.forum_id', $forum_ary) . '
- ORDER BY t.topic_last_post_time DESC';
-
$topic_list = $rowset = array();
+
// If the user can't see any forums, he can't read any posts because fid of 0 is invalid
if (!empty($forum_ary))
{
+ $sql = "SELECT t.* $sql_select
+ FROM $sql_from
+ WHERE t.topic_type = " . POST_GLOBAL . '
+ AND ' . $db->sql_in_set('t.forum_id', $forum_ary) . '
+ ORDER BY t.topic_last_post_time DESC';
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
@@ -670,9 +669,10 @@ class ucp_main
if ($topics_count)
{
+ phpbb_generate_template_pagination($template, $this->u_action, 'pagination', 'start', $topics_count, $config['topics_per_page'], $start);
+
$template->assign_vars(array(
- 'PAGINATION' => generate_pagination($this->u_action, $topics_count, $config['topics_per_page'], $start),
- 'PAGE_NUMBER' => on_page($topics_count, $config['topics_per_page'], $start),
+ 'PAGE_NUMBER' => phpbb_on_page($template, $user, $this->u_action, $topics_count, $config['topics_per_page'], $start),
'TOTAL_TOPICS' => $user->lang('VIEW_FORUM_TOPICS', (int) $topics_count),
));
}
@@ -813,7 +813,6 @@ class ucp_main
'S_DELETED_TOPIC' => (!$row['topic_id']) ? true : false,
- 'PAGINATION' => topic_generate_pagination($replies, append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . "&amp;t=$topic_id")),
'REPLIES' => $replies,
'VIEWS' => $row['topic_views'],
'TOPIC_TITLE' => censor_text($row['topic_title']),
@@ -837,6 +836,8 @@ class ucp_main
'U_VIEW_TOPIC' => $view_topic_url,
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
));
+
+ phpbb_generate_template_pagination($template, append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $row['forum_id'] . "&amp;t=$topic_id"), 'topicrow.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true);
}
}
}
diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php
index 1b474457b3..d8bcd374fe 100644
--- a/phpBB/includes/ucp/ucp_pm_compose.php
+++ b/phpBB/includes/ucp/ucp_pm_compose.php
@@ -874,7 +874,7 @@ function compose_pm($id, $mode, $action, $user_folders = array())
$forward_text[] = sprintf($user->lang['FWD_SUBJECT'], censor_text($message_subject));
$forward_text[] = sprintf($user->lang['FWD_DATE'], $user->format_date($message_time, false, true));
$forward_text[] = sprintf($user->lang['FWD_FROM'], $quote_username_text);
- $forward_text[] = sprintf($user->lang['FWD_TO'], implode(', ', $fwd_to_field['to']));
+ $forward_text[] = sprintf($user->lang['FWD_TO'], implode($user->lang['COMMA_SEPARATOR'], $fwd_to_field['to']));
$message_parser->message = implode("\n", $forward_text) . "\n\n[quote=&quot;{$quote_username}&quot;]\n" . censor_text(trim($message_parser->message)) . "\n[/quote]";
$message_subject = ((!preg_match('/^Fwd:/', $message_subject)) ? 'Fwd: ' : '') . censor_text($message_subject);
diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php
index 8b1cd419f4..1026f24699 100644
--- a/phpBB/includes/ucp/ucp_pm_viewfolder.php
+++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php
@@ -176,7 +176,7 @@ function view_folder($id, $mode, $folder_id, $folder)
'U_VIEW_PM' => ($row['pm_deleted']) ? '' : $view_message_url,
'U_REMOVE_PM' => ($row['pm_deleted']) ? $remove_message_url : '',
'U_MCP_REPORT' => (isset($row['report_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports&amp;mode=pm_report_details&amp;r=' . $row['report_id']) : '',
- 'RECIPIENTS' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? implode(', ', $address_list[$message_id]) : '')
+ 'RECIPIENTS' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? implode($user->lang['COMMA_SEPARATOR'], $address_list[$message_id]) : '')
);
}
unset($folder_info['rowset']);
@@ -266,9 +266,9 @@ function view_folder($id, $mode, $folder_id, $folder)
}
}
- // There is the chance that all recipients of the message got deleted. To avoid creating
+ // There is the chance that all recipients of the message got deleted. To avoid creating
// exports without recipients, we add a bogus "undisclosed recipient".
- if (!(isset($address[$message_id]['g']) && sizeof($address[$message_id]['g'])) &&
+ if (!(isset($address[$message_id]['g']) && sizeof($address[$message_id]['g'])) &&
!(isset($address[$message_id]['u']) && sizeof($address[$message_id]['u'])))
{
$address[$message_id]['u'] = array();
@@ -277,7 +277,7 @@ function view_folder($id, $mode, $folder_id, $folder)
}
decode_message($message_row['message_text'], $message_row['bbcode_uid']);
-
+
$data[] = array(
'subject' => censor_text($row['message_subject']),
'sender' => $row['username'],
@@ -451,9 +451,11 @@ function get_pm_from($folder_id, $folder, $user_id)
$sql_limit_time = '';
}
+ $base_url = append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&amp;mode=view&amp;action=view_folder&amp;f=$folder_id&amp;$u_sort_param");
+ phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $pm_count, $config['topics_per_page'], $start);
+
$template->assign_vars(array(
- 'PAGINATION' => generate_pagination(append_sid("{$phpbb_root_path}ucp.$phpEx", "i=pm&amp;mode=view&amp;action=view_folder&amp;f=$folder_id&amp;$u_sort_param"), $pm_count, $config['topics_per_page'], $start),
- 'PAGE_NUMBER' => on_page($pm_count, $config['topics_per_page'], $start),
+ 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $pm_count, $config['topics_per_page'], $start),
'TOTAL_MESSAGES' => $user->lang('VIEW_PM_MESSAGES', (int) $pm_count),
'POST_IMG' => (!$auth->acl_get('u_sendpm')) ? $user->img('button_topic_locked', 'POST_PM_LOCKED') : $user->img('button_pm_new', 'POST_NEW_PM'),
diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php
index c55e8850a6..c85b05f144 100644
--- a/phpBB/includes/ucp/ucp_pm_viewmessage.php
+++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php
@@ -21,7 +21,7 @@ if (!defined('IN_PHPBB'))
function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
{
global $user, $template, $auth, $db, $cache;
- global $phpbb_root_path, $request, $phpEx, $config;
+ global $phpbb_root_path, $request, $phpEx, $config, $phpbb_dispatcher;
$user->add_lang(array('viewtopic', 'memberlist'));
@@ -204,7 +204,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
}
}
- $template->assign_vars(array(
+ $msg_data = array(
'MESSAGE_AUTHOR_FULL' => get_username_string('full', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']),
'MESSAGE_AUTHOR_COLOUR' => get_username_string('colour', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']),
'MESSAGE_AUTHOR' => get_username_string('username', $author_id, $user_info['username'], $user_info['user_colour'], $user_info['username']),
@@ -257,6 +257,7 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
'U_PM_ACTION' => $url . '&amp;mode=compose&amp;f=' . $folder_id . '&amp;p=' . $message_row['msg_id'],
'S_HAS_ATTACHMENTS' => (sizeof($attachments)) ? true : false,
+ 'S_HAS_MULTIPLE_ATTACHMENTS' => (sizeof($attachments) > 1),
'S_DISPLAY_NOTICE' => $display_notice && $message_row['message_attachment'],
'S_AUTHOR_DELETED' => ($author_id == ANONYMOUS) ? true : false,
'S_SPECIAL_FOLDER' => in_array($folder_id, array(PRIVMSGS_NO_BOX, PRIVMSGS_OUTBOX)),
@@ -265,9 +266,28 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
'S_CUSTOM_FIELDS' => (!empty($cp_row['row'])) ? true : false,
'U_PRINT_PM' => ($config['print_pm'] && $auth->acl_get('u_pm_printpm')) ? "$url&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] . "&amp;view=print" : '',
- 'U_FORWARD_PM' => ($config['forward_pm'] && $auth->acl_get('u_sendpm') && $auth->acl_get('u_pm_forward')) ? "$url&amp;mode=compose&amp;action=forward&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] : '')
+ 'U_FORWARD_PM' => ($config['forward_pm'] && $auth->acl_get('u_sendpm') && $auth->acl_get('u_pm_forward')) ? "$url&amp;mode=compose&amp;action=forward&amp;f=$folder_id&amp;p=" . $message_row['msg_id'] : '',
);
+ /**
+ * Modify pm and sender data before it is assigned to the template
+ *
+ * @event core.ucp_pm_view_messsage
+ * @var mixed id Active module category (can be int or string)
+ * @var string mode Active module
+ * @var int folder_id ID of the folder the message is in
+ * @var int msg_id ID of the private message
+ * var array folder Array with data of user's message folders
+ * @var array message_row Array with message data
+ * @var array cp_row Array with senders custom profile field data
+ * @var array msg_data Template array with message data
+ * @since 3.1-A1
+ */
+ $vars = array('id', 'mode', 'folder_id', 'msg_id', 'folder', 'message_row', 'cp_row', 'msg_data');
+ extract($phpbb_dispatcher->trigger_event('core.ucp_pm_view_messsage', compact($vars)));
+
+ $template->assign_vars($msg_data);
+
// Display the custom profile fields
if (!empty($cp_row['row']))
{
@@ -282,6 +302,12 @@ function view_message($id, $mode, $folder_id, $msg_id, $folder, $message_row)
// Display not already displayed Attachments for this post, we already parsed them. ;)
if (isset($attachments) && sizeof($attachments))
{
+ $methods = phpbb_gen_download_links('post_msg_id', $msg_id, $phpbb_root_path, $phpEx);
+ foreach ($methods as $method)
+ {
+ $template->assign_block_vars('dl_method', $method);
+ }
+
foreach ($attachments as $attachment)
{
$template->assign_block_vars('attachment', array(
diff --git a/phpBB/includes/ucp/ucp_prefs.php b/phpBB/includes/ucp/ucp_prefs.php
index 0c9f20f266..2228bc7931 100644
--- a/phpBB/includes/ucp/ucp_prefs.php
+++ b/phpBB/includes/ucp/ucp_prefs.php
@@ -41,9 +41,8 @@ class ucp_prefs
'dateformat' => request_var('dateformat', $user->data['user_dateformat'], true),
'lang' => basename(request_var('lang', $user->data['user_lang'])),
'style' => request_var('style', (int) $user->data['user_style']),
- 'tz' => request_var('tz', (float) $user->data['user_timezone']),
+ 'tz' => request_var('tz', $user->data['user_timezone']),
- 'dst' => request_var('dst', (bool) $user->data['user_dst']),
'viewemail' => request_var('viewemail', (bool) $user->data['user_allow_viewemail']),
'massemail' => request_var('massemail', (bool) $user->data['user_allow_massemail']),
'hideonline' => request_var('hideonline', (bool) !$user->data['user_allow_viewonline']),
@@ -72,7 +71,7 @@ class ucp_prefs
$error = validate_data($data, array(
'dateformat' => array('string', false, 1, 30),
'lang' => array('language_iso_name'),
- 'tz' => array('num', false, -14, 14),
+ 'tz' => array('timezone'),
));
if (!check_form_key('ucp_prefs_personal'))
@@ -93,7 +92,6 @@ class ucp_prefs
'user_notify_pm' => $data['notifypm'],
'user_options' => $user->data['user_options'],
- 'user_dst' => $data['dst'],
'user_dateformat' => $data['dateformat'],
'user_lang' => $data['lang'],
'user_timezone' => $data['tz'],
@@ -133,6 +131,7 @@ class ucp_prefs
}
$dateformat_options .= '>' . $user->lang['CUSTOM_DATEFORMAT'] . '</option>';
+ $timezone_selects = phpbb_timezone_select($user, $data['tz'], true);
$template->assign_vars(array(
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
@@ -145,7 +144,6 @@ class ucp_prefs
'S_HIDE_ONLINE' => $data['hideonline'],
'S_NOTIFY_PM' => $data['notifypm'],
'S_POPUP_PM' => $data['popuppm'],
- 'S_DST' => $data['dst'],
'DATE_FORMAT' => $data['dateformat'],
'A_DATE_FORMAT' => addslashes($data['dateformat']),
@@ -156,7 +154,8 @@ class ucp_prefs
'S_LANG_OPTIONS' => language_select($data['lang']),
'S_STYLE_OPTIONS' => ($config['override_user_style']) ? '' : style_select($data['style']),
- 'S_TZ_OPTIONS' => tz_select($data['tz'], true),
+ 'S_TZ_OPTIONS' => $timezone_selects['tz_select'],
+ 'S_TZ_DATE_OPTIONS' => $timezone_selects['tz_dates'],
'S_CAN_HIDE_ONLINE' => ($auth->acl_get('u_hideonline')) ? true : false,
'S_SELECT_NOTIFY' => ($config['jab_enable'] && $user->data['user_jabber'] && @extension_loaded('xml')) ? true : false)
);
diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php
index 2ac82fb52f..89bf20a30f 100644
--- a/phpBB/includes/ucp/ucp_profile.php
+++ b/phpBB/includes/ucp/ucp_profile.php
@@ -46,9 +46,9 @@ class ucp_profile
$data = array(
'username' => utf8_normalize_nfc(request_var('username', $user->data['username'], true)),
'email' => strtolower(request_var('email', $user->data['user_email'])),
- 'new_password' => request_var('new_password', '', true),
- 'cur_password' => request_var('cur_password', '', true),
- 'password_confirm' => request_var('password_confirm', '', true),
+ 'new_password' => $request->variable('new_password', '', true),
+ 'cur_password' => $request->variable('cur_password', '', true),
+ 'password_confirm' => $request->variable('password_confirm', '', true),
);
add_form_key('ucp_reg_details');
diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php
index 5d85029e62..c57aec00a0 100644
--- a/phpBB/includes/ucp/ucp_register.php
+++ b/phpBB/includes/ucp/ucp_register.php
@@ -100,7 +100,7 @@ class ucp_register
'username' => utf8_normalize_nfc(request_var('username', '', true)),
'email' => strtolower(request_var('email', '')),
'lang' => $user->lang_name,
- 'tz' => request_var('tz', (float) $config['board_timezone']),
+ 'tz' => request_var('tz', $config['board_timezone']),
));
}
@@ -120,7 +120,10 @@ class ucp_register
if ($coppa === false && $config['coppa_enable'])
{
$now = getdate();
- $coppa_birthday = $user->format_date(mktime($now['hours'] + $user->data['user_dst'], $now['minutes'], $now['seconds'], $now['mon'], $now['mday'] - 1, $now['year'] - 13), $user->lang['DATE_FORMAT']);
+ $coppa_birthday = $user->create_datetime()
+ ->setDate($now['year'] - 13, $now['mon'], $now['mday'] - 1)
+ ->setTime(0, 0, 0)
+ ->format($user->lang['DATE_FORMAT'], true);
unset($now);
$template->assign_vars(array(
@@ -163,16 +166,15 @@ class ucp_register
$captcha->init(CONFIRM_REG);
}
- $is_dst = $config['board_dst'];
$timezone = $config['board_timezone'];
$data = array(
'username' => utf8_normalize_nfc(request_var('username', '', true)),
- 'new_password' => request_var('new_password', '', true),
- 'password_confirm' => request_var('password_confirm', '', true),
+ 'new_password' => $request->variable('new_password', '', true),
+ 'password_confirm' => $request->variable('password_confirm', '', true),
'email' => strtolower(request_var('email', '')),
'lang' => basename(request_var('lang', $user->lang_name)),
- 'tz' => request_var('tz', (float) $timezone),
+ 'tz' => request_var('tz', $timezone),
);
// Check and initialize some variables if needed
@@ -189,7 +191,7 @@ class ucp_register
'email' => array(
array('string', false, 6, 60),
array('email')),
- 'tz' => array('num', false, -14, 14),
+ 'tz' => array('timezone'),
'lang' => array('language_iso_name'),
));
@@ -279,8 +281,7 @@ class ucp_register
'user_password' => phpbb_hash($data['new_password']),
'user_email' => $data['email'],
'group_id' => (int) $group_id,
- 'user_timezone' => (float) $data['tz'],
- 'user_dst' => $is_dst,
+ 'user_timezone' => $data['tz'],
'user_lang' => $data['lang'],
'user_type' => $user_type,
'user_actkey' => $user_actkey,
@@ -441,6 +442,7 @@ class ucp_register
break;
}
+ $timezone_selects = phpbb_timezone_select($user, $data['tz'], true);
$template->assign_vars(array(
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
'USERNAME' => $data['username'],
@@ -453,7 +455,8 @@ class ucp_register
'L_PASSWORD_EXPLAIN' => $user->lang($config['pass_complex'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_pass_chars']), $user->lang('CHARACTERS', (int) $config['max_pass_chars'])),
'S_LANG_OPTIONS' => language_select($data['lang']),
- 'S_TZ_OPTIONS' => tz_select($data['tz']),
+ 'S_TZ_OPTIONS' => $timezone_selects['tz_select'],
+ 'S_TZ_DATE_OPTIONS' => $timezone_selects['tz_dates'],
'S_CONFIRM_REFRESH' => ($config['enable_confirm'] && $config['confirm_refresh']) ? true : false,
'S_REGISTRATION' => true,
'S_COPPA' => $coppa,
diff --git a/phpBB/includes/ucp/ucp_zebra.php b/phpBB/includes/ucp/ucp_zebra.php
index efe928b387..a669c450a4 100644
--- a/phpBB/includes/ucp/ucp_zebra.php
+++ b/phpBB/includes/ucp/ucp_zebra.php
@@ -25,7 +25,7 @@ class ucp_zebra
function main($id, $mode)
{
- global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx, $request;
+ global $config, $db, $user, $auth, $template, $phpbb_root_path, $phpEx, $request, $phpbb_dispatcher;
$submit = (isset($_POST['submit']) || isset($_GET['add']) || isset($_GET['remove'])) ? true : false;
$s_hidden_fields = '';
@@ -54,9 +54,22 @@ class ucp_zebra
// Remove users
if (!empty($data['usernames']))
{
+ $user_ids = $data['usernames'];
+
+ /**
+ * Remove users from friends/foes
+ *
+ * @event core.ucp_remove_zebra
+ * @var string mode Zebra type: friends|foes
+ * @var array user_ids User ids we remove
+ * @since 3.1-A1
+ */
+ $vars = array('user_ids');
+ extract($phpbb_dispatcher->trigger_event('core.ucp_remove_zebra', compact($vars)));
+
$sql = 'DELETE FROM ' . ZEBRA_TABLE . '
WHERE user_id = ' . $user->data['user_id'] . '
- AND ' . $db->sql_in_set('zebra_id', $data['usernames']);
+ AND ' . $db->sql_in_set('zebra_id', $user_ids);
$db->sql_query($sql);
$updated = true;
@@ -186,6 +199,19 @@ class ucp_zebra
);
}
+ /**
+ * Add users to friends/foes
+ *
+ * @event core.ucp_add_zebra
+ * @var string mode Zebra type:
+ * friends|foes
+ * @var array sql_ary Array of
+ * entries we add
+ * @since 3.1-A1
+ */
+ $vars = array('mode', 'sql_ary');
+ extract($phpbb_dispatcher->trigger_event('core.ucp_add_zebra', compact($vars)));
+
$db->sql_multi_insert(ZEBRA_TABLE, $sql_ary);
$updated = true;
diff --git a/phpBB/includes/update_helpers.php b/phpBB/includes/update_helpers.php
new file mode 100644
index 0000000000..69d678b2f8
--- /dev/null
+++ b/phpBB/includes/update_helpers.php
@@ -0,0 +1,112 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*/
+
+/**
+* phpBB Update Helpers
+*/
+class phpbb_update_helpers
+{
+ /**
+ * Determine the new timezone for a given phpBB 3.0 timezone and
+ * "Daylight Saving Time" option
+ *
+ * @param $timezone float Users timezone in 3.0
+ * @param $dst int Users daylight saving time
+ * @return string Users new php Timezone which is used since 3.1
+ */
+ function convert_phpbb30_timezone($timezone, $dst)
+ {
+ $offset = $timezone + $dst;
+
+ switch ($timezone)
+ {
+ case '-12':
+ return 'Etc/GMT+' . abs($offset); //'[UTC - 12] Baker Island Time'
+ case '-11':
+ return 'Etc/GMT+' . abs($offset); //'[UTC - 11] Niue Time, Samoa Standard Time'
+ case '-10':
+ return 'Etc/GMT+' . abs($offset); //'[UTC - 10] Hawaii-Aleutian Standard Time, Cook Island Time'
+ case '-9.5':
+ return 'Pacific/Marquesas'; //'[UTC - 9:30] Marquesas Islands Time'
+ case '-9':
+ return 'Etc/GMT+' . abs($offset); //'[UTC - 9] Alaska Standard Time, Gambier Island Time'
+ case '-8':
+ return 'Etc/GMT+' . abs($offset); //'[UTC - 8] Pacific Standard Time'
+ case '-7':
+ return 'Etc/GMT+' . abs($offset); //'[UTC - 7] Mountain Standard Time'
+ case '-6':
+ return 'Etc/GMT+' . abs($offset); //'[UTC - 6] Central Standard Time'
+ case '-5':
+ return 'Etc/GMT+' . abs($offset); //'[UTC - 5] Eastern Standard Time'
+ case '-4.5':
+ return 'America/Caracas'; //'[UTC - 4:30] Venezuelan Standard Time'
+ case '-4':
+ return 'Etc/GMT+' . abs($offset); //'[UTC - 4] Atlantic Standard Time'
+ case '-3.5':
+ return 'America/St_Johns'; //'[UTC - 3:30] Newfoundland Standard Time'
+ case '-3':
+ return 'Etc/GMT+' . abs($offset); //'[UTC - 3] Amazon Standard Time, Central Greenland Time'
+ case '-2':
+ return 'Etc/GMT+' . abs($offset); //'[UTC - 2] Fernando de Noronha Time, South Georgia &amp; the South Sandwich Islands Time'
+ case '-1':
+ return 'Etc/GMT+' . abs($offset); //'[UTC - 1] Azores Standard Time, Cape Verde Time, Eastern Greenland Time'
+ case '0':
+ return (!$dst) ? 'UTC' : 'Etc/GMT-1'; //'[UTC] Western European Time, Greenwich Mean Time'
+ case '1':
+ return 'Etc/GMT-' . $offset; //'[UTC + 1] Central European Time, West African Time'
+ case '2':
+ return 'Etc/GMT-' . $offset; //'[UTC + 2] Eastern European Time, Central African Time'
+ case '3':
+ return 'Etc/GMT-' . $offset; //'[UTC + 3] Moscow Standard Time, Eastern African Time'
+ case '3.5':
+ return 'Asia/Tehran'; //'[UTC + 3:30] Iran Standard Time'
+ case '4':
+ return 'Etc/GMT-' . $offset; //'[UTC + 4] Gulf Standard Time, Samara Standard Time'
+ case '4.5':
+ return 'Asia/Kabul'; //'[UTC + 4:30] Afghanistan Time'
+ case '5':
+ return 'Etc/GMT-' . $offset; //'[UTC + 5] Pakistan Standard Time, Yekaterinburg Standard Time'
+ case '5.5':
+ return 'Asia/Kolkata'; //'[UTC + 5:30] Indian Standard Time, Sri Lanka Time'
+ case '5.75':
+ return 'Asia/Kathmandu'; //'[UTC + 5:45] Nepal Time'
+ case '6':
+ return 'Etc/GMT-' . $offset; //'[UTC + 6] Bangladesh Time, Bhutan Time, Novosibirsk Standard Time'
+ case '6.5':
+ return 'Indian/Cocos'; //'[UTC + 6:30] Cocos Islands Time, Myanmar Time'
+ case '7':
+ return 'Etc/GMT-' . $offset; //'[UTC + 7] Indochina Time, Krasnoyarsk Standard Time'
+ case '8':
+ return 'Etc/GMT-' . $offset; //'[UTC + 8] Chinese Standard Time, Australian Western Standard Time, Irkutsk Standard Time'
+ case '8.75':
+ return 'Australia/Eucla'; //'[UTC + 8:45] Southeastern Western Australia Standard Time'
+ case '9':
+ return 'Etc/GMT-' . $offset; //'[UTC + 9] Japan Standard Time, Korea Standard Time, Chita Standard Time'
+ case '9.5':
+ return 'Australia/ACT'; //'[UTC + 9:30] Australian Central Standard Time'
+ case '10':
+ return 'Etc/GMT-' . $offset; //'[UTC + 10] Australian Eastern Standard Time, Vladivostok Standard Time'
+ case '10.5':
+ return 'Australia/Lord_Howe'; //'[UTC + 10:30] Lord Howe Standard Time'
+ case '11':
+ return 'Etc/GMT-' . $offset; //'[UTC + 11] Solomon Island Time, Magadan Standard Time'
+ case '11.5':
+ return 'Pacific/Norfolk'; //'[UTC + 11:30] Norfolk Island Time'
+ case '12':
+ return 'Etc/GMT-12'; //'[UTC + 12] New Zealand Time, Fiji Time, Kamchatka Standard Time'
+ case '12.75':
+ return 'Pacific/Chatham'; //'[UTC + 12:45] Chatham Islands Time'
+ case '13':
+ return 'Pacific/Tongatapu'; //'[UTC + 13] Tonga Time, Phoenix Islands Time'
+ case '14':
+ return 'Pacific/Kiritimati'; //'[UTC + 14] Line Island Time'
+ default:
+ return 'UTC';
+ }
+ }
+}
diff --git a/phpBB/includes/user.php b/phpBB/includes/user.php
index cf9e6b9994..93557f3558 100644
--- a/phpBB/includes/user.php
+++ b/phpBB/includes/user.php
@@ -29,8 +29,11 @@ class phpbb_user extends phpbb_session
var $help = array();
var $style = array();
var $date_format;
- var $timezone;
- var $dst;
+
+ /**
+ * DateTimeZone object holding the timezone of the user
+ */
+ public $timezone;
var $lang_name = false;
var $lang_id = false;
@@ -73,21 +76,19 @@ class phpbb_user extends phpbb_session
function setup($lang_set = false, $style_id = false)
{
global $db, $phpbb_style, $template, $config, $auth, $phpEx, $phpbb_root_path, $cache;
+ global $phpbb_dispatcher;
if ($this->data['user_id'] != ANONYMOUS)
{
- $this->lang_name = (file_exists($this->lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']);
-
- $this->date_format = $this->data['user_dateformat'];
- $this->timezone = $this->data['user_timezone'] * 3600;
- $this->dst = $this->data['user_dst'] * 3600;
+ $user_lang_name = (file_exists($this->lang_path . $this->data['user_lang'] . "/common.$phpEx")) ? $this->data['user_lang'] : basename($config['default_lang']);
+ $user_date_format = $this->data['user_dateformat'];
+ $user_timezone = $this->data['user_timezone'];
}
else
{
- $this->lang_name = basename($config['default_lang']);
- $this->date_format = $config['default_dateformat'];
- $this->timezone = $config['board_timezone'] * 3600;
- $this->dst = $config['board_dst'] * 3600;
+ $user_lang_name = basename($config['default_lang']);
+ $user_date_format = $config['default_dateformat'];
+ $user_timezone = $config['board_timezone'];
/**
* If a guest user is surfing, we try to guess his/her language first by obtaining the browser language
@@ -106,7 +107,7 @@ class phpbb_user extends phpbb_session
if (file_exists($this->lang_path . $accept_lang . "/common.$phpEx"))
{
- $this->lang_name = $config['default_lang'] = $accept_lang;
+ $user_lang_name = $config['default_lang'] = $accept_lang;
break;
}
else
@@ -117,7 +118,7 @@ class phpbb_user extends phpbb_session
if (file_exists($this->lang_path . $accept_lang . "/common.$phpEx"))
{
- $this->lang_name = $config['default_lang'] = $accept_lang;
+ $user_lang_name = $config['default_lang'] = $accept_lang;
break;
}
}
@@ -126,6 +127,38 @@ class phpbb_user extends phpbb_session
*/
}
+ $user_data = $this->data;
+
+ /**
+ * Event to load language files and modify user data on every page
+ *
+ * @event core.user_setup
+ * @var array user_data Array with user's data row
+ * @var string user_lang_name Basename of the user's langauge
+ * @var string user_date_format User's date/time format
+ * @var string user_timezone User's timezone, should be one of
+ * http://www.php.net/manual/en/timezones.php
+ * @var mixed lang_set String or array of language files
+ * @var mixed style_id Style we are going to display
+ * @since 3.1-A1
+ */
+ $vars = array('user_data', 'user_lang_name', 'user_date_format', 'user_timezone', 'lang_set', 'style_id');
+ extract($phpbb_dispatcher->trigger_event('core.user_setup', compact($vars)));
+
+ $this->data = $user_data;
+ $this->lang_name = $user_lang_name;
+ $this->date_format = $user_date_format;
+
+ try
+ {
+ $this->timezone = new DateTimeZone($user_timezone);
+ }
+ catch (Exception $e)
+ {
+ // If the timezone the user has selected is invalid, we fall back to UTC.
+ $this->timezone = new DateTimeZone('UTC');
+ }
+
// We include common language file here to not load it every time a custom language file is included
$lang = &$this->lang;
@@ -612,70 +645,46 @@ class phpbb_user extends phpbb_session
*/
function format_date($gmepoch, $format = false, $forcedate = false)
{
- static $midnight;
- static $date_cache;
-
- $format = (!$format) ? $this->date_format : $format;
- $now = time();
- $delta = $now - $gmepoch;
-
- if (!isset($date_cache[$format]))
- {
- // Is the user requesting a friendly date format (i.e. 'Today 12:42')?
- $date_cache[$format] = array(
- 'is_short' => strpos($format, '|'),
- 'format_short' => substr($format, 0, strpos($format, '|')) . '||' . substr(strrchr($format, '|'), 1),
- 'format_long' => str_replace('|', '', $format),
- 'lang' => $this->lang['datetime'],
- );
-
- // Short representation of month in format? Some languages use different terms for the long and short format of May
- if ((strpos($format, '\M') === false && strpos($format, 'M') !== false) || (strpos($format, '\r') === false && strpos($format, 'r') !== false))
- {
- $date_cache[$format]['lang']['May'] = $this->lang['datetime']['May_short'];
- }
- }
-
- // Zone offset
- $zone_offset = $this->timezone + $this->dst;
-
- // Show date < 1 hour ago as 'xx min ago' but not greater than 60 seconds in the future
- // A small tolerence is given for times in the future but in the same minute are displayed as '< than a minute ago'
- if ($delta < 3600 && $delta > -60 && ($delta >= -5 || (($now / 60) % 60) == (($gmepoch / 60) % 60)) && $date_cache[$format]['is_short'] !== false && !$forcedate && isset($this->lang['datetime']['AGO']))
- {
- return $this->lang(array('datetime', 'AGO'), max(0, (int) floor($delta / 60)));
- }
+ static $utc;
- if (!$midnight)
+ if (!isset($utc))
{
- list($d, $m, $y) = explode(' ', gmdate('j n Y', time() + $zone_offset));
- $midnight = gmmktime(0, 0, 0, $m, $d, $y) - $zone_offset;
+ $utc = new DateTimeZone('UTC');
}
- if ($date_cache[$format]['is_short'] !== false && !$forcedate && !($gmepoch < $midnight - 86400 || $gmepoch > $midnight + 172800))
- {
- $day = false;
+ $time = new phpbb_datetime($this, "@$gmepoch", $utc);
+ $time->setTimezone($this->timezone);
- if ($gmepoch > $midnight + 86400)
- {
- $day = 'TOMORROW';
- }
- else if ($gmepoch > $midnight)
- {
- $day = 'TODAY';
- }
- else if ($gmepoch > $midnight - 86400)
- {
- $day = 'YESTERDAY';
- }
+ return $time->format($format, $forcedate);
+ }
- if ($day !== false)
- {
- return str_replace('||', $this->lang['datetime'][$day], strtr(@gmdate($date_cache[$format]['format_short'], $gmepoch + $zone_offset), $date_cache[$format]['lang']));
- }
- }
+ /**
+ * Create a phpbb_datetime object in the context of the current user
+ *
+ * @since 3.1
+ * @param string $time String in a format accepted by strtotime().
+ * @param DateTimeZone $timezone Time zone of the time.
+ * @return phpbb_datetime Date time object linked to the current users locale
+ */
+ public function create_datetime($time = 'now', DateTimeZone $timezone = null)
+ {
+ $timezone = $timezone ?: $this->timezone;
+ return new phpbb_datetime($this, $time, $timezone);
+ }
- return strtr(@gmdate($date_cache[$format]['format_long'], $gmepoch + $zone_offset), $date_cache[$format]['lang']);
+ /**
+ * Get the UNIX timestamp for a datetime in the users timezone, so we can store it in the database.
+ *
+ * @param string $format Format of the entered date/time
+ * @param string $time Date/time with the timezone applied
+ * @param DateTimeZone $timezone Timezone of the date/time, falls back to timezone of current user
+ * @return int Returns the unix timestamp
+ */
+ public function get_timestamp_from_format($format, $time, DateTimeZone $timezone = null)
+ {
+ $timezone = $timezone ?: $this->timezone;
+ $date = DateTime::createFromFormat($format, $time, $timezone);
+ return ($date !== false) ? $date->format('U') : false;
}
/**
diff --git a/phpBB/index.php b/phpBB/index.php
index 9a57105d57..0ac8034d7f 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -104,17 +104,18 @@ while ($row = $db->sql_fetchrow($result))
}
$db->sql_freeresult($result);
-$legend = implode(', ', $legend);
+$legend = implode($user->lang['COMMA_SEPARATOR'], $legend);
// Generate birthday list if required ...
$birthday_list = array();
if ($config['load_birthdays'] && $config['allow_birthdays'] && $auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'))
{
- $now = phpbb_gmgetdate(time() + $user->timezone + $user->dst);
+ $time = $user->create_datetime();
+ $now = phpbb_gmgetdate($time->getTimestamp() + $time->getOffset());
// Display birthdays of 29th february on 28th february in non-leap-years
$leap_year_birthdays = '';
- if ($now['mday'] == 28 && $now['mon'] == 2 && !$user->format_date(time(), 'L'))
+ if ($now['mday'] == 28 && $now['mon'] == 2 && !$time->format('L'))
{
$leap_year_birthdays = " OR u.user_birthday LIKE '" . $db->sql_escape(sprintf('%2d-%2d-', 29, 2)) . "%'";
}
@@ -156,7 +157,7 @@ $template->assign_vars(array(
'NEWEST_USER' => $user->lang('NEWEST_USER', get_username_string('full', $config['newest_user_id'], $config['newest_username'], $config['newest_user_colour'])),
'LEGEND' => $legend,
- 'BIRTHDAY_LIST' => (empty($birthday_list)) ? '' : implode(', ', $birthday_list),
+ 'BIRTHDAY_LIST' => (empty($birthday_list)) ? '' : implode($user->lang['COMMA_SEPARATOR'], $birthday_list),
'FORUM_IMG' => $user->img('forum_read', 'NO_UNREAD_POSTS'),
'FORUM_UNREAD_IMG' => $user->img('forum_unread', 'UNREAD_POSTS'),
@@ -170,8 +171,20 @@ $template->assign_vars(array(
'U_MCP' => ($auth->acl_get('m_') || $auth->acl_getf_global('m_')) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=main&amp;mode=front', true, $user->session_id) : '')
);
+$page_title = $user->lang['INDEX'];
+
+/**
+* You can use this event to modify the page title and load data for the index
+*
+* @event core.index_modify_page_title
+* @var string page_title Title of the index page
+* @since 3.1-A1
+*/
+$vars = array('page_title');
+extract($phpbb_dispatcher->trigger_event('core.index_modify_page_title', compact($vars)));
+
// Output page
-page_header($user->lang['INDEX']);
+page_header($page_title);
$template->set_filenames(array(
'body' => 'index_body.html')
diff --git a/phpBB/install/convertors/convert_phpbb20.php b/phpBB/install/convertors/convert_phpbb20.php
index 79c20b718d..68acea02b3 100644
--- a/phpBB/install/convertors/convert_phpbb20.php
+++ b/phpBB/install/convertors/convert_phpbb20.php
@@ -32,7 +32,7 @@ $convertor_data = array(
'forum_name' => 'phpBB 2.0.x',
'version' => '1.0.3',
'phpbb_version' => '3.1.0-dev',
- 'author' => '<a href="http://www.phpbb.com/">phpBB Group</a>',
+ 'author' => '<a href="https://www.phpbb.com/">phpBB Group</a>',
'dbms' => $dbms,
'dbhost' => $dbhost,
'dbport' => $dbport,
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index 594397c815..542685a69d 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -7,6 +7,10 @@
*
*/
+use Symfony\Component\Config\FileLocator;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+
define('UPDATES_TO_VERSION', '3.1.0-dev');
// Enter any version to update from to test updates. The version within the db will not be updated.
@@ -107,21 +111,37 @@ if (!defined('EXT_TABLE'))
define('EXT_TABLE', $table_prefix . 'ext');
}
-$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx");
-$phpbb_class_loader_ext->register();
-$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx");
-$phpbb_class_loader->register();
+$phpbb_container = new ContainerBuilder();
+$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config'));
+$loader->load('services.yml');
+
+// We must include the DI processor class files because the class loader
+// is not yet set up
+require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx);
+require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx);
+$processor = new phpbb_di_processor_config($phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx);
+$processor->process($phpbb_container);
+
+// Setup class loader first
+$phpbb_class_loader = $phpbb_container->get('class_loader');
+$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext');
// set up caching
-$cache_factory = new phpbb_cache_factory($acm_type);
-$cache = $cache_factory->get_service();
-$phpbb_class_loader_ext->set_cache($cache->get_driver());
-$phpbb_class_loader->set_cache($cache->get_driver());
+$cache = $phpbb_container->get('cache');
-$phpbb_dispatcher = new phpbb_event_dispatcher();
-$request = new phpbb_request();
-$user = new phpbb_user();
-$db = new $sql_db();
+// Instantiate some basic classes
+$phpbb_dispatcher = $phpbb_container->get('dispatcher');
+$request = $phpbb_container->get('request');
+$user = $phpbb_container->get('user');
+$auth = $phpbb_container->get('auth');
+$db = $phpbb_container->get('dbal.conn');
+
+$ids = array_keys($phpbb_container->findTaggedServiceIds('container.processor'));
+foreach ($ids as $id)
+{
+ $processor = $phpbb_container->get($id);
+ $processor->process($phpbb_container);
+}
// make sure request_var uses this request instance
request_var('', 0, false, false, $request); // "dependency injection" for a function
@@ -597,7 +617,7 @@ function _print_footer()
</div>
<div id="page-footer">
- Powered by <a href="http://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group
+ Powered by <a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group
</div>
</div>
@@ -683,12 +703,12 @@ function _write_result($no_updates, $errored, $error_ary)
function _add_modules($modules_to_install)
{
- global $phpbb_root_path, $phpEx, $db, $phpbb_extension_manager;
+ global $phpbb_root_path, $phpEx, $db, $phpbb_extension_manager, $config;
// modules require an extension manager
if (empty($phpbb_extension_manager))
{
- $phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx");
+ $phpbb_extension_manager = new phpbb_extension_manager($db, $config, EXT_TABLE, $phpbb_root_path, ".$phpEx");
}
include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx);
@@ -1071,6 +1091,16 @@ function database_update_info()
'3.0.10-RC3' => array(),
// No changes from 3.0.10 to 3.0.11-RC1
'3.0.10' => array(),
+ // Changes from 3.0.11-RC1 to 3.0.11-RC2
+ '3.0.11-RC1' => array(
+ 'add_columns' => array(
+ PROFILE_FIELDS_TABLE => array(
+ 'field_show_novalue' => array('BOOL', 0),
+ ),
+ ),
+ ),
+ // No changes from 3.0.11-RC2 to 3.0.11
+ '3.0.11-RC2' => array(),
/** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 */
@@ -1109,6 +1139,9 @@ function database_update_info()
GROUPS_TABLE => array(
'group_legend' => array('UINT', 0),
),
+ USERS_TABLE => array(
+ 'user_timezone' => array('VCHAR:100', ''),
+ ),
),
),
);
@@ -1123,6 +1156,8 @@ function change_database_data(&$no_updates, $version)
{
global $db, $errored, $error_ary, $config, $phpbb_root_path, $phpEx, $db_tools;
+ $update_helpers = new phpbb_update_helpers();
+
switch ($version)
{
case '3.0.0':
@@ -1968,7 +2003,7 @@ function change_database_data(&$no_updates, $version)
'user_email' => '',
'user_lang' => $config['default_lang'],
'user_style' => $config['default_style'],
- 'user_timezone' => 0,
+ 'user_timezone' => 'UTC',
'user_dateformat' => $config['default_dateformat'],
'user_allow_massemail' => 0,
);
@@ -2205,6 +2240,14 @@ function change_database_data(&$no_updates, $version)
$no_updates = false;
break;
+ // No changes from 3.0.11-RC1 to 3.0.11-RC2
+ case '3.0.11-RC1':
+ break;
+
+ // No changes from 3.0.11-RC2 to 3.0.11
+ case '3.0.11-RC2':
+ break;
+
// Changes from 3.1.0-dev to 3.1.0-A1
case '3.1.0-dev':
@@ -2260,6 +2303,16 @@ function change_database_data(&$no_updates, $version)
set_config('fulltext_postgres_max_word_len', 254);
}
+ if (!isset($config['fulltext_sphinx_stopwords']))
+ {
+ set_config('fulltext_sphinx_stopwords', 0);
+ }
+
+ if (!isset($config['fulltext_sphinx_indexer_mem_limit']))
+ {
+ set_config('fulltext_sphinx_indexer_mem_limit', 512);
+ }
+
if (!isset($config['load_jquery_cdn']))
{
set_config('load_jquery_cdn', 0);
@@ -2607,6 +2660,38 @@ function change_database_data(&$no_updates, $version)
$config->set('assets_version', '1');
}
+ // If the column exists, we did not yet update the users timezone
+ if ($db_tools->sql_column_exists(USERS_TABLE, 'user_dst'))
+ {
+ // Update user timezones
+ $sql = 'SELECT user_dst, user_timezone
+ FROM ' . USERS_TABLE . '
+ GROUP BY user_timezone, user_dst';
+ $result = $db->sql_query($sql);
+
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $sql = 'UPDATE ' . USERS_TABLE . "
+ SET user_timezone = '" . $db->sql_escape($update_helpers->convert_phpbb30_timezone($row['user_timezone'], $row['user_dst'])) . "'
+ WHERE user_timezone = '" . $db->sql_escape($row['user_timezone']) . "'
+ AND user_dst = " . (int) $row['user_dst'];
+ _sql($sql, $errored, $error_ary);
+ }
+ $db->sql_freeresult($result);
+
+ // Update board default timezone
+ set_config('board_timezone', $update_helpers->convert_phpbb30_timezone($config['board_timezone'], $config['board_dst']));
+
+ // After we have calculated the timezones we can delete user_dst column from user table.
+ $db_tools->sql_column_remove(USERS_TABLE, 'user_dst');
+ }
+
+ if (!isset($config['site_home_url']))
+ {
+ $config->set('site_home_url', '');
+ $config->set('site_home_text', '');
+ }
+
break;
}
}
diff --git a/phpBB/install/index.php b/phpBB/install/index.php
index f992b67bb7..4f1fbee7ad 100644
--- a/phpBB/install/index.php
+++ b/phpBB/install/index.php
@@ -7,6 +7,10 @@
*
*/
+use Symfony\Component\Config\FileLocator;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
+
/**#@+
* @ignore
*/
@@ -71,6 +75,9 @@ else
// Include essential scripts
require($phpbb_root_path . 'includes/class_loader.' . $phpEx);
+require($phpbb_root_path . 'includes/di/processor/interface.' . $phpEx);
+require($phpbb_root_path . 'includes/di/processor/config.' . $phpEx);
+
require($phpbb_root_path . 'includes/functions.' . $phpEx);
phpbb_require_updated('includes/functions_content.' . $phpEx, true);
@@ -79,19 +86,23 @@ include($phpbb_root_path . 'includes/functions_admin.' . $phpEx);
include($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
require($phpbb_root_path . 'includes/functions_install.' . $phpEx);
-$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".$phpEx");
-$phpbb_class_loader_ext->register();
-$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".$phpEx");
-$phpbb_class_loader->register();
+$phpbb_container = new ContainerBuilder();
+$loader = new YamlFileLoader($phpbb_container, new FileLocator(__DIR__.'/../config'));
+$loader->load('services.yml');
+
+$phpbb_container->setParameter('core.root_path', $phpbb_root_path);
+$phpbb_container->setParameter('core.php_ext', $phpEx);
+
+$phpbb_container->setAlias('cache.driver', 'cache.driver.install');
+
+$phpbb_class_loader = $phpbb_container->get('class_loader');
+$phpbb_class_loader_ext = $phpbb_container->get('class_loader.ext');
// set up caching
-$cache_factory = new phpbb_cache_factory('file');
-$cache = $cache_factory->get_service();
-$phpbb_class_loader_ext->set_cache($cache->get_driver());
-$phpbb_class_loader->set_cache($cache->get_driver());
+$cache = $phpbb_container->get('cache');
-$phpbb_dispatcher = new phpbb_event_dispatcher();
-$request = new phpbb_request();
+$phpbb_dispatcher = $phpbb_container->get('dispatcher');
+$request = $phpbb_container->get('request');
// make sure request_var uses this request instance
request_var('', 0, false, false, $request); // "dependency injection" for a function
@@ -583,7 +594,7 @@ class module
echo ' </div>';
echo ' </div>';
echo ' <div id="page-footer">';
- echo ' Powered by <a href="http://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group';
+ echo ' Powered by <a href="https://www.phpbb.com/">phpBB</a>&reg; Forum Software &copy; phpBB Group';
echo ' </div>';
echo '</div>';
echo '</body>';
diff --git a/phpBB/install/install_convert.php b/phpBB/install/install_convert.php
index db974f9903..b8045cb98b 100644
--- a/phpBB/install/install_convert.php
+++ b/phpBB/install/install_convert.php
@@ -569,7 +569,7 @@ class install_convert extends module
*/
function convert_data($sub)
{
- global $template, $user, $phpbb_root_path, $phpEx, $db, $lang, $config, $cache;
+ global $template, $user, $phpbb_root_path, $phpEx, $db, $lang, $config, $cache, $auth;
global $convert, $convert_row, $message_parser, $skip_rows, $language;
global $request;
@@ -750,7 +750,7 @@ class install_convert extends module
}
$error = false;
- $convert->fulltext_search = new $search_type($error);
+ $convert->fulltext_search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
if ($error)
{
@@ -933,7 +933,7 @@ class install_convert extends module
}
else if (sizeof($missing_tables))
{
- $this->p_master->error(sprintf($user->lang['TABLES_MISSING'], implode(', ', $missing_tables)) . '<br /><br />' . $user->lang['CHECK_TABLE_PREFIX'], __LINE__, __FILE__);
+ $this->p_master->error(sprintf($user->lang['TABLES_MISSING'], implode($user->lang['COMMA_SEPARATOR'], $missing_tables)) . '<br /><br />' . $user->lang['CHECK_TABLE_PREFIX'], __LINE__, __FILE__);
}
$url = $this->save_convert_progress('&amp;confirm=1');
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index bbd11f9a6f..9162d5ab60 100644
--- a/phpBB/install/install_install.php
+++ b/phpBB/install/install_install.php
@@ -250,7 +250,7 @@ class install_install extends module
'S_EXPLAIN' => true,
'S_LEGEND' => false,
));
-
+
// Check for php json support
if (@extension_loaded('json'))
{
@@ -1427,7 +1427,7 @@ class install_install extends module
*/
function build_search_index($mode, $sub)
{
- global $db, $lang, $phpbb_root_path, $phpEx, $config;
+ global $db, $lang, $phpbb_root_path, $phpEx, $config, $auth, $user;
// Obtain any submitted data
$data = $this->get_submitted_data();
@@ -1463,7 +1463,7 @@ class install_install extends module
set_config_count(null, null, null, $config);
$error = false;
- $search = new phpbb_search_fulltext_native($error);
+ $search = new phpbb_search_fulltext_native($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
$sql = 'SELECT post_id, post_subject, post_text, poster_id, forum_id
FROM ' . POSTS_TABLE;
@@ -1481,12 +1481,12 @@ class install_install extends module
*/
function add_modules($mode, $sub)
{
- global $db, $lang, $phpbb_root_path, $phpEx, $phpbb_extension_manager;
+ global $db, $lang, $phpbb_root_path, $phpEx, $phpbb_extension_manager, $config;
// modules require an extension manager
if (empty($phpbb_extension_manager))
{
- $phpbb_extension_manager = new phpbb_extension_manager($db, EXT_TABLE, $phpbb_root_path, ".$phpEx");
+ $phpbb_extension_manager = new phpbb_extension_manager($db, $config, EXT_TABLE, $phpbb_root_path, ".$phpEx");
}
include_once($phpbb_root_path . 'includes/acp/acp_modules.' . $phpEx);
@@ -1795,7 +1795,7 @@ class install_install extends module
'user_email' => '',
'user_lang' => $data['default_lang'],
'user_style' => 1,
- 'user_timezone' => 0,
+ 'user_timezone' => 'UTC',
'user_dateformat' => $lang['default_dateformat'],
'user_allow_massemail' => 0,
);
diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php
index c2feaa086a..8c044550f3 100644
--- a/phpBB/install/install_update.php
+++ b/phpBB/install/install_update.php
@@ -349,7 +349,7 @@ class install_update extends module
// We are directly within an update. To make sure our update list is correct we check its status.
$update_list = ($request->variable('check_again', false, false, phpbb_request_interface::POST)) ? false : $cache->get('_update_list');
- $modified = ($update_list !== false) ? @filemtime($cache->cache_dir . 'data_update_list.' . $phpEx) : 0;
+ $modified = ($update_list !== false) ? @filemtime($cache->get_driver()->cache_dir . 'data_update_list.' . $phpEx) : 0;
// Make sure the list is up-to-date
if ($update_list !== false)
@@ -862,7 +862,14 @@ class install_update extends module
$test_connection = false;
if ($test_ftp_connection || $submit)
{
- $transfer = new $method(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', ''));
+ $transfer = new $method(
+ request_var('host', ''),
+ request_var('username', ''),
+ htmlspecialchars_decode($request->untrimmed_variable('password', '')),
+ request_var('root_path', ''),
+ request_var('port', ''),
+ request_var('timeout', '')
+ );
$test_connection = $transfer->open_session();
// Make sure that the directory is correct by checking for the existence of common.php
@@ -948,7 +955,14 @@ class install_update extends module
}
else
{
- $transfer = new $method(request_var('host', ''), request_var('username', ''), request_var('password', ''), request_var('root_path', ''), request_var('port', ''), request_var('timeout', ''));
+ $transfer = new $method(
+ request_var('host', ''),
+ request_var('username', ''),
+ htmlspecialchars_decode($request->untrimmed_variable('password', '')),
+ request_var('root_path', ''),
+ request_var('port', ''),
+ request_var('timeout', '')
+ );
$transfer->open_session();
}
diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql
index 51565ef2d4..588557b92a 100644
--- a/phpBB/install/schemas/firebird_schema.sql
+++ b/phpBB/install/schemas/firebird_schema.sql
@@ -818,6 +818,7 @@ CREATE TABLE phpbb_profile_fields (
field_default_value VARCHAR(255) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
field_validation VARCHAR(20) CHARACTER SET UTF8 DEFAULT '' NOT NULL COLLATE UNICODE,
field_required INTEGER DEFAULT 0 NOT NULL,
+ field_show_novalue INTEGER DEFAULT 0 NOT NULL,
field_show_on_reg INTEGER DEFAULT 0 NOT NULL,
field_show_on_pm INTEGER DEFAULT 0 NOT NULL,
field_show_on_vt INTEGER DEFAULT 0 NOT NULL,
@@ -1242,8 +1243,7 @@ CREATE TABLE phpbb_users (
user_inactive_time INTEGER DEFAULT 0 NOT NULL,
user_posts INTEGER DEFAULT 0 NOT NULL,
user_lang VARCHAR(30) CHARACTER SET NONE DEFAULT '' NOT NULL,
- user_timezone DOUBLE PRECISION DEFAULT 0 NOT NULL,
- user_dst INTEGER DEFAULT 0 NOT NULL,
+ user_timezone VARCHAR(100) CHARACTER SET NONE DEFAULT 'UTC' NOT NULL,
user_dateformat VARCHAR(30) CHARACTER SET UTF8 DEFAULT 'd M Y H:i' NOT NULL COLLATE UNICODE,
user_style INTEGER DEFAULT 0 NOT NULL,
user_rank INTEGER DEFAULT 0 NOT NULL,
diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql
index 2c78dd009f..9d0e81a66d 100644
--- a/phpBB/install/schemas/mssql_schema.sql
+++ b/phpBB/install/schemas/mssql_schema.sql
@@ -992,6 +992,7 @@ CREATE TABLE [phpbb_profile_fields] (
[field_default_value] [varchar] (255) DEFAULT ('') NOT NULL ,
[field_validation] [varchar] (20) DEFAULT ('') NOT NULL ,
[field_required] [int] DEFAULT (0) NOT NULL ,
+ [field_show_novalue] [int] DEFAULT (0) NOT NULL ,
[field_show_on_reg] [int] DEFAULT (0) NOT NULL ,
[field_show_on_pm] [int] DEFAULT (0) NOT NULL ,
[field_show_on_vt] [int] DEFAULT (0) NOT NULL ,
@@ -1526,8 +1527,7 @@ CREATE TABLE [phpbb_users] (
[user_inactive_time] [int] DEFAULT (0) NOT NULL ,
[user_posts] [int] DEFAULT (0) NOT NULL ,
[user_lang] [varchar] (30) DEFAULT ('') NOT NULL ,
- [user_timezone] [float] DEFAULT (0) NOT NULL ,
- [user_dst] [int] DEFAULT (0) NOT NULL ,
+ [user_timezone] [varchar] (100) DEFAULT ('UTC') NOT NULL ,
[user_dateformat] [varchar] (30) DEFAULT ('d M Y H:i') NOT NULL ,
[user_style] [int] DEFAULT (0) NOT NULL ,
[user_rank] [int] DEFAULT (0) NOT NULL ,
diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql
index d19f1930d0..e71afcd5b3 100644
--- a/phpBB/install/schemas/mysql_40_schema.sql
+++ b/phpBB/install/schemas/mysql_40_schema.sql
@@ -582,6 +582,7 @@ CREATE TABLE phpbb_profile_fields (
field_default_value blob NOT NULL,
field_validation varbinary(60) DEFAULT '' NOT NULL,
field_required tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
+ field_show_novalue tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
field_show_on_reg tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
field_show_on_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
field_show_on_vt tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
@@ -890,8 +891,7 @@ CREATE TABLE phpbb_users (
user_inactive_time int(11) UNSIGNED DEFAULT '0' NOT NULL,
user_posts mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
user_lang varbinary(30) DEFAULT '' NOT NULL,
- user_timezone decimal(5,2) DEFAULT '0' NOT NULL,
- user_dst tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
+ user_timezone varbinary(100) DEFAULT 'UTC' NOT NULL,
user_dateformat varbinary(90) DEFAULT 'd M Y H:i' NOT NULL,
user_style mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
user_rank mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql
index 3fd8d4f1d1..20af6f3566 100644
--- a/phpBB/install/schemas/mysql_41_schema.sql
+++ b/phpBB/install/schemas/mysql_41_schema.sql
@@ -582,6 +582,7 @@ CREATE TABLE phpbb_profile_fields (
field_default_value varchar(255) DEFAULT '' NOT NULL,
field_validation varchar(20) DEFAULT '' NOT NULL,
field_required tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
+ field_show_novalue tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
field_show_on_reg tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
field_show_on_pm tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
field_show_on_vt tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
@@ -890,8 +891,7 @@ CREATE TABLE phpbb_users (
user_inactive_time int(11) UNSIGNED DEFAULT '0' NOT NULL,
user_posts mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
user_lang varchar(30) DEFAULT '' NOT NULL,
- user_timezone decimal(5,2) DEFAULT '0' NOT NULL,
- user_dst tinyint(1) UNSIGNED DEFAULT '0' NOT NULL,
+ user_timezone varchar(100) DEFAULT 'UTC' NOT NULL,
user_dateformat varchar(30) DEFAULT 'd M Y H:i' NOT NULL,
user_style mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
user_rank mediumint(8) UNSIGNED DEFAULT '0' NOT NULL,
diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql
index 8a0f3e56b1..04155fe28b 100644
--- a/phpBB/install/schemas/oracle_schema.sql
+++ b/phpBB/install/schemas/oracle_schema.sql
@@ -1100,6 +1100,7 @@ CREATE TABLE phpbb_profile_fields (
field_default_value varchar2(765) DEFAULT '' ,
field_validation varchar2(60) DEFAULT '' ,
field_required number(1) DEFAULT '0' NOT NULL,
+ field_show_novalue number(1) DEFAULT '0' NOT NULL,
field_show_on_reg number(1) DEFAULT '0' NOT NULL,
field_show_on_pm number(1) DEFAULT '0' NOT NULL,
field_show_on_vt number(1) DEFAULT '0' NOT NULL,
@@ -1638,8 +1639,7 @@ CREATE TABLE phpbb_users (
user_inactive_time number(11) DEFAULT '0' NOT NULL,
user_posts number(8) DEFAULT '0' NOT NULL,
user_lang varchar2(30) DEFAULT '' ,
- user_timezone number(5, 2) DEFAULT '0' NOT NULL,
- user_dst number(1) DEFAULT '0' NOT NULL,
+ user_timezone varchar2(100) DEFAULT 'UTC' NOT NULL,
user_dateformat varchar2(90) DEFAULT 'd M Y H:i' NOT NULL,
user_style number(8) DEFAULT '0' NOT NULL,
user_rank number(8) DEFAULT '0' NOT NULL,
diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql
index c624024362..659a32bf19 100644
--- a/phpBB/install/schemas/postgres_schema.sql
+++ b/phpBB/install/schemas/postgres_schema.sql
@@ -774,6 +774,7 @@ CREATE TABLE phpbb_profile_fields (
field_default_value varchar(255) DEFAULT '' NOT NULL,
field_validation varchar(20) DEFAULT '' NOT NULL,
field_required INT2 DEFAULT '0' NOT NULL CHECK (field_required >= 0),
+ field_show_novalue INT2 DEFAULT '0' NOT NULL CHECK (field_show_novalue >= 0),
field_show_on_reg INT2 DEFAULT '0' NOT NULL CHECK (field_show_on_reg >= 0),
field_show_on_pm INT2 DEFAULT '0' NOT NULL CHECK (field_show_on_pm >= 0),
field_show_on_vt INT2 DEFAULT '0' NOT NULL CHECK (field_show_on_vt >= 0),
@@ -1140,8 +1141,7 @@ CREATE TABLE phpbb_users (
user_inactive_time INT4 DEFAULT '0' NOT NULL CHECK (user_inactive_time >= 0),
user_posts INT4 DEFAULT '0' NOT NULL CHECK (user_posts >= 0),
user_lang varchar(30) DEFAULT '' NOT NULL,
- user_timezone decimal(5,2) DEFAULT '0' NOT NULL,
- user_dst INT2 DEFAULT '0' NOT NULL CHECK (user_dst >= 0),
+ user_timezone varchar(100) DEFAULT 'UTC' NOT NULL,
user_dateformat varchar(30) DEFAULT 'd M Y H:i' NOT NULL,
user_style INT4 DEFAULT '0' NOT NULL CHECK (user_style >= 0),
user_rank INT4 DEFAULT '0' NOT NULL CHECK (user_rank >= 0),
diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql
index deefdafbc4..dbb5fd7481 100644
--- a/phpBB/install/schemas/schema_data.sql
+++ b/phpBB/install/schemas/schema_data.sql
@@ -54,12 +54,11 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('avatar_salt', 'php
INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_contact', 'contact@yourdomain.tld');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_disable', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_disable_msg', '');
-INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_dst', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email', 'address@yourdomain.tld');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email_form', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_email_sig', '{L_CONFIG_BOARD_EMAIL_SIG}');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_hide_emails', '1');
-INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_timezone', '0');
+INSERT INTO phpbb_config (config_name, config_value) VALUES ('board_timezone', 'UTC');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('browser_check', '1');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('bump_interval', '10');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('bump_type', 'd');
@@ -128,6 +127,8 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_native_mi
INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_postgres_max_word_len', '254');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_postgres_min_word_len', '4');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_postgres_ts_name', 'simple');
+INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_sphinx_indexer_mem_limit', '512');
+INSERT INTO phpbb_config (config_name, config_value) VALUES ('fulltext_sphinx_stopwords', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('gzip_compress', '0');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('hot_threshold', '25');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('icons_path', 'images/icons');
@@ -241,6 +242,8 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('server_protocol',
INSERT INTO phpbb_config (config_name, config_value) VALUES ('session_gc', '3600');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('session_length', '3600');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('site_desc', '{L_CONFIG_SITE_DESC}');
+INSERT INTO phpbb_config (config_name, config_value) VALUES ('site_home_url', '');
+INSERT INTO phpbb_config (config_name, config_value) VALUES ('site_home_text', '');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('sitename', '{L_CONFIG_SITENAME}');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('smilies_path', 'images/smilies');
INSERT INTO phpbb_config (config_name, config_value) VALUES ('smilies_per_page', '50');
@@ -344,6 +347,7 @@ INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_board', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_bots', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_clearlogs', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_email', 1);
+INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_extensions', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_fauth', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_forum', 1);
INSERT INTO phpbb_acl_options (auth_option, is_global) VALUES ('a_forumadd', 1);
diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql
index bd002c93ed..8360bc30ea 100644
--- a/phpBB/install/schemas/sqlite_schema.sql
+++ b/phpBB/install/schemas/sqlite_schema.sql
@@ -565,6 +565,7 @@ CREATE TABLE phpbb_profile_fields (
field_default_value varchar(255) NOT NULL DEFAULT '',
field_validation varchar(20) NOT NULL DEFAULT '',
field_required INTEGER UNSIGNED NOT NULL DEFAULT '0',
+ field_show_novalue INTEGER UNSIGNED NOT NULL DEFAULT '0',
field_show_on_reg INTEGER UNSIGNED NOT NULL DEFAULT '0',
field_show_on_pm INTEGER UNSIGNED NOT NULL DEFAULT '0',
field_show_on_vt INTEGER UNSIGNED NOT NULL DEFAULT '0',
@@ -864,8 +865,7 @@ CREATE TABLE phpbb_users (
user_inactive_time INTEGER UNSIGNED NOT NULL DEFAULT '0',
user_posts INTEGER UNSIGNED NOT NULL DEFAULT '0',
user_lang varchar(30) NOT NULL DEFAULT '',
- user_timezone decimal(5,2) NOT NULL DEFAULT '0',
- user_dst INTEGER UNSIGNED NOT NULL DEFAULT '0',
+ user_timezone varchar(100) NOT NULL DEFAULT 'UTC',
user_dateformat varchar(30) NOT NULL DEFAULT 'd M Y H:i',
user_style INTEGER UNSIGNED NOT NULL DEFAULT '0',
user_rank INTEGER UNSIGNED NOT NULL DEFAULT '0',
diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index 384bce75bf..a4380486cc 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -45,16 +45,19 @@ $lang = array_merge($lang, array(
'DISABLE_BOARD' => 'Disable board',
'DISABLE_BOARD_EXPLAIN' => 'This will make the board unavailable to users. You can also enter a short (255 character) message to display if you wish.',
'DISPLAY_LAST_SUBJECT' => 'Display subject of last added post on forum list',
- 'DISPLAY_LAST_SUBJECT_EXPLAIN' => 'The subject of the last added post will be displayed in the forum list with a hyperlink to the post. Subjects from password protected forums and forums in which user doesn’t have read access are not shown.',
+ 'DISPLAY_LAST_SUBJECT_EXPLAIN' => 'The subject of the last added post will be displayed in the forum list with a hyperlink to the post. Subjects from password protected forums and forums in which user doesn’t have read access are not shown.',
'OVERRIDE_STYLE' => 'Override user style',
'OVERRIDE_STYLE_EXPLAIN' => 'Replaces user’s style with the default.',
'SITE_DESC' => 'Site description',
+ 'SITE_HOME_TEXT' => 'Main website text',
+ 'SITE_HOME_TEXT_EXPLAIN' => 'This text will be displayed as a link to your website homepage in the board’s breadcrumbs. If not specified, it will default to “Homeâ€.',
+ 'SITE_HOME_URL' => 'Main website URL',
+ 'SITE_HOME_URL_EXPLAIN' => 'If specified, a link to this URL will be prepended to your board’s breadcrumbs and the board logo will link to this URL instead of the forum index. An absolute URL is required, e.g. <samp>http://www.phpbb.com</samp>.',
'SITE_NAME' => 'Site name',
- 'SYSTEM_DST' => 'Enable Summer Time/<abbr title="Daylight Saving Time">DST</abbr>',
'SYSTEM_TIMEZONE' => 'Guest timezone',
'SYSTEM_TIMEZONE_EXPLAIN' => 'Timezone to use for displaying times to users who are not logged in (guests, bots). Logged in users set their timezone during registration and can change it in their user control panel.',
'WARNINGS_EXPIRE' => 'Warning duration',
- 'WARNINGS_EXPIRE_EXPLAIN' => 'Number of days that will elapse before the warning will automatically expire from a user’s record. Set this value to 0 to make warnings permanent.',
+ 'WARNINGS_EXPIRE_EXPLAIN' => 'Number of days that will elapse before a warning will automatically expire from a user’s record. Set this value to 0 to make warnings permanent.',
));
// Board Features
diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php
index dc35969955..5eb10d50b3 100644
--- a/phpBB/language/en/acp/common.php
+++ b/phpBB/language/en/acp/common.php
@@ -81,6 +81,7 @@ $lang = array_merge($lang, array(
'ACP_EMAIL_SETTINGS' => 'Email settings',
'ACP_EXTENSION_GROUPS' => 'Manage extension groups',
+ 'ACP_EXTENSIONS' => 'Manage board extensions',
'ACP_FORUM_BASED_PERMISSIONS' => 'Forum based permissions',
'ACP_FORUM_LOGS' => 'Forum logs',
@@ -401,6 +402,8 @@ $lang = array_merge($lang, array(
'STATISTIC' => 'Statistic',
'STATISTIC_RESYNC_OPTIONS' => 'Resynchronise or reset statistics',
+ 'TIMEZONE_INVALID' => 'The timezone you selected is invalid.',
+ 'TIMEZONE_SELECTED' => '(currently selected)',
'TOPICS_PER_DAY' => 'Topics per day',
'UPLOAD_DIR_SIZE' => 'Size of posted attachments',
@@ -688,6 +691,7 @@ $lang = array_merge($lang, array(
'LOG_SEARCH_INDEX_CREATED' => '<strong>Created search index for</strong><br />» %s',
'LOG_SEARCH_INDEX_REMOVED' => '<strong>Removed search index for</strong><br />» %s',
+ 'LOG_SPHINX_ERROR' => '<strong>Sphinx Error</strong><br />» %s',
'LOG_STYLE_ADD' => '<strong>Added new style</strong><br />» %s',
'LOG_STYLE_DELETE' => '<strong>Deleted style</strong><br />» %s',
'LOG_STYLE_EDIT_DETAILS' => '<strong>Edited style</strong><br />» %s',
diff --git a/phpBB/language/en/acp/extensions.php b/phpBB/language/en/acp/extensions.php
new file mode 100644
index 0000000000..0adaff10c8
--- /dev/null
+++ b/phpBB/language/en/acp/extensions.php
@@ -0,0 +1,103 @@
+<?php
+/**
+*
+* acp_extensions [English]
+*
+* @package language
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
+*
+*/
+/**
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* DO NOT CHANGE
+*/
+if (empty($lang) || !is_array($lang))
+{
+ $lang = array();
+}
+
+// DEVELOPERS PLEASE NOTE
+//
+// Placeholders can now contain order information, e.g. instead of
+// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
+// translators to re-order the output of data while ensuring it remains correct
+//
+// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
+// equally where a string contains only two placeholders which are used to wrap text
+// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
+
+
+$lang = array_merge($lang, array(
+ 'EXTENSION' => 'Extension',
+ 'EXTENSIONS' => 'Extensions',
+ 'EXTENSIONS_ADMIN' => 'Extensions Manager',
+ 'EXTENSIONS_EXPLAIN' => 'The Extensions Manager is a tool in your phpBB Board which allows you to manage all of your extensions statuses and view information about them.',
+ 'EXTENSION_INVALID_LIST' => 'The "%s" extension is not valid.<br /><p>%s</p>',
+ 'EXTENSION_NOT_AVAILABLE' => 'The selected extension is not available for this board, please verify your phpBB and PHP versions are allowed (see the details page).',
+
+ 'DETAILS' => 'Details',
+
+ 'AVAILABLE' => 'Available',
+ 'ENABLED' => 'Enabled',
+ 'DISABLED' => 'Disabled',
+ 'PURGED' => 'Purged',
+ 'UPLOADED' => 'Uploaded',
+
+ 'ENABLE' => 'Enable',
+ 'DISABLE' => 'Disable',
+ 'PURGE' => 'Purge',
+
+ 'ENABLE_EXPLAIN' => 'Enabling an extension allows you to use it on your board.',
+ 'DISABLE_EXPLAIN' => 'Disabling an extension retains its files and settings but removes any functionality added by the extension.',
+ 'PURGE_EXPLAIN' => 'Purging an extension clears an extensions data while retaining its files.',
+ 'DELETE_EXPLAIN' => 'Deleting an extension removes all of its files and settings. Log entries will remain, although any language variables added by the extension will not be available.',
+
+ 'DISABLE_IN_PROGRESS' => 'The extension is currently being disabled, please do not leave this page or refresh until it is completed.',
+ 'ENABLE_IN_PROGRESS' => 'The extension is currently being installed, please do not leave this page or refresh until it is completed.',
+ 'PURGE_IN_PROGRESS' => 'The extension is currently being purged, please do not leave this page or refresh until it is completed.',
+ 'ENABLE_SUCCESS' => 'The extension was enabled successfully',
+ 'DISABLE_SUCCESS' => 'The extension was disabled successfully',
+ 'PURGE_SUCCESS' => 'The extension was purged successfully',
+
+ 'ENABLE_FAIL' => 'The extension could not be enabled',
+ 'DISABLE_FAIL' => 'The extension could not be disabled',
+ 'PURGE_FAIL' => 'The extension could not be purged',
+
+ 'EXTENSION_NAME' => 'Extension Name',
+ 'EXTENSION_ACTIONS' => 'Actions',
+ 'EXTENSION_OPTIONS' => 'Options',
+
+ 'ENABLE_CONFIRM' => 'Are you sure that you wish to enable this extension?',
+ 'DISABLE_CONFIRM' => 'Are you sure that you wish to disable this extension?',
+ 'PURGE_CONFIRM' => 'Are you sure that you wish to purge this extension&#39;s data? This will remove all settings stored for this extension and cannot be undone!',
+
+ 'WARNING' => 'Warning',
+ 'RETURN' => 'Return',
+
+ 'EXT_DETAILS' => 'Extension Details',
+ 'DISPLAY_NAME' => 'Display Name',
+ 'CLEAN_NAME' => 'Clean Name',
+ 'TYPE' => 'Type',
+ 'DESCRIPTION' => 'Description',
+ 'VERSION' => 'Version',
+ 'HOMEPAGE' => 'Homepage',
+ 'PATH' => 'File Path',
+ 'TIME' => 'Release Time',
+ 'LICENCE' => 'Licence',
+
+ 'REQUIREMENTS' => 'Requirements',
+ 'PHPBB_VERSION' => 'phpBB Version',
+ 'PHP_VERSION' => 'PHP Version',
+ 'AUTHOR_INFORMATION' => 'Author Information',
+ 'AUTHOR_NAME' => 'Name',
+ 'AUTHOR_EMAIL' => 'Email',
+ 'AUTHOR_HOMEPAGE' => 'Homepage',
+ 'AUTHOR_ROLE' => 'Role',
+));
diff --git a/phpBB/language/en/acp/permissions_phpbb.php b/phpBB/language/en/acp/permissions_phpbb.php
index 17649693fa..bb068e625f 100644
--- a/phpBB/language/en/acp/permissions_phpbb.php
+++ b/phpBB/language/en/acp/permissions_phpbb.php
@@ -226,6 +226,7 @@ $lang = array_merge($lang, array(
'acl_a_switchperm' => array('lang' => 'Can use others permissions', 'cat' => 'permissions'),
'acl_a_styles' => array('lang' => 'Can manage styles', 'cat' => 'misc'),
+ 'acl_a_extensions' => array('lang' => 'Can manage extensions', 'cat' => 'misc'),
'acl_a_viewlogs' => array('lang' => 'Can view logs', 'cat' => 'misc'),
'acl_a_clearlogs' => array('lang' => 'Can clear logs', 'cat' => 'misc'),
'acl_a_modules' => array('lang' => 'Can manage modules', 'cat' => 'misc'),
diff --git a/phpBB/language/en/acp/profile.php b/phpBB/language/en/acp/profile.php
index 92e642a993..8509845860 100644
--- a/phpBB/language/en/acp/profile.php
+++ b/phpBB/language/en/acp/profile.php
@@ -132,6 +132,8 @@ $lang = array_merge($lang, array(
'SAVE' => 'Save',
'SECOND_OPTION' => 'Second option',
+ 'SHOW_NOVALUE_FIELD' => 'Show field if no value was selected',
+ 'SHOW_NOVALUE_FIELD_EXPLAIN' => 'Determines if the profile field should be displayed if no value was selected for optional fields or if no value has been selected yet for required fields.',
'STEP_1_EXPLAIN_CREATE' => 'Here you can enter the first basic parameters of your new profile field. This information is needed for the second step where you’ll be able to set remaining options and tweak your profile field further.',
'STEP_1_EXPLAIN_EDIT' => 'Here you can change the basic parameters of your profile field. The relevant options are re-calculated within the second step.',
'STEP_1_TITLE_CREATE' => 'Add profile field',
diff --git a/phpBB/language/en/acp/search.php b/phpBB/language/en/acp/search.php
index cd319c66a9..9f947dc816 100644
--- a/phpBB/language/en/acp/search.php
+++ b/phpBB/language/en/acp/search.php
@@ -69,6 +69,22 @@ $lang = array_merge($lang, array(
'FULLTEXT_POSTGRES_MIN_WORD_LEN_EXPLAIN' => 'Words with at least this many characters will be included in the query to the database.',
'FULLTEXT_POSTGRES_MAX_WORD_LEN_EXPLAIN' => 'Words with no more than this many characters will be included in the query to the database.',
+ 'FULLTEXT_SPHINX_CONFIGURE' => 'Configure the following settings to generate sphinx config file',
+ 'FULLTEXT_SPHINX_DATA_PATH' => 'Path to data directory',
+ 'FULLTEXT_SPHINX_DATA_PATH_EXPLAIN' => 'It will be used to store the indexes and log files. You should create this directory outside the web accessible directories. (should have a trailing slash)',
+ 'FULLTEXT_SPHINX_DELTA_POSTS' => 'Number of posts in frequently updated delta index',
+ 'FULLTEXT_SPHINX_HOST' => 'Sphinx search daemon host',
+ 'FULLTEXT_SPHINX_HOST_EXPLAIN' => 'Host on which the sphinx search daemon (searchd) listens. Leave empty to use the default localhost',
+ 'FULLTEXT_SPHINX_INDEXER_MEM_LIMIT' => 'Indexer memory limit',
+ 'FULLTEXT_SPHINX_INDEXER_MEM_LIMIT_EXPLAIN' => 'This number should at all times be lower than the RAM available on your machine. If you experience periodic performance problems this might be due to the indexer consuming too many resources. It might help to lower the amount of memory available to the indexer.',
+ 'FULLTEXT_SPHINX_MAIN_POSTS' => 'Number of posts in main index',
+ 'FULLTEXT_SPHINX_PORT' => 'Sphinx search daemon port',
+ 'FULLTEXT_SPHINX_PORT_EXPLAIN' => 'Port on which the sphinx search daemon (searchd) listens. Leave empty to use the default Sphinx API port 9312',
+ 'FULLTEXT_SPHINX_WRONG_DATABASE' => 'The sphinx search for phpBB supports MySQL and PostgreSQL only.',
+ 'FULLTEXT_SPHINX_CONFIG_FILE' => 'Sphinx config file',
+ 'FULLTEXT_SPHINX_CONFIG_FILE_EXPLAIN' => 'The generated content of the sphinx config file. This data needs to be pasted into the sphinx.conf which is used by sphinx search daemon.',
+ 'FULLTEXT_SPHINX_NO_CONFIG_DATA' => 'The sphinx data and config directory paths are not defined. Please define them to generate the config file.',
+
'GENERAL_SEARCH_SETTINGS' => 'General search settings',
'GO_TO_SEARCH_INDEX' => 'Go to search index page',
diff --git a/phpBB/language/en/acp/users.php b/phpBB/language/en/acp/users.php
index 45cf36469b..865a2a0371 100644
--- a/phpBB/language/en/acp/users.php
+++ b/phpBB/language/en/acp/users.php
@@ -58,7 +58,7 @@ $lang = array_merge($lang, array(
'DELETE_POSTS' => 'Delete posts',
'DELETE_USER' => 'Delete user',
- 'DELETE_USER_EXPLAIN' => 'Please note that deleting a user is final, they cannot be recovered.',
+ 'DELETE_USER_EXPLAIN' => 'Please note that deleting a user is final, they cannot be recovered. Unread private messages sent by this user will be deleted and will not be available to their recipients.',
'FORCE_REACTIVATION_SUCCESS' => 'Successfully forced reactivation.',
'FOUNDER' => 'Founder',
diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php
index a6da52d4ef..e6022e3b79 100644
--- a/phpBB/language/en/common.php
+++ b/phpBB/language/en/common.php
@@ -42,6 +42,7 @@ $lang = array_merge($lang, array(
'TRANSLATION_INFO' => '',
'DIRECTION' => 'ltr',
'DATE_FORMAT' => '|d M Y|', // 01 Jan 2007 (with Relative days enabled)
+ 'DATETIME_FORMAT' => '|d M Y, H:i|', // 01 Jan 2007, 13:37 (with Relative days enabled)
'USER_LANG' => 'en-gb',
// You can define different rules for the determination of plural forms here.
@@ -74,7 +75,7 @@ $lang = array_merge($lang, array(
'ALL_FORUMS' => 'All forums',
'ALL_MESSAGES' => 'All messages',
'ALL_POSTS' => 'All posts',
- 'ALL_TIMES' => 'All times are %1$s %2$s',
+ 'ALL_TIMES' => 'All times are <abbr title="%2$s">%1$s</abbr>',
'ALL_TOPICS' => 'All Topics',
'AND' => 'And',
'ARE_WATCHING_FORUM' => 'You have subscribed to be notified of new posts in this forum.',
@@ -133,7 +134,7 @@ $lang = array_merge($lang, array(
'COLLAPSE_VIEW' => 'Collapse view',
'CLOSE_WINDOW' => 'Close window',
'COLOUR_SWATCH' => 'Colour swatch',
- 'COMMA_SEPARATOR' => ', ', // Used in pagination of ACP & prosilver, use localised comma if appropriate, eg: Ideographic or Arabic
+ 'COMMA_SEPARATOR' => ', ', // Comma used to join lists into a single string, use localised comma if appropriate, eg: Ideographic or Arabic
'CONFIRM' => 'Confirm',
'CONFIRM_CODE' => 'Confirmation code',
'CONFIRM_CODE_EXPLAIN' => 'Enter the code exactly as it appears. All letters are case insensitive.',
@@ -160,6 +161,8 @@ $lang = array_merge($lang, array(
'DISPLAY_MESSAGES' => 'Display messages from previous',
'DISPLAY_POSTS' => 'Display posts from previous',
'DISPLAY_TOPICS' => 'Display topics from previous',
+ 'DOWNLOAD_ALL' => 'Download all',
+ 'DOWNLOAD_ALL_ATTACHMENTS' => 'Download all attachments',
'DOWNLOADED' => 'Downloaded',
'DOWNLOADING_FILE' => 'Downloading file',
'DOWNLOAD_COUNTS' => array(
@@ -835,91 +838,33 @@ $lang = array_merge($lang, array(
'Dec' => 'Dec',
),
- 'tz' => array(
- '-12' => 'UTC - 12 hours',
- '-11' => 'UTC - 11 hours',
- '-10' => 'UTC - 10 hours',
- '-9.5' => 'UTC - 9:30 hours',
- '-9' => 'UTC - 9 hours',
- '-8' => 'UTC - 8 hours',
- '-7' => 'UTC - 7 hours',
- '-6' => 'UTC - 6 hours',
- '-5' => 'UTC - 5 hours',
- '-4.5' => 'UTC - 4:30 hours',
- '-4' => 'UTC - 4 hours',
- '-3.5' => 'UTC - 3:30 hours',
- '-3' => 'UTC - 3 hours',
- '-2' => 'UTC - 2 hours',
- '-1' => 'UTC - 1 hour',
- '0' => 'UTC',
- '1' => 'UTC + 1 hour',
- '2' => 'UTC + 2 hours',
- '3' => 'UTC + 3 hours',
- '3.5' => 'UTC + 3:30 hours',
- '4' => 'UTC + 4 hours',
- '4.5' => 'UTC + 4:30 hours',
- '5' => 'UTC + 5 hours',
- '5.5' => 'UTC + 5:30 hours',
- '5.75' => 'UTC + 5:45 hours',
- '6' => 'UTC + 6 hours',
- '6.5' => 'UTC + 6:30 hours',
- '7' => 'UTC + 7 hours',
- '8' => 'UTC + 8 hours',
- '8.75' => 'UTC + 8:45 hours',
- '9' => 'UTC + 9 hours',
- '9.5' => 'UTC + 9:30 hours',
- '10' => 'UTC + 10 hours',
- '10.5' => 'UTC + 10:30 hours',
- '11' => 'UTC + 11 hours',
- '11.5' => 'UTC + 11:30 hours',
- '12' => 'UTC + 12 hours',
- '12.75' => 'UTC + 12:45 hours',
- '13' => 'UTC + 13 hours',
- '14' => 'UTC + 14 hours',
- 'dst' => '[ <abbr title="Daylight Saving Time">DST</abbr> ]',
- ),
-
- 'tz_zones' => array(
- '-12' => '[UTC - 12] Baker Island Time',
- '-11' => '[UTC - 11] Niue Time, Samoa Standard Time',
- '-10' => '[UTC - 10] Hawaii-Aleutian Standard Time, Cook Island Time',
- '-9.5' => '[UTC - 9:30] Marquesas Islands Time',
- '-9' => '[UTC - 9] Alaska Standard Time, Gambier Island Time',
- '-8' => '[UTC - 8] Pacific Standard Time',
- '-7' => '[UTC - 7] Mountain Standard Time',
- '-6' => '[UTC - 6] Central Standard Time',
- '-5' => '[UTC - 5] Eastern Standard Time',
- '-4.5' => '[UTC - 4:30] Venezuelan Standard Time',
- '-4' => '[UTC - 4] Atlantic Standard Time',
- '-3.5' => '[UTC - 3:30] Newfoundland Standard Time',
- '-3' => '[UTC - 3] Amazon Standard Time, Central Greenland Time',
- '-2' => '[UTC - 2] Fernando de Noronha Time, South Georgia &amp; the South Sandwich Islands Time',
- '-1' => '[UTC - 1] Azores Standard Time, Cape Verde Time, Eastern Greenland Time',
- '0' => '[UTC] Western European Time, Greenwich Mean Time',
- '1' => '[UTC + 1] Central European Time, West African Time',
- '2' => '[UTC + 2] Eastern European Time, Central African Time',
- '3' => '[UTC + 3] Moscow Standard Time, Eastern African Time',
- '3.5' => '[UTC + 3:30] Iran Standard Time',
- '4' => '[UTC + 4] Gulf Standard Time, Samara Standard Time',
- '4.5' => '[UTC + 4:30] Afghanistan Time',
- '5' => '[UTC + 5] Pakistan Standard Time, Yekaterinburg Standard Time',
- '5.5' => '[UTC + 5:30] Indian Standard Time, Sri Lanka Time',
- '5.75' => '[UTC + 5:45] Nepal Time',
- '6' => '[UTC + 6] Bangladesh Time, Bhutan Time, Novosibirsk Standard Time',
- '6.5' => '[UTC + 6:30] Cocos Islands Time, Myanmar Time',
- '7' => '[UTC + 7] Indochina Time, Krasnoyarsk Standard Time',
- '8' => '[UTC + 8] Chinese Standard Time, Australian Western Standard Time, Irkutsk Standard Time',
- '8.75' => '[UTC + 8:45] Southeastern Western Australia Standard Time',
- '9' => '[UTC + 9] Japan Standard Time, Korea Standard Time, Chita Standard Time',
- '9.5' => '[UTC + 9:30] Australian Central Standard Time',
- '10' => '[UTC + 10] Australian Eastern Standard Time, Vladivostok Standard Time',
- '10.5' => '[UTC + 10:30] Lord Howe Standard Time',
- '11' => '[UTC + 11] Solomon Island Time, Magadan Standard Time',
- '11.5' => '[UTC + 11:30] Norfolk Island Time',
- '12' => '[UTC + 12] New Zealand Time, Fiji Time, Kamchatka Standard Time',
- '12.75' => '[UTC + 12:45] Chatham Islands Time',
- '13' => '[UTC + 13] Tonga Time, Phoenix Islands Time',
- '14' => '[UTC + 14] Line Island Time',
+ // Timezones can be translated. We use this for the Etc/GMT timezones here,
+ // because they are named invers to their offset.
+ 'timezones' => array(
+ 'Etc/GMT-12' => 'GMT+12',
+ 'Etc/GMT-11' => 'GMT+11',
+ 'Etc/GMT-10' => 'GMT+10',
+ 'Etc/GMT-9' => 'GMT+9',
+ 'Etc/GMT-8' => 'GMT+8',
+ 'Etc/GMT-7' => 'GMT+7',
+ 'Etc/GMT-6' => 'GMT+6',
+ 'Etc/GMT-5' => 'GMT+5',
+ 'Etc/GMT-4' => 'GMT+4',
+ 'Etc/GMT-3' => 'GMT+3',
+ 'Etc/GMT-2' => 'GMT+2',
+ 'Etc/GMT-1' => 'GMT+1',
+ 'Etc/GMT+1' => 'GMT-1',
+ 'Etc/GMT+2' => 'GMT-2',
+ 'Etc/GMT+3' => 'GMT-3',
+ 'Etc/GMT+4' => 'GMT-4',
+ 'Etc/GMT+5' => 'GMT-5',
+ 'Etc/GMT+6' => 'GMT-6',
+ 'Etc/GMT+7' => 'GMT-7',
+ 'Etc/GMT+8' => 'GMT-8',
+ 'Etc/GMT+9' => 'GMT-9',
+ 'Etc/GMT+10' => 'GMT-10',
+ 'Etc/GMT+11' => 'GMT-11',
+ 'Etc/GMT+12' => 'GMT-12',
),
// The value is only an example and will get replaced by the current time on view
diff --git a/phpBB/language/en/email/forum_notify.txt b/phpBB/language/en/email/forum_notify.txt
index fae5a83885..490780a0a6 100644
--- a/phpBB/language/en/email/forum_notify.txt
+++ b/phpBB/language/en/email/forum_notify.txt
@@ -2,7 +2,7 @@ Subject: Forum post notification - "{FORUM_NAME}"
Hello {USERNAME},
-You are receiving this notification because you are watching the forum, "{FORUM_NAME}" at "{SITENAME}". This forum has received a new reply to the topic "{TOPIC_TITLE}" since your last visit. You can use the following link to view the last unread reply, no more notifications will be sent until you visit the topic.
+You are receiving this notification because you are watching the forum, "{FORUM_NAME}" at "{SITENAME}". This forum has received a new reply to the topic "{TOPIC_TITLE}"<!-- IF AUTHOR_NAME --> by {AUTHOR_NAME}<!-- ENDIF --> since your last visit. You can use the following link to view the last unread reply, no more notifications will be sent until you visit the topic.
{U_NEWEST_POST}
diff --git a/phpBB/language/en/email/newtopic_notify.txt b/phpBB/language/en/email/newtopic_notify.txt
index 529bbf0f8f..eda1370938 100644
--- a/phpBB/language/en/email/newtopic_notify.txt
+++ b/phpBB/language/en/email/newtopic_notify.txt
@@ -2,7 +2,7 @@ Subject: New topic notification - "{FORUM_NAME}"
Hello {USERNAME},
-You are receiving this notification because you are watching the forum, "{FORUM_NAME}" at "{SITENAME}". This forum has received a new topic since your last visit, "{TOPIC_TITLE}". You can use the following link to view the forum, no more notifications will be sent until you visit the forum.
+You are receiving this notification because you are watching the forum, "{FORUM_NAME}" at "{SITENAME}". This forum has received a new topic<!-- IF AUTHOR_NAME --> by {AUTHOR_NAME}<!-- ENDIF --> since your last visit, "{TOPIC_TITLE}". You can use the following link to view the forum, no more notifications will be sent until you visit the forum.
{U_FORUM}
diff --git a/phpBB/language/en/email/topic_notify.txt b/phpBB/language/en/email/topic_notify.txt
index 99587b28e0..fcfbcc2abd 100644
--- a/phpBB/language/en/email/topic_notify.txt
+++ b/phpBB/language/en/email/topic_notify.txt
@@ -2,7 +2,7 @@ Subject: Topic reply notification - "{TOPIC_TITLE}"
Hello {USERNAME},
-You are receiving this notification because you are watching the topic, "{TOPIC_TITLE}" at "{SITENAME}". This topic has received a reply since your last visit. You can use the following link to view the replies made, no more notifications will be sent until you visit the topic.
+You are receiving this notification because you are watching the topic, "{TOPIC_TITLE}" at "{SITENAME}". This topic has received a reply<!-- IF AUTHOR_NAME --> by {AUTHOR_NAME}<!-- ENDIF --> since your last visit. You can use the following link to view the replies made, no more notifications will be sent until you visit the topic.
If you want to view the newest post made since your last visit, click the following link:
{U_NEWEST_POST}
diff --git a/phpBB/language/en/help_faq.php b/phpBB/language/en/help_faq.php
index f21a8d866e..5c99f81c06 100644
--- a/phpBB/language/en/help_faq.php
+++ b/phpBB/language/en/help_faq.php
@@ -87,7 +87,7 @@ $help = array(
),
array(
0 => 'I changed the timezone and the time is still wrong!',
- 1 => 'If you are sure you have set the timezone and Summer Time/DST correctly and the time is still incorrect, then the time stored on the server clock is incorrect. Please notify an administrator to correct the problem.'
+ 1 => 'If you are sure you have set the timezone correctly and the time is still incorrect, then the time stored on the server clock is incorrect. Please notify an administrator to correct the problem.'
),
array(
0 => 'My language is not in the list!',
diff --git a/phpBB/language/en/search.php b/phpBB/language/en/search.php
index d09b4303cd..71cbec4b41 100644
--- a/phpBB/language/en/search.php
+++ b/phpBB/language/en/search.php
@@ -105,6 +105,8 @@ $lang = array_merge($lang, array(
'SORT_FORUM' => 'Forum',
'SORT_POST_SUBJECT' => 'Post subject',
'SORT_TIME' => 'Post time',
+ 'SPHINX_SEARCH_FAILED' => 'Search failed: %s',
+ 'SPHINX_SEARCH_FAILED_LOG' => 'Sorry, search could not be performed. More information about this failure has been logged in the error log.',
'TOO_FEW_AUTHOR_CHARS' => array(
1 => 'You must specify at least %d character of the authors name.',
diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php
index e3971c75e2..648de587aa 100644
--- a/phpBB/language/en/ucp.php
+++ b/phpBB/language/en/ucp.php
@@ -103,7 +103,6 @@ $lang = array_merge($lang, array(
'BIRTHDAY_EXPLAIN' => 'Setting a year will list your age when it is your birthday.',
'BOARD_DATE_FORMAT' => 'My date format',
'BOARD_DATE_FORMAT_EXPLAIN' => 'The syntax used is identical to the PHP <a href="http://www.php.net/date">date()</a> function.',
- 'BOARD_DST' => 'Summer Time/<abbr title="Daylight Saving Time">DST</abbr> is in effect',
'BOARD_LANGUAGE' => 'My language',
'BOARD_STYLE' => 'My board style',
'BOARD_TIMEZONE' => 'My timezone',
@@ -270,7 +269,7 @@ $lang = array_merge($lang, array(
'MESSAGE_COLOURS' => 'Message colours',
'MESSAGE_DELETED' => 'Message successfully deleted.',
'MESSAGE_HISTORY' => 'Message history',
- 'MESSAGE_REMOVED_FROM_OUTBOX' => 'This message has been removed by its author before it was delivered.',
+ 'MESSAGE_REMOVED_FROM_OUTBOX' => 'This message was deleted by its author.',
'MESSAGE_SENT_ON' => 'on',
'MESSAGE_STORED' => 'This message has been sent successfully.',
'MESSAGE_TO' => 'To',
@@ -419,6 +418,8 @@ $lang = array_merge($lang, array(
'SIGNATURE_EXPLAIN' => 'This is a block of text that can be added to posts you make. There is a %d character limit.',
'SIGNATURE_PREVIEW' => 'Your signature will appear like this in posts',
'SIGNATURE_TOO_LONG' => 'Your signature is too long.',
+ 'SELECT_CURRENT_TIME' => 'Select current time',
+ 'SELECT_TIMEZONE' => 'Select timezone',
'SORT' => 'Sort',
'SORT_COMMENT' => 'File comment',
'SORT_DOWNLOADS' => 'Downloads',
@@ -428,6 +429,8 @@ $lang = array_merge($lang, array(
'SORT_SIZE' => 'File size',
'TIMEZONE' => 'Timezone',
+ 'TIMEZONE_DATE_SUGGESTION' => 'Suggestion: %s',
+ 'TIMEZONE_INVALID' => 'The timezone you selected is invalid.',
'TO' => 'To',
'TOO_MANY_RECIPIENTS' => 'You tried to send a private message to too many recipients.',
'TOO_MANY_REGISTERS' => 'You have exceeded the maximum number of registration attempts for this session. Please try again later.',
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php
index ed87b6c448..f142d182bc 100644
--- a/phpBB/memberlist.php
+++ b/phpBB/memberlist.php
@@ -575,6 +575,26 @@ switch ($mode)
unset($module);
}
+ /**
+ * Modify user data before we display the profile
+ *
+ * @event core.memberlist_view_profile
+ * @var array member Title of the index page
+ * @var bool user_notes_enabled Is the mcp user notes module
+ * enabled?
+ * @var bool warn_user_enabled Is the mcp warnings module
+ * enabled?
+ * @var bool zebra_enabled Is the ucp zebra module
+ * enabled?
+ * @var bool friends_enabled Is the ucp friends module
+ * enabled?
+ * @var bool foes_enabled Is the ucp foes module
+ * enabled?
+ * @since 3.1-A1
+ */
+ $vars = array('member', 'user_notes_enabled', 'warn_user_enabled', 'zebra_enabled', 'friends_enabled', 'foes_enabled');
+ extract($phpbb_dispatcher->trigger_event('core.memberlist_view_profile', compact($vars)));
+
$template->assign_vars(show_profile($member, $user_notes_enabled, $warn_user_enabled));
// Custom Profile Fields
@@ -1572,10 +1592,11 @@ switch ($mode)
}
}
+ phpbb_generate_template_pagination($template, $pagination_url, 'pagination', 'start', $total_users, $config['topics_per_page'], $start);
+
// Generate page
$template->assign_vars(array(
- 'PAGINATION' => generate_pagination($pagination_url, $total_users, $config['topics_per_page'], $start),
- 'PAGE_NUMBER' => on_page($total_users, $config['topics_per_page'], $start),
+ 'PAGE_NUMBER' => phpbb_on_page($template, $user, $pagination_url, $total_users, $config['topics_per_page'], $start),
'TOTAL_USERS' => $user->lang('LIST_USERS', (int) $total_users),
'PROFILE_IMG' => $user->img('icon_user_profile', $user->lang['PROFILE']),
@@ -1630,7 +1651,7 @@ page_footer();
*/
function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = false)
{
- global $config, $auth, $template, $user, $phpEx, $phpbb_root_path;
+ global $config, $auth, $template, $user, $phpEx, $phpbb_root_path, $phpbb_dispatcher;
$username = $data['username'];
$user_id = $data['user_id'];
@@ -1674,7 +1695,8 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f
if ($bday_year)
{
- $now = phpbb_gmgetdate(time() + $user->timezone + $user->dst);
+ $now = $user->create_datetime();
+ $now = phpbb_gmgetdate($now->getTimestamp() + $now->getOffset());
$diff = $now['mon'] - $bday_month;
if ($diff == 0)
@@ -1691,7 +1713,7 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f
}
// Dump it out to the template
- return array(
+ $template_data = array(
'AGE' => $age,
'RANK_TITLE' => $rank_title,
'JOINED' => $user->format_date($data['user_regdate']),
@@ -1739,6 +1761,19 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f
'L_VIEWING_PROFILE' => sprintf($user->lang['VIEWING_PROFILE'], $username),
);
+
+ /**
+ * Preparing a user's data before displaying it in profile and memberlist
+ *
+ * @event core.memberlist_prepare_profile_data
+ * @var array data Array with user's data
+ * @var array template_data Template array with user's data
+ * @since 3.1-A1
+ */
+ $vars = array('data', 'template_data');
+ extract($phpbb_dispatcher->trigger_event('core.memberlist_prepare_profile_data', compact($vars)));
+
+ return $template_data;
}
function _sort_last_active($first, $second)
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 7f57f693af..2d3cb9ab44 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -44,6 +44,41 @@ $mode = ($delete && !$preview && !$refresh && $submit) ? 'delete' : request_var
$error = $post_data = array();
$current_time = time();
+/**
+* This event allows you to alter the above parameters, such as submit and mode
+*
+* Note: $refresh must be true to retain previously submitted form data.
+*
+* Note: The template class will not work properly until $user->setup() is
+* called, and it has not been called yet. Extensions requiring template
+* assignments should use an event that comes later in this file.
+*
+* @event core.modify_posting_parameters
+* @var int post_id ID of the post
+* @var int topic_id ID of the topic
+* @var int forum_id ID of the forum
+* @var int draft_id ID of the draft
+* @var int lastclick Timestamp of when the form was last loaded
+* @var bool submit Whether or not the form has been submitted
+* @var bool preview Whether or not the post is being previewed
+* @var bool save Whether or not a draft is being saved
+* @var bool load Whether or not a draft is being loaded
+* @var bool delete Whether or not the post is being deleted
+* @var bool cancel Whether or not to cancel the form (returns to
+* viewtopic or viewforum depending on if the user
+* is posting a new topic or editing a post)
+* @var bool refresh Whether or not to retain previously submitted data
+* @var string mode What action to take if the form has been sumitted
+* post|reply|quote|edit|delete|bump|smilies|popup
+* @var array error Any error strings; a non-empty array aborts
+* form submission.
+* NOTE: Should be actual language strings, NOT
+* language keys.
+* @since 3.1-A1
+*/
+$vars = array('post_id', 'topic_id', 'forum_id', 'draft_id', 'lastclick', 'submit', 'preview', 'save', 'load', 'delete', 'cancel', 'refresh', 'mode', 'error');
+extract($phpbb_dispatcher->trigger_event('core.modify_posting_parameters', compact($vars)));
+
// Was cancel pressed? If so then redirect to the appropriate page
if ($cancel || ($current_time - $lastclick < 2 && $submit))
{
@@ -1362,7 +1397,7 @@ $template->assign_vars(array(
'FORUM_NAME' => $post_data['forum_name'],
'FORUM_DESC' => ($post_data['forum_desc']) ? generate_text_for_display($post_data['forum_desc'], $post_data['forum_desc_uid'], $post_data['forum_desc_bitfield'], $post_data['forum_desc_options']) : '',
'TOPIC_TITLE' => censor_text($post_data['topic_title']),
- 'MODERATORS' => (sizeof($moderators)) ? implode(', ', $moderators[$forum_id]) : '',
+ 'MODERATORS' => (sizeof($moderators)) ? implode($user->lang['COMMA_SEPARATOR'], $moderators[$forum_id]) : '',
'USERNAME' => ((!$preview && $mode != 'quote') || $preview) ? $post_data['username'] : '',
'SUBJECT' => $post_data['post_subject'],
'MESSAGE' => $post_data['post_text'],
@@ -1376,7 +1411,7 @@ $template->assign_vars(array(
'POST_DATE' => ($post_data['post_time']) ? $user->format_date($post_data['post_time']) : '',
'ERROR' => (sizeof($error)) ? implode('<br />', $error) : '',
'TOPIC_TIME_LIMIT' => (int) $post_data['topic_time_limit'],
- 'EDIT_REASON' => $post_data['post_edit_reason'],
+ 'EDIT_REASON' => $request->variable('edit_reason', ''),
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id"),
'U_VIEW_TOPIC' => ($mode != 'post') ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id") : '',
'U_PROGRESS_BAR' => append_sid("{$phpbb_root_path}posting.$phpEx", "f=$forum_id&amp;mode=popup"),
@@ -1417,6 +1452,14 @@ $template->assign_vars(array(
'S_HIDDEN_FIELDS' => $s_hidden_fields)
);
+/**
+* This event allows you to modify template variables for the posting screen
+*
+* @event core.posting_modify_template_vars
+* @since 3.1-A1
+*/
+$phpbb_dispatcher->trigger_event('core.posting_modify_template_vars');
+
// Build custom bbcodes array
display_custom_bbcodes();
diff --git a/phpBB/search.php b/phpBB/search.php
index 93cd0c31fd..7eda3c4d1d 100644
--- a/phpBB/search.php
+++ b/phpBB/search.php
@@ -280,21 +280,31 @@ if ($keywords || $author || $author_id || $search_id || $submit)
}
// We do some additional checks in the module to ensure it can actually be utilised
$error = false;
- $search = new $search_type($error);
+ $search = new $search_type($error, $phpbb_root_path, $phpEx, $auth, $config, $db, $user);
if ($error)
{
trigger_error($error);
}
+ $common_words = $search->get_common_words();
+
// let the search module split up the keywords
if ($keywords)
{
$correct_query = $search->split_keywords($keywords, $search_terms);
- if (!$correct_query || (empty($search->search_query) && !sizeof($author_id_ary) && !$search_id))
+ if (!$correct_query || (!$search->get_search_query() && !sizeof($author_id_ary) && !$search_id))
{
- $ignored = (sizeof($search->common_words)) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $search->common_words)) . '<br />' : '';
- trigger_error($ignored . $user->lang('NO_KEYWORDS', $user->lang('CHARACTERS', (int) $search->word_length['min']), $user->lang('CHARACTERS', (int) $search->word_length['max'])));
+ $ignored = (sizeof($common_words)) ? sprintf($user->lang['IGNORED_TERMS_EXPLAIN'], implode(' ', $common_words)) . '<br />' : '';
+ $word_length = $search->get_word_length();
+ if ($word_length)
+ {
+ trigger_error($ignored . $user->lang('NO_KEYWORDS', $user->lang('CHARACTERS', (int) $word_length['min']), $user->lang('CHARACTERS', (int) $word_length['max'])));
+ }
+ else
+ {
+ trigger_error($ignored);
+ }
}
}
@@ -526,7 +536,7 @@ if ($keywords || $author || $author_id || $search_id || $submit)
sort($m_approve_fid_ary);
sort($author_id_ary);
- if (!empty($search->search_query))
+ if ($search->get_search_query())
{
$total_match_count = $search->keyword_search($show_results, $search_fields, $search_terms, $sort_by_sql, $sort_key, $sort_dir, $sort_days, $ex_fid_ary, $m_approve_fid_ary, $topic_id, $author_id_ary, $sql_author_match, $id_ary, $start, $per_page);
}
@@ -603,14 +613,15 @@ if ($keywords || $author || $author_id || $search_id || $submit)
$phrase_search_disabled = $search->supports_phrase_search() ? false : true;
}
+ phpbb_generate_template_pagination($template, $u_search, 'pagination', 'start', $total_match_count, $per_page, $start);
+
$template->assign_vars(array(
'SEARCH_TITLE' => $l_search_title,
'SEARCH_MATCHES' => $l_search_matches,
'SEARCH_WORDS' => $keywords,
- 'SEARCHED_QUERY' => $search->search_query,
- 'IGNORED_WORDS' => (sizeof($search->common_words)) ? implode(' ', $search->common_words) : '',
- 'PAGINATION' => generate_pagination($u_search, $total_match_count, $per_page, $start),
- 'PAGE_NUMBER' => on_page($total_match_count, $per_page, $start),
+ 'SEARCHED_QUERY' => $search->get_search_query(),
+ 'IGNORED_WORDS' => (sizeof($common_words)) ? implode(' ', $common_words) : '',
+ 'PAGE_NUMBER' => phpbb_on_page($template, $user, $u_search, $total_match_count, $per_page, $start),
'PHRASE_SEARCH_DISABLED' => $phrase_search_disabled,
@@ -899,7 +910,6 @@ if ($keywords || $author || $author_id || $search_id || $submit)
'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
- 'PAGINATION' => topic_generate_pagination($replies, $view_topic_url),
'TOPIC_TYPE' => $topic_type,
'TOPIC_IMG_STYLE' => $folder_img,
@@ -1003,6 +1013,11 @@ if ($keywords || $author || $author_id || $search_id || $submit)
'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $forum_id),
'U_VIEW_POST' => (!empty($row['post_id'])) ? append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=" . $row['topic_id'] . '&amp;p=' . $row['post_id'] . (($u_hilit) ? '&amp;hilit=' . $u_hilit : '')) . '#p' . $row['post_id'] : '')
));
+
+ if ($show_results == 'topics')
+ {
+ phpbb_generate_template_pagination($template, $view_topic_url, 'searchresults.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true);
+ }
}
if ($topic_id && ($topic_id == $result_topic_id))
diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js
index 240fe7e51d..995b4b0ab7 100644
--- a/phpBB/styles/prosilver/template/forum_fn.js
+++ b/phpBB/styles/prosilver/template/forum_fn.js
@@ -42,11 +42,7 @@ function jumpto()
*/
function marklist(id, name, state)
{
- var parent = document.getElementById(id);
- if (!parent)
- {
- eval('parent = document.' + id);
- }
+ var parent = document.getElementById(id) || document[id];
if (!parent)
{
diff --git a/phpBB/styles/prosilver/template/forumlist_body.html b/phpBB/styles/prosilver/template/forumlist_body.html
index 723c2ffeda..488658d806 100644
--- a/phpBB/styles/prosilver/template/forumlist_body.html
+++ b/phpBB/styles/prosilver/template/forumlist_body.html
@@ -51,7 +51,7 @@
<!-- IF forumrow.U_UNAPPROVED_TOPICS --><a href="{forumrow.U_UNAPPROVED_TOPICS}">{UNAPPROVED_IMG}</a><!-- ENDIF -->
<!-- IF forumrow.LAST_POST_TIME --><dfn>{L_LAST_POST}</dfn>
<!-- IF forumrow.S_DISPLAY_SUBJECT -->
- <a href="{forumrow.U_LAST_POST}" title="{forumrow.LAST_POST_SUBJECT}">{forumrow.LAST_POST_SUBJECT_TRUNCATED}</a> <br />
+ <a href="{forumrow.U_LAST_POST}" title="{forumrow.LAST_POST_SUBJECT}" class="lastsubject">{forumrow.LAST_POST_SUBJECT_TRUNCATED}</a> <br />
<!-- ENDIF -->
{L_POST_BY_AUTHOR} {forumrow.LAST_POSTER_FULL}
<!-- IF not S_IS_BOT --><a href="{forumrow.U_LAST_POST}">{LAST_POST_IMG}</a> <!-- ENDIF --><br />{forumrow.LAST_POST_TIME}<!-- ELSE -->{L_NO_POSTS}<br />&nbsp;<!-- ENDIF --></span>
diff --git a/phpBB/styles/prosilver/template/login_body.html b/phpBB/styles/prosilver/template/login_body.html
index d8b9b01779..90d8191676 100644
--- a/phpBB/styles/prosilver/template/login_body.html
+++ b/phpBB/styles/prosilver/template/login_body.html
@@ -2,7 +2,9 @@
<script type="text/javascript">
// <![CDATA[
- onload_functions.push('document.getElementById("<!-- IF S_ADMIN_AUTH -->{PASSWORD_CREDENTIAL}<!-- ELSE -->{USERNAME_CREDENTIAL}<!-- ENDIF -->").focus();');
+ onload_functions.push(function () {
+ document.getElementById("<!-- IF S_ADMIN_AUTH -->{PASSWORD_CREDENTIAL}<!-- ELSE -->{USERNAME_CREDENTIAL}<!-- ENDIF -->").focus();
+ });
// ]]>
</script>
diff --git a/phpBB/styles/prosilver/template/mcp_forum.html b/phpBB/styles/prosilver/template/mcp_forum.html
index afd4f2308a..811aace154 100644
--- a/phpBB/styles/prosilver/template/mcp_forum.html
+++ b/phpBB/styles/prosilver/template/mcp_forum.html
@@ -10,11 +10,15 @@
<div class="panel">
<div class="inner">
- <!-- IF PAGINATION or TOTAL_TOPICS -->
+ <!-- IF .pagination or TOTAL_TOPICS -->
<ul class="linklist">
<li class="rightside pagination">
- <!-- IF TOTAL_TOPICS --> {TOTAL_TOPICS}<!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL_TOPICS --> {TOTAL_TOPICS} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
<!-- ENDIF -->
@@ -42,7 +46,20 @@
<!-- IF topicrow.S_TOPIC_REPORTED --><a href="{topicrow.U_MCP_REPORT}">{REPORTED_IMG}</a><!-- ENDIF -->
<!-- IF topicrow.S_MOVED_TOPIC and S_CAN_DELETE -->&nbsp;<a href="{topicrow.U_DELETE_TOPIC}" class="topictitle">[ {L_DELETE_SHADOW_TOPIC} ]</a><!-- ENDIF -->
<br />
- <!-- IF topicrow.PAGINATION --><strong class="pagination"><span>{topicrow.PAGINATION}</span></strong><!-- ENDIF -->
+ <!-- IF .topicrow.pagination -->
+ <div class="pagination">
+ <ul>
+ <!-- BEGIN pagination -->
+ <!-- IF topicrow.pagination.S_IS_PREV -->
+ <!-- ELSEIF topicrow.pagination.S_IS_CURRENT --><li class="active"><span>{topicrow.pagination.PAGE_NUMBER}</span></li>
+ <!-- ELSEIF topicrow.pagination.S_IS_ELLIPSIS --><li class="ellipsis"><span>{L_ELLIPSIS}</span></li>
+ <!-- ELSEIF topicrow.pagination.S_IS_NEXT -->
+ <!-- ELSE --><li><a href="{topicrow.pagination.PAGE_URL}">{topicrow.pagination.PAGE_NUMBER}</a></li>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+ </ul>
+ </div>
+ <!-- ENDIF -->
<!-- IF topicrow.ATTACH_ICON_IMG -->{topicrow.ATTACH_ICON_IMG} <!-- ENDIF -->{L_POST_BY_AUTHOR} {topicrow.TOPIC_AUTHOR_FULL} &raquo; {topicrow.FIRST_POST_TIME} </dt>
<dd class="posts">{topicrow.REPLIES} <dfn>{L_REPLIES}</dfn></dd>
<dd class="lastpost"><span><dfn>{L_LAST_POST} </dfn>{L_POST_BY_AUTHOR} {topicrow.LAST_POST_AUTHOR_FULL}<br />{topicrow.LAST_POST_TIME}</span>
@@ -72,11 +89,28 @@
<hr />
- <!-- IF PAGINATION or TOTAL_TOPICS -->
+ <!-- IF .pagination or TOTAL_TOPICS -->
<ul class="linklist">
<li class="rightside pagination">
- <!-- IF TOTAL_TOPICS --> {TOTAL_TOPICS}<!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL_TOPICS --> {TOTAL_TOPICS} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull;
+ <ul>
+ <!-- BEGIN pagination -->
+ <!-- IF pagination.S_IS_PREV -->
+ <!-- ELSEIF pagination.S_IS_CURRENT -->
+ <li class="active"><span>{pagination.PAGE_NUMBER}</span></li>
+ <!-- ELSEIF pagination.S_IS_ELLIPSIS -->
+ <li class="ellipsis"><span>{L_ELLIPSIS}</span></li>
+ <!-- ELSEIF pagination.S_IS_NEXT -->
+ <!-- ELSE -->
+ <li><a href="{pagination.PAGE_URL}">{pagination.PAGE_NUMBER}</a></li>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+ </ul>
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
<!-- ENDIF -->
diff --git a/phpBB/styles/prosilver/template/mcp_logs.html b/phpBB/styles/prosilver/template/mcp_logs.html
index b5561687b2..0d7f357d5b 100644
--- a/phpBB/styles/prosilver/template/mcp_logs.html
+++ b/phpBB/styles/prosilver/template/mcp_logs.html
@@ -12,8 +12,12 @@
{L_SEARCH_KEYWORDS}: <input type="text" class="inputbox autowidth" name="keywords" value="{S_KEYWORDS}" />&nbsp;<input type="submit" class="button2" name="filter" value="{L_SEARCH}" />
</li>
<li class="rightside pagination">
- <!-- IF TOTAL -->{TOTAL} <!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL -->{TOTAL} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
@@ -62,8 +66,12 @@
<ul class="linklist">
<li class="rightside pagination">
- <!-- IF TOTAL -->{TOTAL} <!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL -->{TOTAL} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
{S_FORM_TOKEN}
diff --git a/phpBB/styles/prosilver/template/mcp_notes_user.html b/phpBB/styles/prosilver/template/mcp_notes_user.html
index afe904dab3..d0d79f4664 100644
--- a/phpBB/styles/prosilver/template/mcp_notes_user.html
+++ b/phpBB/styles/prosilver/template/mcp_notes_user.html
@@ -55,8 +55,12 @@
{L_SEARCH_KEYWORDS}: <input type="text" class="inputbox autowidth" name="keywords" value="{S_KEYWORDS}" />&nbsp;<input type="submit" class="button2" name="filter" value="{L_SEARCH}" />
</li>
<li class="rightside pagination">
- <!-- IF TOTAL_REPORTS -->{TOTAL_REPORTS} <!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL_REPORTS -->{TOTAL_REPORTS} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
@@ -102,8 +106,12 @@
<ul class="linklist">
<li class="rightside pagination">
- <!-- IF TOTAL_REPORTS -->{TOTAL_REPORTS}<!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL_REPORTS -->{TOTAL_REPORTS} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
diff --git a/phpBB/styles/prosilver/template/mcp_queue.html b/phpBB/styles/prosilver/template/mcp_queue.html
index e9a477a24c..93483ae02a 100644
--- a/phpBB/styles/prosilver/template/mcp_queue.html
+++ b/phpBB/styles/prosilver/template/mcp_queue.html
@@ -18,8 +18,12 @@
<!-- IF .postrow -->
<ul class="linklist">
<li class="rightside pagination">
- <!-- IF TOTAL --> {TOTAL}<!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL --> {TOTAL} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
<ul class="topiclist">
@@ -73,8 +77,12 @@
<ul class="linklist">
<li class="rightside pagination">
- <!-- IF TOTAL -->{TOTAL}<!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL -->{TOTAL} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
<!-- ELSE -->
diff --git a/phpBB/styles/prosilver/template/mcp_reports.html b/phpBB/styles/prosilver/template/mcp_reports.html
index 95e7d9e021..aa67414713 100644
--- a/phpBB/styles/prosilver/template/mcp_reports.html
+++ b/phpBB/styles/prosilver/template/mcp_reports.html
@@ -20,8 +20,12 @@
<!-- IF .postrow -->
<ul class="linklist">
<li class="rightside pagination">
- <!-- IF TOTAL -->{TOTAL_REPORTS}<!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL -->{TOTAL_REPORTS} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
<ul class="topiclist">
@@ -74,8 +78,12 @@
<hr />
<ul class="linklist">
<li class="rightside pagination">
- <!-- IF TOTAL -->{TOTAL_REPORTS}<!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL -->{TOTAL_REPORTS} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
diff --git a/phpBB/styles/prosilver/template/mcp_topic.html b/phpBB/styles/prosilver/template/mcp_topic.html
index 8d0294d226..ed9307b11c 100644
--- a/phpBB/styles/prosilver/template/mcp_topic.html
+++ b/phpBB/styles/prosilver/template/mcp_topic.html
@@ -22,15 +22,13 @@ onload_functions.push('subPanels()');
<div id="minitabs">
<ul>
- <li id="display-panel-tab"<!-- IF not S_MERGE_VIEW --> class="activetab"<!-- ENDIF -->
+ <li id="display-panel-tab"<!-- IF not S_MERGE_VIEW --> class="activetab"<!-- ENDIF -->>
<a href="#minitabs" onclick="subPanels('display-panel'); return false;"><span>{L_DISPLAY_OPTIONS}</span></a>
</li>
<li id="split-panel-tab">
-
<a href="#minitabs" onclick="subPanels('split-panel'); return false;"><span>{L_SPLIT_TOPIC}</span></a>
</li>
<li id="merge-panel-tab"<!-- IF S_MERGE_VIEW --> class="activetab"<!-- ENDIF -->>
-
<a href="#minitabs" onclick="subPanels('merge-panel'); return false;"><span>{L_MERGE_POSTS}</span></a>
</li>
</ul>
@@ -139,11 +137,15 @@ onload_functions.push('subPanels()');
<hr />
- <!-- IF PAGINATION or TOTAL_POSTS -->
+ <!-- IF .pagination or TOTAL_POSTS -->
<ul class="linklist">
<li class="rightside pagination">
- <!-- IF TOTAL_POSTS --> {TOTAL_POSTS}<!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL_POSTS --> {TOTAL_POSTS} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
<!-- ENDIF -->
diff --git a/phpBB/styles/prosilver/template/mcp_warn_list.html b/phpBB/styles/prosilver/template/mcp_warn_list.html
index e4f82bbe67..fca377a823 100644
--- a/phpBB/styles/prosilver/template/mcp_warn_list.html
+++ b/phpBB/styles/prosilver/template/mcp_warn_list.html
@@ -12,8 +12,25 @@
<!-- IF .user -->
<ul class="linklist">
<li class="rightside pagination">
- <!-- IF TOTAL_USERS -->{TOTAL_USERS} <!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL_USERS -->{TOTAL_USERS} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull;
+ <ul>
+ <!-- BEGIN pagination -->
+ <!-- IF pagination.S_IS_PREV -->
+ <!-- ELSEIF pagination.S_IS_CURRENT -->
+ <li class="active"><span>{pagination.PAGE_NUMBER}</span></li>
+ <!-- ELSEIF pagination.S_IS_ELLIPSIS -->
+ <li class="ellipsis"><span>{L_ELLIPSIS}</span></li>
+ <!-- ELSEIF pagination.S_IS_NEXT -->
+ <!-- ELSE -->
+ <li><a href="{pagination.PAGE_URL}">{pagination.PAGE_NUMBER}</a></li>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+ </ul>
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
@@ -48,8 +65,12 @@
<ul class="linklist">
<li class="rightside pagination">
- <!-- IF TOTAL_USERS -->{TOTAL_USERS} <!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL_USERS -->{TOTAL_USERS} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
<!-- ELSE -->
diff --git a/phpBB/styles/prosilver/template/memberlist_body.html b/phpBB/styles/prosilver/template/memberlist_body.html
index d5154761e9..545d5000c4 100644
--- a/phpBB/styles/prosilver/template/memberlist_body.html
+++ b/phpBB/styles/prosilver/template/memberlist_body.html
@@ -41,8 +41,13 @@
</strong>
</li>
<li class="rightside pagination">
- {TOTAL_USERS} &bull;
- <!-- IF PAGINATION --><a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE -->{PAGE_NUMBER}<!-- ENDIF -->
+ {TOTAL_USERS}
+ <!-- IF .pagination -->
+ &bull;
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
@@ -150,7 +155,14 @@
<hr />
<ul class="linklist">
- <li class="rightside pagination">{TOTAL_USERS} &bull; <!-- IF PAGINATION --><a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE -->{PAGE_NUMBER}<!-- ENDIF --></li>
+ <li class="rightside pagination">{TOTAL_USERS}
+ <!-- IF .pagination -->
+ &bull;
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
+ </li>
</ul>
<!-- IF S_IN_SEARCH_POPUP -->
diff --git a/phpBB/styles/prosilver/template/overall_footer.html b/phpBB/styles/prosilver/template/overall_footer.html
index b473e7022c..7e43ff2d0a 100644
--- a/phpBB/styles/prosilver/template/overall_footer.html
+++ b/phpBB/styles/prosilver/template/overall_footer.html
@@ -4,9 +4,9 @@
<div class="navbar">
<div class="inner">
-
+
<ul class="linklist">
- <li class="icon-home"><a href="{U_INDEX}" accesskey="h">{L_INDEX}</a></li>
+ <li class="icon-home"><!-- IF U_SITE_HOME --><a href="{U_SITE_HOME}">{L_SITE_HOME}</a> <strong>&#8249;</strong> <!-- ENDIF --><a href="{U_INDEX}" accesskey="h">{L_INDEX}</a></li>
<!-- IF not S_IS_BOT -->
<!-- IF U_WATCH_FORUM_LINK --><li <!-- IF S_WATCHING_FORUM -->class="icon-unsubscribe"<!-- ELSE -->class="icon-subscribe"<!-- ENDIF -->><a href="{U_WATCH_FORUM_LINK}" title="{S_WATCH_FORUM_TITLE}" data-ajax="toggle_link" data-toggle-class="icon-<!-- IF not S_WATCHING_FORUM -->unsubscribe<!-- ELSE -->subscribe<!-- ENDIF -->" data-toggle-text="{S_WATCH_FORUM_TOGGLE}" data-toggle-url="{U_WATCH_FORUM_TOGGLE}">{S_WATCH_FORUM_TITLE}</a></li><!-- ENDIF -->
<!-- IF U_WATCH_TOPIC --><li <!-- IF S_WATCHING_TOPIC -->class="icon-unsubscribe"<!-- ELSE -->class="icon-subscribe"<!-- ENDIF -->><a href="{U_WATCH_TOPIC}" title="{S_WATCH_TOPIC_TITLE}" data-ajax="toggle_link" data-toggle-class="<!-- IF not S_WATCHING_TOPIC -->icon-unsubscribe<!-- ELSE -->icon-subscribe<!-- ENDIF -->" data-toggle-text="{S_WATCH_TOPIC_TOGGLE}" data-toggle-url="{U_WATCH_TOPIC_TOGGLE}">{S_WATCH_TOPIC_TITLE}</a></li><!-- ENDIF -->
diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html
index 349309ab4e..0900222d09 100644
--- a/phpBB/styles/prosilver/template/overall_header.html
+++ b/phpBB/styles/prosilver/template/overall_header.html
@@ -56,7 +56,7 @@
{
for (var i = 0; i < onload_functions.length; i++)
{
- eval(onload_functions[i]);
+ onload_functions[i]();
}
};
@@ -64,7 +64,7 @@
{
for (var i = 0; i < onunload_functions.length; i++)
{
- eval(onunload_functions[i]);
+ onunload_functions[i]();
}
};
@@ -95,7 +95,7 @@
<div class="inner">
<div id="site-description">
- <a href="{U_INDEX}" title="{L_INDEX}" id="logo">{SITE_LOGO_IMG}</a>
+ <a href="<!-- IF U_SITE_HOME -->{U_SITE_HOME}<!-- ELSE -->{U_INDEX}<!-- ENDIF -->" title="<!-- IF U_SITE_HOME -->{L_SITE_HOME}<!-- ELSE -->{L_INDEX}<!-- ENDIF -->" id="logo">{SITE_LOGO_IMG}</a>
<h1>{SITENAME}</h1>
<p>{SITE_DESCRIPTION}</p>
<p class="skiplink"><a href="#start_here">{L_SKIP}</a></p>
@@ -120,7 +120,7 @@
<div class="inner">
<ul class="linklist navlinks">
- <li class="icon-home"><a href="{U_INDEX}" accesskey="h">{L_INDEX}</a> <!-- BEGIN navlinks --> <strong>&#8249;</strong> <a href="{navlinks.U_VIEW_FORUM}">{navlinks.FORUM_NAME}</a><!-- END navlinks --></li>
+ <li class="icon-home"><!-- IF U_SITE_HOME --><a href="{U_SITE_HOME}">{L_SITE_HOME}</a> <strong>&#8249;</strong> <!-- ENDIF --><a href="{U_INDEX}" accesskey="h">{L_INDEX}</a> <!-- BEGIN navlinks --> <strong>&#8249;</strong> <a href="{navlinks.U_VIEW_FORUM}">{navlinks.FORUM_NAME}</a><!-- END navlinks --></li>
<!-- IF U_EMAIL_TOPIC --><li class="rightside"><a href="{U_EMAIL_TOPIC}" title="{L_EMAIL_TOPIC}" class="sendemail">{L_EMAIL_TOPIC}</a></li><!-- ENDIF -->
<!-- IF U_EMAIL_PM --><li class="rightside"><a href="{U_EMAIL_PM}" title="{L_EMAIL_PM}" class="sendemail">{L_EMAIL_PM}</a></li><!-- ENDIF -->
diff --git a/phpBB/styles/prosilver/template/pagination.html b/phpBB/styles/prosilver/template/pagination.html
new file mode 100644
index 0000000000..1c8441a9fd
--- /dev/null
+++ b/phpBB/styles/prosilver/template/pagination.html
@@ -0,0 +1,15 @@
+
+ <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull;
+ <ul>
+ <!-- BEGIN pagination -->
+ <!-- IF pagination.S_IS_PREV -->
+ <!-- ELSEIF pagination.S_IS_CURRENT -->
+ <li class="active"><span>{pagination.PAGE_NUMBER}</span></li>
+ <!-- ELSEIF pagination.S_IS_ELLIPSIS -->
+ <li class="ellipsis"><span>{L_ELLIPSIS}</span></li>
+ <!-- ELSEIF pagination.S_IS_NEXT -->
+ <!-- ELSE -->
+ <li><a href="{pagination.PAGE_URL}">{pagination.PAGE_NUMBER}</a></li>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+ </ul>
diff --git a/phpBB/styles/prosilver/template/posting_editor.html b/phpBB/styles/prosilver/template/posting_editor.html
index d1c86e7e13..99e518d486 100644
--- a/phpBB/styles/prosilver/template/posting_editor.html
+++ b/phpBB/styles/prosilver/template/posting_editor.html
@@ -1,6 +1,6 @@
<script type="text/javascript">
// <![CDATA[
- onload_functions.push('apply_onkeypress_event()');
+ onload_functions.push(apply_onkeypress_event);
// ]]>
</script>
diff --git a/phpBB/styles/prosilver/template/posting_smilies.html b/phpBB/styles/prosilver/template/posting_smilies.html
index d3d6293586..01b74c710c 100644
--- a/phpBB/styles/prosilver/template/posting_smilies.html
+++ b/phpBB/styles/prosilver/template/posting_smilies.html
@@ -17,7 +17,11 @@
</div>
</div>
-<div>{PAGINATION}</div>
+<div class="pagination">
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ENDIF -->
+</div>
<a href="#" onclick="window.close(); return false;">{L_CLOSE_WINDOW}</a>
<!-- INCLUDE simple_footer.html -->
diff --git a/phpBB/styles/prosilver/template/search_body.html b/phpBB/styles/prosilver/template/search_body.html
index a8baafa5f1..0d8797b2ff 100644
--- a/phpBB/styles/prosilver/template/search_body.html
+++ b/phpBB/styles/prosilver/template/search_body.html
@@ -2,7 +2,9 @@
<script type="text/javascript">
// <![CDATA[
- onload_functions.push('document.getElementById("keywords").focus();');
+ onload_functions.push(function () {
+ document.getElementById("keywords").focus();
+ });
// ]]>
</script>
diff --git a/phpBB/styles/prosilver/template/search_results.html b/phpBB/styles/prosilver/template/search_results.html
index 0a58605b31..063cc8c8ea 100644
--- a/phpBB/styles/prosilver/template/search_results.html
+++ b/phpBB/styles/prosilver/template/search_results.html
@@ -11,7 +11,7 @@
<p><a class="{S_CONTENT_FLOW_BEGIN}" href="{U_SEARCH}" title="{L_SEARCH_ADV}">{L_RETURN_TO_SEARCH_ADV}</a></p>
<!-- ENDIF -->
-<!-- IF PAGINATION or SEARCH_MATCHES or PAGE_NUMBER -->
+<!-- IF .pagination or SEARCH_MATCHES or PAGE_NUMBER -->
<form method="post" action="{S_SEARCH_ACTION}">
<div class="topic-actions">
@@ -26,7 +26,13 @@
<!-- ENDIF -->
<div class="rightside pagination">
- {SEARCH_MATCHES}<!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF -->
+ {SEARCH_MATCHES}
+ <!-- IF .pagination -->
+ &bull;
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</div>
</div>
@@ -59,7 +65,20 @@
<a href="{searchresults.U_VIEW_TOPIC}" class="topictitle">{searchresults.TOPIC_TITLE}</a> {searchresults.ATTACH_ICON_IMG}
<!-- IF searchresults.S_TOPIC_UNAPPROVED or searchresults.S_POSTS_UNAPPROVED --><a href="{searchresults.U_MCP_QUEUE}">{searchresults.UNAPPROVED_IMG}</a> <!-- ENDIF -->
<!-- IF searchresults.S_TOPIC_REPORTED --><a href="{searchresults.U_MCP_REPORT}">{REPORTED_IMG}</a><!-- ENDIF --><br />
- <!-- IF searchresults.PAGINATION --><strong class="pagination"><span>{searchresults.PAGINATION}</span></strong><!-- ENDIF -->
+ <!-- IF .searchresults.pagination -->
+ <div class="pagination">
+ <ul>
+ <!-- BEGIN pagination -->
+ <!-- IF searchresults.pagination.S_IS_PREV -->
+ <!-- ELSEIF searchresults.pagination.S_IS_CURRENT --><li class="active"><span>{searchresults.pagination.PAGE_NUMBER}</span></li>
+ <!-- ELSEIF searchresults.pagination.S_IS_ELLIPSIS --><li class="ellipsis"><span>{L_ELLIPSIS}</span></li>
+ <!-- ELSEIF searchresults.pagination.S_IS_NEXT -->
+ <!-- ELSE --><li><a href="{searchresults.pagination.PAGE_URL}">{searchresults.pagination.PAGE_NUMBER}</a></li>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+ </ul>
+ </div>
+ <!-- ENDIF -->
{L_POST_BY_AUTHOR} {searchresults.TOPIC_AUTHOR_FULL} &raquo; {searchresults.FIRST_POST_TIME} &raquo; {L_IN} <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a>
</dt>
<dd class="posts">{searchresults.TOPIC_REPLIES}</dd>
@@ -127,7 +146,7 @@
<!-- END searchresults -->
<!-- ENDIF -->
-<!-- IF PAGINATION or .searchresults or S_SELECT_SORT_KEY or S_SELECT_SORT_DAYS -->
+<!-- IF .pagination or .searchresults or S_SELECT_SORT_KEY or S_SELECT_SORT_DAYS -->
<form method="post" action="{S_SEARCH_ACTION}">
<fieldset class="display-options">
@@ -144,10 +163,29 @@
<hr />
<!-- ENDIF -->
-<!-- IF PAGINATION or .searchresults or PAGE_NUMBER -->
+<!-- IF .pagination or .searchresults or PAGE_NUMBER -->
<ul class="linklist">
<li class="rightside pagination">
- {SEARCH_MATCHES}<!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF -->
+ {SEARCH_MATCHES}
+ <!-- IF .pagination -->
+ &bull;
+ <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull;
+ <ul>
+ <!-- BEGIN pagination -->
+ <!-- IF pagination.S_IS_PREV -->
+ <!-- ELSEIF pagination.S_IS_CURRENT -->
+ <li class="active"><span>{pagination.PAGE_NUMBER}</span></li>
+ <!-- ELSEIF pagination.S_IS_ELLIPSIS -->
+ <li class="ellipsis"><span>{L_ELLIPSIS}</span></li>
+ <!-- ELSEIF pagination.S_IS_NEXT -->
+ <!-- ELSE -->
+ <li><a href="{pagination.PAGE_URL}">{pagination.PAGE_NUMBER}</a></li>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+ </ul>
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
<!-- ENDIF -->
diff --git a/phpBB/styles/prosilver/template/simple_header.html b/phpBB/styles/prosilver/template/simple_header.html
index 5440d66520..6026dfd329 100644
--- a/phpBB/styles/prosilver/template/simple_header.html
+++ b/phpBB/styles/prosilver/template/simple_header.html
@@ -26,7 +26,7 @@
{
for (var i = 0; i < onload_functions.length; i++)
{
- eval(onload_functions[i]);
+ onload_functions[i]();
}
}
@@ -34,7 +34,7 @@
{
for (var i = 0; i < onunload_functions.length; i++)
{
- eval(onunload_functions[i]);
+ onunload_functions[i]();
}
}
diff --git a/phpBB/styles/prosilver/template/timezone.js b/phpBB/styles/prosilver/template/timezone.js
new file mode 100644
index 0000000000..da0a2b0bfd
--- /dev/null
+++ b/phpBB/styles/prosilver/template/timezone.js
@@ -0,0 +1,19 @@
+(function($) { // Avoid conflicts with other libraries
+
+$('#tz_date').change(function() {
+ phpbb.timezone_switch_date(false);
+});
+
+$('#tz_select_date_suggest').click(function(){
+ phpbb.timezone_preselect_select(true);
+});
+
+$(document).ready(
+ phpbb.timezone_enable_date_selection
+);
+
+$(document).ready(
+ phpbb.timezone_preselect_select($('#tz_select_date_suggest').attr('data-is-registration') == 'true')
+);
+
+})(jQuery); // Avoid conflicts with other libraries
diff --git a/phpBB/styles/prosilver/template/timezone_option.html b/phpBB/styles/prosilver/template/timezone_option.html
new file mode 100644
index 0000000000..24d6aa677f
--- /dev/null
+++ b/phpBB/styles/prosilver/template/timezone_option.html
@@ -0,0 +1,20 @@
+<dl>
+ <dt><label for="timezone">{L_BOARD_TIMEZONE}:</label></dt>
+ <!-- IF S_TZ_DATE_OPTIONS -->
+ <dd id="tz_select_date" style="display: none;">
+ <select name="tz_date" id="tz_date" class="autowidth tz_select">
+ <option value="">{L_SELECT_CURRENT_TIME}</option>
+ {S_TZ_DATE_OPTIONS}
+ </select>
+ <input type="button" id="tz_select_date_suggest" class="button2" style="display: none;" data-is-registration="<!-- IF S_REGISTRATION -->true<!-- ELSE -->false<!-- ENDIF -->" data-l-suggestion="{L_TIMEZONE_DATE_SUGGESTION}" value="{L_TIMEZONE_DATE_SUGGESTION}" />
+ </dd>
+ <!-- ENDIF -->
+ <dd>
+ <select name="tz" id="timezone" class="autowidth tz_select">
+ <option value="">{L_SELECT_TIMEZONE}</option>
+ {S_TZ_OPTIONS}
+ </select>
+
+ <!-- INCLUDEJS template/timezone.js -->
+ </dd>
+</dl>
diff --git a/phpBB/styles/prosilver/template/ucp_attachments.html b/phpBB/styles/prosilver/template/ucp_attachments.html
index 84e4c2e875..2160d8fcf7 100644
--- a/phpBB/styles/prosilver/template/ucp_attachments.html
+++ b/phpBB/styles/prosilver/template/ucp_attachments.html
@@ -12,8 +12,12 @@
<!-- IF .attachrow -->
<ul class="linklist">
<li class="rightside pagination">
- <!-- IF TOTAL_ATTACHMENTS -->{TOTAL_ATTACHMENTS} {L_TITLE}<!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL_ATTACHMENTS -->{TOTAL_ATTACHMENTS} {L_TITLE} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
@@ -55,8 +59,12 @@
<ul class="linklist">
<li class="rightside pagination">
- <!-- IF TOTAL_ATTACHMENTS -->{TOTAL_ATTACHMENTS} {L_TITLE}<!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL_ATTACHMENTS -->{TOTAL_ATTACHMENTS} {L_TITLE} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
<!-- ELSE -->
diff --git a/phpBB/styles/prosilver/template/ucp_groups_manage.html b/phpBB/styles/prosilver/template/ucp_groups_manage.html
index a13c043e48..892a5d12b4 100644
--- a/phpBB/styles/prosilver/template/ucp_groups_manage.html
+++ b/phpBB/styles/prosilver/template/ucp_groups_manage.html
@@ -159,7 +159,11 @@
<ul class="linklist">
<li class="leftside pagination">
- <!-- IF PAGINATION --><a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{S_ON_PAGE}</a> &bull; <span>{PAGINATION}</span><!-- ELSE -->{S_ON_PAGE}<!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {S_ON_PAGE}
+ <!-- ENDIF -->
</li>
</ul>
diff --git a/phpBB/styles/prosilver/template/ucp_groups_membership.html b/phpBB/styles/prosilver/template/ucp_groups_membership.html
index a312911ae4..5cb238082a 100644
--- a/phpBB/styles/prosilver/template/ucp_groups_membership.html
+++ b/phpBB/styles/prosilver/template/ucp_groups_membership.html
@@ -93,7 +93,7 @@
<!-- IF pending.GROUP_DESC --><br />{pending.GROUP_DESC}<!-- ENDIF -->
<!-- IF not pending.GROUP_SPECIAL --><br /><i>{pending.GROUP_STATUS}</i><!-- ENDIF -->
</dt>
- <dd class="mark"><input type="radio" name="selected" value="{pending.GROUP_ID}" <!-- IF pending.GROUP_SPECIAL -->disabled="diabled"<!-- ENDIF --> /></dd>
+ <dd class="mark"><input type="radio" name="selected" value="{pending.GROUP_ID}" <!-- IF pending.GROUP_SPECIAL -->disabled="disabled"<!-- ENDIF --> /></dd>
</dl>
</li>
<!-- END pending -->
diff --git a/phpBB/styles/prosilver/template/ucp_main_bookmarks.html b/phpBB/styles/prosilver/template/ucp_main_bookmarks.html
index 89502bbc3d..8707a749c1 100644
--- a/phpBB/styles/prosilver/template/ucp_main_bookmarks.html
+++ b/phpBB/styles/prosilver/template/ucp_main_bookmarks.html
@@ -36,7 +36,20 @@
<!-- IF topicrow.S_UNREAD_TOPIC --><a href="{topicrow.U_NEWEST_POST}">{NEWEST_POST_IMG}</a> <!-- ENDIF --><a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a>
<!-- IF topicrow.S_TOPIC_UNAPPROVED or topicrow.S_POSTS_UNAPPROVED --><a href="{topicrow.U_MCP_QUEUE}">{topicrow.UNAPPROVED_IMG}</a> <!-- ENDIF -->
<!-- IF topicrow.S_TOPIC_REPORTED --><a href="{topicrow.U_MCP_REPORT}">{REPORTED_IMG}</a><!-- ENDIF --><br />
- <!-- IF topicrow.PAGINATION --><strong class="pagination"><span>{topicrow.PAGINATION}</span></strong><!-- ENDIF -->
+ <!-- IF .topicrow.pagination -->
+ <div class="pagination">
+ <ul>
+ <!-- BEGIN pagination -->
+ <!-- IF topicrow.pagination.S_IS_PREV -->
+ <!-- ELSEIF topicrow.pagination.S_IS_CURRENT --><li class="active"><span>{topicrow.pagination.PAGE_NUMBER}</span></li>
+ <!-- ELSEIF topicrow.pagination.S_IS_ELLIPSIS --><li class="ellipsis"><span>{L_ELLIPSIS}</span></li>
+ <!-- ELSEIF topicrow.pagination.S_IS_NEXT -->
+ <!-- ELSE --><li><a href="{topicrow.pagination.PAGE_URL}">{topicrow.pagination.PAGE_NUMBER}</a></li>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+ </ul>
+ </div>
+ <!-- ENDIF -->
<!-- IF topicrow.ATTACH_ICON_IMG -->{topicrow.ATTACH_ICON_IMG} <!-- ENDIF -->{L_POST_BY_AUTHOR} {topicrow.TOPIC_AUTHOR_FULL} &raquo; {topicrow.FIRST_POST_TIME}
</dt>
<dd class="lastpost"><span><dfn>{L_LAST_POST} </dfn>{L_POST_BY_AUTHOR} {topicrow.LAST_POST_AUTHOR_FULL}
@@ -50,8 +63,12 @@
</ul>
<ul class="linklist">
<li class="rightside pagination">
- <!-- IF TOTAL_TOPICS --> {TOTAL_TOPICS} <!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL_TOPICS --> {TOTAL_TOPICS} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
<!-- ELSE -->
diff --git a/phpBB/styles/prosilver/template/ucp_main_front.html b/phpBB/styles/prosilver/template/ucp_main_front.html
index b7a0619227..04767b6c01 100644
--- a/phpBB/styles/prosilver/template/ucp_main_front.html
+++ b/phpBB/styles/prosilver/template/ucp_main_front.html
@@ -16,7 +16,20 @@
<dl class="icon {topicrow.TOPIC_IMG_STYLE}">
<dt <!-- IF topicrow.TOPIC_ICON_IMG -->style="background-image: url({T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}); background-repeat: no-repeat;"<!-- ENDIF -->>
<!-- IF topicrow.S_UNREAD --><a href="{topicrow.U_NEWEST_POST}">{NEWEST_POST_IMG}</a> <!-- ENDIF --><a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a><br />
- <!-- IF topicrow.PAGINATION --><strong class="pagination"><span>{topicrow.PAGINATION}</span></strong><!-- ENDIF -->
+ <!-- IF .topicrow.pagination -->
+ <div class="pagination">
+ <ul>
+ <!-- BEGIN pagination -->
+ <!-- IF topicrow.pagination.S_IS_PREV -->
+ <!-- ELSEIF topicrow.pagination.S_IS_CURRENT --><li class="active"><span>{topicrow.pagination.PAGE_NUMBER}</span></li>
+ <!-- ELSEIF topicrow.pagination.S_IS_ELLIPSIS --><li class="ellipsis"><span>{L_ELLIPSIS}</span></li>
+ <!-- ELSEIF topicrow.pagination.S_IS_NEXT -->
+ <!-- ELSE --><li><a href="{topicrow.pagination.PAGE_URL}">{topicrow.pagination.PAGE_NUMBER}</a></li>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+ </ul>
+ </div>
+ <!-- ENDIF -->
<!-- IF topicrow.ATTACH_ICON_IMG -->{topicrow.ATTACH_ICON_IMG} <!-- ENDIF -->{L_POST_BY_AUTHOR} {topicrow.TOPIC_AUTHOR_FULL} &raquo; {topicrow.FIRST_POST_TIME}
</dt>
<dd class="lastpost"><span>{L_LAST_POST} {L_POST_BY_AUTHOR} {topicrow.LAST_POST_AUTHOR_FULL}
diff --git a/phpBB/styles/prosilver/template/ucp_main_subscribed.html b/phpBB/styles/prosilver/template/ucp_main_subscribed.html
index ab65d9b3ae..11957aa90d 100644
--- a/phpBB/styles/prosilver/template/ucp_main_subscribed.html
+++ b/phpBB/styles/prosilver/template/ucp_main_subscribed.html
@@ -56,7 +56,20 @@
<!-- IF topicrow.S_UNREAD_TOPIC --><a href="{topicrow.U_NEWEST_POST}">{NEWEST_POST_IMG}</a> <!-- ENDIF --><a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a>
<!-- IF topicrow.S_TOPIC_UNAPPROVED or topicrow.S_POSTS_UNAPPROVED --><a href="{topicrow.U_MCP_QUEUE}">{topicrow.UNAPPROVED_IMG}</a> <!-- ENDIF -->
<!-- IF topicrow.S_TOPIC_REPORTED --><a href="{topicrow.U_MCP_REPORT}">{REPORTED_IMG}</a><!-- ENDIF --><br />
- <!-- IF topicrow.PAGINATION --><strong class="pagination"><span>{topicrow.PAGINATION}</span></strong><!-- ENDIF -->
+ <!-- IF .topicrow.pagination -->
+ <div class="pagination">
+ <ul>
+ <!-- BEGIN pagination -->
+ <!-- IF topicrow.pagination.S_IS_PREV -->
+ <!-- ELSEIF topicrow.pagination.S_IS_CURRENT --><li class="active"><span>{topicrow.pagination.PAGE_NUMBER}</span></li>
+ <!-- ELSEIF topicrow.pagination.S_IS_ELLIPSIS --><li class="ellipsis"><span>{L_ELLIPSIS}</span></li>
+ <!-- ELSEIF topicrow.pagination.S_IS_NEXT -->
+ <!-- ELSE --><li><a href="{topicrow.pagination.PAGE_URL}">{topicrow.pagination.PAGE_NUMBER}</a></li>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+ </ul>
+ </div>
+ <!-- ENDIF -->
<!-- IF topicrow.ATTACH_ICON_IMG -->{topicrow.ATTACH_ICON_IMG} <!-- ENDIF -->{L_POST_BY_AUTHOR} {topicrow.TOPIC_AUTHOR_FULL} &raquo; {topicrow.FIRST_POST_TIME}
</dt>
<dd class="lastpost"><span><dfn>{L_LAST_POST} </dfn>{L_POST_BY_AUTHOR} {topicrow.LAST_POST_AUTHOR_FULL}
@@ -69,8 +82,12 @@
</ul>
<ul class="linklist">
<li class="rightside pagination">
- <!-- IF TOTAL_TOPICS --> {TOTAL_TOPICS} <!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL_TOPICS --> {TOTAL_TOPICS} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
</ul>
<!-- ELSEIF S_TOPIC_NOTIFY -->
diff --git a/phpBB/styles/prosilver/template/ucp_pm_message_header.html b/phpBB/styles/prosilver/template/ucp_pm_message_header.html
index d6659fad0f..c02a34f83d 100644
--- a/phpBB/styles/prosilver/template/ucp_pm_message_header.html
+++ b/phpBB/styles/prosilver/template/ucp_pm_message_header.html
@@ -20,8 +20,12 @@
<li class="rightside pagination">
<!-- IF S_VIEW_MESSAGE --><a class="{S_CONTENT_FLOW_BEGIN}" href="{U_CURRENT_FOLDER}">{L_RETURN_TO} {CUR_FOLDER_NAME}</a><!-- ENDIF -->
<!-- IF FOLDER_CUR_MESSAGES neq 0 -->
- <!-- IF TOTAL_MESSAGES -->{TOTAL_MESSAGES}<!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL_MESSAGES -->{TOTAL_MESSAGES} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
<!-- ENDIF -->
</li>
</ul>
diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewfolder.html b/phpBB/styles/prosilver/template/ucp_pm_viewfolder.html
index 20394b254e..68df22c68e 100644
--- a/phpBB/styles/prosilver/template/ucp_pm_viewfolder.html
+++ b/phpBB/styles/prosilver/template/ucp_pm_viewfolder.html
@@ -103,8 +103,12 @@
<ul class="linklist">
<!-- IF TOTAL_MESSAGES or S_VIEW_MESSAGE -->
<li class="rightside pagination">
- <!-- IF TOTAL_MESSAGES -->{TOTAL_MESSAGES}<!-- ENDIF -->
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF TOTAL_MESSAGES -->{TOTAL_MESSAGES} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</li>
<!-- ENDIF -->
</ul>
diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html
index 2e7a7c4ac9..b022bcd979 100644
--- a/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html
+++ b/phpBB/styles/prosilver/template/ucp_pm_viewmessage.html
@@ -41,12 +41,24 @@
<div class="content">{MESSAGE}</div>
<!-- IF S_HAS_ATTACHMENTS -->
- <dl class="attachbox">
- <dt>{L_ATTACHMENTS}</dt>
- <!-- BEGIN attachment -->
- <dd>{attachment.DISPLAY_ATTACHMENT}</dd>
- <!-- END attachment -->
- </dl>
+ <dl class="attachbox">
+ <dt>
+ {L_ATTACHMENTS}
+ <!-- IF S_HAS_MULTIPLE_ATTACHMENTS -->
+ <div class="dl_links">
+ <strong>{L_DOWNLOAD_ALL}:</strong>
+ <ul>
+ <!-- BEGIN dl_method -->
+ <li>[ <a href="{dl_method.LINK}">{dl_method.TYPE}</a> ]</li>
+ <!-- END dl_method -->
+ </ul>
+ </div>
+ <!-- ENDIF -->
+ </dt>
+ <!-- BEGIN attachment -->
+ <dd>{attachment.DISPLAY_ATTACHMENT}</dd>
+ <!-- END attachment -->
+ </dl>
<!-- ENDIF -->
<!-- IF S_DISPLAY_NOTICE -->
diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewmessage_print.html b/phpBB/styles/prosilver/template/ucp_pm_viewmessage_print.html
index bafb64dbc8..a024a170a7 100644
--- a/phpBB/styles/prosilver/template/ucp_pm_viewmessage_print.html
+++ b/phpBB/styles/prosilver/template/ucp_pm_viewmessage_print.html
@@ -17,10 +17,9 @@
<div id="page-header">
<h1>{SITENAME}</h1>
- <p>{SITE_DESCRIPTION}<br /><a href="{U_FORUM}">{U_FORUM}</a></p>
+ <p>{SITE_DESCRIPTION}</p>
- <h2>{TOPIC_TITLE}</h2>
- <p><a href="{U_TOPIC}">{U_TOPIC}</a></p>
+ <h2>{L_PRIVATE_MESSAGING}</h2>
</div>
<div id="page-body">
@@ -43,7 +42,7 @@
<div id="page-footer">
<div class="page-number">{S_TIMEZONE}<br />{PAGE_NUMBER}</div>
- <div class="copyright">Powered by phpBB&reg; Forum Software &copy; phpBB Group<br />http://www.phpbb.com/</div>
+ <div class="copyright">Powered by phpBB&reg; Forum Software &copy; phpBB Group<br />https://www.phpbb.com/</div>
</div>
</div>
diff --git a/phpBB/styles/prosilver/template/ucp_prefs_personal.html b/phpBB/styles/prosilver/template/ucp_prefs_personal.html
index 1c829899fd..29c01e03b9 100644
--- a/phpBB/styles/prosilver/template/ucp_prefs_personal.html
+++ b/phpBB/styles/prosilver/template/ucp_prefs_personal.html
@@ -73,17 +73,7 @@
<dd><select name="style" id="style">{S_STYLE_OPTIONS}</select></dd>
</dl>
<!-- ENDIF -->
- <dl>
- <dt><label for="timezone">{L_BOARD_TIMEZONE}:</label></dt>
- <dd><select name="tz" id="timezone" class="autowidth">{S_TZ_OPTIONS}</select></dd>
- </dl>
- <dl>
- <dt><label for="dst1">{L_BOARD_DST}:</label></dt>
- <dd>
- <label for="dst1"><input type="radio" name="dst" id="dst1" value="1"<!-- IF S_DST --> checked="checked"<!-- ENDIF --> /> {L_YES}</label>
- <label for="dst0"><input type="radio" name="dst" id="dst0" value="0"<!-- IF not S_DST --> checked="checked"<!-- ENDIF --> /> {L_NO}</label>
- </dd>
- </dl>
+ <!-- INCLUDE timezone_option.html -->
<dl>
<dt><label for="dateformat">{L_BOARD_DATE_FORMAT}:</label><br /><span>{L_BOARD_DATE_FORMAT_EXPLAIN}</span></dt>
<dd>
diff --git a/phpBB/styles/prosilver/template/ucp_register.html b/phpBB/styles/prosilver/template/ucp_register.html
index 47253af37c..e14ca6493d 100644
--- a/phpBB/styles/prosilver/template/ucp_register.html
+++ b/phpBB/styles/prosilver/template/ucp_register.html
@@ -12,7 +12,7 @@
}
<!-- IF CAPTCHA_TEMPLATE and S_CONFIRM_REFRESH -->
- onload_functions.push('apply_onkeypress_event()');
+ onload_functions.push(apply_onkeypress_event);
<!-- ENDIF -->
// ]]>
@@ -53,10 +53,8 @@
<dt><label for="lang">{L_LANGUAGE}:</label></dt>
<dd><select name="lang" id="lang" onchange="change_language(this.value); return false;" tabindex="6" title="{L_LANGUAGE}">{S_LANG_OPTIONS}</select></dd>
</dl>
- <dl>
- <dt><label for="tz">{L_TIMEZONE}:</label></dt>
- <dd><select name="tz" id="tz" tabindex="7" class="autowidth">{S_TZ_OPTIONS}</select></dd>
- </dl>
+
+ <!-- INCLUDE timezone_option.html -->
<!-- IF .profile_fields -->
<dl><dd><strong>{L_ITEMS_REQUIRED}</strong></dd></dl>
@@ -106,4 +104,7 @@
</div>
</form>
+<script type="text/javascript" src="{T_SUPER_TEMPLATE_PATH}/timezone.js"></script>
+<script type="text/javascript">phpbb_preselect_tz_select();</script>
+
<!-- INCLUDE overall_footer.html -->
diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html
index f5ff1d3f98..373a172918 100644
--- a/phpBB/styles/prosilver/template/viewforum_body.html
+++ b/phpBB/styles/prosilver/template/viewforum_body.html
@@ -34,7 +34,7 @@
<!-- INCLUDE forumlist_body.html -->
<!-- ENDIF -->
-<!-- IF S_DISPLAY_POST_INFO or PAGINATION or TOTAL_POSTS or TOTAL_TOPICS -->
+<!-- IF S_DISPLAY_POST_INFO or .pagination or TOTAL_POSTS or TOTAL_TOPICS -->
<div class="topic-actions" <!-- IF S_HAS_SUBFORUM -->style="margin-top: 2em;"<!-- ENDIF -->>
<!-- IF not S_IS_BOT and S_DISPLAY_POST_INFO -->
@@ -55,11 +55,14 @@
</div>
<!-- ENDIF -->
- <!-- IF PAGINATION or TOTAL_POSTS or TOTAL_TOPICS -->
+ <!-- IF .pagination or TOTAL_POSTS or TOTAL_TOPICS -->
<div class="pagination">
- <!-- IF not S_IS_BOT and U_MARK_TOPICS --><a href="{U_MARK_TOPICS}" accesskey="m" data-ajax="true">{L_MARK_TOPICS_READ}</a> &bull; <!-- ENDIF --><!-- IF TOTAL_TOPICS -->{TOTAL_TOPICS}<!-- ENDIF -->
- <!-- IF PAGE_NUMBER -->
- <!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF -->
+ <!-- IF not S_IS_BOT and U_MARK_TOPICS --><a href="{U_MARK_TOPICS}" accesskey="m" data-ajax="true">{L_MARK_TOPICS_READ}</a> &bull; <!-- ENDIF -->
+ <!-- IF TOTAL_TOPICS -->{TOTAL_TOPICS} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
<!-- ENDIF -->
</div>
<!-- ENDIF -->
@@ -142,7 +145,20 @@
<dt<!-- IF topicrow.TOPIC_ICON_IMG and S_TOPIC_ICONS --> style="background-image: url({T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}); background-repeat: no-repeat;"<!-- ENDIF --> title="{topicrow.TOPIC_FOLDER_IMG_ALT}"><!-- IF topicrow.S_UNREAD_TOPIC --><a href="{topicrow.U_NEWEST_POST}">{NEWEST_POST_IMG}</a> <!-- ENDIF --><a href="{topicrow.U_VIEW_TOPIC}" class="topictitle">{topicrow.TOPIC_TITLE}</a>
<!-- IF topicrow.S_TOPIC_UNAPPROVED or topicrow.S_POSTS_UNAPPROVED --><a href="{topicrow.U_MCP_QUEUE}">{topicrow.UNAPPROVED_IMG}</a> <!-- ENDIF -->
<!-- IF topicrow.S_TOPIC_REPORTED --><a href="{topicrow.U_MCP_REPORT}">{REPORTED_IMG}</a><!-- ENDIF --><br />
- <!-- IF topicrow.PAGINATION --><strong class="pagination"><span>{topicrow.PAGINATION}</span></strong><!-- ENDIF -->
+ <!-- IF .topicrow.pagination -->
+ <div class="pagination">
+ <ul>
+ <!-- BEGIN pagination -->
+ <!-- IF topicrow.pagination.S_IS_PREV -->
+ <!-- ELSEIF topicrow.pagination.S_IS_CURRENT --><li class="active"><span>{topicrow.pagination.PAGE_NUMBER}</span></li>
+ <!-- ELSEIF topicrow.pagination.S_IS_ELLIPSIS --><li class="ellipsis"><span>{L_ELLIPSIS}</span></li>
+ <!-- ELSEIF topicrow.pagination.S_IS_NEXT -->
+ <!-- ELSE --><li><a href="{topicrow.pagination.PAGE_URL}">{topicrow.pagination.PAGE_NUMBER}</a></li>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+ </ul>
+ </div>
+ <!-- ENDIF -->
<!-- IF topicrow.ATTACH_ICON_IMG -->{topicrow.ATTACH_ICON_IMG} <!-- ENDIF -->{L_POST_BY_AUTHOR} {topicrow.TOPIC_AUTHOR_FULL} &raquo; {topicrow.FIRST_POST_TIME}
<!-- IF topicrow.S_POST_GLOBAL and FORUM_ID != topicrow.FORUM_ID --> &raquo; {L_IN} <a href="{topicrow.U_VIEW_FORUM}">{topicrow.FORUM_NAME}</a><!-- ENDIF -->
</dt>
@@ -193,13 +209,16 @@
</div>
<!-- ENDIF -->
- <!-- IF PAGINATION or TOTAL_POSTS or TOTAL_TOPICS -->
+ <!-- IF PAGE_NUMBER or TOTAL_POSTS or TOTAL_TOPICS -->
<div class="pagination">
<!-- IF TOTAL_TOPICS and not S_IS_BOT and U_MARK_TOPICS --><a href="{U_MARK_TOPICS}">{L_MARK_TOPICS_READ}</a> &bull; <!-- ENDIF -->
- <!-- IF TOTAL_POSTS and not NEWEST_USER --> {TOTAL_POSTS}<!-- ELSEIF TOTAL_TOPICS and not NEWEST_USER --> {TOTAL_TOPICS}<!-- ENDIF -->
- <!-- IF TOTAL_USERS -->{TOTAL_USERS}<!-- ENDIF -->
- <!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a>
- &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF -->
+ <!-- IF TOTAL_POSTS and not NEWEST_USER --> {TOTAL_POSTS}<!-- ELSEIF TOTAL_TOPICS and not NEWEST_USER --> {TOTAL_TOPICS} &bull; <!-- ENDIF -->
+ <!-- IF TOTAL_USERS -->{TOTAL_USERS} &bull; <!-- ENDIF -->
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</div>
<!-- ENDIF -->
</div>
diff --git a/phpBB/styles/prosilver/template/viewonline_body.html b/phpBB/styles/prosilver/template/viewonline_body.html
index 9da8202783..9156090407 100644
--- a/phpBB/styles/prosilver/template/viewonline_body.html
+++ b/phpBB/styles/prosilver/template/viewonline_body.html
@@ -4,7 +4,13 @@
<p>{TOTAL_GUEST_USERS_ONLINE}<!-- IF S_SWITCH_GUEST_DISPLAY --> &bull; <a href="{U_SWITCH_GUEST_DISPLAY}">{L_SWITCH_GUEST_DISPLAY}</a><!-- ENDIF --></p>
<ul class="linklist">
- <li class="rightside pagination"><!-- IF PAGINATION --><a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE -->{PAGE_NUMBER}<!-- ENDIF --></li>
+ <li class="rightside pagination">
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
+ </li>
</ul>
<div class="forumbg forumbg-table">
@@ -50,7 +56,13 @@
<!-- IF LEGEND --><p><em>{L_LEGEND}: {LEGEND}</em></p><!-- ENDIF -->
<ul class="linklist">
- <li class="rightside pagination"><!-- IF PAGINATION --><a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE -->{PAGE_NUMBER}<!-- ENDIF --></li>
+ <li class="rightside pagination">
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
+ </li>
</ul>
<!-- INCLUDE jumpbox.html -->
diff --git a/phpBB/styles/prosilver/template/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html
index 1af512732d..4534dc5bcc 100644
--- a/phpBB/styles/prosilver/template/viewtopic_body.html
+++ b/phpBB/styles/prosilver/template/viewtopic_body.html
@@ -45,10 +45,14 @@
</div>
<!-- ENDIF -->
- <!-- IF PAGINATION or TOTAL_POSTS -->
+ <!-- IF .pagination or TOTAL_POSTS -->
<div class="pagination">
- <!-- IF U_VIEW_UNREAD_POST and not S_IS_BOT --><a href="{U_VIEW_UNREAD_POST}">{L_VIEW_UNREAD_POST}</a> &bull; <!-- ENDIF -->{TOTAL_POSTS}
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ <!-- IF U_VIEW_UNREAD_POST and not S_IS_BOT --><a href="{U_VIEW_UNREAD_POST}">{L_VIEW_UNREAD_POST}</a> &bull; <!-- ENDIF -->{TOTAL_POSTS} &bull;
+ <!-- IF .pagination -->
+ <!-- INCLUDE pagination.html -->
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</div>
<!-- ENDIF -->
@@ -153,7 +157,19 @@
<!-- IF postrow.S_HAS_ATTACHMENTS -->
<dl class="attachbox">
- <dt>{L_ATTACHMENTS}</dt>
+ <dt>
+ {L_ATTACHMENTS}
+ <!-- IF postrow.S_MULTIPLE_ATTACHMENTS -->
+ <div class="dl_links">
+ <strong>{L_DOWNLOAD_ALL}:</strong>
+ <ul>
+ <!-- BEGIN dl_method -->
+ <li>[ <a href="{postrow.dl_method.LINK}">{postrow.dl_method.TYPE}</a> ]</li>
+ <!-- END dl_method -->
+ </ul>
+ </div>
+ <!-- ENDIF -->
+ </dt>
<!-- BEGIN attachment -->
<dd>{postrow.attachment.DISPLAY_ATTACHMENT}</dd>
<!-- END attachment -->
@@ -252,10 +268,35 @@
<!-- ENDIF -->
</div>
- <!-- IF PAGINATION or TOTAL_POSTS -->
+ <!-- IF S_HAS_ATTACHMENTS -->
+ <div class="dl_links">
+ <strong>{L_DOWNLOAD_ALL_ATTACHMENTS}:</strong>
+ <ul>
+ <!-- BEGIN dl_method -->
+ <li>[ <a href="{dl_method.LINK}">{dl_method.TYPE}</a> ]</li>
+ <!-- END dl_method -->
+ </ul>
+ </div>
+ <!-- ENDIF -->
+
+ <!-- IF .pagination or TOTAL_POSTS -->
<div class="pagination">
- {TOTAL_POSTS}
- <!-- IF PAGE_NUMBER --><!-- IF PAGINATION --> &bull; <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull; <span>{PAGINATION}</span><!-- ELSE --> &bull; {PAGE_NUMBER}<!-- ENDIF --><!-- ENDIF -->
+ {TOTAL_POSTS} &bull;
+ <!-- IF .pagination -->
+ <a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{PAGE_NUMBER}</a> &bull;
+ <ul>
+ <!-- BEGIN pagination -->
+ <!-- IF pagination.S_IS_PREV -->
+ <!-- ELSEIF pagination.S_IS_CURRENT --><li class="active"><span>{pagination.PAGE_NUMBER}</span></li>
+ <!-- ELSEIF pagination.S_IS_ELLIPSIS --><li class="ellipsis"><span>{L_ELLIPSIS}</span></li>
+ <!-- ELSEIF pagination.S_IS_NEXT -->
+ <!-- ELSE --><li><a href="{pagination.PAGE_URL}">{pagination.PAGE_NUMBER}</a></li>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+ </ul>
+ <!-- ELSE -->
+ {PAGE_NUMBER}
+ <!-- ENDIF -->
</div>
<!-- ENDIF -->
</div>
diff --git a/phpBB/styles/prosilver/template/viewtopic_print.html b/phpBB/styles/prosilver/template/viewtopic_print.html
index b28608d6f1..88d65ea407 100644
--- a/phpBB/styles/prosilver/template/viewtopic_print.html
+++ b/phpBB/styles/prosilver/template/viewtopic_print.html
@@ -38,7 +38,7 @@
<div id="page-footer">
<div class="page-number">{S_TIMEZONE}<br />{PAGE_NUMBER}</div>
- <div class="copyright">Powered by phpBB&reg; Forum Software &copy; phpBB Group<br />http://www.phpbb.com/</div>
+ <div class="copyright">Powered by phpBB&reg; Forum Software &copy; phpBB Group<br />https://www.phpbb.com/</div>
</div>
</div>
diff --git a/phpBB/styles/prosilver/theme/colours.css b/phpBB/styles/prosilver/theme/colours.css
index fe6a7a7fda..29968cbb14 100644
--- a/phpBB/styles/prosilver/theme/colours.css
+++ b/phpBB/styles/prosilver/theme/colours.css
@@ -145,25 +145,30 @@ dl.details dd {
/* Pagination
---------------------------------------- */
-.pagination span strong {
- color: #FFFFFF;
- background-color: #4692BF;
- border-color: #4692BF;
-}
-
-.pagination span a, .pagination span a:link, .pagination span a:visited {
+.pagination li a, .pagination li a:link, .pagination li a:visited {
color: #5C758C;
background-color: #ECEDEE;
border-color: #B4BAC0;
}
-.pagination span a:hover {
+.pagination li.ellipsis span {
+ background-color: transparent;
+ color: #000
+}
+
+.pagination li.active span {
+ color: #FFFFFF;
+ background-color: #4692BF;
+ border-color: #4692BF;
+}
+
+.pagination li a:hover, .pagination .active a:hover {
border-color: #368AD2;
background-color: #368AD2;
color: #FFF;
}
-.pagination span a:active {
+.pagination li a:active, .pagination li.active a:active {
color: #5C758C;
background-color: #ECEDEE;
border-color: #B4BAC0;
diff --git a/phpBB/styles/prosilver/theme/common.css b/phpBB/styles/prosilver/theme/common.css
index 3dda343829..4b4fa263b1 100644
--- a/phpBB/styles/prosilver/theme/common.css
+++ b/phpBB/styles/prosilver/theme/common.css
@@ -483,6 +483,7 @@ dl.details dd {
overflow: hidden;
}
+
/* Pagination
---------------------------------------- */
.pagination {
@@ -493,51 +494,43 @@ dl.details dd {
float: right;
}
-.pagination span.page-sep {
- display: none;
-}
-
li.pagination {
margin-top: 0;
}
-.pagination strong, .pagination b {
- font-weight: normal;
+.pagination img {
+ vertical-align: middle;
}
-.pagination span strong {
- padding: 0 2px;
- margin: 0 2px;
- font-weight: normal;
- border: 1px solid transparent;
- font-size: 0.9em;
+.pagination ul {
+ display: inline-block;
+ *display: inline; /* IE7 inline-block hack */
+ *zoom: 1;
+ margin-left: 0;
+ margin-bottom: 0;
}
-.pagination span a, .pagination span a:link, .pagination span a:visited, .pagination span a:active {
+.pagination ul li, dl .pagination ul li, dl.icon .pagination ul li {
+ display: inline;
+ padding: 0;
+}
+
+.pagination li a, .pagnation li span, li .pagination li a, li .pagnation li span, .pagination li.active span, .pagination li.ellipsis span {
font-weight: normal;
text-decoration: none;
- margin: 0 2px;
padding: 0 2px;
border: 1px solid transparent;
font-size: 0.9em;
line-height: 1.5em;
}
-.pagination span a:hover {
- text-decoration: none;
-}
-
-.pagination img {
- vertical-align: middle;
-}
-
/* Pagination in viewforum for multipage topics */
.row .pagination {
display: block;
float: right;
width: auto;
margin-top: 0;
- padding: 1px 0 1px 15px;
+ padding: 1px 0 1px 8px;
font-size: 0.9em;
background: none 0 50% no-repeat;
}
@@ -623,9 +616,10 @@ li.pagination {
}
div.rules {
- padding: 0 10px;
margin: 10px 0;
font-size: 1.1em;
+ padding: 5px 10px;
+ border-radius: 7px;
}
div.rules ul, div.rules ol {
diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css
index 60903911dd..b6012f8a63 100644
--- a/phpBB/styles/prosilver/theme/content.css
+++ b/phpBB/styles/prosilver/theme/content.css
@@ -702,3 +702,26 @@ dl.pmlist dd {
margin-left: 61% !important;
margin-bottom: 2px;
}
+
+.topic-actions div.dl_links {
+ padding: 10px 0 0 10px;
+}
+
+div.dl_links {
+ display: inline-block;
+ text-transform: none;
+}
+
+.dl_links strong {
+ font-weight: bold;
+}
+
+.dl_links ul {
+ list-style-type: none;
+ margin: 0;
+ display: inline-block;
+}
+
+.dl_links li {
+ display: inline-block;
+}
diff --git a/phpBB/styles/prosilver/theme/cp.css b/phpBB/styles/prosilver/theme/cp.css
index bf7d304ca4..da3ec1736e 100644
--- a/phpBB/styles/prosilver/theme/cp.css
+++ b/phpBB/styles/prosilver/theme/cp.css
@@ -260,8 +260,9 @@ ul.cplist {
/* Friends list */
.cp-mini {
- padding: 0 5px;
margin: 10px 15px 10px 5px;
+ padding: 5px 10px;
+ border-radius: 7px;
}
dl.mini dt {
diff --git a/phpBB/styles/prosilver/theme/forms.css b/phpBB/styles/prosilver/theme/forms.css
index 77b3be5cfa..8829211934 100644
--- a/phpBB/styles/prosilver/theme/forms.css
+++ b/phpBB/styles/prosilver/theme/forms.css
@@ -32,6 +32,11 @@ option {
padding-right: 1em;
}
+select optgroup option {
+ padding-right: 1em;
+ font-family: Verdana, Helvetica, Arial, sans-serif;
+}
+
textarea {
font-family: "Lucida Grande", Verdana, Helvetica, Arial, sans-serif;
width: 60%;
diff --git a/phpBB/styles/prosilver/theme/links.css b/phpBB/styles/prosilver/theme/links.css
index 3cb6e928b5..66c3aed03e 100644
--- a/phpBB/styles/prosilver/theme/links.css
+++ b/phpBB/styles/prosilver/theme/links.css
@@ -66,6 +66,15 @@ a.topictitle:hover {
text-decoration: underline;
}
+a.lastsubject {
+ font-weight: bold;
+ text-decoration: none;
+}
+
+a.lastsubject:hover {
+ text-decoration: underline;
+}
+
/* Post body links */
.postlink {
text-decoration: none;
diff --git a/phpBB/styles/prosilver/theme/stylesheet.css b/phpBB/styles/prosilver/theme/stylesheet.css
index 419de4e6ec..48a00c6803 100644
--- a/phpBB/styles/prosilver/theme/stylesheet.css
+++ b/phpBB/styles/prosilver/theme/stylesheet.css
@@ -3,7 +3,7 @@
Style name: prosilver (the default phpBB 3.1.x style)
Based on style:
Original author: Tom Beddard ( http://www.subblue.com/ )
- Modified by: phpBB Group ( http://www.phpbb.com/ )
+ Modified by: phpBB Group ( https://www.phpbb.com/ )
--------------------------------------------------------------
*/
diff --git a/phpBB/styles/subsilver2/template/breadcrumbs.html b/phpBB/styles/subsilver2/template/breadcrumbs.html
index f8476ec37a..73386ed851 100644
--- a/phpBB/styles/subsilver2/template/breadcrumbs.html
+++ b/phpBB/styles/subsilver2/template/breadcrumbs.html
@@ -1,7 +1,7 @@
<table class="tablebg" width="100%" cellspacing="1" cellpadding="0" style="margin-top: 5px;">
<tr>
<td class="row1">
- <p class="breadcrumbs"><a href="{U_INDEX}">{L_INDEX}</a><!-- BEGIN navlinks --> &#187; <a href="{navlinks.U_VIEW_FORUM}">{navlinks.FORUM_NAME}</a><!-- END navlinks --></p>
+ <p class="breadcrumbs"><!-- IF U_SITE_HOME --><a href="{U_SITE_HOME}">{L_SITE_HOME}</a> <strong>&#187;</strong> <!-- ENDIF --><a href="{U_INDEX}">{L_INDEX}</a><!-- BEGIN navlinks --> &#187; <a href="{navlinks.U_VIEW_FORUM}">{navlinks.FORUM_NAME}</a><!-- END navlinks --></p>
<p class="datetime">{S_TIMEZONE}</p>
</td>
</tr>
diff --git a/phpBB/styles/subsilver2/template/forumlist_body.html b/phpBB/styles/subsilver2/template/forumlist_body.html
index b9a1102df0..521eaf3c16 100644
--- a/phpBB/styles/subsilver2/template/forumlist_body.html
+++ b/phpBB/styles/subsilver2/template/forumlist_body.html
@@ -61,7 +61,7 @@
<td class="row2" align="center" nowrap="nowrap">
<!-- IF forumrow.LAST_POST_TIME -->
<!-- IF forumrow.S_DISPLAY_SUBJECT -->
- <p class="topicdetails"><a href="{forumrow.U_LAST_POST}" title="{forumrow.LAST_POST_SUBJECT}">{forumrow.LAST_POST_SUBJECT_TRUNCATED}</a></p>
+ <p class="topicdetails"><a href="{forumrow.U_LAST_POST}" title="{forumrow.LAST_POST_SUBJECT}" class="lastsubject">{forumrow.LAST_POST_SUBJECT_TRUNCATED}</a></p>
<!-- ENDIF -->
<p class="topicdetails"><!-- IF forumrow.U_UNAPPROVED_TOPICS --><a href="{forumrow.U_UNAPPROVED_TOPICS}" class="imageset">{UNAPPROVED_IMG}</a>&nbsp;<!-- ENDIF -->{forumrow.LAST_POST_TIME}</p>
<p class="topicdetails">{forumrow.LAST_POSTER_FULL}
diff --git a/phpBB/styles/subsilver2/template/memberlist_search.html b/phpBB/styles/subsilver2/template/memberlist_search.html
index 96ffad00d6..ab1ecca2ee 100644
--- a/phpBB/styles/subsilver2/template/memberlist_search.html
+++ b/phpBB/styles/subsilver2/template/memberlist_search.html
@@ -43,11 +43,7 @@
*/
function marklist(id, name, state)
{
- var parent = document.getElementById(id);
- if (!parent)
- {
- eval('parent = document.' + id);
- }
+ var parent = document.getElementById(id) || document[id];
if (!parent)
{
diff --git a/phpBB/styles/subsilver2/template/overall_header.html b/phpBB/styles/subsilver2/template/overall_header.html
index 5d5489338a..8bedec4c9e 100644
--- a/phpBB/styles/subsilver2/template/overall_header.html
+++ b/phpBB/styles/subsilver2/template/overall_header.html
@@ -71,11 +71,7 @@ function find_username(url)
*/
function marklist(id, name, state)
{
- var parent = document.getElementById(id);
- if (!parent)
- {
- eval('parent = document.' + id);
- }
+ var parent = document.getElementById(id) || document[id];
if (!parent)
{
@@ -83,7 +79,7 @@ function marklist(id, name, state)
}
var rb = parent.getElementsByTagName('input');
-
+
for (var r = 0; r < rb.length; r++)
{
if (rb[r].name.substr(0, name.length) == name)
@@ -143,7 +139,7 @@ function marklist(id, name, state)
<div id="logodesc">
<table width="100%" cellspacing="0">
<tr>
- <td><a href="{U_INDEX}" class="imageset">{SITE_LOGO_IMG}</a></td>
+ <td><a href="<!-- IF U_SITE_HOME -->{U_SITE_HOME}<!-- ELSE -->{U_INDEX}<!-- ENDIF -->" class="imageset">{SITE_LOGO_IMG}</a></td>
<td width="100%" align="center"><h1>{SITENAME}</h1><span class="gen">{SITE_DESCRIPTION}</span></td>
</tr>
</table>
diff --git a/phpBB/styles/subsilver2/template/pagination.html b/phpBB/styles/subsilver2/template/pagination.html
index a36eb88d8f..f78bb554fc 100644
--- a/phpBB/styles/subsilver2/template/pagination.html
+++ b/phpBB/styles/subsilver2/template/pagination.html
@@ -1 +1,11 @@
-<!-- IF PAGINATION --><b><a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a>&nbsp;&nbsp;<!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE --> &nbsp;<a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b><!-- ENDIF -->
+<!-- IF .pagination -->
+ <b><a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{L_GOTO_PAGE}</a>
+ <!-- BEGIN pagination -->
+ <!-- IF pagination.S_IS_PREV --><a href="{pagination.PAGE_URL}">{pagination.PAGE_NUMBER}</a>
+ <!-- ELSEIF pagination.S_IS_CURRENT --><strong>{pagination.PAGE_NUMBER}</strong>
+ <!-- ELSEIF pagination.S_IS_ELLIPSIS --> {L_ELLIPSIS}
+ <!-- ELSEIF pagination.S_IS_NEXT --><a href="{pagination.PAGE_URL}">{pagination.PAGE_NUMBER}</a>
+ <!-- ELSE --><a href="{pagination.PAGE_URL}">{pagination.PAGE_NUMBER}</a>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+<!-- ENDIF -->
diff --git a/phpBB/styles/subsilver2/template/posting_smilies.html b/phpBB/styles/subsilver2/template/posting_smilies.html
index 691ba239b2..30a80e26ab 100644
--- a/phpBB/styles/subsilver2/template/posting_smilies.html
+++ b/phpBB/styles/subsilver2/template/posting_smilies.html
@@ -16,7 +16,20 @@
<th>{L_SMILIES}</th>
</tr>
<tr>
- <td class="row1" align="center" valign="middle"><!-- BEGIN smiley --> <a href="#" onclick="initInsertions(); insert_text('{smiley.A_SMILEY_CODE}', true, true); return false;"><img src="{smiley.SMILEY_IMG}" width="{smiley.SMILEY_WIDTH}" height="{smiley.SMILEY_HEIGHT}" alt="{smiley.SMILEY_CODE}" title="{smiley.SMILEY_DESC}" hspace="2" vspace="2" /></a> <!-- END smiley --><br />{PAGINATION}<br /><a class="nav" href="#" onclick="window.close(); return false;">{L_CLOSE_WINDOW}</a></td>
+ <td class="row1" align="center" valign="middle"><!-- BEGIN smiley --> <a href="#" onclick="initInsertions(); insert_text('{smiley.A_SMILEY_CODE}', true, true); return false;"><img src="{smiley.SMILEY_IMG}" width="{smiley.SMILEY_WIDTH}" height="{smiley.SMILEY_HEIGHT}" alt="{smiley.SMILEY_CODE}" title="{smiley.SMILEY_DESC}" hspace="2" vspace="2" /></a> <!-- END smiley --><br />
+ <!-- IF .pagination -->
+ <b><a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{L_GOTO_PAGE}</a>
+ <!-- BEGIN pagination -->
+ <!-- IF pagination.S_IS_PREV --><a href="{pagination.PAGE_URL}">{pagination.PAGE_NUMBER}</a>
+ <!-- ELSEIF pagination.S_IS_CURRENT --><strong>{pagination.PAGE_NUMBER}</strong>
+ <!-- ELSEIF pagination.S_IS_ELLIPSIS --> {L_ELLIPSIS}
+ <!-- ELSEIF pagination.S_IS_NEXT --><a href="{pagination.PAGE_URL}">{pagination.PAGE_NUMBER}</a>
+ <!-- ELSE --><a href="{pagination.PAGE_URL}">{pagination.PAGE_NUMBER}</a>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+ <br />
+ <!-- ENDIF -->
+ <a class="nav" href="#" onclick="window.close(); return false;">{L_CLOSE_WINDOW}</a></td>
</tr>
</table>
</td>
diff --git a/phpBB/styles/subsilver2/template/search_results.html b/phpBB/styles/subsilver2/template/search_results.html
index d8a1879ca7..a143a186d7 100644
--- a/phpBB/styles/subsilver2/template/search_results.html
+++ b/phpBB/styles/subsilver2/template/search_results.html
@@ -42,8 +42,17 @@
<!-- IF searchresults.S_TOPIC_REPORTED -->
<a href="{searchresults.U_MCP_REPORT}" class="imageset">{REPORTED_IMG}</a>&nbsp;
<!-- ENDIF -->
- <!-- IF searchresults.PAGINATION -->
- <p class="gensmall"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {searchresults.PAGINATION} ] </p>
+ <!-- IF .searchresults.pagination -->
+ <p class="gensmall"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}:
+ <!-- BEGIN pagination -->
+ <!-- IF searchresults.pagination.S_IS_PREV -->
+ <!-- ELSEIF searchresults.pagination.S_IS_CURRENT --><strong>{searchresults.pagination.PAGE_NUMBER}</strong>
+ <!-- ELSEIF searchresults.pagination.S_IS_ELLIPSIS --> {L_ELLIPSIS}
+ <!-- ELSEIF searchresults.pagination.S_IS_NEXT -->
+ <!-- ELSE --><a href="{searchresults.pagination.PAGE_URL}">{searchresults.pagination.PAGE_NUMBER}</a>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+ ] </p>
<!-- ENDIF -->
<p class="gensmall">{L_IN} <a href="{searchresults.U_VIEW_FORUM}">{searchresults.FORUM_TITLE}</a></p>
</td>
diff --git a/phpBB/styles/subsilver2/template/simple_footer.html b/phpBB/styles/subsilver2/template/simple_footer.html
index 6082b71891..38a86c5001 100644
--- a/phpBB/styles/subsilver2/template/simple_footer.html
+++ b/phpBB/styles/subsilver2/template/simple_footer.html
@@ -2,7 +2,7 @@
</div>
<div id="wrapfooter">
- <span class="copyright">{CREDIT_LINE}
+ <span class="copyright">{CREDIT_LINE}</span>
</div>
<script type="text/javascript" src="{T_JQUERY_LINK}"></script>
diff --git a/phpBB/styles/subsilver2/template/timezone.js b/phpBB/styles/subsilver2/template/timezone.js
new file mode 100644
index 0000000000..da0a2b0bfd
--- /dev/null
+++ b/phpBB/styles/subsilver2/template/timezone.js
@@ -0,0 +1,19 @@
+(function($) { // Avoid conflicts with other libraries
+
+$('#tz_date').change(function() {
+ phpbb.timezone_switch_date(false);
+});
+
+$('#tz_select_date_suggest').click(function(){
+ phpbb.timezone_preselect_select(true);
+});
+
+$(document).ready(
+ phpbb.timezone_enable_date_selection
+);
+
+$(document).ready(
+ phpbb.timezone_preselect_select($('#tz_select_date_suggest').attr('data-is-registration') == 'true')
+);
+
+})(jQuery); // Avoid conflicts with other libraries
diff --git a/phpBB/styles/subsilver2/template/timezone_option.html b/phpBB/styles/subsilver2/template/timezone_option.html
new file mode 100644
index 0000000000..c7e47a8ee4
--- /dev/null
+++ b/phpBB/styles/subsilver2/template/timezone_option.html
@@ -0,0 +1,20 @@
+<tr>
+ <td class="row1" width="50%"><b class="genmed">{L_BOARD_TIMEZONE}:</b></td>
+ <td class="row2">
+ <!-- IF S_TZ_DATE_OPTIONS -->
+ <div id="tz_select_date" style="display: none;">
+ <select name="tz_date" id="tz_date" class="autowidth tz_select">
+ <option value="">{L_SELECT_CURRENT_TIME}</option>
+ {S_TZ_DATE_OPTIONS}
+ </select><br />
+ <input type="button" id="tz_select_date_suggest" class="btnlite" style="display: none;" data-is-registration="<!-- IF S_REGISTRATION -->true<!-- ELSE -->false<!-- ENDIF -->" data-l-suggestion="{L_TIMEZONE_DATE_SUGGESTION}" value="{L_TIMEZONE_DATE_SUGGESTION}" />
+ </div>
+ <!-- ENDIF -->
+ <select name="tz" id="timezone" class="autowidth tz_select">
+ <option value="">{L_SELECT_TIMEZONE}</option>
+ {S_TZ_OPTIONS}
+ </select>
+
+ <!-- INCLUDEJS template/timezone.js -->
+ </td>
+</tr>
diff --git a/phpBB/styles/subsilver2/template/ucp_main_bookmarks.html b/phpBB/styles/subsilver2/template/ucp_main_bookmarks.html
index 2fa8f6ac2e..ba19c45eab 100644
--- a/phpBB/styles/subsilver2/template/ucp_main_bookmarks.html
+++ b/phpBB/styles/subsilver2/template/ucp_main_bookmarks.html
@@ -43,8 +43,17 @@
<td style="padding: 4px;" width="100%" valign="top">
<p class="topictitle"><!-- IF topicrow.S_UNREAD_TOPIC --><a href="{topicrow.U_NEWEST_POST}">{NEWEST_POST_IMG}</a> <!-- ENDIF -->{topicrow.ATTACH_ICON_IMG} <a href="{topicrow.U_VIEW_TOPIC}">{topicrow.TOPIC_TITLE}</a></p>
<!-- IF topicrow.S_GLOBAL_TOPIC --><span class="gensmall">{L_GLOBAL_ANNOUNCEMENT}</span><!-- ELSE --><span class="gensmall"><b>{L_FORUM}: </b><a href="{topicrow.U_VIEW_FORUM}">{topicrow.FORUM_NAME}</a></span><!-- ENDIF -->
- <!-- IF topicrow.PAGINATION -->
- <p class="gensmall"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {topicrow.PAGINATION} ] </p>
+ <!-- IF .topicrow.pagination -->
+ <p class="gensmall"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}:
+ <!-- BEGIN pagination -->
+ <!-- IF topicrow.pagination.S_IS_PREV -->
+ <!-- ELSEIF topicrow.pagination.S_IS_CURRENT --><strong>{topicrow.pagination.PAGE_NUMBER}</strong>
+ <!-- ELSEIF topicrow.pagination.S_IS_ELLIPSIS --> {L_ELLIPSIS}
+ <!-- ELSEIF topicrow.pagination.S_IS_NEXT -->
+ <!-- ELSE --><a href="{topicrow.pagination.PAGE_URL}">{topicrow.pagination.PAGE_NUMBER}</a>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+ ] </p>
<!-- ENDIF -->
</td>
<td style="padding: 4px;" align="{S_CONTENT_FLOW_BEGIN}" valign="top" nowrap="nowrap">
diff --git a/phpBB/styles/subsilver2/template/ucp_main_subscribed.html b/phpBB/styles/subsilver2/template/ucp_main_subscribed.html
index 42a452549b..13d2935757 100644
--- a/phpBB/styles/subsilver2/template/ucp_main_subscribed.html
+++ b/phpBB/styles/subsilver2/template/ucp_main_subscribed.html
@@ -52,8 +52,17 @@
<td style="padding: 4px;" width="100%" valign="top">
<p class="topictitle"><!-- IF topicrow.S_UNREAD_TOPIC --><a href="{topicrow.U_NEWEST_POST}" class="imageset">{NEWEST_POST_IMG}</a> <!-- ENDIF -->{topicrow.ATTACH_ICON_IMG} <a href="{topicrow.U_VIEW_TOPIC}">{topicrow.TOPIC_TITLE}</a></p>
<!-- IF topicrow.S_GLOBAL_TOPIC --><span class="gensmall">{L_GLOBAL_ANNOUNCEMENT}</span><!-- ELSE --><span class="gensmall"><b>{L_FORUM}: </b><a href="{topicrow.U_VIEW_FORUM}">{topicrow.FORUM_NAME}</a></span><!-- ENDIF -->
- <!-- IF topicrow.PAGINATION -->
- <p class="gensmall"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {topicrow.PAGINATION} ] </p>
+ <!-- IF .topicrow.pagination -->
+ <p class="gensmall"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}:
+ <!-- BEGIN pagination -->
+ <!-- IF topicrow.pagination.S_IS_PREV -->
+ <!-- ELSEIF topicrow.pagination.S_IS_CURRENT --><strong>{topicrow.pagination.PAGE_NUMBER}</strong>
+ <!-- ELSEIF topicrow.pagination.S_IS_ELLIPSIS --> {L_ELLIPSIS}
+ <!-- ELSEIF topicrow.pagination.S_IS_NEXT -->
+ <!-- ELSE --><a href="{topicrow.pagination.PAGE_URL}">{topicrow.pagination.PAGE_NUMBER}</a>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+ ] </p>
<!-- ENDIF -->
</td>
<td style="padding: 4px;" align="{S_CONTENT_FLOW_BEGIN}" valign="top" nowrap="nowrap">
diff --git a/phpBB/styles/subsilver2/template/ucp_pm_viewmessage_print.html b/phpBB/styles/subsilver2/template/ucp_pm_viewmessage_print.html
index 7c368c8124..041fca48a7 100644
--- a/phpBB/styles/subsilver2/template/ucp_pm_viewmessage_print.html
+++ b/phpBB/styles/subsilver2/template/ucp_pm_viewmessage_print.html
@@ -112,7 +112,7 @@ hr.sep {
<td align="{S_CONTENT_FLOW_END}"><span class="gensmall">{S_TIMEZONE}</span></td>
</tr>
<tr>
- <td colspan="2" align="center"><span class="gensmall">Powered by phpBB&reg; Forum Software &copy; phpBB Group<br />http://www.phpbb.com/</span></td>
+ <td colspan="2" align="center"><span class="gensmall">Powered by phpBB&reg; Forum Software &copy; phpBB Group<br />https://www.phpbb.com/</span></td>
</tr>
</table>
diff --git a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html
index 8e4b04fc10..bf0e67d68b 100644
--- a/phpBB/styles/subsilver2/template/ucp_prefs_personal.html
+++ b/phpBB/styles/subsilver2/template/ucp_prefs_personal.html
@@ -71,16 +71,7 @@
<td class="row2"><select name="style">{S_STYLE_OPTIONS}</select></td>
</tr>
<!-- ENDIF -->
-<tr>
- <td class="row1" width="50%"><b class="genmed">{L_BOARD_TIMEZONE}:</b></td>
- <td class="row2">
- <select id="tz" name="tz">{S_TZ_OPTIONS}</select>
- </td>
-</tr>
-<tr>
- <td class="row1" width="50%"><b class="genmed">{L_BOARD_DST}:</b></td>
- <td class="row2"><input type="radio" class="radio" name="dst" value="1"<!-- IF S_DST --> checked="checked"<!-- ENDIF --> /> <span class="genmed">{L_YES}</span>&nbsp;&nbsp;<input type="radio" class="radio" name="dst" value="0"<!-- IF not S_DST --> checked="checked"<!-- ENDIF --> /> <span class="genmed">{L_NO}</span></td>
-</tr>
+<!-- INCLUDE timezone_option.html -->
<tr>
<td class="row1" width="50%"><b class="genmed">{L_BOARD_DATE_FORMAT}:</b><br /><span class="gensmall">{L_BOARD_DATE_FORMAT_EXPLAIN}</span></td>
<td class="row2">
diff --git a/phpBB/styles/subsilver2/template/ucp_register.html b/phpBB/styles/subsilver2/template/ucp_register.html
index 0c3533292d..095c97ed49 100644
--- a/phpBB/styles/subsilver2/template/ucp_register.html
+++ b/phpBB/styles/subsilver2/template/ucp_register.html
@@ -53,10 +53,9 @@
<td class="row1"><b class="genmed">{L_LANGUAGE}: </b></td>
<td class="row2"><select name="lang" onchange="change_language(this.value); return false;">{S_LANG_OPTIONS}</select></td>
</tr>
-<tr>
- <td class="row1"><b class="genmed">{L_TIMEZONE}: </b></td>
- <td class="row2"><select name="tz">{S_TZ_OPTIONS}</select></td>
-</tr>
+
+<!-- INCLUDE timezone_option.html -->
+
<!-- IF .profile_fields -->
<tr>
<td class="row2" colspan="2"><span class="gensmall">{L_ITEMS_REQUIRED}</span></td>
diff --git a/phpBB/styles/subsilver2/template/viewforum_body.html b/phpBB/styles/subsilver2/template/viewforum_body.html
index afb8426799..7f241ce874 100644
--- a/phpBB/styles/subsilver2/template/viewforum_body.html
+++ b/phpBB/styles/subsilver2/template/viewforum_body.html
@@ -48,8 +48,17 @@
<!-- IF topicrow.S_TOPIC_REPORTED -->
<a href="{topicrow.U_MCP_REPORT}" class="imageset">{REPORTED_IMG}</a>&nbsp;
<!-- ENDIF -->
- <!-- IF topicrow.PAGINATION -->
- <p class="gensmall"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {topicrow.PAGINATION} ] </p>
+ <!-- IF .topicrow.pagination -->
+ <p class="gensmall"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}:
+ <!-- BEGIN pagination -->
+ <!-- IF topicrow.pagination.S_IS_PREV -->
+ <!-- ELSEIF topicrow.pagination.S_IS_CURRENT --><strong>{topicrow.pagination.PAGE_NUMBER}</strong>
+ <!-- ELSEIF topicrow.pagination.S_IS_ELLIPSIS --> {L_ELLIPSIS}
+ <!-- ELSEIF topicrow.pagination.S_IS_NEXT -->
+ <!-- ELSE --><a href="{topicrow.pagination.PAGE_URL}">{topicrow.pagination.PAGE_NUMBER}</a>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+ ] </p>
<!-- ENDIF -->
</td>
<td class="row2" width="130" align="center"><p class="topicauthor">{topicrow.TOPIC_AUTHOR_FULL}</p></td>
@@ -199,8 +208,17 @@
<!-- IF topicrow.S_TOPIC_REPORTED -->
<a href="{topicrow.U_MCP_REPORT}" class="imageset">{REPORTED_IMG}</a>&nbsp;
<!-- ENDIF -->
- <!-- IF topicrow.PAGINATION -->
- <p class="gensmall"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}: {topicrow.PAGINATION} ] </p>
+ <!-- IF .topicrow.pagination -->
+ <p class="gensmall"> [ {GOTO_PAGE_IMG}{L_GOTO_PAGE}:
+ <!-- BEGIN pagination -->
+ <!-- IF topicrow.pagination.S_IS_PREV -->
+ <!-- ELSEIF topicrow.pagination.S_IS_CURRENT --><strong>{topicrow.pagination.PAGE_NUMBER}</strong>
+ <!-- ELSEIF topicrow.pagination.S_IS_ELLIPSIS --> {L_ELLIPSIS}
+ <!-- ELSEIF topicrow.pagination.S_IS_NEXT -->
+ <!-- ELSE --><a href="{topicrow.pagination.PAGE_URL}">{topicrow.pagination.PAGE_NUMBER}</a>
+ <!-- ENDIF -->
+ <!-- END pagination -->
+ ] </p>
<!-- ENDIF -->
<!-- IF topicrow.S_POST_GLOBAL and FORUM_ID != topicrow.FORUM_ID --><p class="gensmall">{L_IN} <a href="{topicrow.U_VIEW_FORUM}">{topicrow.FORUM_NAME}</a></p><!-- ENDIF -->
</td>
diff --git a/phpBB/styles/subsilver2/template/viewonline_body.html b/phpBB/styles/subsilver2/template/viewonline_body.html
index 1c8734d06a..b05a9470e0 100644
--- a/phpBB/styles/subsilver2/template/viewonline_body.html
+++ b/phpBB/styles/subsilver2/template/viewonline_body.html
@@ -8,7 +8,7 @@
<table width="100%" cellspacing="1">
<tr>
<td class="nav" valign="middle" nowrap="nowrap">&nbsp;{PAGE_NUMBER}<br /></td>
- <td class="gensmall" width="100%" align="{S_CONTENT_FLOW_END}" nowrap="nowrap"><b><a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a>&nbsp;&nbsp;<!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE -->&nbsp;&nbsp;<a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b></td>
+ <td class="gensmall" width="100%" align="{S_CONTENT_FLOW_END}" nowrap="nowrap"><!-- INCLUDE pagination.html --></td>
</tr>
</table>
<!-- ENDIF -->
@@ -39,7 +39,7 @@
<table width="100%" cellspacing="1">
<tr>
<td class="nav" valign="middle" nowrap="nowrap">&nbsp;{PAGE_NUMBER}<br /></td>
- <td class="gensmall" width="100%" align="{S_CONTENT_FLOW_END}" nowrap="nowrap"><b><a href="#" onclick="jumpto(); return false;" title="{L_JUMP_TO_PAGE}">{L_GOTO_PAGE}</a> <!-- IF PREVIOUS_PAGE --><a href="{PREVIOUS_PAGE}">{L_PREVIOUS}</a>&nbsp;&nbsp;<!-- ENDIF -->{PAGINATION}<!-- IF NEXT_PAGE -->&nbsp;&nbsp;<a href="{NEXT_PAGE}">{L_NEXT}</a><!-- ENDIF --></b></td>
+ <td class="gensmall" width="100%" align="{S_CONTENT_FLOW_END}" nowrap="nowrap"><!-- INCLUDE pagination.html --></td>
</tr>
</table>
<!-- ENDIF -->
diff --git a/phpBB/styles/subsilver2/template/viewtopic_print.html b/phpBB/styles/subsilver2/template/viewtopic_print.html
index 07da8ef752..7e84b6fdad 100644
--- a/phpBB/styles/subsilver2/template/viewtopic_print.html
+++ b/phpBB/styles/subsilver2/template/viewtopic_print.html
@@ -126,7 +126,7 @@ hr.sep {
<td align="{S_CONTENT_FLOW_END}"><span class="gensmall">{S_TIMEZONE}</span></td>
</tr>
<tr>
- <td colspan="2" align="center"><span class="gensmall">Powered by phpBB&reg; Forum Software &copy; phpBB Group<br />http://www.phpbb.com/</span></td>
+ <td colspan="2" align="center"><span class="gensmall">Powered by phpBB&reg; Forum Software &copy; phpBB Group<br />https://www.phpbb.com/</span></td>
</tr>
</table>
diff --git a/phpBB/styles/subsilver2/theme/stylesheet.css b/phpBB/styles/subsilver2/theme/stylesheet.css
index 18d15a8d41..977e5c20c6 100644
--- a/phpBB/styles/subsilver2/theme/stylesheet.css
+++ b/phpBB/styles/subsilver2/theme/stylesheet.css
@@ -3,7 +3,7 @@
Style name: subsilver2
Based on style: subSilver (the default phpBB 2.0.x style)
Original author: Tom Beddard ( http://www.subblue.com/ )
- Modified by: phpBB Group ( http://www.phpbb.com/ )
+ Modified by: phpBB Group ( https://www.phpbb.com/ )
--------------------------------------------------------------
*/
@@ -422,6 +422,15 @@ a.topictitle:visited {
text-decoration: none;
}
+a.lastsubject {
+ font-weight: bold;
+ text-decoration: none;
+}
+
+a.lastsubject:hover {
+ text-decoration: underline;
+}
+
th a,
th a:visited {
color: #FFA34F !important;
diff --git a/phpBB/ucp.php b/phpBB/ucp.php
index 64afa0be67..9730591698 100644
--- a/phpBB/ucp.php
+++ b/phpBB/ucp.php
@@ -328,6 +328,18 @@ if (!$auth->acl_get('u_sig'))
$module->set_display('profile', 'signature', false);
}
+/**
+* Use this event to enable and disable additional UCP modules
+*
+* @event core.ucp_display_module_before
+* @var p_master module Object holding all modules and their status
+* @var mixed id Active module category (can be the int or string)
+* @var string mode Active module
+* @since 3.1-A1
+*/
+$vars = array('module', 'id', 'mode');
+extract($phpbb_dispatcher->trigger_event('core.ucp_display_module_before', compact($vars)));
+
// Select the active module
$module->set_active($id, $mode);
diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php
index 6a39f10394..03c2bb286f 100644
--- a/phpBB/viewforum.php
+++ b/phpBB/viewforum.php
@@ -193,8 +193,12 @@ if ($forum_data['forum_topics_per_page'])
// Do the forum Prune thang - cron type job ...
if (!$config['use_system_cron'])
{
- $task = $cron->instantiate_task('cron_task_core_prune_forum', $forum_data);
- if ($task && $task->is_ready())
+ $cron = $phpbb_container->get('cron.manager');
+
+ $task = $cron->find_task('cron.task.core.prune_forum');
+ $task->set_forum_data($forum_data);
+
+ if ($task->is_ready())
{
$url = $task->get_url();
$template->assign_var('RUN_CRON_TASK', '<img src="' . $url . '" width="1" height="1" alt="cron" />');
@@ -289,7 +293,7 @@ if (!empty($_EXTRA_URL))
}
$template->assign_vars(array(
- 'MODERATORS' => (!empty($moderators[$forum_id])) ? implode(', ', $moderators[$forum_id]) : '',
+ 'MODERATORS' => (!empty($moderators[$forum_id])) ? implode($user->lang['COMMA_SEPARATOR'], $moderators[$forum_id]) : '',
'POST_IMG' => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', $post_alt) : $user->img('button_topic_new', $post_alt),
'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
@@ -590,9 +594,11 @@ if ($s_display_active)
// otherwise the number is different from the one on the forum list
$total_topic_count = $topics_count - sizeof($global_announce_forums);
+$base_url = append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : ''));
+phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $topics_count, $config['topics_per_page'], $start);
+
$template->assign_vars(array(
- 'PAGINATION' => generate_pagination(append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '')), $topics_count, $config['topics_per_page'], $start),
- 'PAGE_NUMBER' => on_page($topics_count, $config['topics_per_page'], $start),
+ 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $topics_count, $config['topics_per_page'], $start),
'TOTAL_TOPICS' => ($s_display_active) ? false : $user->lang('VIEW_FORUM_TOPICS', (int) $total_topic_count),
));
@@ -688,7 +694,7 @@ if (sizeof($topic_list))
$u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&amp;mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&amp;t=$topic_id", true, $user->session_id) : '';
// Send vars to template
- $template->assign_block_vars('topicrow', array(
+ $topic_row = array(
'FORUM_ID' => $row['forum_id'],
'TOPIC_ID' => $topic_id,
'TOPIC_AUTHOR' => get_username_string('username', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']),
@@ -702,7 +708,6 @@ if (sizeof($topic_list))
'LAST_POST_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
'LAST_POST_AUTHOR_FULL' => get_username_string('full', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']),
- 'PAGINATION' => topic_generate_pagination($replies, $view_topic_url),
'REPLIES' => $replies,
'VIEWS' => $row['topic_views'],
'TOPIC_TITLE' => censor_text($row['topic_title']),
@@ -741,9 +746,24 @@ if (sizeof($topic_list))
'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&amp;mode=reports&amp;f=' . $row['forum_id'] . '&amp;t=' . $topic_id, true, $user->session_id),
'U_MCP_QUEUE' => $u_mcp_queue,
- 'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test)
+ 'S_TOPIC_TYPE_SWITCH' => ($s_type_switch == $s_type_switch_test) ? -1 : $s_type_switch_test,
);
+ /**
+ * Modify the topic data before it is assigned to the template
+ *
+ * @event core.viewforum_modify_topicrow
+ * @var array row Array with topic data
+ * @var array topic_row Template array with topic data
+ * @since 3.1-A1
+ */
+ $vars = array('row', 'topic_row');
+ extract($phpbb_dispatcher->trigger_event('core.viewforum_modify_topicrow', compact($vars)));
+
+ $template->assign_block_vars('topicrow', $topic_row);
+
+ phpbb_generate_template_pagination($template, $view_topic_url, 'topicrow.pagination', 'start', $replies + 1, $config['posts_per_page'], 1, true, true);
+
$s_type_switch = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0;
if ($unread_topic)
diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php
index 08ca7f7a04..15884a41d8 100644
--- a/phpBB/viewonline.php
+++ b/phpBB/viewonline.php
@@ -121,13 +121,30 @@ if (!$show_guests)
}
// Get user list
-$sql = 'SELECT u.user_id, u.username, u.username_clean, u.user_type, u.user_colour, s.session_id, s.session_time, s.session_page, s.session_ip, s.session_browser, s.session_viewonline, s.session_forum_id
- FROM ' . USERS_TABLE . ' u, ' . SESSIONS_TABLE . ' s
- WHERE u.user_id = s.session_user_id
+$sql_ary = array(
+ 'SELECT' => 'u.user_id, u.username, u.username_clean, u.user_type, u.user_colour, s.session_id, s.session_time, s.session_page, s.session_ip, s.session_browser, s.session_viewonline, s.session_forum_id',
+ 'FROM' => array(
+ USERS_TABLE => 'u',
+ SESSIONS_TABLE => 's',
+ ),
+ 'WHERE' => 'u.user_id = s.session_user_id
AND s.session_time >= ' . (time() - ($config['load_online_time'] * 60)) .
- ((!$show_guests) ? ' AND s.session_user_id <> ' . ANONYMOUS : '') . '
- ORDER BY ' . $order_by;
-$result = $db->sql_query($sql);
+ ((!$show_guests) ? ' AND s.session_user_id <> ' . ANONYMOUS : ''),
+ 'ORDER_BY' => $order_by,
+);
+
+/**
+* Modify the SQL query for getting the user data to display viewonline list
+*
+* @event core.viewonline_modify_sql
+* @var array sql_ary The SQL array
+* @var bool show_guests Do we display guests in the list
+* @since 3.1-A1
+*/
+$vars = array('sql_ary', 'show_guests');
+extract($phpbb_dispatcher->trigger_event('core.viewonline_modify_sql', compact($vars)));
+
+$result = $db->sql_query($db->sql_build_query('SELECT', $sql_ary));
$prev_id = $prev_ip = $user_list = array();
$logged_visible_online = $logged_hidden_online = $counter = 0;
@@ -320,6 +337,19 @@ while ($row = $db->sql_fetchrow($result))
break;
}
+ /**
+ * Overwrite the location's name and URL, which are displayed in the list
+ *
+ * @event core.viewonline_overwrite_location
+ * @var array on_page File name and query string
+ * @var array row Array with the users sql row
+ * @var string location Page name to displayed in the list
+ * @var string location_url Page url to displayed in the list
+ * @since 3.1-A1
+ */
+ $vars = array('on_page', 'row', 'location', 'location_url');
+ extract($phpbb_dispatcher->trigger_event('core.viewonline_overwrite_location', compact($vars)));
+
$template->assign_block_vars('user_row', array(
'USERNAME' => $row['username'],
'USERNAME_COLOUR' => $row['user_colour'],
@@ -342,8 +372,6 @@ while ($row = $db->sql_fetchrow($result))
$db->sql_freeresult($result);
unset($prev_id, $prev_ip);
-$pagination = generate_pagination(append_sid("{$phpbb_root_path}viewonline.$phpEx", "sg=$show_guests&amp;sk=$sort_key&amp;sd=$sort_dir"), $counter, $config['topics_per_page'], $start);
-
$order_legend = ($config['legend_sort_groupname']) ? 'group_name' : 'group_legend';
// Grab group details for legend display
if ($auth->acl_gets('a_group', 'a_groupadd', 'a_groupdel'))
@@ -386,13 +414,16 @@ $db->sql_freeresult($result);
// Refreshing the page every 60 seconds...
meta_refresh(60, append_sid("{$phpbb_root_path}viewonline.$phpEx", "sg=$show_guests&amp;sk=$sort_key&amp;sd=$sort_dir&amp;start=$start"));
+$base_url = append_sid("{$phpbb_root_path}viewonline.$phpEx", "sg=$show_guests&amp;sk=$sort_key&amp;sd=$sort_dir");
+phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $counter, $config['topics_per_page'], $start);
+
// Send data to template
$template->assign_vars(array(
'TOTAL_REGISTERED_USERS_ONLINE' => $user->lang('REG_USERS_ONLINE', (int) $logged_visible_online, $user->lang('HIDDEN_USERS_ONLINE', (int) $logged_hidden_online)),
'TOTAL_GUEST_USERS_ONLINE' => $user->lang('GUEST_USERS_ONLINE', (int) $guest_counter),
'LEGEND' => $legend,
'PAGINATION' => $pagination,
- 'PAGE_NUMBER' => on_page($counter, $config['topics_per_page'], $start),
+ 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $counter, $config['topics_per_page'], $start),
'U_SORT_USERNAME' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'sk=a&amp;sd=' . (($sort_key == 'a' && $sort_dir == 'a') ? 'd' : 'a') . '&amp;sg=' . ((int) $show_guests)),
'U_SORT_UPDATED' => append_sid("{$phpbb_root_path}viewonline.$phpEx", 'sk=b&amp;sd=' . (($sort_key == 'b' && $sort_dir == 'a') ? 'd' : 'a') . '&amp;sg=' . ((int) $show_guests)),
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index 0d6e9afd54..3fde5b5e03 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -545,9 +545,6 @@ foreach($quickmod_array as $option => $qm_ary)
}
}
-// If we've got a hightlight set pass it on to pagination.
-$pagination = generate_pagination(append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . (($highlight_match) ? "&amp;hilit=$highlight" : '')), $total_posts, $config['posts_per_page'], $start);
-
// Navigation links
generate_forum_nav($topic_data);
@@ -585,6 +582,10 @@ if (!empty($_EXTRA_URL))
}
}
+// If we've got a hightlight set pass it on to pagination.
+$base_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&amp;t=$topic_id" . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : '') . (($highlight_match) ? "&amp;hilit=$highlight" : ''));
+phpbb_generate_template_pagination($template, $base_url, 'pagination', 'start', $total_posts, $config['posts_per_page'], $start);
+
// Send vars to template
$template->assign_vars(array(
'FORUM_ID' => $forum_id,
@@ -598,11 +599,10 @@ $template->assign_vars(array(
'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']),
'TOPIC_AUTHOR' => get_username_string('username', $topic_data['topic_poster'], $topic_data['topic_first_poster_name'], $topic_data['topic_first_poster_colour']),
- 'PAGINATION' => $pagination,
- 'PAGE_NUMBER' => on_page($total_posts, $config['posts_per_page'], $start),
+ 'PAGE_NUMBER' => phpbb_on_page($template, $user, $base_url, $total_posts, $config['posts_per_page'], $start),
'TOTAL_POSTS' => $user->lang('VIEW_TOPIC_POSTS', (int) $total_posts),
'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&amp;mode=topic_view&amp;f=$forum_id&amp;t=$topic_id" . (($start == 0) ? '' : "&amp;start=$start") . ((strlen($u_sort_param)) ? "&amp;$u_sort_param" : ''), true, $user->session_id) : '',
- 'MODERATORS' => (isset($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id])) ? implode(', ', $forum_moderators[$forum_id]) : '',
+ 'MODERATORS' => (isset($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id])) ? implode($user->lang['COMMA_SEPARATOR'], $forum_moderators[$forum_id]) : '',
'POST_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'FORUM_LOCKED') : $user->img('button_topic_new', 'POST_NEW_TOPIC'),
'QUOTE_IMG' => $user->img('icon_post_quote', 'REPLY_WITH_QUOTE'),
@@ -987,10 +987,21 @@ $sql_ary = array(
AND u.user_id = p.poster_id',
);
+/**
+* Event to modify the SQL query before the post and poster data is retrieved
+*
+* @event core.viewtopic_get_post_data
+* @var array sql_ary The SQL array to get the data of posts and posters
+* @since 3.1-A1
+*/
+$vars = array('sql_ary');
+extract($phpbb_dispatcher->trigger_event('core.viewtopic_get_post_data', compact($vars)));
+
$sql = $db->sql_build_query('SELECT', $sql_ary);
$result = $db->sql_query($sql);
-$now = phpbb_gmgetdate(time() + $user->timezone + $user->dst);
+$now = $user->create_datetime();
+$now = phpbb_gmgetdate($now->getTimestamp() + $now->getOffset());
// Posts are stored in the $rowset array while $attach_list, $user_cache
// and the global bbcode_bitfield are built
@@ -1062,7 +1073,7 @@ while ($row = $db->sql_fetchrow($result))
{
if ($poster_id == ANONYMOUS)
{
- $user_cache[$poster_id] = array(
+ $user_cache_data = array(
'joined' => '',
'posts' => '',
'from' => '',
@@ -1097,6 +1108,20 @@ while ($row = $db->sql_fetchrow($result))
'allow_pm' => 0,
);
+ /**
+ * Modify the guest user's data displayed with the posts
+ *
+ * @event core.viewtopic_cache_guest_data
+ * @var array user_cache_data Array with the user's data
+ * @var int poster_id Poster's user id
+ * @var array row Array with original user and post data
+ * @since 3.1-A1
+ */
+ $vars = array('user_cache_data', 'poster_id', 'row');
+ extract($phpbb_dispatcher->trigger_event('core.viewtopic_cache_guest_data', compact($vars)));
+
+ $user_cache[$poster_id] = $user_cache_data;
+
get_user_rank($row['user_rank'], false, $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
}
else
@@ -1111,7 +1136,7 @@ while ($row = $db->sql_fetchrow($result))
$id_cache[] = $poster_id;
- $user_cache[$poster_id] = array(
+ $user_cache_data = array(
'joined' => $user->format_date($row['user_regdate']),
'posts' => $row['user_posts'],
'warnings' => (isset($row['user_warnings'])) ? $row['user_warnings'] : 0,
@@ -1149,6 +1174,20 @@ while ($row = $db->sql_fetchrow($result))
'author_profile' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour']),
);
+ /**
+ * Modify the users' data displayed with their posts
+ *
+ * @event core.viewtopic_cache_user_data
+ * @var array user_cache_data Array with the user's data
+ * @var int poster_id Poster's user id
+ * @var array row Array with original user and post data
+ * @since 3.1-A1
+ */
+ $vars = array('user_cache_data', 'poster_id', 'row');
+ extract($phpbb_dispatcher->trigger_event('core.viewtopic_cache_user_data', compact($vars)));
+
+ $user_cache[$poster_id] = $user_cache_data;
+
get_user_rank($row['user_rank'], $row['user_posts'], $user_cache[$poster_id]['rank_title'], $user_cache[$poster_id]['rank_image'], $user_cache[$poster_id]['rank_image_src']);
if ((!empty($row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email'))
@@ -1313,6 +1352,16 @@ if (sizeof($attach_list))
}
}
+$template->assign_vars(array(
+ 'S_HAS_ATTACHMENTS' => !empty($attachments),
+));
+
+$methods = phpbb_gen_download_links('topic_id', $topic_id, $phpbb_root_path, $phpEx);
+foreach ($methods as $method)
+{
+ $template->assign_block_vars('dl_method', $method);
+}
+
// Instantiate BBCode if need be
if ($bbcode_bitfield !== '')
{
@@ -1492,7 +1541,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
)));
//
- $postrow = array(
+ $post_row = array(
'POST_AUTHOR_FULL' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_full'] : get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'POST_AUTHOR_COLOUR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_colour'] : get_username_string('colour', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
'POST_AUTHOR' => ($poster_id != ANONYMOUS) ? $user_cache[$poster_id]['author_username'] : get_username_string('username', $poster_id, $row['username'], $row['user_colour'], $row['post_username']),
@@ -1555,6 +1604,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
'POSTER_ID' => $poster_id,
'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']])) ? true : false,
+ 'S_MULTIPLE_ATTACHMENTS' => !empty($attachments[$row['post_id']]) && sizeof($attachments[$row['post_id']]) > 1,
'S_POST_UNAPPROVED' => ($row['post_approved']) ? false : true,
'S_POST_REPORTED' => ($row['post_reported'] && $auth->acl_get('m_report', $forum_id)) ? true : false,
'S_DISPLAY_NOTICE' => $display_notice && $row['post_attachment'],
@@ -1568,13 +1618,28 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
'L_IGNORE_POST' => ($row['hide_post']) ? sprintf($user->lang['POST_BY_FOE'], get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), '<a href="' . $viewtopic_url . "&amp;p={$row['post_id']}&amp;view=show#p{$row['post_id']}" . '">', '</a>') : '',
);
+ $user_poster_data = $user_cache[$poster_id];
+
+ /**
+ * Modify the posts template block
+ *
+ * @event core.viewtopic_modify_post_row
+ * @var array row Array with original post and user data
+ * @var array cp_row Custom profile field data of the poster
+ * @var array user_poster_data Poster's data from user cache
+ * @var array post_row Template block array of the post
+ * @since 3.1-A1
+ */
+ $vars = array('row', 'cp_row', 'user_poster_data', 'post_row');
+ extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_post_row', compact($vars)));
+
if (isset($cp_row['row']) && sizeof($cp_row['row']))
{
- $postrow = array_merge($postrow, $cp_row['row']);
+ $post_row = array_merge($post_row, $cp_row['row']);
}
// Dump vars into template
- $template->assign_block_vars('postrow', $postrow);
+ $template->assign_block_vars('postrow', $post_row);
if (!empty($cp_row['blockrow']))
{
@@ -1593,6 +1658,12 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i)
'DISPLAY_ATTACHMENT' => $attachment)
);
}
+
+ $methods = phpbb_gen_download_links('post_msg_id', $row['post_id'], $phpbb_root_path, $phpEx);
+ foreach ($methods as $method)
+ {
+ $template->assign_block_vars('postrow.dl_method', $method);
+ }
}
$prev_post_id = $row['post_id'];
@@ -1728,8 +1799,23 @@ if (!request_var('t', 0) && !empty($topic_id))
$request->overwrite('t', $topic_id);
}
+$page_title = $topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang['PAGE_TITLE_NUMBER'], floor($start / $config['posts_per_page']) + 1) : '');
+
+/**
+* You can use this event to modify the page title of the viewtopic page
+*
+* @event core.viewtopic_modify_page_title
+* @var string page_title Title of the index page
+* @var array topic_data Array with topic data
+* @var int forum_id Forum ID of the topic
+* @var int start Start offset used to calculate the page
+* @since 3.1-A1
+*/
+$vars = array('page_title', 'topic_data', 'forum_id', 'start');
+extract($phpbb_dispatcher->trigger_event('core.viewtopic_modify_page_title', compact($vars)));
+
// Output the page
-page_header($topic_data['topic_title'] . ($start ? ' - ' . sprintf($user->lang['PAGE_TITLE_NUMBER'], floor($start / $config['posts_per_page']) + 1) : ''), true, $forum_id);
+page_header($page_title, true, $forum_id);
$template->set_filenames(array(
'body' => ($view == 'print') ? 'viewtopic_print.html' : 'viewtopic_body.html')
diff --git a/tests/RUNNING_TESTS.txt b/tests/RUNNING_TESTS.txt
index b976545c22..7c2a7c3fce 100644
--- a/tests/RUNNING_TESTS.txt
+++ b/tests/RUNNING_TESTS.txt
@@ -51,6 +51,27 @@ test_config.php file:
PHPBB_TEST_DBNAME='database' PHPBB_TEST_DBUSER='user' \
PHPBB_TEST_DBPASSWD='password' phpunit
+Special Database Cases
+----------------------
+In order to run tests on some of the databases that we support, it will be
+necessary to provide a custom DSN string in test_config.php. This is only
+needed for MSSQL 2000+ (PHP module), MSSQL via ODBC, and Firebird when
+PDO_Firebird does not work on your system
+(https://bugs.php.net/bug.php?id=61183). The variable must be named $custom_dsn.
+
+Examples:
+Firebird using http://www.firebirdsql.org/en/odbc-driver/
+$custom_dsn = "Driver={Firebird/InterBase(r) driver};dbname=$dbhost:$dbname";
+
+MSSQL
+$custom_dsn = "Driver={SQL Server Native Client 10.0};Server=$dbhost;Database=$dbname";
+
+The other fields in test_config.php should be filled out as you would normally
+to connect to that database in phpBB.
+
+Additionally, you will need to be running the DbUnit fork from
+https://github.com/phpbb/dbunit/tree/phpbb.
+
Running
=======
diff --git a/tests/cache/cache_test.php b/tests/cache/cache_test.php
index 564bd35863..c5f5fac88c 100644
--- a/tests/cache/cache_test.php
+++ b/tests/cache/cache_test.php
@@ -9,7 +9,7 @@
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
-class phpbb_cache_test extends phpbb_test_case
+class phpbb_cache_test extends phpbb_database_test_case
{
private $cache_dir;
@@ -18,8 +18,15 @@ class phpbb_cache_test extends phpbb_test_case
$this->cache_dir = dirname(__FILE__) . '/../tmp/cache/';
}
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
+ }
+
protected function setUp()
{
+ parent::setUp();
+
if (file_exists($this->cache_dir))
{
// cache directory possibly left after aborted
@@ -35,6 +42,8 @@ class phpbb_cache_test extends phpbb_test_case
{
$this->remove_cache_dir();
}
+
+ parent::tearDown();
}
private function create_cache_dir()
@@ -67,4 +76,34 @@ class phpbb_cache_test extends phpbb_test_case
'File ACM put and get'
);
}
+
+ public function test_cache_sql()
+ {
+ $driver = new phpbb_cache_driver_file($this->cache_dir);
+
+ global $db, $cache;
+ $db = $this->new_dbal();
+ $cache = new phpbb_cache_service($driver);
+
+ $sql = "SELECT * FROM phpbb_config
+ WHERE config_name = 'foo'";
+ $result = $db->sql_query($sql, 300);
+ $first_result = $db->sql_fetchrow($result);
+
+ $this->assertFileExists($this->cache_dir . 'sql_' . md5(preg_replace('/[\n\r\s\t]+/', ' ', $sql)) . '.php');
+
+ $sql = "SELECT * FROM phpbb_config
+ WHERE config_name = 'foo'";
+ $result = $db->sql_query($sql, 300);
+
+ $this->assertEquals($first_result, $db->sql_fetchrow($result));
+
+ $sql = "SELECT * FROM phpbb_config
+ WHERE config_name = 'bar'";
+ $result = $db->sql_query($sql, 300);
+
+ $this->assertNotEquals($first_result, $db->sql_fetchrow($result));
+
+ $db->sql_close();
+ }
}
diff --git a/tests/cache/fixtures/config.xml b/tests/cache/fixtures/config.xml
new file mode 100644
index 0000000000..9d395b685c
--- /dev/null
+++ b/tests/cache/fixtures/config.xml
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_config">
+ <column>config_name</column>
+ <column>config_value</column>
+ <column>is_dynamic</column>
+ <row>
+ <value>foo</value>
+ <value>23</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>bar</value>
+ <value>42</value>
+ <value>1</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/compress/archive/.gitkeep b/tests/compress/archive/.gitkeep
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/compress/archive/.gitkeep
diff --git a/tests/compress/compress_test.php b/tests/compress/compress_test.php
new file mode 100644
index 0000000000..ac8dd358d3
--- /dev/null
+++ b/tests/compress/compress_test.php
@@ -0,0 +1,173 @@
+<?php
+/**
+ *
+ * @package testing
+ * @copyright (c) 2012 phpBB Group
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+ *
+ */
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compress.php';
+
+class phpbb_compress_test extends phpbb_test_case
+{
+ const EXTRACT_DIR = '/extract/';
+ const ARCHIVE_DIR = '/archive/';
+
+ private $path;
+
+ protected $filelist = array(
+ '1.txt',
+ 'dir/2.txt',
+ 'dir/3.txt',
+ 'dir/subdir/4.txt',
+ );
+
+ protected $conflicts = array(
+ '1_1.txt',
+ '1_2.txt',
+ 'dir/2_1.txt',
+ );
+
+ protected function setUp()
+ {
+ // Required for compress::add_file
+ global $phpbb_root_path;
+ $phpbb_root_path = '';
+
+ $this->path = dirname(__FILE__) . '/fixtures/';
+
+ if (!@extension_loaded('zlib') || !@extension_loaded('bz2'))
+ {
+ $this->markTestSkipped('PHP needs to be compiled with --with-zlib and --with-bz2 in order to run these tests');
+ }
+ }
+
+ protected function tearDown()
+ {
+ foreach (array(dirname(__FILE__) . self::EXTRACT_DIR, dirname(__FILE__) . self::ARCHIVE_DIR) as $dir)
+ {
+ $this->clear_dir($dir);
+ }
+ }
+
+ protected function clear_dir($dir)
+ {
+ $iterator = new DirectoryIterator($dir);
+ foreach ($iterator as $fileinfo)
+ {
+ $name = $fileinfo->getFilename();
+ $path = $fileinfo->getPathname();
+
+ if ($name[0] !== '.')
+ {
+ if ($fileinfo->isDir())
+ {
+ $this->clear_dir($path);
+ rmdir($path);
+ }
+ else
+ {
+ unlink($path);
+ }
+ }
+ }
+ }
+
+ protected function archive_files($compress)
+ {
+ $compress->add_file($this->path . '1.txt', $this->path);
+ $compress->add_file(
+ 'tests/compress/fixtures/dir/',
+ 'tests/compress/fixtures/',
+ '',
+ // The comma here is not an error, this is a comma-separated list
+ 'subdir/4.txt,3.txt'
+ );
+ $compress->add_custom_file($this->path . 'dir/3.txt', 'dir/3.txt');
+ $compress->add_data(file_get_contents($this->path . 'dir/subdir/4.txt'), 'dir/subdir/4.txt');
+
+ // Add multiples of the same file to check conflicts are handled
+ $compress->add_file($this->path . '1.txt', $this->path);
+ $compress->add_file($this->path . '1.txt', $this->path);
+ $compress->add_file($this->path . 'dir/2.txt', $this->path);
+ }
+
+ protected function valid_extraction($extra = array())
+ {
+ $filelist = array_merge($this->filelist, $extra);
+
+ foreach ($filelist as $filename)
+ {
+ $path = dirname(__FILE__) . self::EXTRACT_DIR . $filename;
+ $this->assertTrue(file_exists($path));
+
+ // Check the file's contents is correct
+ $contents = explode('_', basename($filename, '.txt'));
+ $contents = $contents[0];
+ $this->assertEquals($contents . "\n", file_get_contents($path));
+ }
+ }
+
+ public function tar_archive_list()
+ {
+ return array(
+ array('archive.tar', '.tar'),
+ array('archive.tar.gz', '.tar.gz'),
+ array('archive.tar.bz2', '.tar.bz2'),
+ );
+ }
+
+ /**
+ * @dataProvider tar_archive_list
+ */
+ public function test_extract_tar($filename, $type)
+ {
+ $compress = new compress_tar('r', $this->path . $filename);
+ $compress->extract('tests/compress/' . self::EXTRACT_DIR);
+ $this->valid_extraction();
+ }
+
+ public function test_extract_zip()
+ {
+ $compress = new compress_zip('r', $this->path . 'archive.zip');
+ $compress->extract('tests/compress/' . self::EXTRACT_DIR);
+ $this->valid_extraction();
+ }
+
+ /**
+ * @depends test_extract_tar
+ * @dataProvider tar_archive_list
+ */
+ public function test_compress_tar($filename, $type)
+ {
+ $tar = dirname(__FILE__) . self::ARCHIVE_DIR . $filename;
+ $compress = new compress_tar('w', $tar);
+ $this->archive_files($compress);
+ $compress->close();
+ $this->assertTrue(file_exists($tar));
+
+ $compress->mode = 'r';
+ $compress->open();
+ $compress->extract('tests/compress/' . self::EXTRACT_DIR);
+ $this->valid_extraction($this->conflicts);
+ }
+
+ /**
+ * @depends test_extract_zip
+ */
+ public function test_compress_zip()
+ {
+ $zip = dirname(__FILE__) . self::ARCHIVE_DIR . 'archive.zip';
+ $compress = new compress_zip('w', $zip);
+ $this->archive_files($compress);
+ $compress->close();
+ $this->assertTrue(file_exists($zip));
+
+ $compress = new compress_zip('r', $zip);
+ $compress->extract('tests/compress/' . self::EXTRACT_DIR);
+ $this->valid_extraction($this->conflicts);
+ }
+}
diff --git a/tests/compress/extract/.gitkeep b/tests/compress/extract/.gitkeep
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/compress/extract/.gitkeep
diff --git a/tests/compress/fixtures/1.txt b/tests/compress/fixtures/1.txt
new file mode 100644
index 0000000000..d00491fd7e
--- /dev/null
+++ b/tests/compress/fixtures/1.txt
@@ -0,0 +1 @@
+1
diff --git a/tests/compress/fixtures/archive.tar b/tests/compress/fixtures/archive.tar
new file mode 100644
index 0000000000..54ed56084e
--- /dev/null
+++ b/tests/compress/fixtures/archive.tar
Binary files differ
diff --git a/tests/compress/fixtures/archive.tar.bz2 b/tests/compress/fixtures/archive.tar.bz2
new file mode 100644
index 0000000000..04c0eccd74
--- /dev/null
+++ b/tests/compress/fixtures/archive.tar.bz2
Binary files differ
diff --git a/tests/compress/fixtures/archive.tar.gz b/tests/compress/fixtures/archive.tar.gz
new file mode 100644
index 0000000000..195e7a060a
--- /dev/null
+++ b/tests/compress/fixtures/archive.tar.gz
Binary files differ
diff --git a/tests/compress/fixtures/archive.zip b/tests/compress/fixtures/archive.zip
new file mode 100644
index 0000000000..bdb618fc26
--- /dev/null
+++ b/tests/compress/fixtures/archive.zip
Binary files differ
diff --git a/tests/compress/fixtures/dir/2.txt b/tests/compress/fixtures/dir/2.txt
new file mode 100644
index 0000000000..0cfbf08886
--- /dev/null
+++ b/tests/compress/fixtures/dir/2.txt
@@ -0,0 +1 @@
+2
diff --git a/tests/compress/fixtures/dir/3.txt b/tests/compress/fixtures/dir/3.txt
new file mode 100644
index 0000000000..00750edc07
--- /dev/null
+++ b/tests/compress/fixtures/dir/3.txt
@@ -0,0 +1 @@
+3
diff --git a/tests/compress/fixtures/dir/subdir/4.txt b/tests/compress/fixtures/dir/subdir/4.txt
new file mode 100644
index 0000000000..b8626c4cff
--- /dev/null
+++ b/tests/compress/fixtures/dir/subdir/4.txt
@@ -0,0 +1 @@
+4
diff --git a/tests/cron/ext/testext/cron/dummy_task.php b/tests/cron/ext/testext/cron/dummy_task.php
index 996f5b39cf..a31806c1b1 100644
--- a/tests/cron/ext/testext/cron/dummy_task.php
+++ b/tests/cron/ext/testext/cron/dummy_task.php
@@ -11,6 +11,11 @@ class phpbb_ext_testext_cron_dummy_task extends phpbb_cron_task_base
{
public static $was_run = 0;
+ public function get_name()
+ {
+ return get_class($this);
+ }
+
public function run()
{
self::$was_run++;
diff --git a/tests/cron/includes/cron/task/core/dummy_task.php b/tests/cron/includes/cron/task/core/dummy_task.php
index 6e2e2db636..ce3e91a9ba 100644
--- a/tests/cron/includes/cron/task/core/dummy_task.php
+++ b/tests/cron/includes/cron/task/core/dummy_task.php
@@ -11,6 +11,11 @@ class phpbb_cron_task_core_dummy_task extends phpbb_cron_task_base
{
public static $was_run = 0;
+ public function get_name()
+ {
+ return get_class($this);
+ }
+
public function run()
{
self::$was_run++;
diff --git a/tests/cron/includes/cron/task/core/second_dummy_task.php b/tests/cron/includes/cron/task/core/second_dummy_task.php
index 8cd0bddfc0..76a55588f9 100644
--- a/tests/cron/includes/cron/task/core/second_dummy_task.php
+++ b/tests/cron/includes/cron/task/core/second_dummy_task.php
@@ -11,6 +11,11 @@ class phpbb_cron_task_core_second_dummy_task extends phpbb_cron_task_base
{
public static $was_run = 0;
+ public function get_name()
+ {
+ return get_class($this);
+ }
+
public function run()
{
self::$was_run++;
diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php
index 3e40a6d338..3c541be2a6 100644
--- a/tests/cron/manager_test.php
+++ b/tests/cron/manager_test.php
@@ -18,10 +18,10 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
{
public function setUp()
{
- $this->manager = new phpbb_cron_manager(array(
- 'phpbb_cron_task_core_dummy_task',
- 'phpbb_cron_task_core_second_dummy_task',
- 'phpbb_ext_testext_cron_dummy_task',
+ $this->manager = $this->create_cron_manager(array(
+ new phpbb_cron_task_core_dummy_task(),
+ new phpbb_cron_task_core_second_dummy_task(),
+ new phpbb_ext_testext_cron_dummy_task(),
));
$this->task_name = 'phpbb_cron_task_core_dummy_task';
}
@@ -33,13 +33,6 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
$this->assertEquals($this->task_name, $task->get_name());
}
- public function test_manager_instantiates_task_by_name()
- {
- $task = $this->manager->instantiate_task($this->task_name, array());
- $this->assertInstanceOf('phpbb_cron_task_wrapper', $task);
- $this->assertEquals($this->task_name, $task->get_name());
- }
-
public function test_manager_finds_all_ready_tasks()
{
$tasks = $this->manager->find_all_ready_tasks();
@@ -54,10 +47,10 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
public function test_manager_finds_only_ready_tasks()
{
- $manager = new phpbb_cron_manager(array(
- 'phpbb_cron_task_core_simple_ready',
- 'phpbb_cron_task_core_simple_not_runnable',
- 'phpbb_cron_task_core_simple_should_not_run',
+ $manager = $this->create_cron_manager(array(
+ new phpbb_cron_task_core_simple_ready(),
+ new phpbb_cron_task_core_simple_not_runnable(),
+ new phpbb_cron_task_core_simple_should_not_run(),
));
$tasks = $manager->find_all_ready_tasks();
$task_names = $this->tasks_to_names($tasks);
@@ -69,8 +62,15 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
$names = array();
foreach ($tasks as $task)
{
- $names[] = get_class($task->task);
+ $names[] = $task->get_name();
}
return $names;
}
+
+ private function create_cron_manager($tasks)
+ {
+ global $phpbb_root_path, $phpEx;
+
+ return new phpbb_cron_manager($tasks, $phpbb_root_path, $phpEx);
+ }
}
diff --git a/tests/cron/task_provider_test.php b/tests/cron/task_provider_test.php
index b42f40bb4a..ec853bb3ba 100644
--- a/tests/cron/task_provider_test.php
+++ b/tests/cron/task_provider_test.php
@@ -11,31 +11,40 @@ class phpbb_cron_task_provider_test extends PHPUnit_Framework_TestCase
{
public function setUp()
{
- $this->extension_manager = new phpbb_mock_extension_manager(
- dirname(__FILE__) . '/',
- array(
- 'testext' => array(
- 'ext_name' => 'testext',
- 'ext_active' => true,
- 'ext_path' => 'ext/testext/'
- ),
- ));
- $this->provider = new phpbb_cron_task_provider($this->extension_manager);
+ $this->tasks = array(
+ 'phpbb_cron_task_core_dummy_task',
+ 'phpbb_cron_task_core_second_dummy_task',
+ 'phpbb_ext_testext_cron_dummy_task',
+ );
+
+ $container = $this->getMock('Symfony\Component\DependencyInjection\TaggedContainerInterface');
+ $container
+ ->expects($this->once())
+ ->method('findTaggedServiceIds')
+ ->will($this->returnValue(array_flip($this->tasks)));
+ $container
+ ->expects($this->any())
+ ->method('get')
+ ->will($this->returnCallback(function ($name) {
+ return new $name;
+ }));
+
+ $this->provider = new phpbb_cron_task_provider($container);
}
public function test_manager_finds_shipped_tasks()
{
- $tasks = array();
+ $task_names = array();
foreach ($this->provider as $task)
{
- $tasks[] = $task;
+ $task_names[] = $task->get_name();
}
- sort($tasks);
+ sort($task_names);
$this->assertEquals(array(
'phpbb_cron_task_core_dummy_task',
'phpbb_cron_task_core_second_dummy_task',
'phpbb_ext_testext_cron_dummy_task',
- ), $tasks);
+ ), $task_names);
}
}
diff --git a/tests/cron/tasks/simple_not_runnable.php b/tests/cron/tasks/simple_not_runnable.php
index 837f28f1c0..56d484eacd 100644
--- a/tests/cron/tasks/simple_not_runnable.php
+++ b/tests/cron/tasks/simple_not_runnable.php
@@ -2,6 +2,11 @@
class phpbb_cron_task_core_simple_not_runnable extends phpbb_cron_task_base
{
+ public function get_name()
+ {
+ return get_class($this);
+ }
+
public function run()
{
}
diff --git a/tests/cron/tasks/simple_ready.php b/tests/cron/tasks/simple_ready.php
index de5f10e491..8aa0507406 100644
--- a/tests/cron/tasks/simple_ready.php
+++ b/tests/cron/tasks/simple_ready.php
@@ -2,6 +2,11 @@
class phpbb_cron_task_core_simple_ready extends phpbb_cron_task_base
{
+ public function get_name()
+ {
+ return get_class($this);
+ }
+
public function run()
{
}
diff --git a/tests/cron/tasks/simple_should_not_run.php b/tests/cron/tasks/simple_should_not_run.php
index c2a41616f6..58f6df2616 100644
--- a/tests/cron/tasks/simple_should_not_run.php
+++ b/tests/cron/tasks/simple_should_not_run.php
@@ -2,6 +2,11 @@
class phpbb_cron_task_core_simple_should_not_run extends phpbb_cron_task_base
{
+ public function get_name()
+ {
+ return get_class($this);
+ }
+
public function run()
{
}
diff --git a/tests/datetime/from_format_test.php b/tests/datetime/from_format_test.php
new file mode 100644
index 0000000000..c28925272e
--- /dev/null
+++ b/tests/datetime/from_format_test.php
@@ -0,0 +1,57 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/session.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/user.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/datetime.php';
+require_once dirname(__FILE__) . '/../mock/lang.php';
+
+class phpbb_datetime_from_format_test extends phpbb_test_case
+{
+ public function from_format_data()
+ {
+ return array(
+ array(
+ 'UTC',
+ 'Y-m-d',
+ '2012-06-08',
+ ),
+
+ array(
+ 'Europe/Berlin',
+ 'Y-m-d H:i:s',
+ '2012-06-08 14:01:02',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider from_format_data()
+ */
+ public function test_from_format($timezone, $format, $expected)
+ {
+ global $user;
+
+ $user = new phpbb_user();
+ $user->timezone = new DateTimeZone($timezone);
+ $user->lang['datetime'] = array(
+ 'TODAY' => 'Today',
+ 'TOMORROW' => 'Tomorrow',
+ 'YESTERDAY' => 'Yesterday',
+ 'AGO' => array(
+ 0 => 'less than a minute ago',
+ 1 => '%d minute ago',
+ 2 => '%d minutes ago',
+ ),
+ );
+
+ $timestamp = $user->get_timestamp_from_format($format, $expected, new DateTimeZone($timezone));
+ $this->assertEquals($expected, $user->format_date($timestamp, $format, true));
+ }
+}
diff --git a/tests/dbal/case_test.php b/tests/dbal/case_test.php
new file mode 100644
index 0000000000..57a1729a39
--- /dev/null
+++ b/tests/dbal/case_test.php
@@ -0,0 +1,69 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+class phpbb_dbal_case_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/config.xml');
+ }
+
+ public function test_case_int()
+ {
+ $db = $this->new_dbal();
+
+ $sql = 'SELECT ' . $db->sql_case('1 = 1', '1', '2') . ' AS test_num
+ FROM phpbb_config';
+ $result = $db->sql_query_limit($sql, 1);
+
+ $this->assertEquals(1, (int) $db->sql_fetchfield('test_num'));
+
+ $sql = 'SELECT ' . $db->sql_case('1 = 0', '1', '2') . ' AS test_num
+ FROM phpbb_config';
+ $result = $db->sql_query_limit($sql, 1);
+
+ $this->assertEquals(2, (int) $db->sql_fetchfield('test_num'));
+ }
+
+ public function test_case_string()
+ {
+ $db = $this->new_dbal();
+
+ $sql = 'SELECT ' . $db->sql_case('1 = 1', "'foo'", "'bar'") . ' AS test_string
+ FROM phpbb_config';
+ $result = $db->sql_query_limit($sql, 1);
+
+ $this->assertEquals('foo', $db->sql_fetchfield('test_string'));
+
+ $sql = 'SELECT ' . $db->sql_case('1 = 0', "'foo'", "'bar'") . ' AS test_string
+ FROM phpbb_config';
+ $result = $db->sql_query_limit($sql, 1);
+
+ $this->assertEquals('bar', $db->sql_fetchfield('test_string'));
+ }
+
+ public function test_case_column()
+ {
+ $db = $this->new_dbal();
+
+ $sql = 'SELECT ' . $db->sql_case("config_name = 'config1'", 'config_name', 'config_value') . " AS test_string
+ FROM phpbb_config
+ WHERE config_name = 'config1'";
+ $result = $db->sql_query_limit($sql, 1);
+
+ $this->assertEquals('config1', $db->sql_fetchfield('test_string'));
+
+ $sql = 'SELECT ' . $db->sql_case("config_name = 'config1'", 'config_name', 'config_value') . " AS test_string
+ FROM phpbb_config
+ WHERE config_value = 'bar'";
+ $result = $db->sql_query_limit($sql, 1);
+
+ $this->assertEquals('bar', $db->sql_fetchfield('test_string'));
+ }
+}
diff --git a/tests/dbal/concatenate_test.php b/tests/dbal/concatenate_test.php
new file mode 100644
index 0000000000..0891fa58a0
--- /dev/null
+++ b/tests/dbal/concatenate_test.php
@@ -0,0 +1,64 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+class phpbb_dbal_concatenate_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/config.xml');
+ }
+
+ public function test_concatenate_string()
+ {
+ $db = $this->new_dbal();
+
+ $sql = 'SELECT config_name, ' . $db->sql_concatenate('config_name', "'" . $db->sql_escape('append') . "'") . ' AS string
+ FROM phpbb_config';
+ $result = $db->sql_query($sql);
+
+ $db->sql_return_on_error(false);
+
+ $this->assertEquals(array(
+ array(
+ 'config_name' => 'config1',
+ 'string' => 'config1append',
+ ),
+ array(
+ 'config_name' => 'config2',
+ 'string' => 'config2append',
+ ),
+ ),
+ $db->sql_fetchrowset($result)
+ );
+ }
+
+ public function test_concatenate_statement()
+ {
+ $db = $this->new_dbal();
+
+ $sql = 'SELECT config_name, ' . $db->sql_concatenate('config_name', 'config_value') . ' AS string
+ FROM phpbb_config';
+ $result = $db->sql_query($sql);
+
+ $db->sql_return_on_error(false);
+
+ $this->assertEquals(array(
+ array(
+ 'config_name' => 'config1',
+ 'string' => 'config1foo',
+ ),
+ array(
+ 'config_name' => 'config2',
+ 'string' => 'config2bar',
+ ),
+ ),
+ $db->sql_fetchrowset($result)
+ );
+ }
+}
diff --git a/tests/dbal/order_lower_test.php b/tests/dbal/order_lower_test.php
index e16c0c20ee..84d454742f 100644
--- a/tests/dbal/order_lower_test.php
+++ b/tests/dbal/order_lower_test.php
@@ -14,7 +14,7 @@ class phpbb_dbal_order_lower_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/styles.xml');
}
- public function test_cross_join()
+ public function test_order_lower()
{
$db = $this->new_dbal();
diff --git a/tests/extension/acp.php b/tests/extension/acp.php
new file mode 100644
index 0000000000..790df77c0d
--- /dev/null
+++ b/tests/extension/acp.php
@@ -0,0 +1,205 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+class acp_test extends phpbb_functional_test_case
+{
+ static private $copied_files = array();
+ static private $helper;
+
+ /**
+ * This should only be called once before the tests are run.
+ * This is used to copy the extensions to the phpBB install
+ */
+ static public function setUpBeforeClass()
+ {
+ global $phpbb_root_path;
+
+ parent::setUpBeforeClass();
+
+ self::$helper = new phpbb_test_case_helpers(self);
+
+ // First, move any extensions setup on the board to a temp directory
+ self::$copied_files = self::$helper->copy_dir($phpbb_root_path . 'ext/', $phpbb_root_path . 'store/temp_ext/');
+
+ // Then empty the ext/ directory on the board (for accurate test cases)
+ self::$helper->empty_dir($phpbb_root_path . 'ext/');
+
+ // Copy our ext/ files from the test case to the board
+ self::$copied_files = array_merge(self::$copied_files, self::$helper->copy_dir(dirname(__FILE__) . '/ext/', $phpbb_root_path . 'ext/'));
+ }
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->get_db();
+
+ // Clear the phpbb_ext table
+ $this->db->sql_query('DELETE FROM phpbb_ext');
+
+ // Insert our base data
+ $insert_rows = array(
+ array(
+ 'ext_name' => 'foo',
+ 'ext_active' => true,
+ 'ext_state' => 'b:0;',
+ ),
+ array(
+ 'ext_name' => 'vendor/moo',
+ 'ext_active' => false,
+ 'ext_state' => 'b:0;',
+ ),
+
+ // do not exist
+ array(
+ 'ext_name' => 'test2',
+ 'ext_active' => true,
+ 'ext_state' => 'b:0;',
+ ),
+ array(
+ 'ext_name' => 'test3',
+ 'ext_active' => false,
+ 'ext_state' => 'b:0;',
+ ),
+ );
+ $this->db->sql_multi_insert('phpbb_ext', $insert_rows);
+
+ $this->login();
+ $this->admin_login();
+
+ $this->add_lang('acp/extensions');
+ }
+
+ /**
+ * This should only be called once after the tests are run.
+ * This is used to remove the files copied to the phpBB install
+ */
+ static public function tearDownAfterClass()
+ {
+ global $phpbb_root_path;
+
+ // Copy back the board installed extensions from the temp directory
+ self::$helper->copy_dir($phpbb_root_path . 'store/temp_ext/', $phpbb_root_path . 'ext/');
+
+ self::$copied_files[] = $phpbb_root_path . 'store/temp_ext/';
+
+ // Remove all of the files we copied around (from board ext -> temp_ext, from test ext -> board ext)
+ self::$helper->remove_files(self::$copied_files);
+ }
+
+ public function test_list()
+ {
+ $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
+
+ $this->assertCount(1, $crawler->filter('.ext_enabled'));
+ $this->assertCount(4, $crawler->filter('.ext_disabled'));
+
+ $this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text());
+ $this->assertContainsLang('PURGE', $crawler->filter('.ext_enabled')->eq(0)->text());
+
+ $this->assertContains('The "test2" extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text());
+
+ $this->assertContains('The "test3" extension is not valid.', $crawler->filter('.ext_disabled')->eq(1)->text());
+
+ $this->assertContains('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(2)->text());
+ $this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(2)->text());
+ $this->assertContainsLang('ENABLE', $crawler->filter('.ext_disabled')->eq(2)->text());
+ $this->assertContainsLang('PURGE', $crawler->filter('.ext_disabled')->eq(2)->text());
+
+ $this->assertContains('The "bar" extension is not valid.', $crawler->filter('.ext_disabled')->eq(3)->text());
+ }
+
+ public function test_details()
+ {
+ $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=foo&sid=' . $this->sid);
+
+ $validation = array(
+ 'DISPLAY_NAME' => 'phpBB Foo Extension',
+ 'CLEAN_NAME' => 'foo/example',
+ 'DESCRIPTION' => 'An example/sample extension to be used for testing purposes in phpBB Development.',
+ 'VERSION' => '1.0.0',
+ 'TIME' => '2012-02-15 01:01:01',
+ 'LICENCE' => 'GPL-2.0',
+ 'PHPBB_VERSION' => '3.1.0-dev',
+ 'PHP_VERSION' => '>=5.3',
+ 'AUTHOR_NAME' => 'Nathan Guse',
+ 'AUTHOR_EMAIL' => 'email@phpbb.com',
+ 'AUTHOR_HOMEPAGE' => 'http://lithiumstudios.org',
+ 'AUTHOR_ROLE' => 'N/A',
+ );
+
+ for ($i = 0; $i < $crawler->filter('dl')->count(); $i++)
+ {
+ $text = $crawler->filter('dl')->eq($i)->text();
+
+ $match = false;
+
+ foreach ($validation as $language_key => $expected)
+ {
+ if (strpos($text, $this->lang($language_key)) === 0)
+ {
+ $match = true;
+
+ $this->assertContains($expected, $text);
+ }
+ }
+
+ if (!$match)
+ {
+ $this->fail('Unexpected field: "' . $text . '"');
+ }
+ }
+ }
+
+ public function test_enable_pre()
+ {
+ // Foo is already enabled (redirect to list)
+ $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=foo&sid=' . $this->sid);
+ $this->assertContainsLang('EXTENSION_NAME', $crawler->filter('html')->text());
+ $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text());
+ $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('html')->text());
+
+ $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
+ $this->assertContainsLang('ENABLE_CONFIRM', $crawler->filter('html')->text());
+ }
+
+ public function test_disable_pre()
+ {
+ // Moo is not enabled (redirect to list)
+ $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
+ $this->assertContainsLang('EXTENSION_NAME', $crawler->filter('html')->text());
+ $this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text());
+ $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('html')->text());
+
+ $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=foo&sid=' . $this->sid);
+ $this->assertContainsLang('DISABLE_CONFIRM', $crawler->filter('html')->text());
+ }
+
+ public function test_purge_pre()
+ {
+ // test2 is not available (error)
+ $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=test2&sid=' . $this->sid);
+ $this->assertContains('The required file does not exist', $crawler->filter('html')->text());
+
+ $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=foo&sid=' . $this->sid);
+ $this->assertContainsLang('PURGE_CONFIRM', $crawler->filter('html')->text());
+ }
+
+ public function test_actions()
+ {
+ $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable&ext_name=vendor%2Fmoo&sid=' . $this->sid);
+ $this->assertContainsLang('ENABLE_SUCCESS', $crawler->filter('html')->text());
+
+ $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable&ext_name=vendor%2Fmoo&sid=' . $this->sid);
+ $this->assertContainsLang('DISABLE_SUCCESS', $crawler->filter('html')->text());
+
+ $crawler = $this->request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge&ext_name=vendor%2Fmoo&sid=' . $this->sid);
+ $this->assertContainsLang('PURGE_SUCCESS', $crawler->filter('html')->text());
+ }
+} \ No newline at end of file
diff --git a/tests/extension/ext/foo/composer.json b/tests/extension/ext/foo/composer.json
new file mode 100644
index 0000000000..744f7be625
--- /dev/null
+++ b/tests/extension/ext/foo/composer.json
@@ -0,0 +1,22 @@
+{
+ "name": "foo/example",
+ "type": "phpbb3-extension",
+ "description": "An example/sample extension to be used for testing purposes in phpBB Development.",
+ "version": "1.0.0",
+ "time": "2012-02-15 01:01:01",
+ "licence": "GPL-2.0",
+ "authors": [{
+ "name": "Nathan Guse",
+ "username": "EXreaction",
+ "email": "email@phpbb.com",
+ "homepage": "http://lithiumstudios.org",
+ "role": "N/A"
+ }],
+ "require": {
+ "php": ">=5.3",
+ "phpbb": "3.1.0-dev"
+ },
+ "extra": {
+ "display-name": "phpBB Foo Extension"
+ }
+}
diff --git a/tests/extension/ext/vendor/moo/composer.json b/tests/extension/ext/vendor/moo/composer.json
new file mode 100644
index 0000000000..c91a5e027b
--- /dev/null
+++ b/tests/extension/ext/vendor/moo/composer.json
@@ -0,0 +1,22 @@
+{
+ "name": "moo/example",
+ "type": "phpbb3-extension",
+ "description": "An example/sample extension to be used for testing purposes in phpBB Development.",
+ "version": "1.0.0",
+ "time": "2012-02-15 01:01:01",
+ "licence": "GNU GPL v2",
+ "authors": [{
+ "name": "Nathan Guse",
+ "username": "EXreaction",
+ "email": "email@phpbb.com",
+ "homepage": "http://lithiumstudios.org",
+ "role": "N/A"
+ }],
+ "require": {
+ "php": ">=5.3",
+ "phpbb": "3.1.0-dev"
+ },
+ "extra": {
+ "display-name": "phpBB Moo Extension"
+ }
+}
diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php
index 45bed247ae..5cde5bccdb 100644
--- a/tests/extension/manager_test.php
+++ b/tests/extension/manager_test.php
@@ -27,6 +27,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
$this->extension_manager = new phpbb_extension_manager(
$this->new_dbal(),
+ new phpbb_config(array()),
'phpbb_ext',
dirname(__FILE__) . '/',
'.php',
@@ -90,6 +91,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
{
$extension_manager = new phpbb_extension_manager(
$this->new_dbal(),
+ new phpbb_config(array()),
'phpbb_ext',
dirname(__FILE__) . '/',
'.php'
diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php
new file mode 100644
index 0000000000..9865f14314
--- /dev/null
+++ b/tests/extension/metadata_manager_test.php
@@ -0,0 +1,430 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+class metadata_manager_test extends phpbb_database_test_case
+{
+ protected $class_loader;
+ protected $extension_manager;
+
+ protected $cache;
+ protected $config;
+ protected $db;
+ protected $phpbb_root_path;
+ protected $phpEx;
+ protected $template;
+ protected $user;
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/extensions.xml');
+ }
+
+ protected function setUp()
+ {
+ parent::setUp();
+
+ $this->cache = new phpbb_mock_cache();
+ $this->config = new phpbb_config(array(
+ 'version' => '3.1.0',
+ ));
+ $this->db = $this->new_dbal();
+ $this->phpbb_root_path = dirname(__FILE__) . '/';
+ $this->phpEx = '.php';
+ $this->user = new phpbb_user();
+
+ $this->template = new phpbb_template(
+ $this->phpbb_root_path,
+ $this->phpEx,
+ $this->config,
+ $this->user,
+ new phpbb_style_resource_locator()
+ );
+
+ $this->extension_manager = new phpbb_extension_manager(
+ $this->db,
+ $this->config,
+ 'phpbb_ext',
+ $this->phpbb_root_path,
+ $this->phpEx,
+ $this->cache
+ );
+ }
+
+ // Should fail from missing composer.json
+ public function test_bar()
+ {
+ $ext_name = 'bar';
+
+ $manager = $this->get_metadata_manager($ext_name);
+
+ try
+ {
+ $manager->get_metadata();
+ }
+ catch(phpbb_extension_exception $e){}
+
+ $this->assertEquals((string) $e, 'The required file does not exist: ' . $this->phpbb_root_path . $this->extension_manager->get_extension_path($ext_name) . 'composer.json');
+ }
+
+ // Should be the same as a direct json_decode of the composer.json file
+ public function test_foo()
+ {
+ $ext_name = 'foo';
+
+ $manager = $this->get_metadata_manager($ext_name);
+
+ try
+ {
+ $metadata = $manager->get_metadata();
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->fail($e);
+ }
+
+ $json = json_decode(file_get_contents($this->phpbb_root_path . 'ext/foo/composer.json'), true);
+
+ $this->assertEquals($metadata, $json);
+ }
+
+ public function test_validator_non_existant()
+ {
+ $ext_name = 'validator';
+
+ $manager = $this->get_metadata_manager($ext_name);
+
+ // Non-existant data
+ try
+ {
+ $manager->validate('name');
+
+ $this->fail('Exception not triggered');
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->assertEquals((string) $e, 'Required meta field \'name\' has not been set.');
+ }
+
+ try
+ {
+ $manager->validate('type');
+
+ $this->fail('Exception not triggered');
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->assertEquals((string) $e, 'Required meta field \'type\' has not been set.');
+ }
+
+ try
+ {
+ $manager->validate('licence');
+
+ $this->fail('Exception not triggered');
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->assertEquals((string) $e, 'Required meta field \'licence\' has not been set.');
+ }
+
+ try
+ {
+ $manager->validate('version');
+
+ $this->fail('Exception not triggered');
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->assertEquals((string) $e, 'Required meta field \'version\' has not been set.');
+ }
+
+ try
+ {
+ $manager->validate_authors();
+
+ $this->fail('Exception not triggered');
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->assertEquals((string) $e, 'Required meta field \'authors\' has not been set.');
+ }
+
+ $manager->merge_metadata(array(
+ 'authors' => array(
+ array(),
+ ),
+ ));
+
+ try
+ {
+ $manager->validate_authors();
+
+ $this->fail('Exception not triggered');
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->assertEquals((string) $e, 'Required meta field \'author name\' has not been set.');
+ }
+ }
+
+
+ public function test_validator_invalid()
+ {
+ $ext_name = 'validator';
+
+ $manager = $this->get_metadata_manager($ext_name);
+
+ // Invalid data
+ $manager->set_metadata(array(
+ 'name' => 'asdf',
+ 'type' => 'asdf',
+ 'licence' => '',
+ 'version' => '',
+ ));
+
+ try
+ {
+ $manager->validate('name');
+
+ $this->fail('Exception not triggered');
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->assertEquals((string) $e, 'Meta field \'name\' is invalid.');
+ }
+
+ try
+ {
+ $manager->validate('type');
+
+ $this->fail('Exception not triggered');
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->assertEquals((string) $e, 'Meta field \'type\' is invalid.');
+ }
+
+ try
+ {
+ $manager->validate('licence');
+
+ $this->fail('Exception not triggered');
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->assertEquals((string) $e, 'Meta field \'licence\' is invalid.');
+ }
+
+ try
+ {
+ $manager->validate('version');
+
+ $this->fail('Exception not triggered');
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->assertEquals((string) $e, 'Meta field \'version\' is invalid.');
+ }
+ }
+
+ public function test_validator_valid()
+ {
+ $ext_name = 'validator';
+
+ $manager = $this->get_metadata_manager($ext_name);
+
+ // Valid data
+ $manager->set_metadata(array(
+ 'name' => 'test/foo',
+ 'type' => 'phpbb3-extension',
+ 'licence' => 'GPL v2',
+ 'version' => '1.0.0',
+ ));
+
+ try
+ {
+ $this->assertEquals(true, $manager->validate('enable'));
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->fail($e);
+ }
+ }
+
+
+ public function test_validator_requirements()
+ {
+ $ext_name = 'validator';
+
+ $manager = $this->get_metadata_manager($ext_name);
+ // Too high of requirements
+ $manager->merge_metadata(array(
+ 'require' => array(
+ 'php' => '10.0.0',
+ 'phpbb' => '3.2.0', // config is set to 3.1.0
+ ),
+ ));
+
+ try
+ {
+ $this->assertEquals(false, $manager->validate_require_php());
+ $this->assertEquals(false, $manager->validate_require_phpbb());
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->fail($e);
+ }
+
+
+ // Too high of requirements
+ $manager->merge_metadata(array(
+ 'require' => array(
+ 'php' => '5.3.0',
+ 'phpbb' => '3.1.0-beta', // config is set to 3.1.0
+ ),
+ ));
+
+ try
+ {
+ $this->assertEquals(true, $manager->validate_require_php());
+ $this->assertEquals(true, $manager->validate_require_phpbb());
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->fail($e);
+ }
+
+
+ // Too high of requirements
+ $manager->merge_metadata(array(
+ 'require' => array(
+ 'php' => '>' . phpversion(),
+ 'phpbb' => '>3.1.0', // config is set to 3.1.0
+ ),
+ ));
+
+ try
+ {
+ $this->assertEquals(false, $manager->validate_require_php());
+ $this->assertEquals(false, $manager->validate_require_phpbb());
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->fail($e);
+ }
+
+
+ // Too high of current install
+ $manager->merge_metadata(array(
+ 'require' => array(
+ 'php' => '<' . phpversion(),
+ 'phpbb' => '<3.1.0', // config is set to 3.1.0
+ ),
+ ));
+
+ try
+ {
+ $this->assertEquals(false, $manager->validate_require_php());
+ $this->assertEquals(false, $manager->validate_require_phpbb());
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->fail($e);
+ }
+
+
+ // Matching requirements
+ $manager->merge_metadata(array(
+ 'require' => array(
+ 'php' => phpversion(),
+ 'phpbb' => '3.1.0', // config is set to 3.1.0
+ ),
+ ));
+
+ try
+ {
+ $this->assertEquals(true, $manager->validate_require_php());
+ $this->assertEquals(true, $manager->validate_require_phpbb());
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->fail($e);
+ }
+
+
+ // Matching requirements
+ $manager->merge_metadata(array(
+ 'require' => array(
+ 'php' => '>=' . phpversion(),
+ 'phpbb' => '>=3.1.0', // config is set to 3.1.0
+ ),
+ ));
+
+ try
+ {
+ $this->assertEquals(true, $manager->validate_require_php());
+ $this->assertEquals(true, $manager->validate_require_phpbb());
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->fail($e);
+ }
+
+
+ // Matching requirements
+ $manager->merge_metadata(array(
+ 'require' => array(
+ 'php' => '<=' . phpversion(),
+ 'phpbb' => '<=3.1.0', // config is set to 3.1.0
+ ),
+ ));
+
+ try
+ {
+ $this->assertEquals(true, $manager->validate_require_php());
+ $this->assertEquals(true, $manager->validate_require_phpbb());
+ }
+ catch(phpbb_extension_exception $e)
+ {
+ $this->fail($e);
+ }
+ }
+
+ /**
+ * Get an instance of the metadata manager
+ *
+ * @param string $ext_name
+ * @return phpbb_extension_metadata_manager_test
+ */
+ private function get_metadata_manager($ext_name)
+ {
+ return new phpbb_extension_metadata_manager_test(
+ $ext_name,
+ $this->db,
+ $this->extension_manager,
+ $this->phpbb_root_path,
+ $this->phpEx,
+ $this->template,
+ $this->config
+ );
+ }
+}
+
+class phpbb_extension_metadata_manager_test extends phpbb_extension_metadata_manager
+{
+ public function set_metadata($metadata)
+ {
+ $this->metadata = $metadata;
+ }
+
+ public function merge_metadata($metadata)
+ {
+ $this->metadata = array_merge($this->metadata, $metadata);
+ }
+} \ No newline at end of file
diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php
index 6ba55eeba7..f7267fa659 100644
--- a/tests/functional/fileupload_form_test.php
+++ b/tests/functional/fileupload_form_test.php
@@ -22,41 +22,48 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
$this->login();
}
+ private function upload_file($filename, $mimetype)
+ {
+ $file = array(
+ 'tmp_name' => $this->path . $filename,
+ 'name' => $filename,
+ 'type' => $mimetype,
+ 'size' => filesize($this->path . $filename),
+ 'error' => UPLOAD_ERR_OK,
+ );
+
+ $crawler = $this->client->request(
+ 'POST',
+ 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid,
+ array('add_file' => $this->lang('ADD_FILE')),
+ array('fileupload' => $file)
+ );
+
+ return $crawler;
+ }
+
public function test_empty_file()
{
- $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid);
- $form = $crawler->selectButton('add_file')->form();
- $form['fileupload']->upload($this->path . 'empty.png');
- $crawler = $this->client->submit($form);
+ $crawler = $this->upload_file('empty.png', 'image/png');
$this->assertEquals($this->lang('ATTACHED_IMAGE_NOT_IMAGE'), $crawler->filter('div#message p')->text());
}
public function test_invalid_extension()
{
- $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid);
- $form = $crawler->selectButton('add_file')->form();
- $form['fileupload']->upload($this->path . 'illegal-extension.bif');
- $crawler = $this->client->submit($form);
+ $crawler = $this->upload_file('illegal-extension.bif', 'application/octet-stream');
$this->assertEquals($this->lang('DISALLOWED_EXTENSION', 'bif'), $crawler->filter('p.error')->text());
}
public function test_too_large()
{
$this->markTestIncomplete('Functional tests use an admin account which ignores maximum upload size.');
- $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid);
- $form = $crawler->selectButton('add_file')->form();
- $form['fileupload']->upload($this->path . 'too-large.png');
- $crawler = $this->client->submit($form);
+ $crawler = $this->upload_file('too-large.png', 'image/png');
$this->assertEquals($this->lang('WRONG_FILESIZE', '256', 'KiB'), $crawler->filter('p.error')->text());
}
public function test_valid_file()
{
- $crawler = $this->request('GET', 'posting.php?mode=reply&f=2&t=1&sid=' . $this->sid);
- $form = $crawler->selectButton('add_file')->form();
- $form['fileupload']->upload($this->path . 'valid.jpg');
- $crawler = $this->client->submit($form);
- $this->assertEquals(0, $crawler->filter('p.error')->count());
+ $crawler = $this->upload_file('valid.jpg', 'image/jpeg');
$this->assertContains($this->lang('POSTED_ATTACHMENTS'), $crawler->filter('#postform h3')->eq(1)->text());
}
}
diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php
new file mode 100644
index 0000000000..f54a3591b2
--- /dev/null
+++ b/tests/functional/posting_test.php
@@ -0,0 +1,102 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @group functional
+*/
+class phpbb_functional_posting_test extends phpbb_functional_test_case
+{
+ public function test_post_new_topic()
+ {
+ $this->login();
+ $this->add_lang('posting');
+
+ $crawler = $this->request('GET', 'posting.php?mode=post&f=2&sid=' . $this->sid);
+ $this->assertContains($this->lang('POST_TOPIC'), $crawler->filter('html')->text());
+
+ $hidden_fields = array();
+ $hidden_fields[] = $crawler->filter('[type="hidden"]')->each(function ($node, $i) {
+ return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value'));
+ });
+
+ $test_message = 'This is a test topic posted by the testing framework.';
+ $form_data = array(
+ 'subject' => 'Test Topic 1',
+ 'message' => $test_message,
+ 'post' => true,
+ 'f' => 2,
+ 'mode' => 'post',
+ 'sid' => $this->sid,
+ );
+
+ foreach ($hidden_fields as $fields)
+ {
+ foreach($fields as $field)
+ {
+ $form_data[$field['name']] = $field['value'];
+ }
+ }
+
+ // Bypass time restriction that said that if the lastclick time (i.e. time when the form was opened)
+ // is not at least 2 seconds before submission, cancel the form
+ $form_data['lastclick'] = 0;
+
+ // I use a request because the form submission method does not allow you to send data that is not
+ // contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs)
+ // Instead, I send it as a request with the submit button "post" set to true.
+ $crawler = $this->client->request('POST', 'posting.php', $form_data);
+ $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
+
+ $crawler = $this->request('GET', 'viewtopic.php?t=2&sid=' . $this->sid);
+ $this->assertContains($test_message, $crawler->filter('html')->text());
+ }
+
+ public function test_post_reply()
+ {
+ $this->login();
+ $this->add_lang('posting');
+
+ $crawler = $this->request('GET', 'posting.php?mode=reply&t=2&f=2&sid=' . $this->sid);
+ $this->assertContains($this->lang('POST_REPLY'), $crawler->filter('html')->text());
+
+ $hidden_fields = array();
+ $hidden_fields[] = $crawler->filter('[type="hidden"]')->each(function ($node, $i) {
+ return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value'));
+ });
+
+ $test_message = 'This is a test post posted by the testing framework.';
+ $form_data = array(
+ 'subject' => 'Re: Test Topic 1',
+ 'message' => $test_message,
+ 'post' => true,
+ 't' => 2,
+ 'f' => 2,
+ 'mode' => 'reply',
+ 'sid' => $this->sid,
+ );
+
+ foreach ($hidden_fields as $fields)
+ {
+ foreach($fields as $field)
+ {
+ $form_data[$field['name']] = $field['value'];
+ }
+ }
+
+ // For reasoning behind the following command, see the test_post_new_topic() test
+ $form_data['lastclick'] = 0;
+
+ // Submit the post
+ $crawler = $this->client->request('POST', 'posting.php', $form_data);
+ $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
+
+ $crawler = $this->request('GET', 'viewtopic.php?t=2&sid=' . $this->sid);
+ $this->assertContains($test_message, $crawler->filter('html')->text());
+ }
+}
diff --git a/tests/functions_acp/build_cfg_template_test.php b/tests/functions_acp/build_cfg_template_test.php
index 12121f6678..bf5330fd88 100644
--- a/tests/functions_acp/build_cfg_template_test.php
+++ b/tests/functions_acp/build_cfg_template_test.php
@@ -46,8 +46,9 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
*/
public function test_build_cfg_template_text($tpl_type, $key, $new, $config_key, $vars, $expected)
{
- global $user;
+ global $user, $phpbb_dispatcher;
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$user->lang = new phpbb_mock_lang();
$this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
@@ -80,8 +81,9 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
*/
public function test_build_cfg_template_dimension($tpl_type, $key, $new, $config_key, $vars, $expected)
{
- global $user;
+ global $user, $phpbb_dispatcher;
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$user->lang = new phpbb_mock_lang();
$this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
@@ -106,8 +108,9 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
*/
public function test_build_cfg_template_textarea($tpl_type, $key, $new, $config_key, $vars, $expected)
{
- global $user;
+ global $user, $phpbb_dispatcher;
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$user->lang = new phpbb_mock_lang();
$this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
@@ -156,8 +159,9 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
*/
public function test_build_cfg_template_radio($tpl_type, $key, $new, $config_key, $vars, $expected)
{
- global $user;
+ global $user, $phpbb_dispatcher;
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$user->lang = new phpbb_mock_lang();
$this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
@@ -182,8 +186,9 @@ class phpbb_functions_acp_build_cfg_template_test extends phpbb_test_case
*/
public function test_build_cfg_template_append($tpl_type, $key, $new, $config_key, $vars, $expected)
{
- global $user;
+ global $user, $phpbb_dispatcher;
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$user->lang = new phpbb_mock_lang();
$this->assertEquals($expected, build_cfg_template($tpl_type, $key, $new, $config_key, $vars));
diff --git a/tests/mock/cache.php b/tests/mock/cache.php
index c6d08afef0..b64c92ea89 100644
--- a/tests/mock/cache.php
+++ b/tests/mock/cache.php
@@ -121,7 +121,7 @@ class phpbb_mock_cache implements phpbb_cache_driver_interface
public function sql_load($query)
{
}
- public function sql_save($query, &$query_result, $ttl)
+ public function sql_save($query, $query_result, $ttl)
{
}
public function sql_exists($query_id)
diff --git a/tests/mock/event_dispatcher.php b/tests/mock/event_dispatcher.php
new file mode 100644
index 0000000000..8887b16163
--- /dev/null
+++ b/tests/mock/event_dispatcher.php
@@ -0,0 +1,16 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+class phpbb_mock_event_dispatcher
+{
+ public function trigger_event($eventName, $data)
+ {
+ return array();
+ }
+}
diff --git a/tests/mock/extension_manager.php b/tests/mock/extension_manager.php
index 77f799dd3b..fdda4cbadc 100644
--- a/tests/mock/extension_manager.php
+++ b/tests/mock/extension_manager.php
@@ -12,7 +12,7 @@ class phpbb_mock_extension_manager extends phpbb_extension_manager
public function __construct($phpbb_root_path, $extensions = array())
{
$this->phpbb_root_path = $phpbb_root_path;
- $this->phpEx = '.php';
+ $this->php_ext = '.php';
$this->extensions = $extensions;
}
}
diff --git a/tests/privmsgs/delete_user_pms_test.php b/tests/privmsgs/delete_user_pms_test.php
new file mode 100644
index 0000000000..265df1596a
--- /dev/null
+++ b/tests/privmsgs/delete_user_pms_test.php
@@ -0,0 +1,102 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_privmsgs.php';
+
+class phpbb_privmsgs_delete_user_pms_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/delete_user_pms.xml');
+ }
+
+ public static function delete_user_pms_data()
+ {
+ return array(
+ // array(
+ // (user we delete),
+ // array(remaining privmsgs ids),
+ // array(remaining privmsgs_to),
+ // ),
+ array(
+ 2,
+ array(
+ array('msg_id' => 1),
+ ),
+ array(
+ array('msg_id' => 1, 'user_id' => 3),
+ ),
+ ),
+ array(
+ 3,
+ array(
+ array('msg_id' => 1),
+ array('msg_id' => 2),
+ array('msg_id' => 3),
+ array('msg_id' => 5),
+ ),
+ array(
+ array('msg_id' => 1, 'user_id' => 2),
+ array('msg_id' => 1, 'user_id' => 4),
+ array('msg_id' => 2, 'user_id' => 2),
+ array('msg_id' => 2, 'user_id' => 4),
+ array('msg_id' => 3, 'user_id' => 2),
+ array('msg_id' => 5, 'user_id' => 2),
+ array('msg_id' => 5, 'user_id' => 4),
+ ),
+ ),
+ array(
+ 5,
+ array(
+ array('msg_id' => 1),
+ array('msg_id' => 2),
+ array('msg_id' => 3),
+ array('msg_id' => 4),
+ array('msg_id' => 5),
+ ),
+ array(
+ array('msg_id' => 1, 'user_id' => 2),
+ array('msg_id' => 1, 'user_id' => 3),
+ array('msg_id' => 1, 'user_id' => 4),
+ array('msg_id' => 2, 'user_id' => 2),
+ array('msg_id' => 2, 'user_id' => 4),
+ array('msg_id' => 3, 'user_id' => 2),
+ array('msg_id' => 4, 'user_id' => 3),
+ array('msg_id' => 5, 'user_id' => 2),
+ array('msg_id' => 5, 'user_id' => 3),
+ array('msg_id' => 5, 'user_id' => 4),
+ ),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider delete_user_pms_data
+ */
+ public function test_delete_user_pms($delete_user, $remaining_privmsgs, $remaining_privmsgs_to)
+ {
+ global $db;
+
+ $db = $this->new_dbal();
+
+ phpbb_delete_user_pms($delete_user);
+
+ $sql = 'SELECT msg_id
+ FROM ' . PRIVMSGS_TABLE;
+ $result = $db->sql_query($sql);
+
+ $this->assertEquals($remaining_privmsgs, $db->sql_fetchrowset($result));
+
+ $sql = 'SELECT msg_id, user_id
+ FROM ' . PRIVMSGS_TO_TABLE;
+ $result = $db->sql_query($sql);
+
+ $this->assertEquals($remaining_privmsgs_to, $db->sql_fetchrowset($result));
+ }
+}
diff --git a/tests/privmsgs/fixtures/delete_user_pms.xml b/tests/privmsgs/fixtures/delete_user_pms.xml
new file mode 100644
index 0000000000..9a86501b7a
--- /dev/null
+++ b/tests/privmsgs/fixtures/delete_user_pms.xml
@@ -0,0 +1,215 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_users">
+ <column>user_id</column>
+ <column>username</column>
+ <column>username_clean</column>
+ <column>user_new_privmsg</column>
+ <column>user_unread_privmsg</column>
+ <column>user_permissions</column>
+ <column>user_sig</column>
+ <column>user_occ</column>
+ <column>user_interests</column>
+ <row>
+ <value>2</value>
+ <value>sender</value>
+ <value>sender</value>
+ <value>0</value>
+ <value>0</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>pm in inbox</value>
+ <value>pm in inbox</value>
+ <value>0</value>
+ <value>0</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>pm in no box</value>
+ <value>pm in no box</value>
+ <value>2</value>
+ <value>2</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>5</value>
+ <value>no pms</value>
+ <value>no pms</value>
+ <value>0</value>
+ <value>0</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
+ </row>
+ </table>
+ <table name="phpbb_privmsgs">
+ <column>msg_id</column>
+ <column>root_level</column>
+ <column>author_id</column>
+ <column>message_subject</column>
+ <column>message_text</column>
+ <column>to_address</column>
+ <column>bcc_address</column>
+ <row>
+ <value>1</value>
+ <value>0</value>
+ <value>2</value>
+ <value>#1</value>
+ <value>
+ 2 - outbox
+ 3 - inbox
+ 4 - nobox
+ </value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>0</value>
+ <value>2</value>
+ <value>#2</value>
+ <value>
+ 2 - outbox
+ 4 - nobox
+ </value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>0</value>
+ <value>2</value>
+ <value>#3</value>
+ <value>
+ 2 - outbox
+ </value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>0</value>
+ <value>2</value>
+ <value>#4</value>
+ <value>
+ 3 - nobox
+ </value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>5</value>
+ <value>0</value>
+ <value>2</value>
+ <value>#5</value>
+ <value>
+ 2 - outbox
+ 3 - nobox
+ 4 - nobox
+ </value>
+ <value></value>
+ <value></value>
+ </row>
+ </table>
+ <table name="phpbb_privmsgs_to">
+ <column>msg_id</column>
+ <column>user_id</column>
+ <column>author_id</column>
+ <column>pm_new</column>
+ <column>pm_unread</column>
+ <column>folder_id</column>
+ <row>
+ <value>1</value>
+ <value>2</value>
+ <value>2</value>
+ <value>0</value>
+ <value>0</value>
+ <value>-2</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>3</value>
+ <value>2</value>
+ <value>0</value>
+ <value>0</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>4</value>
+ <value>2</value>
+ <value>0</value>
+ <value>0</value>
+ <value>-3</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>2</value>
+ <value>2</value>
+ <value>0</value>
+ <value>0</value>
+ <value>-2</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>4</value>
+ <value>2</value>
+ <value>0</value>
+ <value>0</value>
+ <value>-3</value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>2</value>
+ <value>2</value>
+ <value>0</value>
+ <value>0</value>
+ <value>-2</value>
+ </row>
+ <row>
+ <value>4</value>
+ <value>3</value>
+ <value>2</value>
+ <value>0</value>
+ <value>0</value>
+ <value>-3</value>
+ </row>
+ <row>
+ <value>5</value>
+ <value>2</value>
+ <value>2</value>
+ <value>0</value>
+ <value>0</value>
+ <value>-2</value>
+ </row>
+ <row>
+ <value>5</value>
+ <value>3</value>
+ <value>2</value>
+ <value>0</value>
+ <value>0</value>
+ <value>-3</value>
+ </row>
+ <row>
+ <value>5</value>
+ <value>4</value>
+ <value>2</value>
+ <value>0</value>
+ <value>0</value>
+ <value>-3</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/request/type_cast_helper_test.php b/tests/request/type_cast_helper_test.php
index d553d5b8cd..f41db005af 100644
--- a/tests/request/type_cast_helper_test.php
+++ b/tests/request/type_cast_helper_test.php
@@ -48,4 +48,24 @@ class phpbb_type_cast_helper_test extends phpbb_test_case
$this->assertEquals($expected, $data);
}
+
+ public function test_simple_untrimmed_recursive_set_var()
+ {
+ $data = " eviL<3\t\t";
+ $expected = " eviL&lt;3\t\t";
+
+ $this->type_cast_helper->recursive_set_var($data, '', true, false);
+
+ $this->assertEquals($expected, $data);
+ }
+
+ public function test_nested_untrimmed_recursive_set_var()
+ {
+ $data = array(" eviL<3\t\t");
+ $expected = array(" eviL&lt;3\t\t");
+
+ $this->type_cast_helper->recursive_set_var($data, array(0 => ''), true, false);
+
+ $this->assertEquals($expected, $data);
+ }
}
diff --git a/tests/session/append_sid_test.php b/tests/session/append_sid_test.php
index 88f6f0718e..34f6dea8ca 100644
--- a/tests/session/append_sid_test.php
+++ b/tests/session/append_sid_test.php
@@ -45,6 +45,9 @@ class phpbb_session_append_sid_test extends phpbb_test_case
*/
public function test_append_sid($url, $params, $is_amp, $session_id, $expected, $description)
{
+ global $phpbb_dispatcher;
+
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher;
$this->assertEquals($expected, append_sid($url, $params, $is_amp, $session_id));
}
}
diff --git a/tests/test_framework/phpbb_database_connection_odbc_pdo_wrapper.php b/tests/test_framework/phpbb_database_connection_odbc_pdo_wrapper.php
new file mode 100644
index 0000000000..ec59fa3886
--- /dev/null
+++ b/tests/test_framework/phpbb_database_connection_odbc_pdo_wrapper.php
@@ -0,0 +1,37 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+if (!class_exists('PDO'))
+{
+ return;
+}
+
+/**
+* Used for passing in information about the PDO driver
+* since the PDO class reveals nothing about the DSN that
+* the user provided.
+*
+* This is used in the custom PHPUnit ODBC driver
+*/
+class phpbb_database_connection_odbc_pdo_wrapper extends PDO
+{
+ // Name of the driver being used (i.e. mssql, firebird)
+ public $driver = '';
+
+ // Version number of driver since PDO::getAttribute(PDO::ATTR_CLIENT_VERSION) is pretty useless for this
+ public $version = 0;
+
+ function __construct($dbms, $version, $dsn, $user, $pass)
+ {
+ $this->driver = $dbms;
+ $this->version = (double) $version;
+
+ parent::__construct($dsn, $user, $pass);
+ }
+}
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index e742b543b0..bb86df0ef0 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -28,6 +28,28 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
);
}
+ public function createXMLDataSet($path)
+ {
+ $db_config = $this->get_database_config();
+
+ // Firebird requires table and column names to be uppercase
+ if ($db_config['dbms'] == 'firebird')
+ {
+ $xml_data = file_get_contents($path);
+ $xml_data = preg_replace_callback('/(?:(<table name="))([a-z_]+)(?:(">))/', 'phpbb_database_test_case::to_upper', $xml_data);
+ $xml_data = preg_replace_callback('/(?:(<column>))([a-z_]+)(?:(<\/column>))/', 'phpbb_database_test_case::to_upper', $xml_data);
+
+ $new_fixture = tmpfile();
+ fwrite($new_fixture, $xml_data);
+ fseek($new_fixture, 0);
+
+ $meta_data = stream_get_meta_data($new_fixture);
+ $path = $meta_data['uri'];
+ }
+
+ return parent::createXMLDataSet($path);
+ }
+
public function get_test_case_helpers()
{
if (!$this->test_case_helpers)
@@ -106,4 +128,17 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
{
return new phpbb_database_test_connection_manager($config);
}
+
+ /**
+ * Converts a match in the middle of a string to uppercase.
+ * This is necessary for transforming the fixture information for Firebird tests
+ *
+ * @param $matches The array of matches from a regular expression
+ *
+ * @return string The string with the specified match converted to uppercase
+ */
+ public static function to_upper($matches)
+ {
+ return $matches[1] . strtoupper($matches[2]) . $matches[3];
+ }
}
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php
index dacbbe2dc4..25e0972f42 100644
--- a/tests/test_framework/phpbb_database_test_connection_manager.php
+++ b/tests/test_framework/phpbb_database_test_connection_manager.php
@@ -8,6 +8,7 @@
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_install.php';
+require_once dirname(__FILE__) . '/phpbb_database_connection_odbc_pdo_wrapper.php';
class phpbb_database_test_connection_manager
{
@@ -62,6 +63,13 @@ class phpbb_database_test_connection_manager
// e.g. Driver={SQL Server Native Client 10.0};Server=(local)\SQLExpress;
$dsn .= $this->config['dbhost'];
+ // Primarily for MSSQL Native/Azure as ODBC needs it in $dbhost, attached to the Server param
+ if ($this->config['dbport'])
+ {
+ $port_delimiter = (defined('PHP_OS') && substr(PHP_OS, 0, 3) === 'WIN') ? ',' : ':';
+ $dsn .= $port_delimiter . $this->config['dbport'];
+ }
+
if ($use_db)
{
$dsn .= ';Database=' . $this->config['dbname'];
@@ -98,9 +106,34 @@ class phpbb_database_test_connection_manager
break;
}
+ // These require different connection strings on the phpBB side than they do in PDO
+ // so you must provide a DSN string for ODBC separately
+ if (!empty($this->config['custom_dsn']) && ($this->config['dbms'] == 'mssql' || $this->config['dbms'] == 'firebird'))
+ {
+ $dsn = 'odbc:' . $this->config['custom_dsn'];
+ }
+
try
{
- $this->pdo = new PDO($dsn, $this->config['dbuser'], $this->config['dbpasswd']);
+ switch ($this->config['dbms'])
+ {
+ case 'mssql':
+ case 'mssql_odbc':
+ $this->pdo = new phpbb_database_connection_odbc_pdo_wrapper('mssql', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']);
+ break;
+
+ case 'firebird':
+ if (!empty($this->config['custom_dsn']))
+ {
+ $this->pdo = new phpbb_database_connection_odbc_pdo_wrapper('firebird', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']);
+ break;
+ }
+ // Fall through if they're using the firebird PDO driver and not the generic ODBC driver
+
+ default:
+ $this->pdo = new PDO($dsn, $this->config['dbuser'], $this->config['dbpasswd']);
+ break;
+ }
}
catch (PDOException $e)
{
@@ -108,8 +141,7 @@ class phpbb_database_test_connection_manager
throw new Exception("Unable do connect to $cleaned_dsn using PDO with error: {$e->getMessage()}");
}
- // good for debug
- // $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
/**
@@ -140,12 +172,41 @@ class phpbb_database_test_connection_manager
}
break;
+ case 'firebird':
+ $this->connect();
+ // Drop all of the tables
+ foreach ($this->get_tables() as $table)
+ {
+ $this->pdo->exec('DROP TABLE ' . $table);
+ }
+ $this->purge_extras();
+ break;
+
+ case 'oracle':
+ $this->connect();
+ // Drop all of the tables
+ foreach ($this->get_tables() as $table)
+ {
+ $this->pdo->exec('DROP TABLE ' . $table . ' CASCADE CONSTRAINTS');
+ }
+ $this->purge_extras();
+ break;
+
default:
$this->connect(false);
try
{
$this->pdo->exec('DROP DATABASE ' . $this->config['dbname']);
+
+ try
+ {
+ $this->pdo->exec('CREATE DATABASE ' . $this->config['dbname']);
+ }
+ catch (PDOException $e)
+ {
+ throw new Exception("Unable to re-create database: {$e->getMessage()}");
+ }
}
catch (PDOException $e)
{
@@ -154,9 +215,8 @@ class phpbb_database_test_connection_manager
{
$this->pdo->exec('DROP TABLE ' . $table);
}
+ $this->purge_extras();
}
-
- $this->pdo->exec('CREATE DATABASE ' . $this->config['dbname']);
break;
}
}
@@ -332,4 +392,44 @@ class phpbb_database_test_connection_manager
throw new Exception($message);
}
}
+
+ /**
+ * Removes extra objects from a database. This is for cases where dropping the database fails.
+ */
+ public function purge_extras()
+ {
+ $this->ensure_connected(__METHOD__);
+ $queries = array();
+
+ switch ($this->config['dbms'])
+ {
+ case 'firebird':
+ $sql = 'SELECT RDB$GENERATOR_NAME
+ FROM RDB$GENERATORS
+ WHERE RDB$SYSTEM_FLAG = 0';
+ $result = $this->pdo->query($sql);
+
+ while ($row = $result->fetch(PDO::FETCH_NUM))
+ {
+ $queries[] = 'DROP GENERATOR ' . current($row);
+ }
+ break;
+
+ case 'oracle':
+ $sql = 'SELECT sequence_name
+ FROM USER_SEQUENCES';
+ $result = $this->pdo->query($sql);
+
+ while ($row = $result->fetch(PDO::FETCH_NUM))
+ {
+ $queries[] = 'DROP SEQUENCE ' . current($row);
+ }
+ break;
+ }
+
+ foreach ($queries as $query)
+ {
+ $this->pdo->exec($query);
+ }
+ }
}
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 76650feb02..d002615e8c 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -34,16 +34,6 @@ class phpbb_functional_test_case extends phpbb_test_case
static protected $config = array();
static protected $already_installed = false;
- static public function setUpBeforeClass()
- {
- if (!extension_loaded('phar'))
- {
- self::markTestSkipped('phar extension is not loaded');
- }
-
- require_once 'phar://' . __DIR__ . '/../../vendor/goutte.phar';
- }
-
public function setUp()
{
if (!isset(self::$config['phpbb_functional_url']))
@@ -52,7 +42,10 @@ class phpbb_functional_test_case extends phpbb_test_case
}
$this->cookieJar = new CookieJar;
- $this->client = new Goutte\Client(array(), array(), null, $this->cookieJar);
+ $this->client = new Goutte\Client(array(), null, $this->cookieJar);
+ // Reset the curl handle because it is 0 at this point and not a valid
+ // resource
+ $this->client->getClient()->getCurlMulti()->reset(true);
$this->root_url = self::$config['phpbb_functional_url'];
// Clear the language array so that things
// that were added in other tests are gone
@@ -132,6 +125,7 @@ class phpbb_functional_test_case extends phpbb_test_case
{
$this->extension_manager = new phpbb_extension_manager(
$this->get_db(),
+ new phpbb_config(),
self::$config['table_prefix'] . 'ext',
$phpbb_root_path,
".$phpEx",
@@ -204,13 +198,11 @@ class phpbb_functional_test_case extends phpbb_test_case
$this->do_request('create_table', $data);
- file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], array(), true));
-
$this->do_request('config_file', $data);
-
- copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx");
+ file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], array(), true, true));
$this->do_request('final', $data);
+ copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx");
}
private function do_request($sub, $post_data = null)
@@ -251,15 +243,57 @@ class phpbb_functional_test_case extends phpbb_test_case
$cookies = $this->cookieJar->all();
// The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie
- foreach ($cookies as $key => $cookie);
+ foreach ($cookies as $cookie);
{
- if (substr($key, -4) == '_sid')
+ if (substr($cookie->getName(), -4) == '_sid')
{
$this->sid = $cookie->getValue();
}
}
}
+ /**
+ * Login to the ACP
+ * You must run login() before calling this.
+ */
+ protected function admin_login()
+ {
+ $this->add_lang('acp/common');
+
+ // Requires login first!
+ if (empty($this->sid))
+ {
+ $this->fail('$this->sid is empty. Make sure you call login() before admin_login()');
+ return;
+ }
+
+ $crawler = $this->request('GET', 'adm/index.php?sid=' . $this->sid);
+ $this->assertContains($this->lang('LOGIN_ADMIN_CONFIRM'), $crawler->filter('html')->text());
+
+ $form = $crawler->selectButton($this->lang('LOGIN'))->form();
+
+ foreach ($form->getValues() as $field => $value)
+ {
+ if (strpos($field, 'password_') === 0)
+ {
+ $login = $this->client->submit($form, array('username' => 'admin', $field => 'admin'));
+
+ $cookies = $this->cookieJar->all();
+
+ // The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie
+ foreach ($cookies as $cookie);
+ {
+ if (substr($cookie->getName(), -4) == '_sid')
+ {
+ $this->sid = $cookie->getValue();
+ }
+ }
+
+ break;
+ }
+ }
+ }
+
protected function add_lang($lang_file)
{
if (is_array($lang_file))
@@ -296,4 +330,16 @@ class phpbb_functional_test_case extends phpbb_test_case
return call_user_func_array('sprintf', $args);
}
+
+ /**
+ * assertContains for language strings
+ *
+ * @param string $needle Search string
+ * @param string $haystack Search this
+ * @param string $message Optional failure message
+ */
+ public function assertContainsLang($needle, $haystack, $message = null)
+ {
+ $this->assertContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message);
+ }
}
diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php
index 329af2c537..d10645a732 100644
--- a/tests/test_framework/phpbb_test_case_helpers.php
+++ b/tests/test_framework/phpbb_test_case_helpers.php
@@ -84,6 +84,7 @@ class phpbb_test_case_helpers
'dbname' => $dbname,
'dbuser' => $dbuser,
'dbpasswd' => $dbpasswd,
+ 'custom_dsn' => isset($custom_dsn) ? $custom_dsn : '',
));
if (isset($phpbb_functional_url))
@@ -100,7 +101,8 @@ class phpbb_test_case_helpers
'dbport' => isset($_SERVER['PHPBB_TEST_DBPORT']) ? $_SERVER['PHPBB_TEST_DBPORT'] : '',
'dbname' => isset($_SERVER['PHPBB_TEST_DBNAME']) ? $_SERVER['PHPBB_TEST_DBNAME'] : '',
'dbuser' => isset($_SERVER['PHPBB_TEST_DBUSER']) ? $_SERVER['PHPBB_TEST_DBUSER'] : '',
- 'dbpasswd' => isset($_SERVER['PHPBB_TEST_DBPASSWD']) ? $_SERVER['PHPBB_TEST_DBPASSWD'] : ''
+ 'dbpasswd' => isset($_SERVER['PHPBB_TEST_DBPASSWD']) ? $_SERVER['PHPBB_TEST_DBPASSWD'] : '',
+ 'custom_dsn' => isset($_SERVER['PHPBB_TEST_CUSTOM_DSN']) ? $_SERVER['PHPBB_TEST_CUSTOM_DSN'] : '',
));
}
@@ -113,4 +115,112 @@ class phpbb_test_case_helpers
return $config;
}
+
+ /**
+ * Recursive directory copying function
+ *
+ * @param string $source
+ * @param string $dest
+ * @return array list of files copied
+ */
+ public function copy_dir($source, $dest)
+ {
+ $source = (substr($source, -1) == '/') ? $source : $source . '/';
+ $dest = (substr($dest, -1) == '/') ? $dest : $dest . '/';
+
+ $copied_files = array();
+
+ if (!is_dir($dest))
+ {
+ $this->makedirs($dest);
+ }
+
+ $files = scandir($source);
+ foreach ($files as $file)
+ {
+ if ($file == '.' || $file == '..')
+ {
+ continue;
+ }
+
+ if (is_dir($source . $file))
+ {
+ $created_dir = false;
+ if (!is_dir($dest . $file))
+ {
+ $created_dir = true;
+ $this->makedirs($dest . $file);
+ }
+
+ $copied_files = array_merge($copied_files, self::copy_dir($source . $file, $dest . $file));
+
+ if ($created_dir)
+ {
+ $copied_files[] = $dest . $file;
+ }
+ }
+ else
+ {
+ if (!file_exists($dest . $file))
+ {
+ copy($source . $file, $dest . $file);
+
+ $copied_files[] = $dest . $file;
+ }
+ }
+ }
+
+ return $copied_files;
+ }
+
+ /**
+ * Remove files/directories that are listed in an array
+ * Designed for use with $this->copy_dir()
+ *
+ * @param array $file_list
+ */
+ public function remove_files($file_list)
+ {
+ foreach ($file_list as $file)
+ {
+ if (is_dir($file))
+ {
+ rmdir($file);
+ }
+ else
+ {
+ unlink($file);
+ }
+ }
+ }
+
+ /**
+ * Empty directory (remove any subdirectories/files below)
+ *
+ * @param array $file_list
+ */
+ public function empty_dir($path)
+ {
+ $path = (substr($path, -1) == '/') ? $path : $path . '/';
+
+ $files = scandir($path);
+ foreach ($files as $file)
+ {
+ if ($file == '.' || $file == '..')
+ {
+ continue;
+ }
+
+ if (is_dir($path . $file))
+ {
+ $this->empty_dir($path . $file);
+
+ rmdir($path . $file);
+ }
+ else
+ {
+ unlink($path . $file);
+ }
+ }
+ }
}
diff --git a/vendor/goutte.phar b/vendor/goutte.phar
deleted file mode 100644
index 20b7166a67..0000000000
--- a/vendor/goutte.phar
+++ /dev/null
Binary files differ