aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.travis.yml1
-rw-r--r--README.md4
-rw-r--r--build/build.xml4
-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/admin.css10
-rw-r--r--phpBB/adm/style/install_footer.html2
-rw-r--r--phpBB/common.php81
-rw-r--r--phpBB/composer.json5
-rw-r--r--phpBB/composer.lock42
-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/search_fill.php2
-rw-r--r--phpBB/docs/AUTHORS15
-rw-r--r--phpBB/download/file.php391
-rw-r--r--phpBB/includes/acp/acp_board.php2
-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_language.php27
-rw-r--r--phpBB/includes/acp/acp_users.php53
-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/memory.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/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.php21
-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/db/mssqlnative.php1
-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.php21
-rw-r--r--phpBB/includes/extension/exception.php27
-rw-r--r--phpBB/includes/extension/manager.php18
-rw-r--r--phpBB/includes/extension/metadata_manager.php338
-rw-r--r--phpBB/includes/functions.php163
-rw-r--r--phpBB/includes/functions_acp.php86
-rw-r--r--phpBB/includes/functions_admin.php4
-rw-r--r--phpBB/includes/functions_compress.php4
-rw-r--r--phpBB/includes/functions_content.php120
-rw-r--r--phpBB/includes/functions_display.php150
-rw-r--r--phpBB/includes/functions_download.php129
-rw-r--r--phpBB/includes/functions_install.php11
-rw-r--r--phpBB/includes/functions_jabber.php8
-rw-r--r--phpBB/includes/functions_posting.php16
-rw-r--r--phpBB/includes/functions_user.php94
-rw-r--r--phpBB/includes/mcp/mcp_forum.php13
-rw-r--r--phpBB/includes/mcp/mcp_front.php2
-rw-r--r--phpBB/includes/mcp/mcp_main.php2
-rw-r--r--phpBB/includes/mcp/mcp_post.php4
-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_sphinx.php2
-rw-r--r--phpBB/includes/template/filter.php2
-rw-r--r--phpBB/includes/ucp/ucp_pm_viewmessage.php32
-rw-r--r--phpBB/includes/ucp/ucp_profile.php6
-rw-r--r--phpBB/includes/ucp/ucp_register.php4
-rw-r--r--phpBB/includes/ucp/ucp_zebra.php30
-rw-r--r--phpBB/includes/user.php36
-rw-r--r--phpBB/index.php14
-rw-r--r--phpBB/install/convertors/convert_phpbb20.php2
-rw-r--r--phpBB/install/database_update.php62
-rw-r--r--phpBB/install/index.php33
-rw-r--r--phpBB/install/install_convert.php4
-rw-r--r--phpBB/install/install_install.php10
-rw-r--r--phpBB/install/install_update.php18
-rw-r--r--phpBB/install/schemas/schema_data.sql3
-rw-r--r--phpBB/language/en/acp/board.php8
-rw-r--r--phpBB/language/en/acp/common.php1
-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/common.php2
-rw-r--r--phpBB/language/en/search.php4
-rw-r--r--phpBB/language/en/ucp.php2
-rw-r--r--phpBB/memberlist.php37
-rw-r--r--phpBB/posting.php45
-rw-r--r--phpBB/styles/prosilver/template/mcp_topic.html4
-rw-r--r--phpBB/styles/prosilver/template/overall_footer.html4
-rw-r--r--phpBB/styles/prosilver/template/overall_header.html4
-rw-r--r--phpBB/styles/prosilver/template/ucp_pm_viewmessage.html24
-rw-r--r--phpBB/styles/prosilver/template/ucp_pm_viewmessage_print.html2
-rw-r--r--phpBB/styles/prosilver/template/viewtopic_body.html25
-rw-r--r--phpBB/styles/prosilver/template/viewtopic_print.html2
-rw-r--r--phpBB/styles/prosilver/theme/content.css23
-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/overall_header.html4
-rw-r--r--phpBB/styles/subsilver2/template/simple_footer.html2
-rw-r--r--phpBB/styles/subsilver2/template/ucp_pm_viewmessage_print.html2
-rw-r--r--phpBB/styles/subsilver2/template/viewtopic_print.html2
-rw-r--r--phpBB/styles/subsilver2/theme/stylesheet.css2
-rw-r--r--phpBB/ucp.php12
-rw-r--r--phpBB/viewforum.php27
-rw-r--r--phpBB/viewonline.php42
-rw-r--r--phpBB/viewtopic.php97
-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/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/posting_test.php102
-rw-r--r--tests/functions_acp/build_cfg_template_test.php15
-rw-r--r--tests/mock/event_dispatcher.php16
-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_functional_test_case.php57
-rw-r--r--tests/test_framework/phpbb_test_case_helpers.php108
143 files changed, 4930 insertions, 663 deletions
diff --git a/.travis.yml b/.travis.yml
index 0ddd98b5d8..f296f10230 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,6 +12,7 @@ before_script:
- 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
diff --git a/README.md b/README.md
index 1fc670422f..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,7 +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
- php ../composer.phar install
+ php ../composer.phar install --dev
## CONTRIBUTE
diff --git a/build/build.xml b/build/build.xml
index 4a3799d143..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-RC2" />
+ <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, 3.0.11-RC1" />
+ <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/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/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/common.php b/phpBB/common.php
index 5882bbf9fb..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,61 +76,61 @@ 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);
@@ -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 5340fb85f2..5e88144bc4 100644
--- a/phpBB/composer.json
+++ b/phpBB/composer.json
@@ -1,7 +1,10 @@
{
"minimum-stability": "beta",
"require": {
- "symfony/event-dispatcher": "2.1.*"
+ "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 99e19554ab..6b0d3584d1 100644
--- a/phpBB/composer.lock
+++ b/phpBB/composer.lock
@@ -1,9 +1,21 @@
{
- "hash": "b2daff7465c71d924e915e72454ac266",
+ "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.1.0-BETA3"
+ "version": "v2.1.0-RC1"
+ },
+ {
+ "package": "symfony/yaml",
+ "version": "v2.1.0-RC1"
}
],
"packages-dev": [
@@ -16,32 +28,40 @@
{
"package": "fabpot/goutte",
"version": "dev-master",
- "source-reference": "c2ea8d9a6682d14482e57ede2371001b8a5238d2",
- "commit-date": "1340264258"
+ "source-reference": "6d26279344736f6983a969e46afef082ebf30a67",
+ "commit-date": "1345141401"
+ },
+ {
+ "package": "guzzle/common",
+ "version": "v2.8.4"
+ },
+ {
+ "package": "guzzle/http",
+ "version": "v2.8.4"
},
{
- "package": "guzzle/guzzle",
- "version": "v2.6.6"
+ "package": "guzzle/parser",
+ "version": "v2.8.4"
},
{
"package": "symfony/browser-kit",
- "version": "v2.1.0-BETA3"
+ "version": "v2.1.0-RC1"
},
{
"package": "symfony/css-selector",
- "version": "v2.1.0-BETA3"
+ "version": "v2.1.0-RC1"
},
{
"package": "symfony/dom-crawler",
- "version": "v2.1.0-BETA3"
+ "version": "v2.1.0-RC1"
},
{
"package": "symfony/finder",
- "version": "v2.1.0-BETA3"
+ "version": "v2.1.0-RC1"
},
{
"package": "symfony/process",
- "version": "v2.1.0-BETA3"
+ "version": "v2.1.0-RC1"
}
],
"aliases": [
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/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 85653f04e2..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 --
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/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php
index 575d05933f..322e1c55d8 100644
--- a/phpBB/includes/acp/acp_board.php
+++ b/phpBB/includes/acp/acp_board.php
@@ -53,6 +53,8 @@ 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),
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_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_users.php b/phpBB/includes/acp/acp_users.php
index 62968a17b7..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 = '';
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/memory.php b/phpBB/includes/cache/driver/memory.php
index 92971c6cb2..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;
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/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 f6cf77d01d..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();
}
/**
@@ -57,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/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php
index 36ff461a29..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,
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 2b8c50aafb..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 $php_ext;
/**
- * @var string Relative path to board root
+ * Relative path to board root
+ * @var string
*/
protected $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/manager.php b/phpBB/includes/extension/manager.php
index 86d8fab64b..9a518c215f 100644
--- a/phpBB/includes/extension/manager.php
+++ b/phpBB/includes/extension/manager.php
@@ -22,6 +22,8 @@ if (!defined('IN_PHPBB'))
*/
class phpbb_extension_manager
{
+ protected $db;
+ protected $config;
protected $cache;
protected $php_ext;
protected $extensions;
@@ -33,16 +35,18 @@ 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 $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, $php_ext = '.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->php_ext = $php_ext;
$this->extension_table = $extension_table;
@@ -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
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 e5b721b1f5..0c9421c12f 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -2085,7 +2085,7 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam
$on_page = floor($start_item / $per_page) + 1;
$url_delim = (strpos($base_url, '?') === false) ? '?' : ((strpos($base_url, '?') === strlen($base_url) - 1) ? '' : '&amp;');
-
+
if ($reverse_count)
{
$start_page = ($total_pages > 5) ? $total_pages - 4 : 1;
@@ -2094,9 +2094,9 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam
else
{
// 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.
+ // 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
@@ -2115,18 +2115,18 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam
if ($on_page != $total_pages)
{
$template->assign_block_vars($block_var_name, array(
- 'PAGE_NUMBER' => '',
+ '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,
+ 'S_IS_CURRENT' => false,
+ 'S_IS_PREV' => false,
+ 'S_IS_NEXT' => true,
+ 'S_IS_ELLIPSIS' => false,
));
- }
+ }
// 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).
+ // 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
{
@@ -2137,17 +2137,17 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam
// 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_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),
+ '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
+ // 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
+ // 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
@@ -2169,18 +2169,18 @@ function phpbb_generate_template_pagination($template, $base_url, $block_var_nam
if ($on_page != 1)
{
$template->assign_block_vars($block_var_name, array(
- 'PAGE_NUMBER' => '',
+ '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,
+ 'S_IS_CURRENT' => false,
+ 'S_IS_PREV' => true,
+ 'S_IS_NEXT' => false,
+ 'S_IS_ELLIPSIS' => false,
));
}
}
/**
-* Return current page
+* Return current page
* This function also sets certain specific template variables
*
* @param object $template the template object
@@ -2200,9 +2200,9 @@ function phpbb_on_page($template, $user, $base_url, $num_items, $per_page, $star
$template->assign_vars(array(
'PER_PAGE' => $per_page,
- 'ON_PAGE' => $on_page,
-
- 'A_BASE_URL' => addslashes($base_url),
+ '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));
@@ -2231,6 +2231,7 @@ function phpbb_on_page($template, $user, $base_url, $num_items, $per_page, $star
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)))
{
@@ -2238,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))
@@ -2821,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);
@@ -3010,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);
@@ -3343,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']);
@@ -4113,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>';
@@ -4753,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'])
{
@@ -4935,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'),
@@ -4946,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),
@@ -5033,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');
@@ -5058,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'))
@@ -5092,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) : '')
);
@@ -5143,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 5d19cd7adb..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)
{
diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php
index 8e07e6d1b8..4675394633 100644
--- a/phpBB/includes/functions_compress.php
+++ b/phpBB/includes/functions_compress.php
@@ -159,8 +159,10 @@ class compress
/**
* 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');
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_display.php b/phpBB/includes/functions_display.php
index a1ff7a1f99..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);
@@ -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)
{
@@ -830,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;
@@ -850,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');
}
/**
@@ -1248,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))
{
@@ -1285,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 46541acd44..10ec13669b 100644
--- a/phpBB/includes/functions_install.php
+++ b/phpBB/includes/functions_install.php
@@ -522,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);
@@ -540,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,
);
@@ -562,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 6c21b0f412..c50395a5df 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);
@@ -123,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(
@@ -2370,7 +2382,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)
{
diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php
index 6e658b4ef4..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']))
{
@@ -244,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);
@@ -331,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 *
@@ -346,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
@@ -535,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)
{
@@ -2759,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)
{
@@ -2818,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'))
{
@@ -2940,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'])
{
@@ -3039,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);
@@ -3356,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))
{
@@ -3452,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 4518e7b7cf..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'));
@@ -288,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_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_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/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_sphinx.php b/phpBB/includes/search/fulltext_sphinx.php
index a6cc47b836..0a230f0e98 100644
--- a/phpBB/includes/search/fulltext_sphinx.php
+++ b/phpBB/includes/search/fulltext_sphinx.php
@@ -530,7 +530,7 @@ class phpbb_search_fulltext_sphinx
}
else
{
- trigger_error($this->user->lang('SPHINX_SEARCH_FAILED', $this->user->lang('SPHINX_SEARCH_ERROR_LOG')));
+ trigger_error($this->user->lang('SPHINX_SEARCH_FAILED_LOG'));
}
}
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/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_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 6ce53a79ab..c57aec00a0 100644
--- a/phpBB/includes/ucp/ucp_register.php
+++ b/phpBB/includes/ucp/ucp_register.php
@@ -170,8 +170,8 @@ class ucp_register
$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', $timezone),
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/user.php b/phpBB/includes/user.php
index fcbfaaddfa..93557f3558 100644
--- a/phpBB/includes/user.php
+++ b/phpBB/includes/user.php
@@ -76,18 +76,18 @@ 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'];
+ $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'];
+ $user_lang_name = basename($config['default_lang']);
+ $user_date_format = $config['default_dateformat'];
$user_timezone = $config['board_timezone'];
/**
@@ -107,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
@@ -118,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;
}
}
@@ -127,6 +127,28 @@ 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);
diff --git a/phpBB/index.php b/phpBB/index.php
index c13f3c06ab..0ac8034d7f 100644
--- a/phpBB/index.php
+++ b/phpBB/index.php
@@ -171,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 1408db27be..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);
@@ -1079,6 +1099,8 @@ function database_update_info()
),
),
),
+ // 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 */
@@ -2222,6 +2244,10 @@ function change_database_data(&$no_updates, $version)
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':
@@ -2659,6 +2685,12 @@ function change_database_data(&$no_updates, $version)
// 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 ca3994d129..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)
{
diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php
index 40dee7b3d7..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);
diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php
index 88b00f1cf1..8c044550f3 100644
--- a/phpBB/install/install_update.php
+++ b/phpBB/install/install_update.php
@@ -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/schema_data.sql b/phpBB/install/schemas/schema_data.sql
index ea7864bd4c..dbb5fd7481 100644
--- a/phpBB/install/schemas/schema_data.sql
+++ b/phpBB/install/schemas/schema_data.sql
@@ -242,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');
@@ -345,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/language/en/acp/board.php b/phpBB/language/en/acp/board.php
index 0754884473..a4380486cc 100644
--- a/phpBB/language/en/acp/board.php
+++ b/phpBB/language/en/acp/board.php
@@ -45,15 +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_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 04df897dba..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',
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/common.php b/phpBB/language/en/common.php
index 33d39c3e99..e6022e3b79 100644
--- a/phpBB/language/en/common.php
+++ b/phpBB/language/en/common.php
@@ -161,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(
diff --git a/phpBB/language/en/search.php b/phpBB/language/en/search.php
index 5eea6044bc..71cbec4b41 100644
--- a/phpBB/language/en/search.php
+++ b/phpBB/language/en/search.php
@@ -105,8 +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_ERROR_LOG' => 'The error information has been logged.',
+ '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 512a4a5c24..648de587aa 100644
--- a/phpBB/language/en/ucp.php
+++ b/phpBB/language/en/ucp.php
@@ -269,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',
diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php
index 4f9a8cdff3..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
@@ -1631,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'];
@@ -1693,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']),
@@ -1741,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 a17578e343..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))
{
@@ -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/styles/prosilver/template/mcp_topic.html b/phpBB/styles/prosilver/template/mcp_topic.html
index a6938ee2fb..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>
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 43ae83767d..0900222d09 100644
--- a/phpBB/styles/prosilver/template/overall_header.html
+++ b/phpBB/styles/prosilver/template/overall_header.html
@@ -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/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 43e7de2e12..a024a170a7 100644
--- a/phpBB/styles/prosilver/template/ucp_pm_viewmessage_print.html
+++ b/phpBB/styles/prosilver/template/ucp_pm_viewmessage_print.html
@@ -42,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/viewtopic_body.html b/phpBB/styles/prosilver/template/viewtopic_body.html
index cfbf0969d9..4534dc5bcc 100644
--- a/phpBB/styles/prosilver/template/viewtopic_body.html
+++ b/phpBB/styles/prosilver/template/viewtopic_body.html
@@ -157,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 -->
@@ -256,6 +268,17 @@
<!-- ENDIF -->
</div>
+ <!-- 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} &bull;
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/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/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/overall_header.html b/phpBB/styles/subsilver2/template/overall_header.html
index f08531c47f..8bedec4c9e 100644
--- a/phpBB/styles/subsilver2/template/overall_header.html
+++ b/phpBB/styles/subsilver2/template/overall_header.html
@@ -79,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)
@@ -139,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/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/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/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 9e258ea778..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/ )
--------------------------------------------------------------
*/
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 f4781a09ff..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" />');
@@ -690,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']),
@@ -742,11 +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 48362a9d67..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'],
diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php
index b6df14d42d..3fde5b5e03 100644
--- a/phpBB/viewtopic.php
+++ b/phpBB/viewtopic.php
@@ -987,6 +987,16 @@ $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);
@@ -1063,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' => '',
@@ -1098,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
@@ -1112,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,
@@ -1150,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'))
@@ -1314,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 !== '')
{
@@ -1493,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']),
@@ -1556,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'],
@@ -1569,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']))
{
@@ -1594,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'];
@@ -1729,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/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/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/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/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/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_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index b953017d0a..d002615e8c 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -125,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",
@@ -198,7 +199,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$this->do_request('create_table', $data);
$this->do_request('config_file', $data);
- file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], array(), true));
+ 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");
@@ -251,6 +252,48 @@ class phpbb_functional_test_case extends phpbb_test_case
}
}
+ /**
+ * 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))
@@ -287,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 46feef550a..d10645a732 100644
--- a/tests/test_framework/phpbb_test_case_helpers.php
+++ b/tests/test_framework/phpbb_test_case_helpers.php
@@ -115,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);
+ }
+ }
+ }
}