diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..871d17b386 --- /dev/null +++ b/.gitignore @@ -0,0 +1,8 @@ +*~ +phpBB/cache/*.php +phpBB/config.php +phpBB/files/* +phpBB/images/avatars/upload/* +phpBB/store/* +tests/phpbb_unit_tests.sqlite2 +tests/test_config.php diff --git a/build/build.xml b/build/build.xml new file mode 100644 index 0000000000..bf77d82f6c --- /dev/null +++ b/build/build.xml @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/build_diff.php b/build/build_diff.php index ef815bc0c3..6a6070228f 100755 --- a/build/build_diff.php +++ b/build/build_diff.php @@ -9,16 +9,26 @@ * */ -// CONFIG - Begin -$substitute_old = '3.0.6'; -$substitute_new = '3.0.7-PL1'; -$simple_name_old = 'phpbb306'; -$simple_name_new = 'phpbb307-PL1'; +if ($_SERVER['argc'] != 3) +{ + die("Please specify the previous and current version as arguments (e.g. build_diff.php '1.0.2' '1.0.3')."); +} + +$old_version = trim($_SERVER['argv'][1]); +$new_version = trim($_SERVER['argv'][2]); + +$substitute_old = $old_version; +$substitute_new = $new_version; +$simple_name_old = 'release-' . $old_version; +$simple_name_new = 'release-' . $new_version; $echo_changes = false; + +// DO NOT EVER USE THE FOLLOWING! Fix the script to generate proper changes, +// do NOT manually create them. + // Set this to true to just compress the changes and do not build them again // This should be used for building custom modified txt file. ;) $package_changed_files = false; -// CONFIG - End //$debug_file = 'includes/functions_user.php'; //'styles/prosilver/style.cfg'; $debug_file = false; @@ -36,9 +46,6 @@ if (!$package_changed_files) { if (!$echo_changes) { - // Cleanup... - run_command("rm -R $location/save/*"); - // Create directory... run_command("mkdir $location/save/{$s_name}"); run_command("mkdir $location/save/{$s_name}/language"); @@ -72,14 +79,14 @@ if (!$echo_changes) foreach ($compress_programs as $extension => $compress_command) { echo "Packaging code changes for $extension\n"; - run_command("rm ./../../release_files/{$code_changes_filename}.{$extension}"); + run_command("rm ./../../new_version/release_files/{$code_changes_filename}.{$extension}"); flush(); // Build Package - run_command("$compress_command ./../../release_files/{$code_changes_filename}.{$extension} *"); + run_command("$compress_command ./../../new_version/release_files/{$code_changes_filename}.{$extension} *"); // Build MD5 Sum - run_command("md5sum ./../../release_files/{$code_changes_filename}.{$extension} > ./../../release_files/{$code_changes_filename}.{$extension}.md5"); + run_command("md5sum ./../../new_version/release_files/{$code_changes_filename}.{$extension} > ./../../new_version/release_files/{$code_changes_filename}.{$extension}.md5"); flush(); } } diff --git a/build/build_helper.php b/build/build_helper.php index 2bae32218b..94fc0ff3b5 100644 --- a/build/build_helper.php +++ b/build/build_helper.php @@ -14,10 +14,6 @@ class build_package var $old_packages; var $versions; var $locations; - var $clean_directory_structure; - var $files_to_copy; - var $files_to_remove; - var $remove_from_diff_structure; // -c - context diff // -r - compare recursive @@ -53,11 +49,11 @@ class build_package $this->package_infos = array( 'package_name' => 'phpBB3', 'name_prefix' => 'phpbb', - 'simple_name' => 'phpbb' . str_replace('.', '', $_latest), + 'simple_name' => 'release-' . $_latest, 'new_version_number' => $_latest, 'short_version_number' => str_replace('.', '', $_latest), 'release_filename' => 'phpBB-' . $_latest, - 'last_version' => 'phpbb' . str_replace('.', '', $_before), + 'last_version' => 'release-' . $_before, 'last_version_number' => $_before, ); @@ -78,112 +74,7 @@ class build_package continue; } - $this->old_packages['phpbb' . str_replace('.', '', $package_version)] = $package_version . '_to_'; - } - - // We need to make sure this is up to date with the latest version - $this->clean_directory_structure = array( - 'adm' => array( - 'images' => '', - 'style' => '', - ), - 'cache' => '', - 'docs' => '', - 'download' => '', - 'files' => '', - 'images' => array( - 'avatars' => array( - 'gallery' => '', - 'upload' => '', - ), - 'icons' => array( - 'misc' => '', - 'smile' => '', - ), - 'ranks' => '', - 'smilies' => '', - 'upload_icons' => '', - ), - 'includes' => array( - 'acm' => '', - 'acp' => array( - 'info' => '', - ), - 'auth' => '', - 'captcha' => array( - 'plugins' => '', - ), - 'diff' => '', - 'db' => '', - 'hooks' => '', - 'mcp' => array( - 'info' => '', - ), - 'questionnaire' => '', - 'search' => '', - 'ucp' => array( - 'info' => '', - ), - 'utf' => array( - 'data' => '', - ), - ), - 'install' => array( - 'convertors'=> '', - 'schemas' => '', -// 'data' => '', - ), - 'language' => array( - 'en' => array( - 'acp' => '', - 'email' => '', - 'mods' => '', - ), - ), - 'store' => '', - 'styles' => array( - 'subsilver2' => array( - 'imageset' => array( - 'en' => '', - ), - 'template' => '', - 'theme' => array( - 'images' => '', - ), - ), - 'prosilver' => array( - 'imageset' => array( - 'en' => '', - ), - 'template' => '', - 'theme' => array( - 'images' => '', - ), - ), - ), - ); - - // Files to remove (not include within package) - $this->files_to_remove = array(); //array('includes/utf/data/recode_cjk.php'); - - // Files within the main directory to copy - do not include config.php - $this->files_to_copy = array( - '.htaccess', 'common.php', 'cron.php', 'faq.php', 'feed.php', 'index.php', 'mcp.php', 'memberlist.php', 'posting.php', 'report.php', - 'search.php', 'style.php', 'ucp.php', 'viewforum.php', 'viewonline.php', 'viewtopic.php' - ); - - // These files/directories will be removed and not used for creating the patch files - $this->remove_from_diff_structure = array( - 'config.php', 'cache', 'docs', 'files', 'install', 'store', 'develop' - ); - - // Writeable directories - $this->writeable = array('cache', 'store', 'images/avatars/upload', 'files'); - - // Fill the rest of the files_to_copy array - foreach ($this->clean_directory_structure as $cur_dir => $dir_struct) - { - $this->_fill_files_to_copy($this->locations['new_version'] . $cur_dir, $cur_dir, $dir_struct); + $this->old_packages['release-' . $package_version] = $package_version . '_to_'; } } @@ -192,66 +83,6 @@ class build_package return $this->package_infos[$var]; } - function _fill_files_to_copy($directory, $cur_dir, $dir_struct) - { - $dh = opendir($directory); - - while ($file = readdir($dh)) - { - if (is_file($directory . '/' . $file) && $file != '.' && $file != '..') - { - $_loc = str_replace($this->locations['new_version'], '', $directory . '/' . $file); - - if (in_array($_loc, $this->files_to_remove)) - { - continue; - } - - $this->files_to_copy[] = $cur_dir . '/' . $file; - } - } - closedir($dh); - - if (is_array($dir_struct)) - { - foreach ($dir_struct as $_cur_dir => $_dir_struct) - { - $this->_fill_files_to_copy($directory . '/' . $_cur_dir, $cur_dir . '/' . $_cur_dir, $_dir_struct); - } - } - } - - function adjust_permissions($directory) - { - $dh = opendir($directory); - - while ($file = readdir($dh)) - { - if ($file == '.' || $file == '..' || $file == '.svn') - { - continue; - } - - // If file, then 644 - if (is_file($directory . '/' . $file)) - { - chmod($directory . '/' . $file, 0644); - } - else if (is_dir($directory . '/' . $file)) - { - $_loc = str_replace($this->package_infos['dest_dir'] . '/', '', $directory . '/' . $file); - - // If directory is within the writeable chmod to 777, else 755 - $mode = (in_array($_loc, $this->writeable)) ? 0777 : 0755; - chmod($directory . '/' . $file, $mode); - - // Now traverse to the directory - $this->adjust_permissions($directory . '/' . $file); - } - } - closedir($dh); - } - function begin_status($headline) { if ($this->status_begun) diff --git a/build/package.php b/build/package.php index 7cb30bd493..4ce644e8ca 100755 --- a/build/package.php +++ b/build/package.php @@ -9,14 +9,17 @@ * */ -// The only thing i need to adjust. ;) -// Please always add the latest version number to the end -// Only have 5 releases here... -// If RC8 drops remove the install/data directory -//$versions = array('3.0.2', '3.0.3-RC1', '3.0.3', '3.0.4-RC1', '3.0.4', '3.0.5-RC1', '3.0.5', '3.0.6-RC1', '3.0.6-RC2', '3.0.6-RC3'); -//$versions = array('3.0.2', '3.0.3', '3.0.4', '3.0.5', '3.0.6', '3.0.7-RC1', '3.0.7'); -$versions = array('3.0.2', '3.0.3', '3.0.4', '3.0.5', '3.0.6', '3.0.7-RC1', '3.0.7-RC2', '3.0.7', '3.0.7-PL1'); -$verbose = false; +//$versions = array('3.0.2', '3.0.3', '3.0.4', '3.0.5', '3.0.6', '3.0.7-RC1', '3.0.7-RC2', '3.0.7', '3.0.7-PL1'); + +if ($_SERVER['argc'] < 2) +{ + die("Please specify a list of versions as the first argument (e.g. package.php '1.0.0, 1.0.1, 1.0.2')."); +} + +$versions = explode(',', $_SERVER['argv'][1]); +$versions = array_map('trim', $versions); + +$verbose = true; require('build_helper.php'); @@ -25,130 +28,6 @@ $package = new build_package($versions, $verbose); echo "Building Release Packages\n"; echo "Now all three package types (patch, files, release) are built as well as the update package (update).\n"; -$package->begin_status('Remove temporary files'); - -// Cleanup... -$package->run_command('rm -Rv ' . $package->get('dest_dir')); -$package->run_command('rm -Rv ' . $package->get('diff_dir')); -$package->run_command('rm -Rv ' . $package->get('patch_directory')); -$package->run_command('rm -Rv ' . $package->get('files_directory')); -$package->run_command('rm -Rv ' . $package->get('update_directory')); -$package->run_command('rm -Rv ' . $package->get('release_directory')); - -$package->begin_status('Create new directories'); - -// Make sure the directories got removed -while (file_exists($package->get('update_directory'))) -{ - sleep(1); -} - -if (!file_exists($package->get('dest_dir'))) -{ - $package->run_command('mkdir ' . $package->get('dest_dir')); -} - -if (!file_exists($package->get('diff_dir'))) -{ - $package->run_command('mkdir ' . $package->get('diff_dir')); -} - -if (!file_exists($package->get('patch_directory'))) -{ - $package->run_command('mkdir ' . $package->get('patch_directory')); -} - -if (!file_exists($package->get('files_directory'))) -{ - $package->run_command('mkdir ' . $package->get('files_directory')); -} - -if (!file_exists($package->get('update_directory'))) -{ - $package->run_command('mkdir ' . $package->get('update_directory')); -} - -if (!file_exists($package->get('release_directory'))) -{ - $package->run_command('mkdir ' . $package->get('release_directory')); -} - -$package->begin_status('Copy release files to clean release directory'); - -// Create config.php file -$package->run_command('touch ' . $package->get('dest_dir') . '/config.php'); -//$package->run_command('sudo chown www-data:www-data ' . $package->get('dest_dir') . '/config.php'); - -// Create new directory structure -foreach ($package->clean_directory_structure as $dir => $dir_struct) -{ - $package->create_directory($package->get('dest_dir') . '/' . $dir, $dir_struct); -} - -// First step is to copy the new version over (clean structure) -foreach ($package->files_to_copy as $file) -{ - $source_file = $package->locations['new_version'] . $file; - $dest_file = $package->get('dest_dir') . '/' . $file; - - $package->run_command("cp -p $source_file $dest_file"); -} - -// fix line endings -chdir($package->get('dest_dir')); -$package->run_command($package->locations['new_version'] . 'develop/fix_files.sh'); - -// Now clean up the permissions -$package->begin_status('Adjust permissions'); - -$package->adjust_permissions($package->get('dest_dir')); - -// Now create a version for diffing the version - copy the tree over to old_versions... -$package->begin_status('Create diff directory for obtaining file differences'); - -$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/* ' . $package->get('diff_dir')); -$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/.htaccess ' . $package->get('diff_dir')); - -// Cleanup diff directory (only contents to diff) -foreach ($package->remove_from_diff_structure as $remove_dir) -{ - $package->run_command('rm -Rv ' . $package->get('diff_dir') . '/' . $remove_dir); -} - -// Now, first of all we need to rebuild all old packages we want to support -foreach ($package->old_packages as $package_name => $tag_name) -{ - $package->begin_status('Create old packages directory for diffing to ' . $package_name); - - chdir($package->locations['old_versions']); - - if (is_dir($package->locations['old_versions'] . $package_name)) - { - $package->run_command('rm -Rv ' . $package->locations['old_versions'] . $package_name); - } - - // Now, create a new one... - $tag_name = 'release_' . str_replace(array('.', '_to_'), array('_', ''), $tag_name); - - $package->run_command('svn export --non-interactive http://code.phpbb.com/svn/phpbb/tags/' . $tag_name . '/phpBB/ ' . $package_name); - - $location = $package->locations['old_versions'] . $package_name; - chdir($location . '/'); - - $package->run_command($package->locations['new_version'] . 'develop/fix_files.sh'); - - // Now clean up the permissions - $package->begin_status('Adjust permissions for package ' . $package_name); - - $package->adjust_permissions($location); - - // Cleanup diff directory (only contents to diff) - foreach ($package->remove_from_diff_structure as $remove_dir) - { - $package->run_command('rm -Rv ' . $location . '/' . $remove_dir); - } -} - // Go trough all versions making a diff if we even have old versions // For phpBB 3.0.x we might choose a different update method, rendering the things below useless... if (sizeof($package->old_packages)) @@ -160,13 +39,13 @@ if (sizeof($package->old_packages)) foreach ($package->old_packages as $_package_name => $dest_package_filename) { - $package->begin_status('Creating patch/diff files for phpBB-' . $dest_package_filename . $package->get('new_version_number')); - - $dest_package_filename = $package->get('patch_directory') . '/phpBB-' . $dest_package_filename . $package->get('new_version_number') . '.patch'; - $package->run_command('diff ' . $package->diff_options . ' ' . $_package_name . ' ' . $package->get('simple_name') . ' > ' . $dest_package_filename); + $package->begin_status('Parsing patch/diff files for phpBB-' . $dest_package_filename . $package->get('new_version_number')); // Parse this diff to determine file changes from the checked versions and save them - $diff_file_changes[$_package_name] = $package->collect_diff_files($dest_package_filename, $_package_name); + $diff_file_changes[$_package_name] = $package->collect_diff_files( + $package->get('patch_directory') . '/phpBB-' . $dest_package_filename . $package->get('new_version_number') . '.patch', + $_package_name + ); } // Now put those files determined within the correct directories @@ -404,7 +283,6 @@ if (sizeof($package->old_packages)) foreach ($compress_programs as $extension => $compress_command) { $package->begin_status('Packaging phpBB Patch Files for ' . $extension); - $package->run_command('rm -v ../release_files/' . $package->get('release_filename') . '-patch.' . $extension); // Build Package $package->run_command($compress_command . ' ../release_files/' . $package->get('release_filename') . '-patch.' . $extension . ' *'); @@ -420,7 +298,6 @@ if (sizeof($package->old_packages)) { $package->begin_status('Packaging phpBB Files for ' . $extension); - $package->run_command('rm -v ../release_files/' . $package->get('release_filename') . '-files.' . $extension); $package->run_command('mkdir ' . $package->get('files_directory') . '/release'); $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/docs ' . $package->get('files_directory') . '/release'); $package->run_command('cp -Rp ' . $package->get('dest_dir') . '/install ' . $package->get('files_directory') . '/release'); @@ -457,7 +334,6 @@ if (sizeof($package->old_packages)) $package->begin_status('Packaging phpBB Update for ' . $extension); - $package->run_command('rm -v ../release_files/' . $package->get('release_filename') . '-update.' . $extension); $package->run_command('mkdir ' . $package->get('update_directory') . '/release'); // Pack update files @@ -518,6 +394,13 @@ foreach ($compress_programs as $extension => $compress_command) $package->run_command('md5sum ./release_files/' . $package->get('release_filename') . '.' . $extension . ' > ./release_files/' . $package->get('release_filename') . '.' . $extension . '.md5'); } +// Microsoft Web PI packaging +$package->begin_status('Packaging phpBB for Microsoft WebPI'); +$file = './release_files/' . $package->get('release_filename') . '.webpi.zip'; +$package->run_command('cp -p ./release_files/' . $package->get('release_filename') . ".zip $file"); +$package->run_command('cd ./../webpi && ' . $compress_programs['zip'] . " ./../new_version/$file *"); +$package->run_command("md5sum $file > $file.md5"); + // verify results chdir($package->locations['root']); $package->begin_status('********** Verifying packages **********'); diff --git a/build/webpi/install/mssql.sql b/build/webpi/install/mssql.sql new file mode 100644 index 0000000000..9c0b46678a --- /dev/null +++ b/build/webpi/install/mssql.sql @@ -0,0 +1,39 @@ +/**********************************************************************/ +/* Install.SQL */ +/* Creates a login and makes the user a member of db roles */ +/* */ +/**********************************************************************/ + +-- Declare variables for database name, username and password +DECLARE @dbName sysname, + @dbUser sysname, + @dbPwd nvarchar(max); + +-- Set variables for database name, username and password +SET @dbName = 'PlaceHolderForDb'; +SET @dbUser = 'PlaceHolderForUser'; +SET @dbPwd = 'PlaceHolderForPassword'; + +DECLARE @cmd nvarchar(max) + +-- Create login +IF( SUSER_SID(@dbUser) is null ) +BEGIN + print '-- Creating login ' + SET @cmd = N'CREATE LOGIN ' + quotename(@dbUser) + N' WITH PASSWORD ='''+ replace(@dbPwd, '''', '''''') + N'''' + EXEC(@cmd) +END + +-- Create database user and map to login +-- and add user to the datareader, datawriter, ddladmin and securityadmin roles +-- +SET @cmd = N'USE ' + quotename(@DBName) + N'; +IF( NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = ''' + replace(@dbUser, '''', '''''') + N''')) +BEGIN + print ''-- Creating user''; + CREATE USER ' + quotename(@dbUser) + N' FOR LOGIN ' + quotename(@dbUser) + N'; + print ''-- Adding user''; + EXEC sp_addrolemember ''db_owner'', ''' + replace(@dbUser, '''', '''''') + N'''; +END' +EXEC(@cmd) +GO diff --git a/build/webpi/install/mysql.sql b/build/webpi/install/mysql.sql new file mode 100644 index 0000000000..5c9d8cd922 --- /dev/null +++ b/build/webpi/install/mysql.sql @@ -0,0 +1,15 @@ +USE PlaceHolderForDb$$ + +DROP PROCEDURE IF EXISTS add_user $$ + +CREATE PROCEDURE add_user() +BEGIN +DECLARE EXIT HANDLER FOR 1044 BEGIN END; +GRANT ALL PRIVILEGES ON PlaceHolderForDb.* to 'PlaceHolderForUser'@'PlaceHolderForServer' IDENTIFIED BY 'PlaceHolderForPassword'; +FLUSH PRIVILEGES; +END +$$ + +CALL add_user() $$ + +DROP PROCEDURE IF EXISTS add_user $$ diff --git a/build/webpi/manifest.xml b/build/webpi/manifest.xml new file mode 100644 index 0000000000..947377893b --- /dev/null +++ b/build/webpi/manifest.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/build/webpi/parameters.xml b/build/webpi/parameters.xml new file mode 100644 index 0000000000..be4d374632 --- /dev/null +++ b/build/webpi/parameters.xml @@ -0,0 +1,256 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/git-tools/hooks/commit-msg b/git-tools/hooks/commit-msg new file mode 100755 index 0000000000..a6777ff9c9 --- /dev/null +++ b/git-tools/hooks/commit-msg @@ -0,0 +1,258 @@ +#!/bin/sh +# +# A hook to check syntax of a phpBB3 commit message, per: +# * +# * +# +# This is a commit-msg hook. +# +# To install this you can either copy or symlink it to +# $GIT_DIR/hooks, example: +# +# ln -s ../../git-tools/hooks/commit-msg \\ +# .git/hooks/commit-msg + +config_ns="phpbb.hooks.commit-msg"; + +if [ "$(git config --bool $config_ns.fatal)" = "false" ] +then + fatal=0; +else + fatal=1; +fi + +debug_level=$(git config --int $config_ns.debug || echo 0); + +# Error codes +ERR_LENGTH=1; +ERR_HEADER=2; +ERR_EMPTY=3; +ERR_DESCRIPTION=4; +ERR_FOOTER=5; +ERR_EOF=6; +ERR_UNKNOWN=42; + +debug() +{ + local level; + + level=$1; + shift; + + if [ $debug_level -ge $level ] + then + echo $@; + fi +} + +quit() +{ + if [ $1 -gt 0 ] && [ $1 -ne $ERR_UNKNOWN ] && [ $fatal -eq 0 ] + then + exit 0; + else + exit $1; + fi +} + +msg=$(grep -nE '.{81,}' "$1"); + +if [ $? -eq 0 ] +then + echo "The following lines are greater than 80 characters long:\n" >&2; + echo $msg >&2; + + quit $ERR_LENGTH; +fi + +lines=$(wc -l "$1" | awk '{ print $1; }'); +expecting=header; +in_description=0; +in_empty=0; +ticket=0; +branch_regex="[a-z]+[a-z0-9-]*[a-z0-9]+"; +i=1; +tickets=""; + +while [ $i -le $lines ] +do + # Grab the line we are studying + line=$(head -n$i "$1" | tail -n1); + + debug 1 "==> [$i] $line (description: $in_description, empty: $in_empty)"; + + err=$ERR_UNKNOWN; + + if [ -z "$expecting" ] + then + quit $err; + fi + + if [ "${expecting#comment}" = "$expecting" ] + then + # Prefix comments to the expected tokens list + expecting="comment $expecting"; + fi + + debug 2 "Expecting: $expecting"; + + # Loop over each of the expected line formats + for expect in $expecting + do + # Reset the error code each iteration + err=$ERR_UNKNOWN; + + # Test for validity of each line format + # This is done first so $? contains the result + case $expect in + "header") + err=$ERR_HEADER; + echo "$line" | grep -Eq "^\[(ticket/[0-9]+|feature/$branch_regex|task/$branch_regex)\] [A-Z].+$" + ;; + "empty") + err=$ERR_EMPTY; + echo "$line" | grep -Eq "^$" + ;; + "description") + err=$ERR_DESCRIPTION; + # Free flow text, the line length was constrained by the initial check + echo "$line" | grep -Eq "^.+$"; + ;; + "footer") + err=$ERR_FOOTER; + # Each ticket is on its own line + echo "$line" | grep -Eq "^PHPBB3-[0-9]+$"; + ;; + "eof") + err=$ERR_EOF; + # Should not end up here + false + ;; + "comment") + echo "$line" | grep -Eq "^#"; + ;; + *) + echo "Unrecognised token $expect" >&2; + quit $err; + ;; + esac + + # Preserve the result of the line check + result=$?; + + debug 2 "$expect - '$line' - $result"; + + if [ $result -eq 0 ] + then + # Break out the loop on success + # otherwise roll on round and keep looking for a match + break; + fi + done + + if [ $result -eq 0 ] + then + # Have we switched out of description mode? + if [ $in_description -eq 1 ] && [ "$expect" != "description" ] && [ "$expect" != "empty" ] && [ "$expect" != "comment" ] + then + # Yes, okay we need to backtrace one line and reanalyse + in_description=0; + i=$(( $i - $in_empty )); + + # Reset the empty counter + in_empty=0; + continue; + fi + + # Successful match, but on which line format + case $expect in + "header") + expecting="empty"; + + echo "$line" | grep -Eq "^\[ticket/[0-9]+\]$" && ( + ticket=$(echo "$line" | sed 's,\[ticket/\([0-9]*\)\].*,\1,'); + ) + ;; + "empty") + # Description might have empty lines as spacing + expecting="footer description"; + in_empty=$(($in_empty + 1)); + + if [ $in_description -eq 1 ] + then + expecting="$expecting empty"; + fi + ;; + "description") + expecting="description empty"; + in_description=1; + ;; + "footer") + expecting="footer eof"; + if [ "$tickets" = "" ] + then + tickets="$line"; + else + tickets="$tickets $line"; + fi + ;; + "comment") + # Comments should expect the same thing again + ;; + *) + echo "Unrecognised token $expect" >&2; + quit 254; + ;; + esac + + if [ "$expect" != "empty" ] + then + in_empty=0; + fi + + debug 3 "Now expecting: $expecting"; + else + # None of the expected line formats matched + # Guess we'll call it a day here then + echo "Syntax error on line $i:" >&2; + echo ">> $line" >&2; + echo -n "Expecting: " >&2; + echo "$expecting" | sed 's/ /, /g' >&2; + exit $err; + fi + + i=$(( $i + 1 )); +done + +# If EOF is expected exit cleanly +echo "$expecting" | grep -q "eof" || ( + # Unexpected EOF, error + echo "Unexpected EOF encountered" >&2; + quit $ERR_EOF; +) && ( + # Do post scan checks + if [ ! -z "$tickets" ] + then + # Check for duplicate tickets + dupes=$(echo "$tickets" | sed 's/ /\n/g' | sort | uniq -d); + + if [ ! -z "$dupes" ] + then + echo "The following tickets are repeated:" >&2; + echo "$dupes" | sed 's/ /\n/g;s/^/* /g' >&2; + quit $ERR_FOOTER; + fi + fi + # Check the branch ticket is mentioned, doesn't make sense otherwise + if [ $ticket -gt 0 ] + then + echo "$tickets" | grep -Eq "\bPHPBB3-$ticket\b" || ( + echo "Ticket ID [$ticket] of branch missing from list of tickets:" >&2; + echo "$tickets" | sed 's/ /\n/g;s/^/* /g' >&2; + quit $ERR_FOOTER; + ) || exit $?; + fi + # Got here okay exit to reality + exit 0; +); +exit $?; diff --git a/git-tools/hooks/install b/git-tools/hooks/install new file mode 100755 index 0000000000..a42c55a769 --- /dev/null +++ b/git-tools/hooks/install @@ -0,0 +1,17 @@ +#!/bin/sh +# +# Script to install the git hooks +# by symlinking them into the .git/hooks directory +# +# Usage (from within git-tools/hooks): +# ./install + +dir=$(dirname $0) + +for file in $(ls $dir) +do + if [ $file != "install" ] && [ $file != "uninstall" ] + then + ln -s "../../git-tools/hooks/$file" "$dir/../../.git/hooks/$file" + fi +done diff --git a/git-tools/hooks/pre-commit b/git-tools/hooks/pre-commit new file mode 100755 index 0000000000..4d03359773 --- /dev/null +++ b/git-tools/hooks/pre-commit @@ -0,0 +1,82 @@ +#!/bin/sh +# +# A hook to disallow php syntax errors to be committed +# by running php -l (lint) on them. It requires php-cli +# to be installed. +# +# This is a pre-commit hook. +# +# To install this you can either copy or symlink it to +# $GIT_DIR/hooks, example: +# +# ln -s ../../git-tools/hooks/pre-commit \\ +# .git/hooks/pre-commit + +# NOTE: this is run through /usr/bin/env +PHP_BIN=php + +# necessary check for initial commit +if git rev-parse --verify HEAD >/dev/null 2>&1 +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 +fi + +error=0 +errors="" + +if ! which $PHP_BIN >/dev/null 2>&1 +then + echo "PHP Syntax check failed:" + echo "PHP binary does not exist or is not in path: $PHP_BIN" + exit 1 +fi + +# dash does not support $'\n': +# http://forum.soft32.com/linux2/Bug-409179-DASH-Settings-IFS-work-properly-ftopict70039.html +IFS=' +' +# get a list of staged files +for line in $(git diff-index --cached --full-index $against) +do + # split needed values + sha=$(echo $line | cut -d' ' -f4) + temp=$(echo $line | cut -d' ' -f5) + status=$(echo $temp | cut -d' ' -f1) + filename=$(echo $temp | cut -d' ' -f2) + + # file extension + ext=$(echo $filename | sed 's/^.*\.//') + + # only check files with php extension + if [ $ext != "php" ] + then + continue + fi + + # do not check deleted files + if [ $status = "D" ] + then + continue + fi + + # check the staged file content for syntax errors + # using php -l (lint) + result=$(git cat-file -p $sha | /usr/bin/env $PHP_BIN -l 2>/dev/null) + if [ $? -ne 0 ] + then + error=1 + # Swap back in correct filenames + errors=$(echo "$errors"; echo "$result" |sed -e "s@in - on@in $filename on@g") + fi +done +unset IFS + +if [ $error -eq 1 ] +then + echo -e "PHP Syntax check failed:"; + echo -e "$errors" | grep "^Parse error:" + exit 1 +fi diff --git a/git-tools/hooks/prepare-commit-msg b/git-tools/hooks/prepare-commit-msg new file mode 100755 index 0000000000..2bf25e58a4 --- /dev/null +++ b/git-tools/hooks/prepare-commit-msg @@ -0,0 +1,42 @@ +#!/bin/sh +# +# A hook to add [$branch] to the beginning of a commit message +# if certain conditions are met. +# +# This is a prepare-commit-msg hook. +# +# To install this you can either copy or symlink it to +# $GIT_DIR/hooks, example: +# +# ln -s ../../git-tools/hooks/prepare-commit-msg \\ +# .git/hooks/prepare-commit-msg + +# get branch name +branch="$(git symbolic-ref HEAD)" + +# exit if no branch name is present +# (eg. detached HEAD) +if [ $? -ne 0 ] +then + exit +fi + +# strip off refs/heads/ +branch="$(echo "$branch" | sed "s/refs\/heads\///g")" + +# add [branchname] to commit message +# * only run when normal commit is made (without -m or -F; +# not a merge, etc.) +# * also make sure the branch name begins with bug/ or feature/ +if [ "$2" = "" ] +then + tail=""; + + # Branch is prefixed with 'ticket/', append ticket ID to message + if [ "$branch" != "${branch##ticket/}" ]; + then + tail="\n\nPHPBB3-${branch##ticket/}"; + fi + + echo "[$branch]$tail $(cat "$1")" > "$1" +fi diff --git a/git-tools/hooks/uninstall b/git-tools/hooks/uninstall new file mode 100755 index 0000000000..1b3b7fd2c9 --- /dev/null +++ b/git-tools/hooks/uninstall @@ -0,0 +1,16 @@ +#!/bin/sh +# +# Script to uninstall the git hooks +# +# Usage (from within git-tools/hooks): +# ./uninstall + +dir=$(dirname $0) + +for file in $(ls $dir) +do + if [ $file != "install" ] && [ $file != "uninstall" ] + then + rm -f "$dir/../../.git/hooks/$file" + fi +done diff --git a/phpBB/adm/index.php b/phpBB/adm/index.php index 26f934f6bf..92bcf90039 100644 --- a/phpBB/adm/index.php +++ b/phpBB/adm/index.php @@ -432,6 +432,20 @@ function validate_config_vars($config_vars, &$cfg_array, &$error) { $error[] = sprintf($user->lang['SETTING_TOO_BIG'], $user->lang[$config_definition['lang']], $validator[$max]); } + + if (strpos($config_name, '_max') !== false) + { + // Min/max pairs of settings should ensure that min <= max + // Replace _max with _min to find the name of the minimum + // corresponding configuration variable + $min_name = str_replace('_max', '_min', $config_name); + + if (isset($cfg_array[$min_name]) && is_numeric($cfg_array[$min_name]) && $cfg_array[$config_name] < $cfg_array[$min_name]) + { + // A minimum value exists and the maximum value is less than it + $error[] = sprintf($user->lang['SETTING_TOO_LOW'], $user->lang[$config_definition['lang']], (int) $cfg_array[$min_name]); + } + } break; // Absolute path @@ -533,7 +547,7 @@ function validate_config_vars($config_vars, &$cfg_array, &$error) // Check if the path is writable if ($config_definition['validate'] == 'wpath' || $config_definition['validate'] == 'rwpath') { - if (file_exists($phpbb_root_path . $cfg_array[$config_name]) && !@is_writable($phpbb_root_path . $cfg_array[$config_name])) + if (file_exists($phpbb_root_path . $cfg_array[$config_name]) && !phpbb_is_writable($phpbb_root_path . $cfg_array[$config_name])) { $error[] = sprintf($user->lang['DIRECTORY_NOT_WRITABLE'], $cfg_array[$config_name]); } diff --git a/phpBB/adm/style/acp_ban.html b/phpBB/adm/style/acp_ban.html index 539e8032dd..cf44f4aaa7 100644 --- a/phpBB/adm/style/acp_ban.html +++ b/phpBB/adm/style/acp_ban.html @@ -31,9 +31,9 @@ function display_details(option) { - document.getElementById('acp_unban').unbangivereason.value = ban_give_reason[option]; - document.getElementById('acp_unban').unbanreason.value = ban_reason[option]; - document.getElementById('acp_unban').unbanlength.value = ban_length[option]; + document.getElementById('acp_unban').unbangivereason.innerHTML = ban_give_reason[option]; + document.getElementById('acp_unban').unbanreason.innerHTML = ban_reason[option]; + document.getElementById('acp_unban').unbanlength.innerHTML = ban_length[option]; } // ]]> diff --git a/phpBB/adm/style/acp_forums.html b/phpBB/adm/style/acp_forums.html index 937a288cb2..9f9216a068 100644 --- a/phpBB/adm/style/acp_forums.html +++ b/phpBB/adm/style/acp_forums.html @@ -189,8 +189,8 @@ {L_GENERAL_FORUM_SETTINGS}

{L_DISPLAY_ACTIVE_TOPICS_EXPLAIN}
-
-
+
+
diff --git a/phpBB/adm/style/acp_update.html b/phpBB/adm/style/acp_update.html index 34d4f6934e..a87366a78b 100644 --- a/phpBB/adm/style/acp_update.html +++ b/phpBB/adm/style/acp_update.html @@ -18,6 +18,12 @@ + +
+

{UPGRADE_INSTRUCTIONS}

+
+ +
diff --git a/phpBB/adm/style/acp_users_overview.html b/phpBB/adm/style/acp_users_overview.html index d48cfa57be..911dcad293 100644 --- a/phpBB/adm/style/acp_users_overview.html +++ b/phpBB/adm/style/acp_users_overview.html @@ -140,7 +140,7 @@ {L_DELETE_USER}

{L_DELETE_USER_EXPLAIN}
-
+

@@ -148,6 +148,6 @@ {S_FORM_TOKEN}

- + diff --git a/phpBB/adm/style/acp_users_signature.html b/phpBB/adm/style/acp_users_signature.html index 0ea5328c3c..69c6d8f3fb 100644 --- a/phpBB/adm/style/acp_users_signature.html +++ b/phpBB/adm/style/acp_users_signature.html @@ -56,7 +56,7 @@ - + @@ -93,8 +93,8 @@ // ]]> -
-
+
+
@@ -105,7 +105,7 @@
-
{L_OPTIONS}: {BBCODE_STATUS} :: {IMG_STATUS} :: {FLASH_STATUS} :: {URL_STATUS} :: {SMILIES_STATUS}
+
{L_OPTIONS}: {BBCODE_STATUS} :: {IMG_STATUS} :: {FLASH_STATUS} :: {URL_STATUS} :: {SMILIES_STATUS}
diff --git a/phpBB/adm/style/admin.css b/phpBB/adm/style/admin.css index 5f1f01c0a9..4c3fa51af3 100644 --- a/phpBB/adm/style/admin.css +++ b/phpBB/adm/style/admin.css @@ -670,14 +670,10 @@ legend { position: relative; text-transform: none; line-height: 1.2em; - top: 0; + top: -.2em; vertical-align: middle; } -/* Hide from macIE \*/ -legend { top: -1.2em; } -/* end */ - * html legend { margin: 0 0 -10px -7px; line-height: 1em; diff --git a/phpBB/adm/style/captcha_recaptcha.html b/phpBB/adm/style/captcha_recaptcha.html index 702a4a1099..586c494868 100644 --- a/phpBB/adm/style/captcha_recaptcha.html +++ b/phpBB/adm/style/captcha_recaptcha.html @@ -4,7 +4,8 @@ diff --git a/phpBB/adm/style/editor.js b/phpBB/adm/style/editor.js index cd4e75f51f..217aa699e2 100644 --- a/phpBB/adm/style/editor.js +++ b/phpBB/adm/style/editor.js @@ -46,7 +46,11 @@ function initInsertions() { textarea.focus(); baseHeight = doc.selection.createRange().duplicate().boundingHeight; - // document.body.focus(); + + if (!document.forms[form_name]) + { + document.body.focus(); + } } } @@ -152,7 +156,7 @@ function insert_text(text, spaces, popup) var sel_start = textarea.selectionStart; var sel_end = textarea.selectionEnd; - mozWrap(textarea, text, '') + mozWrap(textarea, text, ''); textarea.selectionStart = sel_start + text.length; textarea.selectionEnd = sel_end + text.length; } @@ -230,6 +234,7 @@ function addquote(post_id, username) theSelection = theSelection.replace(/<\;/ig, '<'); theSelection = theSelection.replace(/>\;/ig, '>'); theSelection = theSelection.replace(/&\;/ig, '&'); + theSelection = theSelection.replace(/ \;/ig, ' '); } else if (document.all) { @@ -269,12 +274,12 @@ function mozWrap(txtarea, open, close) } var s1 = (txtarea.value).substring(0,selStart); - var s2 = (txtarea.value).substring(selStart, selEnd) + var s2 = (txtarea.value).substring(selStart, selEnd); var s3 = (txtarea.value).substring(selEnd, selLength); txtarea.value = s1 + open + s2 + close + s3; - txtarea.selectionStart = selEnd + open.length + close.length; - txtarea.selectionEnd = txtarea.selectionStart; + txtarea.selectionStart = selStart + open.length; + txtarea.selectionEnd = selEnd + open.length; txtarea.focus(); txtarea.scrollTop = scrollTop; @@ -327,8 +332,8 @@ function colorPalette(dir, width, height) for (b = 0; b < 5; b++) { color = String(numberList[r]) + String(numberList[g]) + String(numberList[b]); - document.write(''); - document.write('#' + color + ''); + document.write(''); + document.write('#' + color + ''); document.writeln(''); } diff --git a/phpBB/adm/style/install_update.html b/phpBB/adm/style/install_update.html index 4b89537acb..22d21d8314 100644 --- a/phpBB/adm/style/install_update.html +++ b/phpBB/adm/style/install_update.html @@ -200,7 +200,7 @@ {L_STATUS_UP_TO_DATE}
-
{up_to_date.FILENAME}
+
{up_to_date.FILENAME}
@@ -218,11 +218,11 @@
{new.DIR_PART}
{new.FILE_PART}

{L_FILE_USED}: {new.CUSTOM_ORIGINAL}
-
+
[{new.L_SHOW_DIFF}]{L_BINARY_FILE}
-
+
@@ -242,9 +242,9 @@
{not_modified.DIR_PART}
{not_modified.FILE_PART}

{L_FILE_USED}: {not_modified.CUSTOM_ORIGINAL}
-
[{not_modified.L_SHOW_DIFF}]{L_BINARY_FILE}
+
[{not_modified.L_SHOW_DIFF}]{L_BINARY_FILE}
-
+
@@ -263,22 +263,22 @@
{modified.DIR_PART}
{modified.FILE_PART}

{L_FILE_USED}: {modified.CUSTOM_ORIGINAL}
-
 
+
 
-
+
-
[{modified.L_SHOW_DIFF}]{L_BINARY_FILE}
+
[{modified.L_SHOW_DIFF}]{L_BINARY_FILE}
-
[{L_SHOW_DIFF_FINAL}] 
+
[{L_SHOW_DIFF_FINAL}] 
-
[{L_SHOW_DIFF_FINAL}] 
+
[{L_SHOW_DIFF_FINAL}] 
@@ -296,11 +296,11 @@
{new_conflict.DIR_PART}
{new_conflict.FILE_PART}

{L_FILE_USED}: {new_conflict.CUSTOM_ORIGINAL}
-
+
[{new_conflict.L_SHOW_DIFF}]{L_BINARY_FILE}
-
+
@@ -320,35 +320,35 @@
{L_FILE_USED}: {conflict.CUSTOM_ORIGINAL}
{L_NUM_CONFLICTS}: {conflict.NUM_CONFLICTS} -
+
[{L_DOWNLOAD_CONFLICTS}]
{L_DOWNLOAD_CONFLICTS_EXPLAIN} {L_BINARY_FILE}
-
+
-
 
+
 
-
[{L_SHOW_DIFF_MODIFIED}]
+
[{L_SHOW_DIFF_MODIFIED}]
-
[{L_SHOW_DIFF_MODIFIED}]
+
[{L_SHOW_DIFF_MODIFIED}]
-
[{L_SHOW_DIFF_FINAL}]
+
[{L_SHOW_DIFF_FINAL}]
-
[{L_SHOW_DIFF_FINAL}]
+
[{L_SHOW_DIFF_FINAL}]
diff --git a/phpBB/adm/style/permission_mask.html b/phpBB/adm/style/permission_mask.html index fb4d3ef143..e29609b8b6 100644 --- a/phpBB/adm/style/permission_mask.html +++ b/phpBB/adm/style/permission_mask.html @@ -40,7 +40,7 @@
-
+
{L_NO_ROLE_AVAILABLE}
@@ -118,7 +118,7 @@ -
+

{L_APPLY_PERMISSIONS_EXPLAIN}

diff --git a/phpBB/common.php b/phpBB/common.php index 9b6913e95f..c8b2fb9609 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -123,13 +123,11 @@ if (defined('IN_CRON')) $phpbb_root_path = dirname(__FILE__) . DIRECTORY_SEPARATOR; } -if (!file_exists($phpbb_root_path . 'config.' . $phpEx)) +if (file_exists($phpbb_root_path . 'config.' . $phpEx)) { - die("

The config.$phpEx file could not be found.

Click here to install phpBB

"); + require($phpbb_root_path . 'config.' . $phpEx); } -require($phpbb_root_path . 'config.' . $phpEx); - if (!defined('PHPBB_INSTALLED')) { // Redirect the user to the installer diff --git a/phpBB/config.php b/phpBB/config.php deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/phpBB/develop/check_flash_bbcodes.php b/phpBB/develop/check_flash_bbcodes.php new file mode 100644 index 0000000000..b0fa399209 --- /dev/null +++ b/phpBB/develop/check_flash_bbcodes.php @@ -0,0 +1,163 @@ + ''"; + + $result = $db->sql_query($sql); + while ($row = $db->sql_fetchrow($result)) + { + $uid = $row[$uid_field]; + + // thanks support toolkit + $content = html_entity_decode_utf8($row[$content_field]); + set_var($content, $content, 'string', true); + $content = utf8_normalize_nfc($content); + + $bitfield_data = $row[$bitfield_field]; + + if (!is_valid_flash_bbcode($content, $uid) && has_flash_enabled($bitfield_data)) + { + $ids[] = (int) $row[$id_field]; + } + } + $db->sql_freeresult($result); + + return $ids; +} + +function get_flash_regex($uid) +{ + return "#\[flash=([0-9]+),([0-9]+):$uid\](.*?)\[/flash:$uid\]#"; +} + +// extract all valid flash bbcodes +// check if the bbcode content is a valid URL for each match +function is_valid_flash_bbcode($cleaned_content, $uid) +{ + $regex = get_flash_regex($uid); + + $url_regex = get_preg_expression('url'); + $www_url_regex = get_preg_expression('www_url'); + + if (preg_match_all($regex, $cleaned_content, $matches)) + { + foreach ($matches[3] as $flash_url) + { + if (!preg_match("#^($url_regex|$www_url_regex)$#i", $flash_url)) + { + return false; + } + } + } + + return true; +} + +// check if a bitfield includes flash +// 11 = flash bit +function has_flash_enabled($bitfield_data) +{ + $bitfield = new bitfield($bitfield_data); + return $bitfield->get(11); +} + +// taken from support toolkit +function html_entity_decode_utf8($string) +{ + static $trans_tbl; + + // replace numeric entities + $string = preg_replace('~&#x([0-9a-f]+);~ei', 'code2utf8(hexdec("\\1"))', $string); + $string = preg_replace('~&#([0-9]+);~e', 'code2utf8(\\1)', $string); + + // replace literal entities + if (!isset($trans_tbl)) + { + $trans_tbl = array(); + + foreach (get_html_translation_table(HTML_ENTITIES) as $val=>$key) + $trans_tbl[$key] = utf8_encode($val); + } + return strtr($string, $trans_tbl); +} + +// taken from support toolkit +// Returns the utf string corresponding to the unicode value (from php.net, courtesy - romans@void.lv) +function code2utf8($num) +{ + if ($num < 128) return chr($num); + if ($num < 2048) return chr(($num >> 6) + 192) . chr(($num & 63) + 128); + if ($num < 65536) return chr(($num >> 12) + 224) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); + if ($num < 2097152) return chr(($num >> 18) + 240) . chr((($num >> 12) & 63) + 128) . chr((($num >> 6) & 63) + 128) . chr(($num & 63) + 128); + return ''; +} diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php index 03932bcc13..0515d801f2 100644 --- a/phpBB/develop/create_schema_files.php +++ b/phpBB/develop/create_schema_files.php @@ -266,7 +266,8 @@ foreach ($supported_dbms as $dbms) case 'mssql': $line = "/*\n\n \$I" . "d: $\n\n*/\n\n"; - $line .= "BEGIN TRANSACTION\nGO\n\n"; + // no need to do this, no transaction support for schema changes + //$line .= "BEGIN TRANSACTION\nGO\n\n"; break; case 'oracle': @@ -749,7 +750,8 @@ foreach ($supported_dbms as $dbms) switch ($dbms) { case 'mssql': - $line = "\nCOMMIT\nGO\n\n"; + // No need to do this, no transaction support for schema changes + //$line = "\nCOMMIT\nGO\n\n"; break; case 'sqlite': diff --git a/phpBB/develop/regex.php b/phpBB/develop/regex.php index 4498204b4a..8165ba1f21 100644 --- a/phpBB/develop/regex.php +++ b/phpBB/develop/regex.php @@ -18,14 +18,15 @@ $ls32 = "(?:$h16:$h16|$ipv4)"; $ipv6_construct = array( array(false, '', '{6}', $ls32), - array(false, '::', '{5}', $ls32), + array(false, '::', '{0,5}', "(?:$h16(?::$h16)?|$ipv4)"), array('', ':', '{4}', $ls32), array('{1,2}', ':', '{3}', $ls32), array('{1,3}', ':', '{2}', $ls32), array('{1,4}', ':', '', $ls32), array('{1,5}', ':', false, $ls32), array('{1,6}', ':', false, $h16), - array('{1,7}', ':', false, '') + array('{1,7}', ':', false, ''), + array(false, '::', false, '') ); $ipv6 = '(?:'; diff --git a/phpBB/develop/set_permissions.sh b/phpBB/develop/set_permissions.sh new file mode 100755 index 0000000000..879b94e518 --- /dev/null +++ b/phpBB/develop/set_permissions.sh @@ -0,0 +1,9 @@ +#!/bin/sh +# set permissions required for installation + +dir=$(dirname $0) + +for file in cache files store config.php images/avatars/upload +do + chmod a+w $dir/../$file +done diff --git a/phpBB/docs/AUTHORS b/phpBB/docs/AUTHORS index e886cd5a89..b3166313c3 100644 --- a/phpBB/docs/AUTHORS +++ b/phpBB/docs/AUTHORS @@ -26,17 +26,17 @@ phpBB Developers: A_Jelly_Doughnut (Josh Woody) Acyd Burn (Meik Sievertsen) [Lead 09/2005 - 01/2010] APTX (Marek A. R.) bantu (Andreas Fischer) - DavidMJ (David M.) dhn (Dominik Dröscher) + igorw (Igor Wiedler) kellanved (Henry Sudhof) + nickvergessen (Joas Schilling) + rxu (Ruslan Uzdenov) Terrafrost (Jim Wigginton) ToonArmy (Chris Smith) Contributions by: Brainy (Cullen Walsh) leviatan21 (Gabriel Vazquez) - nickvergessen (Joas Schilling) Raimon (Raimon Meuldijk) - rxu (Ruslan Uzdenov) Xore (Robert Hetzler) @@ -49,6 +49,7 @@ phpBB Lead Developer: psoTFX (Paul S. Owen) [2001 - 09/2005] phpBB Developers: Ashe (Ludovic Arnaud) [10/2002 - 11/2003, 06/2006 - 10/2006] BartVB (Bart van Bragt) [11/2000 - 03/2006] + DavidMJ (David M.) [12/2005 - 08/2009] GrahamJE (Graham Eames) [09/2005 - 11/2006] Vic D'Elfant (Vic D'Elfant) [04/2007 - 04/2009] diff --git a/phpBB/docs/CHANGELOG.html b/phpBB/docs/CHANGELOG.html index 1d5af06f4d..66915b18fa 100644 --- a/phpBB/docs/CHANGELOG.html +++ b/phpBB/docs/CHANGELOG.html @@ -53,6 +53,7 @@
  1. Changelog
      +
    1. Changes since 3.0.7-PL1
    2. Changes since 3.0.7
    3. Changes since 3.0.6
    4. Changes since 3.0.5
    5. @@ -88,13 +89,471 @@
      -

      1.i. Changes since 3.0.7

      +

      1.i. Changes since 3.0.7-PL1

      +

      Security +

      +
        +
      • [PHPBB3-9903] - Execute javascript in [flash=] BBCode +
      • +
      + +

      Bug +

      +
        +
      • [PHPBB3-4923] - compress_tar incorrectly determines type +
      • +
      • [PHPBB3-5164] - Honor minimum and maximum password length in generated passwords as much as possible. +
      • +
      • [PHPBB3-6726] - Connecting to PostgreSQL using 'localhost' doesn't try to use a TCP connection +
      • +
      • [PHPBB3-6747] - word censoring * does not handle space for two or more words +
      • +
      • [PHPBB3-7260] - Do not delete polls if one exists and editing user lacks permissions +
      • +
      • [PHPBB3-7296] - Style export to tar(.*) does not work +
      • +
      • [PHPBB3-7369] - Custom Profile dates display incorrectly +
      • +
      • [PHPBB3-7417] - Search keywords field does not initially get focus +
      • +
      • [PHPBB3-7538] - Query exceeds maximum value for user_login_attempts +
      • +
      • [PHPBB3-7716] - Data too long for column 'message_subject' +
      • +
      • [PHPBB3-7720] - Fix alternative image-description for unread posts. +
      • +
      • [PHPBB3-7782] - Send HTTP 404 if topic, forum or user do not exist +
      • +
      • [PHPBB3-7972] - Copied topics are not indexed +
      • +
      • [PHPBB3-8169] - Parse CSS Regex accepts invalid code +
      • +
      • [PHPBB3-8792] - Misleading error message in auth_ldap.php, function init_ldap() +
      • +
      • [PHPBB3-8894] - JavaScript error and visible quote button on topic review if BBCodes disallowed +
      • +
      • [PHPBB3-8924] - spelling in admin_welcome_inactive.txt +
      • +
      • [PHPBB3-8929] - MS SQL error on view all smilies after 3.0.6 upgrade +
      • +
      • [PHPBB3-8935] - able to set minimal avatar size larger than maximum +
      • +
      • [PHPBB3-8944] - Error on database update (must specify size of index on MySQL4) +
      • +
      • [PHPBB3-9012] - Retain original topic title in shadow topic when moving a topic and editing the title. +
      • +
      • [PHPBB3-9034] - Redirect() fails with directory traversal +
      • +
      • [PHPBB3-9047] - Active topics and reported posts +
      • +
      • [PHPBB3-9049] - Password reminder system generates confusable passwords +
      • +
      • [PHPBB3-9053] - Correctly sort database backup file list by date on database restore page +
      • +
      • [PHPBB3-9061] - Race condition in queue locking +
      • +
      • [PHPBB3-9068] - Grammatical Error under Load Settings +
      • +
      • [PHPBB3-9075] - Missing / bad default values of CPFs result in SQL errors on registration of new users +
      • +
      • [PHPBB3-9091] - Wrong IP checking for IPv4 addresses mapped into IPv6 +
      • +
      • [PHPBB3-9094] - Hide "Copy permissions" message, when permissions were copied. +
      • +
      • [PHPBB3-9095] - Misleading setting text for CAPTCHA +
      • +
      • [PHPBB3-9099] - Missing comma in PASSWORD_EXPLAIN acp language strings +
      • +
      • [PHPBB3-9101] - Bad text placement for reCAPTCHA description +
      • +
      • [PHPBB3-9104] - Safari does not display box headers correctly in the ACP. +
      • +
      • [PHPBB3-9107] - Can't Set Parent Forum +
      • +
      • [PHPBB3-9108] - RSS feeds does not work on Postgres +
      • +
      • [PHPBB3-9112] - Most active forum post count does not respect m_approve permission +
      • +
      • [PHPBB3-9114] - Recent bug fix for smilies causing problems on older MySQL versions +
      • +
      • [PHPBB3-9117] - Wrong redirection after login +
      • +
      • [PHPBB3-9119] - Language selection is disregarded in automatic update +
      • +
      • [PHPBB3-9120] - Typo fix in a comment in functions.php +
      • +
      • [PHPBB3-9121] - Forum feed shows posts that are currently on the moderation queue +
      • +
      • [PHPBB3-9125] - ACP User Overview: Unmatched </form> tag when viewing own user +
      • +
      • [PHPBB3-9126] - Invalid redirection after login to forum not in web root +
      • +
      • [PHPBB3-9132] - Oracle CLOB support is broken, preventing storage of long strings +
      • +
      • [PHPBB3-9135] - Fix report-icon for moderators in PM folders. +
      • +
      • [PHPBB3-9140] - Check current board version in incremental update packages +
      • +
      • [PHPBB3-9145] - Fix open_basedir issues when accessing styles- and language-management +
      • +
      • [PHPBB3-9146] - Quick-Reply tabindex="6" set twice +
      • +
      • [PHPBB3-9147] - "Change topic type"-option "Normal" always selected. +
      • +
      • [PHPBB3-9154] - Correctly check for double inclusion in captcha garbage collection +
      • +
      • [PHPBB3-9158] - viewforum/viewtopic pages unnecessarily duplicated with start=0 +
      • +
      • [PHPBB3-9162] - BBCode in poll options is broken, when posting without question. +
      • +
      • [PHPBB3-9167] - Remove shadow topics from remaining forums when deleting a forum including posts +
      • +
      • [PHPBB3-9170] - Unable to get image size in img bbcode when URL has multiple parameters. +
      • +
      • [PHPBB3-9173] - sql_config_count() artificially limits number scope to 4byte-integer on PostgreSQL and Firebird +
      • +
      • [PHPBB3-9176] - When setting the board's date format the board's timezone settings aren't taken into account +
      • +
      • [PHPBB3-9451] - Unnecessary overhead in avatar_process_user function +
      • +
      • [PHPBB3-9478] - Validate maximum number of allowed recipients per PM value +
      • +
      • [PHPBB3-9495] - Loginbox <input /> redirect breaks xHTML +
      • +
      • [PHPBB3-9499] - Javascript function dE does not correctly detect element visibility +
      • +
      • [PHPBB3-9504] - Allow gallery avatars with whitespaces in the filename +
      • +
      • [PHPBB3-9509] - phpBB Coding Guidelines state subversion as the version control system for phpBB +
      • +
      • [PHPBB3-9510] - Unable to copy permissions from and to forums you cannot see +
      • +
      • [PHPBB3-9512] - Fix dead link in MCP on reports for global announcements in prosilver. +
      • +
      • [PHPBB3-9514] - Correctly delete big datasets when deleting a forum including topics/posts on non-MySQL databases +
      • +
      • [PHPBB3-9518] - Postgres DBAL does not correctly create a new database connection when passing $new_link as true +
      • +
      • [PHPBB3-9519] - Replace remaining is_writable() calls with phpbb_is_writable(). +
      • +
      • [PHPBB3-9521] - MSSQL error reporting returns String instead of an error +
      • +
      • [PHPBB3-9524] - IPv6 regular expression does not match addresses starting in :: +
      • +
      • [PHPBB3-9526] - User Preference to hide online status does not work for bots +
      • +
      • [PHPBB3-9528] - Quoting in a PM does not fall back to bbcode-less quotes using "> " when bbcodes are disabled +
      • +
      • [PHPBB3-9529] - Topic review does not display all selected posts +
      • +
      • [PHPBB3-9530] - subsilver2 missing fallback option on quoting when bbcodes are disabled +
      • +
      • [PHPBB3-9531] - BBCode-less fall back option for quotes is missing "Author wrote:" line when quoting from topic-review. +
      • +
      • [PHPBB3-9535] - Incorrect margins in RTL languages: signatures, permission ACP & updater +
      • +
      • [PHPBB3-9545] - 'Your first forum' should have 'Display active topics:' set to 'Yes' +
      • +
      • [PHPBB3-9546] - Moving all posts from one topic to another does not delete bookmarks +
      • +
      • [PHPBB3-9547] - Changing forum type applies FORUM_FLAG_ACTIVE_TOPICS to new forum type. +
      • +
      • [PHPBB3-9548] - Delete user quicktool drop down should have an empty or invalid selection as the default +
      • +
      • [PHPBB3-9559] - Messenger Queue Batch Size configuration option is overridden +
      • +
      • [PHPBB3-9567] - Newly registered users group ACP wording +
      • +
      • [PHPBB3-9582] - Missing MSSQL native driver case statements +
      • +
      • [PHPBB3-9587] - Prosilver overrides reCaptcha class. +
      • +
      • [PHPBB3-9592] - Test suite does not run on SQLite +
      • +
      • [PHPBB3-9593] - Missing documentation for running unit tests +
      • +
      • [PHPBB3-9599] - Windows workaround for checkdnsrr() returns wrong results +
      • +
      • [PHPBB3-9605] - Wrong class added to topiclist, when there's no announcement topic. +
      • +
      • [PHPBB3-9615] - When attaching a file whose name contains quotes, filename before last quote is cut off in display +
      • +
      • [PHPBB3-9623] - Strings not properly normalized - acp_prune.php +
      • +
      • [PHPBB3-9626] - Regular expressions from get_preg_expression() are untested. +
      • +
      • [PHPBB3-9628] - Add module function does not correctly insert a module after the specified one +
      • +
      • [PHPBB3-9633] - Newly registered users group color is not used in Our Newest Member +
      • +
      • [PHPBB3-9635] - Useless parameter $data['post_time'] in function submit_post. +
      • +
      • [PHPBB3-9637] - SET NAMES 'BINARY' error in convertor +
      • +
      • [PHPBB3-9643] - DB connection error when $dbhost is an IPv6 address +
      • +
      • [PHPBB3-9644] - submit_post shows support for options that cause a trigger_error in the call to user_notification +
      • +
      • [PHPBB3-9646] - Cant hide/outcomment @import in stylesheet.css +
      • +
      • [PHPBB3-9650] - It should not be possible to ban Anonymous +
      • +
      • [PHPBB3-9653] - xhtml errors in subsilver2 when using the bbcodes code and quote in signatures +
      • +
      • [PHPBB3-9655] - Selecting an unavailable captcha plugin looks like a successful action +
      • +
      • [PHPBB3-9656] - PHP Information in ACP always lists error_reporting as 0 +
      • +
      • [PHPBB3-9658] - Optimize topic splitting +
      • +
      • [PHPBB3-9662] - Search interval applied inconsistently +
      • +
      • [PHPBB3-9664] - Another duplicate accesskey: t = top and list item +
      • +
      • [PHPBB3-9665] - Signature "0" cannot be previewed +
      • +
      • [PHPBB3-9677] - Subsilver2 is missing the bbcode-helpline for inline-attachments. +
      • +
      • [PHPBB3-9678] - Flash attachments are not displayed in subsilver2. +
      • +
      • [PHPBB3-9679] - "Notify User" checkbox appears in MCP Queue even if no notification methods are enabled +
      • +
      • [PHPBB3-9686] - Unable to create data backup using the mssqlnative DBAL +
      • +
      • [PHPBB3-9694] - Calling download/file.php with empty avatar parameter can throw an E_NOTICE message +
      • +
      • [PHPBB3-9695] - Bad Display of User Input - mcp_ban +
      • +
      • [PHPBB3-9696] - Installation of phpBB with SQLite fails +
      • +
      • [PHPBB3-9697] - Backlink broken when the select parent forum does not exist. +
      • +
      • [PHPBB3-9698] - Returning result of new by reference is deprecated in php 5.3 +
      • +
      • [PHPBB3-9702] - "Ban until (date)" appears to be based on UTC time instead of local time +
      • +
      • [PHPBB3-9703] - Removing a user does not remove their private message folders or rules +
      • +
      • [PHPBB3-9704] - Coding guidelines typo +
      • +
      • [PHPBB3-9712] - Future dates display as "less than one minute ago" +
      • +
      • [PHPBB3-9714] - "Undefined variable: email" in email regular expression unit tests +
      • +
      • [PHPBB3-9715] - Fix email address regular expression or adjust email regular expression unit tests +
      • +
      • [PHPBB3-9722] - "New Topic" button title attribute mismatch in prosilver's viewforum +
      • +
      • [PHPBB3-9727] - Feed replaces ./ with board URL +
      • +
      • [PHPBB3-9743] - Fix background-position of top2-class in prosilver for RTL-languages. +
      • +
      • [PHPBB3-9744] - Mistyped word 'then' in FAQ. It should be 'than'. +
      • +
      • [PHPBB3-9748] - <br /> not being replaced in prepare_message +
      • +
      • [PHPBB3-9749] - fulltext_mysql.php overreacts on + and - characters in search words +
      • +
      • [PHPBB3-9752] - Misleading text when using Q&A CAPTCHA +
      • +
      • [PHPBB3-9754] - Template variable S_USER_POSTED always set to false in search.php +
      • +
      • [PHPBB3-9757] - Empty template variable HISTORY_TITLE in ucp_pm_history +
      • +
      • [PHPBB3-9760] - Fulltext native search, wildcard * does not get escaped leading to long execution time +
      • +
      • [PHPBB3-9761] - Quote nesting depth explanation is misleading +
      • +
      • [PHPBB3-9771] - build_url() doesn't ignore empty parameters +
      • +
      • [PHPBB3-9772] - Under some circumstances, email addresses are shown to undesired users +
      • +
      • [PHPBB3-9780] - gen_rand_string() not respecting $num_chars parameter anymore. +
      • +
      • [PHPBB3-9782] - Board disable radio in Board-Settings set on when server load high +
      • +
      • [PHPBB3-9793] - Undefined function send_status_line() in download/file.php when in avatar mode. +
      • +
      • [PHPBB3-9807] - Avatar tab displays when avatars are disabled +
      • +
      • [PHPBB3-9810] - Clicking on "Select All" of code tag on print page results in a javascript error when using prosilver +
      • +
      • [PHPBB3-9820] - Fix undefined indexes when trying to post a new topic +
      • +
      • [PHPBB3-9822] - Can not delete style-components from the file-system as per explanation. +
      • +
      • [PHPBB3-9829] - Recaptcha plugin result interpretation fault +
      • +
      • [PHPBB3-9835] - Login Confirm Explain Not Working +
      • +
      • [PHPBB3-9840] - Display view unread posts link for guests +
      • +
      • [PHPBB3-9841] - Change "Save" button to "Save draft" +
      • +
      • [PHPBB3-9847] - Language typo and written form (British/American) +
      • +
      • [PHPBB3-9854] - Auth API documentation is incomplete +
      • +
      • [PHPBB3-9855] - Tests don't run on PHPUnit 3.5 +
      • +
      • [PHPBB3-9879] - captcha_qa.php spelling, punctuation and grammar errors +
      • +
      • [PHPBB3-9883] - CAPTCHA uses american english +
      • +
      • [PHPBB3-9884] - Massive email delays +
      • +
      • [PHPBB3-9885] - Default file extension groups not properly updated by database updater. +
      • +
      • [PHPBB3-9886] - Database updater does not run on PostgreSQL because of an error in _add_module() +
      • +
      • [PHPBB3-9888] - Update fails when Bing [Bot] was already added to the users table +
      • +
      • [PHPBB3-9891] - Updater drops language-selection after database-update +
      • +
      • [PHPBB3-9509] - phpBB Coding Guidelines state subversion as the version control system for phpBB +
      • +
      + +

      Improvement +

      +
        +
      • [PHPBB3-7332] - MCP post details usability +
      • +
      • [PHPBB3-7717] - Use user's language for standard-extensions-group name +
      • +
      • [PHPBB3-8709] - Multibyte keys in request_var not possible +
      • +
      • [PHPBB3-8936] - subsilver2 missing reply-to-all feature +
      • +
      • [PHPBB3-9088] - Add missing semicolons in js files +
      • +
      • [PHPBB3-9179] - improve quasi-documentation of notify_status values +
      • +
      • [PHPBB3-9503] - Posts with empty titles in moderation queue are not easily approved +
      • +
      • [PHPBB3-9534] - user_ipwhois() does not support IPv6 addresses +
      • +
      • [PHPBB3-9536] - Small improvement for query against sessions table in acp_users.php +
      • +
      • [PHPBB3-9553] - Make git hooks run with /bin/sh instead of bash +
      • +
      • [PHPBB3-9570] - Change "system timezone" to "guest timezone" in acp, add explanation +
      • +
      • [PHPBB3-9578] - ACP Posting tab is missing "Post settings" module. +
      • +
      • [PHPBB3-9589] - Sample nginx configuration file +
      • +
      • [PHPBB3-9595] - Search settings in ACP: Add information on minimum word size indexed when using Fulltext MySQL backend +
      • +
      • [PHPBB3-9598] - Call checkdnsrr() on Windows with PHP 5.3 +
      • +
      • [PHPBB3-9609] - Use send_status_line instead of calling header +
      • +
      • [PHPBB3-9611] - Increase entropy in activation keys +
      • +
      • [PHPBB3-9612] - Split gen_rand_string() into gen_rand_string() and gen_rand_string_friendly() +
      • +
      • [PHPBB3-9629] - sid parameter forced for style.php makes caching difficult +
      • +
      • [PHPBB3-9659] - Default phpBB signature user_options need to be set for convertors +
      • +
      • [PHPBB3-9690] - MSN Bot will become Bing Bot +
      • +
      • [PHPBB3-9777] - Print useful error message in pre-commit hook when php is not installed. +
      • +
      • [PHPBB3-9785] - Not able to recover a password when board disabled +
      • +
      • [PHPBB3-9825] - Run tests on sqlite if available and no test db configured +
      • +
      • [PHPBB3-9827] - IE9 Beta fixes IE8 textarea bug +
      • +
      • [PHPBB3-9830] - Awkward message when config.php is missing +
      • +
      • [PHPBB3-9850] - Allow version checker to display information on multiple releases +
      • +
      • [PHPBB3-9853] - Change default reCAPTCHA theme in Prosilver & Subsilver2 to better coordinate with style color scheme +
      • +
      • [PHPBB3-9880] - Rename all mentions of CAPTCHA or visual confirmation to anti-bot +
      • +
      • [PHPBB3-9899] - Change the style in the ACP for the recaptcha to match that displayed on prosilver +
      • +
      + +

      New Feature +

      +
        +
      • [PHPBB3-9039] - Native SQL Server Support mssqlnative.php +
      • +
      • [PHPBB3-9511] - View note for moderators on unapproved posts/topics with unapproved posts in ATOM Feed. +
      • +
      + +

      Task +

      +
        +
      • [PHPBB3-9520] - Add web.config files for IIS +
      • +
      • [PHPBB3-9625] - Update database UNIT-test +
      • +
      • [PHPBB3-9701] - Enable notices in unit tests +
      • +
      • [PHPBB3-9768] - Create git commit-msg hook that verifies the commit message conforms to our standards +
      • +
      • [PHPBB3-9769] - Add install and uninstall scripts for the git hooks +
      • +
      • [PHPBB3-9770] - Git commit message should be prefilled with branch and ticket information +
      • +
      • [PHPBB3-9800] - Update tracker URL in docs/README.html +
      • +
      • [PHPBB3-9804] - Update docs/AUTHORS (DavidMJ & igorw) +
      • +
      • [PHPBB3-9808] - Git commit message hook depends on GNU wc +
      • +
      • [PHPBB3-9816] - Remove config.php from git repository +
      • +
      • [PHPBB3-9848] - Add phpBB data files to .gitignore. +
      • +
      • [PHPBB3-9849] - Create build script using phing +
      • +
      • [PHPBB3-9857] - Remove visible $Id$ from docs files. +
      • +
      • [PHPBB3-9868] - Make the test suite run and pass using the mssqlnative driver +
      • +
      • [PHPBB3-9904] - Update WebPI Parameters.xml +
      • +
      + +

      Sub-task +

      +
        +
      • [PHPBB3-9517] - Remote avatar upload does not check the filesize before and during transfer. +
      • +
      • [PHPBB3-9562] - Advanced Search is inaccessible using the mssqlnative DBAL +
      • +
      • [PHPBB3-9564] - Reported messages are not assigned the default report reason when a reason is removed from the ACP using the mssqlnative DBAL +
      • +
      • [PHPBB3-9565] - It is impossible to create a custom profile field using the mssqlnative DBAL +
      • +
      • [PHPBB3-9566] - Two debug notices are displayed when setting a custom profile field though the UCP using the mssqlnative DBAL +
      • +
      • [PHPBB3-9583] - MSSQL native backups cannot be restored +
      • +
      • [PHPBB3-9606] - Drop redundant SQL query for unreads fetching +
      • +
      • [PHPBB3-9613] - Implement a load switch for unreads search feature. +
      • +
      • [PHPBB3-9817] - Make build script create blank config.php +
      • +
      + + +

      1.ii. Changes since 3.0.7

      • [Sec] Do not expose forum content of forums with ACL entries but no actual permission in ATOM Feeds. (Bug #58595)
      -

      1.ii. Changes since 3.0.6

      +

      1.iii. Changes since 3.0.6

      • [Fix] Allow ban reason and length to be selected and copied in ACP and subsilver2 MCP. (Bug #51095)
      • @@ -198,7 +657,7 @@
      -

      1.ii. Changes since 3.0.5

      +

      1.iv. Changes since 3.0.5

      • [Fix] Allow whitespaces in avatar gallery names. (Bug #44955)
      • @@ -420,7 +879,7 @@
      • [Feature] Send anonymous statistical information to phpBB on installation and update (optional).
      -

      1.iii. Changes since 3.0.4

      +

      1.v. Changes since 3.0.4

      • [Fix] Delete user entry from ban list table upon user deletion (Bug #40015 - Patch by TerraFrost)
      • @@ -509,7 +968,7 @@
      • [Sec] Only use forum id supplied for posting if global announcement detected. (Reported by nickvergessen)
      -

      1.iv. Changes since 3.0.3

      +

      1.vi. Changes since 3.0.3

      • [Fix] Allow mixed-case template directories to be inherited (Bug #36725)
      • @@ -541,7 +1000,7 @@
      • [Sec] Ask for forum password if post within passworded forum quoted in private message. (Reported by nickvergessen)
      -

      1.v. Changes since 3.0.2

      +

      1.vii. Changes since 3.0.2

      • [Fix] Correctly set topic starter if first post in topic removed (Bug #30575 - Patch by blueray2048)
      • @@ -640,7 +1099,7 @@
      • [Sec Precaution] Stricter validation of the HTTP_HOST header (Thanks to Techie-Micheal et al for pointing out possible issues in derived code)
      -

      1.vi. Changes since 3.0.1

      +

      1.viii. Changes since 3.0.1

      • [Fix] Ability to set permissions on non-mysql dbms (Bug #24955)
      • @@ -688,7 +1147,7 @@
      • [Sec] Only allow urls gone through redirect() being used within login_box(). (thanks nookieman)
      -

      1.vii Changes since 3.0.0

      +

      1.ix Changes since 3.0.0

      • [Change] Validate birthdays (Bug #15004)
      • @@ -759,7 +1218,7 @@
      • [Fix] Find and display colliding usernames correctly when converting from one database to another (Bug #23925)
      -

      1.viii. Changes since 3.0.RC8

      +

      1.x. Changes since 3.0.RC8

      • [Fix] Cleaned usernames contain only single spaces, so "a_name" and "a__name" are treated as the same name (Bug #15634)
      • @@ -768,7 +1227,7 @@
      • [Fix] Call garbage_collection() within database updater to correctly close connections (affects Oracle for example)
      -

      1.ix. Changes since 3.0.RC7

      +

      1.xi. Changes since 3.0.RC7

      • [Fix] Fixed MSSQL related bug in the update system
      • @@ -803,7 +1262,7 @@
      • [Fix] No duplication of active topics (Bug #15474)
      -

      1.x. Changes since 3.0.RC6

      +

      1.xii. Changes since 3.0.RC6

      • [Fix] Submitting language changes using acp_language (Bug #14736)
      • @@ -813,7 +1272,7 @@
      • [Fix] Able to request new password (Bug #14743)
      -

      1.xi. Changes since 3.0.RC5

      +

      1.xiii. Changes since 3.0.RC5

      • [Feature] Removing constant PHPBB_EMBEDDED in favor of using an exit_handler(); the constant was meant to achive this more or less.
      • @@ -876,7 +1335,7 @@
      • [Sec] New password hashing mechanism for storing passwords (#i42)
      -

      1.xii. Changes since 3.0.RC4

      +

      1.xiv. Changes since 3.0.RC4

      • [Fix] MySQL, PostgreSQL and SQLite related database fixes (Bug #13862)
      • @@ -927,7 +1386,7 @@
      • [Fix] odbc_autocommit causing existing result sets to be dropped (Bug #14182)
      -

      1.xiii. Changes since 3.0.RC3

      +

      1.xv. Changes since 3.0.RC3

      • [Fix] Fixing some subsilver2 and prosilver style issues
      • @@ -1036,7 +1495,7 @@
      -

      1.xiv. Changes since 3.0.RC2

      +

      1.xvi. Changes since 3.0.RC2

      • [Fix] Re-allow searching within the memberlist
      • @@ -1082,7 +1541,7 @@
      -

      1.xv. Changes since 3.0.RC1

      +

      1.xvii. Changes since 3.0.RC1

      • [Fix] (X)HTML issues within the templates (Bug #11255, #11255)
      • diff --git a/phpBB/docs/INSTALL.html b/phpBB/docs/INSTALL.html index 982c28571e..5857163759 100644 --- a/phpBB/docs/INSTALL.html +++ b/phpBB/docs/INSTALL.html @@ -273,7 +273,7 @@

        This package is meant for those wanting to only replace changed files from a previous version to the latest version. This package normally contains the changed files from up to five previous versions.

        -

        This package contains a number of archives, each contains the files changed from a given release to the latest version. You should select the appropriate archive for your current version, e.g. if you currently have 3.0.6 you should select the phpBB-3.0.6_to_3.0.7-PL1.zip/tar.gz file.

        +

        This package contains a number of archives, each contains the files changed from a given release to the latest version. You should select the appropriate archive for your current version, e.g. if you currently have 3.0.7-PL1 you should select the phpBB-3.0.7-PL1_to_3.0.8.zip/tar.gz file.

        The directory structure has been preserved enabling you (if you wish) to simply upload the contents of the archive to the appropriate location on your server, i.e. simply overwrite the existing files with the new versions. Do not forget that if you have installed any MODs these files will overwrite the originals possibly destroying them in the process. You will need to re-add MODs to any affected file before uploading.

        @@ -285,7 +285,7 @@

        The patch file is one solution for those with many Modifications (MODs) or other changes who do not want to re-add them back to all the changed files if they use the method explained above. To use this you will need command line access to a standard UNIX type patch application. If you do not have access to such an application but still want to use this update approach, we strongly recommend the Automatic update package explained below. It is also the recommended update method.

        -

        A number of patch files are provided to allow you to update from previous stable releases. Select the correct patch, e.g. if your current version is 3.0.5 you need the phpBB-3.0.6_to_3.0.7-PL1.patch file. Place the correct patch in the parent directory containing the phpBB3 core files (i.e. index.php, viewforum.php, etc.). With this done you should run the following command: patch -cl -d [PHPBB DIRECTORY] -p1 < [PATCH NAME] (where PHPBB DIRECTORY is the directory name your phpBB Installation resides in, for example phpBB3, and where PATCH NAME is the relevant filename of the selected patch file). This should complete quickly, hopefully without any HUNK FAILED comments.

        +

        A number of patch files are provided to allow you to update from previous stable releases. Select the correct patch, e.g. if your current version is 3.0.5 you need the phpBB-3.0.7-PL1_to_3.0.8.patch file. Place the correct patch in the parent directory containing the phpBB3 core files (i.e. index.php, viewforum.php, etc.). With this done you should run the following command: patch -cl -d [PHPBB DIRECTORY] -p1 < [PATCH NAME] (where PHPBB DIRECTORY is the directory name your phpBB Installation resides in, for example phpBB3, and where PATCH NAME is the relevant filename of the selected patch file). This should complete quickly, hopefully without any HUNK FAILED comments.

        If you do get failures you should look at using the Changed files only package to replace the files which failed to patch, please note that you will need to manually re-add any Modifications (MODs) to these particular files. Alternatively if you know how you can examine the .rej files to determine what failed where and make manual adjustments to the relevant source.

        diff --git a/phpBB/docs/README.html b/phpBB/docs/README.html index 3510bc448e..bb88fdc01f 100644 --- a/phpBB/docs/README.html +++ b/phpBB/docs/README.html @@ -242,7 +242,7 @@

        The phpBB Group uses a bug tracking system to store, list and manage all reported bugs, it can be found at the location listed below. Please DO NOT post bug reports to our forums, they will be locked. In addition please DO NOT use the bug tracker for support requests. Posting such a request will only see you directed to the support forums (while taking time away from working on real bugs).

        -

        http://www.phpbb.com/bugs/

        +

        http://tracker.phpbb.com/

        While we very much appreciate receiving bug reports (the more reports the more stable phpBB will be) we ask you carry out a few steps before adding new entries:

        diff --git a/phpBB/docs/auth_api.html b/phpBB/docs/auth_api.html index c83aaadc2d..8973582bdb 100644 --- a/phpBB/docs/auth_api.html +++ b/phpBB/docs/auth_api.html @@ -61,6 +61,9 @@
      • acl_getf
      • acl_getf_global
      • acl_cache
      • +
      • acl_clear_prefetch
      • +
      • acl_get_list
      • +
      • Miscellaneous
  2. Admin related functions
  3. @@ -176,7 +179,7 @@ array(forum_id1 => array(option => integer), This method is used to find out whether a user has a permission in at least one forum or globally. This method is similar to checking whether acl_getf(option, true) returned one or more forums but it's faster. It should be called in the following way:

    -$result = acl_getf_global(option)
    +$result = $auth->acl_getf_global(option)
     	

    As with the previous methods option is a string specifying the permission which has to be checked.

    @@ -187,6 +190,49 @@ $result = acl_getf_global(option)

    This should be considered a private method and not be called externally. It handles the generation of the user_permissions data from the basic user and group authorisation data. When necessary this method is called automatically by acl.

    +

    2.vii. acl_clear_prefetch

    + +

    This method clears the user_permissions column in the users table for the given user. If the user ID passed is zero, the permissions cache is cleared for all users. This method should be called whenever permissions are set.

    + +
    +// clear stored permissions for user 2
    +$user_id = 2;
    +$auth->acl_clear_prefetch($user_id);
    +
    + +

    This method returns void.

    + +

    2.viii. acl_get_list

    + +

    This method returns an an array describing which users have permissions in given fora. The resultant array contains an entry for permission that every user has in every forum when no arguments are passed.

    + +
    +$user_id = array(2, 53);
    +$permissions = array('f_list', 'f_read');
    +$forum_id = array(1, 2, 3);
    +$result = $auth->acl_get_list($user_id, $permissions, $forum_id);
    +
    + +

    The parameters may be of the following legal types:

    +
      +
    • $user_id: false, int, array(int, int, int, ...)
    • +
    • $permissions: false, string, array(string, string, ...)
    • +
    • $forum_id: false, int, array(int, int, int, ...)
    • +
    + +

    2.ix. Miscellaneous

    + +

    There are other methods defined in the auth class which serve mostly as private methods, but are available for use if needed. Each of them is used to pull data directly from the database tables. They are:

    +
      +
    • function acl_group_raw_data($group_id = false, $opts = false, $forum_id = false)
    • +
    • function acl_user_raw_data($user_id = false, $opts = false, $forum_id = false)
    • +
    • function acl_raw_data_single_user($user_id)
    • +
    • function acl_raw_data($user_id = false, $opts = false, $forum_id = false)
    • +
    • function acl_role_data($user_type, $role_type, $ug_id = false, $forum_id = false)
    • +
    + +

    Of these, acl_raw_data is the most general, but the others will be faster if you need a smaller amount of data.

    + @@ -241,7 +287,7 @@ $auth_admin = new auth_admin(); diff --git a/phpBB/docs/coding-guidelines.html b/phpBB/docs/coding-guidelines.html index 7f747e09e2..5a73554741 100644 --- a/phpBB/docs/coding-guidelines.html +++ b/phpBB/docs/coding-guidelines.html @@ -90,10 +90,9 @@
  4. VCS Guidelines
    1. Repository structure
    2. -
    3. Commit messages
    4. +
    5. Commit Messages and Repository Rules
  5. -
  6. Guidelines Changelog
  7. Copyright and disclaimer
@@ -288,7 +287,7 @@ PHPBB_QA (Set board to QA-Mode, which means the updater also c
-

Please note that these Guidelines applies to all php, html, javascript and css files.

+

Please note that these guidelines apply to all php, html, javascript and css files.

2.i. Variable/Function Naming

@@ -2326,126 +2325,33 @@ if (utf8_case_fold_nfc($string1) == utf8_case_fold_nfc($string2))
-

The version control system for phpBB3 is subversion. The repository is available at http://code.phpbb.com/svn/phpbb.

+

The version control system for phpBB3 is git. The repository is available at http://github.com/phpbb/phpbb3.

7.i. Repository Structure

    -
  • trunk
    The latest unstable development version with new features etc. Contains the actual board in /trunk/phpBB
  • -
  • branches
    Development branches of stable phpBB releases. Copied from /trunk at the time of release. +
  • develop
    The latest unstable development version with new features etc.
  • +
  • develop-*
    Development branches of stable phpBB releases. Branched off of develop at the time of feature freeze.
      -
    • phpBB3.0/branches/phpBB-3_0_0/phpBB
      Development branch of the stable 3.0 line. Bug fixes are applied here.
    • -
    • phpBB2/branches/phpBB-2_0_0/phpBB
      Old phpBB2 development branch.
    • +
    • phpBB3.0develop-olympus
      Development branch of the stable 3.0 line. Bug fixes are applied here.
    • +
    • phpBB3.1develop-ascraeus
      Development branch of the stable 3.1 line. Bug fixes are applied here.
  • -
  • tags
    Released versions. Copies of trunk or the respective branch, made at the time of release. +
  • master
    A branch containing all stable phpBB3 release points
  • +
  • tags
    Released versions. Stable ones get merged into the master branch.
      -
    • /tags/release_3_0_BX
      Beta release X of the 3.0 line.
    • -
    • /tags/release_3_0_RCX
      Release candidate X of the 3.0 line.
    • -
    • /tags/release_3_0_X-RCY
      Release candidate Y of the stable 3.0.X release.
    • -
    • /tags/release_3_0_X
      Stable 3.0.X release.
    • -
    • /tags/release_2_0_X
      Old stable 2.0.X release.
    • +
    • release-3.Y-BX
      Beta release X of the 3.Y line.
    • +
    • release-3.Y-RCX
      Release candidate X of the 3.Y line.
    • +
    • release-3.Y.Z-RCX
      Release candidate X of the stable 3.Y.Z release.
    • +
    • release-3.0.X
      Stable 3.0.X release.
    • +
    • release-2.0.X
      Old stable 2.0.X release.
-

7.ii. Commit Messages

- -

The commit message should contain a brief explanation of all changes made within the commit. Often identical to the changelog entry. A bug ticket can be referenced by specifying the ticket ID with a hash, e.g. #12345. A reference to another revision should simply be prefixed with r, e.g. r12345.

- -

Junior Developers need to have their patches approved by a development team member first. The commit message must end in a line with the following format:

- -
-Authorised by: developer1[, developer2[, ...]]
-	
- -
- - - -
- - -
- -

8. Guidelines Changelog

-
-
- -
-

Revision 10007

- - - -

Revision 9817

- -
    -
  • Added VCS section.
  • -
- -

Revision 8732

- - - -

Revision 8596+

- -
    -
  • Removed sql_build_array('MULTI_INSERT'... statements.
  • -
  • Added sql_multi_insert() explanation.
  • -
- -

Revision 1.31

- -
    -
  • Added add_form_key and check_form_key.
  • -
- -

Revision 1.24

- - - -

Revision 1.16

- - - -

Revision 1.11-1.15

- -
    -
  • Various document formatting, spelling, punctuation, grammar bugs.
  • -
- -

Revision 1.9-1.10

- - - -

Revision 1.8

- - - -

Revision 1.5

- - +

7.ii. Commit Messages and Repository Rules

+

Information on repository rules, such as commit messages can be found at http://wiki.phpbb.com/display/DEV/Git.

@@ -2475,7 +2381,7 @@ Authorised by: developer1[, developer2[, ...]]
diff --git a/phpBB/docs/hook_system.html b/phpBB/docs/hook_system.html index b23ebab869..1bf4630a9f 100644 --- a/phpBB/docs/hook_system.html +++ b/phpBB/docs/hook_system.html @@ -875,7 +875,7 @@ function phpbb_hook_register(&$hook) diff --git a/phpBB/docs/nginx.conf.sample b/phpBB/docs/nginx.conf.sample new file mode 100644 index 0000000000..a22a126ff4 --- /dev/null +++ b/phpBB/docs/nginx.conf.sample @@ -0,0 +1,70 @@ +# Sample nginx configuration file for phpBB. +# Global settings have been removed, copy them +# from your system's nginx.conf. +# Tested with nginx 0.8.35. + +http { + # Compression - requires gzip and gzip static modules. + gzip on; + gzip_static on; + gzip_vary on; + gzip_http_version 1.1; + gzip_min_length 700; + gzip_comp_level 6; + gzip_disable "MSIE [1-6]\."; + + # Catch-all server for requests to invalid hosts. + # Also catches vulnerability scanners probing IP addresses. + # Should be first. + server { + listen 80; + server_name bogus; + return 444; + root /var/empty; + } + + # If you have domains with and without www prefix, + # redirect one to the other. + server { + listen 80; + server_name myforums.com; + rewrite ^(.*)$ http://www.myforums.com$1 permanent; + } + + # The actual board domain. + server { + listen 80; + server_name www.myforums.com; + + root /path/to/phpbb; + + location / { + # phpbb uses index.htm + index index.php index.html index.htm; + } + + # Deny access to internal phpbb files. + location ~ /(config\.php|common\.php|includes|cache|files|store|images/avatars/upload) { + deny all; + } + + # Pass the php scripts to fastcgi server specified in upstream declaration. + location ~ \.php$ { + fastcgi_pass php; + # Necessary for php. + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + # Unmodified fastcgi_params from nginx distribution. + include fastcgi_params; + } + + # Deny access to version control system directories. + location ~ /\.svn|/\.git { + deny all; + } + } + + # If running php as fastcgi, specify php upstream. + upstream php { + server unix:/tmp/php.sock; + } +} diff --git a/phpBB/download/file.php b/phpBB/download/file.php index 00b8e2e656..5f45b88359 100644 --- a/phpBB/download/file.php +++ b/phpBB/download/file.php @@ -31,6 +31,12 @@ else if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT' if (isset($_GET['avatar'])) { + if (!defined('E_DEPRECATED')) + { + define('E_DEPRECATED', 8192); + } + error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED); + require($phpbb_root_path . 'config.' . $phpEx); if (!defined('PHPBB_INSTALLED') || empty($dbms) || empty($acm_type)) @@ -42,6 +48,7 @@ if (isset($_GET['avatar'])) require($phpbb_root_path . 'includes/cache.' . $phpEx); require($phpbb_root_path . 'includes/db/' . $dbms . '.' . $phpEx); require($phpbb_root_path . 'includes/constants.' . $phpEx); + require($phpbb_root_path . 'includes/functions.' . $phpEx); $db = new $sql_db(); $cache = new cache(); @@ -61,7 +68,7 @@ if (isset($_GET['avatar'])) $avatar_group = false; $exit = false; - if ($filename[0] === 'g') + if (isset($filename[0]) && $filename[0] === 'g') { $avatar_group = true; $filename = substr($filename, 1); @@ -70,7 +77,7 @@ if (isset($_GET['avatar'])) // '==' is not a bug - . as the first char is as bad as no dot at all if (strpos($filename, '.') == false) { - header('HTTP/1.0 403 Forbidden'); + send_status_line(403, 'Forbidden'); $exit = true; } @@ -84,7 +91,7 @@ if (isset($_GET['avatar'])) if (!$exit && !in_array($ext, array('png', 'gif', 'jpg', 'jpeg'))) { // no way such an avatar could exist. They are not following the rules, stop the show. - header("HTTP/1.0 403 Forbidden"); + send_status_line(403, 'Forbidden'); $exit = true; } @@ -94,7 +101,7 @@ if (isset($_GET['avatar'])) if (!$filename) { // no way such an avatar could exist. They are not following the rules, stop the show. - header("HTTP/1.0 403 Forbidden"); + send_status_line(403, 'Forbidden'); } else { @@ -192,7 +199,7 @@ else $row['forum_id'] = false; if (!$auth->acl_get('u_pm_download')) { - header('HTTP/1.0 403 Forbidden'); + send_status_line(403, 'Forbidden'); trigger_error('SORRY_AUTH_VIEW_ATTACH'); } @@ -215,7 +222,7 @@ else if (!$allowed) { - header('HTTP/1.0 403 Forbidden'); + send_status_line(403, 'Forbidden'); trigger_error('ERROR_NO_ATTACHMENT'); } } @@ -230,7 +237,7 @@ else if (!download_allowed()) { - header('HTTP/1.0 403 Forbidden'); + send_status_line(403, 'Forbidden'); trigger_error($user->lang['LINKAGE_FORBIDDEN']); } @@ -376,7 +383,7 @@ function send_avatar_to_browser($file, $browser) } else { - header('HTTP/1.0 404 Not Found'); + send_status_line(404, 'Not Found'); } } @@ -670,15 +677,7 @@ function set_modified_headers($stamp, $browser) { if ($last_load !== false && $last_load >= $stamp) { - if (substr(strtolower(@php_sapi_name()),0,3) === 'cgi') - { - // in theory, we shouldn't need that due to php doing it. Reality offers a differing opinion, though - header('Status: 304 Not Modified', true, 304); - } - else - { - header('HTTP/1.0 304 Not Modified', true, 304); - } + send_status_line(304, 'Not Modified'); // seems that we need those too ... browsers header('Pragma: public'); header('Expires: ' . gmdate('D, d M Y H:i:s \G\M\T', time() + 31536000)); diff --git a/phpBB/feed.php b/phpBB/feed.php index a42aa42a7f..c4b71f3a26 100644 --- a/phpBB/feed.php +++ b/phpBB/feed.php @@ -276,8 +276,8 @@ function feed_generate_content($content, $uid, $bitfield, $options) // Add newlines $content = str_replace('
', '
' . "\n", $content); - // Relative Path to Absolute path, Windows style - $content = str_replace('./', $board_url . '/', $content); + // Convert smiley Relative paths to Absolute path, Windows style + $content = str_replace($phpbb_root_path . $config['smilies_path'], $board_url . '/' . $config['smilies_path'], $content); // Remove "Select all" link and mouse events $content = str_replace('' . $user->lang['SELECT_ALL_CODE'] . '', '', $content); @@ -535,12 +535,30 @@ class phpbb_feed_base if (!isset($forum_ids)) { - $forum_ids = array_keys($auth->acl_getf('m_approve')); + $forum_ids = array_keys($auth->acl_getf('m_approve', true)); } return $forum_ids; } + function is_moderator_approve_forum($forum_id) + { + static $forum_ids; + + if (!isset($forum_ids)) + { + $forum_ids = array_flip($this->get_moderator_approve_forums()); + } + + if (!$forum_id) + { + // Global announcement, your a moderator in any forum than it's okay. + return (!empty($forum_ids)) ? true : false; + } + + return (isset($forum_ids[$forum_id])) ? true : false; + } + function get_excluded_forums() { global $db, $cache; @@ -677,7 +695,8 @@ class phpbb_feed_post_base extends phpbb_feed_base if ($config['feed_item_statistics']) { $item_row['statistics'] = $user->lang['POSTED'] . ' ' . $user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row) - . ' ' . $this->separator_stats . ' ' . $user->format_date($row['post_time']); + . ' ' . $this->separator_stats . ' ' . $user->format_date($row['post_time']) + . (($this->is_moderator_approve_forum($row['forum_id']) && !$row['post_approved']) ? ' ' . $this->separator_stats . ' ' . $user->lang['POST_UNAPPROVED'] : ''); } } } @@ -719,8 +738,9 @@ class phpbb_feed_topic_base extends phpbb_feed_base { $item_row['statistics'] = $user->lang['POSTED'] . ' ' . $user->lang['POST_BY_AUTHOR'] . ' ' . $this->user_viewprofile($row) . ' ' . $this->separator_stats . ' ' . $user->format_date($row[$this->get('date')]) - . ' ' . $this->separator_stats . ' ' . $user->lang['REPLIES'] . ' ' . $row['topic_replies'] - . ' ' . $this->separator_stats . ' ' . $user->lang['VIEWS'] . ' ' . $row['topic_views']; + . ' ' . $this->separator_stats . ' ' . $user->lang['REPLIES'] . ' ' . (($this->is_moderator_approve_forum($row['forum_id'])) ? $row['topic_replies_real'] : $row['topic_replies']) + . ' ' . $this->separator_stats . ' ' . $user->lang['VIEWS'] . ' ' . $row['topic_views'] + . (($this->is_moderator_approve_forum($row['forum_id']) && ($row['topic_replies_real'] != $row['topic_replies'])) ? ' ' . $this->separator_stats . ' ' . $user->lang['POSTS_UNAPPROVED'] : ''); } } } @@ -780,11 +800,11 @@ class phpbb_feed_overall extends phpbb_feed_post_base // Get the actual data $this->sql = array( 'SELECT' => 'f.forum_id, f.forum_name, ' . - 'p.post_id, p.topic_id, p.post_time, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . + 'p.post_id, p.topic_id, p.post_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . 'u.username, u.user_id', 'FROM' => array( - POSTS_TABLE => 'p', USERS_TABLE => 'u', + POSTS_TABLE => 'p', ), 'LEFT_JOIN' => array( array( @@ -912,7 +932,7 @@ class phpbb_feed_forum extends phpbb_feed_post_base } $this->sql = array( - 'SELECT' => 'p.post_id, p.topic_id, p.post_time, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . + 'SELECT' => 'p.post_id, p.topic_id, p.post_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . 'u.username, u.user_id', 'FROM' => array( POSTS_TABLE => 'p', @@ -994,7 +1014,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base if (!$this->topic_data['topic_approved']) { // Also require m_approve - $in_fid_ary = array_intersect($in_fid_ary, array_keys($auth->acl_getf('m_approve'))); + $in_fid_ary = array_intersect($in_fid_ary, $this->get_moderator_approve_forums()); if (empty($in_fid_ary)) { @@ -1077,7 +1097,7 @@ class phpbb_feed_topic extends phpbb_feed_post_base global $auth, $db; $this->sql = array( - 'SELECT' => 'p.post_id, p.post_time, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . + 'SELECT' => 'p.post_id, p.post_time, p.post_approved, p.post_subject, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url, ' . 'u.username, u.user_id', 'FROM' => array( POSTS_TABLE => 'p', @@ -1241,7 +1261,7 @@ class phpbb_feed_news extends phpbb_feed_topic_base $this->sql = array( 'SELECT' => 'f.forum_id, f.forum_name, - t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_replies, t.topic_views, t.topic_time, + t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_replies, t.topic_replies_real, t.topic_views, t.topic_time, p.post_id, p.post_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url', 'FROM' => array( TOPICS_TABLE => 't', @@ -1314,7 +1334,7 @@ class phpbb_feed_topics extends phpbb_feed_topic_base $this->sql = array( 'SELECT' => 'f.forum_id, f.forum_name, - t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_replies, t.topic_views, t.topic_time, + t.topic_id, t.topic_title, t.topic_poster, t.topic_first_poster_name, t.topic_replies, t.topic_replies_real, t.topic_views, t.topic_time, p.post_id, p.post_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url', 'FROM' => array( TOPICS_TABLE => 't', @@ -1412,7 +1432,7 @@ class phpbb_feed_topics_active extends phpbb_feed_topic_base $this->sql = array( 'SELECT' => 'f.forum_id, f.forum_name, - t.topic_id, t.topic_title, t.topic_replies, t.topic_views, + t.topic_id, t.topic_title, t.topic_replies, t.topic_replies_real, t.topic_views, t.topic_last_poster_id, t.topic_last_poster_name, t.topic_last_post_time, p.post_id, p.post_time, p.post_text, p.bbcode_bitfield, p.bbcode_uid, p.enable_bbcode, p.enable_smilies, p.enable_magic_url', 'FROM' => array( diff --git a/phpBB/includes/.htaccess b/phpBB/includes/.htaccess new file mode 100644 index 0000000000..4128d345ab --- /dev/null +++ b/phpBB/includes/.htaccess @@ -0,0 +1,4 @@ + + Order Allow,Deny + Deny from All + diff --git a/phpBB/includes/acm/acm_file.php b/phpBB/includes/acm/acm_file.php index 5a758aa2bb..5c1876d006 100644 --- a/phpBB/includes/acm/acm_file.php +++ b/phpBB/includes/acm/acm_file.php @@ -78,8 +78,14 @@ class acm if (!$this->_write('data_global')) { + if (!function_exists('phpbb_is_writable')) + { + global $phpbb_root_path; + include($phpbb_root_path . 'includes/functions.' . $phpEx); + } + // Now, this occurred how often? ... phew, just tell the user then... - if (!@is_writable($this->cache_dir)) + if (!phpbb_is_writable($this->cache_dir)) { // We need to use die() here, because else we may encounter an infinite loop (the message handler calls $cache->unload()) die($this->cache_dir . ' is NOT writable.'); @@ -707,7 +713,13 @@ class acm */ function remove_file($filename, $check = false) { - if ($check && !@is_writable($this->cache_dir)) + if (!function_exists('phpbb_is_writable')) + { + global $phpbb_root_path, $phpEx; + include($phpbb_root_path . 'includes/functions.' . $phpEx); + } + + if ($check && !phpbb_is_writable($this->cache_dir)) { // E_USER_ERROR - not using language entry - intended. trigger_error('Unable to remove files within ' . $this->cache_dir . '. Please check directory permissions.', E_USER_ERROR); diff --git a/phpBB/includes/acm/acm_memcache.php b/phpBB/includes/acm/acm_memcache.php index 52b8832749..e54fa36c38 100644 --- a/phpBB/includes/acm/acm_memcache.php +++ b/phpBB/includes/acm/acm_memcache.php @@ -37,6 +37,12 @@ if (!defined('PHPBB_ACM_MEMCACHE_HOST')) define('PHPBB_ACM_MEMCACHE_HOST', 'localhost'); } +if (!defined('PHPBB_ACM_MEMCACHE')) +{ + //can define multiple servers with host1/port1,host2/port2 format + define('PHPBB_ACM_MEMCACHE', PHPBB_ACM_MEMCACHE_HOST . '/' . PHPBB_ACM_MEMCACHE_PORT); +} + /** * ACM for Memcached * @package acm @@ -54,7 +60,11 @@ class acm extends acm_memory parent::acm_memory(); $this->memcache = new Memcache; - $this->memcache->connect(PHPBB_ACM_MEMCACHE_HOST, PHPBB_ACM_MEMCACHE_PORT); + foreach(explode(',', PHPBB_ACM_MEMCACHE) as $u) + { + $parts = explode('/', $u); + $this->memcache->addServer(trim($parts[0]), trim($parts[1])); + } $this->flags = (PHPBB_ACM_MEMCACHE_COMPRESS) ? MEMCACHE_COMPRESSED : 0; } @@ -125,4 +135,4 @@ class acm extends acm_memory } } -?> \ No newline at end of file +?> diff --git a/phpBB/includes/acm/acm_memory.php b/phpBB/includes/acm/acm_memory.php index efbfd4dd62..2936ea0bae 100644 --- a/phpBB/includes/acm/acm_memory.php +++ b/phpBB/includes/acm/acm_memory.php @@ -407,7 +407,13 @@ class acm_memory */ function remove_file($filename, $check = false) { - if ($check && !@is_writable($this->cache_dir)) + if (!function_exists('phpbb_is_writable')) + { + global $phpbb_root_path, $phpEx; + include($phpbb_root_path . 'includes/functions.' . $phpEx); + } + + if ($check && !phpbb_is_writable($this->cache_dir)) { // E_USER_ERROR - not using language entry - intended. trigger_error('Unable to remove files within ' . $this->cache_dir . '. Please check directory permissions.', E_USER_ERROR); diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index 25e51814c4..fc5f44e14f 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -90,6 +90,7 @@ class acp_attachments $s_assigned_groups = array(); while ($row = $db->sql_fetchrow($result)) { + $row['group_name'] = (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name']; $s_assigned_groups[$row['cat_id']][] = $row['group_name']; } $db->sql_freeresult($result); @@ -494,6 +495,10 @@ class acp_attachments $sql = 'SELECT group_id FROM ' . EXTENSION_GROUPS_TABLE . " WHERE LOWER(group_name) = '" . $db->sql_escape(utf8_strtolower($new_group_name)) . "'"; + if ($group_id) + { + $sql .= ' AND group_id <> ' . $group_id; + } $result = $db->sql_query($sql); if ($db->sql_fetchrow($result)) @@ -551,6 +556,7 @@ class acp_attachments $group_id = $db->sql_nextid(); } + $group_name = (isset($user->lang['EXT_GROUP_' . $group_name])) ? $user->lang['EXT_GROUP_' . $group_name] : $group_name; add_log('admin', 'LOG_ATTACH_EXTGROUP_' . strtoupper($action), $group_name); } @@ -858,7 +864,7 @@ class acp_attachments 'U_EDIT' => $this->u_action . "&action=edit&g={$row['group_id']}", 'U_DELETE' => $this->u_action . "&action=delete&g={$row['group_id']}", - 'GROUP_NAME' => $row['group_name'], + 'GROUP_NAME' => (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name'], 'CATEGORY' => $cat_lang[$row['cat_id']], ) ); @@ -1118,6 +1124,7 @@ class acp_attachments $group_name = array(); while ($row = $db->sql_fetchrow($result)) { + $row['group_name'] = (isset($user->lang['EXT_GROUP_' . $row['group_name']])) ? $user->lang['EXT_GROUP_' . $row['group_name']] : $row['group_name']; $group_name[] = $row; } $db->sql_freeresult($result); @@ -1215,7 +1222,7 @@ class acp_attachments return; } - if (!is_writable($phpbb_root_path . $upload_dir)) + if (!phpbb_is_writable($phpbb_root_path . $upload_dir)) { $error[] = sprintf($user->lang['NO_WRITE_UPLOAD'], $upload_dir); return; diff --git a/phpBB/includes/acp/acp_ban.php b/phpBB/includes/acp/acp_ban.php index 3198376584..a7ea57b753 100644 --- a/phpBB/includes/acp/acp_ban.php +++ b/phpBB/includes/acp/acp_ban.php @@ -224,7 +224,7 @@ class acp_ban $template->assign_block_vars('ban_reason', array( 'BAN_ID' => $ban_id, 'REASON' => $reason, - 'A_REASON' => addslashes(htmlspecialchars_decode($reason)), + 'A_REASON' => addslashes($reason), )); } } @@ -236,7 +236,7 @@ class acp_ban $template->assign_block_vars('ban_give_reason', array( 'BAN_ID' => $ban_id, 'REASON' => $reason, - 'A_REASON' => addslashes(htmlspecialchars_decode($reason)), + 'A_REASON' => addslashes($reason), )); } } diff --git a/phpBB/includes/acp/acp_board.php b/phpBB/includes/acp/acp_board.php index a5feac1902..a5e80e1f6d 100644 --- a/phpBB/includes/acp/acp_board.php +++ b/phpBB/includes/acp/acp_board.php @@ -58,7 +58,7 @@ class acp_board 'board_disable_msg' => false, 'default_lang' => array('lang' => 'DEFAULT_LANGUAGE', 'validate' => 'lang', 'type' => 'select', 'function' => 'language_select', 'params' => array('{CONFIG_VALUE}'), 'explain' => false), 'default_dateformat' => array('lang' => 'DEFAULT_DATE_FORMAT', 'validate' => 'string', 'type' => 'custom', 'method' => 'dateformat_select', 'explain' => true), - 'board_timezone' => array('lang' => 'SYSTEM_TIMEZONE', 'validate' => 'string', 'type' => 'select', 'function' => 'tz_select', 'params' => array('{CONFIG_VALUE}', 1), 'explain' => false), + 'board_timezone' => array('lang' => 'SYSTEM_TIMEZONE', 'validate' => 'string', 'type' => 'select', 'function' => 'tz_select', 'params' => array('{CONFIG_VALUE}', 1), 'explain' => true), 'board_dst' => array('lang' => 'SYSTEM_DST', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'default_style' => array('lang' => 'DEFAULT_STYLE', 'validate' => 'int', 'type' => 'select', 'function' => 'style_select', 'params' => array('{CONFIG_VALUE}', false), 'explain' => false), 'override_user_style' => array('lang' => 'OVERRIDE_STYLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), @@ -319,6 +319,7 @@ class acp_board 'load_online_guests' => array('lang' => 'YES_ONLINE_GUESTS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'load_onlinetrack' => array('lang' => 'YES_ONLINE_TRACK', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'load_birthdays' => array('lang' => 'YES_BIRTHDAYS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), + 'load_unreads_search' => array('lang' => 'YES_UNREAD_SEARCH', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'load_moderators' => array('lang' => 'YES_MODERATORS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'load_jumpbox' => array('lang' => 'YES_JUMPBOX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'load_user_activity' => array('lang' => 'LOAD_USER_ACTIVITY', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), @@ -888,8 +889,8 @@ class acp_board $old_tz = $user->timezone; $old_dst = $user->dst; - $user->timezone = $config['board_timezone']; - $user->dst = $config['board_dst']; + $user->timezone = $config['board_timezone'] * 3600; + $user->dst = $config['board_dst'] * 3600; $dateformat_options = ''; diff --git a/phpBB/includes/acp/acp_captcha.php b/phpBB/includes/acp/acp_captcha.php index 56a57e319c..1893eed14f 100644 --- a/phpBB/includes/acp/acp_captcha.php +++ b/phpBB/includes/acp/acp_captcha.php @@ -89,14 +89,14 @@ class acp_captcha } else { - trigger_error($user->lang['CAPTCHA_UNAVAILABLE'] . adm_back_link($this->u_action)); + trigger_error($user->lang['CAPTCHA_UNAVAILABLE'] . adm_back_link($this->u_action), E_USER_WARNING); } } trigger_error($user->lang['CONFIG_UPDATED'] . adm_back_link($this->u_action)); } else if ($submit) { - trigger_error($user->lang['FORM_INVALID'] . adm_back_link()); + trigger_error($user->lang['FORM_INVALID'] . adm_back_link(), E_USER_WARNING); } else { diff --git a/phpBB/includes/acp/acp_database.php b/phpBB/includes/acp/acp_database.php index 5d7450bdfd..193dd001c0 100644 --- a/phpBB/includes/acp/acp_database.php +++ b/phpBB/includes/acp/acp_database.php @@ -109,6 +109,7 @@ class acp_database case 'mssql': case 'mssql_odbc': + case 'mssqlnative': $extractor = new mssql_extractor($download, $store, $format, $filename, $time); break; @@ -138,6 +139,7 @@ class acp_database case 'mssql': case 'mssql_odbc': + case 'mssqlnative': $extractor->flush('TRUNCATE TABLE ' . $table_name . "GO\n"); break; @@ -392,6 +394,7 @@ class acp_database case 'mssql': case 'mssql_odbc': + case 'mssqlnative': while (($sql = $fgetd($fp, "GO\n", $read, $seek, $eof)) !== false) { $db->sql_query($sql); @@ -435,7 +438,7 @@ class acp_database { if (in_array($matches[2], $methods)) { - $backup_files[gmdate("d-m-Y H:i:s", $matches[1])] = $file; + $backup_files[(int) $matches[1]] = $file; } } } @@ -450,7 +453,7 @@ class acp_database { $template->assign_block_vars('files', array( 'FILE' => $file, - 'NAME' => $name, + 'NAME' => $user->format_date($name, 'd-m-Y H:i:s', true), 'SUPPORTED' => true, )); } @@ -1509,6 +1512,10 @@ class mssql_extractor extends base_extractor { $this->write_data_mssql($table_name); } + else if($db->sql_layer === 'mssqlnative') + { + $this->write_data_mssqlnative($table_name); + } else { $this->write_data_odbc($table_name); @@ -1608,7 +1615,111 @@ class mssql_extractor extends base_extractor } $this->flush($sql_data); } + + function write_data_mssqlnative($table_name) + { + global $db; + $ary_type = $ary_name = array(); + $ident_set = false; + $sql_data = ''; + // Grab all of the data from current table. + $sql = "SELECT * FROM $table_name"; + $db->mssqlnative_set_query_options(array('Scrollable' => SQLSRV_CURSOR_STATIC)); + $result = $db->sql_query($sql); + + $retrieved_data = $db->mssqlnative_num_rows($result); + + if (!$retrieved_data) + { + $db->sql_freeresult($result); + return; + } + + $sql = "SELECT * FROM $table_name"; + $result_fields = $db->sql_query_limit($sql, 1); + + $row = new result_mssqlnative($result_fields); + $i_num_fields = $row->num_fields(); + + for ($i = 0; $i < $i_num_fields; $i++) + { + $ary_type[$i] = $row->field_type($i); + $ary_name[$i] = $row->field_name($i); + } + $db->sql_freeresult($result_fields); + + $sql = "SELECT 1 as has_identity + FROM INFORMATION_SCHEMA.COLUMNS + WHERE COLUMNPROPERTY(object_id('$table_name'), COLUMN_NAME, 'IsIdentity') = 1"; + $result2 = $db->sql_query($sql); + $row2 = $db->sql_fetchrow($result2); + + if (!empty($row2['has_identity'])) + { + $sql_data .= "\nSET IDENTITY_INSERT $table_name ON\nGO\n"; + $ident_set = true; + } + $db->sql_freeresult($result2); + + while ($row = $db->sql_fetchrow($result)) + { + $schema_vals = $schema_fields = array(); + + // Build the SQL statement to recreate the data. + for ($i = 0; $i < $i_num_fields; $i++) + { + $str_val = $row[$ary_name[$i]]; + + // defaults to type number - better quote just to be safe, so check for is_int too + if (is_int($ary_type[$i]) || preg_match('#char|text|bool|varbinary#i', $ary_type[$i])) + { + $str_quote = ''; + $str_empty = "''"; + $str_val = sanitize_data_mssql(str_replace("'", "''", $str_val)); + } + else if (preg_match('#date|timestamp#i', $ary_type[$i])) + { + if (empty($str_val)) + { + $str_quote = ''; + } + else + { + $str_quote = "'"; + } + } + else + { + $str_quote = ''; + $str_empty = 'NULL'; + } + + if (empty($str_val) && $str_val !== '0' && !(is_int($str_val) || is_float($str_val))) + { + $str_val = $str_empty; + } + + $schema_vals[$i] = $str_quote . $str_val . $str_quote; + $schema_fields[$i] = $ary_name[$i]; + } + + // Take the ordered fields and their associated data and build it + // into a valid sql statement to recreate that field in the data. + $sql_data .= "INSERT INTO $table_name (" . implode(', ', $schema_fields) . ') VALUES (' . implode(', ', $schema_vals) . ");\nGO\n"; + + $this->flush($sql_data); + $sql_data = ''; + } + $db->sql_freeresult($result); + + if ($ident_set) + { + $sql_data .= "\nSET IDENTITY_INSERT $table_name OFF\nGO\n"; + } + $this->flush($sql_data); + } + function write_data_odbc($table_name) { global $db; diff --git a/phpBB/includes/acp/acp_forums.php b/phpBB/includes/acp/acp_forums.php index bde59ec870..4d9b9f01e0 100644 --- a/phpBB/includes/acp/acp_forums.php +++ b/phpBB/includes/acp/acp_forums.php @@ -169,7 +169,7 @@ class acp_forums $forum_data['forum_status'] = ITEM_UNLOCKED; } - $forum_data['show_active'] = ($forum_data['forum_type'] == FORUM_POST) ? request_var('display_recent', true) : request_var('display_active', true); + $forum_data['show_active'] = ($forum_data['forum_type'] == FORUM_POST) ? request_var('display_recent', true) : request_var('display_active', false); // Get data for forum rules if specified... if ($forum_data['forum_rules']) @@ -190,12 +190,14 @@ class acp_forums $forum_perm_from = request_var('forum_perm_from', 0); $cache->destroy('sql', FORUMS_TABLE); + $copied_permissions = false; // Copy permissions? if ($forum_perm_from && $forum_perm_from != $forum_data['forum_id'] && ($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')))) { copy_forum_permissions($forum_perm_from, $forum_data['forum_id'], ($action == 'edit') ? true : false); cache_moderators(); + $copied_permissions = true; } /* Commented out because of questionable UI workflow - re-visit for 3.0.7 else if (!$this->parent_id && $action != 'edit' && $auth->acl_get('a_fauth') && $auth->acl_get('a_authusers') && $auth->acl_get('a_authgroups') && $auth->acl_get('a_mauth')) @@ -211,13 +213,13 @@ class acp_forums $message = ($action == 'add') ? $user->lang['FORUM_CREATED'] : $user->lang['FORUM_UPDATED']; // Redirect to permissions - if ($auth->acl_get('a_fauth')) + if ($auth->acl_get('a_fauth') && !$copied_permissions) { $message .= '

' . sprintf($user->lang['REDIRECT_ACL'], '', ''); } // redirect directly to permission settings screen if authed - if ($action == 'add' && !$forum_perm_from && $auth->acl_get('a_fauth')) + if ($action == 'add' && !$copied_permissions && $auth->acl_get('a_fauth')) { meta_refresh(4, append_sid("{$phpbb_admin_path}index.$phpEx", 'i=permissions' . $acl_url)); } @@ -639,7 +641,8 @@ class acp_forums 'S_PRUNE_OLD_POLLS' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_POLL) ? true : false, 'S_PRUNE_ANNOUNCE' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_ANNOUNCE) ? true : false, 'S_PRUNE_STICKY' => ($forum_data['forum_flags'] & FORUM_FLAG_PRUNE_STICKY) ? true : false, - 'S_DISPLAY_ACTIVE_TOPICS' => ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) ? true : false, + 'S_DISPLAY_ACTIVE_TOPICS' => ($forum_data['forum_type'] == FORUM_POST) ? ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) : true, + 'S_ENABLE_ACTIVE_TOPICS' => ($forum_data['forum_type'] == FORUM_CAT) ? ($forum_data['forum_flags'] & FORUM_FLAG_ACTIVE_TOPICS) : false, '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, @@ -980,7 +983,7 @@ class acp_forums if (!$row) { - trigger_error($user->lang['PARENT_NOT_EXIST'] . adm_back_link($this->u_action . '&' . $this->parent_id), E_USER_WARNING); + trigger_error($user->lang['PARENT_NOT_EXIST'] . adm_back_link($this->u_action . '&parent_id=' . $this->parent_id), E_USER_WARNING); } if ($row['forum_type'] == FORUM_LINK) @@ -1639,6 +1642,9 @@ class acp_forums delete_attachments('topic', $topic_ids, false); + // Delete shadow topics pointing to topics in this forum + delete_topic_shadows($forum_id); + // Before we remove anything we make sure we are able to adjust the post counts later. ;) $sql = 'SELECT poster_id FROM ' . POSTS_TABLE . ' @@ -1705,6 +1711,9 @@ class acp_forums ) ); + // Amount of rows we select and delete in one iteration. + $batch_size = 500; + foreach ($tables_ary as $field => $tables) { $start = 0; @@ -1714,7 +1723,7 @@ class acp_forums $sql = "SELECT $field FROM " . POSTS_TABLE . ' WHERE forum_id = ' . $forum_id; - $result = $db->sql_query_limit($sql, 500, $start); + $result = $db->sql_query_limit($sql, $batch_size, $start); $ids = array(); while ($row = $db->sql_fetchrow($result)) @@ -1733,7 +1742,7 @@ class acp_forums } } } - while ($row); + while (sizeof($ids) == $batch_size); } unset($ids); diff --git a/phpBB/includes/acp/acp_groups.php b/phpBB/includes/acp/acp_groups.php index 3df61ff4e2..486616c33d 100644 --- a/phpBB/includes/acp/acp_groups.php +++ b/phpBB/includes/acp/acp_groups.php @@ -49,7 +49,7 @@ class acp_groups // Clear some vars - $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; + $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; $group_row = array(); // Grab basic data for group, if group_id is set and exists @@ -394,6 +394,15 @@ class acp_groups } } + // Validate the length of "Maximum number of allowed recipients per private message" setting. + // We use 16777215 as a maximum because it matches MySQL unsigned mediumint maximum value + // which is the lowest amongst DBMSes supported by phpBB3 + if ($max_recipients_error = validate_data($submit_ary, array('max_recipients' => array('num', false, 0, 16777215)))) + { + // Replace "error" string with its real, localised form + $error = array_merge($error, array_map(array(&$user, 'lang'), $max_recipients_error)); + } + if (!sizeof($error)) { // Only set the rank, colour, etc. if it's changed or if we're adding a new diff --git a/phpBB/includes/acp/acp_language.php b/phpBB/includes/acp/acp_language.php index fedae6fe67..c2cb2f9c11 100644 --- a/phpBB/includes/acp/acp_language.php +++ b/phpBB/includes/acp/acp_language.php @@ -1120,12 +1120,12 @@ class acp_language { while (($file = readdir($dp)) !== false) { - if (!is_dir($phpbb_root_path . 'language/' . $file)) + if ($file[0] == '.' || !is_dir($phpbb_root_path . 'language/' . $file)) { continue; } - if ($file[0] != '.' && file_exists("{$phpbb_root_path}language/$file/iso.txt")) + if (file_exists("{$phpbb_root_path}language/$file/iso.txt")) { if (!in_array($file, $installed)) { diff --git a/phpBB/includes/acp/acp_php_info.php b/phpBB/includes/acp/acp_php_info.php index 9935c0466e..0499095004 100644 --- a/phpBB/includes/acp/acp_php_info.php +++ b/phpBB/includes/acp/acp_php_info.php @@ -35,9 +35,9 @@ class acp_php_info $this->tpl_name = 'acp_php_info'; $this->page_title = 'ACP_PHP_INFO'; - + ob_start(); - @phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES | INFO_VARIABLES); + phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES | INFO_VARIABLES); $phpinfo = ob_get_clean(); $phpinfo = trim($phpinfo); diff --git a/phpBB/includes/acp/acp_profile.php b/phpBB/includes/acp/acp_profile.php index fc08c7e8e8..2288a0728b 100644 --- a/phpBB/includes/acp/acp_profile.php +++ b/phpBB/includes/acp/acp_profile.php @@ -1480,6 +1480,7 @@ class acp_profile case 'mssql': case 'mssql_odbc': + case 'mssqlnative': // We are defining the biggest common value, because of the possibility to edit the min/max values of each field. $sql = 'ALTER TABLE [' . PROFILE_FIELDS_DATA_TABLE . "] ADD [$field_ident] "; diff --git a/phpBB/includes/acp/acp_prune.php b/phpBB/includes/acp/acp_prune.php index 7eeb37133f..ffe20f86f5 100644 --- a/phpBB/includes/acp/acp_prune.php +++ b/phpBB/includes/acp/acp_prune.php @@ -315,8 +315,8 @@ class acp_prune 'mode' => $mode, 'prune' => 1, - 'users' => request_var('users', '', true), - 'username' => request_var('username', '', true), + 'users' => utf8_normalize_nfc(request_var('users', '', true)), + 'username' => utf8_normalize_nfc(request_var('username', '', true)), 'email' => request_var('email', ''), 'joined_select' => request_var('joined_select', ''), 'joined' => request_var('joined', ''), @@ -369,7 +369,7 @@ class acp_prune { global $user, $db; - $users = request_var('users', '', true); + $users = utf8_normalize_nfc(request_var('users', '', true)); if ($users) { @@ -378,7 +378,7 @@ class acp_prune } else { - $username = request_var('username', '', true); + $username = utf8_normalize_nfc(request_var('username', '', true)); $email = request_var('email', ''); $joined_select = request_var('joined_select', 'lt'); diff --git a/phpBB/includes/acp/acp_reasons.php b/phpBB/includes/acp/acp_reasons.php index 8d7bc88769..dbc9fcb6cc 100644 --- a/phpBB/includes/acp/acp_reasons.php +++ b/phpBB/includes/acp/acp_reasons.php @@ -233,6 +233,7 @@ class acp_reasons // Standard? What's that? case 'mssql': case 'mssql_odbc': + case 'mssqlnative': // Change the reports using this reason to 'other' $sql = "DECLARE @ptrval binary(16) diff --git a/phpBB/includes/acp/acp_styles.php b/phpBB/includes/acp/acp_styles.php index d2a0f9210f..2ccc728031 100644 --- a/phpBB/includes/acp/acp_styles.php +++ b/phpBB/includes/acp/acp_styles.php @@ -643,13 +643,13 @@ parse_css_file = {PARSE_CSS_FILE} { while (($file = readdir($dp)) !== false) { - if (!is_dir($phpbb_root_path . 'styles/' . $file)) + if ($file[0] == '.' || !is_dir($phpbb_root_path . 'styles/' . $file)) { continue; } $subpath = ($mode != 'style') ? "$mode/" : ''; - if ($file[0] != '.' && file_exists("{$phpbb_root_path}styles/$file/$subpath$mode.cfg")) + if (file_exists("{$phpbb_root_path}styles/$file/$subpath$mode.cfg")) { if ($cfg = file("{$phpbb_root_path}styles/$file/$subpath$mode.cfg")) { @@ -748,7 +748,7 @@ parse_css_file = {PARSE_CSS_FILE} $additional = ''; // If the template is stored on the filesystem try to write the file else store it in the database - if (!$safe_mode && !$template_info['template_storedb'] && file_exists($file) && @is_writable($file)) + if (!$safe_mode && !$template_info['template_storedb'] && file_exists($file) && phpbb_is_writable($file)) { if (!($fp = @fopen($file, 'wb'))) { @@ -1155,7 +1155,7 @@ parse_css_file = {PARSE_CSS_FILE} $message = $user->lang['THEME_UPDATED']; // If the theme is stored on the filesystem try to write the file else store it in the database - if (!$safe_mode && !$theme_info['theme_storedb'] && file_exists($file) && @is_writable($file)) + if (!$safe_mode && !$theme_info['theme_storedb'] && file_exists($file) && phpbb_is_writable($file)) { if (!($fp = @fopen($file, 'wb'))) { @@ -2040,23 +2040,18 @@ parse_css_file = {PARSE_CSS_FILE} { case 'tar': $ext = '.tar'; - $mimetype = 'x-tar'; - $compress = 'compress_tar'; break; case 'zip': $ext = '.zip'; - $mimetype = 'zip'; break; case 'tar.gz': $ext = '.tar.gz'; - $mimetype = 'x-gzip'; break; case 'tar.bz2': $ext = '.tar.bz2'; - $mimetype = 'x-bzip2'; break; default: @@ -2246,7 +2241,7 @@ parse_css_file = {PARSE_CSS_FILE} { // a rather elaborate check we have to do here once to avoid trouble later $check = "{$phpbb_root_path}styles/" . $style_row["{$mode}_path"] . (($mode === 'theme') ? '/theme/stylesheet.css' : '/template'); - if (($style_row["{$mode}_storedb"] != $store_db) && !$store_db && ($safe_mode || !@is_writable($check))) + if (($style_row["{$mode}_storedb"] != $store_db) && !$store_db && ($safe_mode || !phpbb_is_writable($check))) { $error[] = $user->lang['EDIT_' . strtoupper($mode) . '_STORED_DB']; $store_db = 1; @@ -2326,7 +2321,7 @@ parse_css_file = {PARSE_CSS_FILE} { $theme_data = $this->db_theme_data($style_row); } - else if (!$store_db && !$safe_mode && @is_writable("{$phpbb_root_path}styles/{$style_row['theme_path']}/theme/stylesheet.css")) + else if (!$store_db && !$safe_mode && phpbb_is_writable("{$phpbb_root_path}styles/{$style_row['theme_path']}/theme/stylesheet.css")) { $store_db = 1; $theme_data = $style_row['theme_data']; @@ -2357,7 +2352,7 @@ parse_css_file = {PARSE_CSS_FILE} } else { - if (!$store_db && !$safe_mode && @is_writable("{$phpbb_root_path}styles/{$style_row['template_path']}/template")) + if (!$store_db && !$safe_mode && phpbb_is_writable("{$phpbb_root_path}styles/{$style_row['template_path']}/template")) { $err = $this->store_in_fs('template', $style_row['template_id']); if ($err) @@ -2531,13 +2526,21 @@ parse_css_file = {PARSE_CSS_FILE} // Match CSS imports $matches = array(); - preg_match_all('/@import url\(["\'](.*)["\']\);/i', $stylesheet, $matches); + preg_match_all('/@import url\((["\'])(.*)\1\);/i', $stylesheet, $matches); + + // remove commented stylesheets (very simple parser, allows only whitespace + // around an @import statement) + preg_match_all('#/\*\s*@import url\((["\'])(.*)\1\);\s\*/#i', $stylesheet, $commented); + $matches[2] = array_diff($matches[2], $commented[2]); if (sizeof($matches)) { foreach ($matches[0] as $idx => $match) { - $stylesheet = str_replace($match, acp_styles::load_css_file($theme_row['theme_path'], $matches[1][$idx]), $stylesheet); + if (isset($matches[2][$idx])) + { + $stylesheet = str_replace($match, acp_styles::load_css_file($theme_row['theme_path'], $matches[2][$idx]), $stylesheet); + } } } @@ -3728,7 +3731,7 @@ parse_css_file = {PARSE_CSS_FILE} $store_db = 0; $error = array(); - if (!$safe_mode && @is_writable("{$phpbb_root_path}styles/{$path}/template")) + if (!$safe_mode && phpbb_is_writable("{$phpbb_root_path}styles/{$path}/template")) { $sql = 'SELECT * FROM ' . STYLES_TEMPLATE_DATA_TABLE . " diff --git a/phpBB/includes/acp/acp_update.php b/phpBB/includes/acp/acp_update.php index 3204e0204e..b0ce8f1084 100644 --- a/phpBB/includes/acp/acp_update.php +++ b/phpBB/includes/acp/acp_update.php @@ -51,6 +51,14 @@ class acp_update $announcement_url = (strpos($announcement_url, '&') === false) ? str_replace('&', '&', $announcement_url) : $announcement_url; $update_link = append_sid($phpbb_root_path . 'install/index.' . $phpEx, 'mode=update'); + // next feature release + $next_feature_version = $next_feature_announcement_url = false; + if (isset($info[2]) && trim($info[2]) !== '') + { + $next_feature_version = trim($info[2]); + $next_feature_announcement_url = trim($info[3]); + } + // Determine automatic update... $sql = 'SELECT config_value FROM ' . CONFIG_TABLE . " @@ -74,8 +82,10 @@ class acp_update 'LATEST_VERSION' => $latest_version, 'CURRENT_VERSION' => $config['version'], 'AUTO_VERSION' => $version_update_from, + 'NEXT_FEATURE_VERSION' => $next_feature_version, 'UPDATE_INSTRUCTIONS' => sprintf($user->lang['UPDATE_INSTRUCTIONS'], $announcement_url, $update_link), + 'UPGRADE_INSTRUCTIONS' => $next_feature_version ? $user->lang('UPGRADE_INSTRUCTIONS', $next_feature_version, $next_feature_announcement_url) : false, )); } } diff --git a/phpBB/includes/acp/acp_users.php b/phpBB/includes/acp/acp_users.php index 4905840e02..6be0760be0 100644 --- a/phpBB/includes/acp/acp_users.php +++ b/phpBB/includes/acp/acp_users.php @@ -105,7 +105,7 @@ class acp_users LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id) WHERE u.user_id = ' . $user_id . ' ORDER BY s.session_time DESC'; - $result = $db->sql_query($sql); + $result = $db->sql_query_limit($sql, 1); $user_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); @@ -191,24 +191,31 @@ class acp_users trigger_error($user->lang['CANNOT_REMOVE_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } - if (confirm_box(true)) + if ($delete_type) { - user_delete($delete_type, $user_id, $user_row['username']); + if (confirm_box(true)) + { + user_delete($delete_type, $user_id, $user_row['username']); - add_log('admin', 'LOG_USER_DELETED', $user_row['username']); - trigger_error($user->lang['USER_DELETED'] . adm_back_link($this->u_action)); + add_log('admin', 'LOG_USER_DELETED', $user_row['username']); + trigger_error($user->lang['USER_DELETED'] . adm_back_link($this->u_action)); + } + else + { + confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( + 'u' => $user_id, + 'i' => $id, + 'mode' => $mode, + 'action' => $action, + 'update' => true, + 'delete' => 1, + 'delete_type' => $delete_type)) + ); + } } else { - confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array( - 'u' => $user_id, - 'i' => $id, - 'mode' => $mode, - 'action' => $action, - 'update' => true, - 'delete' => 1, - 'delete_type' => $delete_type)) - ); + trigger_error($user->lang['NO_MODE'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } } @@ -224,6 +231,11 @@ class acp_users trigger_error($user->lang['CANNOT_BAN_YOURSELF'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } + if ($user_id == ANONYMOUS) + { + trigger_error($user->lang['CANNOT_BAN_ANONYMOUS'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); + } + if ($user_row['user_type'] == USER_FOUNDER) { trigger_error($user->lang['CANNOT_BAN_FOUNDER'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); @@ -307,10 +319,7 @@ class acp_users $server_url = generate_board_url(); - $user_actkey = gen_rand_string(10); - $key_len = 54 - (strlen($server_url)); - $key_len = ($key_len > 6) ? $key_len : 6; - $user_actkey = substr($user_actkey, 0, $key_len); + $user_actkey = gen_rand_string(mt_rand(6, 10)); $email_template = ($user_row['user_type'] == USER_NORMAL) ? 'user_reactivate_account' : 'user_resend_inactive'; if ($user_row['user_type'] == USER_NORMAL) @@ -1550,6 +1559,31 @@ class acp_users WHERE user_id = $user_id"; $db->sql_query($sql); + // Check if user has an active session + if ($user_row['session_id']) + { + // We'll update the session if user_allow_viewonline has changed and the user is a bot + // Or if it's a regular user and the admin set it to hide the session + if ($user_row['user_allow_viewonline'] != $sql_ary['user_allow_viewonline'] && $user_row['user_type'] == USER_IGNORE + || $user_row['user_allow_viewonline'] && !$sql_ary['user_allow_viewonline']) + { + // We also need to check if the user has the permission to cloak. + $user_auth = new auth(); + $user_auth->acl($user_row); + + $session_sql_ary = array( + 'session_viewonline' => ($user_auth->acl_get('u_hideonline')) ? $sql_ary['user_allow_viewonline'] : true, + ); + + $sql = 'UPDATE ' . SESSIONS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $session_sql_ary) . " + WHERE session_user_id = $user_id"; + $db->sql_query($sql); + + unset($user_auth); + } + } + trigger_error($user->lang['USER_PREFS_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_id)); } @@ -1664,7 +1698,7 @@ class acp_users include($phpbb_root_path . 'includes/functions_display.' . $phpEx); include($phpbb_root_path . 'includes/functions_user.' . $phpEx); - $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; + $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; if ($submit) { @@ -1674,7 +1708,7 @@ class acp_users trigger_error($user->lang['FORM_INVALID'] . adm_back_link($this->u_action . '&u=' . $user_id), E_USER_WARNING); } - if (avatar_process_user($error, $user_row)) + if (avatar_process_user($error, $user_row, $can_upload)) { trigger_error($user->lang['USER_AVATAR_UPDATED'] . adm_back_link($this->u_action . '&u=' . $user_row['user_id'])); } @@ -2084,7 +2118,7 @@ class acp_users LEFT JOIN ' . SESSIONS_TABLE . ' s ON (s.session_user_id = u.user_id) WHERE u.user_id = ' . $user_id . ' ORDER BY s.session_time DESC'; - $result = $db->sql_query($sql); + $result = $db->sql_query_limit($sql, 1); $user_row = $db->sql_fetchrow($result); $db->sql_freeresult($result); } diff --git a/phpBB/includes/acp/info/acp_board.php b/phpBB/includes/acp/info/acp_board.php index 58b650650c..3e18f55940 100644 --- a/phpBB/includes/acp/info/acp_board.php +++ b/phpBB/includes/acp/info/acp_board.php @@ -24,7 +24,7 @@ class acp_board_info 'features' => array('title' => 'ACP_BOARD_FEATURES', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), 'avatar' => array('title' => 'ACP_AVATAR_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), 'message' => array('title' => 'ACP_MESSAGE_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION', 'ACP_MESSAGES')), - 'post' => array('title' => 'ACP_POST_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), + 'post' => array('title' => 'ACP_POST_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION', 'ACP_MESSAGES')), 'signature' => array('title' => 'ACP_SIGNATURE_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), 'feed' => array('title' => 'ACP_FEED_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), 'registration' => array('title' => 'ACP_REGISTER_SETTINGS', 'auth' => 'acl_a_board', 'cat' => array('ACP_BOARD_CONFIGURATION')), diff --git a/phpBB/includes/auth/auth_db.php b/phpBB/includes/auth/auth_db.php index 73c4f92976..e04a6307e9 100644 --- a/phpBB/includes/auth/auth_db.php +++ b/phpBB/includes/auth/auth_db.php @@ -134,7 +134,8 @@ function login_db(&$username, &$password) // increase login attempt count to make sure this cannot be exploited $sql = 'UPDATE ' . USERS_TABLE . ' SET user_login_attempts = user_login_attempts + 1 - WHERE user_id = ' . $row['user_id']; + WHERE user_id = ' . (int) $row['user_id'] . ' + AND user_login_attempts < ' . LOGIN_ATTEMPTS_MAX; $db->sql_query($sql); return array( @@ -194,7 +195,8 @@ function login_db(&$username, &$password) // Password incorrect - increase login attempts $sql = 'UPDATE ' . USERS_TABLE . ' SET user_login_attempts = user_login_attempts + 1 - WHERE user_id = ' . $row['user_id']; + WHERE user_id = ' . (int) $row['user_id'] . ' + AND user_login_attempts < ' . LOGIN_ATTEMPTS_MAX; $db->sql_query($sql); // Give status about wrong password... diff --git a/phpBB/includes/auth/auth_ldap.php b/phpBB/includes/auth/auth_ldap.php index a6092baba5..e8c957aaa3 100644 --- a/phpBB/includes/auth/auth_ldap.php +++ b/phpBB/includes/auth/auth_ldap.php @@ -74,7 +74,7 @@ function init_ldap() if ($search === false) { - return $user->lang['LDAP_NO_SERVER_CONNECTION']; + return $user->lang['LDAP_SEARCH_FAILED']; } $result = @ldap_get_entries($ldap, $search); diff --git a/phpBB/includes/cache.php b/phpBB/includes/cache.php index a0142292ed..b50fab4ca2 100644 --- a/phpBB/includes/cache.php +++ b/phpBB/includes/cache.php @@ -82,11 +82,20 @@ class cache extends acm $result = $db->sql_query($sql); $censors = array(); + $unicode = ((version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) && @preg_match('/\p{L}/u', 'a') !== false) ? true : false; + while ($row = $db->sql_fetchrow($result)) { - if ((version_compare(PHP_VERSION, '5.1.0', '>=') || (version_compare(PHP_VERSION, '5.0.0-dev', '<=') && version_compare(PHP_VERSION, '4.4.0', '>='))) && @preg_match('/\p{L}/u', 'a') !== false) + if ($unicode) { - $censors['match'][] = '#(?code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); + $this->code = gen_rand_string_friendly(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); $this->seed = hexdec(substr(unique_id(), 4, 10)); // compute $seed % 0x7fffffff @@ -235,7 +235,7 @@ class phpbb_default_captcha { global $db, $user; - $this->code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); + $this->code = gen_rand_string_friendly(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); $this->confirm_id = md5(unique_id($user->ip)); $this->seed = hexdec(substr(unique_id(), 4, 10)); $this->solved = 0; @@ -259,7 +259,7 @@ class phpbb_default_captcha { global $db, $user; - $this->code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); + $this->code = gen_rand_string_friendly(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); $this->seed = hexdec(substr(unique_id(), 4, 10)); $this->solved = 0; // compute $seed % 0x7fffffff @@ -281,7 +281,7 @@ class phpbb_default_captcha { global $db, $user; - $this->code = gen_rand_string(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); + $this->code = gen_rand_string_friendly(mt_rand(CAPTCHA_MIN_CHARS, CAPTCHA_MAX_CHARS)); $this->seed = hexdec(substr(unique_id(), 4, 10)); $this->solved = 0; // compute $seed % 0x7fffffff diff --git a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php index 0f0bfc4156..ea171dbe2c 100644 --- a/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php +++ b/phpBB/includes/captcha/plugins/phpbb_recaptcha_plugin.php @@ -314,10 +314,7 @@ class phpbb_recaptcha extends phpbb_default_captcha } else { - if ($answers[1] === 'incorrect-captcha-sol') - { - return $user->lang['RECAPTCHA_INCORRECT']; - } + return $user->lang['RECAPTCHA_INCORRECT']; } } diff --git a/phpBB/includes/constants.php b/phpBB/includes/constants.php index 8d31eaba7f..af2a6ebd24 100644 --- a/phpBB/includes/constants.php +++ b/phpBB/includes/constants.php @@ -25,7 +25,7 @@ if (!defined('IN_PHPBB')) */ // phpBB Version -define('PHPBB_VERSION', '3.0.7-PL1'); +define('PHPBB_VERSION', '3.0.8'); // QA-related // define('PHPBB_QA', 1); @@ -69,6 +69,10 @@ define('LOGIN_ERROR_ATTEMPTS', 13); define('LOGIN_ERROR_EXTERNAL_AUTH', 14); define('LOGIN_ERROR_PASSWORD_CONVERT', 15); +// Maximum login attempts +// The value is arbitrary, but it has to fit into the user_login_attempts field. +define('LOGIN_ATTEMPTS_MAX', 100); + // Group settings define('GROUP_OPEN', 0); define('GROUP_CLOSED', 1); @@ -117,6 +121,10 @@ define('NOTIFY_EMAIL', 0); define('NOTIFY_IM', 1); define('NOTIFY_BOTH', 2); +// Notify status +define('NOTIFY_YES', 0); +define('NOTIFY_NO', 1); + // Email Priority Settings define('MAIL_LOW_PRIORITY', 4); define('MAIL_NORMAL_PRIORITY', 3); diff --git a/phpBB/includes/db/db_tools.php b/phpBB/includes/db/db_tools.php index 7123c83e51..f4b181c6ad 100644 --- a/phpBB/includes/db/db_tools.php +++ b/phpBB/includes/db/db_tools.php @@ -160,6 +160,36 @@ class phpbb_db_tools 'VARBINARY' => '[varchar] (255)', ), + 'mssqlnative' => array( + 'INT:' => '[int]', + 'BINT' => '[float]', + 'UINT' => '[int]', + 'UINT:' => '[int]', + 'TINT:' => '[int]', + 'USINT' => '[int]', + 'BOOL' => '[int]', + 'VCHAR' => '[varchar] (255)', + 'VCHAR:' => '[varchar] (%d)', + 'CHAR:' => '[char] (%d)', + 'XSTEXT' => '[varchar] (1000)', + 'STEXT' => '[varchar] (3000)', + 'TEXT' => '[varchar] (8000)', + 'MTEXT' => '[text]', + 'XSTEXT_UNI'=> '[varchar] (100)', + 'STEXT_UNI' => '[varchar] (255)', + 'TEXT_UNI' => '[varchar] (4000)', + 'MTEXT_UNI' => '[text]', + 'TIMESTAMP' => '[int]', + 'DECIMAL' => '[float]', + 'DECIMAL:' => '[float]', + 'PDECIMAL' => '[float]', + 'PDECIMAL:' => '[float]', + 'VCHAR_UNI' => '[varchar] (255)', + 'VCHAR_UNI:'=> '[varchar] (%d)', + 'VCHAR_CI' => '[varchar] (255)', + 'VARBINARY' => '[varchar] (255)', + ), + 'oracle' => array( 'INT:' => 'number(%d)', 'BINT' => 'number(20)', @@ -261,7 +291,7 @@ class phpbb_db_tools * A list of supported DBMS. We change this class to support more DBMS, the DBMS itself only need to follow some rules. * @var array */ - var $supported_dbms = array('firebird', 'mssql', 'mysql_40', 'mysql_41', 'oracle', 'postgres', 'sqlite'); + var $supported_dbms = array('firebird', 'mssql', 'mssqlnative', 'mysql_40', 'mysql_41', 'oracle', 'postgres', 'sqlite'); /** * This is set to true if user only wants to return the 'to-be-executed' SQL statement(s) (as an array). @@ -307,6 +337,10 @@ class phpbb_db_tools $this->sql_layer = 'mssql'; break; + case 'mssqlnative': + $this->sql_layer = 'mssqlnative'; + break; + default: $this->sql_layer = $this->db->sql_layer; break; @@ -368,6 +402,7 @@ class phpbb_db_tools switch ($this->sql_layer) { case 'mssql': + case 'mssqlnative': $table_sql = 'CREATE TABLE [' . $table_name . '] (' . "\n"; break; @@ -386,6 +421,7 @@ class phpbb_db_tools switch ($this->sql_layer) { case 'mssql': + case 'mssqlnative': $columns[] = "\t [{$column_name}] " . $prepared_column['column_type_sql_default']; break; @@ -425,6 +461,7 @@ class phpbb_db_tools break; case 'mssql': + case 'mssqlnative': $table_sql .= "\n) ON [PRIMARY]" . (($create_textimage) ? ' TEXTIMAGE_ON [PRIMARY]' : ''); $statements[] = $table_sql; break; @@ -453,6 +490,7 @@ class phpbb_db_tools case 'firebird': case 'mssql': + case 'mssqlnative': // We need the data here $old_return_statements = $this->return_statements; $this->return_statements = true; @@ -573,7 +611,7 @@ class phpbb_db_tools * drop_columns: Removing/Dropping columns * add_primary_keys: adding primary keys * add_unique_index: adding an unique index - * add_index: adding an index + * add_index: adding an index (can be column:index_size if you need to provide size) * * The values are in this format: * {TABLE NAME} => array( @@ -970,6 +1008,7 @@ class phpbb_db_tools // same deal with PostgreSQL, we must perform more complex operations than // we technically could case 'mssql': + case 'mssqlnative': $sql = "SELECT c.name FROM syscolumns c LEFT JOIN sysobjects o ON c.id = o.id @@ -1187,6 +1226,7 @@ class phpbb_db_tools break; case 'mssql': + case 'mssqlnative': $sql .= " {$column_type} "; $sql_default = " {$column_type} "; @@ -1335,6 +1375,7 @@ class phpbb_db_tools break; case 'mssql': + case 'mssqlnative': $statements[] = 'ALTER TABLE [' . $table_name . '] ADD [' . $column_name . '] ' . $column_data['column_type_sql_default']; break; @@ -1455,6 +1496,7 @@ class phpbb_db_tools break; case 'mssql': + case 'mssqlnative': $statements[] = 'ALTER TABLE [' . $table_name . '] DROP COLUMN [' . $column_name . ']'; break; @@ -1549,6 +1591,7 @@ class phpbb_db_tools switch ($this->sql_layer) { case 'mssql': + case 'mssqlnative': $statements[] = 'DROP INDEX ' . $table_name . '.' . $index_name; break; @@ -1652,6 +1695,7 @@ class phpbb_db_tools break; case 'mssql': + case 'mssqlnative': $sql = "ALTER TABLE [{$table_name}] WITH NOCHECK ADD "; $sql .= "CONSTRAINT [PK_{$table_name}] PRIMARY KEY CLUSTERED ("; $sql .= '[' . implode("],\n\t\t[", $column) . ']'; @@ -1745,6 +1789,7 @@ class phpbb_db_tools break; case 'mssql': + case 'mssqlnative': $statements[] = 'CREATE UNIQUE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ') ON [PRIMARY]'; break; } @@ -1759,6 +1804,12 @@ class phpbb_db_tools { $statements = array(); + // remove index length unless MySQL4 + if ('mysql_40' != $this->sql_layer) + { + $column = preg_replace('#:.*$#', '', $column); + } + switch ($this->sql_layer) { case 'firebird': @@ -1769,11 +1820,22 @@ class phpbb_db_tools break; case 'mysql_40': + // add index size to definition as required by MySQL4 + foreach ($column as $i => $col) + { + if (false !== strpos($col, ':')) + { + list($col, $index_size) = explode(':', $col); + $column[$i] = "$col($index_size)"; + } + } + // no break case 'mysql_41': $statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; break; case 'mssql': + case 'mssqlnative': $statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ') ON [PRIMARY]'; break; } @@ -1791,7 +1853,7 @@ class phpbb_db_tools { $index_array = array(); - if ($this->sql_layer == 'mssql') + if ($this->sql_layer == 'mssql' || $this->sql_layer == 'mssqlnative') { $sql = "EXEC sp_statistics '$table_name'"; $result = $this->db->sql_query($sql); @@ -1900,6 +1962,7 @@ class phpbb_db_tools break; case 'mssql': + case 'mssqlnative': $statements[] = 'ALTER TABLE [' . $table_name . '] ALTER COLUMN [' . $column_name . '] ' . $column_data['column_type_sql']; if (!empty($column_data['default'])) diff --git a/phpBB/includes/db/firebird.php b/phpBB/includes/db/firebird.php index e554b0f2fb..6f60dd5dad 100644 --- a/phpBB/includes/db/firebird.php +++ b/phpBB/includes/db/firebird.php @@ -63,10 +63,19 @@ class dbal_firebird extends dbal /** * Version information about used database * @param bool $raw if true, only return the fetched sql_server_version + * @param bool $use_cache forced to false for Interbase * @return string sql server version */ - function sql_server_info($raw = false) + function sql_server_info($raw = false, $use_cache = true) { + /** + * force $use_cache false. I didn't research why the caching code there is no caching code + * but I assume its because the IB extension provides a direct method to access it + * without a query. + */ + + $use_cache = false; + if ($this->service_handle !== false && function_exists('ibase_server_info')) { return @ibase_server_info($this->service_handle, IBASE_SVC_SERVER_VERSION); diff --git a/phpBB/includes/db/mssql.php b/phpBB/includes/db/mssql.php index 7134574691..6899a73902 100644 --- a/phpBB/includes/db/mssql.php +++ b/phpBB/includes/db/mssql.php @@ -65,13 +65,14 @@ class dbal_mssql extends dbal /** * Version information about used database * @param bool $raw if true, only return the fetched sql_server_version + * @param bool $use_cache If true, it is safe to retrieve the value from the cache * @return string sql server version */ - function sql_server_info($raw = false) + function sql_server_info($raw = false, $use_cache = true) { global $cache; - if (empty($cache) || ($this->sql_server_version = $cache->get('mssql_version')) === false) + if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mssql_version')) === false) { $result_id = @mssql_query("SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY('productlevel'), SERVERPROPERTY('edition')", $this->db_connect_id); @@ -84,7 +85,7 @@ class dbal_mssql extends dbal $this->sql_server_version = ($row) ? trim(implode(' ', $row)) : 0; - if (!empty($cache)) + if (!empty($cache) && $use_cache) { $cache->put('mssql_version', $this->sql_server_version); } diff --git a/phpBB/includes/db/mssql_odbc.php b/phpBB/includes/db/mssql_odbc.php index 14c4831010..75a080b1b7 100644 --- a/phpBB/includes/db/mssql_odbc.php +++ b/phpBB/includes/db/mssql_odbc.php @@ -76,13 +76,14 @@ class dbal_mssql_odbc extends dbal /** * Version information about used database * @param bool $raw if true, only return the fetched sql_server_version + * @param bool $use_cache If true, it is safe to retrieve the value from the cache * @return string sql server version */ - function sql_server_info($raw = false) + function sql_server_info($raw = false, $use_cache = true) { global $cache; - if (empty($cache) || ($this->sql_server_version = $cache->get('mssqlodbc_version')) === false) + if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mssqlodbc_version')) === false) { $result_id = @odbc_exec($this->db_connect_id, "SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY('productlevel'), SERVERPROPERTY('edition')"); @@ -95,7 +96,7 @@ class dbal_mssql_odbc extends dbal $this->sql_server_version = ($row) ? trim(implode(' ', $row)) : 0; - if (!empty($cache)) + if (!empty($cache) && $use_cache) { $cache->put('mssqlodbc_version', $this->sql_server_version); } diff --git a/phpBB/includes/db/mssqlnative.php b/phpBB/includes/db/mssqlnative.php new file mode 100644 index 0000000000..7ed4146f27 --- /dev/null +++ b/phpBB/includes/db/mssqlnative.php @@ -0,0 +1,641 @@ +m_cursor = 0; + $this->m_rows = array(); + $this->m_num_fields = sqlsrv_num_fields($queryresult); + $this->m_field_meta = sqlsrv_field_metadata($queryresult); + + while ($row = sqlsrv_fetch_array($queryresult, SQLSRV_FETCH_ASSOC)) + { + if ($row !== null) + { + foreach($row as $k => $v) + { + if (is_object($v) && method_exists($v, 'format')) + { + $row[$k] = $v->format("Y-m-d\TH:i:s\Z"); + } + } + $this->m_rows[] = $row;//read results into memory, cursors are not supported + } + } + + $this->m_row_count = count($this->m_rows); + } + + private function array_to_obj($array, &$obj) + { + foreach ($array as $key => $value) + { + if (is_array($value)) + { + $obj->$key = new stdClass(); + array_to_obj($value, $obj->$key); + } + else + { + $obj->$key = $value; + } + } + return $obj; + } + + public function fetch($mode = SQLSRV_FETCH_BOTH, $object_class = 'stdClass') + { + if ($this->m_cursor >= $this->m_row_count || $this->m_row_count == 0) + { + return false; + } + + $ret = false; + $arr_num = array(); + + if ($mode == SQLSRV_FETCH_NUMERIC || $mode == SQLSRV_FETCH_BOTH) + { + foreach($this->m_rows[$this->m_cursor] as $key => $value) + { + $arr_num[] = $value; + } + } + + switch ($mode) + { + case SQLSRV_FETCH_ASSOC: + $ret = $this->m_rows[$this->m_cursor]; + break; + case SQLSRV_FETCH_NUMERIC: + $ret = $arr_num; + break; + case 'OBJECT': + $ret = $this->array_to_obj($this->m_rows[$this->m_cursor], $o = new $object_class); + break; + case SQLSRV_FETCH_BOTH: + default: + $ret = $this->m_rows[$this->m_cursor] + $arr_num; + break; + } + $this->m_cursor++; + return $ret; + } + + public function get($pos, $fld) + { + return $this->m_rows[$pos][$fld]; + } + + public function num_rows() + { + return $this->m_row_count; + } + + public function seek($iRow) + { + $this->m_cursor = min($iRow, $this->m_row_count); + } + + public function num_fields() + { + return $this->m_num_fields; + } + + public function field_name($nr) + { + $arr_keys = array_keys($this->m_rows[0]); + return $arr_keys[$nr]; + } + + public function field_type($nr) + { + $i = 0; + $int_type = -1; + $str_type = ''; + + foreach ($this->m_field_meta as $meta) + { + if ($nr == $i) + { + $int_type = $meta['Type']; + break; + } + $i++; + } + + //http://msdn.microsoft.com/en-us/library/cc296183.aspx contains type table + switch ($int_type) + { + case SQLSRV_SQLTYPE_BIGINT: $str_type = 'bigint'; break; + case SQLSRV_SQLTYPE_BINARY: $str_type = 'binary'; break; + case SQLSRV_SQLTYPE_BIT: $str_type = 'bit'; break; + case SQLSRV_SQLTYPE_CHAR: $str_type = 'char'; break; + case SQLSRV_SQLTYPE_DATETIME: $str_type = 'datetime'; break; + case SQLSRV_SQLTYPE_DECIMAL/*($precision, $scale)*/: $str_type = 'decimal'; break; + case SQLSRV_SQLTYPE_FLOAT: $str_type = 'float'; break; + case SQLSRV_SQLTYPE_IMAGE: $str_type = 'image'; break; + case SQLSRV_SQLTYPE_INT: $str_type = 'int'; break; + case SQLSRV_SQLTYPE_MONEY: $str_type = 'money'; break; + case SQLSRV_SQLTYPE_NCHAR/*($charCount)*/: $str_type = 'nchar'; break; + case SQLSRV_SQLTYPE_NUMERIC/*($precision, $scale)*/: $str_type = 'numeric'; break; + case SQLSRV_SQLTYPE_NVARCHAR/*($charCount)*/: $str_type = 'nvarchar'; break; + case SQLSRV_SQLTYPE_NTEXT: $str_type = 'ntext'; break; + case SQLSRV_SQLTYPE_REAL: $str_type = 'real'; break; + case SQLSRV_SQLTYPE_SMALLDATETIME: $str_type = 'smalldatetime'; break; + case SQLSRV_SQLTYPE_SMALLINT: $str_type = 'smallint'; break; + case SQLSRV_SQLTYPE_SMALLMONEY: $str_type = 'smallmoney'; break; + case SQLSRV_SQLTYPE_TEXT: $str_type = 'text'; break; + case SQLSRV_SQLTYPE_TIMESTAMP: $str_type = 'timestamp'; break; + case SQLSRV_SQLTYPE_TINYINT: $str_type = 'tinyint'; break; + case SQLSRV_SQLTYPE_UNIQUEIDENTIFIER: $str_type = 'uniqueidentifier'; break; + case SQLSRV_SQLTYPE_UDT: $str_type = 'UDT'; break; + case SQLSRV_SQLTYPE_VARBINARY/*($byteCount)*/: $str_type = 'varbinary'; break; + case SQLSRV_SQLTYPE_VARCHAR/*($charCount)*/: $str_type = 'varchar'; break; + case SQLSRV_SQLTYPE_XML: $str_type = 'xml'; break; + default: $str_type = $int_type; + } + return $str_type; + } + + public function free() + { + unset($this->m_rows); + return; + } +} + +/** +* @package dbal +*/ +class dbal_mssqlnative extends dbal +{ + var $m_insert_id = NULL; + var $last_query_text = ''; + var $query_options = array(); + + /** + * Connect to server + */ + function sql_connect($sqlserver, $sqluser, $sqlpassword, $database, $port = false, $persistency = false, $new_link = false) + { + # Test for driver support, to avoid suppressed fatal error + if (!function_exists('sqlsrv_connect')) + { + trigger_error('Native MS SQL Server driver for PHP is missing or needs to be updated. Version 1.1 or later is required to install phpBB3. You can download the driver from: http://www.microsoft.com/sqlserver/2005/en/us/PHP-Driver.aspx\n', E_USER_ERROR); + } + + //set up connection variables + $this->persistency = $persistency; + $this->user = $sqluser; + $this->dbname = $database; + $port_delimiter = (defined('PHP_OS') && substr(PHP_OS, 0, 3) === 'WIN') ? ',' : ':'; + $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, + 'PWD' => $sqlpassword + )); + + return ($this->db_connect_id) ? $this->db_connect_id : $this->sql_error(''); + } + + /** + * Version information about used database + * @param bool $raw if true, only return the fetched sql_server_version + * @param bool $use_cache If true, it is safe to retrieve the value from the cache + * @return string sql server version + */ + function sql_server_info($raw = false, $use_cache = true) + { + global $cache; + + if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mssql_version')) === false) + { + $arr_server_info = sqlsrv_server_info($this->db_connect_id); + $this->sql_server_version = $arr_server_info['SQLServerVersion']; + + if (!empty($cache) && $use_cache) + { + $cache->put('mssql_version', $this->sql_server_version); + } + } + + if ($raw) + { + return $this->sql_server_version; + } + + return ($this->sql_server_version) ? 'MSSQL
' . $this->sql_server_version : 'MSSQL'; + } + + /** + * SQL Transaction + * @access private + */ + function _sql_transaction($status = 'begin') + { + switch ($status) + { + case 'begin': + return sqlsrv_begin_transaction($this->db_connect_id); + break; + + case 'commit': + return sqlsrv_commit($this->db_connect_id); + break; + + case 'rollback': + return sqlsrv_rollback($this->db_connect_id); + break; + } + return true; + } + + /** + * Base query method + * + * @param string $query Contains the SQL query which shall be executed + * @param int $cache_ttl Either 0 to avoid caching or the time in seconds which the result shall be kept in cache + * @return mixed When casted to bool the returned value returns true on success and false on failure + * + * @access public + */ + function sql_query($query = '', $cache_ttl = 0) + { + if ($query != '') + { + global $cache; + + // EXPLAIN only in extra debug mode + if (defined('DEBUG_EXTRA')) + { + $this->sql_report('start', $query); + } + + $this->last_query_text = $query; + $this->query_result = ($cache_ttl && method_exists($cache, 'sql_load')) ? $cache->sql_load($query) : false; + $this->sql_add_num_queries($this->query_result); + + if ($this->query_result === false) + { + if (($this->query_result = @sqlsrv_query($this->db_connect_id, $query, array(), $this->query_options)) === false) + { + $this->sql_error($query); + } + // reset options for next query + $this->query_options = array(); + + if (defined('DEBUG_EXTRA')) + { + $this->sql_report('stop', $query); + } + + if ($cache_ttl && method_exists($cache, 'sql_save')) + { + $this->open_queries[(int) $this->query_result] = $this->query_result; + $cache->sql_save($query, $this->query_result, $cache_ttl); + } + else if (strpos($query, 'SELECT') === 0 && $this->query_result) + { + $this->open_queries[(int) $this->query_result] = $this->query_result; + } + } + else if (defined('DEBUG_EXTRA')) + { + $this->sql_report('fromcache', $query); + } + } + else + { + return false; + } + return $this->query_result; + } + + /** + * Build LIMIT query + */ + function _sql_query_limit($query, $total, $offset = 0, $cache_ttl = 0) + { + $this->query_result = false; + + // total == 0 means all results - not zero results + if ($offset == 0 && $total !== 0) + { + if (strpos($query, "SELECT") === false) + { + $query = "TOP {$total} " . $query; + } + else + { + $query = preg_replace('/SELECT(\s*DISTINCT)?/Dsi', 'SELECT$1 TOP '.$total, $query); + } + } + else if ($offset > 0) + { + $query = preg_replace('/SELECT(\s*DISTINCT)?/Dsi', 'SELECT$1 TOP(10000000) ', $query); + $query = 'SELECT * + FROM (SELECT sub2.*, ROW_NUMBER() OVER(ORDER BY sub2.line2) AS line3 + FROM (SELECT 1 AS line2, sub1.* FROM (' . $query . ') AS sub1) as sub2) AS sub3'; + + if ($total > 0) + { + $query .= ' WHERE line3 BETWEEN ' . ($offset+1) . ' AND ' . ($offset + $total); + } + else + { + $query .= ' WHERE line3 > ' . $offset; + } + } + + $result = $this->sql_query($query, $cache_ttl); + + return $result; + } + + /** + * Return number of affected rows + */ + function sql_affectedrows() + { + return ($this->db_connect_id) ? @sqlsrv_rows_affected($this->db_connect_id) : false; + } + + /** + * Fetch current row + */ + function sql_fetchrow($query_id = false) + { + global $cache; + + if ($query_id === false) + { + $query_id = $this->query_result; + } + + if (isset($cache->sql_rowset[$query_id])) + { + return $cache->sql_fetchrow($query_id); + } + + if ($query_id === false) + { + return false; + } + + $row = @sqlsrv_fetch_array($query_id, SQLSRV_FETCH_ASSOC); + + if ($row) + { + foreach ($row as $key => $value) + { + $row[$key] = ($value === ' ' || $value === NULL) ? '' : $value; + } + + // remove helper values from LIMIT queries + if (isset($row['line2'])) + { + unset($row['line2'], $row['line3']); + } + } + return $row; + } + + /** + * Seek to given row number + * rownum is zero-based + */ + function sql_rowseek($rownum, &$query_id) + { + global $cache; + + if (isset($cache->sql_rowset[$query_id])) + { + return $cache->sql_rowseek($rownum, $query_id); + } + + $seek = new result_mssqlnative($query_id); + $row = $seek->seek($rownum); + return ($row = $seek->fetch()) ? $row : false; + } + + /** + * Get last inserted id after insert statement + */ + function sql_nextid() + { + $result_id = @sqlsrv_query($this->db_connect_id, 'SELECT @@IDENTITY'); + + if ($result_id !== false) + { + $row = @sqlsrv_fetch_array($result_id); + $id = $row[0]; + @sqlsrv_free_stmt($result_id); + return $id; + } + else + { + return false; + } + } + + /** + * Free sql result + */ + function sql_freeresult($query_id = false) + { + global $cache; + + if ($query_id === false) + { + $query_id = $this->query_result; + } + + if (isset($cache->sql_rowset[$query_id])) + { + return $cache->sql_freeresult($query_id); + } + + if (isset($this->open_queries[$query_id])) + { + unset($this->open_queries[$query_id]); + return @sqlsrv_free_stmt($query_id); + } + return false; + } + + /** + * Escape string used in sql query + */ + function sql_escape($msg) + { + return str_replace(array("'", "\0"), array("''", ''), $msg); + } + + /** + * Build LIKE expression + * @access private + */ + function _sql_like_expression($expression) + { + return $expression . " ESCAPE '\\'"; + } + + /** + * return sql error array + * @access private + */ + function _sql_error() + { + $errors = @sqlsrv_errors(SQLSRV_ERR_ERRORS); + $error_message = ''; + $code = 0; + + if ($errors != null) + { + foreach ($errors as $error) + { + $error_message .= "SQLSTATE: ".$error[ 'SQLSTATE']."\n"; + $error_message .= "code: ".$error[ 'code']."\n"; + $code = $error['code']; + $error_message .= "message: ".$error[ 'message']."\n"; + } + $this->last_error_result = $error_message; + $error = $this->last_error_result; + } + else + { + $error = (isset($this->last_error_result) && $this->last_error_result) ? $this->last_error_result : array(); + } + + return array( + 'message' => $error, + 'code' => $code, + ); + } + + /** + * Build db-specific query data + * @access private + */ + function _sql_custom_build($stage, $data) + { + return $data; + } + + /** + * Close sql connection + * @access private + */ + function _sql_close() + { + return @sqlsrv_close($this->db_connect_id); + } + + /** + * Build db-specific report + * @access private + */ + function _sql_report($mode, $query = '') + { + switch ($mode) + { + case 'start': + $html_table = false; + @sqlsrv_query($this->db_connect_id, 'SET SHOWPLAN_TEXT ON;'); + if ($result = @sqlsrv_query($this->db_connect_id, $query)) + { + @sqlsrv_next_result($result); + while ($row = @sqlsrv_fetch_array($result)) + { + $html_table = $this->sql_report('add_select_row', $query, $html_table, $row); + } + } + @sqlsrv_query($this->db_connect_id, 'SET SHOWPLAN_TEXT OFF;'); + @sqlsrv_free_stmt($result); + + if ($html_table) + { + $this->html_hold .= ''; + } + break; + + case 'fromcache': + $endtime = explode(' ', microtime()); + $endtime = $endtime[0] + $endtime[1]; + + $result = @sqlsrv_query($this->db_connect_id, $query); + while ($void = @sqlsrv_fetch_array($result)) + { + // Take the time spent on parsing rows into account + } + @sqlsrv_free_stmt($result); + + $splittime = explode(' ', microtime()); + $splittime = $splittime[0] + $splittime[1]; + + $this->sql_report('record_fromcache', $query, $endtime, $splittime); + + break; + } + } + + /** + * Utility method used to retrieve number of rows + * Emulates mysql_num_rows + * Used in acp_database.php -> write_data_mssqlnative() + * Requires a static or keyset cursor to be definde via + * mssqlnative_set_query_options() + */ + function mssqlnative_num_rows($res) + { + if ($res !== false) + { + return sqlsrv_num_rows($res); + } + else + { + return false; + } + } + + /** + * Allows setting mssqlnative specific query options passed to sqlsrv_query as 4th parameter. + */ + function mssqlnative_set_query_options($options) + { + $this->query_options = $options; + } +} + +?> diff --git a/phpBB/includes/db/mysql.php b/phpBB/includes/db/mysql.php index 0487dfa6d2..1e24c79577 100644 --- a/phpBB/includes/db/mysql.php +++ b/phpBB/includes/db/mysql.php @@ -96,13 +96,14 @@ class dbal_mysql extends dbal /** * Version information about used database * @param bool $raw if true, only return the fetched sql_server_version + * @param bool $use_cache If true, it is safe to retrieve the value from the cache * @return string sql server version */ - function sql_server_info($raw = false) + function sql_server_info($raw = false, $use_cache = true) { global $cache; - if (empty($cache) || ($this->sql_server_version = $cache->get('mysql_version')) === false) + if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mysql_version')) === false) { $result = @mysql_query('SELECT VERSION() AS version', $this->db_connect_id); $row = @mysql_fetch_assoc($result); @@ -110,7 +111,7 @@ class dbal_mysql extends dbal $this->sql_server_version = $row['version']; - if (!empty($cache)) + if (!empty($cache) && $use_cache) { $cache->put('mysql_version', $this->sql_server_version); } diff --git a/phpBB/includes/db/mysqli.php b/phpBB/includes/db/mysqli.php index f0e58fd148..862d62f4ba 100644 --- a/phpBB/includes/db/mysqli.php +++ b/phpBB/includes/db/mysqli.php @@ -80,14 +80,14 @@ class dbal_mysqli extends dbal /** * Version information about used database - * @param bool $raw if true, only return the fetched sql_server_version + * @param bool $use_cache If true, it is safe to retrieve the value from the cache * @return string sql server version */ - function sql_server_info($raw = false) + function sql_server_info($raw = false, $use_cache = true) { global $cache; - if (empty($cache) || ($this->sql_server_version = $cache->get('mysqli_version')) === false) + if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('mysqli_version')) === false) { $result = @mysqli_query($this->db_connect_id, 'SELECT VERSION() AS version'); $row = @mysqli_fetch_assoc($result); @@ -95,7 +95,7 @@ class dbal_mysqli extends dbal $this->sql_server_version = $row['version']; - if (!empty($cache)) + if (!empty($cache) && $use_cache) { $cache->put('mysqli_version', $this->sql_server_version); } diff --git a/phpBB/includes/db/oracle.php b/phpBB/includes/db/oracle.php index 55b3599800..c8a9a5f604 100644 --- a/phpBB/includes/db/oracle.php +++ b/phpBB/includes/db/oracle.php @@ -56,10 +56,18 @@ class dbal_oracle extends dbal /** * Version information about used database * @param bool $raw if true, only return the fetched sql_server_version + * @param bool $use_cache forced to false for Oracle * @return string sql server version */ - function sql_server_info($raw = false) + function sql_server_info($raw = false, $use_cache = true) { + /** + * force $use_cache false. I didn't research why the caching code below is commented out + * but I assume its because the Oracle extension provides a direct method to access it + * without a query. + */ + + $use_cache = false; /* global $cache; @@ -261,6 +269,10 @@ class dbal_oracle extends dbal { $cols = explode(', ', $regs[2]); +/* The code inside this comment block breaks clob handling, but does allow the + database restore script to work. If you want to allow no posts longer than 4KB + and/or need the db restore script, uncomment this. + preg_match_all('/\'(?:[^\']++|\'\')*+\'|[\d-.]+/', $regs[3], $vals, PREG_PATTERN_ORDER); if (sizeof($cols) !== sizeof($vals)) @@ -310,6 +322,7 @@ class dbal_oracle extends dbal $vals = array(0 => $vals); } +*/ $inserts = $vals[0]; unset($vals); diff --git a/phpBB/includes/db/postgres.php b/phpBB/includes/db/postgres.php index d117e8c948..4360c790a1 100644 --- a/phpBB/includes/db/postgres.php +++ b/phpBB/includes/db/postgres.php @@ -46,7 +46,10 @@ class dbal_postgres extends dbal if ($sqlserver) { - if (strpos($sqlserver, ':') !== false) + // $sqlserver can carry a port separated by : for compatibility reasons + // If $sqlserver has more than one : it's probably an IPv6 address. + // In this case we only allow passing a port via the $port variable. + if (substr_count($sqlserver, ':') === 1) { list($sqlserver, $port) = explode(':', $sqlserver); } @@ -76,7 +79,14 @@ class dbal_postgres extends dbal $this->persistency = $persistency; - $this->db_connect_id = ($this->persistency) ? @pg_pconnect($connect_string, $new_link) : @pg_connect($connect_string, $new_link); + if ($this->persistency) + { + $this->db_connect_id = (!$new_link) ? @pg_pconnect($connect_string) : @pg_pconnect($connect_string, PGSQL_CONNECT_FORCE_NEW); + } + else + { + $this->db_connect_id = (!$new_link) ? @pg_connect($connect_string) : @pg_connect($connect_string, PGSQL_CONNECT_FORCE_NEW); + } if ($this->db_connect_id) { @@ -98,13 +108,14 @@ class dbal_postgres extends dbal /** * Version information about used database * @param bool $raw if true, only return the fetched sql_server_version + * @param bool $use_cache If true, it is safe to retrieve the value from the cache * @return string sql server version */ - function sql_server_info($raw = false) + function sql_server_info($raw = false, $use_cache = true) { global $cache; - if (empty($cache) || ($this->sql_server_version = $cache->get('pgsql_version')) === false) + if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('pgsql_version')) === false) { $query_id = @pg_query($this->db_connect_id, 'SELECT VERSION() AS version'); $row = @pg_fetch_assoc($query_id, null); @@ -112,7 +123,7 @@ class dbal_postgres extends dbal $this->sql_server_version = (!empty($row['version'])) ? trim(substr($row['version'], 10)) : 0; - if (!empty($cache)) + if (!empty($cache) && $use_cache) { $cache->put('pgsql_version', $this->sql_server_version); } diff --git a/phpBB/includes/db/sqlite.php b/phpBB/includes/db/sqlite.php index 288f6e0992..8de72fd394 100644 --- a/phpBB/includes/db/sqlite.php +++ b/phpBB/includes/db/sqlite.php @@ -50,19 +50,24 @@ class dbal_sqlite extends dbal /** * Version information about used database * @param bool $raw if true, only return the fetched sql_server_version + * @param bool $use_cache if true, it is safe to retrieve the stored value from the cache * @return string sql server version */ - function sql_server_info($raw = false) + function sql_server_info($raw = false, $use_cache = true) { global $cache; - if (empty($cache) || ($this->sql_server_version = $cache->get('sqlite_version')) === false) + if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('sqlite_version')) === false) { $result = @sqlite_query('SELECT sqlite_version() AS version', $this->db_connect_id); $row = @sqlite_fetch_array($result, SQLITE_ASSOC); $this->sql_server_version = (!empty($row['version'])) ? $row['version'] : 0; - $cache->put('sqlite_version', $this->sql_server_version); + + if (!empty($cache) && $use_cache) + { + $cache->put('sqlite_version', $this->sql_server_version); + } } return ($raw) ? $this->sql_server_version : 'SQLite ' . $this->sql_server_version; diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 4b73aa4af9..561a9906c4 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -114,7 +114,7 @@ function request_var($var_name, $default, $multibyte = false, $cookie = false) { $_v = null; } - set_var($_k, $_k, $sub_key_type); + set_var($_k, $_k, $sub_key_type, $multibyte); set_var($var[$k][$_k], $_v, $sub_type, $multibyte); } } @@ -175,11 +175,8 @@ function set_config_count($config_name, $increment, $is_dynamic = false) switch ($db->sql_layer) { case 'firebird': - $sql_update = 'CAST(CAST(config_value as integer) + ' . (int) $increment . ' as VARCHAR(255))'; - break; - case 'postgres': - $sql_update = 'int4(config_value) + ' . (int) $increment; + $sql_update = 'CAST(CAST(config_value as DECIMAL(255, 0)) + ' . (int) $increment . ' as VARCHAR(255))'; break; // MySQL, SQlite, mssql, mssql_odbc, oracle @@ -198,11 +195,28 @@ function set_config_count($config_name, $increment, $is_dynamic = false) /** * Generates an alphanumeric random string of given length +* +* @return string */ function gen_rand_string($num_chars = 8) +{ + // [a, z] + [0, 9] = 36 + return substr(strtoupper(base_convert(unique_id(), 16, 36)), 0, $num_chars); +} + +/** +* Generates a user-friendly alphanumeric random string of given length +* We remove 0 and O so users cannot confuse those in passwords etc. +* +* @return string +*/ +function gen_rand_string_friendly($num_chars = 8) { $rand_str = unique_id(); - $rand_str = str_replace('0', 'Z', strtoupper(base_convert($rand_str, 16, 35))); + + // Remove Z and Y from the base_convert(), replace 0 with Z and O with Y + // [a, z] + [0, 9] - {z, y} = [a, z] + [0, 9] - {0, o} = 34 + $rand_str = str_replace(array('0', 'O'), array('Z', 'Y'), strtoupper(base_convert($rand_str, 16, 34))); return substr($rand_str, 0, $num_chars); } @@ -704,7 +718,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) clearstatcache(); - if (is_readable($filename) && is_writable($filename)) + if (is_readable($filename) && phpbb_is_writable($filename)) { break; } @@ -714,7 +728,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) clearstatcache(); - if ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename))) + if ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || phpbb_is_writable($filename))) { break; } @@ -724,7 +738,7 @@ function phpbb_chmod($filename, $perms = CHMOD_READ) clearstatcache(); - if ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || is_writable($filename))) + if ((!($perms & CHMOD_READ) || is_readable($filename)) && (!($perms & CHMOD_WRITE) || phpbb_is_writable($filename))) { break; } @@ -1038,7 +1052,7 @@ function phpbb_own_realpath($path) // @todo If the file exists fine and open_basedir only has one path we should be able to prepend it // because we must be inside that basedir, the question is where... // @internal The slash in is_dir() gets around an open_basedir restriction - if (!@file_exists($resolved) || (!is_dir($resolved . '/') && !is_file($resolved))) + if (!@file_exists($resolved) || (!@is_dir($resolved . '/') && !is_file($resolved))) { return false; } @@ -1663,10 +1677,11 @@ function get_complete_topic_tracking($forum_id, $topic_ids, $global_announce_lis * @param string $sql_extra Extra WHERE SQL statement * @param string $sql_sort ORDER BY SQL sorting statement * @param string $sql_limit Limits the size of unread topics list, 0 for unlimited query +* @param string $sql_limit_offset Sets the offset of the first row to search, 0 to search from the start * * @return array[int][int] Topic ids as keys, mark_time of topic as value */ -function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001) +function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $sql_limit = 1001, $sql_limit_offset = 0) { global $config, $db, $user; @@ -1712,7 +1727,7 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s ); $sql = $db->sql_build_query('SELECT', $sql_array); - $result = $db->sql_query_limit($sql, $sql_limit); + $result = $db->sql_query_limit($sql, $sql_limit, $sql_limit_offset); while ($row = $db->sql_fetchrow($result)) { @@ -1745,7 +1760,7 @@ function get_unread_topics($user_id = false, $sql_extra = '', $sql_sort = '', $s WHERE t.topic_last_post_time > ' . $user_lastmark . " $sql_extra $sql_sort"; - $result = $db->sql_query_limit($sql, $sql_limit); + $result = $db->sql_query_limit($sql, $sql_limit, $sql_limit_offset); while ($row = $db->sql_fetchrow($result)) { @@ -2139,8 +2154,8 @@ function append_sid($url, $params = false, $is_amp = true, $session_id = false) { global $_SID, $_EXTRA_URL, $phpbb_hook; - // Developers using the hook function need to globalise the $_SID and $_EXTRA_URL on their own and also handle it appropiatly. - // They could mimick most of what is within this function + // 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)) { if ($phpbb_hook->hook_return(__FUNCTION__)) @@ -2297,6 +2312,8 @@ function redirect($url, $return = false, $disable_cd_check = false) { global $db, $cache, $config, $user, $phpbb_root_path; + $failover_flag = false; + if (empty($user->lang)) { $user->add_lang('common'); @@ -2336,61 +2353,78 @@ function redirect($url, $return = false, $disable_cd_check = false) // Relative uri $pathinfo = pathinfo($url); - // Is the uri pointing to the current directory? - if ($pathinfo['dirname'] == '.') + if (!$disable_cd_check && !file_exists($pathinfo['dirname'])) { - $url = str_replace('./', '', $url); + $url = str_replace('../', '', $url); + $pathinfo = pathinfo($url); - // Strip / from the beginning - if ($url && substr($url, 0, 1) == '/') + if (!file_exists($pathinfo['dirname'])) { - $url = substr($url, 1); + // fallback to "last known user page" + // at least this way we know the user does not leave the phpBB root + $url = generate_board_url() . '/' . $user->page['page']; + $failover_flag = true; } + } - if ($user->page['page_dir']) + if (!$failover_flag) + { + // Is the uri pointing to the current directory? + if ($pathinfo['dirname'] == '.') { - $url = generate_board_url() . '/' . $user->page['page_dir'] . '/' . $url; + $url = str_replace('./', '', $url); + + // Strip / from the beginning + if ($url && substr($url, 0, 1) == '/') + { + $url = substr($url, 1); + } + + if ($user->page['page_dir']) + { + $url = generate_board_url() . '/' . $user->page['page_dir'] . '/' . $url; + } + else + { + $url = generate_board_url() . '/' . $url; + } } else { + // Used ./ before, but $phpbb_root_path is working better with urls within another root path + $root_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($phpbb_root_path))); + $page_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($pathinfo['dirname']))); + $intersection = array_intersect_assoc($root_dirs, $page_dirs); + + $root_dirs = array_diff_assoc($root_dirs, $intersection); + $page_dirs = array_diff_assoc($page_dirs, $intersection); + + $dir = str_repeat('../', sizeof($root_dirs)) . implode('/', $page_dirs); + + // Strip / from the end + if ($dir && substr($dir, -1, 1) == '/') + { + $dir = substr($dir, 0, -1); + } + + // Strip / from the beginning + if ($dir && substr($dir, 0, 1) == '/') + { + $dir = substr($dir, 1); + } + + $url = str_replace($pathinfo['dirname'] . '/', '', $url); + + // Strip / from the beginning + if (substr($url, 0, 1) == '/') + { + $url = substr($url, 1); + } + + $url = (!empty($dir) ? $dir . '/' : '') . $url; $url = generate_board_url() . '/' . $url; } } - else - { - // Used ./ before, but $phpbb_root_path is working better with urls within another root path - $root_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($phpbb_root_path))); - $page_dirs = explode('/', str_replace('\\', '/', phpbb_realpath($pathinfo['dirname']))); - $intersection = array_intersect_assoc($root_dirs, $page_dirs); - - $root_dirs = array_diff_assoc($root_dirs, $intersection); - $page_dirs = array_diff_assoc($page_dirs, $intersection); - - $dir = str_repeat('../', sizeof($root_dirs)) . implode('/', $page_dirs); - - // Strip / from the end - if ($dir && substr($dir, -1, 1) == '/') - { - $dir = substr($dir, 0, -1); - } - - // Strip / from the beginning - if ($dir && substr($dir, 0, 1) == '/') - { - $dir = substr($dir, 1); - } - - $url = str_replace($pathinfo['dirname'] . '/', '', $url); - - // Strip / from the beginning - if (substr($url, 0, 1) == '/') - { - $url = substr($url, 1); - } - - $url = (!empty($dir) ? $dir . '/' : '') . $url; - $url = generate_board_url() . '/' . $url; - } } // Make sure no linebreaks are there... to prevent http response splitting for PHP < 4.4.2 @@ -2502,6 +2536,11 @@ function build_url($strip_vars = false) $key = $arguments[0]; unset($arguments[0]); + if ($key === '') + { + continue; + } + $query[$key] = implode('=', $arguments); } @@ -2562,6 +2601,47 @@ function meta_refresh($time, $url, $disable_cd_check = false) return $url; } +/** +* Outputs correct status line header. +* +* Depending on php sapi one of the two following forms is used: +* +* Status: 404 Not Found +* +* HTTP/1.x 404 Not Found +* +* HTTP version is taken from HTTP_VERSION environment variable, +* and defaults to 1.0. +* +* Sample usage: +* +* send_status_line(404, 'Not Found'); +* +* @param int $code HTTP status code +* @param string $message Message for the status code +* @return void +*/ +function send_status_line($code, $message) +{ + if (substr(strtolower(@php_sapi_name()), 0, 3) === 'cgi') + { + // in theory, we shouldn't need that due to php doing it. Reality offers a differing opinion, though + header("Status: $code $message", true, $code); + } + else + { + if (isset($_SERVER['HTTP_VERSION'])) + { + $version = $_SERVER['HTTP_VERSION']; + } + else + { + $version = 'HTTP/1.0'; + } + header("$version $code $message", true, $code); + } +} + //Form validation @@ -3297,7 +3377,9 @@ function get_preg_expression($mode) switch ($mode) { case 'email': - return '(?:[a-z0-9\'\.\-_\+\|]++|&)+@[a-z0-9\-]+\.(?:[a-z0-9\-]+\.)*[a-z]+'; + // 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})?)'; break; case 'bbcode_htm': @@ -3319,7 +3401,7 @@ function get_preg_expression($mode) break; case 'ipv6': - return '#^(?:(?:(?:[\dA-F]{1,4}:){6}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:::(?:[\dA-F]{1,4}:){5}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:):(?:[\dA-F]{1,4}:){4}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,2}:(?:[\dA-F]{1,4}:){3}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,3}:(?:[\dA-F]{1,4}:){2}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,4}:(?:[\dA-F]{1,4}:)(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,5}:(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,6}:[\dA-F]{1,4})|(?:(?:[\dA-F]{1,4}:){1,7}:))$#i'; + return '#^(?:(?:(?:[\dA-F]{1,4}:){6}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:::(?:[\dA-F]{1,4}:){0,5}(?:[\dA-F]{1,4}(?::[\dA-F]{1,4})?|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:):(?:[\dA-F]{1,4}:){4}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,2}:(?:[\dA-F]{1,4}:){3}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,3}:(?:[\dA-F]{1,4}:){2}(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,4}:(?:[\dA-F]{1,4}:)(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,5}:(?:[\dA-F]{1,4}:[\dA-F]{1,4}|(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])))|(?:(?:[\dA-F]{1,4}:){1,6}:[\dA-F]{1,4})|(?:(?:[\dA-F]{1,4}:){1,7}:)|(?:::))$#i'; break; case 'url': @@ -3380,25 +3462,110 @@ function short_ipv6($ip, $length) /** * Wrapper for php's checkdnsrr function. * -* The windows failover is from the php manual -* Please make sure to check the return value for === true and === false, since NULL could -* be returned too. +* @param string $host Fully-Qualified Domain Name +* @param string $type Resource record type to lookup +* Supported types are: MX (default), A, AAAA, NS, TXT, CNAME +* Other types may work or may not work * -* @return true if entry found, false if not, NULL if this function is not supported by this environment +* @return mixed true if entry found, +* false if entry not found, +* null if this function is not supported by this environment +* +* Since null can also be returned, you probably want to compare the result +* with === true or === false, +* +* @author bantu */ -function phpbb_checkdnsrr($host, $type = '') +function phpbb_checkdnsrr($host, $type = 'MX') { - $type = (!$type) ? 'MX' : $type; - - if (DIRECTORY_SEPARATOR == '\\') + // The dot indicates to search the DNS root (helps those having DNS prefixes on the same domain) + if (substr($host, -1) == '.') { - if (!function_exists('exec')) + $host_fqdn = $host; + $host = substr($host, 0, -1); + } + else + { + $host_fqdn = $host . '.'; + } + // $host has format some.host.example.com + // $host_fqdn has format some.host.example.com. + + // If we're looking for an A record we can use gethostbyname() + if ($type == 'A' && function_exists('gethostbyname')) + { + return (@gethostbyname($host_fqdn) == $host_fqdn) ? false : true; + } + + // checkdnsrr() is available on Windows since PHP 5.3, + // but until 5.3.3 it only works for MX records + // See: http://bugs.php.net/bug.php?id=51844 + + // Call checkdnsrr() if + // we're looking for an MX record or + // we're not on Windows or + // we're running a PHP version where #51844 has been fixed + + // checkdnsrr() supports AAAA since 5.0.0 + // checkdnsrr() supports TXT since 5.2.4 + if ( + ($type == 'MX' || DIRECTORY_SEPARATOR != '\\' || version_compare(PHP_VERSION, '5.3.3', '>=')) && + ($type != 'AAAA' || version_compare(PHP_VERSION, '5.0.0', '>=')) && + ($type != 'TXT' || version_compare(PHP_VERSION, '5.2.4', '>=')) && + function_exists('checkdnsrr') + ) + { + return checkdnsrr($host_fqdn, $type); + } + + // dns_get_record() is available since PHP 5; since PHP 5.3 also on Windows, + // but on Windows it does not work reliable for AAAA records before PHP 5.3.1 + + // Call dns_get_record() if + // we're not looking for an AAAA record or + // we're not on Windows or + // we're running a PHP version where AAAA lookups work reliable + if ( + ($type != 'AAAA' || DIRECTORY_SEPARATOR != '\\' || version_compare(PHP_VERSION, '5.3.1', '>=')) && + function_exists('dns_get_record') + ) + { + // dns_get_record() expects an integer as second parameter + // We have to convert the string $type to the corresponding integer constant. + $type_constant = 'DNS_' . $type; + $type_param = (defined($type_constant)) ? constant($type_constant) : DNS_ANY; + + // dns_get_record() might throw E_WARNING and return false for records that do not exist + $resultset = @dns_get_record($host_fqdn, $type_param); + + if (empty($resultset) || !is_array($resultset)) { - return NULL; + return false; + } + else if ($type_param == DNS_ANY) + { + // $resultset is a non-empty array + return true; } - // @exec('nslookup -retry=1 -timout=1 -type=' . escapeshellarg($type) . ' ' . escapeshellarg($host), $output); - @exec('nslookup -type=' . escapeshellarg($type) . ' ' . escapeshellarg($host) . '.', $output); + foreach ($resultset as $result) + { + if ( + isset($result['host']) && $result['host'] == $host && + isset($result['type']) && $result['type'] == $type + ) + { + return true; + } + } + + return false; + } + + // If we're on Windows we can still try to call nslookup via exec() as a last resort + if (DIRECTORY_SEPARATOR == '\\' && function_exists('exec')) + { + @exec('nslookup -type=' . escapeshellarg($type) . ' ' . escapeshellarg($host_fqdn), $output); // If output is empty, the nslookup failed if (empty($output)) @@ -3408,25 +3575,71 @@ function phpbb_checkdnsrr($host, $type = '') foreach ($output as $line) { - if (!trim($line)) + $line = trim($line); + + if (empty($line)) { continue; } - // Valid records begin with host name: - if (strpos($line, $host) === 0) + // Squash tabs and multiple whitespaces to a single whitespace. + $line = preg_replace('/\s+/', ' ', $line); + + switch ($type) { - return true; + case 'MX': + if (stripos($line, "$host MX") === 0) + { + return true; + } + break; + + case 'NS': + if (stripos($line, "$host nameserver") === 0) + { + return true; + } + break; + + case 'TXT': + if (stripos($line, "$host text") === 0) + { + return true; + } + break; + + case 'CNAME': + if (stripos($line, "$host canonical name") === 0) + { + return true; + } + + default: + case 'A': + case 'AAAA': + if (!empty($host_matches)) + { + // Second line + if (stripos($line, "Address: ") === 0) + { + return true; + } + else + { + $host_matches = false; + } + } + else if (stripos($line, "Name: $host") === 0) + { + // First line + $host_matches = true; + } + break; } } return false; } - else if (function_exists('checkdnsrr')) - { - // The dot indicates to search the DNS root (helps those having DNS prefixes on the same domain) - return (checkdnsrr($host . '.', $type)) ? true : false; - } return NULL; } @@ -3540,7 +3753,7 @@ function msg_handler($errno, $msg_text, $errfile, $errline) } // Do not send 200 OK, but service unavailable on errors - header('HTTP/1.1 503 Service Unavailable'); + send_status_line(503, 'Service Unavailable'); garbage_collection(); @@ -3609,6 +3822,11 @@ function msg_handler($errno, $msg_text, $errfile, $errline) $user->setup(); } + if ($msg_text == 'ERROR_NO_ATTACHMENT' || $msg_text == 'NO_FORUM' || $msg_text == 'NO_TOPIC' || $msg_text == 'NO_USER') + { + send_status_line(404, 'Not Found'); + } + $msg_text = (!empty($user->lang[$msg_text])) ? $user->lang[$msg_text] : $msg_text; $msg_title = (!isset($msg_title)) ? $user->lang['INFORMATION'] : ((!empty($user->lang[$msg_title])) ? $user->lang[$msg_title] : $msg_title); @@ -4005,7 +4223,8 @@ function phpbb_http_login($param) } else if ($auth_result['status'] == LOGIN_ERROR_ATTEMPTS) { - header('HTTP/1.0 401 Unauthorized'); + send_status_line(401, 'Unauthorized'); + trigger_error('NOT_AUTHORISED'); } } @@ -4017,7 +4236,7 @@ function phpbb_http_login($param) $param['auth_message'] = preg_replace('/[\x80-\xFF]/', '?', $param['auth_message']); header('WWW-Authenticate: Basic realm="' . $param['auth_message'] . '"'); - header('HTTP/1.0 401 Unauthorized'); + send_status_line(401, 'Unauthorized'); trigger_error('NOT_AUTHORISED'); } @@ -4238,7 +4457,7 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'S_TOPIC_ID' => $topic_id, 'S_LOGIN_ACTION' => ((!defined('ADMIN_START')) ? append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login') : append_sid("index.$phpEx", false, true, $user->session_id)), - 'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => str_replace('&', '&', build_url()))), + 'S_LOGIN_REDIRECT' => build_hidden_fields(array('redirect' => build_url())), 'S_ENABLE_FEEDS' => ($config['feed_enable']) ? true : false, 'S_ENABLE_FEEDS_OVERALL' => ($config['feed_overall']) ? true : false, @@ -4247,6 +4466,8 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0 'S_ENABLE_FEEDS_TOPICS_ACTIVE' => ($config['feed_topics_active']) ? true : false, 'S_ENABLE_FEEDS_NEWS' => ($s_feed_news) ? true : false, + 'S_LOAD_UNREADS' => ($config['load_unreads_search'] && ($config['load_anon_lastread'] || $user->data['is_registered'])) ? true : false, + 'T_THEME_PATH' => "{$web_path}styles/" . $user->theme['theme_path'] . '/theme', 'T_TEMPLATE_PATH' => "{$web_path}styles/" . $user->theme['template_path'] . '/template', 'T_SUPER_TEMPLATE_PATH' => (isset($user->theme['template_inherit_path']) && $user->theme['template_inherit_path']) ? "{$web_path}styles/" . $user->theme['template_inherit_path'] . '/template' : "{$web_path}styles/" . $user->theme['template_path'] . '/template', @@ -4259,7 +4480,7 @@ 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' => (!$user->theme['theme_storedb']) ? "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : append_sid("{$phpbb_root_path}style.$phpEx", 'id=' . $user->theme['style_id'] . '&lang=' . $user->data['user_lang'], true, $user->session_id), + 'T_STYLESHEET_LINK' => (!$user->theme['theme_storedb']) ? "{$web_path}styles/" . $user->theme['theme_path'] . '/theme/stylesheet.css' : append_sid("{$phpbb_root_path}style.$phpEx", 'id=' . $user->theme['style_id'] . '&lang=' . $user->data['user_lang']), 'T_STYLESHEET_NAME' => $user->theme['theme_name'], 'T_THEME_NAME' => $user->theme['theme_path'], diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index c033684ae1..2aa12adb2e 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -96,16 +96,12 @@ function make_forum_select($select_id = false, $ignore_id = false, $ignore_acl = $right = $row['right_id']; $disabled = false; - if (!$ignore_acl && $auth->acl_get('f_list', $row['forum_id'])) + if (!$ignore_acl && $auth->acl_gets(array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel'), $row['forum_id'])) { if ($only_acl_post && !$auth->acl_get('f_post', $row['forum_id']) || (!$auth->acl_get('m_approve', $row['forum_id']) && !$auth->acl_get('f_noapprove', $row['forum_id']))) { $disabled = true; } - else if (!$only_acl_post && !$auth->acl_gets(array('f_list', 'a_forum', 'a_forumadd', 'a_forumdel'), $row['forum_id'])) - { - $disabled = true; - } } else if (!$ignore_acl) { @@ -577,8 +573,8 @@ function move_posts($post_ids, $topic_id, $auto_sync = true) while ($row = $db->sql_fetchrow($result)) { - $forum_ids[] = $row['forum_id']; - $topic_ids[] = $row['topic_id']; + $forum_ids[] = (int) $row['forum_id']; + $topic_ids[] = (int) $row['topic_id']; } $db->sql_freeresult($result); @@ -595,7 +591,7 @@ function move_posts($post_ids, $topic_id, $auto_sync = true) } $sql = 'UPDATE ' . POSTS_TABLE . ' - SET forum_id = ' . $forum_row['forum_id'] . ", topic_id = $topic_id + SET forum_id = ' . (int) $forum_row['forum_id'] . ", topic_id = $topic_id WHERE " . $db->sql_in_set('post_id', $post_ids); $db->sql_query($sql); @@ -606,7 +602,7 @@ function move_posts($post_ids, $topic_id, $auto_sync = true) if ($auto_sync) { - $forum_ids[] = $forum_row['forum_id']; + $forum_ids[] = (int) $forum_row['forum_id']; sync('topic_reported', 'topic_id', $topic_ids); sync('topic_attachment', 'topic_id', $topic_ids); @@ -675,7 +671,7 @@ function delete_topics($where_type, $where_ids, $auto_sync = true, $post_count_s $db->sql_transaction('begin'); - $table_ary = array(TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, POLL_VOTES_TABLE, POLL_OPTIONS_TABLE, TOPICS_WATCH_TABLE, TOPICS_TABLE); + $table_ary = array(BOOKMARKS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, POLL_VOTES_TABLE, POLL_OPTIONS_TABLE, TOPICS_WATCH_TABLE, TOPICS_TABLE); foreach ($table_ary as $table) { @@ -1129,53 +1125,65 @@ function delete_attachments($mode, $ids, $resync = true) } /** -* Remove topic shadows +* Deletes shadow topics pointing to a specified forum. +* +* @param int $forum_id The forum id +* @param string $sql_more Additional WHERE statement, e.g. t.topic_time < (time() - 1234) +* @param bool $auto_sync Will call sync() if this is true +* +* @return array Array with affected forums +* +* @author bantu */ -function delete_topic_shadows($max_age, $forum_id = '', $auto_sync = true) +function delete_topic_shadows($forum_id, $sql_more = '', $auto_sync = true) { - $where = (is_array($forum_id)) ? 'AND ' . $db->sql_in_set('t.forum_id', array_map('intval', $forum_id)) : (($forum_id) ? 'AND t.forum_id = ' . (int) $forum_id : ''); + global $db; - switch ($db->sql_layer) + if (!$forum_id) { - case 'mysql4': - case 'mysqli': - $sql = 'DELETE t.* - FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TABLE . ' t2 - WHERE t.topic_moved_id = t2.topic_id - AND t.topic_time < ' . (time() - $max_age) - . $where; - $db->sql_query($sql); - break; - - default: - $sql = 'SELECT t.topic_id - FROM ' . TOPICS_TABLE . ' t, ' . TOPICS_TABLE . ' t2 - WHERE t.topic_moved_id = t2.topic_id - AND t.topic_time < ' . (time() - $max_age) - . $where; - $result = $db->sql_query($sql); - - $topic_ids = array(); - while ($row = $db->sql_fetchrow($result)) - { - $topic_ids[] = $row['topic_id']; - } - $db->sql_freeresult($result); - - if (sizeof($topic_ids)) - { - $sql = 'DELETE FROM ' . TOPICS_TABLE . ' - WHERE ' . $db->sql_in_set('topic_id', $topic_ids); - $db->sql_query($sql); - } - break; + // Nothing to do. + return; } + // Set of affected forums we have to resync + $sync_forum_ids = array(); + + // Amount of topics we select and delete at once. + $batch_size = 500; + + do + { + $sql = 'SELECT t2.forum_id, t2.topic_id + FROM ' . TOPICS_TABLE . ' t2, ' . TOPICS_TABLE . ' t + WHERE t2.topic_moved_id = t.topic_id + AND t.forum_id = ' . (int) $forum_id . ' + ' . (($sql_more) ? 'AND ' . $sql_more : ''); + $result = $db->sql_query_limit($sql, $batch_size); + + $topic_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $topic_ids[] = (int) $row['topic_id']; + + $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id']; + } + $db->sql_freeresult($result); + + if (!empty($topic_ids)) + { + $sql = 'DELETE FROM ' . TOPICS_TABLE . ' + WHERE ' . $db->sql_in_set('topic_id', $topic_ids); + $db->sql_query($sql); + } + } + while (sizeof($topic_ids) == $batch_size); + if ($auto_sync) { - $where_type = ($forum_id) ? 'forum_id' : ''; - sync('forum', $where_type, $forum_id, true, true); + sync('forum', 'forum_id', $sync_forum_ids, true, true); } + + return $sync_forum_ids; } /** @@ -3042,6 +3050,7 @@ function get_database_size() case 'mssql': case 'mssql_odbc': + case 'mssqlnative': $sql = 'SELECT ((SUM(size) * 8.0) * 1024.0) as dbsize FROM sysfiles'; $result = $db->sql_query($sql, 7200); @@ -3290,7 +3299,7 @@ function obtain_latest_version_info($force_update = false, $warn_fail = false, $ $errstr = ''; $errno = 0; - $info = get_remote_file('www.phpbb.com', '/updatecheck', + $info = get_remote_file('version.phpbb.com', '/phpbb', ((defined('PHPBB_QA')) ? '30x_qa.txt' : '30x.txt'), $errstr, $errno); if ($info === false) diff --git a/phpBB/includes/functions_compress.php b/phpBB/includes/functions_compress.php index f17c780a65..455debd939 100644 --- a/phpBB/includes/functions_compress.php +++ b/phpBB/includes/functions_compress.php @@ -53,13 +53,18 @@ class compress $filelist = filelist("$phpbb_root_path$src", '', '*'); krsort($filelist); + /** + * Commented out, as adding the folders produces corrupted archives if ($src_path) { $this->data($src_path, '', true, stat("$phpbb_root_path$src")); } + */ foreach ($filelist as $path => $file_ary) { + /** + * Commented out, as adding the folders produces corrupted archives if ($path) { // Same as for src_path @@ -68,6 +73,7 @@ class compress $this->data("$src_path$path", '', true, stat("$phpbb_root_path$src$path")); } + */ foreach ($file_ary as $file) { @@ -502,8 +508,8 @@ class compress_tar extends compress function compress_tar($mode, $file, $type = '') { $type = (!$type) ? $file : $type; - $this->isgz = (strpos($type, '.tar.gz') !== false || strpos($type, '.tgz') !== false) ? true : false; - $this->isbz = (strpos($type, '.tar.bz2') !== false) ? true : false; + $this->isgz = preg_match('#(\.tar\.gz|\.tgz)$#', $type); + $this->isbz = preg_match('#\.tar\.bz2$#', $type); $this->mode = &$mode; $this->file = &$file; diff --git a/phpBB/includes/functions_convert.php b/phpBB/includes/functions_convert.php index 048212bcfe..9e26043b39 100644 --- a/phpBB/includes/functions_convert.php +++ b/phpBB/includes/functions_convert.php @@ -1025,6 +1025,9 @@ function set_user_options() 'bbcode' => array('bit' => 8, 'default' => 1), 'smilies' => array('bit' => 9, 'default' => 1), 'popuppm' => array('bit' => 10, 'default' => 0), + 'sig_bbcode' => array('bit' => 15, 'default' => 1), + 'sig_smilies' => array('bit' => 16, 'default' => 1), + 'sig_links' => array('bit' => 17, 'default' => 1), ); $option_field = 0; @@ -1645,6 +1648,7 @@ function mass_auth($ug_type, $forum_id, $ug_id, $acl_list, $setting = ACL_NO) case 'mssql': case 'sqlite': + case 'mssqlnative': $sql = implode(' UNION ALL ', preg_replace('#^(.*?)$#', 'SELECT \1', $sql_subary)); break; @@ -2302,7 +2306,7 @@ function copy_file($src, $trg, $overwrite = false, $die_on_failure = true, $sour } } - if (!is_writable($path)) + if (!phpbb_is_writable($path)) { @chmod($path, 0777); } @@ -2337,7 +2341,7 @@ function copy_dir($src, $trg, $copy_subdirs = true, $overwrite = false, $die_on_ @chmod($trg_path, 0777); } - if (!@is_writable($trg_path)) + if (!phpbb_is_writable($trg_path)) { $bad_dirs[] = path($config['script_path']) . $trg; } @@ -2404,7 +2408,7 @@ function copy_dir($src, $trg, $copy_subdirs = true, $overwrite = false, $die_on_ @chmod($trg_path . $dir, 0777); } - if (!@is_writable($trg_path . $dir)) + if (!phpbb_is_writable($trg_path . $dir)) { $bad_dirs[] = $trg . $dir; $bad_dirs[] = $trg_path . $dir; diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php index f49aa42324..2de7e1b169 100644 --- a/phpBB/includes/functions_display.php +++ b/phpBB/includes/functions_display.php @@ -396,7 +396,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod } else { - $folder_alt = ($forum_unread) ? 'NEW_POSTS' : 'NO_NEW_POSTS'; + $folder_alt = ($forum_unread) ? 'UNREAD_POSTS' : 'NO_UNREAD_POSTS'; } // Create last post link information, if appropriate @@ -425,7 +425,7 @@ function display_forums($root_data = '', $display_moderators = true, $return_mod $s_subforums_list = array(); foreach ($subforums_list as $subforum) { - $s_subforums_list[] = '' . $subforum['name'] . ''; + $s_subforums_list[] = '' . $subforum['name'] . ''; } $s_subforums_list = (string) implode(', ', $s_subforums_list); $catless = ($row['parent_id'] == $root_data['forum_id']) ? true : false; @@ -660,7 +660,7 @@ function topic_generate_pagination($replies, $url) $times = 1; for ($j = 0; $j < $replies + 1; $j += $per_page) { - $pagination .= '' . $times . ''; + $pagination .= '' . $times . ''; if ($times == 1 && $total_pages > 5) { $pagination .= ' ... '; @@ -854,7 +854,7 @@ function topic_status(&$topic_row, $replies, $unread_topic, &$folder_img, &$fold $folder_img = ($unread_topic) ? $folder_new : $folder; - $folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($topic_row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS'); + $folder_alt = ($unread_topic) ? 'UNREAD_POSTS' : (($topic_row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_UNREAD_POSTS'); // Posted image? if (!empty($topic_row['topic_posted']) && $topic_row['topic_posted']) @@ -969,11 +969,16 @@ function display_user_activity(&$userdata) $forum_ary = array_unique($forum_ary); $forum_sql = (sizeof($forum_ary)) ? 'AND ' . $db->sql_in_set('forum_id', $forum_ary, true) : ''; + $fid_m_approve = $auth->acl_getf('m_approve', true); + $sql_m_approve = (!empty($fid_m_approve)) ? 'OR ' . $db->sql_in_set('forum_id', array_keys($fid_m_approve)) : ''; + // Obtain active forum $sql = 'SELECT forum_id, COUNT(post_id) AS num_posts FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $userdata['user_id'] . " AND post_postcount = 1 + AND (post_approved = 1 + $sql_m_approve) $forum_sql GROUP BY forum_id ORDER BY num_posts DESC"; @@ -996,6 +1001,8 @@ function display_user_activity(&$userdata) FROM ' . POSTS_TABLE . ' WHERE poster_id = ' . $userdata['user_id'] . " AND post_postcount = 1 + AND (post_approved = 1 + $sql_m_approve) $forum_sql GROUP BY topic_id ORDER BY num_posts DESC"; @@ -1112,10 +1119,10 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, { $is_watching = true; - if ($notify_status) + if ($notify_status != NOTIFY_YES) { $sql = 'UPDATE ' . $table_sql . " - SET notify_status = 0 + SET notify_status = " . NOTIFY_YES . " WHERE $where_sql = $match_id AND user_id = $user_id"; $db->sql_query($sql); @@ -1134,7 +1141,7 @@ function watch_topic_forum($mode, &$s_watching, $user_id, $forum_id, $topic_id, $is_watching = true; $sql = 'INSERT INTO ' . $table_sql . " (user_id, $where_sql, notify_status) - VALUES ($user_id, $match_id, 0)"; + VALUES ($user_id, $match_id, " . NOTIFY_YES . ')'; $db->sql_query($sql); $message = $user->lang['ARE_WATCHING_' . strtoupper($mode)] . '

' . sprintf($user->lang['RETURN_' . strtoupper($mode)], '', ''); } diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 1b9c66fc84..992e8d6bb0 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -95,6 +95,16 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20 'AVAILABLE' => true, '2.0.x' => true, ), + 'mssqlnative' => array( + 'LABEL' => 'MS SQL Server 2005+ [ Native ]', + 'SCHEMA' => 'mssql', + 'MODULE' => 'sqlsrv', + 'DELIM' => 'GO', + 'COMMENTS' => 'remove_comments', + 'DRIVER' => 'mssqlnative', + 'AVAILABLE' => true, + '2.0.x' => false, + ), 'oracle' => array( 'LABEL' => 'Oracle', 'SCHEMA' => 'oracle', @@ -220,6 +230,7 @@ function get_tables($db) case 'mssql': case 'mssql_odbc': + case 'mssqlnative': $sql = "SELECT name FROM sysobjects WHERE type='U'"; @@ -313,6 +324,7 @@ function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, case 'mssql': case 'mssql_odbc': + case 'mssqlnative': $prefix_length = 90; break; diff --git a/phpBB/includes/functions_messenger.php b/phpBB/includes/functions_messenger.php index 99883cd9ca..b5c87094c0 100644 --- a/phpBB/includes/functions_messenger.php +++ b/phpBB/includes/functions_messenger.php @@ -631,6 +631,64 @@ class queue $this->data[$object]['data'][] = $scope; } + /** + * Obtains exclusive lock on queue cache file. + * Returns resource representing the lock + */ + function lock() + { + // For systems that can't have two processes opening + // one file for writing simultaneously + if (file_exists($this->cache_file . '.lock')) + { + $mode = 'rb'; + } + else + { + $mode = 'wb'; + } + + $lock_fp = @fopen($this->cache_file . '.lock', $mode); + + if ($mode == 'wb') + { + if (!$lock_fp) + { + // Two processes may attempt to create lock file at the same time. + // Have the losing process try opening the lock file again for reading + // on the assumption that the winning process created it + $mode = 'rb'; + $lock_fp = @fopen($this->cache_file . '.lock', $mode); + } + else + { + // Only need to set mode when the lock file is written + @chmod($this->cache_file . '.lock', 0666); + } + } + + if ($lock_fp) + { + @flock($lock_fp, LOCK_EX); + } + + return $lock_fp; + } + + /** + * Releases lock on queue cache file, using resource obtained from lock() + */ + function unlock($lock_fp) + { + // lock() will return null if opening lock file, and thus locking, failed. + // Accept null values here so that client code does not need to check them + if ($lock_fp) + { + @flock($lock_fp, LOCK_UN); + fclose($lock_fp); + } + } + /** * Process queue * Using lock file @@ -639,24 +697,16 @@ class queue { global $db, $config, $phpEx, $phpbb_root_path, $user; + $lock_fp = $this->lock(); + set_config('last_queue_run', time(), true); - // Delete stale lock file - if (file_exists($this->cache_file . '.lock') && !file_exists($this->cache_file)) + if (!file_exists($this->cache_file) || filemtime($this->cache_file) > time() - $config['queue_interval']) { - @unlink($this->cache_file . '.lock'); + $this->unlock($lock_fp); return; } - if (!file_exists($this->cache_file) || (file_exists($this->cache_file . '.lock') && filemtime($this->cache_file) > time() - $config['queue_interval'])) - { - return; - } - - $fp = @fopen($this->cache_file . '.lock', 'wb'); - fclose($fp); - @chmod($this->cache_file . '.lock', 0777); - include($this->cache_file); foreach ($this->queue_data as $object => $data_ary) @@ -671,11 +721,18 @@ class queue $package_size = $data_ary['package_size']; $num_items = (!$package_size || sizeof($data_ary['data']) < $package_size) ? sizeof($data_ary['data']) : $package_size; + /* + * This code is commented out because it causes problems on some web hosts. + * The core problem is rather restrictive email sending limits. + * This code is nly useful if you have no such restrictions from the + * web host and the package size setting is wrong. + // If the amount of emails to be sent is way more than package_size than we need to increase it to prevent backlogs... if (sizeof($data_ary['data']) > $package_size * 2.5) { $num_items = sizeof($data_ary['data']); } + */ switch ($object) { @@ -713,6 +770,7 @@ class queue break; default: + $this->unlock($lock_fp); return; } @@ -738,8 +796,6 @@ class queue if (!$result) { - @unlink($this->cache_file . '.lock'); - messenger::error('EMAIL', $err_msg); continue 2; } @@ -783,16 +839,14 @@ class queue { if ($fp = @fopen($this->cache_file, 'wb')) { - @flock($fp, LOCK_EX); fwrite($fp, "queue_data = unserialize(" . var_export(serialize($this->queue_data), true) . ");\n\n?>"); - @flock($fp, LOCK_UN); fclose($fp); phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE); } } - @unlink($this->cache_file . '.lock'); + $this->unlock($lock_fp); } /** @@ -805,6 +859,8 @@ class queue return; } + $lock_fp = $this->lock(); + if (file_exists($this->cache_file)) { include($this->cache_file); @@ -824,13 +880,13 @@ class queue if ($fp = @fopen($this->cache_file, 'w')) { - @flock($fp, LOCK_EX); fwrite($fp, "queue_data = unserialize(" . var_export(serialize($this->data), true) . ");\n\n?>"); - @flock($fp, LOCK_UN); fclose($fp); phpbb_chmod($this->cache_file, CHMOD_READ | CHMOD_WRITE); } + + $this->unlock($lock_fp); } } diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index 49ea382411..6fd87db663 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -85,10 +85,10 @@ function generate_smilies($mode, $forum_id) if ($mode == 'window') { - $sql = 'SELECT smiley_url, MIN(emotion) as emotion, MIN(code) AS code, smiley_width, smiley_height + $sql = 'SELECT smiley_url, MIN(emotion) as emotion, MIN(code) AS code, smiley_width, smiley_height, MIN(smiley_order) AS min_smiley_order FROM ' . SMILIES_TABLE . ' GROUP BY smiley_url, smiley_width, smiley_height - ORDER BY MIN(smiley_order)'; + ORDER BY min_smiley_order'; $result = $db->sql_query_limit($sql, $config['smilies_per_page'], $start, 3600); } else @@ -348,7 +348,7 @@ function posting_gen_topic_types($forum_id, $cur_topic_type = POST_NORMAL) { $topic_type_array = array_merge(array(0 => array( 'VALUE' => POST_NORMAL, - 'S_CHECKED' => ($topic_type == POST_NORMAL) ? ' checked="checked"' : '', + 'S_CHECKED' => ($cur_topic_type == POST_NORMAL) ? ' checked="checked"' : '', 'L_TOPIC_TYPE' => $user->lang['POST_NORMAL'])), $topic_type_array @@ -1146,7 +1146,7 @@ function topic_review($topic_id, $forum_id, $mode = 'topic_review', $cur_post_id } } - unset($rowset[$i]); + unset($rowset[$post_list[$i]]); } if ($mode == 'topic_review') @@ -1201,8 +1201,8 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id FROM ' . (($topic_notification) ? TOPICS_WATCH_TABLE : FORUMS_WATCH_TABLE) . ' w, ' . USERS_TABLE . ' u WHERE w.' . (($topic_notification) ? 'topic_id' : 'forum_id') . ' = ' . (($topic_notification) ? $topic_id : $forum_id) . " AND w.user_id NOT IN ($sql_ignore_users) - AND w.notify_status = 0 - AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ') + AND w.notify_status = " . NOTIFY_YES . ' + AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ') AND u.user_id = w.user_id'; $result = $db->sql_query($sql); @@ -1234,8 +1234,8 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id FROM ' . FORUMS_WATCH_TABLE . ' fw, ' . USERS_TABLE . " u WHERE fw.forum_id = $forum_id AND fw.user_id NOT IN ($sql_ignore_users) - AND fw.notify_status = 0 - AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ') + AND fw.notify_status = " . NOTIFY_YES . ' + AND u.user_type IN (' . USER_NORMAL . ', ' . USER_FOUNDER . ') AND u.user_id = fw.user_id'; $result = $db->sql_query($sql); @@ -1344,8 +1344,8 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id if (!empty($update_notification['topic'])) { - $sql = 'UPDATE ' . TOPICS_WATCH_TABLE . " - SET notify_status = 1 + $sql = 'UPDATE ' . TOPICS_WATCH_TABLE . ' + SET notify_status = ' . NOTIFY_NO . " WHERE topic_id = $topic_id AND " . $db->sql_in_set('user_id', $update_notification['topic']); $db->sql_query($sql); @@ -1353,8 +1353,8 @@ function user_notification($mode, $subject, $topic_title, $forum_name, $forum_id if (!empty($update_notification['forum'])) { - $sql = 'UPDATE ' . FORUMS_WATCH_TABLE . " - SET notify_status = 1 + $sql = 'UPDATE ' . FORUMS_WATCH_TABLE . ' + SET notify_status = ' . NOTIFY_NO . " WHERE forum_id = $forum_id AND " . $db->sql_in_set('user_id', $update_notification['forum']); $db->sql_query($sql); @@ -2537,7 +2537,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u if ($mode == 'post' || $mode == 'reply' || $mode == 'quote') { // Mark this topic as posted to - markread('post', $data['forum_id'], $data['topic_id'], $data['post_time']); + markread('post', $data['forum_id'], $data['topic_id']); } // Mark this topic as read @@ -2583,7 +2583,7 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u } // Send Notifications - if ($mode != 'edit' && $mode != 'delete' && $post_approval) + if (($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_approval) { user_notification($mode, $subject, $data['topic_title'], $data['forum_name'], $data['forum_id'], $data['topic_id'], $data['post_id']); } diff --git a/phpBB/includes/functions_privmsgs.php b/phpBB/includes/functions_privmsgs.php index 4fc5034f7b..4c34bc92ca 100644 --- a/phpBB/includes/functions_privmsgs.php +++ b/phpBB/includes/functions_privmsgs.php @@ -1380,6 +1380,9 @@ function submit_pm($mode, $subject, &$data, $put_in_outbox = true) } } + // First of all make sure the subject are having the correct length. + $subject = truncate_string($subject); + $db->sql_transaction('begin'); $sql = ''; @@ -1751,6 +1754,8 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode return false; } + $title = $row['message_subject']; + $rowset = array(); $bbcode_bitfield = ''; $folder_url = append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm') . '&folder='; @@ -1774,8 +1779,6 @@ function message_history($msg_id, $user_id, $message_row, $folder, $in_post_mode while ($row = $db->sql_fetchrow($result)); $db->sql_freeresult($result); - $title = $row['message_subject']; - if (sizeof($rowset) == 1 && !$in_post_mode) { return false; diff --git a/phpBB/includes/functions_profile_fields.php b/phpBB/includes/functions_profile_fields.php index 61e3587158..78fe049f40 100644 --- a/phpBB/includes/functions_profile_fields.php +++ b/phpBB/includes/functions_profile_fields.php @@ -366,6 +366,7 @@ class custom_profile case 'sqlite': case 'mssql': case 'mssql_odbc': + case 'mssqlnative': $right_delim = ']'; $left_delim = '['; break; @@ -542,8 +543,9 @@ class custom_profile else if ($day && $month && $year) { global $user; - // d/m/y 00:00 GMT isn't necessarily on the same d/m/y in the user's timezone, so add the timezone seconds - return $user->format_date(gmmktime(0, 0, 0, $month, $day, $year) + $user->timezone + $user->dst, $user->lang['DATE_FORMAT'], true); + // Date should display as the same date for every user regardless of timezone, so remove offset + // to compensate for the offset added by user::format_date() + return $user->format_date(gmmktime(0, 0, 0, $month, $day, $year) - ($user->timezone + $user->dst), $user->lang['DATE_FORMAT'], true); } return $value; @@ -876,6 +878,11 @@ class custom_profile $now = getdate(); $row['field_default_value'] = sprintf('%2d-%2d-%4d', $now['mday'], $now['mon'], $now['year']); } + else if ($row['field_default_value'] === '' && $row['field_type'] == FIELD_INT) + { + // We cannot insert an empty string into an integer column. + $row['field_default_value'] = NULL; + } $cp_data['pf_' . $row['field_ident']] = (in_array($row['field_type'], array(FIELD_TEXT, FIELD_STRING))) ? $row['lang_default_value'] : $row['field_default_value']; } diff --git a/phpBB/includes/functions_upload.php b/phpBB/includes/functions_upload.php index 054af29045..7f09cc1640 100644 --- a/phpBB/includes/functions_upload.php +++ b/phpBB/includes/functions_upload.php @@ -58,8 +58,9 @@ class filespec $this->filename = $upload_ary['tmp_name']; $this->filesize = $upload_ary['size']; - $name = trim(utf8_htmlspecialchars(utf8_basename($upload_ary['name']))); - $this->realname = $this->uploadname = (STRIP) ? stripslashes($name) : $name; + $name = (STRIP) ? stripslashes($upload_ary['name']) : $upload_ary['name']; + $name = trim(utf8_htmlspecialchars(utf8_basename($name))); + $this->realname = $this->uploadname = $name; $this->mimetype = $upload_ary['type']; // Opera adds the name to the mime type @@ -775,7 +776,18 @@ class fileupload { if ($get_info) { - $data .= @fread($fsock, 1024); + $block = @fread($fsock, 1024); + $filesize += strlen($block); + + if ($this->max_filesize && $filesize > $this->max_filesize) + { + $max_filesize = get_formatted_filesize($this->max_filesize, false); + + $file = new fileerror(sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit'])); + return $file; + } + + $data .= $block; } else { @@ -791,6 +803,18 @@ class fileupload { $upload_ary['type'] = rtrim(str_replace('content-type: ', '', strtolower($line))); } + else if ($this->max_filesize && stripos($line, 'content-length: ') !== false) + { + $length = (int) str_replace('content-length: ', '', strtolower($line)); + + if ($length && $length > $this->max_filesize) + { + $max_filesize = get_formatted_filesize($this->max_filesize, false); + + $file = new fileerror(sprintf($user->lang[$this->error_prefix . 'WRONG_FILESIZE'], $max_filesize['value'], $max_filesize['unit'])); + return $file; + } + } else if (stripos($line, '404 not found') !== false) { $file = new fileerror($user->lang[$this->error_prefix . 'URL_NOT_FOUND']); diff --git a/phpBB/includes/functions_user.php b/phpBB/includes/functions_user.php index 21e82030ee..f2c80705ba 100644 --- a/phpBB/includes/functions_user.php +++ b/phpBB/includes/functions_user.php @@ -297,6 +297,7 @@ function user_add($user_row, $cp_data = false) if ($config['new_member_group_default']) { group_user_add($add_group_id, $user_id, false, false, true); + $user_row['group_id'] = $add_group_id; } else { @@ -527,7 +528,7 @@ function user_delete($mode, $user_id, $post_username = false) $db->sql_transaction('begin'); - $table_ary = array(USERS_TABLE, USER_GROUP_TABLE, TOPICS_WATCH_TABLE, FORUMS_WATCH_TABLE, ACL_USERS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, FORUMS_TRACK_TABLE, PROFILE_FIELDS_DATA_TABLE, MODERATOR_CACHE_TABLE, DRAFTS_TABLE, BOOKMARKS_TABLE, SESSIONS_KEYS_TABLE); + $table_ary = array(USERS_TABLE, USER_GROUP_TABLE, TOPICS_WATCH_TABLE, FORUMS_WATCH_TABLE, ACL_USERS_TABLE, TOPICS_TRACK_TABLE, TOPICS_POSTED_TABLE, FORUMS_TRACK_TABLE, PROFILE_FIELDS_DATA_TABLE, MODERATOR_CACHE_TABLE, DRAFTS_TABLE, BOOKMARKS_TABLE, SESSIONS_KEYS_TABLE, PRIVMSGS_FOLDER_TABLE, PRIVMSGS_RULES_TABLE); foreach ($table_ary as $table) { @@ -765,7 +766,8 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas if (sizeof($ban_other) == 3 && ((int)$ban_other[0] < 9999) && (strlen($ban_other[0]) == 4) && (strlen($ban_other[1]) == 2) && (strlen($ban_other[2]) == 2)) { - $ban_end = max($current_time, gmmktime(0, 0, 0, (int)$ban_other[1], (int)$ban_other[2], (int)$ban_other[0])); + $time_offset = (isset($user->timezone) && isset($user->dst)) ? (int) $user->timezone + (int) $user->dst : 0; + $ban_end = max($current_time, gmmktime(0, 0, 0, (int)$ban_other[1], (int)$ban_other[2], (int)$ban_other[0]) - $time_offset); } else { @@ -836,14 +838,15 @@ function user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reas FROM ' . USERS_TABLE . ' WHERE ' . $db->sql_in_set('username_clean', $sql_usernames); - // Do not allow banning yourself + // Do not allow banning yourself, the guest account, or founders. + $non_bannable = array($user->data['user_id'], ANONYMOUS); if (sizeof($founder)) { - $sql .= ' AND ' . $db->sql_in_set('user_id', array_merge(array_keys($founder), array($user->data['user_id'])), true); + $sql .= ' AND ' . $db->sql_in_set('user_id', array_merge(array_keys($founder), $non_bannable), true); } else { - $sql .= ' AND user_id <> ' . $user->data['user_id']; + $sql .= ' AND ' . $db->sql_in_set('user_id', $non_bannable, true); } $result = $db->sql_query($sql); @@ -1227,22 +1230,39 @@ function user_unban($mode, $ban) } /** -* Whois facility +* Internet Protocol Address Whois +* RFC3912: WHOIS Protocol Specification * -* @link http://tools.ietf.org/html/rfc3912 RFC3912: WHOIS Protocol Specification +* @param string $ip Ip address, either IPv4 or IPv6. +* +* @return string Empty string if not a valid ip address. +* Otherwise make_clickable()'ed whois result. */ function user_ipwhois($ip) { - $ipwhois = ''; - - // Check IP - // Only supporting IPv4 at the moment... - if (empty($ip) || !preg_match(get_preg_expression('ipv4'), $ip)) + if (empty($ip)) { return ''; } - if (($fsk = @fsockopen('whois.arin.net', 43))) + if (preg_match(get_preg_expression('ipv4'), $ip)) + { + // IPv4 address + $whois_host = 'whois.arin.net.'; + } + else if (preg_match(get_preg_expression('ipv6'), $ip)) + { + // IPv6 address + $whois_host = 'whois.sixxs.net.'; + } + else + { + return ''; + } + + $ipwhois = ''; + + if (($fsk = @fsockopen($whois_host, 43))) { // CRLF as per RFC3912 fputs($fsk, "$ip\r\n"); @@ -1255,7 +1275,7 @@ function user_ipwhois($ip) $match = array(); - // Test for referrals from ARIN to other whois databases, roll on rwhois + // Test for referrals from $whois_host to other whois databases, roll on rwhois if (preg_match('#ReferralServer: whois://(.+)#im', $ipwhois, $match)) { if (strpos($match[1], ':') !== false) @@ -1283,7 +1303,7 @@ function user_ipwhois($ip) @fclose($fsk); } - // Use the result from ARIN if we don't get any result here + // Use the result from $whois_host if we don't get any result here $ipwhois = (empty($buffer)) ? $ipwhois : $buffer; } @@ -2283,7 +2303,7 @@ function avatar_get_dimensions($avatar, $avatar_type, &$error, $current_x = 0, $ /** * Uploading/Changing user avatar */ -function avatar_process_user(&$error, $custom_userdata = false) +function avatar_process_user(&$error, $custom_userdata = false, $can_upload = null) { global $config, $phpbb_root_path, $auth, $user, $db; @@ -2322,7 +2342,10 @@ function avatar_process_user(&$error, $custom_userdata = false) $avatar_select = basename(request_var('avatar_select', '')); // Can we upload? - $can_upload = ($config['allow_avatar_upload'] && file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $change_avatar && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; + if (is_null($can_upload)) + { + $can_upload = ($config['allow_avatar_upload'] && file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $change_avatar && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; + } if ((!empty($_FILES['uploadfile']['name']) || $data['uploadurl']) && $can_upload) { @@ -2347,7 +2370,7 @@ function avatar_process_user(&$error, $custom_userdata = false) } else { - list($sql_ary['user_avatar_width'], $sql_ary['user_avatar_height']) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . $sql_ary['user_avatar']); + list($sql_ary['user_avatar_width'], $sql_ary['user_avatar_height']) = getimagesize($phpbb_root_path . $config['avatar_gallery_path'] . '/' . $category . '/' . urldecode($sql_ary['user_avatar'])); $sql_ary['user_avatar'] = $category . '/' . $sql_ary['user_avatar']; } } diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php index 80c3559649..d5551f5114 100644 --- a/phpBB/includes/mcp/mcp_main.php +++ b/phpBB/includes/mcp/mcp_main.php @@ -1048,6 +1048,35 @@ function mcp_fork_topic($topic_ids) $total_posts = 0; $new_topic_id_list = array(); + if ($topic_data['enable_indexing']) + { + // Select the search method and do some additional checks to ensure it can actually be utilised + $search_type = basename($config['search_type']); + + if (!file_exists($phpbb_root_path . 'includes/search/' . $search_type . '.' . $phpEx)) + { + trigger_error('NO_SUCH_SEARCH_MODULE'); + } + + if (!class_exists($search_type)) + { + include("{$phpbb_root_path}includes/search/$search_type.$phpEx"); + } + + $error = false; + $search = new $search_type($error); + $search_mode = 'post'; + + if ($error) + { + trigger_error($error); + } + } + else + { + $search_type = false; + } + foreach ($topic_data as $topic_id => $topic_row) { $sql_ary = array( @@ -1158,6 +1187,12 @@ function mcp_fork_topic($topic_ids) // Copy whether the topic is dotted markread('post', $to_forum_id, $new_topic_id, 0, $row['poster_id']); + if ($search_type) + { + $search->index($search_mode, $sql_ary['post_id'], $sql_ary['post_text'], $sql_ary['post_subject'], $sql_ary['poster_id'], ($topic_row['topic_type'] == POST_GLOBAL) ? 0 : $to_forum_id); + $search_mode = 'reply'; // After one we index replies + } + // Copy Attachments if ($row['post_attachment']) { diff --git a/phpBB/includes/mcp/mcp_post.php b/phpBB/includes/mcp/mcp_post.php index fa44e006dd..7098b4bbce 100644 --- a/phpBB/includes/mcp/mcp_post.php +++ b/phpBB/includes/mcp/mcp_post.php @@ -176,7 +176,7 @@ function mcp_post_details($id, $mode, $action) } $template->assign_vars(array( - 'U_MCP_ACTION' => "$url&i=main&quickmod=1", // Use this for mode paramaters + 'U_MCP_ACTION' => "$url&i=main&quickmod=1&mode=post_details", // Use this for mode paramaters 'U_POST_ACTION' => "$url&i=$id&mode=post_details", // Use this for action parameters 'U_APPROVE_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "i=queue&p=$post_id&f={$post_info['forum_id']}"), @@ -200,7 +200,7 @@ function mcp_post_details($id, $mode, $action) 'U_VIEW_POST' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&p=' . $post_info['post_id'] . '#p' . $post_info['post_id']), 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']), - 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'), + 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '", ''), 'RETURN_FORUM' => sprintf($user->lang['RETURN_FORUM'], '', ''), diff --git a/phpBB/includes/mcp/mcp_queue.php b/phpBB/includes/mcp/mcp_queue.php index 8d9ece5205..c419da5574 100644 --- a/phpBB/includes/mcp/mcp_queue.php +++ b/phpBB/includes/mcp/mcp_queue.php @@ -196,7 +196,7 @@ class mcp_queue 'U_VIEW_POST' => $post_url, 'U_VIEW_TOPIC' => $topic_url, - 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'), + 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'RETURN_QUEUE' => sprintf($user->lang['RETURN_QUEUE'], '", ''), 'RETURN_POST' => sprintf($user->lang['RETURN_POST'], '', ''), @@ -428,7 +428,7 @@ class mcp_queue 'POST_ID' => $row['post_id'], 'FORUM_NAME' => (!$global_topic) ? $forum_names[$row['forum_id']] : $user->lang['GLOBAL_ANNOUNCEMENT'], - 'POST_SUBJECT' => $row['post_subject'], + 'POST_SUBJECT' => ($row['post_subject'] != '') ? $row['post_subject'] : $user->lang['NO_SUBJECT'], 'TOPIC_TITLE' => $row['topic_title'], 'POST_TIME' => $user->format_date($row['post_time'])) ); @@ -691,16 +691,19 @@ function approve_post($post_id_list, $id, $mode) { $show_notify = false; - foreach ($post_info as $post_data) + if ($config['email_enable'] || $config['jab_enable']) { - if ($post_data['poster_id'] == ANONYMOUS) + foreach ($post_info as $post_data) { - continue; - } - else - { - $show_notify = true; - break; + if ($post_data['poster_id'] == ANONYMOUS) + { + continue; + } + else + { + $show_notify = true; + break; + } } } diff --git a/phpBB/includes/mcp/mcp_reports.php b/phpBB/includes/mcp/mcp_reports.php index e19fe96963..39d9fbd4af 100644 --- a/phpBB/includes/mcp/mcp_reports.php +++ b/phpBB/includes/mcp/mcp_reports.php @@ -205,7 +205,7 @@ class mcp_reports 'U_VIEW_TOPIC' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $post_info['forum_id'] . '&t=' . $post_info['topic_id']), 'EDIT_IMG' => $user->img('icon_post_edit', $user->lang['EDIT_POST']), - 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'), + 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', $user->lang['POST_UNAPPROVED']), 'RETURN_REPORTS' => sprintf($user->lang['RETURN_REPORTS'], '', ''), diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php index 9779478330..76cd9beb92 100644 --- a/phpBB/includes/mcp/mcp_topic.php +++ b/phpBB/includes/mcp/mcp_topic.php @@ -237,7 +237,7 @@ function mcp_topic_view($id, $mode, $action) 'POST_ID' => $row['post_id'], 'RETURN_TOPIC' => sprintf($user->lang['RETURN_TOPIC'], '', ''), - 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'), + 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'S_POST_REPORTED' => ($row['post_reported']) ? true : false, 'S_POST_UNAPPROVED' => ($row['post_approved']) ? false : true, diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index 8979511d9a..b2d0b6c566 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -300,7 +300,7 @@ class bbcode_firstpass extends bbcode if ($config['max_' . $this->mode . '_img_height'] || $config['max_' . $this->mode . '_img_width']) { - $stats = @getimagesize($in); + $stats = @getimagesize(htmlspecialchars_decode($in)); if ($stats === false) { @@ -352,6 +352,15 @@ class bbcode_firstpass extends bbcode return '[flash=' . $width . ',' . $height . ']' . $in . '[/flash]'; } + $in = str_replace(' ', '%20', $in); + + // Make sure $in is a URL. + if (!preg_match('#^' . get_preg_expression('url') . '$#i', $in) && + !preg_match('#^' . get_preg_expression('www_url') . '$#i', $in)) + { + return '[flash=' . $width . ',' . $height . ']' . $in . '[/flash]'; + } + // Apply the same size checks on flash files as on images if ($config['max_' . $this->mode . '_img_height'] || $config['max_' . $this->mode . '_img_width']) { @@ -1284,6 +1293,7 @@ class parse_message extends bbcode_firstpass { case 'mssql': case 'mssql_odbc': + case 'mssqlnative': $sql = 'SELECT * FROM ' . SMILIES_TABLE . ' ORDER BY LEN(code) DESC'; diff --git a/phpBB/includes/search/fulltext_mysql.php b/phpBB/includes/search/fulltext_mysql.php index da3833754e..29cdd8ee9a 100644 --- a/phpBB/includes/search/fulltext_mysql.php +++ b/phpBB/includes/search/fulltext_mysql.php @@ -122,7 +122,7 @@ class fulltext_mysql extends search_backend if ($terms == 'all') { - $match = array('#\sand\s#iu', '#\sor\s#iu', '#\snot\s#iu', '#\+#', '#-#', '#\|#'); + $match = array('#\sand\s#iu', '#\sor\s#iu', '#\snot\s#iu', '#(^|\s)\+#', '#(^|\s)-#', '#(^|\s)\|#'); $replace = array(' +', ' |', ' -', ' +', ' -', ' |'); $keywords = preg_replace($match, $replace, $keywords); @@ -919,6 +919,14 @@ class fulltext_mysql extends search_backend

' . $user->lang['FULLTEXT_MYSQL_MBSTRING_EXPLAIN'] . '
' . (($this->mbstring_regex) ? $user->lang['YES'] : $user->lang['NO']). '
+
+

' . $user->lang['FULLTEXT_MYSQL_MIN_SEARCH_CHARS_EXPLAIN'] . '
+
' . $config['fulltext_mysql_min_word_len'] . '
+
+
+

' . $user->lang['FULLTEXT_MYSQL_MAX_SEARCH_CHARS_EXPLAIN'] . '
+
' . $config['fulltext_mysql_max_word_len'] . '
+
'; // These are fields required in the config table diff --git a/phpBB/includes/search/fulltext_native.php b/phpBB/includes/search/fulltext_native.php index c89e92711e..727e3aaffb 100644 --- a/phpBB/includes/search/fulltext_native.php +++ b/phpBB/includes/search/fulltext_native.php @@ -83,7 +83,9 @@ class fulltext_native extends search_backend { global $db, $user, $config; - $keywords = trim($this->cleanup($keywords, '+-|()*')); + $tokens = '+-|()*'; + + $keywords = trim($this->cleanup($keywords, $tokens)); // allow word|word|word without brackets if ((strpos($keywords, ' ') === false) && (strpos($keywords, '|') !== false) && (strpos($keywords, '(') === false)) @@ -114,6 +116,15 @@ class fulltext_native extends search_backend case ' ': $keywords[$i] = '|'; break; + case '*': + if ($i === 0 || ($keywords[$i - 1] !== '*' && strcspn($keywords[$i - 1], $tokens) === 0)) + { + if ($i === $n - 1 || ($keywords[$i + 1] !== '*' && strcspn($keywords[$i + 1], $tokens) === 0)) + { + $keywords = substr($keywords, 0, $i) . substr($keywords, $i + 1); + } + } + break; } } else diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php index 11f1896332..5f5b39fe27 100644 --- a/phpBB/includes/session.php +++ b/phpBB/includes/session.php @@ -83,7 +83,7 @@ class session $query_string = trim(implode('&', $use_args)); // basenamed page name (for example: index.php) - $page_name = basename($script_name); + $page_name = (substr($script_name, -1, 1) == '/') ? '' : basename($script_name); $page_name = urlencode(htmlspecialchars($page_name)); // current directory within the phpBB root (for example: adm) @@ -285,6 +285,17 @@ class session break; } + // Quick check for IPv4-mapped address in IPv6 + if (stripos($ip, '::ffff:') === 0) + { + $ipv4 = substr($ip, 7); + + if (preg_match(get_preg_expression('ipv4'), $ipv4)) + { + $ip = $ipv4; + } + } + // Use the last in chain $this->ip = $ip; } @@ -608,6 +619,12 @@ class session } else { + // Bot user, if they have a SID in the Request URI we need to get rid of it + // otherwise they'll index this page with the SID, duplicate content oh my! + if (isset($_GET['sid'])) + { + redirect(build_url(array('sid'))); + } $this->data['session_last_visit'] = $this->time_now; } @@ -742,7 +759,7 @@ class session if ((int) $row['sessions'] > (int) $config['active_sessions']) { - header('HTTP/1.1 503 Service Unavailable'); + send_status_line(503, 'Service Unavailable'); trigger_error('BOARD_UNAVAILABLE'); } } @@ -977,7 +994,7 @@ class session } // only called from CRON; should be a safe workaround until the infrastructure gets going - if (!class_exists('captcha_factory')) + if (!class_exists('phpbb_captcha_factory')) { include($phpbb_root_path . "includes/captcha/captcha_factory." . $phpEx); } @@ -1815,7 +1832,7 @@ class user extends session { if ($this->data['is_bot']) { - header('HTTP/1.1 503 Service Unavailable'); + send_status_line(503, 'Service Unavailable'); } $message = (!empty($config['board_disable_msg'])) ? $config['board_disable_msg'] : 'BOARD_DISABLE'; @@ -1825,7 +1842,7 @@ class user extends session // Is load exceeded? if ($config['limit_load'] && $this->load !== false) { - if ($this->load > floatval($config['limit_load']) && !defined('IN_LOGIN')) + if ($this->load > floatval($config['limit_load']) && !defined('IN_LOGIN') && !defined('IN_ADMIN')) { // Set board disabled to true to let the admins/mods get the proper notification $config['board_disable'] = '1'; @@ -1834,7 +1851,7 @@ class user extends session { if ($this->data['is_bot']) { - header('HTTP/1.1 503 Service Unavailable'); + send_status_line(503, 'Service Unavailable'); } trigger_error('BOARD_UNAVAILABLE'); } @@ -2128,9 +2145,9 @@ class user extends session // Zone offset $zone_offset = $this->timezone + $this->dst; - // Show date <= 1 hour ago as 'xx min ago' + // Show date <= 1 hour ago as 'xx min ago' but not greater than 60 seconds in the future // A small tolerence is given for times in the future but in the same minute are displayed as '< than a minute ago' - if ($delta <= 3600 && ($delta >= -5 || (($now / 60) % 60) == (($gmepoch / 60) % 60)) && $date_cache[$format]['is_short'] !== false && !$forcedate && isset($this->lang['datetime']['AGO'])) + if ($delta <= 3600 && $delta > -60 && ($delta >= -5 || (($now / 60) % 60) == (($gmepoch / 60) % 60)) && $date_cache[$format]['is_short'] !== false && !$forcedate && isset($this->lang['datetime']['AGO'])) { return $this->lang(array('datetime', 'AGO'), max(0, (int) floor($delta / 60))); } diff --git a/phpBB/includes/ucp/info/ucp_profile.php b/phpBB/includes/ucp/info/ucp_profile.php index 03a4c81f46..d19b80f4c0 100644 --- a/phpBB/includes/ucp/info/ucp_profile.php +++ b/phpBB/includes/ucp/info/ucp_profile.php @@ -22,7 +22,7 @@ class ucp_profile_info 'modes' => array( 'profile_info' => array('title' => 'UCP_PROFILE_PROFILE_INFO', 'auth' => '', 'cat' => array('UCP_PROFILE')), 'signature' => array('title' => 'UCP_PROFILE_SIGNATURE', 'auth' => '', 'cat' => array('UCP_PROFILE')), - 'avatar' => array('title' => 'UCP_PROFILE_AVATAR', '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')), ), ); diff --git a/phpBB/includes/ucp/ucp_groups.php b/phpBB/includes/ucp/ucp_groups.php index 423d9b718a..1c055a4823 100644 --- a/phpBB/includes/ucp/ucp_groups.php +++ b/phpBB/includes/ucp/ucp_groups.php @@ -490,7 +490,7 @@ class ucp_groups $avatar_select = basename(request_var('avatar_select', '')); $category = basename(request_var('category', '')); - $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; + $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $file_uploads) ? true : false; // Did we submit? if ($update) diff --git a/phpBB/includes/ucp/ucp_main.php b/phpBB/includes/ucp/ucp_main.php index 6ac2412ef0..a6f71669ce 100644 --- a/phpBB/includes/ucp/ucp_main.php +++ b/phpBB/includes/ucp/ucp_main.php @@ -119,7 +119,7 @@ class ucp_main $unread_topic = (isset($topic_tracking_info[$topic_id]) && $row['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false; $folder_img = ($unread_topic) ? $folder_new : $folder; - $folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS'); + $folder_alt = ($unread_topic) ? 'UNREAD_POSTS' : (($row['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_UNREAD_POSTS'); if ($row['topic_status'] == ITEM_LOCKED) { @@ -318,7 +318,7 @@ class ucp_main else { $folder_image = ($unread_forum) ? 'forum_unread' : 'forum_read'; - $folder_alt = ($unread_forum) ? 'NEW_POSTS' : 'NO_NEW_POSTS'; + $folder_alt = ($unread_forum) ? 'UNREAD_POSTS' : 'NO_UNREAD_POSTS'; } // Create last post link information, if appropriate diff --git a/phpBB/includes/ucp/ucp_pm_compose.php b/phpBB/includes/ucp/ucp_pm_compose.php index 4d72d45f81..b596e72c41 100644 --- a/phpBB/includes/ucp/ucp_pm_compose.php +++ b/phpBB/includes/ucp/ucp_pm_compose.php @@ -1054,7 +1054,7 @@ function compose_pm($id, $mode, $action) 'S_COMPOSE_PM' => true, 'S_EDIT_POST' => ($action == 'edit'), 'S_SHOW_PM_ICONS' => $s_pm_icons, - 'S_BBCODE_ALLOWED' => $bbcode_status, + 'S_BBCODE_ALLOWED' => ($bbcode_status) ? 1 : 0, 'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '', 'S_SMILIES_ALLOWED' => $smilies_status, 'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '', diff --git a/phpBB/includes/ucp/ucp_pm_viewfolder.php b/phpBB/includes/ucp/ucp_pm_viewfolder.php index 665dd2c83f..6b7172ca2b 100644 --- a/phpBB/includes/ucp/ucp_pm_viewfolder.php +++ b/phpBB/includes/ucp/ucp_pm_viewfolder.php @@ -170,10 +170,12 @@ function view_folder($id, $mode, $folder_id, $folder) 'ATTACH_ICON_IMG' => ($auth->acl_get('u_pm_download') && $row['message_attachment'] && $config['allow_pm_attach']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'S_PM_DELETED' => ($row['pm_deleted']) ? true : false, + 'S_PM_REPORTED' => (isset($row['report_id'])) ? true : false, 'S_AUTHOR_DELETED' => ($row['author_id'] == ANONYMOUS) ? true : false, 'U_VIEW_PM' => ($row['pm_deleted']) ? '' : $view_message_url, 'U_REMOVE_PM' => ($row['pm_deleted']) ? $remove_message_url : '', + 'U_MCP_REPORT' => (isset($row['report_id'])) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=pm_reports&mode=pm_report_details&r=' . $row['report_id']) : '', 'RECIPIENTS' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? implode(', ', $address_list[$message_id]) : '') ); } @@ -183,6 +185,7 @@ function view_folder($id, $mode, $folder_id, $folder) 'S_SHOW_RECIPIENTS' => ($folder_id == PRIVMSGS_OUTBOX || $folder_id == PRIVMSGS_SENTBOX) ? true : false, 'S_SHOW_COLOUR_LEGEND' => true, + 'REPORTED_IMG' => $user->img('icon_topic_reported', 'PM_REPORTED'), 'S_PM_ICONS' => ($config['enable_pm_icons']) ? true : false) ); } @@ -502,7 +505,7 @@ function get_pm_from($folder_id, $folder, $user_id) $sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction; } - $sql = 'SELECT t.*, p.root_level, p.message_time, p.message_subject, p.icon_id, p.to_address, p.message_attachment, p.bcc_address, u.username, u.username_clean, u.user_colour + $sql = 'SELECT t.*, p.root_level, p.message_time, p.message_subject, p.icon_id, p.to_address, p.message_attachment, p.bcc_address, u.username, u.username_clean, u.user_colour, p.message_reported FROM ' . PRIVMSGS_TO_TABLE . ' t, ' . PRIVMSGS_TABLE . ' p, ' . USERS_TABLE . " u WHERE t.user_id = $user_id AND p.author_id = u.user_id @@ -512,13 +515,34 @@ function get_pm_from($folder_id, $folder, $user_id) ORDER BY $sql_sort_order"; $result = $db->sql_query_limit($sql, $sql_limit, $sql_start); + $pm_reported = array(); while ($row = $db->sql_fetchrow($result)) { $rowset[$row['msg_id']] = $row; $pm_list[] = $row['msg_id']; + if ($row['message_reported']) + { + $pm_reported[] = $row['msg_id']; + } } $db->sql_freeresult($result); + // Fetch the report_ids, if there are any reported pms. + if (!empty($pm_reported) && $auth->acl_getf_global('m_report')) + { + $sql = 'SELECT pm_id, report_id + FROM ' . REPORTS_TABLE . ' + WHERE report_closed = 0 + AND ' . $db->sql_in_set('pm_id', $pm_reported); + $result = $db->sql_query($sql); + + while ($row = $db->sql_fetchrow($result)) + { + $rowset[$row['pm_id']]['report_id'] = $row['report_id']; + } + $db->sql_freeresult($result); + } + $pm_list = ($store_reverse) ? array_reverse($pm_list) : $pm_list; return array( diff --git a/phpBB/includes/ucp/ucp_pm_viewmessage.php b/phpBB/includes/ucp/ucp_pm_viewmessage.php index 26968e1382..16700c490c 100644 --- a/phpBB/includes/ucp/ucp_pm_viewmessage.php +++ b/phpBB/includes/ucp/ucp_pm_viewmessage.php @@ -309,7 +309,7 @@ function get_user_information($user_id, $user_row) get_user_rank($user_row['user_rank'], $user_row['user_posts'], $user_row['rank_title'], $user_row['rank_image'], $user_row['rank_image_src']); - if (!empty($user_row['user_allow_viewemail']) || $auth->acl_get('a_email')) + if ((!empty($user_row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email')) { $user_row['email'] = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&u=$user_id") : ((($config['board_hide_emails'] && !$auth->acl_get('a_email')) || empty($user_row['user_email'])) ? '' : 'mailto:' . $user_row['user_email']); } diff --git a/phpBB/includes/ucp/ucp_profile.php b/phpBB/includes/ucp/ucp_profile.php index f4f4abad4a..c099e3b3fa 100644 --- a/phpBB/includes/ucp/ucp_profile.php +++ b/phpBB/includes/ucp/ucp_profile.php @@ -141,10 +141,7 @@ class ucp_profile $server_url = generate_board_url(); - $user_actkey = gen_rand_string(10); - $key_len = 54 - (strlen($server_url)); - $key_len = ($key_len > 6) ? $key_len : 6; - $user_actkey = substr($user_actkey, 0, $key_len); + $user_actkey = gen_rand_string(mt_rand(6, 10)); $messenger = new messenger(false); @@ -564,7 +561,7 @@ class ucp_profile $avatar_select = basename(request_var('avatar_select', '')); $category = basename(request_var('category', '')); - $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && @is_writable($phpbb_root_path . $config['avatar_path']) && $auth->acl_get('u_chgavatar') && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; + $can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && phpbb_is_writable($phpbb_root_path . $config['avatar_path']) && $auth->acl_get('u_chgavatar') && (@ini_get('file_uploads') || strtolower(@ini_get('file_uploads')) == 'on')) ? true : false; add_form_key('ucp_avatar'); @@ -572,7 +569,7 @@ class ucp_profile { if (check_form_key('ucp_avatar')) { - if (avatar_process_user($error)) + if (avatar_process_user($error, false, $can_upload)) { meta_refresh(3, $this->u_action); $message = $user->lang['PROFILE_UPDATED'] . '

' . sprintf($user->lang['RETURN_UCP'], '', ''); diff --git a/phpBB/includes/ucp/ucp_register.php b/phpBB/includes/ucp/ucp_register.php index 9656a4a3af..7fd99da55a 100644 --- a/phpBB/includes/ucp/ucp_register.php +++ b/phpBB/includes/ucp/ucp_register.php @@ -286,11 +286,7 @@ class ucp_register $config['require_activation'] == USER_ACTIVATION_SELF || $config['require_activation'] == USER_ACTIVATION_ADMIN) && $config['email_enable']) { - $user_actkey = gen_rand_string(10); - $key_len = 54 - (strlen($server_url)); - $key_len = ($key_len < 6) ? 6 : $key_len; - $user_actkey = substr($user_actkey, 0, $key_len); - + $user_actkey = gen_rand_string(mt_rand(6, 10)); $user_type = USER_INACTIVE; $user_inactive_reason = INACTIVE_REGISTER; $user_inactive_time = time(); diff --git a/phpBB/includes/ucp/ucp_remind.php b/phpBB/includes/ucp/ucp_remind.php index df6733d038..cb89ad99be 100644 --- a/phpBB/includes/ucp/ucp_remind.php +++ b/phpBB/includes/ucp/ucp_remind.php @@ -77,11 +77,12 @@ class ucp_remind $server_url = generate_board_url(); - $key_len = 54 - strlen($server_url); - $key_len = max(6, $key_len); // we want at least 6 - $key_len = ($config['max_pass_chars']) ? min($key_len, $config['max_pass_chars']) : $key_len; // we want at most $config['max_pass_chars'] - $user_actkey = substr(gen_rand_string(10), 0, $key_len); - $user_password = gen_rand_string(8); + // Make password at least 8 characters long, make it longer if admin wants to. + // gen_rand_string() however has a limit of 12 or 13. + $user_password = gen_rand_string_friendly(max(8, mt_rand((int) $config['min_pass_chars'], (int) $config['max_pass_chars']))); + + // For the activation key a random length between 6 and 10 will do. + $user_actkey = gen_rand_string(mt_rand(6, 10)); $sql = 'UPDATE ' . USERS_TABLE . " SET user_newpasswd = '" . $db->sql_escape(phpbb_hash($user_password)) . "', user_actkey = '" . $db->sql_escape($user_actkey) . "' diff --git a/phpBB/index.php b/phpBB/index.php index c3dbbd346e..cc83641acd 100644 --- a/phpBB/index.php +++ b/phpBB/index.php @@ -115,10 +115,10 @@ $template->assign_vars(array( 'LEGEND' => $legend, 'BIRTHDAY_LIST' => $birthday_list, - 'FORUM_IMG' => $user->img('forum_read', 'NO_NEW_POSTS'), - 'FORUM_NEW_IMG' => $user->img('forum_unread', 'NEW_POSTS'), - 'FORUM_LOCKED_IMG' => $user->img('forum_read_locked', 'NO_NEW_POSTS_LOCKED'), - 'FORUM_NEW_LOCKED_IMG' => $user->img('forum_unread_locked', 'NO_NEW_POSTS_LOCKED'), + 'FORUM_IMG' => $user->img('forum_read', 'NO_UNREAD_POSTS'), + 'FORUM_UNREAD_IMG' => $user->img('forum_unread', 'UNREAD_POSTS'), + 'FORUM_LOCKED_IMG' => $user->img('forum_read_locked', 'NO_UNREAD_POSTS_LOCKED'), + 'FORUM_UNREAD_LOCKED_IMG' => $user->img('forum_unread_locked', 'UNREAD_POSTS_LOCKED'), 'S_LOGIN_ACTION' => append_sid("{$phpbb_root_path}ucp.$phpEx", 'mode=login'), 'S_DISPLAY_BIRTHDAY_LIST' => ($config['load_birthdays']) ? true : false, diff --git a/phpBB/install/convertors/convert_phpbb20.php b/phpBB/install/convertors/convert_phpbb20.php index dfade990d2..efe2bc2962 100644 --- a/phpBB/install/convertors/convert_phpbb20.php +++ b/phpBB/install/convertors/convert_phpbb20.php @@ -32,7 +32,7 @@ unset($dbpasswd); $convertor_data = array( 'forum_name' => 'phpBB 2.0.x', 'version' => '1.0.3', - 'phpbb_version' => '3.0.7-PL1', + 'phpbb_version' => '3.0.8', 'author' => 'phpBB Group', 'dbms' => $dbms, 'dbhost' => $dbhost, diff --git a/phpBB/install/convertors/functions_phpbb20.php b/phpBB/install/convertors/functions_phpbb20.php index b80c7673e3..78224dd5da 100644 --- a/phpBB/install/convertors/functions_phpbb20.php +++ b/phpBB/install/convertors/functions_phpbb20.php @@ -1239,9 +1239,9 @@ function phpbb_prepare_message($message) // Already the new user id ;) $user_id = $convert->row['poster_id']; + $message = str_replace('
', "\n", $message); $message = str_replace('<', '<', $message); $message = str_replace('>', '>', $message); - $message = str_replace('
', "\n", $message); // make the post UTF-8 $message = phpbb_set_encoding($message); diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php index f39ed60d43..0ec9f24190 100644 --- a/phpBB/install/database_update.php +++ b/phpBB/install/database_update.php @@ -8,7 +8,7 @@ * */ -$updates_to_version = '3.0.7-PL1'; +$updates_to_version = '3.0.8'; // Enter any version to update from to test updates. The version within the db will not be updated. $debug_from_version = false; @@ -119,6 +119,7 @@ $db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, false); unset($dbpasswd); $user->ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : ''; +$user->ip = (stripos($user->ip, '::ffff:') === 0) ? substr($user->ip, 7) : $user->ip; $sql = "SELECT config_value FROM " . CONFIG_TABLE . " @@ -476,7 +477,7 @@ else

-

" class="button1">

+

" class="button1">

sql_escape($module_data['class']) . "' AND parent_id = {$parent_id} - AND left_id BETWEEN {$first_left_id} AND {$module_row['left_id']} - GROUP BY left_id - ORDER BY left_id"; + AND left_id BETWEEN {$first_left_id} AND {$module_row['left_id']}"; $result = $db->sql_query($sql); $steps = (int) $db->sql_fetchfield('num_modules'); $db->sql_freeresult($result); @@ -881,7 +880,7 @@ function database_update_info() 'pm_id' => array('pm_id'), ), POSTS_TABLE => array( - 'post_username' => array('post_username'), + 'post_username' => array('post_username:255'), ), ), ), @@ -913,6 +912,10 @@ function database_update_info() '3.0.7-RC2' => array(), // No changes from 3.0.7 to 3.0.7-PL1 '3.0.7' => array(), + // No changes from 3.0.7-PL1 to 3.0.8-RC1 + '3.0.7-PL1' => array(), + // No changes from 3.0.8-RC1 to 3.0.8 + '3.0.8-RC1' => array(), ); } @@ -1648,6 +1651,213 @@ function change_database_data(&$no_updates, $version) // No changes from 3.0.7 to 3.0.7-PL1 case '3.0.7': break; + + // Changes from 3.0.7-PL1 to 3.0.8-RC1 + case '3.0.7-PL1': + // Update file extension group names to use language strings. + $sql = 'SELECT lang_dir + FROM ' . LANG_TABLE; + $result = $db->sql_query($sql); + + $extension_groups_updated = array(); + while ($lang_dir = $db->sql_fetchfield('lang_dir')) + { + $lang_dir = basename($lang_dir); + + // The language strings we need are either in language/.../acp/attachments.php + // in the update package if we're updating to 3.0.8-RC1 or later, + // or they are in language/.../install.php when we're updating from 3.0.7-PL1 or earlier. + // On an already updated board, they can also already be in language/.../acp/attachments.php + // in the board root. + $lang_files = array( + "{$phpbb_root_path}install/update/new/language/$lang_dir/acp/attachments.$phpEx", + "{$phpbb_root_path}language/$lang_dir/install.$phpEx", + "{$phpbb_root_path}language/$lang_dir/acp/attachments.$phpEx", + ); + + foreach ($lang_files as $lang_file) + { + if (!file_exists($lang_file)) + { + continue; + } + + $lang = array(); + include($lang_file); + + foreach($lang as $lang_key => $lang_val) + { + if (isset($extension_groups_updated[$lang_key]) || strpos($lang_key, 'EXT_GROUP_') !== 0) + { + continue; + } + + $sql_ary = array( + 'group_name' => substr($lang_key, 10), // Strip off 'EXT_GROUP_' + ); + + $sql = 'UPDATE ' . EXTENSION_GROUPS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . " + WHERE group_name = '" . $db->sql_escape($lang_val) . "'"; + _sql($sql, $errored, $error_ary); + + $extension_groups_updated[$lang_key] = true; + } + } + } + $db->sql_freeresult($result); + + // Install modules + $modules_to_install = array( + 'post' => array( + 'base' => 'board', + 'class' => 'acp', + 'title' => 'ACP_POST_SETTINGS', + 'auth' => 'acl_a_board', + 'cat' => 'ACP_MESSAGES', + 'after' => array('message', 'ACP_MESSAGE_SETTINGS') + ), + ); + + _add_modules($modules_to_install); + + // update + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET module_auth = \'cfg_allow_avatar && (cfg_allow_avatar_local || cfg_allow_avatar_remote || cfg_allow_avatar_upload || cfg_allow_avatar_remote_upload)\' + WHERE module_class = \'ucp\' + AND module_basename = \'profile\' + AND module_mode = \'avatar\''; + _sql($sql, $errored, $error_ary); + + // add Bing Bot + $bot_name = 'Bing [Bot]'; + $bot_name_clean = utf8_clean_string($bot_name); + + $sql = 'SELECT user_id + FROM ' . USERS_TABLE . " + WHERE username_clean = '" . $db->sql_escape($bot_name_clean) . "'"; + $result = $db->sql_query($sql); + $bing_already_added = (bool) $db->sql_fetchfield('user_id'); + $db->sql_freeresult($result); + + if (!$bing_already_added) + { + $bot_agent = 'bingbot/'; + $bot_ip = ''; + $sql = 'SELECT group_id, group_colour + FROM ' . GROUPS_TABLE . " + WHERE group_name = 'BOTS'"; + $result = $db->sql_query($sql); + $group_row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + if (!$group_row) + { + // default fallback, should never get here + $group_row['group_id'] = 6; + $group_row['group_colour'] = '9E8DA7'; + } + + if (!function_exists('user_add')) + { + include($phpbb_root_path . 'includes/functions_user.' . $phpEx); + } + + $user_row = array( + 'user_type' => USER_IGNORE, + 'group_id' => $group_row['group_id'], + 'username' => $bot_name, + 'user_regdate' => time(), + 'user_password' => '', + 'user_colour' => $group_row['group_colour'], + 'user_email' => '', + 'user_lang' => $config['default_lang'], + 'user_style' => $config['default_style'], + 'user_timezone' => 0, + 'user_dateformat' => $config['default_dateformat'], + 'user_allow_massemail' => 0, + ); + + $user_id = user_add($user_row); + + $sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array( + 'bot_active' => 1, + 'bot_name' => (string) $bot_name, + 'user_id' => (int) $user_id, + 'bot_agent' => (string) $bot_agent, + 'bot_ip' => (string) $bot_ip, + )); + + _sql($sql, $errored, $error_ary); + } + // end Bing Bot addition + + // Delete shadow topics pointing to not existing topics + $batch_size = 500; + + // Set of affected forums we have to resync + $sync_forum_ids = array(); + + do + { + $sql_array = array( + 'SELECT' => 't1.topic_id, t1.forum_id', + 'FROM' => array( + TOPICS_TABLE => 't1', + ), + 'LEFT_JOIN' => array( + array( + 'FROM' => array(TOPICS_TABLE => 't2'), + 'ON' => 't1.topic_moved_id = t2.topic_id', + ), + ), + 'WHERE' => 't1.topic_moved_id <> 0 + AND t2.topic_id IS NULL', + ); + $sql = $db->sql_build_query('SELECT', $sql_array); + $result = $db->sql_query_limit($sql, $batch_size); + + $topic_ids = array(); + while ($row = $db->sql_fetchrow($result)) + { + $topic_ids[] = (int) $row['topic_id']; + + $sync_forum_ids[(int) $row['forum_id']] = (int) $row['forum_id']; + } + $db->sql_freeresult($result); + + if (!empty($topic_ids)) + { + $sql = 'DELETE FROM ' . TOPICS_TABLE . ' + WHERE ' . $db->sql_in_set('topic_id', $topic_ids); + $db->sql_query($sql); + } + } + while (sizeof($topic_ids) == $batch_size); + + // Sync the forums we have deleted shadow topics from. + sync('forum', 'forum_id', $sync_forum_ids, true, true); + + // Unread posts search load switch + set_config('load_unreads_search', '1'); + + // Reduce queue interval to 60 seconds, email package size to 20 + if ($config['queue_interval'] == 600) + { + set_config('queue_interval', '60'); + } + + if ($config['email_package_size'] == 50) + { + set_config('email_package_size', '20'); + } + + $no_updates = false; + break; + + // No changes from 3.0.8-RC1 to 3.0.8 + case '3.0.8-RC1': + break; } } @@ -1795,6 +2005,36 @@ class updater_db_tools 'VARBINARY' => '[varchar] (255)', ), + 'mssqlnative' => array( + 'INT:' => '[int]', + 'BINT' => '[float]', + 'UINT' => '[int]', + 'UINT:' => '[int]', + 'TINT:' => '[int]', + 'USINT' => '[int]', + 'BOOL' => '[int]', + 'VCHAR' => '[varchar] (255)', + 'VCHAR:' => '[varchar] (%d)', + 'CHAR:' => '[char] (%d)', + 'XSTEXT' => '[varchar] (1000)', + 'STEXT' => '[varchar] (3000)', + 'TEXT' => '[varchar] (8000)', + 'MTEXT' => '[text]', + 'XSTEXT_UNI'=> '[varchar] (100)', + 'STEXT_UNI' => '[varchar] (255)', + 'TEXT_UNI' => '[varchar] (4000)', + 'MTEXT_UNI' => '[text]', + 'TIMESTAMP' => '[int]', + 'DECIMAL' => '[float]', + 'DECIMAL:' => '[float]', + 'PDECIMAL' => '[float]', + 'PDECIMAL:' => '[float]', + 'VCHAR_UNI' => '[varchar] (255)', + 'VCHAR_UNI:'=> '[varchar] (%d)', + 'VCHAR_CI' => '[varchar] (255)', + 'VARBINARY' => '[varchar] (255)', + ), + 'oracle' => array( 'INT:' => 'number(%d)', 'BINT' => 'number(20)', @@ -1896,7 +2136,7 @@ class updater_db_tools * A list of supported DBMS. We change this class to support more DBMS, the DBMS itself only need to follow some rules. * @var array */ - var $supported_dbms = array('firebird', 'mssql', 'mysql_40', 'mysql_41', 'oracle', 'postgres', 'sqlite'); + var $supported_dbms = array('firebird', 'mssql', 'mssqlnative', 'mysql_40', 'mysql_41', 'oracle', 'postgres', 'sqlite'); /** * This is set to true if user only wants to return the 'to-be-executed' SQL statement(s) (as an array). @@ -1942,6 +2182,10 @@ class updater_db_tools $this->sql_layer = 'mssql'; break; + case 'mssqlnative': + $this->sql_layer = 'mssqlnative'; + break; + default: $this->sql_layer = $this->db->sql_layer; break; @@ -1958,7 +2202,7 @@ class updater_db_tools * drop_columns: Removing/Dropping columns * add_primary_keys: adding primary keys * add_unique_index: adding an unique index - * add_index: adding an index + * add_index: adding an index (can be column:index_size if you need to provide size) * * The values are in this format: * {TABLE NAME} => array( @@ -2373,6 +2617,7 @@ class updater_db_tools // same deal with PostgreSQL, we must perform more complex operations than // we technically could case 'mssql': + case 'mssqlnative': $sql = "SELECT c.name FROM syscolumns c LEFT JOIN sysobjects o ON c.id = o.id @@ -2476,7 +2721,7 @@ class updater_db_tools */ function sql_index_exists($table_name, $index_name) { - if ($this->sql_layer == 'mssql') + if ($this->sql_layer == 'mssql' || $this->sql_layer == 'mssqlnative') { $sql = "EXEC sp_statistics '$table_name'"; $result = $this->db->sql_query($sql); @@ -2581,7 +2826,7 @@ class updater_db_tools */ function sql_unique_index_exists($table_name, $index_name) { - if ($this->sql_layer == 'mssql') + if ($this->sql_layer == 'mssql' || $this->sql_layer == 'mssqlnative') { $sql = "EXEC sp_statistics '$table_name'"; $result = $this->db->sql_query($sql); @@ -2820,6 +3065,7 @@ class updater_db_tools break; case 'mssql': + case 'mssqlnative': $sql .= " {$column_type} "; $sql_default = " {$column_type} "; @@ -2969,6 +3215,7 @@ class updater_db_tools break; case 'mssql': + case 'mssqlnative': // Does not support AFTER, only through temporary table $statements[] = 'ALTER TABLE [' . $table_name . '] ADD [' . $column_name . '] ' . $column_data['column_type_sql_default']; break; @@ -3093,6 +3340,7 @@ class updater_db_tools break; case 'mssql': + case 'mssqlnative': $statements[] = 'ALTER TABLE [' . $table_name . '] DROP COLUMN [' . $column_name . ']'; break; @@ -3187,6 +3435,7 @@ class updater_db_tools switch ($this->sql_layer) { case 'mssql': + case 'mssqlnative': $statements[] = 'DROP INDEX ' . $table_name . '.' . $index_name; break; @@ -3223,6 +3472,7 @@ class updater_db_tools break; case 'mssql': + case 'mssqlnative': $sql = "ALTER TABLE [{$table_name}] WITH NOCHECK ADD "; $sql .= "CONSTRAINT [PK_{$table_name}] PRIMARY KEY CLUSTERED ("; $sql .= '[' . implode("],\n\t\t[", $column) . ']'; @@ -3316,6 +3566,7 @@ class updater_db_tools break; case 'mssql': + case 'mssqlnative': $statements[] = 'CREATE UNIQUE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ') ON [PRIMARY]'; break; } @@ -3330,6 +3581,12 @@ class updater_db_tools { $statements = array(); + // remove index length unless MySQL4 + if ('mysql_40' != $this->sql_layer) + { + $column = preg_replace('#:.*$#', '', $column); + } + switch ($this->sql_layer) { case 'firebird': @@ -3340,11 +3597,22 @@ class updater_db_tools break; case 'mysql_40': + // add index size to definition as required by MySQL4 + foreach ($column as $i => $col) + { + if (false !== strpos($col, ':')) + { + list($col, $index_size) = explode(':', $col); + $column[$i] = "$col($index_size)"; + } + } + // no break case 'mysql_41': $statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ')'; break; case 'mssql': + case 'mssqlnative': $statements[] = 'CREATE INDEX ' . $index_name . ' ON ' . $table_name . '(' . implode(', ', $column) . ') ON [PRIMARY]'; break; } @@ -3377,6 +3645,7 @@ class updater_db_tools break; case 'mssql': + case 'mssqlnative': $statements[] = 'ALTER TABLE [' . $table_name . '] ALTER COLUMN [' . $column_name . '] ' . $column_data['column_type_sql']; if (!empty($column_data['default'])) @@ -3534,4 +3803,4 @@ class updater_db_tools } } -?> \ No newline at end of file +?> diff --git a/phpBB/install/install_convert.php b/phpBB/install/install_convert.php index 7f1b9de5b6..814b50cf68 100644 --- a/phpBB/install/install_convert.php +++ b/phpBB/install/install_convert.php @@ -685,7 +685,7 @@ class install_convert extends module // Thanks MySQL, for silently converting... case 'mysql': case 'mysql4': - if (version_compare($src_db->sql_server_info(true), '4.1.3', '>=')) + if (version_compare($src_db->sql_server_info(true, false), '4.1.3', '>=')) { $convert->mysql_convert = true; } @@ -835,7 +835,7 @@ class install_convert extends module $this->p_master->error($user->lang['DEV_NO_TEST_FILE'], __LINE__, __FILE__); } - if (!$local_path || !@is_writable($phpbb_root_path . $local_path)) + if (!$local_path || !phpbb_is_writable($phpbb_root_path . $local_path)) { if (!$local_path) { @@ -1248,6 +1248,7 @@ class install_convert extends module { case 'mssql': case 'mssql_odbc': + case 'mssqlnative': $db->sql_query('SET IDENTITY_INSERT ' . $schema['target'] . ' ON'); break; } @@ -1375,6 +1376,7 @@ class install_convert extends module { case 'mssql': case 'mssql_odbc': + case 'mssqlnative': $db->sql_query('SET IDENTITY_INSERT ' . $schema['target'] . ' OFF'); break; diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 1cc1365752..2dd58584f4 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -486,7 +486,7 @@ class install_install extends module $write = $exists = true; if (file_exists($phpbb_root_path . $dir)) { - if (!@is_writable($phpbb_root_path . $dir)) + if (!phpbb_is_writable($phpbb_root_path . $dir)) { $write = false; } @@ -906,7 +906,7 @@ class install_install extends module $config_data .= '?' . '>'; // Done this to prevent highlighting editors getting confused! // Attempt to write out the config file directly. If it works, this is the easiest way to do it ... - if ((file_exists($phpbb_root_path . 'config.' . $phpEx) && is_writable($phpbb_root_path . 'config.' . $phpEx)) || is_writable($phpbb_root_path)) + if ((file_exists($phpbb_root_path . 'config.' . $phpEx) && phpbb_is_writable($phpbb_root_path . 'config.' . $phpEx)) || phpbb_is_writable($phpbb_root_path)) { // Assume it will work ... if nothing goes wrong below $written = true; @@ -1203,6 +1203,7 @@ class install_install extends module { case 'mssql': case 'mssql_odbc': + case 'mssqlnative': $sql_query = preg_replace('#\# MSSQL IDENTITY (phpbb_[a-z_]+) (ON|OFF) \##s', 'SET IDENTITY_INSERT \1 \2;', $sql_query); break; @@ -1235,6 +1236,7 @@ class install_install extends module $current_time = time(); $user_ip = (!empty($_SERVER['REMOTE_ADDR'])) ? htmlspecialchars($_SERVER['REMOTE_ADDR']) : ''; + $user_ip = (stripos($user_ip, '::ffff:') === 0) ? substr($user_ip, 7) : $user_ip; if ($data['script_path'] !== '/') { @@ -1375,7 +1377,7 @@ class install_install extends module $sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config SET config_value = 'phpbb_captcha_gd' WHERE config_name = 'captcha_plugin'"; - + $sql_ary[] = 'UPDATE ' . $data['table_prefix'] . "config SET config_value = '1' WHERE config_name = 'captcha_gd'"; @@ -2107,6 +2109,7 @@ class install_install extends module 'Alta Vista [Bot]' => array('Scooter/', ''), 'Ask Jeeves [Bot]' => array('Ask Jeeves', ''), 'Baidu [Spider]' => array('Baiduspider+(', ''), + 'Bing [Bot]' => array('bingbot/', ''), 'Exabot [Bot]' => array('Exabot/', ''), 'FAST Enterprise [Crawler]' => array('FAST Enterprise Crawler', ''), 'FAST WebCrawler [Crawler]' => array('FAST-WebCrawler/', ''), diff --git a/phpBB/install/install_update.php b/phpBB/install/install_update.php index a5e54a354a..ec76f2a407 100644 --- a/phpBB/install/install_update.php +++ b/phpBB/install/install_update.php @@ -72,7 +72,7 @@ class install_update extends module function main($mode, $sub) { - global $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth; + global $template, $phpEx, $phpbb_root_path, $user, $db, $config, $cache, $auth, $language; $this->tpl_name = 'install_update'; $this->page_title = 'UPDATE_INSTALLATION'; @@ -119,7 +119,17 @@ class install_update extends module $user->session_begin(); $auth->acl($user->data); - $user->setup('install'); + // Overwrite user's language with the selected one. + // Config needs to be changed to ensure that guests also get the selected language. + $config_default_lang = $config['default_lang']; + $config['default_lang'] = $language; + $user->data['user_lang'] = $language; + + $user->setup(array('common', 'acp/common', 'acp/board', 'install', 'posting')); + + // Reset the default_lang + $config['default_lang'] = $config_default_lang; + unset($config_default_lang); // If we are within the intro page we need to make sure we get up-to-date version info if ($sub == 'intro') @@ -133,6 +143,14 @@ class install_update extends module // still, the acp template is never stored in the database $user->theme['template_storedb'] = false; + $template->assign_vars(array( + 'S_USER_LANG' => $user->lang['USER_LANG'], + 'S_CONTENT_DIRECTION' => $user->lang['DIRECTION'], + 'S_CONTENT_ENCODING' => 'UTF-8', + 'S_CONTENT_FLOW_BEGIN' => ($user->lang['DIRECTION'] == 'ltr') ? 'left' : 'right', + 'S_CONTENT_FLOW_END' => ($user->lang['DIRECTION'] == 'ltr') ? 'right' : 'left', + )); + // Get current and latest version if (($latest_version = $cache->get('_version_info')) === false) { @@ -174,6 +192,17 @@ class install_update extends module return; } + // Check if the update files are actually meant to update from the current version + if ($this->current_version != $this->update_info['version']['from']) + { + $this->unequal_version = true; + + $template->assign_vars(array( + 'S_ERROR' => true, + 'ERROR_MSG' => sprintf($user->lang['INCOMPATIBLE_UPDATE_FILES'], $this->current_version, $this->update_info['version']['from'], $this->update_info['version']['to']), + )); + } + // Check if the update files stored are for the latest version... if ($this->latest_version != $this->update_info['version']['to']) { @@ -234,7 +263,7 @@ class install_update extends module $template->assign_vars(array( 'S_INTRO' => true, - 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=version_check"), + 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=version_check"), )); // Make sure the update list is destroyed. @@ -250,8 +279,8 @@ class install_update extends module 'S_UP_TO_DATE' => $up_to_date, 'S_VERSION_CHECK' => true, - 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"), - 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_db"), + 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"), + 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_db"), 'LATEST_VERSION' => $this->latest_version, 'CURRENT_VERSION' => $this->current_version) @@ -305,8 +334,8 @@ class install_update extends module 'S_DB_UPDATE' => true, 'S_DB_UPDATE_FINISHED' => ($config['version'] == $this->update_info['version']['to']) ? true : false, 'U_DB_UPDATE' => append_sid($phpbb_root_path . 'install/database_update.' . $phpEx, 'type=1&language=' . $user->data['user_lang']), - 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_db"), - 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"), + 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_db"), + 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"), )); break; @@ -363,7 +392,7 @@ class install_update extends module // Refresh the page if we are still not finished... if ($update_list['status'] != -1) { - $refresh_url = append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"); + $refresh_url = append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"); meta_refresh(2, $refresh_url); $template->assign_vars(array( @@ -427,7 +456,7 @@ class install_update extends module $file_part = $filename; } - $diff_url = append_sid($this->p_master->module_url, "mode=$mode&sub=file_check&action=diff&status=$status&file=" . urlencode($file_struct['filename'])); + $diff_url = append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check&action=diff&status=$status&file=" . urlencode($file_struct['filename'])); if (isset($file_struct['as_expected']) && $file_struct['as_expected']) { @@ -475,9 +504,9 @@ class install_update extends module 'S_FILE_CHECK' => true, 'S_ALL_UP_TO_DATE' => $all_up_to_date, 'S_VERSION_UP_TO_DATE' => $up_to_date, - 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check"), - 'U_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_files"), - 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_db"), + 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check"), + 'U_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_files"), + 'U_DB_UPDATE_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_db"), )); if ($all_up_to_date) @@ -690,7 +719,7 @@ class install_update extends module $params[] = 'download=1'; } - $redirect_url = append_sid($this->p_master->module_url, "mode=$mode&sub=update_files&" . implode('&', $params)); + $redirect_url = append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_files&" . implode('&', $params)); meta_refresh(3, $redirect_url); $template->assign_vars(array( @@ -831,7 +860,7 @@ class install_update extends module $template->assign_vars(array( 'S_DOWNLOAD_FILES' => true, - 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_files"), + 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_files"), 'RADIO_BUTTONS' => $radio_buttons, 'S_HIDDEN_FIELDS' => $s_hidden_fields) ); @@ -945,8 +974,8 @@ class install_update extends module 'S_FTP_UPLOAD' => true, 'UPLOAD_METHOD' => $method, - 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_files"), - 'U_DOWNLOAD_METHOD' => append_sid($this->p_master->module_url, "mode=$mode&sub=update_files&download=1"), + 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_files"), + 'U_DOWNLOAD_METHOD' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=update_files&download=1"), 'S_HIDDEN_FIELDS' => $s_hidden_fields, )); @@ -1079,7 +1108,7 @@ class install_update extends module $template->assign_vars(array( 'S_UPLOAD_SUCCESS' => true, - 'U_ACTION' => append_sid($this->p_master->module_url, "mode=$mode&sub=file_check")) + 'U_ACTION' => append_sid($this->p_master->module_url, "language=$language&mode=$mode&sub=file_check")) ); return; } diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql index 960c6eeaed..0827b14cc2 100644 --- a/phpBB/install/schemas/mssql_schema.sql +++ b/phpBB/install/schemas/mssql_schema.sql @@ -4,9 +4,6 @@ */ -BEGIN TRANSACTION -GO - /* Table: 'phpbb_attachments' */ @@ -1733,8 +1730,3 @@ ALTER TABLE [phpbb_zebra] WITH NOCHECK ADD ) ON [PRIMARY] GO - - -COMMIT -GO - diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 996ab5765d..e3c9d1e13a 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -94,7 +94,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('delete_time', '0') INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_check_mx', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_enable', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_function_name', 'mail'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_package_size', '50'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_package_size', '20'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_confirm', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_pm_icons', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_post_confirm', '1'); @@ -168,6 +168,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_online_time', INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_onlinetrack', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_search', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_tplcompile', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_unreads_search', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('load_user_activity', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_attachments', '3'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('max_attachments_pm', '1'); @@ -208,7 +209,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('pm_max_msgs', '50' INSERT INTO phpbb_config (config_name, config_value) VALUES ('pm_max_recipients', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('posts_per_page', '10'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('print_pm', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('queue_interval', '600'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('queue_interval', '60'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('ranks_path', 'images/ranks'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('require_activation', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('referer_validation', '1'); @@ -241,7 +242,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('topics_per_page', INSERT INTO phpbb_config (config_name, config_value) VALUES ('tpl_allow_php', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_icons_path', 'images/upload_icons'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('upload_path', 'files'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '3.0.7-PL1'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('version', '3.0.8'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('warnings_expire_days', '90'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('warnings_gc', '14400'); @@ -509,7 +510,7 @@ INSERT INTO phpbb_styles_theme (theme_name, theme_copyright, theme_path, theme_s # -- Forums INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts, forum_topics, forum_topics_real, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour, forum_last_post_time, forum_link, forum_password, forum_image, forum_rules, forum_rules_link, forum_rules_uid, forum_desc_uid, prune_days, prune_viewed, forum_parents) VALUES ('{L_FORUMS_FIRST_CATEGORY}', '', 1, 4, 0, 0, 1, 1, 1, 1, 2, 'Admin', 'AA0000', 972086460, '', '', '', '', '', '', '', 0, 0, ''); -INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts, forum_topics, forum_topics_real, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour, forum_last_post_subject, forum_last_post_time, forum_link, forum_password, forum_image, forum_rules, forum_rules_link, forum_rules_uid, forum_desc_uid, prune_days, prune_viewed, forum_parents) VALUES ('{L_FORUMS_TEST_FORUM_TITLE}', '{L_FORUMS_TEST_FORUM_DESC}', 2, 3, 1, 1, 1, 1, 1, 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, '', '', '', '', '', '', '', 0, 0, ''); +INSERT INTO phpbb_forums (forum_name, forum_desc, left_id, right_id, parent_id, forum_type, forum_posts, forum_topics, forum_topics_real, forum_last_post_id, forum_last_poster_id, forum_last_poster_name, forum_last_poster_colour, forum_last_post_subject, forum_last_post_time, forum_link, forum_password, forum_image, forum_rules, forum_rules_link, forum_rules_uid, forum_desc_uid, prune_days, prune_viewed, forum_parents, forum_flags) VALUES ('{L_FORUMS_TEST_FORUM_TITLE}', '{L_FORUMS_TEST_FORUM_DESC}', 2, 3, 1, 1, 1, 1, 1, 1, 2, 'Admin', 'AA0000', '{L_TOPICS_TOPIC_TITLE}', 972086460, '', '', '', '', '', '', '', 0, 0, '', 48); # -- Users / Anonymous user INSERT INTO phpbb_users (user_type, group_id, username, username_clean, user_regdate, user_password, user_email, user_lang, user_style, user_rank, user_colour, user_posts, user_permissions, user_ip, user_birthday, user_lastpage, user_last_confirm_key, user_post_sortby_type, user_post_sortby_dir, user_topic_sortby_type, user_topic_sortby_dir, user_avatar, user_sig, user_sig_bbcode_uid, user_from, user_icq, user_aim, user_yim, user_msnm, user_jabber, user_website, user_occ, user_interests, user_actkey, user_newpasswd, user_allow_massemail) VALUES (2, 1, 'Anonymous', 'anonymous', 0, '', '', 'en', 1, 0, '', 0, '', '', '', '', '', 't', 'a', 't', 'd', '', '', '', '', '', '', '', '', '', '', '', '', '', '', 0); @@ -828,4 +829,4 @@ INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'mp3'); INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogg'); INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogm'); -# POSTGRES COMMIT # +# POSTGRES COMMIT # \ No newline at end of file diff --git a/phpBB/language/en/acp/attachments.php b/phpBB/language/en/acp/attachments.php index f6369b6739..1821b8c867 100644 --- a/phpBB/language/en/acp/attachments.php +++ b/phpBB/language/en/acp/attachments.php @@ -85,7 +85,7 @@ $lang = array_merge($lang, array( 'DISPLAY_INLINED_EXPLAIN' => 'If set to No image attachments will show as a link.', 'DISPLAY_ORDER' => 'Attachment display order', 'DISPLAY_ORDER_EXPLAIN' => 'Display attachments ordered by time.', - + 'EDIT_EXTENSION_GROUP' => 'Edit extension group', 'EXCLUDE_ENTERED_IP' => 'Enable this to exclude the entered IP/hostname.', 'EXCLUDE_FROM_ALLOWED_IP' => 'Exclude IP from allowed IPs/hostnames', @@ -97,6 +97,16 @@ $lang = array_merge($lang, array( 'EXTENSION_GROUP_DELETED' => 'Extension group successfully deleted.', 'EXTENSION_GROUP_EXIST' => 'The extension group %s already exists.', + 'EXT_GROUP_ARCHIVES' => 'Archives', + 'EXT_GROUP_DOCUMENTS' => 'Documents', + 'EXT_GROUP_DOWNLOADABLE_FILES' => 'Downloadable Files', + 'EXT_GROUP_FLASH_FILES' => 'Flash Files', + 'EXT_GROUP_IMAGES' => 'Images', + 'EXT_GROUP_PLAIN_TEXT' => 'Plain Text', + 'EXT_GROUP_QUICKTIME_MEDIA' => 'Quicktime Media', + 'EXT_GROUP_REAL_MEDIA' => 'Real Media', + 'EXT_GROUP_WINDOWS_MEDIA' => 'Windows Media', + 'GO_TO_EXTENSIONS' => 'Go to extension management screen', 'GROUP_NAME' => 'Group name', diff --git a/phpBB/language/en/acp/board.php b/phpBB/language/en/acp/board.php index 7f07237fbf..753decd517 100644 --- a/phpBB/language/en/acp/board.php +++ b/phpBB/language/en/acp/board.php @@ -50,7 +50,8 @@ $lang = array_merge($lang, array( 'SITE_DESC' => 'Site description', 'SITE_NAME' => 'Site name', 'SYSTEM_DST' => 'Enable Summer Time/DST', - 'SYSTEM_TIMEZONE' => 'System timezone', + '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 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.', )); @@ -85,7 +86,7 @@ $lang = array_merge($lang, array( 'ALLOW_SMILIES' => 'Allow smilies', 'ALLOW_TOPIC_NOTIFY' => 'Allow subscribing to topics', 'BOARD_PM' => 'Private messaging', - 'BOARD_PM_EXPLAIN' => 'Enable or disable private messaging for all users.', + 'BOARD_PM_EXPLAIN' => 'Enable private messaging for all users.', )); // Avatar Settings @@ -176,8 +177,8 @@ $lang = array_merge($lang, array( 'MIN_CHAR_LIMIT_EXPLAIN' => 'The minimum number of characters the user need to enter within a post/private message.', 'POSTING' => 'Posting', 'POSTS_PER_PAGE' => 'Posts per page', - 'QUOTE_DEPTH_LIMIT' => 'Maximum nested quotes per post', - 'QUOTE_DEPTH_LIMIT_EXPLAIN' => 'Maximum number of nested quotes in a post. Set to 0 for unlimited depth.', + 'QUOTE_DEPTH_LIMIT' => 'Maximum nesting depth for quotes', + 'QUOTE_DEPTH_LIMIT_EXPLAIN' => 'Maximum quote nesting depth in a post. Set to 0 for unlimited depth.', 'SMILIES_LIMIT' => 'Maximum smilies per post', 'SMILIES_LIMIT_EXPLAIN' => 'Maximum number of smilies in a post. Set to 0 for unlimited smilies.', 'SMILIES_PER_PAGE' => 'Smilies per page', @@ -211,7 +212,7 @@ $lang = array_merge($lang, array( 'NEW_MEMBER_POST_LIMIT' => 'New member post limit', 'NEW_MEMBER_POST_LIMIT_EXPLAIN' => 'New members are within the Newly Registered Users group until they reach this number of posts. You can use this group to keep them from using the PM system or to review their posts. A value of 0 disables this feature.', 'NEW_MEMBER_GROUP_DEFAULT' => 'Set Newly Registered Users group to default', - 'NEW_MEMBER_GROUP_DEFAULT_EXPLAIN' => 'If set to yes and a new member post limit is specified newly registered users will be not only put into the Newly Registered Users group, but this group also being their default one. This may come in handy if you want to assign a group default rank and/or avatar the user then inherits.', + 'NEW_MEMBER_GROUP_DEFAULT_EXPLAIN' => 'If set to yes, and a new member post limit is specified, newly registered users will not only be put into the Newly Registered Users group, but this group will also be their default one. This may come in handy if you want to assign a group default rank and/or avatar the user then inherits.', 'ACC_ADMIN' => 'By Admin', 'ACC_DISABLE' => 'Disable', @@ -232,7 +233,7 @@ $lang = array_merge($lang, array( 'PASSWORD_LENGTH' => 'Password length', 'PASSWORD_LENGTH_EXPLAIN' => 'Minimum and maximum number of characters in passwords.', 'REG_LIMIT' => 'Registration attempts', - 'REG_LIMIT_EXPLAIN' => 'Number of attempts users can make at the confirmation code before being locked out that session.', + 'REG_LIMIT_EXPLAIN' => 'Number of attempts users can make at solving the anti-spambot task before being locked out of that session.', 'USERNAME_ALPHA_ONLY' => 'Alphanumeric only', 'USERNAME_ALPHA_SPACERS' => 'Alphanumeric and spacers', 'USERNAME_ASCII' => 'ASCII (no international unicode)', @@ -287,44 +288,44 @@ $lang = array_merge($lang, array( // Visual Confirmation Settings $lang = array_merge($lang, array( - 'ACP_VC_SETTINGS_EXPLAIN' => 'Here you can select and configure CAPTCHA plugins, which implement various ways to reject registration attempts from so-called spambots.', + 'ACP_VC_SETTINGS_EXPLAIN' => 'Here you can select and configure plugins, which are designed to block automated form submissions by spambots. These plugins typically work by challenging the user with a CAPTCHA, a test which is designed to be difficult for computers to solve.', 'AVAILABLE_CAPTCHAS' => 'Available plugins', - 'CAPTCHA_UNAVAILABLE' => 'The CAPTCHA cannot be selected as its requirements are not met.', - 'CAPTCHA_GD' => 'GD CAPTCHA', - 'CAPTCHA_GD_3D' => 'GD 3D Captcha', - 'CAPTCHA_GD_FOREGROUND_NOISE' => 'GD CAPTCHA foreground noise', - 'CAPTCHA_GD_EXPLAIN' => 'Use GD to make a more advanced CAPTCHA.', - 'CAPTCHA_GD_FOREGROUND_NOISE_EXPLAIN' => 'Use foreground noise to make the GD based CAPTCHA harder.', - 'CAPTCHA_GD_X_GRID' => 'GD CAPTCHA background noise x-axis', - 'CAPTCHA_GD_X_GRID_EXPLAIN' => 'Use lower settings of this to make the GD based CAPTCHA harder. 0 will disable x-axis background noise.', - 'CAPTCHA_GD_Y_GRID' => 'GD CAPTCHA background noise y-axis', - 'CAPTCHA_GD_Y_GRID_EXPLAIN' => 'Use lower settings of this to make the GD based CAPTCHA harder. 0 will disable y-axis background noise.', - 'CAPTCHA_GD_WAVE' => 'GD CAPTCHA wave distortion', - 'CAPTCHA_GD_WAVE_EXPLAIN' => 'This applies a wave distortion to the CAPTCHA.', + 'CAPTCHA_UNAVAILABLE' => 'The plugin cannot be selected as its requirements are not met.', + 'CAPTCHA_GD' => 'GD image', + 'CAPTCHA_GD_3D' => 'GD 3D image', + 'CAPTCHA_GD_FOREGROUND_NOISE' => 'Foreground noise', + 'CAPTCHA_GD_EXPLAIN' => 'Uses GD to make a more advanced anti-spambot image.', + 'CAPTCHA_GD_FOREGROUND_NOISE_EXPLAIN' => 'Use foreground noise to make the image harder to read.', + 'CAPTCHA_GD_X_GRID' => 'Background noise x-axis', + 'CAPTCHA_GD_X_GRID_EXPLAIN' => 'Use lower settings of this to make the image harder to read. 0 will disable x-axis background noise.', + 'CAPTCHA_GD_Y_GRID' => 'Background noise y-axis', + 'CAPTCHA_GD_Y_GRID_EXPLAIN' => 'Use lower settings of this to make the image harder to read. 0 will disable y-axis background noise.', + 'CAPTCHA_GD_WAVE' => 'Wave distortion', + 'CAPTCHA_GD_WAVE_EXPLAIN' => 'This applies a wave distortion to the image.', 'CAPTCHA_GD_3D_NOISE' => 'Add 3D-noise objects', - 'CAPTCHA_GD_3D_NOISE_EXPLAIN' => 'This adds additional objects to the CAPTCHA, over the letters.', + 'CAPTCHA_GD_3D_NOISE_EXPLAIN' => 'This adds additional objects to the image, over the letters.', 'CAPTCHA_GD_FONTS' => 'Use different fonts', 'CAPTCHA_GD_FONTS_EXPLAIN' => 'This setting controls how many different letter shapes are used. You can just use the default shapes or introduce altered letters. Adding lowercase letters is also possible.', 'CAPTCHA_FONT_DEFAULT' => 'Default', 'CAPTCHA_FONT_NEW' => 'New Shapes', 'CAPTCHA_FONT_LOWER' => 'Also use lowercase', - 'CAPTCHA_NO_GD' => 'CAPTCHA without GD', - 'CAPTCHA_PREVIEW_MSG' => 'Your changes to the visual confirmation setting were not saved. This is just a preview.', - 'CAPTCHA_PREVIEW_EXPLAIN' => 'The CAPTCHA as it would look like using the current selection.', + 'CAPTCHA_NO_GD' => 'Simple image', + 'CAPTCHA_PREVIEW_MSG' => 'Your changes have not been saved, this is just a preview.', + 'CAPTCHA_PREVIEW_EXPLAIN' => 'The plugin as it would look like using the current selection.', - 'CAPTCHA_SELECT' => 'Installed CAPTCHA plugins', - 'CAPTCHA_SELECT_EXPLAIN' => 'The dropdown holds the CAPTCHA plugins recognized by the board. Gray entries are not available right now and might need configuration prior to use.', - 'CAPTCHA_CONFIGURE' => 'Configure CAPTCHAs', - 'CAPTCHA_CONFIGURE_EXPLAIN' => 'Change the settings for the selected CAPTCHA.', + 'CAPTCHA_SELECT' => 'Installed plugins', + 'CAPTCHA_SELECT_EXPLAIN' => 'The dropdown holds the plugins recognised by the board. Grey entries are not available right now and might need configuration prior to use.', + 'CAPTCHA_CONFIGURE' => 'Configure plugins', + 'CAPTCHA_CONFIGURE_EXPLAIN' => 'Change the settings for the selected plugin.', 'CONFIGURE' => 'Configure', - 'CAPTCHA_NO_OPTIONS' => 'This CAPTCHA has no configuration options.', + 'CAPTCHA_NO_OPTIONS' => 'This plugin has no configuration options.', - 'VISUAL_CONFIRM_POST' => 'Enable visual confirmation for guest postings', - 'VISUAL_CONFIRM_POST_EXPLAIN' => 'Requires anonymous users to enter a random code matching an image to help prevent mass postings.', - 'VISUAL_CONFIRM_REG' => 'Enable visual confirmation for registrations', - 'VISUAL_CONFIRM_REG_EXPLAIN' => 'Requires new users to enter a random code matching an image to help prevent mass registrations.', - 'VISUAL_CONFIRM_REFRESH' => 'Enable users to refresh the confirmation image', - 'VISUAL_CONFIRM_REFRESH_EXPLAIN' => 'Allows users to request new confirmation codes, if they are unable to solve the VC during registration. Some plugins might not support this option.', + 'VISUAL_CONFIRM_POST' => 'Enable spambot countermeasures for guest postings', + 'VISUAL_CONFIRM_POST_EXPLAIN' => 'Requires guest users to pass the anti-spambot task to help prevent automated postings.', + 'VISUAL_CONFIRM_REG' => 'Enable spambot countermeasures for registrations', + 'VISUAL_CONFIRM_REG_EXPLAIN' => 'Requires new users to pass the anti-spambot task to help prevent automated registrations.', + 'VISUAL_CONFIRM_REFRESH' => 'Allow users to refresh the anti-spambot task', + 'VISUAL_CONFIRM_REFRESH_EXPLAIN' => 'Allows users to request a new anti-spambot task if they are unable to solve the currunt task during registration. Some plugins might not support this option.', )); // Cookie Settings @@ -359,7 +360,7 @@ $lang = array_merge($lang, array( 'RECOMPILE_STYLES' => 'Recompile stale style components', 'RECOMPILE_STYLES_EXPLAIN' => 'Check for updated style components on filesystem and recompile.', 'YES_ANON_READ_MARKING' => 'Enable topic marking for guests', - 'YES_ANON_READ_MARKING_EXPLAIN' => 'Stores read/unread status information for guests. If disabled posts are always read for guests.', + 'YES_ANON_READ_MARKING_EXPLAIN' => 'Stores read/unread status information for guests. If disabled, posts are always marked read for guests.', 'YES_BIRTHDAYS' => 'Enable birthday listing', 'YES_BIRTHDAYS_EXPLAIN' => 'If disabled the birthday listing is no longer displayed. To let this setting take effect the birthday feature needs to be enabled too.', 'YES_JUMPBOX' => 'Enable display of jumpbox', @@ -374,6 +375,7 @@ $lang = array_merge($lang, array( 'YES_POST_MARKING_EXPLAIN' => 'Indicates whether user has posted to a topic.', 'YES_READ_MARKING' => 'Enable server-side topic marking', 'YES_READ_MARKING_EXPLAIN' => 'Stores read/unread status information in the database rather than a cookie.', + 'YES_UNREAD_SEARCH' => 'Enable search for unread posts', )); // Auth settings @@ -392,7 +394,7 @@ $lang = array_merge($lang, array( 'LDAP_NO_EMAIL' => 'The specified e-mail attribute does not exist.', 'LDAP_NO_IDENTITY' => 'Could not find a login identity for %s.', 'LDAP_PASSWORD' => 'LDAP password', - 'LDAP_PASSWORD_EXPLAIN' => 'Leave blank to use anonymous binding. Else fill in the password for the above user. Required for Active Directory Servers.
Warning: This password will be stored as plain text in the database visible to everybody who can access your database or who can view this configuration page.', + 'LDAP_PASSWORD_EXPLAIN' => 'Leave blank to use anonymous binding. Else fill in the password for the above user. Required for Active Directory Servers.
Warning: This password will be stored as plain text in the database, visible to everybody who can access your database or who can view this configuration page.', 'LDAP_PORT' => 'LDAP server port', 'LDAP_PORT_EXPLAIN' => 'Optionally you can specify a port which should be used to connect to the LDAP server instead of the default port 389.', 'LDAP_SERVER' => 'LDAP server name', @@ -461,7 +463,7 @@ $lang = array_merge($lang, array( 'IP_VALID' => 'Session IP validation', 'IP_VALID_EXPLAIN' => 'Determines how much of the users IP is used to validate a session; All compares the complete address, A.B.C the first x.x.x, A.B the first x.x, None disables checking. On IPv6 addresses A.B.C compares the first 4 blocks and A.B the first 3 blocks.', 'MAX_LOGIN_ATTEMPTS' => 'Maximum number of login attempts', - 'MAX_LOGIN_ATTEMPTS_EXPLAIN' => 'After this number of failed logins the user needs to additionally confirm his login visually (visual confirmation).', + 'MAX_LOGIN_ATTEMPTS_EXPLAIN' => 'After this number of failed logins the user needs to additionally solve the anti-spambot task.', 'NO_IP_VALIDATION' => 'None', 'NO_REF_VALIDATION' => 'None', 'PASSWORD_TYPE' => 'Password complexity', @@ -504,7 +506,7 @@ $lang = array_merge($lang, array( 'SMTP_DIGEST_MD5' => 'DIGEST-MD5', 'SMTP_LOGIN' => 'LOGIN', 'SMTP_PASSWORD' => 'SMTP password', - 'SMTP_PASSWORD_EXPLAIN' => 'Only enter a password if your SMTP server requires it.
Warning: This password will be stored as plain text in the database visible to everybody who can access your database or who can view this configuration page.', + 'SMTP_PASSWORD_EXPLAIN' => 'Only enter a password if your SMTP server requires it.
Warning: This password will be stored as plain text in the database, visible to everybody who can access your database or who can view this configuration page.', 'SMTP_PLAIN' => 'PLAIN', 'SMTP_POP_BEFORE_SMTP' => 'POP-BEFORE-SMTP', 'SMTP_PORT' => 'SMTP server port', @@ -527,7 +529,7 @@ $lang = array_merge($lang, array( 'JAB_PACKAGE_SIZE' => 'Jabber package size', 'JAB_PACKAGE_SIZE_EXPLAIN' => 'This is the number of messages sent in one package. If set to 0 the message is sent immediately and will not be queued for later sending.', 'JAB_PASSWORD' => 'Jabber password', - 'JAB_PASSWORD_EXPLAIN' => 'Warning: This password will be stored as plain text in the database visible to everybody who can access your database or who can view this configuration page.', + 'JAB_PASSWORD_EXPLAIN' => 'Warning: This password will be stored as plain text in the database, visible to everybody who can access your database or who can view this configuration page.', 'JAB_PORT' => 'Jabber port', 'JAB_PORT_EXPLAIN' => 'Leave blank unless you know it is not port 5222.', 'JAB_SERVER' => 'Jabber server', diff --git a/phpBB/language/en/acp/common.php b/phpBB/language/en/acp/common.php index bca19c7f12..2c549f8130 100644 --- a/phpBB/language/en/acp/common.php +++ b/phpBB/language/en/acp/common.php @@ -190,7 +190,7 @@ $lang = array_merge($lang, array( 'ACP_USER_SIG' => 'Signature', 'ACP_USER_WARNINGS' => 'Warnings', - 'ACP_VC_SETTINGS' => 'CAPTCHA module settings', + 'ACP_VC_SETTINGS' => 'Spambot countermeasures', 'ACP_VC_CAPTCHA_DISPLAY' => 'CAPTCHA image preview', 'ACP_VERSION_CHECK' => 'Check for updates', 'ACP_VIEW_ADMIN_PERMISSIONS' => 'View administrative permissions', @@ -503,7 +503,7 @@ $lang = array_merge($lang, array( 'LOG_CONFIG_SERVER' => 'Altered server settings', 'LOG_CONFIG_SETTINGS' => 'Altered board settings', 'LOG_CONFIG_SIGNATURE' => 'Altered signature settings', - 'LOG_CONFIG_VISUAL' => 'Altered antibot settings', + 'LOG_CONFIG_VISUAL' => 'Altered anti-spambot settings', 'LOG_APPROVE_TOPIC' => 'Approved topic
» %s', 'LOG_BUMP_TOPIC' => 'User bumped topic
» %s', diff --git a/phpBB/language/en/acp/search.php b/phpBB/language/en/acp/search.php index 88eed9d948..a7d687d7c2 100644 --- a/phpBB/language/en/acp/search.php +++ b/phpBB/language/en/acp/search.php @@ -59,6 +59,8 @@ $lang = array_merge($lang, array( 'FULLTEXT_MYSQL_PCRE' => 'Support for non-latin UTF-8 characters using PCRE:', 'FULLTEXT_MYSQL_MBSTRING_EXPLAIN' => 'If PCRE does not have unicode character properties, the search backend will try to use mbstring’s regular expression engine.', 'FULLTEXT_MYSQL_PCRE_EXPLAIN' => 'This search backend requires PCRE unicode character properties, only available in PHP 4.4, 5.1 and above, if you want to search for non-latin characters.', + 'FULLTEXT_MYSQL_MIN_SEARCH_CHARS_EXPLAIN' => 'Words with at least this many characters will be indexed for searching. You or your host can only change this setting by changing the mysql configuration.', + 'FULLTEXT_MYSQL_MAX_SEARCH_CHARS_EXPLAIN' => 'Words with no more than this many characters will be indexed for searching. You or your host can only change this setting by changing the mysql configuration.', 'GENERAL_SEARCH_SETTINGS' => 'General search settings', 'GO_TO_SEARCH_INDEX' => 'Go to search index page', diff --git a/phpBB/language/en/acp/styles.php b/phpBB/language/en/acp/styles.php index 247d8a4140..f161a7e6e6 100644 --- a/phpBB/language/en/acp/styles.php +++ b/phpBB/language/en/acp/styles.php @@ -76,13 +76,13 @@ $lang = array_merge($lang, array( 'DEACTIVATE_DEFAULT' => 'You cannot deactivate the default style.', 'DELETE_FROM_FS' => 'Delete from filesystem', 'DELETE_IMAGESET' => 'Delete imageset', - 'DELETE_IMAGESET_EXPLAIN' => 'Here you can remove the selected imageset from the database. Additionally, if you have permission you can elect to remove the set from the filesystem. Please note that there is no undo capability. When the imageset is deleted it is gone for good. It is recommended that you first export your set for possible future use.', + 'DELETE_IMAGESET_EXPLAIN' => 'Here you can remove the selected imageset from the database. Please note that there is no undo capability. It is recommended that you first export your set for possible future use.', 'DELETE_STYLE' => 'Delete style', - 'DELETE_STYLE_EXPLAIN' => 'Here you can remove the selected style. You cannot remove all the style elements from here. These must be deleted individually via their respective forms. Take care in deleting styles there is no undo facility.', + 'DELETE_STYLE_EXPLAIN' => 'Here you can remove the selected style. You cannot remove all the style elements from here. These must be deleted individually via their respective forms. Take care when deleting styles, there is no undo facility.', 'DELETE_TEMPLATE' => 'Delete template', - 'DELETE_TEMPLATE_EXPLAIN' => 'Here you can remove the selected template set from the database. Additionally, if you have permission you can elect to remove the set from the filesystem. Please note that there is no undo capability. When the templates are deleted they are gone for good. It is recommended that you first export your set for possible future use.', + 'DELETE_TEMPLATE_EXPLAIN' => 'Here you can remove the selected template set from the database. Please note that there is no undo capability. It is recommended that you first export your set for possible future use.', 'DELETE_THEME' => 'Delete theme', - 'DELETE_THEME_EXPLAIN' => 'Here you can remove the selected theme from the database. Additionally, if you have permission you can elect to remove the theme from the filesystem. Please note that there is no undo capability. When the theme is deleted it is gone for good. It is recommended that you first export your theme for possible future use.', + 'DELETE_THEME_EXPLAIN' => 'Here you can remove the selected theme from the database. Please note that there is no undo capability. It is recommended that you first export your theme for possible future use.', 'DETAILS' => 'Details', 'DIMENSIONS_EXPLAIN' => 'Selecting yes here will include width/height parameters.', @@ -165,11 +165,11 @@ $lang = array_merge($lang, array( 'IMG_FORUM_READ' => 'Forum', 'IMG_FORUM_READ_LOCKED' => 'Forum locked', 'IMG_FORUM_READ_SUBFORUM' => 'Subforum', - 'IMG_FORUM_UNREAD' => 'Forum new posts', - 'IMG_FORUM_UNREAD_LOCKED' => 'Forum new posts locked', - 'IMG_FORUM_UNREAD_SUBFORUM' => 'Subforum new posts', + 'IMG_FORUM_UNREAD' => 'Forum unread posts', + 'IMG_FORUM_UNREAD_LOCKED' => 'Forum unread posts locked', + 'IMG_FORUM_UNREAD_SUBFORUM' => 'Subforum unread posts', 'IMG_SUBFORUM_READ' => 'Legend subforum', - 'IMG_SUBFORUM_UNREAD' => 'Legend subforum new posts', + 'IMG_SUBFORUM_UNREAD' => 'Legend subforum unread posts', 'IMG_TOPIC_MOVED' => 'Topic moved', @@ -180,39 +180,39 @@ $lang = array_merge($lang, array( 'IMG_TOPIC_READ_LOCKED' => 'Topic locked', 'IMG_TOPIC_READ_LOCKED_MINE' => 'Topic locked posted to', - 'IMG_TOPIC_UNREAD' => 'Topic new posts', - 'IMG_TOPIC_UNREAD_MINE' => 'Topic posted to new', - 'IMG_TOPIC_UNREAD_HOT' => 'Topic popular new posts', - 'IMG_TOPIC_UNREAD_HOT_MINE' => 'Topic popular posted to new', - 'IMG_TOPIC_UNREAD_LOCKED' => 'Topic locked new', - 'IMG_TOPIC_UNREAD_LOCKED_MINE' => 'Topic locked posted to new', + 'IMG_TOPIC_UNREAD' => 'Topic unread posts', + 'IMG_TOPIC_UNREAD_MINE' => 'Topic posted to unread', + 'IMG_TOPIC_UNREAD_HOT' => 'Topic popular unread posts', + 'IMG_TOPIC_UNREAD_HOT_MINE' => 'Topic popular posted to unread', + 'IMG_TOPIC_UNREAD_LOCKED' => 'Topic locked unread', + 'IMG_TOPIC_UNREAD_LOCKED_MINE' => 'Topic locked posted to unread', 'IMG_STICKY_READ' => 'Sticky topic', 'IMG_STICKY_READ_MINE' => 'Sticky topic posted to', 'IMG_STICKY_READ_LOCKED' => 'Sticky topic locked', 'IMG_STICKY_READ_LOCKED_MINE' => 'Sticky topic locked posted to', - 'IMG_STICKY_UNREAD' => 'Sticky topic new posts', - 'IMG_STICKY_UNREAD_MINE' => 'Sticky topic posted to new', - 'IMG_STICKY_UNREAD_LOCKED' => 'Sticky topic locked new posts', - 'IMG_STICKY_UNREAD_LOCKED_MINE' => 'Sticky topic locked posted to new', + 'IMG_STICKY_UNREAD' => 'Sticky topic unread posts', + 'IMG_STICKY_UNREAD_MINE' => 'Sticky topic posted to unread', + 'IMG_STICKY_UNREAD_LOCKED' => 'Sticky topic locked unread posts', + 'IMG_STICKY_UNREAD_LOCKED_MINE' => 'Sticky topic locked posted to unread', 'IMG_ANNOUNCE_READ' => 'Announcement', 'IMG_ANNOUNCE_READ_MINE' => 'Announcement posted to', 'IMG_ANNOUNCE_READ_LOCKED' => 'Announcement locked', 'IMG_ANNOUNCE_READ_LOCKED_MINE' => 'Announcement locked posted to', - 'IMG_ANNOUNCE_UNREAD' => 'Announcement new posts', - 'IMG_ANNOUNCE_UNREAD_MINE' => 'Announcement posted to new', - 'IMG_ANNOUNCE_UNREAD_LOCKED' => 'Announcement locked new posts', - 'IMG_ANNOUNCE_UNREAD_LOCKED_MINE' => 'Announcement locked posted to new', + 'IMG_ANNOUNCE_UNREAD' => 'Announcement unread posts', + 'IMG_ANNOUNCE_UNREAD_MINE' => 'Announcement posted to unread', + 'IMG_ANNOUNCE_UNREAD_LOCKED' => 'Announcement locked unread posts', + 'IMG_ANNOUNCE_UNREAD_LOCKED_MINE' => 'Announcement locked posted to unread', 'IMG_GLOBAL_READ' => 'Global', 'IMG_GLOBAL_READ_MINE' => 'Global posted to', 'IMG_GLOBAL_READ_LOCKED' => 'Global locked', 'IMG_GLOBAL_READ_LOCKED_MINE' => 'Global locked posted to', - 'IMG_GLOBAL_UNREAD' => 'Global new posts', - 'IMG_GLOBAL_UNREAD_MINE' => 'Global posted to new', - 'IMG_GLOBAL_UNREAD_LOCKED' => 'Global locked new posts', - 'IMG_GLOBAL_UNREAD_LOCKED_MINE' => 'Global locked posted to new', + 'IMG_GLOBAL_UNREAD' => 'Global unread posts', + 'IMG_GLOBAL_UNREAD_MINE' => 'Global posted to unread', + 'IMG_GLOBAL_UNREAD_LOCKED' => 'Global locked unread posts', + 'IMG_GLOBAL_UNREAD_LOCKED_MINE' => 'Global locked posted to unread', 'IMG_PM_READ' => 'Read private message', 'IMG_PM_UNREAD' => 'Unread private message', diff --git a/phpBB/language/en/acp/users.php b/phpBB/language/en/acp/users.php index 8d9bf0d486..eda9659795 100644 --- a/phpBB/language/en/acp/users.php +++ b/phpBB/language/en/acp/users.php @@ -42,6 +42,7 @@ $lang = array_merge($lang, array( 'BAN_ALREADY_ENTERED' => 'The ban had been previously entered successfully. The ban list has not been updated.', 'BAN_SUCCESSFUL' => 'Ban entered successfully.', + 'CANNOT_BAN_ANONYMOUS' => 'You are not allowed to ban the anonymous account. Permissions for anonymous users can be set under the Permissions tab.', 'CANNOT_BAN_FOUNDER' => 'You are not allowed to ban founder accounts.', 'CANNOT_BAN_YOURSELF' => 'You are not allowed to ban yourself.', 'CANNOT_DEACTIVATE_BOT' => 'You are not allowed to deactivate bot accounts. Please deactivate the bot within the bots page instead.', diff --git a/phpBB/language/en/captcha_qa.php b/phpBB/language/en/captcha_qa.php index 5cd822b3c4..42c8df2d6d 100644 --- a/phpBB/language/en/captcha_qa.php +++ b/phpBB/language/en/captcha_qa.php @@ -36,9 +36,9 @@ if (empty($lang) || !is_array($lang)) // in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine $lang = array_merge($lang, array( - 'CAPTCHA_QA' => 'Q&A CAPTCHA', - 'CONFIRM_QUESTION_EXPLAIN' => 'This question is a means of identifying and preventing automated submissions.', - 'CONFIRM_QUESTION_WRONG' => 'You have provided an invalid answer to the confirmation question.', + 'CAPTCHA_QA' => 'Q&A', + 'CONFIRM_QUESTION_EXPLAIN' => 'This question is a means of preventing automated form submissions by spambots.', + 'CONFIRM_QUESTION_WRONG' => 'You have provided an invalid answer to the question.', 'QUESTION_ANSWERS' => 'Answers', 'ANSWERS_EXPLAIN' => 'Please enter valid answers to the question, one per line.', @@ -47,15 +47,15 @@ $lang = array_merge($lang, array( 'ANSWER' => 'Answer', 'EDIT_QUESTION' => 'Edit Question', 'QUESTIONS' => 'Questions', - 'QUESTIONS_EXPLAIN' => 'During registration, users will be asked one of the questions specified here. To use this plugin, at least one question must be set in the default language. These questions should be easy for your target audience to answer, but beyond the ability of a bot capable of running a Google™ search. Using a large and regulary changed set of questions will yield the best results. Enable the strict setting if your question relies on punctuation or capitalisation.', + 'QUESTIONS_EXPLAIN' => 'For every form submission where you have enabled the Q&A plugin, users will be asked one of the questions specified here. To use this plugin at least one question must be set in the default language. These questions should be easy for your target audience to answer but beyond the ability of a bot capable of running a Google™ search. Using a large and regularly changed set of questions will yield the best results. Enable the strict setting if your question relies on mixed case, punctuation or whitespace.', 'QUESTION_DELETED' => 'Question deleted', 'QUESTION_LANG' => 'Language', - 'QUESTION_LANG_EXPLAIN' => 'The language that this question and its answers are written in.', + 'QUESTION_LANG_EXPLAIN' => 'The language this question and its answers are written in.', 'QUESTION_STRICT' => 'Strict check', - 'QUESTION_STRICT_EXPLAIN' => 'If enabled, capitalisation and whitespace will also be enforced.', + 'QUESTION_STRICT_EXPLAIN' => 'Enable to enforce mixed case, punctuation and whitespace.', 'QUESTION_TEXT' => 'Question', - 'QUESTION_TEXT_EXPLAIN' => 'The question that will be asked on registration.', + 'QUESTION_TEXT_EXPLAIN' => 'The question presented to the user.', 'QA_ERROR_MSG' => 'Please fill in all fields and enter at least one answer.', 'QA_LAST_QUESTION' => 'You cannot delete all questions while the plugin is active.', diff --git a/phpBB/language/en/captcha_recaptcha.php b/phpBB/language/en/captcha_recaptcha.php index 897e8a4979..463bfffe0d 100644 --- a/phpBB/language/en/captcha_recaptcha.php +++ b/phpBB/language/en/captcha_recaptcha.php @@ -46,7 +46,7 @@ $lang = array_merge($lang, array( 'RECAPTCHA_PRIVATE' => 'Private reCaptcha key', 'RECAPTCHA_PRIVATE_EXPLAIN' => 'Your private reCaptcha key. Keys can be obtained on reCaptcha.net.', - 'RECAPTCHA_EXPLAIN' => 'In an effort to prevent automatic submissions, we require that you enter both of the words displayed below into the text field underneath.', + 'RECAPTCHA_EXPLAIN' => 'In an effort to prevent automatic submissions, we require that you enter both of the words displayed into the text field underneath.', )); ?> \ No newline at end of file diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 821896f32a..db60cbf227 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -124,7 +124,7 @@ $lang = array_merge($lang, array( 'COMMA_SEPARATOR' => ', ', // Used in pagination of ACP & prosilver, use localised comma if appropriate, eg: Ideographic or Arabic 'CONFIRM' => 'Confirm', 'CONFIRM_CODE' => 'Confirmation code', - 'CONFIRM_CODE_EXPLAIN' => 'Enter the code exactly as it appears. All letters are case insensitive, there is no zero.', + 'CONFIRM_CODE_EXPLAIN' => 'Enter the code exactly as it appears. All letters are case insensitive.', 'CONFIRM_CODE_WRONG' => 'The confirmation code you entered was incorrect.', 'CONFIRM_OPERATION' => 'Are you sure you wish to carry out this operation?', 'CONGRATULATIONS' => 'Congratulations to', @@ -295,6 +295,7 @@ $lang = array_merge($lang, array( 'LAST_VISIT' => 'Last visit', 'LDAP_NO_LDAP_EXTENSION' => 'LDAP extension not available.', 'LDAP_NO_SERVER_CONNECTION' => 'Could not connect to LDAP server.', + 'LDAP_SEARCH_FAILED' => 'An error occured while searching the LDAP directory.', 'LEGEND' => 'Legend', 'LOCATION' => 'Location', 'LOCK_POST' => 'Lock post', @@ -303,8 +304,8 @@ $lang = array_merge($lang, array( 'LOGIN' => 'Login', 'LOGIN_CHECK_PM' => 'Log in to check your private messages.', 'LOGIN_CONFIRMATION' => 'Confirmation of login', - 'LOGIN_CONFIRM_EXPLAIN' => 'To prevent brute forcing accounts the board requires you to enter a confirmation code after a maximum amount of failed logins. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.', - 'LOGIN_ERROR_ATTEMPTS' => 'You exceeded the maximum allowed number of login attempts. In addition to your username and password you now also have to enter the confirm code from the image you see below.', + 'LOGIN_CONFIRM_EXPLAIN' => 'To prevent brute forcing accounts the board requires you to enter a confirmation code after a maximum amount of failed logins. The code is displayed in the image you should see below. If you are visually impaired or cannot otherwise read this code please contact the %sBoard Administrator%s.', // unused + 'LOGIN_ERROR_ATTEMPTS' => 'You exceeded the maximum allowed number of login attempts. In addition to your username and password you now also have to solve the CAPTCHA below.', 'LOGIN_ERROR_EXTERNAL_AUTH_APACHE' => 'You have not been authenticated by Apache.', 'LOGIN_ERROR_PASSWORD' => 'You have specified an incorrect password. Please check your password and try again. If you continue to have problems please contact the %sBoard Administrator%s.', 'LOGIN_ERROR_PASSWORD_CONVERT' => 'It was not possible to convert your password when updating this bulletin board’s software. Please %srequest a new password%s. If you continue to have problems please contact the %sBoard Administrator%s.', @@ -346,8 +347,8 @@ $lang = array_merge($lang, array( 'NEW_MESSAGES' => 'New messages', 'NEW_PM' => '%d new message', 'NEW_PMS' => '%d new messages', - 'NEW_POST' => 'New post', - 'NEW_POSTS' => 'New posts', + 'NEW_POST' => 'New post', // Not used anymore + 'NEW_POSTS' => 'New posts', // Not used anymore 'NEXT' => 'Next', // Used in pagination 'NEXT_STEP' => 'Next', 'NEVER' => 'Never', @@ -380,7 +381,7 @@ $lang = array_merge($lang, array( 'NO_MODERATORS' => 'There are no moderators.', 'NO_NEW_MESSAGES' => 'No new messages', 'NO_NEW_PM' => '0 new messages', - 'NO_NEW_POSTS' => 'No new posts', + 'NO_NEW_POSTS' => 'No new posts', // Not used anymore 'NO_ONLINE_USERS' => 'No registered users', 'NO_POSTS' => 'No posts', 'NO_POSTS_TIME_FRAME' => 'No posts exist inside this topic for the selected time frame.', @@ -394,6 +395,7 @@ $lang = array_merge($lang, array( 'NO_TOPICS' => 'There are no topics or posts in this forum.', 'NO_TOPICS_TIME_FRAME' => 'No topics exist inside this forum for the selected time frame.', 'NO_UNREAD_PM' => '0 unread messages', + 'NO_UNREAD_POSTS' => 'No unread posts', 'NO_UPLOAD_FORM_FOUND' => 'Upload initiated but no valid file upload form found.', 'NO_USER' => 'The requested user does not exist.', 'NO_USERS' => 'The requested users do not exist.', @@ -420,6 +422,7 @@ $lang = array_merge($lang, array( 'PIXEL' => 'px', 'PLAY_QUICKTIME_FILE' => 'Play Quicktime file', 'PM' => 'PM', + 'PM_REPORTED' => 'Click to view report', 'POSTING_MESSAGE' => 'Posting message in %s', 'POSTING_PRIVATE_MESSAGE' => 'Composing private message', 'POST' => 'Post', @@ -563,6 +566,9 @@ $lang = array_merge($lang, array( 'TEST_CONNECTION' => 'Test connection', 'THE_TEAM' => 'The team', 'TIME' => 'Time', + + 'TOO_LARGE' => 'The value you entered is too large.', + 'TOO_LARGE_MAX_RECIPIENTS' => 'The value of Maximum number of allowed recipients per private message setting you entered is too large.', 'TOO_LONG' => 'The value you entered is too long.', @@ -605,6 +611,9 @@ $lang = array_merge($lang, array( 'TOO_SHORT_EMAIL_CONFIRM' => 'The e-mail address confirmation you entered is too short.', 'TOO_SHORT_WEBSITE' => 'The website address you entered is too short.', 'TOO_SHORT_YIM' => 'The Yahoo! Messenger name you entered is too short.', + + 'TOO_SMALL' => 'The value you entered is too small.', + 'TOO_SMALL_MAX_RECIPIENTS' => 'The value of Maximum number of allowed recipients per private message setting you entered is too small.', 'TOPIC' => 'Topic', 'TOPICS' => 'Topics', @@ -639,6 +648,8 @@ $lang = array_merge($lang, array( 'UNREAD_MESSAGES' => 'Unread messages', 'UNREAD_PM' => '%d unread message', 'UNREAD_PMS' => '%d unread messages', + 'UNREAD_POST' => 'Unread post', + 'UNREAD_POSTS' => 'Unread posts', 'UNWATCHED_FORUMS' => 'You are no longer subscribed to the selected forums.', 'UNWATCHED_TOPICS' => 'You are no longer subscribed to the selected topics.', 'UNWATCHED_FORUMS_TOPICS' => 'You are no longer subscribed to the selected entries.', diff --git a/phpBB/language/en/email/admin_welcome_inactive.txt b/phpBB/language/en/email/admin_welcome_inactive.txt index e0970d3ff3..30b3aae852 100644 --- a/phpBB/language/en/email/admin_welcome_inactive.txt +++ b/phpBB/language/en/email/admin_welcome_inactive.txt @@ -10,7 +10,7 @@ Username: {USERNAME} Board URL: {U_BOARD} ---------------------------- -Your account is currently inactive and will need to be approved by an administrator before you can log in. Another email will be sent when this has occured. +Your account is currently inactive and will need to be approved by an administrator before you can log in. Another email will be sent when this has occurred. Your password has been securely stored in our database and cannot be retrieved. In the event that it is forgotten, you will be able to reset it using the email address associated with your account. diff --git a/phpBB/language/en/help_faq.php b/phpBB/language/en/help_faq.php index c76c281df5..3b7dc02d3f 100644 --- a/phpBB/language/en/help_faq.php +++ b/phpBB/language/en/help_faq.php @@ -128,7 +128,7 @@ $help = array( ), array( 0 => 'Why can’t I add more poll options?', - 1 => 'The limit for poll options is set by the board administrator. If you feel you need to add more options to your poll then the allowed amount, contact the board administrator.' + 1 => 'The limit for poll options is set by the board administrator. If you feel you need to add more options to your poll than the allowed amount, contact the board administrator.' ), array( 0 => 'How do I edit or delete a poll?', diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php index 9543c712da..14923e836e 100644 --- a/phpBB/language/en/install.php +++ b/phpBB/language/en/install.php @@ -128,7 +128,7 @@ $lang = array_merge($lang, array( 'DB_ERR_QUERY_FIRST_TABLE' => 'Error while executing query_first, %s (“%s”).', 'DB_ERR_SELECT' => 'Error while running SELECT query.', 'DB_HOST' => 'Database server hostname or DSN', - 'DB_HOST_EXPLAIN' => 'DSN stands for Data Source Name and is relevant only for ODBC installs.', + 'DB_HOST_EXPLAIN' => 'DSN stands for Data Source Name and is relevant only for ODBC installs. On PostgreSQL, use localhost to connect to the local server via UNIX domain socket and 127.0.0.1 to connect via TCP.', 'DB_NAME' => 'Database name', 'DB_PASSWORD' => 'Database password', 'DB_PORT' => 'Database server port', @@ -147,6 +147,7 @@ $lang = array_merge($lang, array( 'DLL_MBSTRING' => 'Multi-byte character support', 'DLL_MSSQL' => 'MSSQL Server 2000+', 'DLL_MSSQL_ODBC' => 'MSSQL Server 2000+ via ODBC', + 'DLL_MSSQLNATIVE' => 'MSSQL Server 2005+ [ Native ]', 'DLL_MYSQL' => 'MySQL', 'DLL_MYSQLI' => 'MySQL with MySQLi Extension', 'DLL_ORACLE' => 'Oracle', @@ -214,6 +215,7 @@ $lang = array_merge($lang, array(
  • SQLite 2.8.2+
  • Firebird 2.1+
  • MS SQL Server 2000 or above (directly or via ODBC)
  • +
  • MS SQL Server 2005 or above (native)
  • Oracle
  • @@ -557,6 +559,7 @@ $lang = array_merge($lang, array( 'UPDATING_DATA' => 'Updating data', 'UPDATING_TO_LATEST_STABLE' => 'Updating database to latest stable release', 'UPDATED_VERSION' => 'Updated version', + 'UPGRADE_INSTRUCTIONS' => 'A new feature release %1$s is available. Please read the release announcement to learn about what it has to offer, and how to upgrade.', 'UPLOAD_METHOD' => 'Upload method', 'UPDATE_DB_SUCCESS' => 'Database update was successful.', @@ -584,16 +587,6 @@ $lang = array_merge($lang, array( 'DEFAULT_INSTALL_POST' => 'This is an example post in your phpBB3 installation. Everything seems to be working. You may delete this post if you like and continue to set up your board. During the installation process your first category and your first forum are assigned an appropriate set of permissions for the predefined usergroups administrators, bots, global moderators, guests, registered users and registered COPPA users. If you also choose to delete your first category and your first forum, do not forget to assign permissions for all these usergroups for all new categories and forums you create. It is recommended to rename your first category and your first forum and copy permissions from these while creating new categories and forums. Have fun!', - 'EXT_GROUP_ARCHIVES' => 'Archives', - 'EXT_GROUP_DOCUMENTS' => 'Documents', - 'EXT_GROUP_DOWNLOADABLE_FILES' => 'Downloadable Files', - 'EXT_GROUP_FLASH_FILES' => 'Flash Files', - 'EXT_GROUP_IMAGES' => 'Images', - 'EXT_GROUP_PLAIN_TEXT' => 'Plain Text', - 'EXT_GROUP_QUICKTIME_MEDIA' => 'Quicktime Media', - 'EXT_GROUP_REAL_MEDIA' => 'Real Media', - 'EXT_GROUP_WINDOWS_MEDIA' => 'Windows Media', - 'FORUMS_FIRST_CATEGORY' => 'Your first category', 'FORUMS_TEST_FORUM_DESC' => 'Description of your first forum.', 'FORUMS_TEST_FORUM_TITLE' => 'Your first forum', diff --git a/phpBB/language/en/search.php b/phpBB/language/en/search.php index be92391a4e..d93fe6b56a 100644 --- a/phpBB/language/en/search.php +++ b/phpBB/language/en/search.php @@ -62,6 +62,7 @@ $lang = array_merge($lang, array( 'NO_SEARCH' => 'Sorry but you are not permitted to use the search system.', 'NO_SEARCH_RESULTS' => 'No suitable matches were found.', 'NO_SEARCH_TIME' => 'Sorry but you cannot use search at this time. Please try again in a few minutes.', + 'NO_SEARCH_UNREADS' => 'Sorry but searching for unread posts has been disabled on this board.', 'WORD_IN_NO_POST' => 'No posts were found because the word %s is not contained in any post.', 'WORDS_IN_NO_POST' => 'No posts were found because the words %s are not contained in any post.', diff --git a/phpBB/language/en/search_synonyms.php b/phpBB/language/en/search_synonyms.php index 1618c292d3..e544456226 100644 --- a/phpBB/language/en/search_synonyms.php +++ b/phpBB/language/en/search_synonyms.php @@ -77,7 +77,7 @@ $synonyms = array( 'foriegn' => 'foreign', 'fourty' => 'forty', - 'gage' => 'guage', + 'gage' => 'gauge', 'geneology' => 'genealogy', 'grammer' => 'grammar', 'gray' => 'grey', @@ -98,7 +98,7 @@ $synonyms = array( 'irrevelant' => 'irrelevant', 'jeweler' => 'jeweller', - 'judgement' => 'judgment', + 'judgment' => 'judgement', 'labeled' => 'labelled', 'labor' => 'labour', diff --git a/phpBB/language/en/viewforum.php b/phpBB/language/en/viewforum.php index 546f91587d..d2fae20c62 100644 --- a/phpBB/language/en/viewforum.php +++ b/phpBB/language/en/viewforum.php @@ -48,16 +48,21 @@ $lang = array_merge($lang, array( 'MARK_TOPICS_READ' => 'Mark topics read', - 'NEW_POSTS_HOT' => 'New posts [ Popular ]', - 'NEW_POSTS_LOCKED' => 'New posts [ Locked ]', - 'NO_NEW_POSTS_HOT' => 'No new posts [ Popular ]', - 'NO_NEW_POSTS_LOCKED' => 'No new posts [ Locked ]', + 'NEW_POSTS_HOT' => 'New posts [ Popular ]', // Not used anymore + 'NEW_POSTS_LOCKED' => 'New posts [ Locked ]', // Not used anymore + 'NO_NEW_POSTS_HOT' => 'No new posts [ Popular ]', // Not used anymore + 'NO_NEW_POSTS_LOCKED' => 'No new posts [ Locked ]', // Not used anymore 'NO_READ_ACCESS' => 'You do not have the required permissions to read topics within this forum.', + 'NO_UNREAD_POSTS_HOT' => 'No unread posts [ Popular ]', + 'NO_UNREAD_POSTS_LOCKED' => 'No unread posts [ Locked ]', 'POST_FORUM_LOCKED' => 'Forum is locked', 'TOPICS_MARKED' => 'The topics for this forum have now been marked read.', + 'UNREAD_POSTS_HOT' => 'Unread posts [ Popular ]', + 'UNREAD_POSTS_LOCKED' => 'Unread posts [ Locked ]', + 'VIEW_FORUM' => 'View forum', 'VIEW_FORUM_TOPIC' => '1 topic', 'VIEW_FORUM_TOPICS' => '%d topics', diff --git a/phpBB/memberlist.php b/phpBB/memberlist.php index b46230b10a..2fa2d11ee1 100644 --- a/phpBB/memberlist.php +++ b/phpBB/memberlist.php @@ -1607,7 +1607,7 @@ function show_profile($data, $user_notes_enabled = false, $warn_user_enabled = f $rank_title = $rank_img = $rank_img_src = ''; get_user_rank($data['user_rank'], (($user_id == ANONYMOUS) ? false : $data['user_posts']), $rank_title, $rank_img, $rank_img_src); - if (!empty($data['user_allow_viewemail']) || $auth->acl_get('a_user')) + if ((!empty($data['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_user')) { $email = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=email&u=' . $user_id) : (($config['board_hide_emails'] && !$auth->acl_get('a_user')) ? '' : 'mailto:' . $data['user_email']); } diff --git a/phpBB/posting.php b/phpBB/posting.php index 6a95dce489..f775699cee 100644 --- a/phpBB/posting.php +++ b/phpBB/posting.php @@ -402,6 +402,19 @@ if ($post_data['poll_start']) $db->sql_freeresult($result); } +if ($mode == 'edit') +{ + $original_poll_data = array( + 'poll_title' => $post_data['poll_title'], + 'poll_length' => $post_data['poll_length'], + 'poll_max_options' => $post_data['poll_max_options'], + 'poll_option_text' => implode("\n", $post_data['poll_options']), + 'poll_start' => $post_data['poll_start'], + 'poll_last_vote' => $post_data['poll_last_vote'], + 'poll_vote_change' => $post_data['poll_vote_change'], + ); +} + $orig_poll_options_size = sizeof($post_data['poll_options']); $message_parser = new parse_message(); @@ -912,6 +925,22 @@ if ($submit || $preview || $refresh) $message_parser->warn_msg[] = $user->lang['NO_DELETE_POLL_OPTIONS']; }*/ } + else if (!$auth->acl_get('f_poll', $forum_id) && ($mode == 'edit') && ($post_id == $post_data['topic_first_post_id']) && ($original_poll_data['poll_title'] != '')) + { + // We have a poll but the editing user is not permitted to create/edit it. + // So we just keep the original poll-data. + $poll = array_merge($original_poll_data, array( + 'enable_bbcode' => $post_data['enable_bbcode'], + 'enable_urls' => $post_data['enable_urls'], + 'enable_smilies' => $post_data['enable_smilies'], + 'img_status' => $img_status, + )); + + $message_parser->parse_poll($poll); + + $post_data['poll_options'] = (isset($poll['poll_options'])) ? $poll['poll_options'] : ''; + $post_data['poll_title'] = (isset($poll['poll_title'])) ? $poll['poll_title'] : ''; + } else { $poll = array(); @@ -1152,7 +1181,7 @@ if (!sizeof($error) && $preview) $parse_sig->bbcode_bitfield = $preview_signature_bitfield; // Not sure about parameters for bbcode/smilies/urls... in signatures - $parse_sig->format_display($config['allow_sig_bbcode'], true, $config['allow_sig_smilies']); + $parse_sig->format_display($config['allow_sig_bbcode'], $config['allow_sig_links'], $config['allow_sig_smilies']); $preview_signature = $parse_sig->message; unset($parse_sig); } @@ -1258,7 +1287,7 @@ if ($mode == 'quote' && !$submit && !$preview && !$refresh) $message = $quote_string . $message; $message = str_replace("\n", "\n" . $quote_string, $message); - $message_parser->message = $post_data['quote_username'] . " " . $user->lang['WROTE'] . " :\n" . $message . "\n"; + $message_parser->message = $post_data['quote_username'] . " " . $user->lang['WROTE'] . ":\n" . $message . "\n"; } } @@ -1271,7 +1300,7 @@ $attachment_data = $message_parser->attachment_data; $filename_data = $message_parser->filename_data; $post_data['post_text'] = $message_parser->message; -if (sizeof($post_data['poll_options']) && $post_data['poll_title']) +if (sizeof($post_data['poll_options']) || !empty($post_data['poll_title'])) { $message_parser->message = $post_data['poll_title']; $message_parser->bbcode_uid = $post_data['bbcode_uid']; @@ -1420,7 +1449,7 @@ $template->assign_vars(array( 'S_DISPLAY_USERNAME' => (!$user->data['is_registered'] || ($mode == 'edit' && $post_data['poster_id'] == ANONYMOUS)) ? true : false, 'S_SHOW_TOPIC_ICONS' => $s_topic_icons, 'S_DELETE_ALLOWED' => ($mode == 'edit' && (($post_id == $post_data['topic_last_post_id'] && $post_data['poster_id'] == $user->data['user_id'] && $auth->acl_get('f_delete', $forum_id) && !$post_data['post_edit_locked'] && ($post_data['post_time'] > time() - ($config['delete_time'] * 60) || !$config['delete_time'])) || $auth->acl_get('m_delete', $forum_id))) ? true : false, - 'S_BBCODE_ALLOWED' => $bbcode_status, + 'S_BBCODE_ALLOWED' => ($bbcode_status) ? 1 : 0, 'S_BBCODE_CHECKED' => ($bbcode_checked) ? ' checked="checked"' : '', 'S_SMILIES_ALLOWED' => $smilies_status, 'S_SMILIES_CHECKED' => ($smilies_checked) ? ' checked="checked"' : '', diff --git a/phpBB/search.php b/phpBB/search.php index ab2221a96e..2a13e20477 100644 --- a/phpBB/search.php +++ b/phpBB/search.php @@ -61,10 +61,18 @@ if ($search_id == 'egosearch') } } -// Search for unread posts needs user to be logged in if topics tracking for guests is disabled -if ($search_id == 'unreadposts' && !$config['load_anon_lastread'] && !$user->data['is_registered']) +// Search for unread posts needs to be allowed and user to be logged in if topics tracking for guests is disabled +if ($search_id == 'unreadposts') { - login_box('', $user->lang['LOGIN_EXPLAIN_UNREADSEARCH']); + if (!$config['load_unreads_search']) + { + $template->assign_var('S_NO_SEARCH', true); + trigger_error('NO_SEARCH_UNREADS'); + } + else if (!$config['load_anon_lastread'] && !$user->data['is_registered']) + { + login_box('', $user->lang['LOGIN_EXPLAIN_UNREADSEARCH']); + } } // Is user able to search? Has search been disabled? @@ -81,9 +89,10 @@ if ($user->load && $config['limit_search_load'] && ($user->load > doubleval($con trigger_error('NO_SEARCH_TIME'); } -// Check flood limit ... if applicable +// It is applicable if the configuration setting is non-zero, and the user cannot +// ignore the flood setting, and the search is a keyword search. $interval = ($user->data['user_id'] == ANONYMOUS) ? $config['search_anonymous_interval'] : $config['search_interval']; -if ($interval && !$auth->acl_get('u_ignoreflood')) +if ($interval && !in_array($search_id, array('unreadposts', 'unanswered', 'active_topics', 'egosearch')) && !$auth->acl_get('u_ignoreflood')) { if ($user->data['user_last_search'] > time() - $interval) { @@ -387,18 +396,6 @@ if ($keywords || $author || $author_id || $search_id || $submit) gen_sort_selects($limit_days, $sort_by_text, $sort_days, $sort_key, $sort_dir, $s_limit_days, $s_sort_key, $s_sort_dir, $u_sort_param); $s_sort_key = $s_sort_dir = $u_sort_param = $s_limit_days = ''; - - $unread_list = array(); - $unread_list = get_unread_topics($user->data['user_id'], $sql_where, $sql_sort); - - if (!empty($unread_list)) - { - $sql = 'SELECT t.topic_id - FROM ' . TOPICS_TABLE . ' t - WHERE ' . $db->sql_in_set('t.topic_id', array_keys($unread_list)) . " - $sql_sort"; - $field = 'topic_id'; - } break; case 'newposts': @@ -476,6 +473,13 @@ if ($keywords || $author || $author_id || $search_id || $submit) $total_match_count = sizeof($id_ary) + $start; $id_ary = array_slice($id_ary, 0, $per_page); } + else if ($search_id == 'unreadposts') + { + $id_ary = array_keys(get_unread_topics($user->data['user_id'], $sql_where, $sql_sort, 1001 - $start, $start)); + + $total_match_count = sizeof($id_ary) + $start; + $id_ary = array_slice($id_ary, 0, $per_page); + } else { $search_id = ''; @@ -896,7 +900,7 @@ if ($keywords || $author || $author_id || $search_id || $submit) 'S_TOPIC_GLOBAL' => (!$forum_id) ? true : false, 'S_TOPIC_TYPE' => $row['topic_type'], - 'S_USER_POSTED' => (!empty($row['mark_type'])) ? true : false, + 'S_USER_POSTED' => (!empty($row['topic_posted'])) ? true : false, 'S_UNREAD_TOPIC' => $unread_topic, 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $forum_id)) ? true : false, @@ -1155,6 +1159,7 @@ if ($auth->acl_get('a_search')) case 'mssql': case 'mssql_odbc': + case 'mssqlnative': $sql = 'SELECT search_time, search_keywords FROM ' . SEARCH_RESULTS_TABLE . ' WHERE DATALENGTH(search_keywords) > 0 diff --git a/phpBB/style.php b/phpBB/style.php index fa77815670..8ca1751391 100644 --- a/phpBB/style.php +++ b/phpBB/style.php @@ -45,15 +45,8 @@ if (!empty($load_extensions) && function_exists('dl')) } } - -$sid = (isset($_GET['sid']) && !is_array($_GET['sid'])) ? htmlspecialchars($_GET['sid']) : ''; $id = (isset($_GET['id'])) ? intval($_GET['id']) : 0; -if (strspn($sid, 'abcdefABCDEF0123456789') !== strlen($sid)) -{ - $sid = ''; -} - // This is a simple script to grab and output the requested CSS data stored in the DB // We include a session_id check to try and limit 3rd party linking ... unless they // happen to have a current session it will output nothing. We will also cache the @@ -81,6 +74,20 @@ if ($id) $config = $cache->obtain_config(); $user = false; + // try to get a session ID from REQUEST array + $sid = request_var('sid', ''); + + if (!$sid) + { + // if that failed, then look in the cookies + $sid = request_var($config['cookie_name'] . '_sid', '', false, true); + } + + if (strspn($sid, 'abcdefABCDEF0123456789') !== strlen($sid)) + { + $sid = ''; + } + if ($sid) { $sql = 'SELECT u.user_id, u.user_lang diff --git a/phpBB/styles/prosilver/imageset/imageset.cfg b/phpBB/styles/prosilver/imageset/imageset.cfg index 7fc8274ad2..bbafe5e26d 100644 --- a/phpBB/styles/prosilver/imageset/imageset.cfg +++ b/phpBB/styles/prosilver/imageset/imageset.cfg @@ -19,7 +19,7 @@ # General Information about this style name = prosilver copyright = © phpBB Group, 2007 -version = 3.0.7 +version = 3.0.8 # Images img_site_logo = site_logo.gif*52*139 diff --git a/phpBB/styles/prosilver/style.cfg b/phpBB/styles/prosilver/style.cfg index 8b660c969e..7f7e677993 100644 --- a/phpBB/styles/prosilver/style.cfg +++ b/phpBB/styles/prosilver/style.cfg @@ -19,4 +19,4 @@ # General Information about this style name = prosilver copyright = © phpBB Group, 2007 -version = 3.0.7 \ No newline at end of file +version = 3.0.8 \ No newline at end of file diff --git a/phpBB/styles/prosilver/template/captcha_recaptcha.html b/phpBB/styles/prosilver/template/captcha_recaptcha.html index 97d2cda28e..51a1615bd5 100644 --- a/phpBB/styles/prosilver/template/captcha_recaptcha.html +++ b/phpBB/styles/prosilver/template/captcha_recaptcha.html @@ -16,6 +16,7 @@ // {$CAPTCHA_TAB_INDEX}10 }; // ]]> diff --git a/phpBB/styles/prosilver/template/editor.js b/phpBB/styles/prosilver/template/editor.js index 98dab5d7c8..ddc862bb8c 100644 --- a/phpBB/styles/prosilver/template/editor.js +++ b/phpBB/styles/prosilver/template/editor.js @@ -157,7 +157,7 @@ function insert_text(text, spaces, popup) var sel_start = textarea.selectionStart; var sel_end = textarea.selectionEnd; - mozWrap(textarea, text, '') + mozWrap(textarea, text, ''); textarea.selectionStart = sel_start + text.length; textarea.selectionEnd = sel_end + text.length; } @@ -194,12 +194,18 @@ function attach_inline(index, filename) /** * Add quote text to message */ -function addquote(post_id, username) +function addquote(post_id, username, l_wrote) { var message_name = 'message_' + post_id; var theSelection = ''; var divarea = false; + if (l_wrote === undefined) + { + // Backwards compatibility + l_wrote = 'wrote'; + } + if (document.all) { divarea = document.all[message_name]; @@ -256,10 +262,11 @@ function addquote(post_id, username) } else { + insert_text(username + ' ' + l_wrote + ':' + '\n'); var lines = split_lines(theSelection); for (i = 0; i < lines.length; i++) { - insert_text('> ' + lines[i] + '\n') + insert_text('> ' + lines[i] + '\n'); } } } @@ -289,7 +296,7 @@ function split_lines(text) if (splitAt == -1) { splitLines[j] = line; - j++ + j++; } else { @@ -298,7 +305,7 @@ function split_lines(text) j++; } } - while(splitAt != -1) + while(splitAt != -1); } } return splitLines; @@ -319,7 +326,7 @@ function mozWrap(txtarea, open, close) } var s1 = (txtarea.value).substring(0,selStart); - var s2 = (txtarea.value).substring(selStart, selEnd) + var s2 = (txtarea.value).substring(selStart, selEnd); var s3 = (txtarea.value).substring(selEnd, selLength); txtarea.value = s1 + open + s2 + close + s3; diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 6fb3778952..4a85858df5 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -98,16 +98,21 @@ function viewableArea(e, itself) /** * Set display of page element * s[-1,0,1] = hide,toggle display,show +* type = string: inline, block, inline-block or other CSS "display" type */ -function dE(n, s) +function dE(n, s, type) { - var e = document.getElementById(n); + if (!type) + { + type = 'block'; + } + var e = document.getElementById(n); if (!s) { - s = (e.style.display == '' || e.style.display == 'block') ? -1 : 1; + s = (e.style.display == '' || e.style.display == type) ? -1 : 1; } - e.style.display = (s == 1) ? 'block' : 'none'; + e.style.display = (s == 1) ? type : 'none'; } /** diff --git a/phpBB/styles/prosilver/template/index_body.html b/phpBB/styles/prosilver/template/index_body.html index 17790eb78a..d4d50a11c0 100644 --- a/phpBB/styles/prosilver/template/index_body.html +++ b/phpBB/styles/prosilver/template/index_body.html @@ -6,7 +6,7 @@ diff --git a/phpBB/styles/prosilver/template/login_body.html b/phpBB/styles/prosilver/template/login_body.html index fe111aaa45..26e425a1d0 100644 --- a/phpBB/styles/prosilver/template/login_body.html +++ b/phpBB/styles/prosilver/template/login_body.html @@ -1,5 +1,11 @@ + +
    @@ -32,11 +38,11 @@ + {S_LOGIN_REDIRECT}
     
    {S_HIDDEN_FIELDS}
    - {S_LOGIN_REDIRECT}
    diff --git a/phpBB/styles/prosilver/template/mcp_post.html b/phpBB/styles/prosilver/template/mcp_post.html index 0265d7ce12..04e24cd1f9 100644 --- a/phpBB/styles/prosilver/template/mcp_post.html +++ b/phpBB/styles/prosilver/template/mcp_post.html @@ -54,6 +54,8 @@ + {L_EXPAND_VIEW} +

    {POST_SUBJECT}

    @@ -84,7 +86,7 @@

    -
    +
    {POST_PREVIEW}
    diff --git a/phpBB/styles/prosilver/template/mcp_reports.html b/phpBB/styles/prosilver/template/mcp_reports.html index 649154deb4..eefb24ee91 100644 --- a/phpBB/styles/prosilver/template/mcp_reports.html +++ b/phpBB/styles/prosilver/template/mcp_reports.html @@ -54,7 +54,7 @@
    {postrow.REPORTER_FULL} « {postrow.REPORT_TIME}
    - {L_FORUM}: {postrow.FORUM_NAME}
    + {L_FORUM}: {postrow.FORUM_NAME}{postrow.FORUM_NAME}
    diff --git a/phpBB/styles/prosilver/template/overall_header.html b/phpBB/styles/prosilver/template/overall_header.html index 8f4ac19fb8..44857dbc41 100644 --- a/phpBB/styles/prosilver/template/overall_header.html +++ b/phpBB/styles/prosilver/template/overall_header.html @@ -11,7 +11,7 @@ - + {META} {SITENAME} • <!-- IF S_IN_MCP -->{L_MCP} • <!-- ELSEIF S_IN_UCP -->{L_UCP} • <!-- ENDIF -->{PAGE_TITLE} diff --git a/phpBB/styles/prosilver/template/posting_buttons.html b/phpBB/styles/prosilver/template/posting_buttons.html index 4d866681f0..5d21229611 100644 --- a/phpBB/styles/prosilver/template/posting_buttons.html +++ b/phpBB/styles/prosilver/template/posting_buttons.html @@ -79,7 +79,7 @@ - + diff --git a/phpBB/styles/prosilver/template/posting_editor.html b/phpBB/styles/prosilver/template/posting_editor.html index 9476242d11..5f7fb8408e 100644 --- a/phpBB/styles/prosilver/template/posting_editor.html +++ b/phpBB/styles/prosilver/template/posting_editor.html @@ -187,8 +187,8 @@
    {S_HIDDEN_ADDRESS_FIELD} {S_HIDDEN_FIELDS} -   -   +   +   onclick="document.getElementById('postform').action += '#preview';" />    diff --git a/phpBB/styles/prosilver/template/posting_topic_review.html b/phpBB/styles/prosilver/template/posting_topic_review.html index 0d68a02758..a05f057e21 100644 --- a/phpBB/styles/prosilver/template/posting_topic_review.html +++ b/phpBB/styles/prosilver/template/posting_topic_review.html @@ -24,7 +24,7 @@
    diff --git a/phpBB/styles/prosilver/template/quickreply_editor.html b/phpBB/styles/prosilver/template/quickreply_editor.html index 8a5b8aeb16..ea07c2e6d8 100644 --- a/phpBB/styles/prosilver/template/quickreply_editor.html +++ b/phpBB/styles/prosilver/template/quickreply_editor.html @@ -61,7 +61,7 @@ {S_FORM_TOKEN} {QR_HIDDEN_FIELDS}   -   +  
    {L_COLLAPSE_QR}
    diff --git a/phpBB/styles/prosilver/template/search_body.html b/phpBB/styles/prosilver/template/search_body.html index 612641b141..6616b95a73 100644 --- a/phpBB/styles/prosilver/template/search_body.html +++ b/phpBB/styles/prosilver/template/search_body.html @@ -1,5 +1,11 @@ + +

    {L_SEARCH}

    @@ -119,4 +125,4 @@ - \ No newline at end of file + diff --git a/phpBB/styles/prosilver/template/template.cfg b/phpBB/styles/prosilver/template/template.cfg index 03b61e1003..0dd4150266 100644 --- a/phpBB/styles/prosilver/template/template.cfg +++ b/phpBB/styles/prosilver/template/template.cfg @@ -19,7 +19,7 @@ # General Information about this template name = prosilver copyright = © phpBB Group, 2007 -version = 3.0.7 +version = 3.0.8 # Defining a different template bitfield template_bitfield = lNg= diff --git a/phpBB/styles/prosilver/template/ucp_pm_history.html b/phpBB/styles/prosilver/template/ucp_pm_history.html index 88efcf95be..9051eb2ee0 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_history.html +++ b/phpBB/styles/prosilver/template/ucp_pm_history.html @@ -1,10 +1,15 @@

    {L_EXPAND_VIEW} - {L_MESSAGE_HISTORY}: {HISTORY_TITLE} + {L_MESSAGE_HISTORY}:

    +
    @@ -12,7 +17,7 @@
    diff --git a/phpBB/styles/prosilver/template/ucp_pm_viewfolder.html b/phpBB/styles/prosilver/template/ucp_pm_viewfolder.html index 7b309a74f7..d7e02e405e 100644 --- a/phpBB/styles/prosilver/template/ucp_pm_viewfolder.html +++ b/phpBB/styles/prosilver/template/ucp_pm_viewfolder.html @@ -71,7 +71,7 @@
    {L_PM_FROM_REMOVED_AUTHOR} - {REPORTED_IMG} {messagerow.ATTACH_ICON_IMG}
    + {REPORTED_IMG} {messagerow.ATTACH_ICON_IMG}
    {L_MESSAGE_TO} {messagerow.RECIPIENTS}{L_MESSAGE_BY_AUTHOR} {messagerow.MESSAGE_AUTHOR_FULL} » {messagerow.SENT_TIME}
    {L_SENT_AT}: {messagerow.SENT_TIME}
    diff --git a/phpBB/styles/prosilver/template/ucp_profile_signature.html b/phpBB/styles/prosilver/template/ucp_profile_signature.html index 5d25d2d9f4..ab23b84076 100644 --- a/phpBB/styles/prosilver/template/ucp_profile_signature.html +++ b/phpBB/styles/prosilver/template/ucp_profile_signature.html @@ -4,7 +4,7 @@

    {L_TITLE}

    - +

    {L_SIGNATURE_PREVIEW}

    diff --git a/phpBB/styles/prosilver/template/viewforum_body.html b/phpBB/styles/prosilver/template/viewforum_body.html index cc38ed9d2b..12073a39d2 100644 --- a/phpBB/styles/prosilver/template/viewforum_body.html +++ b/phpBB/styles/prosilver/template/viewforum_body.html @@ -39,7 +39,7 @@ @@ -122,12 +122,12 @@ -
    +
    • -
      {L_ACTIVE_TOPICS}{L_ANNOUNCEMENTS}{L_TOPICS}
      +
      {L_ACTIVE_TOPICS}{L_ANNOUNCEMENTS}{L_TOPICS}
      {L_REPLIES}
      {L_VIEWS}
      {L_LAST_POST}
      @@ -137,7 +137,7 @@
        -
      • +
      • style="background-image: url({T_ICONS_PATH}{topicrow.TOPIC_ICON_IMG}); background-repeat: no-repeat;" title="{topicrow.TOPIC_FOLDER_IMG_ALT}">{NEWEST_POST_IMG} {topicrow.TOPIC_TITLE} {topicrow.UNAPPROVED_IMG} diff --git a/phpBB/styles/prosilver/theme/bidi.css b/phpBB/styles/prosilver/theme/bidi.css index 109312ac1b..f441784d85 100644 --- a/phpBB/styles/prosilver/theme/bidi.css +++ b/phpBB/styles/prosilver/theme/bidi.css @@ -236,6 +236,7 @@ } .rtl a.top2 { + background-position: 100% 50%; padding-left: 0; padding-right: 15px; } diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css index 417537e660..64beb97a37 100644 --- a/phpBB/styles/prosilver/theme/content.css +++ b/phpBB/styles/prosilver/theme/content.css @@ -298,6 +298,20 @@ div[class].topic-actions { display: none; } +/* MCP Post details +----------------------------------------*/ +#post_details +{ + /* This will only work in IE7+, plus the others */ + overflow: auto; + max-height: 300px; +} + +#expand +{ + clear: both; +} + /* Content container styles ----------------------------------------*/ .content { diff --git a/phpBB/styles/prosilver/theme/forms.css b/phpBB/styles/prosilver/theme/forms.css index 4db342661c..4e48a93a55 100644 --- a/phpBB/styles/prosilver/theme/forms.css +++ b/phpBB/styles/prosilver/theme/forms.css @@ -96,6 +96,11 @@ fieldset.fields1 div { margin-bottom: 3px; } +/* Set it back to 0px for the reCaptcha divs: PHPBB3-9587 */ +fieldset.fields1 #recaptcha_widget_div div { + margin-bottom: 0; +} + /* Specific layout 2 */ fieldset.fields2 dt { width: 15em; diff --git a/phpBB/styles/prosilver/theme/print.css b/phpBB/styles/prosilver/theme/print.css index 6dfb5c4726..68600b030b 100644 --- a/phpBB/styles/prosilver/theme/print.css +++ b/phpBB/styles/prosilver/theme/print.css @@ -140,3 +140,5 @@ div.spacer { clear: both; } /* Accessibility tweaks: Mozilla.org */ .skip_link { display: none; } + +dl.codebox dt { display: none; } \ No newline at end of file diff --git a/phpBB/styles/prosilver/theme/theme.cfg b/phpBB/styles/prosilver/theme/theme.cfg index 8b7916a144..83f3120829 100644 --- a/phpBB/styles/prosilver/theme/theme.cfg +++ b/phpBB/styles/prosilver/theme/theme.cfg @@ -21,7 +21,7 @@ # General Information about this theme name = prosilver copyright = © phpBB Group, 2007 -version = 3.0.7 +version = 3.0.8 # Some configuration options diff --git a/phpBB/styles/subsilver2/imageset/imageset.cfg b/phpBB/styles/subsilver2/imageset/imageset.cfg index 7709070734..ce0c859193 100644 --- a/phpBB/styles/subsilver2/imageset/imageset.cfg +++ b/phpBB/styles/subsilver2/imageset/imageset.cfg @@ -19,7 +19,7 @@ # General Information about this style name = subsilver2 copyright = © phpBB Group, 2003 -version = 3.0.7 +version = 3.0.8 # Images img_site_logo = site_logo.gif*94*170 diff --git a/phpBB/styles/subsilver2/style.cfg b/phpBB/styles/subsilver2/style.cfg index 86b5b8a4e8..b8ddd6deec 100644 --- a/phpBB/styles/subsilver2/style.cfg +++ b/phpBB/styles/subsilver2/style.cfg @@ -19,4 +19,4 @@ # General Information about this style name = subsilver2 copyright = © 2005 phpBB Group -version = 3.0.7 +version = 3.0.8 diff --git a/phpBB/styles/subsilver2/template/attachment.html b/phpBB/styles/subsilver2/template/attachment.html index d54994fe67..833bd4d55f 100644 --- a/phpBB/styles/subsilver2/template/attachment.html +++ b/phpBB/styles/subsilver2/template/attachment.html @@ -58,13 +58,13 @@ - + - + diff --git a/phpBB/styles/subsilver2/template/captcha_default.html b/phpBB/styles/subsilver2/template/captcha_default.html index e0116ae42c..4c65f81643 100644 --- a/phpBB/styles/subsilver2/template/captcha_default.html +++ b/phpBB/styles/subsilver2/template/captcha_default.html @@ -1,9 +1,11 @@ {L_CONFIRM_CODE} + {L_CONFIRM_EXPLAIN} + {L_CONFIRM_CODE} diff --git a/phpBB/styles/subsilver2/template/captcha_recaptcha.html b/phpBB/styles/subsilver2/template/captcha_recaptcha.html index 3776c77ea4..ec09b28ef5 100644 --- a/phpBB/styles/subsilver2/template/captcha_recaptcha.html +++ b/phpBB/styles/subsilver2/template/captcha_recaptcha.html @@ -9,6 +9,7 @@ // {$CAPTCHA_TAB_INDEX}10 }; // ]]> diff --git a/phpBB/styles/subsilver2/template/editor.js b/phpBB/styles/subsilver2/template/editor.js index 0c48c93ad3..cd22812bab 100644 --- a/phpBB/styles/subsilver2/template/editor.js +++ b/phpBB/styles/subsilver2/template/editor.js @@ -6,6 +6,7 @@ // Startup variables var imageTag = false; var theSelection = false; +var bbcodeEnabled = true; // Check for Browser & Platform for PC & IE specific bits // More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html @@ -156,7 +157,7 @@ function insert_text(text, spaces, popup) var sel_start = textarea.selectionStart; var sel_end = textarea.selectionEnd; - mozWrap(textarea, text, '') + mozWrap(textarea, text, ''); textarea.selectionStart = sel_start + text.length; textarea.selectionEnd = sel_end + text.length; } @@ -195,12 +196,18 @@ function attach_inline(index, filename) /** * Add quote text to message */ -function addquote(post_id, username) +function addquote(post_id, username, l_wrote) { var message_name = 'message_' + post_id; var theSelection = ''; var divarea = false; + if (l_wrote === undefined) + { + // Backwards compatibility + l_wrote = 'wrote'; + } + if (document.all) { divarea = document.all[message_name]; @@ -233,6 +240,7 @@ function addquote(post_id, username) theSelection = theSelection.replace(/<\;/ig, '<'); theSelection = theSelection.replace(/>\;/ig, '>'); theSelection = theSelection.replace(/&\;/ig, '&'); + theSelection = theSelection.replace(/ \;/ig, ' '); } else if (document.all) { @@ -250,12 +258,62 @@ function addquote(post_id, username) if (theSelection) { - insert_text('[quote="' + username + '"]' + theSelection + '[/quote]'); + if (bbcodeEnabled) + { + insert_text('[quote="' + username + '"]' + theSelection + '[/quote]'); + } + else + { + insert_text(username + ' ' + l_wrote + ':' + '\n'); + var lines = split_lines(theSelection); + for (i = 0; i < lines.length; i++) + { + insert_text('> ' + lines[i] + '\n'); + } + } } return; } + +function split_lines(text) +{ + var lines = text.split('\n'); + var splitLines = new Array(); + var j = 0; + for(i = 0; i < lines.length; i++) + { + if (lines[i].length <= 80) + { + splitLines[j] = lines[i]; + j++; + } + else + { + var line = lines[i]; + do + { + var splitAt = line.indexOf(' ', 80); + + if (splitAt == -1) + { + splitLines[j] = line; + j++; + } + else + { + splitLines[j] = line.substring(0, splitAt); + line = line.substring(splitAt); + j++; + } + } + while(splitAt != -1); + } + } + return splitLines; +} + /** * From http://www.massless.org/mozedit/ */ @@ -272,7 +330,7 @@ function mozWrap(txtarea, open, close) } var s1 = (txtarea.value).substring(0,selStart); - var s2 = (txtarea.value).substring(selStart, selEnd) + var s2 = (txtarea.value).substring(selStart, selEnd); var s3 = (txtarea.value).substring(selEnd, selLength); txtarea.value = s1 + open + s2 + close + s3; @@ -330,8 +388,8 @@ function colorPalette(dir, width, height) for (b = 0; b < 5; b++) { color = String(numberList[r]) + String(numberList[g]) + String(numberList[b]); - document.write(''); - document.write('#' + color + ''); + document.write(''); + document.write('#' + color + ''); document.writeln(''); } diff --git a/phpBB/styles/subsilver2/template/index_body.html b/phpBB/styles/subsilver2/template/index_body.html index 863e4f7bee..8faf76e9ee 100644 --- a/phpBB/styles/subsilver2/template/index_body.html +++ b/phpBB/styles/subsilver2/template/index_body.html @@ -89,11 +89,11 @@ - - + + - + diff --git a/phpBB/styles/subsilver2/template/login_body.html b/phpBB/styles/subsilver2/template/login_body.html index 51f7068b5f..90bbf8c139 100644 --- a/phpBB/styles/subsilver2/template/login_body.html +++ b/phpBB/styles/subsilver2/template/login_body.html @@ -72,12 +72,12 @@ +{S_LOGIN_REDIRECT}
        {FORUM_NEW_IMG}{L_NEW_POSTS}{FORUM_UNREAD_IMG}{L_UNREAD_POSTS}    {FORUM_IMG}{L_NO_NEW_POSTS}{L_NO_UNREAD_POSTS}    {FORUM_LOCKED_IMG} {L_FORUM_LOCKED}
        colspan="2" align="center">{S_HIDDEN_FIELDS}
        {S_FORM_TOKEN} -{S_LOGIN_REDIRECT}
        @@ -88,4 +88,21 @@
        - \ No newline at end of file + + + diff --git a/phpBB/styles/subsilver2/template/overall_header.html b/phpBB/styles/subsilver2/template/overall_header.html index 963f5160dd..874beb8e2b 100644 --- a/phpBB/styles/subsilver2/template/overall_header.html +++ b/phpBB/styles/subsilver2/template/overall_header.html @@ -11,7 +11,7 @@ - + {META} {SITENAME} • <!-- IF S_IN_MCP -->{L_MCP} • <!-- ELSEIF S_IN_UCP -->{L_UCP} • <!-- ENDIF -->{PAGE_TITLE} @@ -201,8 +201,8 @@ function marklist(id, name, state) diff --git a/phpBB/styles/subsilver2/template/posting_body.html b/phpBB/styles/subsilver2/template/posting_body.html index 963e6fe966..0021cd2eb3 100644 --- a/phpBB/styles/subsilver2/template/posting_body.html +++ b/phpBB/styles/subsilver2/template/posting_body.html @@ -342,8 +342,8 @@   -   -   +   +     @@ -365,8 +365,8 @@   -   -   +   +     diff --git a/phpBB/styles/subsilver2/template/posting_buttons.html b/phpBB/styles/subsilver2/template/posting_buttons.html index 0aab79b7aa..621fa87fd4 100644 --- a/phpBB/styles/subsilver2/template/posting_buttons.html +++ b/phpBB/styles/subsilver2/template/posting_buttons.html @@ -19,6 +19,7 @@ o: '{LA_BBCODE_O_HELP}', p: '{LA_BBCODE_P_HELP}', w: '{LA_BBCODE_W_HELP}', + a: '{LA_BBCODE_A_HELP}', s: '{LA_BBCODE_S_HELP}', f: '{LA_BBCODE_F_HELP}', e: '{LA_BBCODE_E_HELP}', @@ -44,7 +45,7 @@ - + diff --git a/phpBB/styles/subsilver2/template/posting_topic_review.html b/phpBB/styles/subsilver2/template/posting_topic_review.html index d1af72b522..54bbf6e553 100644 --- a/phpBB/styles/subsilver2/template/posting_topic_review.html +++ b/phpBB/styles/subsilver2/template/posting_topic_review.html @@ -1,3 +1,8 @@ + @@ -31,7 +36,7 @@ - +
          {L_POST_SUBJECT}:  {topic_review_row.POST_SUBJECT} {QUOTE_IMG} {QUOTE_IMG}
        diff --git a/phpBB/styles/subsilver2/template/search_body.html b/phpBB/styles/subsilver2/template/search_body.html index a0ec30e9ba..763a229c83 100644 --- a/phpBB/styles/subsilver2/template/search_body.html +++ b/phpBB/styles/subsilver2/template/search_body.html @@ -75,4 +75,21 @@
        - \ No newline at end of file + + + diff --git a/phpBB/styles/subsilver2/template/template.cfg b/phpBB/styles/subsilver2/template/template.cfg index b6765268bc..edfc2d43f2 100644 --- a/phpBB/styles/subsilver2/template/template.cfg +++ b/phpBB/styles/subsilver2/template/template.cfg @@ -19,5 +19,5 @@ # General Information about this template name = subsilver2 copyright = © phpBB Group, 2003 -version = 3.0.7 +version = 3.0.8 diff --git a/phpBB/styles/subsilver2/template/ucp_pm_history.html b/phpBB/styles/subsilver2/template/ucp_pm_history.html index cb87d1892a..8754acaaa2 100644 --- a/phpBB/styles/subsilver2/template/ucp_pm_history.html +++ b/phpBB/styles/subsilver2/template/ucp_pm_history.html @@ -1,7 +1,12 @@ + - + - + diff --git a/phpBB/styles/subsilver2/template/ucp_pm_message_footer.html b/phpBB/styles/subsilver2/template/ucp_pm_message_footer.html index 314d03caf3..d1ef5ebd10 100644 --- a/phpBB/styles/subsilver2/template/ucp_pm_message_footer.html +++ b/phpBB/styles/subsilver2/template/ucp_pm_message_footer.html @@ -14,6 +14,7 @@ {L_PRINT_PM} | {L_FORWARD_PM} + | {L_REPLY_TO_ALL} diff --git a/phpBB/styles/subsilver2/template/ucp_pm_viewfolder.html b/phpBB/styles/subsilver2/template/ucp_pm_viewfolder.html index 1663502865..f0b076edb2 100644 --- a/phpBB/styles/subsilver2/template/ucp_pm_viewfolder.html +++ b/phpBB/styles/subsilver2/template/ucp_pm_viewfolder.html @@ -81,6 +81,9 @@ {messagerow.SUBJECT} + + {REPORTED_IMG}  +
        {L_PM_FROM_REMOVED_AUTHOR} diff --git a/phpBB/styles/subsilver2/template/ucp_profile_signature.html b/phpBB/styles/subsilver2/template/ucp_profile_signature.html index 2b396ea0df..a33726e166 100644 --- a/phpBB/styles/subsilver2/template/ucp_profile_signature.html +++ b/phpBB/styles/subsilver2/template/ucp_profile_signature.html @@ -93,7 +93,7 @@ - + diff --git a/phpBB/styles/subsilver2/template/viewforum_body.html b/phpBB/styles/subsilver2/template/viewforum_body.html index 387a749e24..6511fa5349 100644 --- a/phpBB/styles/subsilver2/template/viewforum_body.html +++ b/phpBB/styles/subsilver2/template/viewforum_body.html @@ -281,31 +281,31 @@
        {L_MESSAGE_HISTORY} - {HISTORY_TITLE}{L_MESSAGE_HISTORY}
        @@ -54,7 +59,7 @@
        {L_VIEW_PM}
        {L_SIGNATURE_PREVIEW}
        - - + + - + - - + + - + - - + + - + diff --git a/phpBB/styles/subsilver2/template/viewtopic_body.html b/phpBB/styles/subsilver2/template/viewtopic_body.html index 8f01c64c0e..bba00ce685 100644 --- a/phpBB/styles/subsilver2/template/viewtopic_body.html +++ b/phpBB/styles/subsilver2/template/viewtopic_body.html @@ -238,7 +238,7 @@

        {L_DOWNLOAD_NOTICE}
        -
        _________________
        {postrow.SIGNATURE}
        +

        _________________
        {postrow.SIGNATURE}
        diff --git a/phpBB/styles/subsilver2/theme/theme.cfg b/phpBB/styles/subsilver2/theme/theme.cfg index 7f6bfd9a12..a6ac5f337c 100644 --- a/phpBB/styles/subsilver2/theme/theme.cfg +++ b/phpBB/styles/subsilver2/theme/theme.cfg @@ -21,7 +21,7 @@ # General Information about this theme name = subsilver2 copyright = © phpBB Group, 2003 -version = 3.0.7 +version = 3.0.8 # Some configuration options diff --git a/phpBB/ucp.php b/phpBB/ucp.php index 994fe064a1..f5a2ec9648 100644 --- a/phpBB/ucp.php +++ b/phpBB/ucp.php @@ -22,7 +22,7 @@ require($phpbb_root_path . 'includes/functions_module.' . $phpEx); $id = request_var('i', ''); $mode = request_var('mode', ''); -if ($mode == 'login' || $mode == 'logout' || $mode == 'confirm') +if (in_array($mode, array('login', 'logout', 'confirm', 'sendpassword', 'activate'))) { define('IN_LOGIN', true); } diff --git a/phpBB/viewforum.php b/phpBB/viewforum.php index 95c142d865..9cfa93f880 100644 --- a/phpBB/viewforum.php +++ b/phpBB/viewforum.php @@ -151,7 +151,7 @@ $template->set_filenames(array( make_jumpbox(append_sid("{$phpbb_root_path}viewforum.$phpEx"), $forum_id); $template->assign_vars(array( - 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id&start=$start"), + 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . (($start == 0) ? '' : "&start=$start")), )); // Not postable forum or showing active topics? @@ -273,16 +273,16 @@ $template->assign_vars(array( 'POST_IMG' => ($forum_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', $post_alt) : $user->img('button_topic_new', $post_alt), 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'), 'LAST_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'), - 'FOLDER_IMG' => $user->img('topic_read', 'NO_NEW_POSTS'), - 'FOLDER_NEW_IMG' => $user->img('topic_unread', 'NEW_POSTS'), - 'FOLDER_HOT_IMG' => $user->img('topic_read_hot', 'NO_NEW_POSTS_HOT'), - 'FOLDER_HOT_NEW_IMG' => $user->img('topic_unread_hot', 'NEW_POSTS_HOT'), - 'FOLDER_LOCKED_IMG' => $user->img('topic_read_locked', 'NO_NEW_POSTS_LOCKED'), - 'FOLDER_LOCKED_NEW_IMG' => $user->img('topic_unread_locked', 'NEW_POSTS_LOCKED'), + 'FOLDER_IMG' => $user->img('topic_read', 'NO_UNREAD_POSTS'), + 'FOLDER_UNREAD_IMG' => $user->img('topic_unread', 'UNREAD_POSTS'), + 'FOLDER_HOT_IMG' => $user->img('topic_read_hot', 'NO_UNREAD_POSTS_HOT'), + 'FOLDER_HOT_UNREAD_IMG' => $user->img('topic_unread_hot', 'UNREAD_POSTS_HOT'), + 'FOLDER_LOCKED_IMG' => $user->img('topic_read_locked', 'NO_UNREAD_POSTS_LOCKED'), + 'FOLDER_LOCKED_UNREAD_IMG' => $user->img('topic_unread_locked', 'UNREAD_POSTS_LOCKED'), 'FOLDER_STICKY_IMG' => $user->img('sticky_read', 'POST_STICKY'), - 'FOLDER_STICKY_NEW_IMG' => $user->img('sticky_unread', 'POST_STICKY'), + 'FOLDER_STICKY_UNREAD_IMG' => $user->img('sticky_unread', 'POST_STICKY'), 'FOLDER_ANNOUNCE_IMG' => $user->img('announce_read', 'POST_ANNOUNCEMENT'), - 'FOLDER_ANNOUNCE_NEW_IMG' => $user->img('announce_unread', 'POST_ANNOUNCEMENT'), + 'FOLDER_ANNOUNCE_UNREAD_IMG'=> $user->img('announce_unread', 'POST_ANNOUNCEMENT'), 'FOLDER_MOVED_IMG' => $user->img('topic_moved', 'TOPIC_MOVED'), 'REPORTED_IMG' => $user->img('icon_topic_reported', 'TOPIC_REPORTED'), 'UNAPPROVED_IMG' => $user->img('icon_topic_unapproved', 'TOPIC_UNAPPROVED'), @@ -302,7 +302,7 @@ $template->assign_vars(array( 'S_WATCH_FORUM_LINK' => $s_watching_forum['link'], 'S_WATCH_FORUM_TITLE' => $s_watching_forum['title'], 'S_WATCHING_FORUM' => $s_watching_forum['is_watching'], - 'S_FORUM_ACTION' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id&start=$start"), + 'S_FORUM_ACTION' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . (($start == 0) ? '' : "&start=$start")), 'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false, 'S_SEARCHBOX_ACTION' => append_sid("{$phpbb_root_path}search.$phpEx", 'fid[]=' . $forum_id), 'S_SINGLE_MODERATOR' => (!empty($moderators[$forum_id]) && sizeof($moderators[$forum_id]) > 1) ? false : true, @@ -311,7 +311,7 @@ $template->assign_vars(array( 'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&i=main&mode=forum_view", true, $user->session_id) : '', 'U_POST_NEW_TOPIC' => ($auth->acl_get('f_post', $forum_id) || $user->data['user_id'] == ANONYMOUS) ? append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=post&f=' . $forum_id) : '', - 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . "&start=$start"), + 'U_VIEW_FORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", "f=$forum_id" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($start == 0) ? '' : "&start=$start")), 'U_MARK_TOPICS' => ($user->data['is_registered'] || $config['load_anon_lastread']) ? append_sid("{$phpbb_root_path}viewforum.$phpEx", 'hash=' . generate_link_hash('global') . "&f=$forum_id&mark=topics") : '', )); @@ -508,6 +508,7 @@ if (sizeof($shadow_topic_list)) 'topic_moved_id' => $rowset[$orig_topic_id]['topic_moved_id'], 'topic_status' => $rowset[$orig_topic_id]['topic_status'], 'topic_type' => $rowset[$orig_topic_id]['topic_type'], + 'topic_title' => $rowset[$orig_topic_id]['topic_title'], )); // Shadow topics are never reported @@ -592,12 +593,14 @@ if (sizeof($topic_list)) { $row = &$rowset[$topic_id]; + $topic_forum_id = ($row['forum_id']) ? (int) $row['forum_id'] : $forum_id; + // This will allow the style designer to output a different header // or even separate the list of announcements from sticky and normal topics $s_type_switch_test = ($row['topic_type'] == POST_ANNOUNCE || $row['topic_type'] == POST_GLOBAL) ? 1 : 0; // Replies - $replies = ($auth->acl_get('m_approve', $forum_id)) ? $row['topic_replies_real'] : $row['topic_replies']; + $replies = ($auth->acl_get('m_approve', $topic_forum_id)) ? $row['topic_replies_real'] : $row['topic_replies']; if ($row['topic_status'] == ITEM_MOVED) { @@ -614,16 +617,16 @@ if (sizeof($topic_list)) topic_status($row, $replies, $unread_topic, $folder_img, $folder_alt, $topic_type); // Generate all the URIs ... - $view_topic_url_params = 'f=' . (($row['forum_id']) ? $row['forum_id'] : $forum_id) . '&t=' . $topic_id; + $view_topic_url_params = 'f=' . $topic_forum_id . '&t=' . $topic_id; $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", $view_topic_url_params); - $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', (($row['forum_id']) ? $row['forum_id'] : $forum_id))) ? true : false; - $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', (($row['forum_id']) ? $row['forum_id'] : $forum_id))) ? true : false; + $topic_unapproved = (!$row['topic_approved'] && $auth->acl_get('m_approve', $topic_forum_id)) ? true : false; + $posts_unapproved = ($row['topic_approved'] && $row['topic_replies'] < $row['topic_replies_real'] && $auth->acl_get('m_approve', $topic_forum_id)) ? true : false; $u_mcp_queue = ($topic_unapproved || $posts_unapproved) ? append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=queue&mode=' . (($topic_unapproved) ? 'approve_details' : 'unapproved_posts') . "&t=$topic_id", true, $user->session_id) : ''; // Send vars to template $template->assign_block_vars('topicrow', array( - 'FORUM_ID' => $forum_id, + 'FORUM_ID' => $topic_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']), 'TOPIC_AUTHOR_COLOUR' => get_username_string('colour', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), @@ -651,13 +654,13 @@ if (sizeof($topic_list)) 'TOPIC_ICON_IMG' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['img'] : '', 'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['width'] : '', 'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$row['icon_id']])) ? $icons[$row['icon_id']]['height'] : '', - 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', + 'ATTACH_ICON_IMG' => ($auth->acl_get('u_download') && $auth->acl_get('f_download', $topic_forum_id) && $row['topic_attachment']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '', 'UNAPPROVED_IMG' => ($topic_unapproved || $posts_unapproved) ? $user->img('icon_topic_unapproved', ($topic_unapproved) ? 'TOPIC_UNAPPROVED' : 'POSTS_UNAPPROVED') : '', 'S_TOPIC_TYPE' => $row['topic_type'], 'S_USER_POSTED' => (isset($row['topic_posted']) && $row['topic_posted']) ? true : false, 'S_UNREAD_TOPIC' => $unread_topic, - 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $forum_id)) ? true : false, + 'S_TOPIC_REPORTED' => (!empty($row['topic_reported']) && $auth->acl_get('m_report', $topic_forum_id)) ? true : false, 'S_TOPIC_UNAPPROVED' => $topic_unapproved, 'S_POSTS_UNAPPROVED' => $posts_unapproved, 'S_HAS_POLL' => ($row['poll_start']) ? true : false, @@ -672,7 +675,7 @@ if (sizeof($topic_list)) 'U_LAST_POST_AUTHOR' => get_username_string('profile', $row['topic_last_poster_id'], $row['topic_last_poster_name'], $row['topic_last_poster_colour']), 'U_TOPIC_AUTHOR' => get_username_string('profile', $row['topic_poster'], $row['topic_first_poster_name'], $row['topic_first_poster_colour']), 'U_VIEW_TOPIC' => $view_topic_url, - 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&f=' . $forum_id . '&t=' . $topic_id, true, $user->session_id), + 'U_MCP_REPORT' => append_sid("{$phpbb_root_path}mcp.$phpEx", 'i=reports&mode=reports&f=' . $topic_forum_id . '&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) diff --git a/phpBB/viewtopic.php b/phpBB/viewtopic.php index 29c4e5cdc1..498088c5c8 100644 --- a/phpBB/viewtopic.php +++ b/phpBB/viewtopic.php @@ -477,7 +477,7 @@ if ($start < 0 || $start >= $total_posts) } // General Viewtopic URL for return links -$viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&start=$start" . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($highlight_match) ? "&hilit=$highlight" : '')); +$viewtopic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . ((strlen($u_sort_param)) ? "&$u_sort_param" : '') . (($highlight_match) ? "&hilit=$highlight" : '')); // Are we watching this topic? $s_watching_topic = array( @@ -601,7 +601,7 @@ $template->assign_vars(array( 'PAGINATION' => $pagination, 'PAGE_NUMBER' => on_page($total_posts, $config['posts_per_page'], $start), 'TOTAL_POSTS' => ($total_posts == 1) ? $user->lang['VIEW_TOPIC_POST'] : sprintf($user->lang['VIEW_TOPIC_POSTS'], $total_posts), - 'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=topic_view&f=$forum_id&t=$topic_id&start=$start" . ((strlen($u_sort_param)) ? "&$u_sort_param" : ''), true, $user->session_id) : '', + 'U_MCP' => ($auth->acl_get('m_', $forum_id)) ? append_sid("{$phpbb_root_path}mcp.$phpEx", "i=main&mode=topic_view&f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . ((strlen($u_sort_param)) ? "&$u_sort_param" : ''), true, $user->session_id) : '', 'MODERATORS' => (isset($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id])) ? implode(', ', $forum_moderators[$forum_id]) : '', 'POST_IMG' => ($topic_data['forum_status'] == ITEM_LOCKED) ? $user->img('button_topic_locked', 'FORUM_LOCKED') : $user->img('button_topic_new', 'POST_NEW_TOPIC'), @@ -630,9 +630,9 @@ $template->assign_vars(array( 'S_SELECT_SORT_KEY' => $s_sort_key, 'S_SELECT_SORT_DAYS' => $s_limit_days, 'S_SINGLE_MODERATOR' => (!empty($forum_moderators[$forum_id]) && sizeof($forum_moderators[$forum_id]) > 1) ? false : true, - 'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&start=$start"), + 'S_TOPIC_ACTION' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start")), 'S_TOPIC_MOD' => ($topic_mod != '') ? '' : '', - 'S_MOD_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&t=$topic_id&start=$start&quickmod=1&redirect=" . urlencode(str_replace('&', '&', $viewtopic_url)), true, $user->session_id), + 'S_MOD_ACTION' => append_sid("{$phpbb_root_path}mcp.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start") . "&quickmod=1&redirect=" . urlencode(str_replace('&', '&', $viewtopic_url)), true, $user->session_id), 'S_VIEWTOPIC' => true, 'S_DISPLAY_SEARCHBOX' => ($auth->acl_get('u_search') && $auth->acl_get('f_search', $forum_id) && $config['load_search']) ? true : false, @@ -722,7 +722,7 @@ if (!empty($topic_data['poll_start'])) if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id) || !check_form_key('posting')) { - $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&start=$start"); + $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start")); meta_refresh(5, $redirect_url); if (!sizeof($voted_id)) @@ -805,7 +805,7 @@ if (!empty($topic_data['poll_start'])) //, topic_last_post_time = ' . time() . " -- for bumping topics with new votes, ignore for now $db->sql_query($sql); - $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id&start=$start"); + $redirect_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", "f=$forum_id&t=$topic_id" . (($start == 0) ? '' : "&start=$start")); meta_refresh(5, $redirect_url); trigger_error($user->lang['VOTE_SUBMITTED'] . '

        ' . sprintf($user->lang['RETURN_TOPIC'], '', '')); @@ -1146,7 +1146,7 @@ while ($row = $db->sql_fetchrow($result)) 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('a_email')) + if ((!empty($row['user_allow_viewemail']) && $auth->acl_get('u_sendemail')) || $auth->acl_get('a_email')) { $user_cache[$poster_id]['email'] = ($config['board_email_form'] && $config['email_enable']) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=email&u=$poster_id") : (($config['board_hide_emails'] && !$auth->acl_get('a_email')) ? '' : 'mailto:' . $row['user_email']); } @@ -1513,7 +1513,7 @@ for ($i = 0, $end = sizeof($post_list); $i < $end; ++$i) 'EDIT_REASON' => $row['post_edit_reason'], 'BUMPED_MESSAGE' => $l_bumped_by, - 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'NEW_POST') : $user->img('icon_post_target', 'POST'), + 'MINI_POST_IMG' => ($post_unread) ? $user->img('icon_post_target_unread', 'UNREAD_POST') : $user->img('icon_post_target', 'POST'), 'POST_ICON_IMG' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['img'] : '', 'POST_ICON_IMG_WIDTH' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['width'] : '', 'POST_ICON_IMG_HEIGHT' => ($topic_data['enable_icons'] && !empty($row['icon_id'])) ? $icons[$row['icon_id']]['height'] : '', diff --git a/phpBB/web.config b/phpBB/web.config new file mode 100644 index 0000000000..128fe3c98f --- /dev/null +++ b/phpBB/web.config @@ -0,0 +1,27 @@ + + + + + + + + + ­ + + + + + + + + + + + + + + + + + + diff --git a/tests/RUNNING_TESTS.txt b/tests/RUNNING_TESTS.txt new file mode 100644 index 0000000000..74a0635c1a --- /dev/null +++ b/tests/RUNNING_TESTS.txt @@ -0,0 +1,57 @@ +Running Tests +============= + +Prerequisites +============= + +PHPUnit +------- + +phpBB unit tests use PHPUnit framework. Version 3.3 or better is required +to run the tests. PHPUnit prefers to be installed via PEAR; refer to +http://www.phpunit.de/ for more information. + +PHP extensions +-------------- + +Unit tests use several PHP extensions that board code does not use. Currently +the following PHP extensions must be installed and enabled to run unit tests: + +- ctype + +Database Tests +-------------- +By default all tests requiring a database connection will use sqlite. If you +do not have sqlite installed the tests will be skipped. If you wish to run the +tests on a different database you have to create a test_config.php file within +your tests directory following the same format as phpBB's config.php. An example +for mysqli can be found below. More information on configuration options can be +found on the wiki (see below). + + = 0) +{ + PHP_CodeCoverage_Filter::getInstance()->addDirectoryToBlacklist('./'); +} +else +{ + PHPUnit_Util_Filter::addDirectoryToFilter('./'); +} + +class phpbb_all_tests +{ + public static function main() + { + PHPUnit_TextUI_TestRunner::run(self::suite()); + } + + public static function suite() + { + $suite = new PHPUnit_Framework_TestSuite('phpBB'); + + $suite->addTest(phpbb_utf_all_tests::suite()); + $suite->addTest(phpbb_request_all_tests::suite()); + $suite->addTest(phpbb_security_all_tests::suite()); + $suite->addTest(phpbb_template_all_tests::suite()); + $suite->addTest(phpbb_text_processing_all_tests::suite()); + $suite->addTest(phpbb_dbal_all_tests::suite()); + $suite->addTest(phpbb_regex_all_tests::suite()); + $suite->addTest(phpbb_network_all_tests::suite()); + $suite->addTest(phpbb_random_all_tests::suite()); + + return $suite; + } +} + +if (PHPUnit_MAIN_METHOD == 'phpbb_all_tests::main') +{ + phpbb_all_tests::main(); +} + diff --git a/tests/dbal/all_tests.php b/tests/dbal/all_tests.php new file mode 100644 index 0000000000..cfa8176246 --- /dev/null +++ b/tests/dbal/all_tests.php @@ -0,0 +1,42 @@ +addTestSuite('phpbb_dbal_select_test'); + $suite->addTestSuite('phpbb_dbal_write_test'); + + return $suite; + } +} + +if (PHPUnit_MAIN_METHOD == 'phpbb_dbal_all_tests::main') +{ + phpbb_dbal_all_tests::main(); +} diff --git a/tests/dbal/fixtures/config.xml b/tests/dbal/fixtures/config.xml new file mode 100644 index 0000000000..019f582a91 --- /dev/null +++ b/tests/dbal/fixtures/config.xml @@ -0,0 +1,18 @@ + + +
        {FOLDER_NEW_IMG}{L_NEW_POSTS}{FOLDER_UNREAD_IMG}{L_UNREAD_POSTS}    {FOLDER_IMG}{L_NO_NEW_POSTS}{L_NO_UNREAD_POSTS}    {FOLDER_ANNOUNCE_IMG} {L_ICON_ANNOUNCEMENT}
        {FOLDER_HOT_NEW_IMG}{L_NEW_POSTS_HOT}{FOLDER_HOT_UNREAD_IMG}{L_UNREAD_POSTS_HOT}    {FOLDER_HOT_IMG}{L_NO_NEW_POSTS_HOT}{L_NO_UNREAD_POSTS_HOT}    {FOLDER_STICKY_IMG} {L_ICON_STICKY}
        {FOLDER_LOCKED_NEW_IMG}{L_NEW_POSTS_LOCKED}{FOLDER_LOCKED_UNREAD_IMG}{L_UNREAD_POSTS_LOCKED}    {FOLDER_LOCKED_IMG}{L_NO_NEW_POSTS_LOCKED}{L_NO_UNREAD_POSTS_LOCKED}    {FOLDER_MOVED_IMG} {L_TOPIC_MOVED}
        + config_name + config_value + is_dynamic + + config1 + foo + 0 + + + config2 + bar + 1 + +
        + diff --git a/tests/dbal/fixtures/three_users.xml b/tests/dbal/fixtures/three_users.xml new file mode 100644 index 0000000000..a6789f4a01 --- /dev/null +++ b/tests/dbal/fixtures/three_users.xml @@ -0,0 +1,19 @@ + + + + user_id + username_clean + + 1 + barfoo + + + 2 + foobar + + + 3 + bertie + +
        +
        diff --git a/tests/dbal/select.php b/tests/dbal/select.php new file mode 100644 index 0000000000..70f27549d2 --- /dev/null +++ b/tests/dbal/select.php @@ -0,0 +1,321 @@ +createXMLDataSet(dirname(__FILE__).'/fixtures/three_users.xml'); + } + + public static function return_on_error_select_data() + { + return array( + array('phpbb_users', "username_clean = 'bertie'", array(array('username_clean' => 'bertie'))), + array('phpbb_users', 'username_clean syntax_error', false), + ); + } + + /** + * @dataProvider return_on_error_select_data + */ + public function test_return_on_error_select($table, $where, $expected) + { + $db = $this->new_dbal(); + + $db->sql_return_on_error(true); + + $result = $db->sql_query('SELECT username_clean + FROM ' . $table . ' + WHERE ' . $where . ' + ORDER BY user_id ASC'); + + $db->sql_return_on_error(false); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + } + + public static function fetchrow_data() + { + return array( + array('', array(array('username_clean' => 'barfoo'), + array('username_clean' => 'foobar'), + array('username_clean' => 'bertie'))), + array('user_id = 2', array(array('username_clean' => 'foobar'))), + array("username_clean = 'bertie'", array(array('username_clean' => 'bertie'))), + array("username_clean = 'phpBB'", array()), + ); + } + + /** + * @dataProvider fetchrow_data + */ + public function test_fetchrow($where, $expected) + { + $db = $this->new_dbal(); + + $result = $db->sql_query('SELECT username_clean + FROM phpbb_users + ' . (($where) ? ' WHERE ' . $where : '') . ' + ORDER BY user_id ASC'); + + $ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + $ary[] = $row; + } + $db->sql_freeresult($result); + + $this->assertEquals($expected, $ary); + } + + /** + * @dataProvider fetchrow_data + */ + public function test_fetchrowset($where, $expected) + { + $db = $this->new_dbal(); + + $result = $db->sql_query('SELECT username_clean + FROM phpbb_users + ' . (($where) ? ' WHERE ' . $where : '') . ' + ORDER BY user_id ASC'); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + + $db->sql_freeresult($result); + } + + public static function fetchfield_data() + { + return array( + array('', array('barfoo', 'foobar', 'bertie')), + array('user_id = 2', array('foobar')), + ); + } + + /** + * @dataProvider fetchfield_data + */ + public function test_fetchfield($where, $expected) + { + $db = $this->new_dbal(); + + $result = $db->sql_query('SELECT username_clean + FROM phpbb_users + ' . (($where) ? ' WHERE ' . $where : '') . ' + ORDER BY user_id ASC'); + + $ary = array(); + while ($row = $db->sql_fetchfield('username_clean')) + { + $ary[] = $row; + } + $db->sql_freeresult($result); + + $this->assertEquals($expected, $ary); + } + + public static function query_limit_data() + { + return array( + array(0, 0, array(array('username_clean' => 'barfoo'), + array('username_clean' => 'foobar'), + array('username_clean' => 'bertie'))), + array(0, 1, array(array('username_clean' => 'foobar'), + array('username_clean' => 'bertie'))), + array(1, 0, array(array('username_clean' => 'barfoo'))), + array(1, 2, array(array('username_clean' => 'bertie'))), + array(2, 0, array(array('username_clean' => 'barfoo'), + array('username_clean' => 'foobar'))), + array(2, 2, array(array('username_clean' => 'bertie'))), + array(2, 5, array()), + array(10, 1, array(array('username_clean' => 'foobar'), + array('username_clean' => 'bertie'))), + array(10, 5, array()), + ); + } + + /** + * @dataProvider query_limit_data + */ + public function test_query_limit($total, $offset, $expected) + { + $db = $this->new_dbal(); + + $result = $db->sql_query_limit('SELECT username_clean + FROM phpbb_users + ORDER BY user_id ASC', $total, $offset); + + $ary = array(); + while ($row = $db->sql_fetchrow($result)) + { + $ary[] = $row; + } + $db->sql_freeresult($result); + + $this->assertEquals($expected, $ary); + } + + public static function like_expression_data() + { + // * = any_char; # = one_char + return array( + array('barfoo', array(array('username_clean' => 'barfoo'))), + array('bar', array()), + array('bar*', array(array('username_clean' => 'barfoo'))), + array('*bar*', array(array('username_clean' => 'barfoo'), + array('username_clean' => 'foobar'))), + array('b*r', array()), + array('b*e', array(array('username_clean' => 'bertie'))), + array('#b*e', array()), + array('b####e', array(array('username_clean' => 'bertie'))), + ); + } + + /** + * @dataProvider like_expression_data + */ + public function test_like_expression($like_expression, $expected) + { + $db = $this->new_dbal(); + + $like_expression = str_replace('*', $db->any_char, $like_expression); + $like_expression = str_replace('#', $db->one_char, $like_expression); + $where = ($like_expression) ? 'username_clean ' . $db->sql_like_expression($like_expression) : ''; + + $result = $db->sql_query('SELECT username_clean + FROM phpbb_users + ' . (($where) ? ' WHERE ' . $where : '') . ' + ORDER BY user_id ASC'); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + + $db->sql_freeresult($result); + } + + public static function in_set_data() + { + return array( + array('user_id', 3, false, false, array(array('username_clean' => 'bertie'))), + array('user_id', 3, false, true, array(array('username_clean' => 'bertie'))), + array('user_id', 3, true, false, array(array('username_clean' => 'barfoo'), + array('username_clean' => 'foobar'))), + array('user_id', 3, true, true, array(array('username_clean' => 'barfoo'), + array('username_clean' => 'foobar'))), + array('username_clean', 'bertie', false, false, array(array('username_clean' => 'bertie'))), + array('username_clean', 'bertie', false, true, array(array('username_clean' => 'bertie'))), + array('username_clean', 'bertie', true, false, array(array('username_clean' => 'barfoo'), + array('username_clean' => 'foobar'))), + array('username_clean', 'bertie', true, true, array(array('username_clean' => 'barfoo'), + array('username_clean' => 'foobar'))), + array('user_id', array(3), false, false, array(array('username_clean' => 'bertie'))), + array('user_id', array(3), false, true, array(array('username_clean' => 'bertie'))), + array('user_id', array(3), true, false, array(array('username_clean' => 'barfoo'), + array('username_clean' => 'foobar'))), + array('user_id', array(3), true, true, array(array('username_clean' => 'barfoo'), + array('username_clean' => 'foobar'))), + array('user_id', array(1, 3), false, false, array(array('username_clean' => 'barfoo'), + array('username_clean' => 'bertie'))), + array('user_id', array(1, 3), false, true, array(array('username_clean' => 'barfoo'), + array('username_clean' => 'bertie'))), + array('user_id', array(1, 3), true, false, array(array('username_clean' => 'foobar'))), + array('user_id', array(1, 3), true, true, array(array('username_clean' => 'foobar'))), + array('username_clean', '', false, false, array()), + array('username_clean', '', false, true, array()), + array('username_clean', '', true, false, array(array('username_clean' => 'barfoo'), + array('username_clean' => 'foobar'), + array('username_clean' => 'bertie'))), + array('username_clean', '', true, true, array(array('username_clean' => 'barfoo'), + array('username_clean' => 'foobar'), + array('username_clean' => 'bertie'))), + array('user_id', array(), false, true, array()), + array('user_id', array(), true, true, array(array('username_clean' => 'barfoo'), + array('username_clean' => 'foobar'), + array('username_clean' => 'bertie'))), + + // These here would throw errors and therefor $result should be false. + // Removing for now because SQLite accepts empty IN() syntax + /*array('user_id', array(), false, false, false, true), + array('user_id', array(), true, false, false, true),*/ + ); + } + + /** + * @dataProvider in_set_data + */ + public function test_in_set($field, $array, $negate, $allow_empty_set, $expected, $catch_error = false) + { + $db = $this->new_dbal(); + + if ($catch_error) + { + $db->sql_return_on_error(true); + } + + $result = $db->sql_query('SELECT username_clean + FROM phpbb_users + WHERE ' . $db->sql_in_set($field, $array, $negate, $allow_empty_set) . ' + ORDER BY user_id ASC'); + + if ($catch_error) + { + $db->sql_return_on_error(false); + } + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + + $db->sql_freeresult($result); + } + + public static function build_array_data() + { + return array( + array(array('username_clean' => 'barfoo'), array(array('username_clean' => 'barfoo'))), + array(array('username_clean' => 'barfoo', 'user_id' => 1), array(array('username_clean' => 'barfoo'))), + array(array('username_clean' => 'barfoo', 'user_id' => 2), array()), + + // These here would throw errors and therefor $result should be false. + array(array(), false, true), + array('no_array', false, true), + array(0, false, true), + ); + } + + /** + * @dataProvider build_array_data + */ + public function test_build_array($assoc_ary, $expected, $catch_error = false) + { + $db = $this->new_dbal(); + + if ($catch_error) + { + $db->sql_return_on_error(true); + } + + $sql = 'SELECT username_clean + FROM phpbb_users + WHERE ' . $db->sql_build_array('SELECT', $assoc_ary) . ' + ORDER BY user_id ASC'; + $result = $db->sql_query($sql); + + if ($catch_error) + { + $db->sql_return_on_error(false); + } + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + + $db->sql_freeresult($result); + } +} diff --git a/tests/dbal/write.php b/tests/dbal/write.php new file mode 100644 index 0000000000..01deacda69 --- /dev/null +++ b/tests/dbal/write.php @@ -0,0 +1,172 @@ +createXMLDataSet(dirname(__FILE__).'/fixtures/config.xml'); + } + + public static function build_array_insert_data() + { + return array( + array(array( + 'config_name' => 'test_version', + 'config_value' => '0.0.0', + 'is_dynamic' => 1, + )), + array(array( + 'config_name' => 'second config', + 'config_value' => '10', + 'is_dynamic' => 0, + )), + ); + } + + /** + * @dataProvider build_array_insert_data + */ + public function test_build_array_insert($sql_ary) + { + $db = $this->new_dbal(); + + $sql = 'INSERT INTO phpbb_config ' . $db->sql_build_array('INSERT', $sql_ary); + $result = $db->sql_query($sql); + + $sql = "SELECT * + FROM phpbb_config + WHERE config_name = '" . $sql_ary['config_name'] . "'"; + $result = $db->sql_query_limit($sql, 1); + + $this->assertEquals($sql_ary, $db->sql_fetchrow($result)); + + $db->sql_freeresult($result); + } + + public function test_delete() + { + $db = $this->new_dbal(); + + $sql = "DELETE FROM phpbb_config + WHERE config_name = 'config1'"; + $result = $db->sql_query($sql); + + $sql = 'SELECT * + FROM phpbb_config'; + $result = $db->sql_query($sql); + $rows = $db->sql_fetchrowset($result); + + $this->assertEquals(1, sizeof($rows)); + $this->assertEquals('config2', $rows[0]['config_name']); + + $db->sql_freeresult($result); + } + + public function test_multiple_insert() + { + $db = $this->new_dbal(); + + // empty the table + $sql = 'DELETE FROM phpbb_config'; + $db->sql_query($sql); + + $batch_ary = array( + array( + 'config_name' => 'batch one', + 'config_value' => 'b1', + 'is_dynamic' => 0, + ), + array( + 'config_name' => 'batch two', + 'config_value' => 'b2', + 'is_dynamic' => 1, + ), + ); + + $result = $db->sql_multi_insert('phpbb_config', $batch_ary); + + $sql = 'SELECT * + FROM phpbb_config + ORDER BY config_name ASC'; + $result = $db->sql_query($sql); + + $this->assertEquals($batch_ary, $db->sql_fetchrowset($result)); + + $db->sql_freeresult($result); + } + + public static function update_data() + { + return array( + array( + array( + 'config_value' => '23', + 'is_dynamic' => 0, + ), + " WHERE config_name = 'config1'", + array( + array( + 'config_name' => 'config1', + 'config_value' => '23', + 'is_dynamic' => 0, + ), + array( + 'config_name' => 'config2', + 'config_value' => 'bar', + 'is_dynamic' => 1, + ), + ), + ), + array( + array( + 'config_value' => '0', + 'is_dynamic' => 1, + ), + '', + array( + array( + 'config_name' => 'config1', + 'config_value' => '0', + 'is_dynamic' => 1, + ), + array( + 'config_name' => 'config2', + 'config_value' => '0', + 'is_dynamic' => 1, + ), + ), + ), + ); + } + + /** + * @dataProvider update_data + */ + public function test_update($sql_ary, $where, $expected) + { + $db = $this->new_dbal(); + + $sql = 'UPDATE phpbb_config + SET ' . $db->sql_build_array('UPDATE', $sql_ary) . $where; + $result = $db->sql_query($sql); + + $sql = 'SELECT * + FROM phpbb_config + ORDER BY config_name ASC'; + $result = $db->sql_query($sql); + + $this->assertEquals($expected, $db->sql_fetchrowset($result)); + + $db->sql_freeresult($result); + } +} diff --git a/tests/network/all_tests.php b/tests/network/all_tests.php new file mode 100644 index 0000000000..b500647f81 --- /dev/null +++ b/tests/network/all_tests.php @@ -0,0 +1,40 @@ +addTestSuite('phpbb_network_checkdnsrr_test'); + + return $suite; + } +} + +if (PHPUnit_MAIN_METHOD == 'phpbb_network_all_tests::main') +{ + phpbb_network_all_tests::main(); +} diff --git a/tests/network/checkdnsrr.php b/tests/network/checkdnsrr.php new file mode 100644 index 0000000000..57fe2761cc --- /dev/null +++ b/tests/network/checkdnsrr.php @@ -0,0 +1,63 @@ +assertEquals($expected, phpbb_checkdnsrr($host, $type)); + } +} diff --git a/tests/random/all_tests.php b/tests/random/all_tests.php new file mode 100644 index 0000000000..c6ffe78024 --- /dev/null +++ b/tests/random/all_tests.php @@ -0,0 +1,40 @@ +addTestSuite('phpbb_random_gen_rand_string_test'); + + return $suite; + } +} + +if (PHPUnit_MAIN_METHOD == 'phpbb_random_all_tests::main') +{ + phpbb_random_all_tests::main(); +} diff --git a/tests/random/gen_rand_string.php b/tests/random/gen_rand_string.php new file mode 100644 index 0000000000..cd58d14ed3 --- /dev/null +++ b/tests/random/gen_rand_string.php @@ -0,0 +1,63 @@ +assertTrue($random_string_length >= self::MIN_STRING_LENGTH); + $this->assertTrue($random_string_length <= $num_chars); + $this->assertRegExp('#^[A-Z0-9]+$#', $random_string); + } + } + } + + public function test_gen_rand_string_friendly() + { + for ($tests = 0; $tests <= self::TEST_COUNT; ++$tests) + { + for ($num_chars = self::MIN_STRING_LENGTH; $num_chars <= self::MAX_STRING_LENGTH; ++$num_chars) + { + $random_string = gen_rand_string_friendly($num_chars); + $random_string_length = strlen($random_string); + + $this->assertTrue($random_string_length >= self::MIN_STRING_LENGTH); + $this->assertTrue($random_string_length <= $num_chars); + $this->assertRegExp('#^[A-NP-Z1-9]+$#', $random_string); + } + } + } +} diff --git a/tests/regex/all_tests.php b/tests/regex/all_tests.php new file mode 100644 index 0000000000..316a9d4a58 --- /dev/null +++ b/tests/regex/all_tests.php @@ -0,0 +1,46 @@ +addTestSuite('phpbb_regex_email_test'); + $suite->addTestSuite('phpbb_regex_ipv4_test'); + $suite->addTestSuite('phpbb_regex_ipv6_test'); + $suite->addTestSuite('phpbb_regex_url_test'); + + return $suite; + } +} + +if (PHPUnit_MAIN_METHOD == 'phpbb_regex_all_tests::main') +{ + phpbb_regex_all_tests::main(); +} diff --git a/tests/regex/email.php b/tests/regex/email.php new file mode 100644 index 0000000000..8658b8af36 --- /dev/null +++ b/tests/regex/email.php @@ -0,0 +1,119 @@ +regex = '#^' . get_preg_expression('email') . '$#i'; + } + + public function positive_match_data() + { + return array( + array('nobody@phpbb.com'), + array('Nobody@sub.phpbb.com'), + array('alice.bob@foo.phpbb.com'), + array('alice-foo@bar.phpbb.com'), + array('alice_foo@bar.phpbb.com'), + array('alice+tag@foo.phpbb.com'), + array('alice&tag@foo.phpbb.com'), + + //array('"John Doe"@example.com'), + //array('Alice@[192.168.2.1]'), // IPv4 + //array('Bob@[2001:0db8:85a3:08d3:1319:8a2e:0370:7344]'), // IPv6 + + // http://fightingforalostcause.net/misc/2006/compare-email-regex.php + array('l3tt3rsAndNumb3rs@domain.com'), + array('has-dash@domain.com'), + array('hasApostrophe.o\'leary@domain.org'), + array('uncommonTLD@domain.museum'), + array('uncommonTLD@domain.travel'), + array('uncommonTLD@domain.mobi'), + array('countryCodeTLD@domain.uk'), + array('countryCodeTLD@domain.rw'), + array('numbersInDomain@911.com'), + array('underscore_inLocal@domain.net'), + array('IPInsteadOfDomain@127.0.0.1'), + array('IPAndPort@127.0.0.1:25'), + array('subdomain@sub.domain.com'), + array('local@dash-inDomain.com'), + array('dot.inLocal@foo.com'), + array('a@singleLetterLocal.org'), + array('singleLetterDomain@x.org'), + array('&*=?^+{}\'~@validCharsInLocal.net'), + array('foor@bar.newTLD'), + ); + } + + public function negative_match_data() + { + return array( + array('foo.example.com'), // @ is missing + array('.foo.example.com'), // . as first character + array('Foo.@example.com'), // . is last in local part + array('foo..123@example.com'), // . doubled + array('a@b@c@example.com'), // @ doubled + + array('()[]\;:,<>@example.com'), // invalid characters + array('abc(def@example.com'), // invalid character ( + array('abc)def@example.com'), // invalid character ) + array('abc[def@example.com'), // invalid character [ + array('abc]def@example.com'), // invalid character ] + array('abc\def@example.com'), // invalid character \ + array('abc;def@example.com'), // invalid character ; + array('abc:def@example.com'), // invalid character : + array('abc,def@example.com'), // invalid character , + array('abcdef@example.com'), // invalid character > + + // http://fightingforalostcause.net/misc/2006/compare-email-regex.php + array('missingDomain@.com'), + array('@missingLocal.org'), + array('missingatSign.net'), + array('missingDot@com'), + array('two@@signs.com'), + array('colonButNoPort@127.0.0.1:'), + array(''), + array('someone-else@127.0.0.1.26'), + array('.localStartsWithDot@domain.com'), + array('localEndsWithDot.@domain.com'), + array('two..consecutiveDots@domain.com'), + array('domainStartsWithDash@-domain.com'), + array('domainEndsWithDash@domain-.com'), + array('numbersInTLD@domain.c0m'), + array('missingTLD@domain.'), + array('! "#$%(),/;<>[]`|@invalidCharsInLocal.org'), + array('invalidCharsInDomain@! "#$%(),/;<>_[]`|.org'), + array('local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org'), + ); + } + + /** + * @dataProvider positive_match_data + */ + public function test_positive_match($email) + { + $this->assertEquals(1, preg_match($this->regex, $email)); + } + + /** + * @dataProvider negative_match_data + */ + public function test_negative_match($email) + { + $this->assertEquals(0, preg_match($this->regex, $email)); + } +} + diff --git a/tests/regex/ipv4.php b/tests/regex/ipv4.php new file mode 100644 index 0000000000..9d131ad0ca --- /dev/null +++ b/tests/regex/ipv4.php @@ -0,0 +1,72 @@ +regex = get_preg_expression('ipv4'); + } + + public function positive_match_data() + { + return array( + array('0.0.0.0'), + array('127.0.0.1'), + array('192.168.0.1'), + array('255.255.255.255'), + ); + } + + public function negative_match_data() + { + return array( + // IPv6 addresses + array('2001:0db8:85a3:0000:0000:8a2e:0370:1337'), + array('2001:db8:85a3:c:d:8a2e:370:1337'), + array('2001:db8:85a3::8a2e:370:1337'), + array('2001:db8:0:1::192.168.0.2'), + array('0:0:0:0:0:0:0:1'), + array('0:0::0:0:1'), + array('::1'), + + // Out of scope + array('255.255.255.256'), + + // Other tests + array('a.b.c.d'), + array('11.22.33.'), + array('11.22.33'), + array('11.22'), + array('11'), + ); + } + + /** + * @dataProvider positive_match_data + */ + public function test_positive_match($address) + { + $this->assertEquals(1, preg_match($this->regex, $address)); + } + + /** + * @dataProvider negative_match_data + */ + public function test_negative_match($address) + { + $this->assertEquals(0, preg_match($this->regex, $address)); + } +} + diff --git a/tests/regex/ipv6.php b/tests/regex/ipv6.php new file mode 100644 index 0000000000..3d7a72e492 --- /dev/null +++ b/tests/regex/ipv6.php @@ -0,0 +1,143 @@ +regex = get_preg_expression('ipv6'); + } + + public function positive_match_data() + { + return array( + // Full length IPv6 address + array('2001:0db8:85a3:0000:0000:8a2e:0370:1337'), + array('0000:0000:0000:0000:0000:0000:0000:0001'), + array('3FFE:0b00:0000:0000:0001:0000:0000:000a'), + array('3ffe:0b00:0000:0000:0001:0000:0000:000a'), + array('2002:0db8:0000:0000:0000:dead:1337:d00d'), + + // No leading zeroes in the group + array('2001:db8:85a3:0:0:8a2e:370:1337'), + array('2001:db8:85a3:c:d:8a2e:370:1337'), + + // Consecutive all-zero groups + array('2001:db8:85a3::8a2e:370:1337'), + array('1::2:3:4:5:6:7'), + array('1::2:3:4:5:6'), + array('1::2:3:4:5'), + array('1::2:3:4'), + array('1::2:3'), + array('1::2'), + + // Last 32bit in dotted quad notation + array('2001:db8:0:1::192.168.0.2'), + + // IPv4-compatible IPv6 address + array('::13.1.68.3'), + array('0:0:0:0:0:0:13.1.68.3'), + + // IPv4-mapped IPv6 address + array('::ffff:c000:280'), + array('::ffff:c000:0280'), + array('::ffff:192.0.2.128'), + array('0:0:0:0:0:ffff:c000:280'), + array('0:0:0:0:0:ffff:c000:0280'), + array('0:0:0:0:0:ffff:192.0.2.128'), + array('0000:0000:0000:0000:0000:ffff:c000:280'), + array('0000:0000:0000:0000:0000:ffff:c000:0280'), + array('0000:0000:0000:0000:0000:ffff:192.0.2.128'), + + // No trailing zeroes + array('fe80::'), + array('2002::'), + array('2001:db8::'), + array('2001:0db8:1234::'), + array('1:2:3:4:5:6::'), + array('1:2:3:4:5::'), + array('1:2:3:4::'), + array('1:2:3::'), + array('1:2::'), + + // No leading zeroes + array('::2:3:4:5:6:7:8'), + array('::2:3:4:5:6:7'), + array('::2:3:4:5:6'), + array('::2:3:4:5'), + array('::2:3:4'), + array('::2:3'), + array('::1'), + array('::8'), + array('::c'), + array('::abcd'), + + // All zeroes + array('::'), + array('0:0:0:0:0:0:0:0'), + array('0000:0000:0000:0000:0000:0000:0000:0000'), + + // More tests + array('2::10'), + array('0:0::0:0:1'), + array('0:0:0:0:0:0:0:1'), + array('::ffff:0:0'), + ); + } + + public function negative_match_data() + { + return array( + // Empty address + array(''), + + // IPv4 address + array('192.168.0.2'), + + // Out of scope + array('abcd:efgh:0000::0'), + array('::ffff:192.168.255.256'), + + // Double :: + array('2001::23de::2002'), + array('3ffe:b00::1::b'), + array('::1111:2222:3333:4444:5555:6666::'), + + // Too many blocks + array('2001:0db8:85a3:08d3:1319:8a2e:0370:1337:4430'), + + // More tests + array('02001:0000:1234:0000:0000:C1C0:ABCD:9876'), + array('2001:0000:1234: 0000:0000:C1C0:ABCD:9876'), + array('::ffff:192x168.255.255'), + ); + } + + /** + * @dataProvider positive_match_data + */ + public function test_positive_match($address) + { + $this->assertEquals(1, preg_match($this->regex, $address)); + } + + /** + * @dataProvider negative_match_data + */ + public function test_negative_match($address) + { + $this->assertEquals(0, preg_match($this->regex, $address)); + } +} + diff --git a/tests/regex/url.php b/tests/regex/url.php new file mode 100644 index 0000000000..678b7d108f --- /dev/null +++ b/tests/regex/url.php @@ -0,0 +1,34 @@ +assertEquals($expected, preg_match('#^' . get_preg_expression('url') . '$#i', $url)); + } +} diff --git a/tests/request/all_tests.php b/tests/request/all_tests.php new file mode 100644 index 0000000000..1ee3029b36 --- /dev/null +++ b/tests/request/all_tests.php @@ -0,0 +1,41 @@ +addTestSuite('phpbb_request_request_var_test'); + + return $suite; + } +} + +if (PHPUnit_MAIN_METHOD == 'phpbb_request_all_tests::main') +{ + phpbb_request_all_tests::main(); +} + diff --git a/tests/request/request_var.php b/tests/request/request_var.php new file mode 100644 index 0000000000..b1dacef3fd --- /dev/null +++ b/tests/request/request_var.php @@ -0,0 +1,180 @@ +unset_variables($variable_name); + + $_POST[$variable_name] = $variable_value; + $_REQUEST[$variable_name] = $variable_value; + + $result = request_var($variable_name, $default, $multibyte); + + $label = 'Requesting POST variable, converting from ' . gettype($variable_value) . ' to ' . gettype($default) . (($multibyte) ? ' multibyte' : ''); + $this->assertEquals($expected, $result, $label); + } + + /** + * @dataProvider request_variables + */ + public function test_get($variable_value, $default, $multibyte, $expected) + { + $variable_name = 'name'; + $this->unset_variables($variable_name); + + $_GET[$variable_name] = $variable_value; + $_REQUEST[$variable_name] = $variable_value; + + $result = request_var($variable_name, $default, $multibyte); + + $label = 'Requesting GET variable, converting from ' . gettype($variable_value) . ' to ' . gettype($default) . (($multibyte) ? ' multibyte' : ''); + $this->assertEquals($expected, $result, $label); + } + + /** + * @dataProvider request_variables + */ + public function test_cookie($variable_value, $default, $multibyte, $expected) + { + $variable_name = 'name'; + $this->unset_variables($variable_name); + + $_GET[$variable_name] = false; + $_POST[$variable_name] = false; + $_REQUEST[$variable_name] = false; + $_COOKIE[$variable_name] = $variable_value; + + $result = request_var($variable_name, $default, $multibyte, true); + + $label = 'Requesting COOKIE variable, converting from ' . gettype($variable_value) . ' to ' . gettype($default) . (($multibyte) ? ' multibyte' : ''); + $this->assertEquals($expected, $result, $label); + } + + /** + * Helper for unsetting globals + */ + private function unset_variables($var) + { + unset($_GET[$var], $_POST[$var], $_REQUEST[$var], $_COOKIE[$var]); + } + + public static function request_variables() + { + return array( + // strings + array('abc', '', false, 'abc'), + array(' some spaces ', '', true, 'some spaces'), + array("\r\rsome\rcarriage\r\rreturns\r", '', true, "some\ncarriage\n\nreturns"), + array("\n\nsome\ncarriage\n\nreturns\n", '', true, "some\ncarriage\n\nreturns"), + array("\r\n\r\nsome\r\ncarriage\r\n\r\nreturns\r\n", '', true, "some\ncarriage\n\nreturns"), + array("we\xC2\xA1rd\xE1\x9A\x80ch\xCE\xB1r\xC2\xADacters", '', true, "we\xC2\xA1rd\xE1\x9A\x80ch\xCE\xB1r\xC2\xADacters"), + array("we\xC2\xA1rd\xE1\x9A\x80ch\xCE\xB1r\xC2\xADacters", '', false, "we??rd???ch??r??acters"), + array("Some \"entities\" like &", '', true, "Some <html> "entities" like &"), + + // integers + array('1234', 0, false, 1234), + array('abc', 12, false, 0), + array('324abc', 0, false, 324), + + // string to array + array('123', array(0), false, array()), + array('123', array(''), false, array()), + + // 1 dimensional arrays + array( + // input: + array('123', 'abc'), + // default: + array(''), + false, + // expected: + array('123', 'abc') + ), + array( + // input: + array('123', 'abc'), + // default: + array(999), + false, + // expected: + array(123, 0) + ), + array( + // input: + array('xyz' => '123', 'abc' => 'abc'), + // default: + array('' => ''), + false, + // expected: + array('xyz' => '123', 'abc' => 'abc') + ), + array( + // input: + array('xyz' => '123', 'abc' => 'abc'), + // default: + array('' => 0), + false, + // expected: + array('xyz' => 123, 'abc' => 0) + ), + + // 2 dimensional arrays + array( + // input: + '', + // default: + array(array(0)), + false, + // expected: + array() + ), + array( + // input: + array( + 'xyz' => array('123', 'def'), + 'abc' => 'abc' + ), + // default: + array('' => array('')), + false, + // expected: + array( + 'xyz' => array('123', 'def'), + 'abc' => array() + ) + ), + array( + // input: + array( + 'xyz' => array('123', 'def'), + 'abc' => 'abc' + ), + // default: + array('' => array(0)), + false, + // expected: + array( + 'xyz' => array(123, 0), + 'abc' => array() + ) + ), + ); + } + +} + diff --git a/tests/security/all_tests.php b/tests/security/all_tests.php new file mode 100644 index 0000000000..8e3916733f --- /dev/null +++ b/tests/security/all_tests.php @@ -0,0 +1,86 @@ + gzip,deflate + [HTTP_ACCEPT_CHARSET] => ISO-8859-1,utf-8;q=0.7,*;q=0.7 + DOCUMENT_ROOT] => /var/www/ + [SCRIPT_FILENAME] => /var/www/tests/index.php +*/ + + // Set no user and trick a bit to circumvent errors + $user = new user(); + $user->lang = true; + $user->browser = (!empty($_SERVER['HTTP_USER_AGENT'])) ? htmlspecialchars((string) $_SERVER['HTTP_USER_AGENT']) : ''; + $user->referer = (!empty($_SERVER['HTTP_REFERER'])) ? htmlspecialchars((string) $_SERVER['HTTP_REFERER']) : ''; + $user->forwarded_for = (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? (string) $_SERVER['HTTP_X_FORWARDED_FOR'] : ''; + $user->host = (!empty($_SERVER['HTTP_HOST'])) ? (string) strtolower($_SERVER['HTTP_HOST']) : ((!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : getenv('SERVER_NAME')); + $user->page = session::extract_current_page($phpbb_root_path); + } + + protected function tearDown() + { + global $user; + $user = NULL; + } + + public static function main() + { + PHPUnit_TextUI_TestRunner::run(self::suite()); + } + + public static function suite() + { + // I bet there is a better method calling this... :) + $suite = new phpbb_security_all_tests('phpBB Security Fixes'); + + $suite->addTestSuite('phpbb_security_extract_current_page_test'); + $suite->addTestSuite('phpbb_security_redirect_test'); + + return $suite; + } +} + +if (PHPUnit_MAIN_METHOD == 'phpbb_security_all_tests::main') +{ + phpbb_security_all_tests::main(); +} diff --git a/tests/security/extract_current_page.php b/tests/security/extract_current_page.php new file mode 100644 index 0000000000..8c72fe1440 --- /dev/null +++ b/tests/security/extract_current_page.php @@ -0,0 +1,53 @@ +', 'mark=forums&x=%22%3E%3Cscript%3Ealert(/XSS/);%3C/script%3E'), + array('http://localhost/phpBB/index.php', 'mark=forums&x=%22%3E%3Cscript%3Ealert(/XSS/);%3C/script%3E', 'mark=forums&x=%22%3E%3Cscript%3Ealert(/XSS/);%3C/script%3E'), + ); + } + + /** + * @dataProvider security_variables + */ + public function test_query_string_php_self($url, $query_string, $expected) + { + $_SERVER['PHP_SELF'] = $url; + $_SERVER['QUERY_STRING'] = $query_string; + + $result = session::extract_current_page('./'); + + $label = 'Running extract_current_page on ' . $query_string . ' with PHP_SELF filled.'; + $this->assertEquals($expected, $result['query_string'], $label); + } + + /** + * @dataProvider security_variables + */ + public function test_query_string_request_uri($url, $query_string, $expected) + { + $_SERVER['REQUEST_URI'] = $url . '?' . $query_string; + $_SERVER['QUERY_STRING'] = $query_string; + + $result = session::extract_current_page('./'); + + $label = 'Running extract_current_page on ' . $query_string . ' with REQUEST_URI filled.'; + $this->assertEquals($expected, $result['query_string'], $label); + } +} + diff --git a/tests/security/redirect.php b/tests/security/redirect.php new file mode 100644 index 0000000000..37b0a5bb41 --- /dev/null +++ b/tests/security/redirect.php @@ -0,0 +1,58 @@ + redirect(), expected triggered error (else false), expected returned result url (else false)) + return array( + array('data://x', false, 'http://localhost/phpBB'), + array('bad://localhost/phpBB/index.php', 'Tried to redirect to potentially insecure url.', false), + array('http://www.otherdomain.com/somescript.php', false, 'http://localhost/phpBB'), + array("http://localhost/phpBB/memberlist.php\n\rConnection: close", 'Tried to redirect to potentially insecure url.', false), + array('javascript:test', false, 'http://localhost/phpBB/../tests/javascript:test'), + array('http://localhost/phpBB/index.php;url=', 'Tried to redirect to potentially insecure url.', false), + ); + } + + protected function setUp() + { + $GLOBALS['config'] = array( + 'force_server_vars' => '0', + ); + } + + /** + * @dataProvider provider + */ + public function test_redirect($test, $expected_error, $expected_result) + { + global $user; + + if ($expected_error !== false) + { + $this->setExpectedTriggerError(E_USER_ERROR, $expected_error); + } + + $result = redirect($test, true); + + // only verify result if we did not expect an error + if ($expected_error === false) + { + $this->assertEquals($expected_result, $result); + } + } +} + diff --git a/tests/template/all_tests.php b/tests/template/all_tests.php new file mode 100644 index 0000000000..ea258c1680 --- /dev/null +++ b/tests/template/all_tests.php @@ -0,0 +1,40 @@ +addTestSuite('phpbb_template_template_test'); + + return $suite; + } +} + +if (PHPUnit_MAIN_METHOD == 'phpbb_template_all_tests::main') +{ + phpbb_template_all_tests::main(); +} diff --git a/tests/template/template.php b/tests/template/template.php new file mode 100644 index 0000000000..0c2ca8a032 --- /dev/null +++ b/tests/template/template.php @@ -0,0 +1,690 @@ +assertTrue($this->template->display($handle, false)); + } + catch (Exception $exception) + { + // reset the error level even when an error occured + // PHPUnit turns trigger_error into exceptions as well + error_reporting($error_level); + ob_end_clean(); + throw $exception; + } + + $result = self::trim_template_result(ob_get_clean()); + + // reset error level + error_reporting($error_level); + return $result; + } + + private static function trim_template_result($result) + { + return str_replace("\n\n", "\n", implode("\n", array_map('trim', explode("\n", trim($result))))); + } + + private function setup_engine() + { + $this->template_path = dirname(__FILE__) . '/templates'; + $this->template = new template(); + $this->template->set_custom_template($this->template_path, 'tests'); + } + + protected function setUp() + { + // Test the engine can be used + $this->setup_engine(); + + if (!is_writable(dirname($this->template->cachepath))) + { + $this->markTestSkipped("Template cache directory is not writable."); + } + + foreach (glob($this->template->cachepath . '*') as $file) + { + unlink($file); + } + + $GLOBALS['config'] = array( + 'load_tplcompile' => true, + 'tpl_allow_php' => false, + ); + } + + protected function tearDown() + { + if (is_object($this->template)) + { + foreach (glob($this->template->cachepath . '*') as $file) + { + unlink($file); + } + } + } + + /** + * @todo put test data into templates/xyz.test + */ + public static function template_data() + { + return array( + /* + array( + '', // File + array(), // vars + array(), // block vars + array(), // destroy + '', // Expected result + ), + */ + array( + 'basic.html', + array(), + array(), + array(), + "pass\npass\n", + ), + array( + 'variable.html', + array('VARIABLE' => 'value'), + array(), + array(), + 'value', + ), + array( + 'if.html', + array(), + array(), + array(), + '0', + ), + array( + 'if.html', + array('S_VALUE' => true), + array(), + array(), + "1\n0", + ), + array( + 'if.html', + array('S_VALUE' => true, 'S_OTHER_VALUE' => true), + array(), + array(), + '1', + ), + array( + 'if.html', + array('S_VALUE' => false, 'S_OTHER_VALUE' => true), + array(), + array(), + '2', + ), + array( + 'loop.html', + array(), + array(), + array(), + "noloop\nnoloop", + ), + array( + 'loop.html', + array(), + array('loop' => array(array())), + array(), + "loop\nloop", + ), + array( + 'loop.html', + array(), + array('loop' => array(array(), array()), 'loop.block' => array(array())), + array(), + "loop\nloop\nloop\nloop", + ), + array( + 'loop.html', + array(), + array('loop' => array(array(), array()), 'loop.block' => array(array()), 'block' => array(array(), array())), + array(), + "loop\nloop\nloop\nloop\nloop#0-block#0\nloop#0-block#1\nloop#1-block#0\nloop#1-block#1", + ), + array( + 'loop_vars.html', + array(), + array('loop' => array(array('VARIABLE' => 'x'))), + array(), + "first\n0\nx\nset\nlast", + ),/* no nested top level loops + array( + 'loop_vars.html', + array(), + array('loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y'))), + array(), + "first\n0\n0\n2\nx\nset\n1\n1\n2\ny\nset\nlast", + ), + array( + 'loop_vars.html', + array(), + array('loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'loop.inner' => array(array(), array())), + array(), + "first\n0\n0\n2\nx\nset\n1\n1\n2\ny\nset\nlast\n0\n\n1\nlast inner\ninner loop", + ),*/ + array( + 'loop_advanced.html', + array(), + array('loop' => array(array(), array(), array(), array(), array(), array(), array())), + array(), + "101234561\nx\n101234561\nx\n101234561\nx\n1234561\nx\n1\nx\n101\nx\n234\nx\n10\nx\n561\nx\n561", + ), + array( + 'define.html', + array(), + array('loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())), + array(), + "xyz\nabc", + ), + array( + 'expressions.html', + array(), + array(), + array(), + trim(str_repeat("pass", 39)), + ), + array( + 'php.html', + array(), + array(), + array(), + '', + ), + array( + 'include.html', + array('VARIABLE' => 'value'), + array(), + array(), + 'value', + ), + array( + 'loop_vars.html', + array(), + array('loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'loop.inner' => array(array(), array())), + array('loop'), + '', + ),/* no top level nested loops + array( + 'loop_vars.html', + array(), + array('loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'loop.inner' => array(array(), array())), + array('loop.inner'), + "first\n0\n0\n2\nx\nset\n1\n1\n2\ny\nset\nlast", + ),*/ + array( + 'lang.html', + array(), + array(), + array(), + "{ VARIABLE }\n{ VARIABLE }", + ), + array( + 'lang.html', + array('L_VARIABLE' => "Value'"), + array(), + array(), + "Value'\nValue\'", + ), + array( + 'lang.html', + array('LA_VARIABLE' => "Value'"), + array(), + array(), + "{ VARIABLE }\nValue'", + ), + ); + } + + public function test_missing_file() + { + $filename = 'file_not_found.html'; + + $this->template->set_filenames(array('test' => $filename)); + $this->assertFileNotExists($this->template_path . '/' . $filename, 'Testing missing file, file cannot exist'); + + $expecting = sprintf('template->_tpl_load_file(): File %s does not exist or is empty', realpath($this->template_path . '/../') . '/templates/' . $filename); + $this->setExpectedTriggerError(E_USER_ERROR, $expecting); + + $this->display('test'); + } + + public function test_empty_file() + { + $expecting = 'template->set_filenames: Empty filename specified for test'; + + $this->setExpectedTriggerError(E_USER_ERROR, $expecting); + $this->template->set_filenames(array('test' => '')); + } + + public function test_invalid_handle() + { + $expecting = 'template->_tpl_load(): No file specified for handle test'; + $this->setExpectedTriggerError(E_USER_ERROR, $expecting); + + $this->display('test'); + } + + private function run_template($file, array $vars, array $block_vars, array $destroy, $expected, $cache_file) + { + $this->template->set_filenames(array('test' => $file)); + $this->template->assign_vars($vars); + + foreach ($block_vars as $block => $loops) + { + foreach ($loops as $_vars) + { + $this->template->assign_block_vars($block, $_vars); + } + } + + foreach ($destroy as $block) + { + $this->template->destroy_block_vars($block); + } + + try + { + $this->assertEquals($expected, $this->display('test'), "Testing $file"); + $this->assertFileExists($cache_file); + } + catch (ErrorException $e) + { + if (file_exists($cache_file)) + { + copy($cache_file, str_replace('ctpl_', 'tests_ctpl_', $cache_file)); + } + + throw $e; + } + + // For debugging + if (self::PRESERVE_CACHE) + { + copy($cache_file, str_replace('ctpl_', 'tests_ctpl_', $cache_file)); + } + } + + /** + * @dataProvider template_data + */ + public function test_template($file, array $vars, array $block_vars, array $destroy, $expected) + { + global $phpEx; + $cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.' . $phpEx; + + $this->assertFileNotExists($cache_file); + + $this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file); + + // Reset the engine state + $this->setup_engine(); + + $this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file); + } + + /** + * @dataProvider template_data + */ + public function test_assign_display($file, array $vars, array $block_vars, array $destroy, $expected) + { + $this->template->set_filenames(array( + 'test' => $file, + 'container' => 'variable.html', + )); + $this->template->assign_vars($vars); + + foreach ($block_vars as $block => $loops) + { + foreach ($loops as $_vars) + { + $this->template->assign_block_vars($block, $_vars); + } + } + + foreach ($destroy as $block) + { + $this->template->destroy_block_vars($block); + } + + $error_level = error_reporting(); + error_reporting($error_level & ~E_NOTICE); + + $this->assertEquals($expected, self::trim_template_result($this->template->assign_display('test')), "Testing assign_display($file)"); + + $this->template->assign_display('test', 'VARIABLE', false); + + error_reporting($error_level); + + $this->assertEquals($expected, $this->display('container'), "Testing assign_display($file)"); + } + + public function test_php() + { + global $phpEx; + + $GLOBALS['config']['tpl_allow_php'] = true; + + $cache_file = $this->template->cachepath . 'php.html.' . $phpEx; + + $this->assertFileNotExists($cache_file); + + $this->run_template('php.html', array(), array(), array(), 'test', $cache_file); + + $GLOBALS['config']['tpl_allow_php'] = false; + } + + public function test_includephp() + { + $this->markTestIncomplete('Include PHP test file paths are broken'); + + $GLOBALS['config']['tpl_allow_php'] = true; + + $cache_file = $this->template->cachepath . 'includephp.html.' . PHP_EXT; + + $cwd = getcwd(); + chdir(dirname(__FILE__) . '/templates'); + + $this->run_template('includephp.html', array(), array(), array(), 'testing included php', $cache_file); + + $this->template->set_filenames(array('test' => 'includephp.html')); + $this->assertEquals('testing included php', $this->display('test'), "Testing $file"); + + chdir($cwd); + + $GLOBALS['config']['tpl_allow_php'] = false; + } + + public static function alter_block_array_data() + { + return array( + array( + 'outer', + array('VARIABLE' => 'before'), + false, + 'insert', + << 'after'), + true, + 'insert', + << 'pos #1'), + 1, + 'insert', + << 'pos #1'), + 0, + 'change', + << 'before'), + false, + 'insert', + << 'after'), + true, + 'insert', + << 'pos #1'), + 1, + 'insert', + << 'before'), + false, + 'insert', + << 'before'), + false, + 'insert', + << 'before'), + false, + 'insert', + <<markTestIncomplete('Alter Block Test is broken'); + + $this->template->set_filenames(array('test' => 'loop_nested.html')); + + // @todo Change this + $this->template->assign_block_vars('outer', array()); + $this->template->assign_block_vars('outer.middle', array()); + $this->template->assign_block_vars('outer.middle', array()); + $this->template->assign_block_vars('outer', array()); + $this->template->assign_block_vars('outer.middle', array()); + $this->template->assign_block_vars('outer.middle', array()); + $this->template->assign_block_vars('outer.middle', array()); + $this->template->assign_block_vars('outer', array()); + $this->template->assign_block_vars('outer.middle', array()); + $this->template->assign_block_vars('outer.middle', array()); + + $this->assertEquals("outer - 0/3\nmiddle - 0/2\nmiddle - 1/2\nouter - 1/3\nmiddle - 0/3\nmiddle - 1/3\nmiddle - 2/3\nouter - 2/3\nmiddle - 0/2\nmiddle - 1/2", $this->display('test'), 'Ensuring template is built correctly before modification'); + + $this->template->alter_block_array($alter_block, $vararray, $key, $mode); + $this->assertEquals($expect, $this->display('test'), $description); + } +} + diff --git a/tests/template/templates/_dummy_include.php b/tests/template/templates/_dummy_include.php new file mode 100644 index 0000000000..1de5dddf59 --- /dev/null +++ b/tests/template/templates/_dummy_include.php @@ -0,0 +1,3 @@ + +fail + + +pass + + +fail + +fail + +pass + + +fail + +pass + + + diff --git a/tests/template/templates/define.html b/tests/template/templates/define.html new file mode 100644 index 0000000000..82237d21a3 --- /dev/null +++ b/tests/template/templates/define.html @@ -0,0 +1,8 @@ + +{$VALUE} + +{$VALUE} + +{$VALUE} + + diff --git a/tests/template/templates/expressions.html b/tests/template/templates/expressions.html new file mode 100644 index 0000000000..c40d967dab --- /dev/null +++ b/tests/template/templates/expressions.html @@ -0,0 +1,86 @@ +passfail + +failpass + +failpass + +passfail + +failpass + +passfail + +failpass + +passfail + +passfail + +passfail + + +passfail + +passfail + +passfail + +passfail + + +passfail + +passfail + + +passfail + +passfail + +passfail + +passfail + +passfail + +passfail + + +passfail + +passfail + + +passfail + +passfail + +passfail + +passfail + +passfail + +passfail + + +passfail + +passfail + + +passfail + +passfail + + +passfail + +passfail + +passfail + + +passfail + +passfail diff --git a/tests/template/templates/if.html b/tests/template/templates/if.html new file mode 100644 index 0000000000..c502e52f51 --- /dev/null +++ b/tests/template/templates/if.html @@ -0,0 +1,11 @@ + +1 + +2 + +0 + + + +0 + diff --git a/tests/template/templates/include.html b/tests/template/templates/include.html new file mode 100644 index 0000000000..730d713d65 --- /dev/null +++ b/tests/template/templates/include.html @@ -0,0 +1 @@ + diff --git a/tests/template/templates/includephp.html b/tests/template/templates/includephp.html new file mode 100644 index 0000000000..3e13fa33fa --- /dev/null +++ b/tests/template/templates/includephp.html @@ -0,0 +1 @@ + diff --git a/tests/template/templates/lang.html b/tests/template/templates/lang.html new file mode 100644 index 0000000000..2b5ea1cafe --- /dev/null +++ b/tests/template/templates/lang.html @@ -0,0 +1,3 @@ +{L_VARIABLE} + +{LA_VARIABLE} diff --git a/tests/template/templates/loop.html b/tests/template/templates/loop.html new file mode 100644 index 0000000000..de1a10004d --- /dev/null +++ b/tests/template/templates/loop.html @@ -0,0 +1,21 @@ + +loop + +noloop + + + +loop + +noloop + + + +loop + + + + +loop#{loop.S_ROW_COUNT}-block#{block.S_ROW_COUNT} + + diff --git a/tests/template/templates/loop_advanced.html b/tests/template/templates/loop_advanced.html new file mode 100644 index 0000000000..c75fe55f03 --- /dev/null +++ b/tests/template/templates/loop_advanced.html @@ -0,0 +1,19 @@ +{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +x +{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +x +{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +x +{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +x +{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +x +{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +x +{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +x +{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +x +{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} +x +{loop.S_FIRST_ROW}{loop.S_ROW_COUNT}{loop.S_LAST_ROW} diff --git a/tests/template/templates/loop_nested.html b/tests/template/templates/loop_nested.html new file mode 100644 index 0000000000..571df97b4c --- /dev/null +++ b/tests/template/templates/loop_nested.html @@ -0,0 +1,8 @@ + + {outer.S_BLOCK_NAME} - {outer.S_ROW_NUM}/{outer.S_NUM_ROWS} - {outer.VARIABLE} + + + {middle.S_BLOCK_NAME} - {middle.S_ROW_NUM}/{middle.S_NUM_ROWS} - {middle.VARIABLE} + + + diff --git a/tests/template/templates/loop_vars.html b/tests/template/templates/loop_vars.html new file mode 100644 index 0000000000..4f02fd2e6c --- /dev/null +++ b/tests/template/templates/loop_vars.html @@ -0,0 +1,21 @@ + +first + +{loop.S_ROW_COUNT} + +{loop.VARIABLE} + +set + + +last + + + +{inner.S_ROW_COUNT} + +last inner + + + +inner loop diff --git a/tests/template/templates/php.html b/tests/template/templates/php.html new file mode 100644 index 0000000000..07a260cdb3 --- /dev/null +++ b/tests/template/templates/php.html @@ -0,0 +1 @@ +echo "test"; diff --git a/tests/template/templates/variable.html b/tests/template/templates/variable.html new file mode 100644 index 0000000000..f68f91597c --- /dev/null +++ b/tests/template/templates/variable.html @@ -0,0 +1 @@ +{VARIABLE} diff --git a/tests/test_framework/framework.php b/tests/test_framework/framework.php new file mode 100644 index 0000000000..3a11cc6df9 --- /dev/null +++ b/tests/test_framework/framework.php @@ -0,0 +1,43 @@ += 6.0.0 we do not need some code +if (version_compare(PHP_VERSION, '6.0.0-dev', '>=')) +{ + define('STRIP', false); +} +else +{ + @set_magic_quotes_runtime(0); + define('STRIP', (get_magic_quotes_gpc()) ? true : false); +} + +require_once $phpbb_root_path . 'includes/constants.php'; + +// require at least PHPUnit 3.3.0 +require_once 'PHPUnit/Runner/Version.php'; +if (version_compare(PHPUnit_Runner_Version::id(), '3.3.0', '<')) +{ + trigger_error('PHPUnit >= 3.3.0 required'); +} + +if (version_compare(PHPUnit_Runner_Version::id(), '3.5.0', '<')) +{ + require_once 'PHPUnit/Framework.php'; + require_once 'PHPUnit/Extensions/Database/TestCase.php'; +} + +require_once 'test_framework/phpbb_test_case_helpers.php'; +require_once 'test_framework/phpbb_test_case.php'; +require_once 'test_framework/phpbb_database_test_case.php'; diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php new file mode 100644 index 0000000000..a64bae8c57 --- /dev/null +++ b/tests/test_framework/phpbb_database_test_case.php @@ -0,0 +1,376 @@ +test_case_helpers) + { + $this->test_case_helpers = new phpbb_test_case_helpers($this); + } + + return $this->test_case_helpers; + } + + public function get_dbms_data($dbms) + { + $available_dbms = array( + 'firebird' => array( + 'SCHEMA' => 'firebird', + 'DELIM' => ';;', + 'PDO' => 'firebird', + ), + 'mysqli' => array( + 'SCHEMA' => 'mysql_41', + 'DELIM' => ';', + 'PDO' => 'mysql', + ), + 'mysql' => array( + 'SCHEMA' => 'mysql', + 'DELIM' => ';', + 'PDO' => 'mysql', + ), + 'mssql' => array( + 'SCHEMA' => 'mssql', + 'DELIM' => 'GO', + 'PDO' => 'odbc', + ), + 'mssql_odbc'=> array( + 'SCHEMA' => 'mssql', + 'DELIM' => 'GO', + 'PDO' => 'odbc', + ), + 'mssqlnative' => array( + 'SCHEMA' => 'mssql', + 'DELIM' => 'GO', + 'PDO' => 'sqlsrv', + ), + 'oracle' => array( + 'SCHEMA' => 'oracle', + 'DELIM' => '/', + 'PDO' => 'oci', + ), + 'postgres' => array( + 'SCHEMA' => 'postgres', + 'DELIM' => ';', + 'PDO' => 'pgsql', + ), + 'sqlite' => array( + 'SCHEMA' => 'sqlite', + 'DELIM' => ';', + 'PDO' => 'sqlite2', + ), + ); + + if (isset($available_dbms[$dbms])) + { + return $available_dbms[$dbms]; + } + else + { + trigger_error('Database unsupported', E_USER_ERROR); + } + } + + public function get_database_config() + { + if (isset($_SERVER['PHPBB_TEST_DBMS'])) + { + return array( + 'dbms' => isset($_SERVER['PHPBB_TEST_DBMS']) ? $_SERVER['PHPBB_TEST_DBMS'] : '', + 'dbhost' => isset($_SERVER['PHPBB_TEST_DBHOST']) ? $_SERVER['PHPBB_TEST_DBHOST'] : '', + 'dbport' => isset($_SERVER['PHPBB_TEST_DBPORT']) ? $_SERVER['PHPBB_TEST_DBPORT'] : '', + 'dbname' => isset($_SERVER['PHPBB_TEST_DBNAME']) ? $_SERVER['PHPBB_TEST_DBNAME'] : '', + 'dbuser' => isset($_SERVER['PHPBB_TEST_DBUSER']) ? $_SERVER['PHPBB_TEST_DBUSER'] : '', + 'dbpasswd' => isset($_SERVER['PHPBB_TEST_DBPASSWD']) ? $_SERVER['PHPBB_TEST_DBPASSWD'] : '', + ); + } + else if (file_exists('test_config.php')) + { + include('test_config.php'); + + return array( + 'dbms' => $dbms, + 'dbhost' => $dbhost, + 'dbport' => $dbport, + 'dbname' => $dbname, + 'dbuser' => $dbuser, + 'dbpasswd' => $dbpasswd, + ); + } + else if (extension_loaded('sqlite') && version_compare(PHPUnit_Runner_Version::id(), '3.4.15', '>=')) + { + // Silently use sqlite + return array( + 'dbms' => 'sqlite', + 'dbhost' => 'phpbb_unit_tests.sqlite2', // filename + 'dbport' => '', + 'dbname' => '', + 'dbuser' => '', + 'dbpasswd' => '', + ); + } + else + { + $this->markTestSkipped('Missing test_config.php: See first error.'); + } + } + + // NOTE: This function is not the same as split_sql_file from functions_install + public function split_sql_file($sql, $dbms) + { + $dbms_data = $this->get_dbms_data($dbms); + + $sql = str_replace("\r" , '', $sql); + $data = preg_split('/' . preg_quote($dbms_data['DELIM'], '/') . '$/m', $sql); + + $data = array_map('trim', $data); + + // The empty case + $end_data = end($data); + + if (empty($end_data)) + { + unset($data[key($data)]); + } + + if ($dbms == 'sqlite') + { + // remove comment lines starting with # - they are not proper sqlite + // syntax and break sqlite2 + foreach ($data as $i => $query) + { + $data[$i] = preg_replace('/^#.*$/m', "\n", $query); + } + } + + return $data; + } + + /** + * Retrieves a list of all tables from the database. + * + * @param PDO $pdo + * @param string $dbms + * @return array(string) + */ + function get_tables($pdo, $dbms) + { + switch ($pdo) + { + case 'mysql': + case 'mysql4': + case 'mysqli': + $sql = 'SHOW TABLES'; + break; + + case 'sqlite': + $sql = 'SELECT name + FROM sqlite_master + WHERE type = "table"'; + break; + + case 'mssql': + case 'mssql_odbc': + case 'mssqlnative': + $sql = "SELECT name + FROM sysobjects + WHERE type='U'"; + break; + + case 'postgres': + $sql = 'SELECT relname + FROM pg_stat_user_tables'; + break; + + case 'firebird': + $sql = 'SELECT rdb$relation_name + FROM rdb$relations + WHERE rdb$view_source is null + AND rdb$system_flag = 0'; + break; + + case 'oracle': + $sql = 'SELECT table_name + FROM USER_TABLES'; + break; + } + + $result = $pdo->query($sql); + + $tables = array(); + while ($row = $result->fetch(PDO::FETCH_NUM)) + { + $tables[] = current($row); + } + + return $tables; + } + + /** + * Returns a PDO connection for the configured database. + * + * @param array $config The database configuration + * @param array $dbms Information on the used DBMS. + * @param bool $use_db Whether the DSN should be tied to a + * particular database making it impossible + * to delete that database. + * @return PDO The PDO database connection. + */ + public function new_pdo($config, $dbms, $use_db) + { + $dsn = $dbms['PDO'] . ':'; + + switch ($dbms['PDO']) + { + case 'sqlite2': + $dsn .= $config['dbhost']; + break; + + case 'sqlsrv': + // prefix the hostname (or DSN) with Server= so using just (local)\SQLExpress + // works for example, further parameters can still be appended using ;x=y + $dsn .= 'Server='; + // no break -> rest like ODBC + case 'odbc': + // for ODBC assume dbhost is a suitable DSN + // e.g. Driver={SQL Server Native Client 10.0};Server=(local)\SQLExpress; + $dsn .= $config['dbhost']; + + if ($use_db) + { + $dsn .= ';Database=' . $config['dbname']; + } + break; + + default: + $dsn .= 'host=' . $config['dbhost']; + + if ($use_db) + { + $dsn .= ';dbname=' . $config['dbname']; + } + break; + } + + $pdo = new PDO($dsn, $config['dbuser'], $config['dbpasswd']);; + + // good for debug + // $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + + return $pdo; + } + + private function recreate_db($config, $dbms) + { + switch ($config['dbms']) + { + case 'sqlite': + if (file_exists($config['dbhost'])) + { + unlink($config['dbhost']); + } + break; + + default: + $pdo = $this->new_pdo($config, $dbms, false); + + try + { + $pdo->exec('DROP DATABASE ' . $config['dbname']); + } + catch (PDOException $e) + { + // try to delete all tables if dropping the database was not possible. + foreach ($this->get_tables() as $table) + { + try + { + $pdo->exec('DROP TABLE ' . $table); + } + catch (PDOException $e){} // ignore non-existent tables + } + } + + $pdo->exec('CREATE DATABASE ' . $config['dbname']); + break; + } + } + + private function load_schema($pdo, $config, $dbms) + { + if ($config['dbms'] == 'mysql') + { + $sth = $pdo->query('SELECT VERSION() AS version'); + $row = $sth->fetch(PDO::FETCH_ASSOC); + + if (version_compare($row['version'], '4.1.3', '>=')) + { + $dbms['SCHEMA'] .= '_41'; + } + else + { + $dbms['SCHEMA'] .= '_40'; + } + } + + $sql = $this->split_sql_file(file_get_contents("../phpBB/install/schemas/{$dbms['SCHEMA']}_schema.sql"), $config['dbms']); + + foreach ($sql as $query) + { + $pdo->exec($query); + } + } + + public function getConnection() + { + $config = $this->get_database_config(); + $dbms = $this->get_dbms_data($config['dbms']); + + if (!self::$already_connected) + { + $this->recreate_db($config, $dbms); + } + + $pdo = $this->new_pdo($config, $dbms, true); + + if (!self::$already_connected) + { + $this->load_schema($pdo, $config, $dbms); + + self::$already_connected = true; + } + + return $this->createDefaultDBConnection($pdo, 'testdb'); + } + + public function new_dbal() + { + global $phpbb_root_path, $phpEx; + + $config = $this->get_database_config(); + + require_once '../phpBB/includes/db/' . $config['dbms'] . '.php'; + $dbal = 'dbal_' . $config['dbms']; + $db = new $dbal(); + $db->sql_connect($config['dbhost'], $config['dbuser'], $config['dbpasswd'], $config['dbname'], $config['dbport']); + + return $db; + } + + public function setExpectedTriggerError($errno, $message = '') + { + $this->get_test_case_helpers()->setExpectedTriggerError($errno, $message); + } +} diff --git a/tests/test_framework/phpbb_test_case.php b/tests/test_framework/phpbb_test_case.php new file mode 100644 index 0000000000..fe90d321dc --- /dev/null +++ b/tests/test_framework/phpbb_test_case.php @@ -0,0 +1,28 @@ +test_case_helpers) + { + $this->test_case_helpers = new phpbb_test_case_helpers($this); + } + + return $this->test_case_helpers; + } + + public function setExpectedTriggerError($errno, $message = '') + { + $this->get_test_case_helpers()->setExpectedTriggerError($errno, $message); + } +} diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php new file mode 100644 index 0000000000..0acdce32e0 --- /dev/null +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -0,0 +1,44 @@ +test_case = $test_case; + } + + public function setExpectedTriggerError($errno, $message = '') + { + $exceptionName = ''; + switch ($errno) + { + case E_NOTICE: + case E_STRICT: + PHPUnit_Framework_Error_Notice::$enabled = true; + $exceptionName = 'PHPUnit_Framework_Error_Notice'; + break; + + case E_WARNING: + PHPUnit_Framework_Error_Warning::$enabled = true; + $exceptionName = 'PHPUnit_Framework_Error_Warning'; + break; + + default: + $exceptionName = 'PHPUnit_Framework_Error'; + break; + } + $this->expectedTriggerError = true; + $this->test_case->setExpectedException($exceptionName, (string) $message, $errno); + } +} diff --git a/tests/text_processing/all_tests.php b/tests/text_processing/all_tests.php new file mode 100644 index 0000000000..5e759c72ee --- /dev/null +++ b/tests/text_processing/all_tests.php @@ -0,0 +1,41 @@ +addTestSuite('phpbb_text_processing_make_clickable_test'); + + return $suite; + } +} + +if (PHPUnit_MAIN_METHOD == 'phpbb_text_processing_all_tests::main') +{ + phpbb_text_processing_all_tests::main(); +} + diff --git a/tests/text_processing/make_clickable.php b/tests/text_processing/make_clickable.php new file mode 100644 index 0000000000..a667dd705e --- /dev/null +++ b/tests/text_processing/make_clickable.php @@ -0,0 +1,106 @@ + whether it should work + $prefix_texts = array( + '' => true, + "np \n" => true, + 'bp text ' => true, + 'cp text>' => true, + 'ep text.' => array('w' => false), // doesn't work for www. type urls, but for everything else + ); + $suffix_texts = array( + '' => true, + "\n ns" => true, + ' bs text.' => true, + '>cs text' => true, + '"ds text' => true, + '. es text.' => true, + ', fs text.' => true, + ); + + $urls = array( + 'http://example.com' => array('tag' => 'm', 'url' => false, 'text' => false), // false means same as key + 'http://example.com/' => array('tag' => 'm', 'url' => false, 'text' => false), + 'http://example.com/path?query=abc' => array('tag' => 'm', 'url' => false, 'text' => false), + 'http://example.com/1' => array('tag' => 'm', 'url' => false, 'text' => false), + 'http://example.com/some/very/long/path/with/over/55/characters?and=a&long=query&too=1' => array('tag' => 'm', 'url' => false, 'text' => 'http://example.com/some/very/long/path/ ... uery&too=1'), + 'http://localhost' => array('tag' => 'm', 'url' => false, 'text' => false), + 'http://localhost/#abc' => array('tag' => 'm', 'url' => false, 'text' => false), + + 'www.example.com/path/' => array('tag' => 'w', 'url' => 'http://www.example.com/path/', 'text' => false), + 'randomwww.example.com/path/' => false, + + 'http://thisdomain.org' => array('tag' => 'm', 'url' => false, 'text' => false), + 'http://thisdomain.org/' => array('tag' => 'm', 'url' => false, 'text' => false), + 'http://thisdomain.org/1' => array('tag' => 'l', 'url' => false, 'text' => '1'), + 'http://thisdomain.org/path/some?query=abc#test' => array('tag' => 'l', 'url' => false, 'text' => 'path/some?query=abc#test'), + + 'javascript:www.example.com/' => false, + ); + + $test_data = array(); + + // run the test for each combination + foreach ($prefix_texts as $prefix => $prefix_success) + { + foreach ($suffix_texts as $suffix => $suffix_success) + { + foreach ($urls as $url => $url_type) + { + $input = $prefix . $url . $suffix; + // no valid url => no change + $output = $input; + + if ( + ($prefix_success && $suffix_success && is_array($url_type)) && + // handle except syntax for prefix/suffix + (!is_array($prefix_success) || !isset($prefix_success[$url_type['tag']]) || $prefix_success[$url_type['tag']] == true) && + (!is_array($suffix_success) || !isset($suffix_success[$url_type['tag']]) || $suffix_success[$url_type['tag']] == true) + ) + { + // false means it's the same as the url, less typing + $url_type['url'] = ($url_type['url']) ? $url_type['url'] : $url; + $url_type['text'] = ($url_type['text']) ? $url_type['text'] : $url; + + $class = ($url_type['tag'] === 'l') ? 'postlink-local' : 'postlink'; + + // replace the url with the desired output format + $output = $prefix . '' . $url_type['text'] . '' . $suffix; + } + $test_data[] = array($input, $output); + } + } + } + + return $test_data; + } + + /** + * @dataProvider make_clickable_data + */ + public function test_make_clickable($input, $expected) + { + $result = make_clickable($input, 'http://thisdomain.org'); + + $label = 'Making text clickable: ' . $input; + $this->assertEquals($expected, $result, $label); + } + +} + diff --git a/tests/utf/all_tests.php b/tests/utf/all_tests.php new file mode 100644 index 0000000000..0d5d44d695 --- /dev/null +++ b/tests/utf/all_tests.php @@ -0,0 +1,43 @@ +addTestSuite('phpbb_utf_utf8_wordwrap_test'); + $suite->addTestSuite('phpbb_utf_utf8_clean_string_test'); + + return $suite; + } +} + +if (PHPUnit_MAIN_METHOD == 'phpbb_utf_all_tests::main') +{ + phpbb_utf_all_tests::main(); +} + diff --git a/tests/utf/utf8_clean_string_test.php b/tests/utf/utf8_clean_string_test.php new file mode 100644 index 0000000000..870ad76fc4 --- /dev/null +++ b/tests/utf/utf8_clean_string_test.php @@ -0,0 +1,32 @@ +assertEquals($output, utf8_clean_string($input), $label); + } +} + diff --git a/tests/utf/utf8_wordwrap_test.php b/tests/utf/utf8_wordwrap_test.php new file mode 100644 index 0000000000..ef1165a897 --- /dev/null +++ b/tests/utf/utf8_wordwrap_test.php @@ -0,0 +1,84 @@ +assertEquals($php_wordwrap, $phpbb_utf8_wordwrap, "Checking ASCII standard behaviour with length 20"); + + $php_wordwrap = wordwrap($text, 30, "
        \n"); + $phpbb_utf8_wordwrap = utf8_wordwrap($text, 30, "
        \n"); + $this->assertEquals($php_wordwrap, $phpbb_utf8_wordwrap, "Checking ASCII special break string with length 30"); + + $text = 'A very long woooooooooooord.'; + + $php_wordwrap = wordwrap($text, 8, "\n"); + $phpbb_utf8_wordwrap = utf8_wordwrap($text, 8, "\n"); + $this->assertEquals($php_wordwrap, $phpbb_utf8_wordwrap, 'Checking ASCII not cutting long words'); + + $php_wordwrap = wordwrap($text, 8, "\n", true); + $phpbb_utf8_wordwrap = utf8_wordwrap($text, 8, "\n", true); + $this->assertEquals($php_wordwrap, $phpbb_utf8_wordwrap, 'Checking ASCII cutting long words'); + } + + /** + * Helper function that generates meaningless greek text + */ + private function turn_into_greek($string) + { + $greek_chars = array("\xCE\x90", "\xCE\x91", "\xCE\x92", "\xCE\x93", "\xCE\x94", "\xCE\x95", "\xCE\x96", "\xCE\x97", "\xCE\x98", "\xCE\x99"); + + $greek = ''; + for ($i = 0, $n = strlen($string); $i < $n; $i++) + { + // replace each number with the character from the array + if (ctype_digit($string[$i])) + { + $greek .= $greek_chars[(int) $string[$i]]; + } + else + { + $greek .= $string[$i]; + } + } + + return $greek; + } + + public function test_utf8_wordwrap_utf8() + { + $text = "0123456 0123 012345 01234"; + $greek = $this->turn_into_greek($text); + + $expected = $this->turn_into_greek(wordwrap($text, 10)); + $phpbb_utf8_wordwrap = utf8_wordwrap($greek, 10); + $this->assertEquals($expected, $phpbb_utf8_wordwrap, 'Checking UTF-8 standard behaviour with length 10'); + } + + public function test_utf8_wordwrap_utf8_cut() + { + $text = "0123456 0123 012345 01234"; + $greek = $this->turn_into_greek($text); + + $expected = $this->turn_into_greek(wordwrap($text, 5, "\n", true)); + $phpbb_utf8_wordwrap = utf8_wordwrap($greek, 5, "\n", true); + $this->assertEquals($expected, $phpbb_utf8_wordwrap, 'Checking UTF-8 cutting long words'); + } +} +