diff options
64 files changed, 1117 insertions, 150 deletions
diff --git a/.travis.yml b/.travis.yml index cc2383de57..20c0c6bf4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: php php: - - 5.3.2 + - 5.3.3 + - 5.3 - 5.4 env: diff --git a/build/build.xml b/build/build.xml index 1646c10a08..bc65cd0b38 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.10" /> - <property name="prevversion" value="3.0.9" /> - <property name="olderversions" value="3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.0.7-PL1, 3.0.8, 3.0.10-RC1, 3.0.10-RC2, 3.0.10-RC3" /> + <property name="newversion" value="3.0.11-RC1" /> + <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" /> <!-- no configuration should be needed beyond this point --> <property name="oldversions" value="${olderversions}, ${prevversion}" /> diff --git a/phpBB/adm/style/acp_users_overview.html b/phpBB/adm/style/acp_users_overview.html index 1f10e7f66e..ffdb4d472c 100644 --- a/phpBB/adm/style/acp_users_overview.html +++ b/phpBB/adm/style/acp_users_overview.html @@ -131,19 +131,24 @@ </form> <!-- IF not S_OWN_ACCOUNT --> - <form id="user_delete" method="post" action="{U_ACTION}"> - <fieldset> - <legend>{L_DELETE_USER}</legend> - <dl> - <dt><label for="delete_type">{L_DELETE_USER}:</label><br /><span>{L_DELETE_USER_EXPLAIN}</span></dt> - <dd><select id="delete_type" name="delete_type"><option class="sep" value="">{L_SELECT_OPTION}</option><option value="retain">{L_RETAIN_POSTS}</option><option value="remove">{L_DELETE_POSTS}</option></select></dd> - </dl> - <p class="quick"> - <input class="button1" type="submit" name="update" value="{L_SUBMIT}" /> - <input type="hidden" name="delete" value="1" /> - {S_FORM_TOKEN} - </p> - </fieldset> - </form> + <form id="user_delete" method="post" action="{U_ACTION}"> + <fieldset> + <legend>{L_DELETE_USER}</legend> + <dl> + <dt><label for="delete_type">{L_DELETE_USER}:</label><br /><span>{L_DELETE_USER_EXPLAIN}</span></dt> + <dd> + <!-- IF USER_HAS_POSTS --> + <select id="delete_type" name="delete_type"><option class="sep" value="">{L_SELECT_OPTION}</option><option value="retain">{L_RETAIN_POSTS}</option><option value="remove">{L_DELETE_POSTS}</option></select></dd> + <!-- ELSE --> + {L_USER_NO_POSTS_TO_DELETE}<input type="hidden" id="delete_type" name="delete_type" value="retain" /> + <!-- ENDIF --> + </dl> + <p class="quick"> + <input class="button1" type="submit" name="update" value="{L_SUBMIT}" /> + <input type="hidden" name="delete" value="1" /> + {S_FORM_TOKEN} + </p> + </fieldset> + </form> <!-- ENDIF --> <!-- ENDIF --> diff --git a/phpBB/docs/AUTHORS b/phpBB/docs/AUTHORS index e945af8efa..f0b4e25549 100644 --- a/phpBB/docs/AUTHORS +++ b/phpBB/docs/AUTHORS @@ -23,6 +23,7 @@ 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) igorw (Igor Wiedler) diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index 7655aaa71f..0c56dbb2a3 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -46,6 +46,7 @@ <ol> <li><a href="#changelog">Changelog</a> <ol style="list-style-type: lower-roman;"> + <li><a href="#v3010">Changes since 3.0.10</a></li> <li><a href="#v309">Changes since 3.0.9</a></li> <li><a href="#v308">Changes since 3.0.8</a></li> <li><a href="#v307-PL1">Changes since 3.0.7-PL1</a></li> @@ -84,7 +85,123 @@ <div class="content"> - <a name="v309"></a><h3>1.i. Changes since 3.0.9</h3> + <a name="v3010"></a><h3>1.i. Changes since 3.0.10</h3> + +<h4>Bug</h4> +<ul> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-7432">PHPBB3-7432</a>] - Unclear language for Inactive Users on ACP main page</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-8652">PHPBB3-8652</a>] - Duplicate Emails Sent When Subscribed to Forum and Topic</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-9079">PHPBB3-9079</a>] - Display backtrace on all E_USER_ERROR errors, not only SQL errors (when DEBUG_EXTRA is enabled)</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-9084">PHPBB3-9084</a>] - Unable to display 'option equal to non entered value' if dropdown CPF is not required</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-9089">PHPBB3-9089</a>] - PM message title box not accessible via Tab key</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-9220">PHPBB3-9220</a>] - Blue border width when table in a div</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-9681">PHPBB3-9681</a>] - Password length not in security settings</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-9813">PHPBB3-9813</a>] - fulltext_native.php on innodb loading deadly slow for big indexes</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-9831">PHPBB3-9831</a>] - Cannot change default of Boolean checkbox custom profile field</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10094">PHPBB3-10094</a>] - Clear cache before phpBB installation</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10129">PHPBB3-10129</a>] - Missing apostrophes in ACP user management -> permissions</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10349">PHPBB3-10349</a>] - Unit tests do not remove comments from schemas</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10399">PHPBB3-10399</a>] - Special characters aren't parsed in style component variables</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10401">PHPBB3-10401</a>] - auth_ldap has an incorrect return value in login_ldap()</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10407">PHPBB3-10407</a>] - Incorrect check for empty image file paths during conversion</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10428">PHPBB3-10428</a>] - optionget/optionset functions in session.php and acp_users.php incorrectly check whether $data is at its default value</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10456">PHPBB3-10456</a>] - Subsilver2 does not define $CAPTCHA_TAB_INDEX</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10508">PHPBB3-10508</a>] - Marking forums as read displays misleading language</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10511">PHPBB3-10511</a>] - Grammar defect in permissions language</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10512">PHPBB3-10512</a>] - Test failure when no default timezone is set in php</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10532">PHPBB3-10532</a>] - Out of range $start causes a page with no search results but with pagination</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10538">PHPBB3-10538</a>] - Special character are not correctly parsed for SMTP protocol</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10542">PHPBB3-10542</a>] - Incorrect class="postlink" in styles/subsilver2/template/faq_body.html</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10546">PHPBB3-10546</a>] - Argument missing for adm_back_link() in acp_captcha.php</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10561">PHPBB3-10561</a>] - All users can choose deactivated styles.</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10569">PHPBB3-10569</a>] - template/ucp_main_front.html does not correctly handle active topic with the name "0"</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10580">PHPBB3-10580</a>] - Default tz in registration dropdown not the same as the board default tz</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10589">PHPBB3-10589</a>] - user_birthday does not use table alias in $leap_year_birthdays variable definition</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10605">PHPBB3-10605</a>] - Orpahned privmsgs are left in the prvmsgs table, with no ties in privmsgs_to table</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10606">PHPBB3-10606</a>] - $s_hidden_fields -> incorrect array name (3 files affected)</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10611">PHPBB3-10611</a>] - Add a check for selected tables existence for ACP database backup tool</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10615">PHPBB3-10615</a>] - Static calls in utf normalizer yield E_STRICT spam on php 5.4</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10630">PHPBB3-10630</a>] - Prune Users produced unnecessarily long query; Got a packet bigger than 'max_allowed_packet' bytes</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10633">PHPBB3-10633</a>] - Users are able to get the real filename of attachment</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10639">PHPBB3-10639</a>] - negative value of ranks message</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10658">PHPBB3-10658</a>] - Rank-item is not shown on team-list</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10675">PHPBB3-10675</a>] - Use more descriptive message when disk is out of space</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10684">PHPBB3-10684</a>] - Function user_notification() prevents notifications for users with stale bans</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10689">PHPBB3-10689</a>] - Bug in the popup " Find a member" when select by letter.</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10691">PHPBB3-10691</a>] - Search index creation CLI script incorrectly calculates indexing speed</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10699">PHPBB3-10699</a>] - Long h2 title breaks div.minitabs in MCP</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10708">PHPBB3-10708</a>] - After a conversion, passwords with UTF8 characters do not work when user_pass_convert is set.</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10717">PHPBB3-10717</a>] - memberlist_view.html: including admin defined profile fields doesnt work</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10723">PHPBB3-10723</a>] - Do not use SQLite on PHP 5.4 in Tests on Travis</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10731">PHPBB3-10731</a>] - JS function addquote() works incorrectly in Opera</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10751">PHPBB3-10751</a>] - MS SQL Error when searching Admin Log</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10760">PHPBB3-10760</a>] - In pre-commit git hook, syntax error is thrown, but is not specifically described</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10767">PHPBB3-10767</a>] - Git hooks do not work properly with git GUIs</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10774">PHPBB3-10774</a>] - db_tools::create_unique_index does not use specified index names on MySQL</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10790">PHPBB3-10790</a>] - Strict comparison on user_id for sending pms</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10797">PHPBB3-10797</a>] - Template var for user rank not filled</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10835">PHPBB3-10835</a>] - Misleading message in UCP when no permission to change password</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10846">PHPBB3-10846</a>] - Missing alias for MAX(post_id) in SQL query in acp_main.php</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10849">PHPBB3-10849</a>] - Missing BBCode Help Text in subsilver2</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10858">PHPBB3-10858</a>] - $db->sql_fetchfield returns false with mssqlnative</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10860">PHPBB3-10860</a>] - Side-by-side diff styling javascript bug</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10881">PHPBB3-10881</a>] - Some files use 0xA9 as the copyright symbol which is neither ASCII nor the UTF8 copyright symbol.</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10887">PHPBB3-10887</a>] - Auto increment tests depend on varbinary handling</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10889">PHPBB3-10889</a>] - Default value for c_char_size in database unit tests is an empty string instead of a char(4)</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10890">PHPBB3-10890</a>] - test_sql_fetchrow_returns_false_when_empty() fails on MSSQL and Oracle</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10908">PHPBB3-10908</a>] - No remote avatar size limit results in files limited only by PHP memory limit</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10913">PHPBB3-10913</a>] - Admin is logged out when accessing any url under adm/ without session id</li> +</ul> +<h4>Improvement</h4> +<ul> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-8599">PHPBB3-8599</a>] - Add "Select All" to "Add multiple smilies" screen</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-8636">PHPBB3-8636</a>] - Add resync option to topic_view moderation page</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-9876">PHPBB3-9876</a>] - Names and descriptions for roles "Newly registered User" in "User roles" and "Forum roles" must be different</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-9914">PHPBB3-9914</a>] - Add backup warning to Automatic DB Updater</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-9916">PHPBB3-9916</a>] - License in header not linking to version 2 of GNU GPL</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10093">PHPBB3-10093</a>] - Make commit-msg hook always not fatal</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10162">PHPBB3-10162</a>] - Allow TLDs over 6 characters in email addresses</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10280">PHPBB3-10280</a>] - Change the ACP user activation display</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10308">PHPBB3-10308</a>] - Disable Retain/Delete Posts selection if the user has no posts.</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10453">PHPBB3-10453</a>] - PM viewmessage page is misplacing the online icon</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10492">PHPBB3-10492</a>] - Port functional tests to develop-olympus</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10507">PHPBB3-10507</a>] - Sort installed styles list in admin control panel - styles</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10550">PHPBB3-10550</a>] - Sort not installed styles list in admin control panel - styles</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10563">PHPBB3-10563</a>] - ACP usability improvement: show deactivated styles below active styles in styles list</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10565">PHPBB3-10565</a>] - Performance: Unneeded GROUP BY in update_forum_tracking_info</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10607">PHPBB3-10607</a>] - phpBB Credit Line Hardcoded</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10653">PHPBB3-10653</a>] - Add ability to count table rows to database abstraction layer</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10730">PHPBB3-10730</a>] - Add label tags around "select" text in post splitting UI in MCP</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10764">PHPBB3-10764</a>] - FAQ mentions SourceForge</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10812">PHPBB3-10812</a>] - Installer should not display register globals UI for php 5.4+</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10815">PHPBB3-10815</a>] - Enable Feeds by default</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10819">PHPBB3-10819</a>] - Improve side-by-side diff styling</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10834">PHPBB3-10834</a>] - Backport general development language changes in readme files</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10836">PHPBB3-10836</a>] - Enable Avatars by default</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10891">PHPBB3-10891</a>] - Allow specifying test config file name via environment variable</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10892">PHPBB3-10892</a>] - Cosmetic improvements to RUNNING_TESTS.txt</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10898">PHPBB3-10898</a>] - Do not write ?> into config.php to avoid whitespace output</li> +</ul> +<h4>New Feature</h4> +<ul> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10616">PHPBB3-10616</a>] - Add template inheritance by default</li> +</ul> +<h4>Sub-task</h4> +<ul> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10907">PHPBB3-10907</a>] - Mark (var)binary tests as incomplete on non-MySQL DBMSes</li> +</ul> +<h4>Task</h4> +<ul> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-9896">PHPBB3-9896</a>] - Update links in docs/readme.html</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10434">PHPBB3-10434</a>] - Add a script that allows creating a search index from CLI</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10455">PHPBB3-10455</a>] - Remove NOTE from header files</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10694">PHPBB3-10694</a>] - Update notification in ACP (Olympus) for increase of minimum PHP version to 5.3.2</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10718">PHPBB3-10718</a>] - Add Travis CI</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10788">PHPBB3-10788</a>] - Update docs/AUTHORS for 3.0.11-RC1</li> +<li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10909">PHPBB3-10909</a>] - Update Travis Test Configuration: Travis no longer supports PHP 5.3.2</li> +</ul> + + <a name="v309"></a><h3>1.ii. Changes since 3.0.9</h3> <h4>Bug</h4> <ul> @@ -220,7 +337,7 @@ <li>[<a href="http://tracker.phpbb.com/browse/PHPBB3-10480">PHPBB3-10480</a>] - Automate changelog building</li> </ul> - <a name="v308"></a><h3>1.ii. Changes since 3.0.8</h3> + <a name="v308"></a><h3>1.iii. Changes since 3.0.8</h3> <h4> Bug </h4> @@ -588,7 +705,7 @@ </ul> - <a name="v307-PL1"></a><h3>1.iii. Changes since 3.0.7-PL1</h3> + <a name="v307-PL1"></a><h3>1.iv. Changes since 3.0.7-PL1</h3> <h4> Security </h4> <ul> @@ -1046,13 +1163,13 @@ </ul> - <a name="v307"></a><h3>1.iiv. Changes since 3.0.7</h3> + <a name="v307"></a><h3>1.iv. Changes since 3.0.7</h3> <ul> <li>[Sec] Do not expose forum content of forums with ACL entries but no actual permission in ATOM Feeds. (Bug #58595)</li> </ul> - <a name="v306"></a><h3>1.v. Changes since 3.0.6</h3> + <a name="v306"></a><h3>1.vi. Changes since 3.0.6</h3> <ul> <li>[Fix] Allow ban reason and length to be selected and copied in ACP and subsilver2 MCP. (Bug #51095)</li> @@ -1156,7 +1273,7 @@ </ul> - <a name="v305"></a><h3>1.vi. Changes since 3.0.5</h3> + <a name="v305"></a><h3>1.vii. Changes since 3.0.5</h3> <ul> <li>[Fix] Allow whitespaces in avatar gallery names. (Bug #44955)</li> @@ -1378,7 +1495,7 @@ <li>[Feature] Send anonymous statistical information to phpBB on installation and update (optional).</li> </ul> - <a name="v304"></a><h3>1.vii. Changes since 3.0.4</h3> + <a name="v304"></a><h3>1.viii. Changes since 3.0.4</h3> <ul> <li>[Fix] Delete user entry from ban list table upon user deletion (Bug #40015 - Patch by TerraFrost)</li> @@ -1467,7 +1584,7 @@ <li>[Sec] Only use forum id supplied for posting if global announcement detected. (Reported by nickvergessen)</li> </ul> - <a name="v303"></a><h3>1.viii. Changes since 3.0.3</h3> + <a name="v303"></a><h3>1.ix. Changes since 3.0.3</h3> <ul> <li>[Fix] Allow mixed-case template directories to be inherited (Bug #36725)</li> @@ -1499,7 +1616,7 @@ <li>[Sec] Ask for forum password if post within passworded forum quoted in private message. (Reported by nickvergessen)</li> </ul> - <a name="v302"></a><h3>1.ix. Changes since 3.0.2</h3> + <a name="v302"></a><h3>1.x. Changes since 3.0.2</h3> <ul> <li>[Fix] Correctly set topic starter if first post in topic removed (Bug #30575 - Patch by blueray2048)</li> @@ -1598,7 +1715,7 @@ <li>[Sec Precaution] Stricter validation of the HTTP_HOST header (Thanks to Techie-Micheal et al for pointing out possible issues in derived code)</li> </ul> - <a name="v301"></a><h3>1.x. Changes since 3.0.1</h3> + <a name="v301"></a><h3>1.xi. Changes since 3.0.1</h3> <ul> <li>[Fix] Ability to set permissions on non-mysql dbms (Bug #24955)</li> @@ -1646,7 +1763,7 @@ <li>[Sec] Only allow urls gone through redirect() being used within login_box(). (thanks nookieman)</li> </ul> - <a name="v300"></a><h3>1.xi Changes since 3.0.0</h3> + <a name="v300"></a><h3>1.xii Changes since 3.0.0</h3> <ul> <li>[Change] Validate birthdays (Bug #15004)</li> @@ -1717,7 +1834,7 @@ <li>[Fix] Find and display colliding usernames correctly when converting from one database to another (Bug #23925)</li> </ul> - <a name="v30rc8"></a><h3>1.xii. Changes since 3.0.RC8</h3> + <a name="v30rc8"></a><h3>1.xiii. Changes since 3.0.RC8</h3> <ul> <li>[Fix] Cleaned usernames contain only single spaces, so "a_name" and "a__name" are treated as the same name (Bug #15634)</li> @@ -1726,7 +1843,7 @@ <li>[Fix] Call garbage_collection() within database updater to correctly close connections (affects Oracle for example)</li> </ul> - <a name="v30rc7"></a><h3>1.xiii. Changes since 3.0.RC7</h3> + <a name="v30rc7"></a><h3>1.xiv. Changes since 3.0.RC7</h3> <ul> <li>[Fix] Fixed MSSQL related bug in the update system</li> @@ -1761,7 +1878,7 @@ <li>[Fix] No duplication of active topics (Bug #15474)</li> </ul> - <a name="v30rc6"></a><h3>1.xiv. Changes since 3.0.RC6</h3> + <a name="v30rc6"></a><h3>1.xv. Changes since 3.0.RC6</h3> <ul> <li>[Fix] Submitting language changes using acp_language (Bug #14736)</li> @@ -1771,7 +1888,7 @@ <li>[Fix] Able to request new password (Bug #14743)</li> </ul> - <a name="v30rc5"></a><h3>1.xv. Changes since 3.0.RC5</h3> + <a name="v30rc5"></a><h3>1.xvi. Changes since 3.0.RC5</h3> <ul> <li>[Feature] Removing constant PHPBB_EMBEDDED in favor of using an exit_handler(); the constant was meant to achive this more or less.</li> @@ -1834,7 +1951,7 @@ <li>[Sec] New password hashing mechanism for storing passwords (#i42)</li> </ul> - <a name="v30rc4"></a><h3>1.xvi. Changes since 3.0.RC4</h3> + <a name="v30rc4"></a><h3>1.xvii. Changes since 3.0.RC4</h3> <ul> <li>[Fix] MySQL, PostgreSQL and SQLite related database fixes (Bug #13862)</li> @@ -1885,7 +2002,7 @@ <li>[Fix] odbc_autocommit causing existing result sets to be dropped (Bug #14182)</li> </ul> - <a name="v30rc3"></a><h3>1.xvii. Changes since 3.0.RC3</h3> + <a name="v30rc3"></a><h3>1.xviii. Changes since 3.0.RC3</h3> <ul> <li>[Fix] Fixing some subsilver2 and prosilver style issues</li> @@ -1994,7 +2111,7 @@ </ul> - <a name="v30rc2"></a><h3>1.xviii. Changes since 3.0.RC2</h3> + <a name="v30rc2"></a><h3>1.xviv. Changes since 3.0.RC2</h3> <ul> <li>[Fix] Re-allow searching within the memberlist</li> @@ -2040,7 +2157,7 @@ </ul> - <a name="v30rc1"></a><h3>1.xix. Changes since 3.0.RC1</h3> + <a name="v30rc1"></a><h3>1.xx. Changes since 3.0.RC1</h3> <ul> <li>[Fix] (X)HTML issues within the templates (Bug #11255, #11255)</li> diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html index 3f2c142ac6..ae4655e094 100644 --- a/phpBB/docs/coding-guidelines.html +++ b/phpBB/docs/coding-guidelines.html @@ -295,11 +295,17 @@ PHPBB_QA (Set board to QA-Mode, which means the updater also c <p>We will not be using any form of hungarian notation in our naming conventions. Many of us believe that hungarian naming is one of the primary code obfuscation techniques currently in use.</p> <h4>Variable Names:</h4> - <p>Variable names should be in all lowercase, with words separated by an underscore, example:</p> + <p>In PHP, variable names should be in all lowercase, with words separated by an underscore, example:</p> <div class="indent"> <p><code>$current_user</code> is right, but <code>$currentuser</code> and <code> $currentUser</code> are not.</p> </div> + + <p>In JavaScript, variable names should use camel case:</p> + + <div class="indent"> + <p><code>currentUser</code> is right, but <code>currentuser</code> and <code>current_user</code> are not.</p> + </div> <p>Names should be descriptive, but concise. We don't want huge sentences as our variable names, but typing an extra couple of characters is always better than wondering what exactly a certain variable is for. </p> @@ -317,7 +323,7 @@ for ($i = 0; $i < $outer_size; $i++) </pre></div> <h4>Function Names:</h4> - <p>Functions should also be named descriptively. We're not programming in C here, we don't want to write functions called things like "stristr()". Again, all lower-case names with words separated by a single underscore character. Function names should preferably have a verb in them somewhere. Good function names are <code>print_login_status()</code>, <code>get_user_data()</code>, etc. </p> + <p>Functions should also be named descriptively. We're not programming in C here, we don't want to write functions called things like "stristr()". Again, all lower-case names with words separated by a single underscore character in PHP, and camel caps in JavaScript. Function names should preferably have a verb in them somewhere. Good function names are <code>print_login_status()</code>, <code>get_user_data()</code>, etc. Constructor functions in JavaScript should begin with a capital letter.</p> <h4>Function Arguments:</h4> <p>Arguments are subject to the same guidelines as variable names. We don't want a bunch of functions like: <code>do_stuff($a, $b, $c)</code>. In most cases, we'd like to be able to tell how to use a function by just looking at its declaration. </p> @@ -397,7 +403,7 @@ for ($i = 0; $i < size; $i++) </pre></div> <h4>Where to put the braces:</h4> - <p>This one is a bit of a holy war, but we're going to use a style that can be summed up in one sentence: Braces always go on their own line. The closing brace should also always be at the same column as the corresponding opening brace, examples:</p> + <p>In PHP code, braces always go on their own line. The closing brace should also always be at the same column as the corresponding opening brace, examples:</p> <div class="codebox"><pre> if (condition) @@ -427,6 +433,30 @@ function do_stuff() ... } </pre></div> + + <p>In JavaScript code, braces always go on the same line:</p> + + <div class="codebox"><pre> +if (condition) { + while (condition2) { + ... + } +} else { + ... +} + +for (var i = 0; i < size; i++) { + ... +} + +while (condition) { + ... +} + +function do_stuff() { + ... +} + </pre></div> <h4>Use spaces between tokens:</h4> <p>This is another simple, easy step that helps keep code readable without much effort. Whenever you write an assignment, expression, etc.. Always leave <em>one</em> space between the tokens. Basically, write code as if it was English. Put spaces between variable names and operators. Don't put spaces just after an opening bracket or before a closing bracket. Don't put spaces just before a comma or a semicolon. This is best shown with a few examples, examples:</p> @@ -502,7 +532,7 @@ $post_url = "{$phpbb_root_path}posting.$phpEx?mode=$mode&amp;start=$start"; <p>In SQL statements mixing single and double quotes is partly allowed (following the guidelines listed here about SQL formatting), else one should try to only use one method - mostly single quotes.</p> <h4>Commas after every array element:</h4> - <p>If an array is defined with each element on its own line, you still have to modify the previous line to add a comma when appending a new element. PHP allows for trailing (useless) commas in array definitions. These should always be used so each element including the comma can be appended with a single line</p> + <p>If an array is defined with each element on its own line, you still have to modify the previous line to add a comma when appending a new element. PHP allows for trailing (useless) commas in array definitions. These should always be used so each element including the comma can be appended with a single line. In JavaScript, do not use the trailing comma, as it causes browsers to throw errors.</p> <p class="bad">// wrong</p> <div class="codebox"><pre> diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php index e66fd850c6..ebcbd28a87 100644 --- a/phpBB/includes/acp/acp_database.php +++ b/phpBB/includes/acp/acp_database.php @@ -20,6 +20,7 @@ if (!defined('IN_PHPBB')) */ class acp_database { + var $db_tools; var $u_action; function main($id, $mode) @@ -27,6 +28,12 @@ class acp_database global $cache, $db, $user, $auth, $template, $table_prefix; global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx; + if (!class_exists('phpbb_db_tools')) + { + require($phpbb_root_path . 'includes/db/db_tools.' . $phpEx); + } + $this->db_tools = new phpbb_db_tools($db); + $user->add_lang('acp/database'); $this->tpl_name = 'acp_database'; @@ -49,7 +56,7 @@ class acp_database { case 'download': $type = request_var('type', ''); - $table = request_var('table', array('')); + $table = array_intersect($this->db_tools->sql_list_tables(), request_var('table', array(''))); $format = request_var('method', ''); $where = request_var('where', ''); @@ -172,8 +179,7 @@ class acp_database break; default: - include($phpbb_root_path . 'includes/functions_install.' . $phpEx); - $tables = get_tables($db); + $tables = $this->db_tools->sql_list_tables(); asort($tables); foreach ($tables as $table_name) { diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index de1f678e38..943bfe6a6f 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -21,7 +21,7 @@ if (!defined('IN_PHPBB')) class acp_styles { public $u_action; - + protected $u_base_action; protected $s_hidden_fields; protected $mode; diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 44717452e8..17687b05c7 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -1001,6 +1001,13 @@ class acp_users $user_row['posts_in_queue'] = (int) $db->sql_fetchfield('posts_in_queue'); $db->sql_freeresult($result); + $sql = 'SELECT post_id + FROM ' . POSTS_TABLE . ' + WHERE poster_id = '. $user_id; + $result = $db->sql_query_limit($sql, 1); + $user_row['user_has_posts'] = (bool) $db->sql_fetchfield('post_id'); + $db->sql_freeresult($result); + $template->assign_vars(array( 'L_NAME_CHARS_EXPLAIN' => $user->lang($config['allow_name_chars'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_name_chars']), $user->lang('CHARACTERS', (int) $config['max_name_chars'])), 'L_CHANGE_PASSWORD_EXPLAIN' => $user->lang($config['pass_complex'] . '_EXPLAIN', $user->lang('CHARACTERS', (int) $config['min_pass_chars']), $user->lang('CHARACTERS', (int) $config['max_pass_chars'])), @@ -1028,6 +1035,7 @@ class acp_users 'USER_EMAIL' => $user_row['user_email'], 'USER_WARNINGS' => $user_row['user_warnings'], 'USER_POSTS' => $user_row['user_posts'], + 'USER_HAS_POSTS' => $user_row['user_has_posts'], 'USER_INACTIVE_REASON' => $inactive_reason, )); diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index fde917e5b1..444446e9c3 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -130,7 +130,7 @@ class bbcode if (empty($this->template_filename)) { - $this->template_bitfield = new bitfield($user->theme['bbcode_bitfield']); + $this->template_bitfield = new bitfield($user->style['bbcode_bitfield']); $style_resource_locator = new phpbb_style_resource_locator(); $style_path_provider = new phpbb_style_extension_path_provider($phpbb_extension_manager, new phpbb_style_path_provider()); diff --git a/phpBB/includes/cache/service.php b/phpBB/includes/cache/service.php index aa225ade69..37f32aa753 100644 --- a/phpBB/includes/cache/service.php +++ b/phpBB/includes/cache/service.php @@ -321,50 +321,39 @@ class phpbb_cache_service /** * Obtain cfg file data */ - function obtain_cfg_items($theme) + function obtain_cfg_items($style) { global $config, $phpbb_root_path; - $parsed_items = array( - 'theme' => array(), - 'template' => array(), - 'imageset' => array() - ); + $parsed_array = $this->driver->get('_cfg_' . $style['style_path']); - foreach ($parsed_items as $key => $parsed_array) + if ($parsed_array === false) { - $parsed_array = $this->driver->get('_cfg_' . $key . '_' . $theme[$key . '_path']); - - if ($parsed_array === false) - { - $parsed_array = array(); - } + $parsed_array = array(); + } - $reparse = false; - $filename = $phpbb_root_path . 'styles/' . $theme[$key . '_path'] . '/' . $key . '/' . $key . '.cfg'; + $reparse = false; + $filename = $phpbb_root_path . 'styles/' . $style['style_path'] . '/style.cfg'; - if (!file_exists($filename)) - { - continue; - } + if (!file_exists($filename)) + { + continue; + } - if (!isset($parsed_array['filetime']) || (($config['load_tplcompile'] && @filemtime($filename) > $parsed_array['filetime']))) - { - $reparse = true; - } + if (!isset($parsed_array['filetime']) || (($config['load_tplcompile'] && @filemtime($filename) > $parsed_array['filetime']))) + { + $reparse = true; + } - // Re-parse cfg file - if ($reparse) - { - $parsed_array = parse_cfg_file($filename); - $parsed_array['filetime'] = @filemtime($filename); + // Re-parse cfg file + if ($reparse) + { + $parsed_array = parse_cfg_file($filename); + $parsed_array['filetime'] = @filemtime($filename); - $this->driver->put('_cfg_' . $key . '_' . $theme[$key . '_path'], $parsed_array); - } - $parsed_items[$key] = $parsed_array; + $this->driver->put('_cfg_' . $style['style_path'], $parsed_array); } - - return $parsed_items; + return $parsed_array; } /** diff --git a/phpBB/includes/db/dbal.php b/phpBB/includes/db/dbal.php index db469ed969..cf54d455f7 100644 --- a/phpBB/includes/db/dbal.php +++ b/phpBB/includes/db/dbal.php @@ -522,6 +522,18 @@ class dbal } /** + * Run LOWER() on DB column of type text (i.e. neither varchar nor char). + * + * @param string $column_name The column name to use + * + * @return string A SQL statement like "LOWER($column_name)" + */ + function sql_lower_text($column_name) + { + return "LOWER($column_name)"; + } + + /** * Run more than one insert statement. * * @param string $table table name to run the statements on diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php index fd11dbad3c..abeabc389f 100644 --- a/phpBB/includes/db/mssql.php +++ b/phpBB/includes/db/mssql.php @@ -325,6 +325,14 @@ class dbal_mssql extends dbal } /** + * {@inheritDoc} + */ + function sql_lower_text($column_name) + { + return "LOWER(SUBSTRING($column_name, 1, DATALENGTH($column_name)))"; + } + + /** * Build LIKE expression * @access private */ diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php index 7ead00cece..6e24f4e9e8 100644 --- a/phpBB/includes/db/mssql_odbc.php +++ b/phpBB/includes/db/mssql_odbc.php @@ -310,6 +310,14 @@ class dbal_mssql_odbc extends dbal } /** + * {@inheritDoc} + */ + function sql_lower_text($column_name) + { + return "LOWER(SUBSTRING($column_name, 1, DATALENGTH($column_name)))"; + } + + /** * Build LIKE expression * @access private */ diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php index 8aac032135..8a4503f111 100644 --- a/phpBB/includes/db/mssqlnative.php +++ b/phpBB/includes/db/mssqlnative.php @@ -492,6 +492,14 @@ class dbal_mssqlnative extends dbal } /** + * {@inheritDoc} + */ + function sql_lower_text($column_name) + { + return "LOWER(SUBSTRING($column_name, 1, DATALENGTH($column_name)))"; + } + + /** * Build LIKE expression * @access private */ diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 0eb0b9c26f..e40df93194 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -3250,7 +3250,7 @@ function get_preg_expression($mode) case 'email': // Regex written by James Watts and Francisco Jose Martin Moreno // http://fightingforalostcause.net/misc/2006/compare-email-regex.php - return '([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*(?:[\w\!\#$\%\'\*\+\-\/\=\?\^\`{\|\}\~]|&)+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,6})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)'; + return '([\w\!\#$\%\&\'\*\+\-\/\=\?\^\`{\|\}\~]+\.)*(?:[\w\!\#$\%\'\*\+\-\/\=\?\^\`{\|\}\~]|&)+@((((([a-z0-9]{1}[a-z0-9\-]{0,62}[a-z0-9]{1})|[a-z])\.)+[a-z]{2,63})|(\d{1,3}\.){3}\d{1,3}(\:\d{1,5})?)'; break; case 'bbcode_htm': @@ -4772,9 +4772,9 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'T_ASSETS_VERSION' => $config['assets_version'], 'T_ASSETS_PATH' => "{$web_path}assets", - 'T_THEME_PATH' => "{$web_path}styles/" . rawurlencode($user->theme['style_path']) . '/theme', - 'T_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->theme['style_path']) . '/template', - 'T_SUPER_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->theme['style_path']) . '/template', + 'T_THEME_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme', + 'T_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/template', + 'T_SUPER_TEMPLATE_PATH' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/template', 'T_IMAGES_PATH' => "{$web_path}images/", 'T_SMILIES_PATH' => "{$web_path}{$config['smilies_path']}/", 'T_AVATAR_PATH' => "{$web_path}{$config['avatar_path']}/", @@ -4782,16 +4782,15 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'T_ICONS_PATH' => "{$web_path}{$config['icons_path']}/", 'T_RANKS_PATH' => "{$web_path}{$config['ranks_path']}/", 'T_UPLOAD_PATH' => "{$web_path}{$config['upload_path']}/", - 'T_STYLESHEET_LINK' => "{$web_path}styles/" . rawurlencode($user->theme['style_path']) . '/theme/stylesheet.css?assets_version=' . $config['assets_version'], - 'T_STYLESHEET_LANG_LINK' => "{$web_path}styles/" . rawurlencode($user->theme['style_path']) . '/theme/' . $user->lang_name . '/stylesheet.css?assets_version=' . $config['assets_version'], - 'T_STYLESHEET_NAME' => $user->theme['style_name'], + 'T_STYLESHEET_LINK' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/stylesheet.css?assets_version=' . $config['assets_version'], + 'T_STYLESHEET_LANG_LINK' => "{$web_path}styles/" . rawurlencode($user->style['style_path']) . '/theme/' . $user->lang_name . '/stylesheet.css?assets_version=' . $config['assets_version'], 'T_JQUERY_LINK' => ($config['load_jquery_cdn'] && !empty($config['load_jquery_url'])) ? $config['load_jquery_url'] : "{$web_path}assets/javascript/jquery.js?assets_version=" . $config['assets_version'], 'S_JQUERY_FALLBACK' => ($config['load_jquery_cdn']) ? true : false, - 'T_THEME_NAME' => rawurlencode($user->theme['style_path']), + 'T_THEME_NAME' => rawurlencode($user->style['style_path']), 'T_THEME_LANG_NAME' => $user->data['user_lang'], - 'T_TEMPLATE_NAME' => $user->theme['style_path'], - 'T_SUPER_TEMPLATE_NAME' => rawurlencode((isset($user->theme['style_parent_tree']) && $user->theme['style_parent_tree']) ? $user->theme['style_parent_tree'] : $user->theme['style_path']), + 'T_TEMPLATE_NAME' => $user->style['style_path'], + 'T_SUPER_TEMPLATE_NAME' => rawurlencode((isset($user->style['style_parent_tree']) && $user->style['style_parent_tree']) ? $user->style['style_parent_tree'] : $user->style['style_path']), 'T_IMAGES' => 'images', 'T_SMILIES' => $config['smilies_path'], 'T_AVATAR' => $config['avatar_path'], @@ -4987,3 +4986,16 @@ function phpbb_pcre_utf8_support() } return $utf8_pcre_properties; } + +/** +* Casts a numeric string $input to an appropriate numeric type (i.e. integer or float) +* +* @param string $input A numeric string. +* +* @return int|float Integer $input if $input fits integer, +* float $input otherwise. +*/ +function phpbb_to_numeric($input) +{ + return ($input > PHP_INT_MAX) ? (float) $input : (int) $input; +} diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index 9798e514c1..5d19cd7adb 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -2556,7 +2556,8 @@ function view_log($mode, &$log, &$log_count, $limit = 0, $offset = 0, $forum_id { $sql_keywords .= $db->sql_in_set('l.log_operation', $operations) . ' OR '; } - $sql_keywords .= 'LOWER(l.log_data) ' . implode(' OR LOWER(l.log_data) ', $keywords) . ')'; + $sql_lower = $db->sql_lower_text('l.log_data'); + $sql_keywords .= "$sql_lower " . implode(" OR $sql_lower ", $keywords) . ')'; } if ($log_count !== false) diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index 0c5b80c609..1f45d5e8e1 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -403,7 +403,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod } else { - $last_post_subject = $last_post_time = $last_post_url = ''; + $last_post_subject = $last_post_time = $last_post_url = $last_post_subject_truncated = ''; } // Output moderator listing ... if applicable diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 96e27303ee..8542e3ab0a 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1566,12 +1566,6 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true) while ($row = $db->sql_fetchrow($result)) { - // Additionally, do not include the sender if he is in the group he wants to send to. ;) - if ($row['user_id'] === $user->data['user_id']) - { - continue; - } - $field = ($data['address_list']['g'][$row['group_id']] == 'to') ? 'to' : 'bcc'; $recipients[$row['user_id']] = $field; } diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index 71fe627ac8..f70e20e616 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -756,6 +756,31 @@ class fileupload $filename = $url['path']; $filesize = 0; + $remote_max_filesize = $this->max_filesize; + if (!$remote_max_filesize) + { + $max_filesize = @ini_get('upload_max_filesize'); + + if (!empty($max_filesize)) + { + $unit = strtolower(substr($max_filesize, -1, 1)); + $remote_max_filesize = (int) $max_filesize; + + switch ($unit) + { + case 'g': + $remote_max_filesize *= 1024; + // no break + case 'm': + $remote_max_filesize *= 1024; + // no break + case 'k': + $remote_max_filesize *= 1024; + // no break + } + } + } + $errno = 0; $errstr = ''; @@ -784,9 +809,9 @@ class fileupload $block = @fread($fsock, 1024); $filesize += strlen($block); - if ($this->max_filesize && $filesize > $this->max_filesize) + if ($remote_max_filesize && $filesize > $remote_max_filesize) { - $max_filesize = get_formatted_filesize($this->max_filesize, false); + $max_filesize = get_formatted_filesize($remote_max_filesize, false); $file = new fileerror(sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit'])); return $file; @@ -812,9 +837,9 @@ class fileupload { $length = (int) str_replace('content-length: ', '', strtolower($line)); - if ($length && $length > $this->max_filesize) + if ($remote_max_filesize && $length && $length > $remote_max_filesize) { - $max_filesize = get_formatted_filesize($this->max_filesize, false); + $max_filesize = get_formatted_filesize($remote_max_filesize, false); $file = new fileerror(sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit'])); return $file; diff --git a/phpBB/includes/php/ini.php b/phpBB/includes/php/ini.php new file mode 100644 index 0000000000..17e8c54a57 --- /dev/null +++ b/phpBB/includes/php/ini.php @@ -0,0 +1,175 @@ +<?php +/** +* +* @package phpBB +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +/** +* Wrapper class for ini_get function. +* +* Provides easier handling of the different interpretations of ini values. +* +* @package phpBB +*/ +class phpbb_php_ini +{ + /** + * Simple wrapper for ini_get() + * See http://php.net/manual/en/function.ini-get.php + * + * @param string $varname The configuration option name. + * @return bool|string False if configuration option does not exist, + * the configuration option value (string) otherwise. + */ + public function get($varname) + { + return ini_get($varname); + } + + /** + * Gets the configuration option value as a trimmed string. + * + * @param string $varname The configuration option name. + * @return bool|string False if configuration option does not exist, + * the configuration option value (string) otherwise. + */ + public function get_string($varname) + { + $value = $this->get($varname); + + if ($value === false) + { + return false; + } + + return trim($value); + } + + /** + * Gets configuration option value as a boolean. + * Interprets the string value 'off' as false. + * + * @param string $varname The configuration option name. + * @return bool False if configuration option does not exist. + * False if configuration option is disabled. + * True otherwise. + */ + public function get_bool($varname) + { + $value = $this->get_string($varname); + + if (empty($value) || strtolower($value) == 'off') + { + return false; + } + + return true; + } + + /** + * Gets configuration option value as an integer. + * + * @param string $varname The configuration option name. + * @return bool|int False if configuration option does not exist, + * false if configuration option value is not numeric, + * the configuration option value (integer) otherwise. + */ + public function get_int($varname) + { + $value = $this->get_string($varname); + + if (!is_numeric($value)) + { + return false; + } + + return (int) $value; + } + + /** + * Gets configuration option value as a float. + * + * @param string $varname The configuration option name. + * @return bool|float False if configuration option does not exist, + * false if configuration option value is not numeric, + * the configuration option value (float) otherwise. + */ + public function get_float($varname) + { + $value = $this->get_string($varname); + + if (!is_numeric($value)) + { + return false; + } + + return (float) $value; + } + + /** + * Gets configuration option value in bytes. + * Converts strings like '128M' to bytes (integer or float). + * + * @param string $varname The configuration option name. + * @return bool|int|float False if configuration option does not exist, + * false if configuration option value is not well-formed, + * the configuration option value otherwise. + */ + public function get_bytes($varname) + { + $value = $this->get_string($varname); + + if ($value === false) + { + return false; + } + + if (is_numeric($value)) + { + // Already in bytes. + return phpbb_to_numeric($value); + } + else if (strlen($value) < 2) + { + // Single character. + return false; + } + else if (strlen($value) < 3 && $value[0] === '-') + { + // Two characters but the first one is a minus. + return false; + } + + $value_lower = strtolower($value); + $value_numeric = phpbb_to_numeric($value); + + switch ($value_lower[strlen($value_lower) - 1]) + { + case 'g': + $value_numeric *= 1024; + case 'm': + $value_numeric *= 1024; + case 'k': + $value_numeric *= 1024; + break; + + default: + // It's not already in bytes (and thus numeric) + // and does not carry a unit. + return false; + } + + return $value_numeric; + } +} diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index bcdff54457..257ffb07f6 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -342,8 +342,16 @@ class phpbb_session } } - // Is session_id is set or session_id is set and matches the url param if required - if (!empty($this->session_id) && (!defined('NEED_SID') || (isset($_GET['sid']) && $this->session_id === request_var('sid', '')))) + // if no session id is set, redirect to index.php + $session_id = $request->variable('sid', ''); + if (defined('NEED_SID') && (empty($session_id) || $this->session_id !== $session_id)) + { + send_status_line(401, 'Not authorized'); + redirect(append_sid("{$phpbb_root_path}index.$phpEx")); + } + + // if session id is set + if (!empty($this->session_id)) { $sql = 'SELECT u.*, s.* FROM ' . SESSIONS_TABLE . ' s, ' . USERS_TABLE . " u diff --git a/phpBB/includes/style/style.php b/phpBB/includes/style/style.php index 3f470015f6..22e0f1d67a 100644 --- a/phpBB/includes/style/style.php +++ b/phpBB/includes/style/style.php @@ -89,9 +89,9 @@ class phpbb_style */ public function set_style() { - $style_name = $this->user->theme['style_path']; - $style_dirs = ($this->user->theme['style_parent_id']) ? array_reverse(explode('/', $this->user->theme['style_parent_tree'])) : array(); - $paths = array($this->get_style_path($style_name)); + $style_path = $this->user->style['style_path']; + $style_dirs = ($this->user->style['style_parent_id']) ? array_reverse(explode('/', $this->user->style['style_parent_tree'])) : array(); + $paths = array($this->get_style_path($style_path)); foreach ($style_dirs as $dir) { $paths[] = $this->get_style_path($dir); @@ -100,7 +100,7 @@ class phpbb_style // Add 'all' path, used as last fallback path by hooks and extensions $paths[] = $this->get_style_path('all'); - return $this->set_custom_style($style_name, $paths); + return $this->set_custom_style($style_path, $paths); } /** diff --git a/phpBB/includes/template/filter.php b/phpBB/includes/template/filter.php index 4a2593b757..ad2e35de6a 100644 --- a/phpBB/includes/template/filter.php +++ b/phpBB/includes/template/filter.php @@ -905,12 +905,12 @@ class phpbb_template_filter extends php_user_filter if (substr($filename, 0, strlen($this->phpbb_root_path)) != $this->phpbb_root_path) { // Absolute path, include as is - return ' $_template->_js_include(\'' . addslashes($filename) . '\', false); '; + return ' $_template->_js_include(\'' . addslashes($filename) . '\', false, false); '; } // Relative path, remove root path from it $filename = substr($filename, strlen($this->phpbb_root_path)); - return ' global $phpbb_root_path; $_template->_js_include($phpbb_root_path . \'' . addslashes($filename) . '\', false); '; + return ' $_template->_js_include(\'' . addslashes($filename) . '\', false, true); '; } /** diff --git a/phpBB/includes/template/template.php b/phpBB/includes/template/template.php index e6512c8417..8ab3c44be3 100644 --- a/phpBB/includes/template/template.php +++ b/phpBB/includes/template/template.php @@ -496,14 +496,19 @@ class phpbb_template * * @param string $file file name * @param bool $locate True if file needs to be located + * @param bool $relative True if path is relative to phpBB root directory. Ignored if $locate == true */ - public function _js_include($file, $locate = false) + public function _js_include($file, $locate = false, $relative = false) { // Locate file if ($locate) { $file = $this->locator->get_first_file_location(array($file), true, true); } + else if ($relative) + { + $file = $this->phpbb_root_path . $file; + } $file .= (strpos($file, '?') === false) ? '?' : '&'; $file .= 'assets_version=' . $this->config['assets_version']; diff --git a/phpBB/includes/ucp/info/ucp_profile.php b/phpBB/includes/ucp/info/ucp_profile.php index 09c0318de9..968538a178 100644 --- a/phpBB/includes/ucp/info/ucp_profile.php +++ b/phpBB/includes/ucp/info/ucp_profile.php @@ -23,6 +23,7 @@ class ucp_profile_info 'signature' => array('title' => 'UCP_PROFILE_SIGNATURE', 'auth' => '', 'cat' => array('UCP_PROFILE')), 'avatar' => array('title' => 'UCP_PROFILE_AVATAR', 'auth' => 'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)', 'cat' => array('UCP_PROFILE')), 'reg_details' => array('title' => 'UCP_PROFILE_REG_DETAILS', 'auth' => '', 'cat' => array('UCP_PROFILE')), + 'autologin_keys'=> array('title' => 'UCP_PROFILE_AUTOLOGIN_KEYS', 'auth' => '', 'cat' => array('UCP_PROFILE')), ), ); } diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index 9d81503f0a..2ac82fb52f 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -618,6 +618,60 @@ class ucp_profile } break; + + case 'autologin_keys': + + add_form_key('ucp_autologin_keys'); + + if ($submit) + { + $keys = request_var('keys', array('')); + + if (!check_form_key('ucp_autologin_keys')) + { + $error[] = 'FORM_INVALID'; + } + + if (!sizeof($error)) + { + if (!empty($keys)) + { + $sql = 'DELETE FROM ' . SESSIONS_KEYS_TABLE . ' + WHERE user_id = ' . (int) $user->data['user_id'] . ' + AND ' . $db->sql_in_set('key_id', $keys) ; + + $db->sql_query($sql); + + meta_refresh(3, $this->u_action); + $message = $user->lang['AUTOLOGIN_SESSION_KEYS_DELETED'] . '<br /><br />' . sprintf($user->lang['RETURN_UCP'], '<a href="' . $this->u_action . '">', '</a>'); + trigger_error($message); + } + } + + // Replace "error" strings with their real, localised form + $error = array_map(array($user, 'lang'), $error); + } + + $sql = 'SELECT key_id, last_ip, last_login + FROM ' . SESSIONS_KEYS_TABLE . ' + WHERE user_id = ' . (int) $user->data['user_id']; + + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $template->assign_block_vars('sessions', array( + 'errors' => $error, + + 'KEY' => $row['key_id'], + 'IP' => $row['last_ip'], + 'LOGIN_TIME' => $user->format_date($row['last_login']), + )); + } + + $db->sql_freeresult($result); + + break; } $template->assign_vars(array( diff --git a/phpBB/includes/user.php b/phpBB/includes/user.php index ce9c804f23..cf9e6b9994 100644 --- a/phpBB/includes/user.php +++ b/phpBB/includes/user.php @@ -27,7 +27,7 @@ class phpbb_user extends phpbb_session { var $lang = array(); var $help = array(); - var $theme = array(); + var $style = array(); var $date_format; var $timezone; var $dst; @@ -159,11 +159,11 @@ class phpbb_user extends phpbb_session FROM ' . STYLES_TABLE . " s WHERE s.style_id = $style_id"; $result = $db->sql_query($sql, 3600); - $this->theme = $db->sql_fetchrow($result); + $this->style = $db->sql_fetchrow($result); $db->sql_freeresult($result); // User has wrong style - if (!$this->theme && $style_id == $this->data['user_style']) + if (!$this->style && $style_id == $this->data['user_style']) { $style_id = $this->data['user_style'] = $config['default_style']; @@ -176,20 +176,17 @@ class phpbb_user extends phpbb_session FROM ' . STYLES_TABLE . " s WHERE s.style_id = $style_id"; $result = $db->sql_query($sql, 3600); - $this->theme = $db->sql_fetchrow($result); + $this->style = $db->sql_fetchrow($result); $db->sql_freeresult($result); } - if (!$this->theme) + if (!$this->style) { trigger_error('Could not get style data', E_USER_ERROR); } // Now parse the cfg file and cache it - $parsed_items = $cache->obtain_cfg_items($this->theme); - - // We are only interested in the theme configuration for now - $parsed_items = $parsed_items['theme']; + $parsed_items = $cache->obtain_cfg_items($this->style); $check_for = array( 'pagination_sep' => (string) ', ' @@ -197,12 +194,12 @@ class phpbb_user extends phpbb_session foreach ($check_for as $key => $default_value) { - $this->theme[$key] = (isset($parsed_items[$key])) ? $parsed_items[$key] : $default_value; - settype($this->theme[$key], gettype($default_value)); + $this->style[$key] = (isset($parsed_items[$key])) ? $parsed_items[$key] : $default_value; + settype($this->style[$key], gettype($default_value)); if (is_string($default_value)) { - $this->theme[$key] = htmlspecialchars($this->theme[$key]); + $this->style[$key] = htmlspecialchars($this->style[$key]); } } diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index 1892ab07a3..b7490aca0b 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -1027,7 +1027,7 @@ function database_update_info() // this column was removed from the database updater // after 3.0.9-RC3 was released. It might still exist // in 3.0.9-RCX installations and has to be dropped in - // 3.0.11 after the db_tools class is capable of properly + // 3.0.12 after the db_tools class is capable of properly // removing a primary key. // 'attempt_id' => array('UINT', NULL, 'auto_increment'), 'attempt_ip' => array('VCHAR:40', ''), @@ -1072,7 +1072,7 @@ function database_update_info() // No changes from 3.0.10 to 3.0.11-RC1 '3.0.10' => array(), - /** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.11-RC1 */ + /** @todo DROP LOGIN_ATTEMPT_TABLE.attempt_id in 3.0.12-RC1 */ // Changes from 3.1.0-dev to 3.1.0-A1 '3.1.0-dev' => array( @@ -2343,6 +2343,13 @@ function change_database_data(&$no_updates, $version) 'auth' => 'acl_a_styles', 'cat' => 'ACP_STYLE_MANAGEMENT', ), + 'autologin_keys' => array( + 'base' => 'ucp_profile', + 'class' => 'ucp', + 'title' => 'UCP_PROFILE_AUTOLOGIN_KEYS', + 'auth' => '', + 'cat' => 'UCP_PROFILE', + ), ); _add_modules($modules_to_install); diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 2ea5eca768..5489fd4e3d 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -88,6 +88,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('dbms_version', '') INSERT INTO phpbb_config (config_name, config_value) VALUES ('default_dateformat', 'D M d, Y g:i a'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('default_style', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('display_last_edited', '1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('display_last_subject', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('display_order', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('edit_time', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('delete_time', '0'); diff --git a/phpBB/language/en/acp/attachments.php b/phpBB/language/en/acp/attachments.php index e43bd1d3b0..c7d68d29c2 100644 --- a/phpBB/language/en/acp/attachments.php +++ b/phpBB/language/en/acp/attachments.php @@ -56,7 +56,7 @@ $lang = array_merge($lang, array( 'ATTACH_EXT_GROUPS_URL' => 'Extension groups', 'ATTACH_ID' => 'ID', 'ATTACH_MAX_FILESIZE' => 'Maximum file size', - 'ATTACH_MAX_FILESIZE_EXPLAIN' => 'Maximum size of each file, with 0 being unlimited.', + 'ATTACH_MAX_FILESIZE_EXPLAIN' => 'Maximum size of each file. If this value is 0, the uploadable filesize is only limited by your PHP configuration.', 'ATTACH_MAX_PM_FILESIZE' => 'Maximum file size messaging', 'ATTACH_MAX_PM_FILESIZE_EXPLAIN' => 'Maximum size of each file, with 0 being unlimited, attached to a private message.', 'ATTACH_ORPHAN_URL' => 'Orphan attachments', diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 6e5557d9be..384bce75bf 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -109,7 +109,7 @@ $lang = array_merge($lang, array( 'MAX_AVATAR_SIZE' => 'Maximum avatar dimensions', 'MAX_AVATAR_SIZE_EXPLAIN' => 'Width x Height in pixels.', 'MAX_FILESIZE' => 'Maximum avatar file size', - 'MAX_FILESIZE_EXPLAIN' => 'For uploaded avatar files.', + 'MAX_FILESIZE_EXPLAIN' => 'For uploaded avatar files. If this value is 0, the uploaded filesize is only limited by your PHP configuration.', 'MIN_AVATAR_SIZE' => 'Minimum avatar dimensions', 'MIN_AVATAR_SIZE_EXPLAIN' => 'Width x Height in pixels.', )); diff --git a/phpBB/language/en/acp/users.php b/phpBB/language/en/acp/users.php index 4496fdba7c..45cf36469b 100644 --- a/phpBB/language/en/acp/users.php +++ b/phpBB/language/en/acp/users.php @@ -123,6 +123,7 @@ $lang = array_merge($lang, array( 'USER_GROUP_SPECIAL' => 'Pre-defined groups user is a member of', 'USER_LIFTED_NR' => 'Successfully removed the user’s newly registered status.', 'USER_NO_ATTACHMENTS' => 'There are no attached files to display.', + 'USER_NO_POSTS_TO_DELETE' => 'The user has no posts to retain or delete.', 'USER_OUTBOX_EMPTIED' => 'Successfully emptied user’s private message outbox.', 'USER_OUTBOX_EMPTY' => 'The user’s private message outbox was already empty.', 'USER_OVERVIEW_UPDATED' => 'User details updated.', diff --git a/phpBB/language/en/ucp.php b/phpBB/language/en/ucp.php index 87dced4786..2d9cf46213 100644 --- a/phpBB/language/en/ucp.php +++ b/phpBB/language/en/ucp.php @@ -87,6 +87,7 @@ $lang = array_merge($lang, array( 'ATTACHMENTS_EXPLAIN' => 'This is a list of attachments you have made in posts to this board.', 'ATTACHMENTS_DELETED' => 'Attachments successfully deleted.', 'ATTACHMENT_DELETED' => 'Attachment successfully deleted.', + 'AUTOLOGIN_SESSION_KEYS_DELETED'=> 'The selected persistent login keys were successfully deleted.', 'AVATAR_CATEGORY' => 'Category', 'AVATAR_EXPLAIN' => 'Maximum dimensions; width: %1$s, height: %2$s, file size: %3$.2f KiB.', 'AVATAR_FEATURES_DISABLED' => 'The avatar functionality is currently disabled.', @@ -256,6 +257,8 @@ $lang = array_merge($lang, array( 'LINK_REMOTE_SIZE' => 'Avatar dimensions', 'LINK_REMOTE_SIZE_EXPLAIN' => 'Specify the width and height of the avatar, leave blank to attempt automatic verification.', 'LOGIN_EXPLAIN_UCP' => 'Please login in order to access the User Control Panel.', + 'LOGIN_KEY' => 'Login Key', + 'LOGIN_TIME' => 'Login Time', 'LOGIN_REDIRECT' => 'You have been successfully logged in.', 'LOGOUT_FAILED' => 'You were not logged out, as the request did not match your session. Please contact the board administrator if you continue to experience problems.', 'LOGOUT_REDIRECT' => 'You have been successfully logged out.', @@ -377,6 +380,8 @@ $lang = array_merge($lang, array( 'PREFERENCES_UPDATED' => 'Your preferences have been updated.', 'PROFILE_INFO_NOTICE' => 'Please note that this information may be viewable to other members. Be careful when including any personal details. Any fields marked with a * must be completed.', 'PROFILE_UPDATED' => 'Your profile has been updated.', + 'PROFILE_AUTOLOGIN_KEYS' => 'The persistent login keys automatically log you in when you visit the board. If you logout, the persistent login key is deleted only on the computer you are using to logout. Here you can see persistent login keys created on other computers you used to access this site.', + 'PROFILE_NO_AUTOLOGIN_KEYS' => 'There are no saved persistent login keys.', 'RECIPIENT' => 'Recipient', 'RECIPIENTS' => 'Recipients', @@ -466,6 +471,7 @@ $lang = array_merge($lang, array( 'UCP_PROFILE_PROFILE_INFO' => 'Edit profile', 'UCP_PROFILE_REG_DETAILS' => 'Edit account settings', 'UCP_PROFILE_SIGNATURE' => 'Edit signature', + 'UCP_PROFILE_AUTOLOGIN_KEYS'=> 'Edit persistent login keys', 'UCP_USERGROUPS' => 'Usergroups', 'UCP_USERGROUPS_MEMBER' => 'Edit memberships', diff --git a/phpBB/styles/prosilver/template/ucp_profile_autologin_keys.html b/phpBB/styles/prosilver/template/ucp_profile_autologin_keys.html new file mode 100644 index 0000000000..a6c19508e2 --- /dev/null +++ b/phpBB/styles/prosilver/template/ucp_profile_autologin_keys.html @@ -0,0 +1,53 @@ +<!-- INCLUDE ucp_header.html --> + +<form id="ucp" method="post" action="{S_UCP_ACTION}"{S_FORM_ENCTYPE}> + +<h2>{L_TITLE}</h2> +<div class="panel"> + <div class="inner"> + + <fieldset> + <!-- IF .errors --> + <p class="error"> + <!-- BEGIN errors --> + {errors} <br /> + <!-- END errors --> + </p> + <!-- ENDIF --> + + <p>{L_PROFILE_AUTOLOGIN_KEYS}</p><br /> + <table cellspacing="1" class="table1"> + <thead> + <tr> + <th>{L_MARK}</th> + <th>{L_LOGIN_KEY}</th> + <th>{L_IP}</th> + <th>{L_LOGIN_TIME}</th> + </tr> + </thead> + <tbody> + <!-- BEGIN sessions --> + <!-- IF sessions.S_ROW_COUNT is even --><tr class="bg1"><!-- ELSE --><tr class="bg2"><!-- ENDIF --> + <td style="text-align: center"><input type="checkbox" name="keys[]" value="{sessions.KEY}" id="{sessions.KEY}"/></td> + <td><label for="{sessions.KEY}">{sessions.KEY}</label></td> + <td style="text-align: center">{sessions.IP}</td> + <td style="text-align: center">{sessions.LOGIN_TIME}</td> + </tr> + <!-- BEGINELSE --> + <tr><td colspan="4" class="bg1" style="text-align: center">{L_PROFILE_NO_AUTOLOGIN_KEYS}</td></tr> + <!-- END sessions --> + </tbody> + </table> + </fieldset> + </div> +</div> + +<!-- IF .sessions --> + <fieldset class="submit-buttons"> + {S_HIDDEN_FIELDS}<input type="submit" name="submit" value="{L_DELETE}" class="button1" /> + {S_FORM_TOKEN} + </fieldset> +<!-- ENDIF --> +</form> + +<!-- INCLUDE ucp_footer.html --> diff --git a/phpBB/styles/subsilver2/template/forumlist_body.html b/phpBB/styles/subsilver2/template/forumlist_body.html index 334fd7a968..be32d1fb77 100644 --- a/phpBB/styles/subsilver2/template/forumlist_body.html +++ b/phpBB/styles/subsilver2/template/forumlist_body.html @@ -56,6 +56,9 @@ <td class="row2" align="center"><p class="topicdetails">{forumrow.POSTS}</p></td> <td class="row2" align="center" nowrap="nowrap"> <!-- IF forumrow.LAST_POST_TIME --> + <!-- IF forumrow.S_DISPLAY_SUBJECT --> + <p class="topicdetails"><a href="{forumrow.U_LAST_POST}" title="{forumrow.LAST_POST_SUBJECT}">{forumrow.LAST_POST_SUBJECT_TRUNCATED}</a></p> + <!-- ENDIF --> <p class="topicdetails"><!-- IF forumrow.U_UNAPPROVED_TOPICS --><a href="{forumrow.U_UNAPPROVED_TOPICS}" class="imageset">{UNAPPROVED_IMG}</a> <!-- ENDIF -->{forumrow.LAST_POST_TIME}</p> <p class="topicdetails">{forumrow.LAST_POSTER_FULL} <!-- IF not S_IS_BOT --><a href="{forumrow.U_LAST_POST}" class="imageset">{LAST_POST_IMG}</a><!-- ENDIF --> diff --git a/phpBB/styles/subsilver2/template/ucp_profile_autologin_keys.html b/phpBB/styles/subsilver2/template/ucp_profile_autologin_keys.html new file mode 100644 index 0000000000..1dab9acb9c --- /dev/null +++ b/phpBB/styles/subsilver2/template/ucp_profile_autologin_keys.html @@ -0,0 +1,49 @@ +<!-- INCLUDE ucp_header.html --> + +<table class="tablebg" width="100%" cellspacing="1"> +<tr> + <th colspan="4" valign="middle">{L_TITLE}</th> +</tr> +<!-- IF .errors --> + <tr> + <td class="row3" colspan="2" align="center"><span class="gensmall error"> + <!-- BEGIN errors --> + {errors} <br /> + <!-- END errors --> + </td> + </tr> +<!-- ENDIF --> + +<tr> + <td colspan="4" class="row1">{L_PROFILE_AUTOLOGIN_KEYS}</td> +</tr> +<tr> + <th>{L_MARK}</th> + <th>{L_LOGIN_KEY}</th> + <th>{L_IP}</th> + <th>{L_LOGIN_TIME}</th> +</tr> +<!-- BEGIN sessions --> + <!-- IF sessions.S_ROW_COUNT is even --><tr class="row1"><!-- ELSE --><tr class="row2"><!-- ENDIF --> + <td class="genmed" style="text-align: center"><input type="checkbox" name="keys[]" value="{sessions.KEY}" id="{sessions.KEY}"/></td> + <td class="genmed"><label for="{sessions.KEY}">{sessions.KEY}</label></td> + <td class="genmed" style="text-align: center">{sessions.IP}</td> + <td class="genmed" style="text-align: center">{sessions.LOGIN_TIME}</td> + </tr> +<!-- BEGINELSE --> + <tr> + <td colspan="4" class="row1" style="text-align: center">{L_PROFILE_NO_AUTOLOGIN_KEYS}</td> + </tr> +<!-- END sessions --> + +<!-- IF .sessions --> + <tr> + <td class="cat" colspan="4" align="center"> + {S_HIDDEN_FIELDS}<input class="btnmain" type="submit" name="submit" value="{L_DELETE}" /> + {S_FORM_TOKEN} + </td> + </tr> +<!-- ENDIF --> +</table> + +<!-- INCLUDE ucp_footer.html --> diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index 9bed0648cd..c20e46011f 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -165,6 +165,11 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case */ public function test_created_column($column_name, $column_value) { + if ($column_name === 'c_varbinary' && stripos(get_class($this->db), 'mysql') === false) + { + $this->markTestIncomplete('Binary handling is not implemented properly on non-MySQL DBMSes.'); + } + $row_insert = self::get_default_values(); $row_insert[$column_name] = $column_value; diff --git a/tests/functional/auth_test.php b/tests/functional/auth_test.php new file mode 100644 index 0000000000..e955dcb4df --- /dev/null +++ b/tests/functional/auth_test.php @@ -0,0 +1,40 @@ +<?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_auth_test extends phpbb_functional_test_case +{ + public function test_login() + { + $this->login(); + + // check for logout link + $crawler = $this->request('GET', 'index.php'); + $this->assertContains($this->lang('LOGOUT_USER', 'admin'), $crawler->filter('.navbar')->text()); + } + + /** + * @depends test_login + */ + public function test_logout() + { + $this->login(); + $this->add_lang('ucp'); + + // logout + $crawler = $this->request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout'); + $this->assertContains($this->lang('LOGOUT_REDIRECT'), $crawler->filter('#message')->text()); + + // look for a register link, which should be visible only when logged out + $crawler = $this->request('GET', 'index.php'); + $this->assertContains($this->lang('REGISTER'), $crawler->filter('.navbar')->text()); + } +} diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php index 723cf93232..26c18c4c1f 100644 --- a/tests/functional/browse_test.php +++ b/tests/functional/browse_test.php @@ -23,4 +23,10 @@ class phpbb_functional_browse_test extends phpbb_functional_test_case $crawler = $this->request('GET', 'viewforum.php?f=2'); $this->assertGreaterThan(0, $crawler->filter('.topiclist')->count()); } + + public function test_viewtopic() + { + $crawler = $this->request('GET', 'viewtopic.php?t=1'); + $this->assertGreaterThan(0, $crawler->filter('.postbody')->count()); + } } diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 4ee0e68718..e9409d9d3f 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -65,15 +65,6 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c } } - public static function tearDownAfterClass() - { - $phpbb_root_path = self::$config['phpbb_functional_path']; - - // @todo delete the fixtures from the $phpbb_root_path board - // Note that it might be best to find a public domain function - // and port it into here instead of writing it from scratch - } - public function setUp() { parent::setUp(); diff --git a/tests/functional/lang_test.php b/tests/functional/lang_test.php new file mode 100644 index 0000000000..053806a431 --- /dev/null +++ b/tests/functional/lang_test.php @@ -0,0 +1,45 @@ +<?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_lang_test extends phpbb_functional_test_case +{ + public function test_lang() + { + // Test a language string present in the common language file + $this->assertEquals('Board index', $this->lang('FORUM_INDEX')); + } + + /** + * @expectedException RuntimeException + */ + public function test_lang_missing() + { + $this->assertEquals('Your account has now been activated. Thank you for registering.', $this->lang('ACCOUNT_ACTIVE')); + } + + public function test_add_lang() + { + $this->add_lang('ucp'); + + // Test a language string present only in the UCP language file + $this->assertEquals('Your account has now been activated. Thank you for registering.', $this->lang('ACCOUNT_ACTIVE')); + } + + public function test_add_langs() + { + $this->add_lang(array('groups', 'memberlist')); + + // Test a language string from each UCP and memberlist + $this->assertEquals('The selected group is already your default group.', $this->lang('ALREADY_DEFAULT_GROUP')); + $this->assertEquals('Profile', $this->lang('ABOUT_USER')); + } +} diff --git a/tests/regex/email_test.php b/tests/regex/email_test.php index 17f93259c3..b4ea5b23aa 100644 --- a/tests/regex/email_test.php +++ b/tests/regex/email_test.php @@ -28,6 +28,8 @@ class phpbb_regex_email_test extends phpbb_test_case array('alice_foo@bar.phpbb.com'), array('alice+tag@foo.phpbb.com'), array('alice&tag@foo.phpbb.com'), + array('alice@phpbb.australia'), + array('alice@phpbb.topZlevelZdomainZnamesZcanZbeZupZtoZsixtyZthreeZcharactersZlong'), //array('"John Doe"@example.com'), //array('Alice@[192.168.2.1]'), // IPv4 @@ -96,6 +98,7 @@ class phpbb_regex_email_test extends phpbb_test_case array('! "#$%(),/;<>[]`|@invalidCharsInLocal.org'), array('invalidCharsInDomain@! "#$%(),/;<>_[]`|.org'), array('local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org'), + array('alice@phpbb.topZlevelZdomainZnamesZcanZbeZupZtoZsixtyZthreeZcharactersZlongZ'), ); } diff --git a/tests/template/invalid_constructs_test.php b/tests/template/invalid_constructs_test.php new file mode 100644 index 0000000000..19d192b8b6 --- /dev/null +++ b/tests/template/invalid_constructs_test.php @@ -0,0 +1,87 @@ +<?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__) . '/template_test_case.php'; + +class phpbb_template_invalid_constructs_test extends phpbb_template_template_test_case +{ + public function template_data() + { + return array( + array( + 'Unknown tag', + 'invalid/unknown_tag.html', + array(), + array(), + array(), + 'invalid/output/unknown_tag.html', + ), + /* + * Produces a parse error which is fatal, therefore + * destroying the test suite. + array( + 'ENDIF without IF', + 'invalid/endif_without_if.html', + array(), + array(), + array(), + 'invalid/output/endif_without_if.html', + ), + */ + ); + } + + public function template_data_error() + { + return array( + array( + 'Include a nonexistent file', + 'invalid/include_nonexistent_file.html', + array(), + array(), + array(), + E_USER_ERROR, + 'invalid/output/include_nonexistent_file.html', + ), + ); + } + + /** + * @dataProvider template_data + */ + public function test_template($description, $file, $vars, $block_vars, $destroy, $expected) + { + $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php'; + + $this->assertFileNotExists($cache_file); + + $expected = file_get_contents(dirname(__FILE__) . '/templates/' . $expected); + // apparently the template engine does not put + // the trailing newline into compiled templates + $expected = trim($expected); + $this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file); + } + + /** + * @dataProvider template_data_error + */ + public function test_template_error($description, $file, $vars, $block_vars, $destroy, $error, $expected) + { + $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php'; + + $this->assertFileNotExists($cache_file); + + $expected = file_get_contents(dirname(__FILE__) . '/templates/' . $expected); + // apparently the template engine does not put + // the trailing newline into compiled templates + $expected = trim($expected); + $this->setExpectedTriggerError($error, $expected); + $this->run_template($file, $vars, $block_vars, $destroy, '', $cache_file); + } +} diff --git a/tests/template/parent_templates/parent_and_child.js b/tests/template/parent_templates/parent_and_child.js new file mode 100644 index 0000000000..6d9bb163bf --- /dev/null +++ b/tests/template/parent_templates/parent_and_child.js @@ -0,0 +1 @@ +// JavaScript file in a parent style. diff --git a/tests/template/parent_templates/parent_only.js b/tests/template/parent_templates/parent_only.js new file mode 100644 index 0000000000..9c3007d83f --- /dev/null +++ b/tests/template/parent_templates/parent_only.js @@ -0,0 +1 @@ +// JavaScript file only in parent style. diff --git a/tests/template/template_includejs_test.php b/tests/template/template_includejs_test.php index 632fde61d1..a8f9a9037f 100644 --- a/tests/template/template_includejs_test.php +++ b/tests/template/template_includejs_test.php @@ -17,15 +17,14 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes $this->setup_engine(array('assets_version' => 1)); // Prepare correct result - $dir = dirname(__FILE__); $scripts = array( - '<script src="' . $dir . '/templates/parent_and_child.html?assets_version=1"></script>', - '<script src="' . $dir . '/parent_templates/parent_only.html?assets_version=1"></script>', - '<script src="' . $dir . '/templates/child_only.html?assets_version=1"></script>' + '<script src="' . $this->test_path . '/templates/parent_and_child.js?assets_version=1"></script>', + '<script src="' . $this->test_path . '/parent_templates/parent_only.js?assets_version=1"></script>', + '<script src="' . $this->test_path . '/templates/child_only.js?assets_version=1"></script>' ); // Run test $cache_file = $this->template->cachepath . 'includejs.html.php'; - $this->run_template('includejs.html', array('PARENT' => 'parent_only.html'), array(), array(), implode('', $scripts), $cache_file); + $this->run_template('includejs.html', array('PARENT' => 'parent_only.js'), array(), array(), implode('', $scripts), $cache_file); } } diff --git a/tests/template/template_locate_test.php b/tests/template/template_locate_test.php index d6e2e82a47..be9ae06809 100644 --- a/tests/template/template_locate_test.php +++ b/tests/template/template_locate_test.php @@ -17,21 +17,21 @@ class phpbb_template_template_locate_test extends phpbb_template_template_test_c // First element of the array is test name - keep them distinct array( 'simple inheritance - only parent template exists', - dirname(__FILE__) . '/parent_templates/parent_only.html', + $this->test_path . '/parent_templates/parent_only.html', 'parent_only.html', false, true, ), array( 'simple inheritance - only child template exists', - dirname(__FILE__) . '/templates/child_only.html', + $this->test_path . '/templates/child_only.html', 'child_only.html', false, true, ), array( 'simple inheritance - both parent and child templates exist', - dirname(__FILE__) . '/templates/parent_and_child.html', + $this->test_path . '/templates/parent_and_child.html', 'parent_and_child.html', false, true, diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 739bbe9387..f8677ed913 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -277,7 +277,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case $this->template->set_filenames(array('test' => $filename)); $this->assertFileNotExists($this->template_path . '/' . $filename, 'Testing missing file, file cannot exist'); - $expecting = sprintf('style resource locator: File for handle test does not exist. Could not find: %s', realpath($this->template_path . '/../') . '/templates/' . $filename); + $expecting = sprintf('style resource locator: File for handle test does not exist. Could not find: %s', $this->test_path . '/templates/' . $filename); $this->setExpectedTriggerError(E_USER_ERROR, $expecting); $this->display('test'); diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index d660aa3f56..dd0acba6cd 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -18,6 +18,8 @@ class phpbb_template_template_test_case extends phpbb_test_case protected $style_resource_locator; protected $style_provider; + protected $test_path = 'tests/template'; + // Keep the contents of the cache for debugging? const PRESERVE_CACHE = true; @@ -63,7 +65,7 @@ class phpbb_template_template_test_case extends phpbb_test_case $defaults = $this->config_defaults(); $config = new phpbb_config(array_merge($defaults, $new_config)); - $this->template_path = dirname(__FILE__) . '/templates'; + $this->template_path = $this->test_path . '/templates'; $this->style_resource_locator = new phpbb_style_resource_locator(); $this->style_provider = new phpbb_style_path_provider(); $this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator); diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php index 9522c97330..05ccb7ee55 100644 --- a/tests/template/template_test_case_with_tree.php +++ b/tests/template/template_test_case_with_tree.php @@ -18,8 +18,8 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat $defaults = $this->config_defaults(); $config = new phpbb_config(array_merge($defaults, $new_config)); - $this->template_path = dirname(__FILE__) . '/templates'; - $this->parent_template_path = dirname(__FILE__) . '/parent_templates'; + $this->template_path = $this->test_path . '/templates'; + $this->parent_template_path = $this->test_path . '/parent_templates'; $this->style_resource_locator = new phpbb_style_resource_locator(); $this->style_provider = new phpbb_style_path_provider(); $this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator); diff --git a/tests/template/templates/child_only.js b/tests/template/templates/child_only.js new file mode 100644 index 0000000000..542b26526c --- /dev/null +++ b/tests/template/templates/child_only.js @@ -0,0 +1 @@ +// JavaScript file only in a child style. diff --git a/tests/template/templates/includejs.html b/tests/template/templates/includejs.html index 186fc30b43..8a2587d76b 100644 --- a/tests/template/templates/includejs.html +++ b/tests/template/templates/includejs.html @@ -1,5 +1,5 @@ -<!-- INCLUDEJS parent_and_child.html --> +<!-- INCLUDEJS parent_and_child.js --> <!-- INCLUDEJS {PARENT} --> -<!-- DEFINE $TEST = 'child_only.html' --> +<!-- DEFINE $TEST = 'child_only.js' --> <!-- INCLUDEJS {$TEST} --> {SCRIPTS}
\ No newline at end of file diff --git a/tests/template/templates/invalid/endif_without_if.html b/tests/template/templates/invalid/endif_without_if.html new file mode 100644 index 0000000000..e371ffd150 --- /dev/null +++ b/tests/template/templates/invalid/endif_without_if.html @@ -0,0 +1 @@ +<!-- ENDIF --> diff --git a/tests/template/templates/invalid/include_nonexistent_file.html b/tests/template/templates/invalid/include_nonexistent_file.html new file mode 100644 index 0000000000..617d2fdaaa --- /dev/null +++ b/tests/template/templates/invalid/include_nonexistent_file.html @@ -0,0 +1 @@ +<!-- INCLUDE nonexistent.html --> diff --git a/tests/template/templates/invalid/output/endif_without_if.html b/tests/template/templates/invalid/output/endif_without_if.html new file mode 100644 index 0000000000..5f2239c964 --- /dev/null +++ b/tests/template/templates/invalid/output/endif_without_if.html @@ -0,0 +1 @@ +Parse error (fatal, destroys php runtime). diff --git a/tests/template/templates/invalid/output/include_nonexistent_file.html b/tests/template/templates/invalid/output/include_nonexistent_file.html new file mode 100644 index 0000000000..8a118d2713 --- /dev/null +++ b/tests/template/templates/invalid/output/include_nonexistent_file.html @@ -0,0 +1 @@ +style resource locator: File for handle nonexistent.html does not exist. Could not find: diff --git a/tests/template/templates/invalid/output/unknown_tag.html b/tests/template/templates/invalid/output/unknown_tag.html new file mode 100644 index 0000000000..1489e5e31a --- /dev/null +++ b/tests/template/templates/invalid/output/unknown_tag.html @@ -0,0 +1 @@ +<!-- UNKNOWNTAG variable.html --> diff --git a/tests/template/templates/invalid/unknown_tag.html b/tests/template/templates/invalid/unknown_tag.html new file mode 100644 index 0000000000..1489e5e31a --- /dev/null +++ b/tests/template/templates/invalid/unknown_tag.html @@ -0,0 +1 @@ +<!-- UNKNOWNTAG variable.html --> diff --git a/tests/template/templates/parent_and_child.js b/tests/template/templates/parent_and_child.js new file mode 100644 index 0000000000..d544d94d83 --- /dev/null +++ b/tests/template/templates/parent_and_child.js @@ -0,0 +1 @@ +// JavaScript file in a child style. diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index c734c90a1a..ae21be6c34 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -80,6 +80,21 @@ class phpbb_database_test_connection_manager { $dsn .= ';dbname=' . $this->config['dbname']; } + else if ($this->dbms['PDO'] == 'pgsql') + { + // Postgres always connects to a + // database. If the database is not + // specified here, but the username + // is specified, then connection + // will be to the database named + // as the username. + // + // For greater compatibility, connect + // instead to postgres database which + // should always exist: + // http://www.postgresql.org/docs/9.0/static/manage-ag-templatedbs.html + $dsn .= ';dbname=postgres'; + } break; } diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 69c62af297..76650feb02 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -6,6 +6,7 @@ * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 * */ +use Symfony\Component\BrowserKit\CookieJar; require_once __DIR__ . '/../../phpBB/includes/functions_install.php'; @@ -18,6 +19,18 @@ class phpbb_functional_test_case extends phpbb_test_case protected $db = null; protected $extension_manager = null; + /** + * Session ID for current test's session (each test makes its own) + * @var string + */ + protected $sid; + + /** + * Language array used by phpBB + * @var array + */ + protected $lang = array(); + static protected $config = array(); static protected $already_installed = false; @@ -38,8 +51,13 @@ class phpbb_functional_test_case extends phpbb_test_case $this->markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.'); } - $this->client = new Goutte\Client(); + $this->cookieJar = new CookieJar; + $this->client = new Goutte\Client(array(), array(), null, $this->cookieJar); $this->root_url = self::$config['phpbb_functional_url']; + // Clear the language array so that things + // that were added in other tests are gone + $this->lang = array(); + $this->add_lang('common'); } public function request($method, $path) @@ -219,4 +237,63 @@ class phpbb_functional_test_case extends phpbb_test_case $db_conn_mgr = new phpbb_database_test_connection_manager($config); $db_conn_mgr->recreate_db(); } + + protected function login() + { + $this->add_lang('ucp'); + + $crawler = $this->request('GET', 'ucp.php'); + $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text()); + + $form = $crawler->selectButton($this->lang('LOGIN'))->form(); + $login = $this->client->submit($form, array('username' => 'admin', 'password' => '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 $key => $cookie); + { + if (substr($key, -4) == '_sid') + { + $this->sid = $cookie->getValue(); + } + } + } + + protected function add_lang($lang_file) + { + if (is_array($lang_file)) + { + foreach ($lang_file as $file) + { + $this->add_lang($file); + } + } + + $lang_path = __DIR__ . "/../../phpBB/language/en/$lang_file.php"; + + $lang = array(); + + if (file_exists($lang_path)) + { + include($lang_path); + } + + $this->lang = array_merge($this->lang, $lang); + } + + protected function lang() + { + $args = func_get_args(); + $key = $args[0]; + + if (empty($this->lang[$key])) + { + throw new RuntimeException('Language key "' . $key . '" could not be found.'); + } + + $args[0] = $this->lang[$key]; + + return call_user_func_array('sprintf', $args); + } } diff --git a/tests/wrapper/phpbb_php_ini_fake.php b/tests/wrapper/phpbb_php_ini_fake.php new file mode 100644 index 0000000000..49bc5936e5 --- /dev/null +++ b/tests/wrapper/phpbb_php_ini_fake.php @@ -0,0 +1,16 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +class phpbb_php_ini_fake extends phpbb_php_ini +{ + function get($varname) + { + return $varname; + } +} diff --git a/tests/wrapper/phpbb_php_ini_test.php b/tests/wrapper/phpbb_php_ini_test.php new file mode 100644 index 0000000000..8e08d5c204 --- /dev/null +++ b/tests/wrapper/phpbb_php_ini_test.php @@ -0,0 +1,86 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2011 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +require_once dirname(__FILE__) . '/phpbb_php_ini_fake.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + +class phpbb_wrapper_phpbb_php_ini_test extends phpbb_test_case +{ + protected $php_ini; + + public function setUp() + { + $this->php_ini = new phpbb_php_ini_fake; + } + + public function test_get_string() + { + $this->assertSame(false, $this->php_ini->get_string(false)); + $this->assertSame('phpbb', $this->php_ini->get_string(' phpbb ')); + } + + public function test_get_bool() + { + $this->assertSame(true, $this->php_ini->get_bool('ON')); + $this->assertSame(true, $this->php_ini->get_bool('on')); + $this->assertSame(true, $this->php_ini->get_bool('1')); + + $this->assertSame(false, $this->php_ini->get_bool('OFF')); + $this->assertSame(false, $this->php_ini->get_bool('off')); + $this->assertSame(false, $this->php_ini->get_bool('0')); + $this->assertSame(false, $this->php_ini->get_bool('')); + } + + public function test_get_int() + { + $this->assertSame(1234, $this->php_ini->get_int('1234')); + $this->assertSame(-12345, $this->php_ini->get_int('-12345')); + $this->assertSame(false, $this->php_ini->get_int('phpBB')); + } + + public function test_get_float() + { + $this->assertSame(1234.0, $this->php_ini->get_float('1234')); + $this->assertSame(-12345.0, $this->php_ini->get_float('-12345')); + $this->assertSame(false, $this->php_ini->get_float('phpBB')); + } + + public function test_get_bytes_invalid() + { + $this->assertSame(false, $this->php_ini->get_bytes(false)); + $this->assertSame(false, $this->php_ini->get_bytes('phpBB')); + $this->assertSame(false, $this->php_ini->get_bytes('k')); + $this->assertSame(false, $this->php_ini->get_bytes('-k')); + $this->assertSame(false, $this->php_ini->get_bytes('M')); + $this->assertSame(false, $this->php_ini->get_bytes('-M')); + } + + /** + * @dataProvider get_bytes_data + */ + public function test_get_bytes($expected, $value) + { + $actual = $this->php_ini->get_bytes($value); + + $this->assertTrue(is_float($actual) || is_int($actual)); + $this->assertEquals($expected, $actual); + } + + static public function get_bytes_data() + { + return array( + array(32 * pow(2, 20), '32m'), + array(- 32 * pow(2, 20), '-32m'), + array(8 * pow(2, 30), '8G'), + array(- 8 * pow(2, 30), '-8G'), + array(1234, '1234'), + array(-12345, '-12345'), + ); + } +} |