1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-09-09 07:40:45 +02:00

Compare commits

..

1 Commits

Author SHA1 Message Date
(no author)
22bb74f32f This commit was manufactured by cvs2svn to create tag 'milestone_3'.
git-svn-id: file:///svn/phpbb/tags/milestone_3@5258 89ea8834-ac86-4346-8a33-228a782c2dd0
2005-10-04 21:47:20 +00:00
2640 changed files with 72480 additions and 379699 deletions

View File

@@ -1,18 +0,0 @@
# This file is for standardising the coding style between different editors
# http://editorconfig.org/
root = true
[*]
end_of_line = lf
indent_size = 4
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false
[*.yml]
indent_size = 4
indent_style = space

24
.gitignore vendored
View File

@@ -1,24 +0,0 @@
*~
/phpunit.xml
/phpBB/cache/*
!/phpBB/cache/.htaccess
!/phpBB/cache/index.html
/phpBB/composer.phar
/phpBB/config*.php
/phpBB/ext/*
/phpBB/files/*
/phpBB/images/avatars/gallery/*
/phpBB/images/avatars/upload/*
/phpBB/images/ranks/*
/phpBB/install/schemas/schema.json
/phpBB/language/*
!/phpBB/language/en
/phpBB/store/*
/phpBB/styles/*
!/phpBB/styles/prosilver
!/phpBB/styles/all
/phpBB/vendor
/tests/phpbb_unit_tests.sqlite*
/tests/test_config*.php
/tests/tmp/*
/tests/vendor

78
.jscsrc
View File

@@ -1,78 +0,0 @@
{
"excludeFiles": ["node_modules/**", "**/build/**"],
"requireCurlyBraces": [
"if", "else", "for", "while", "do", "try", "catch"
],
"requireSpaceBeforeKeywords": [
"else", "while", "catch"
],
"requireSpaceAfterKeywords": [
"do", "for", "if", "else", "switch", "case", "try", "catch", "while", "return", "typeof"
],
"requireSpaceBeforeBlockStatements": true,
"requireParenthesesAroundIIFE": true,
"requireSpacesInConditionalExpression": {
"afterTest": true,
"beforeConsequent": true,
"afterConsequent": true,
"beforeAlternate": true
},
"requireSpacesInAnonymousFunctionExpression": {
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInNamedFunctionExpression": {
"beforeOpeningRoundBrace": true
},
"requireSpacesInFunction": {
"beforeOpeningCurlyBrace": true
},
"disallowSpacesInCallExpression": true,
"requireBlocksOnNewline": true,
"requirePaddingNewlinesBeforeKeywords": ["case"],
"disallowEmptyBlocks": true,
"disallowSpacesInsideArrayBrackets": "nested",
"disallowSpacesInsideParentheses": true,
"requireSpacesInsideObjectBrackets": "all",
"disallowQuotedKeysInObjects": "allButReserved",
"disallowSpaceAfterObjectKeys": true,
"requireSpaceBeforeObjectValues": true,
"requireCommaBeforeLineBreak": true,
"requireOperatorBeforeLineBreak": [
"?", "=", "+", "-", "/", "*", "===", "!==", ">", ">=", "<", "<="
],
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
"requireSpaceBeforeBinaryOperators": [
"=", "+", "+=", "-", "-=", "/", "/=", "*", "*=", "===", "!==", "<", "<=", ">", ">="
],
"requireSpaceAfterBinaryOperators": [
"=", "+", "+=", "-", "-=", "/", "/=", "*", "*=", "===", "!==", "<", "<=", ">", ">="
],
"disallowKeywords": ["with"],
"disallowMultipleLineStrings": true,
"disallowMixedSpacesAndTabs": "smart",
"disallowTrailingWhitespace": true,
"disallowTrailingComma": true,
"disallowKeywordsOnNewLine": ["else"],
"requireLineFeedAtFileEnd": true,
"maximumLineLength": {
"value": 120,
"tabSize": 4,
"allowUrlComments": true,
"allowRegex": true
},
"requireCapitalizedConstructors": true,
"requireDotNotation": true,
"disallowYodaConditions": true,
"requireSpaceAfterLineComment": {
"allExcept": ["#", "="]
},
"disallowNewlineBeforeBlockStatements": true,
"validateQuoteMarks": {
"mark": "'",
"escape": true
},
"validateParameterSeparator": ", ",
"safeContextKeyword": ["that"]
}

View File

@@ -1,24 +0,0 @@
{
"bitwise": true,
"curly": true,
"eqeqeq": true,
"es3": true,
"forin": false,
"freeze": true,
"newcap": true,
"noarg": true,
"noempty": true,
"nonbsp": true,
"undef": true,
"unused": true,
"strict": true,
"browser": true,
"devel": true,
"jquery": true,
"globals": {
"JSON": true
}
}

View File

@@ -1,49 +0,0 @@
language: php
matrix:
include:
- php: 5.4
env: DB=none;NOTESTS=1
- php: 5.4
env: DB=mysqli # MyISAM
- php: 5.4
env: DB=mysql
- php: 5.4
env: DB=mariadb
- php: 5.4
env: DB=postgres
- php: 5.4
env: DB=sqlite3
- php: 5.4
env: DB=mysqli;SLOWTESTS=1
- php: 5.5
env: DB=mysqli
- php: 5.6
env: DB=mysqli
- php: 7.0
env: DB=mysqli
- php: hhvm
env: DB=mysqli
allow_failures:
- php: hhvm
fast_finish: true
services:
- redis-server
install:
- travis/setup-phpbb.sh $DB $TRAVIS_PHP_VERSION $NOTESTS
before_script:
- travis/setup-database.sh $DB $TRAVIS_PHP_VERSION $NOTESTS
- phantomjs --webdriver=8910 > /dev/null &
script:
- travis/phing-sniff.sh $DB $TRAVIS_PHP_VERSION $NOTESTS
- travis/check-sami-parse-errors.sh $DB $TRAVIS_PHP_VERSION $NOTESTS
- travis/check-image-icc-profiles.sh $DB $TRAVIS_PHP_VERSION $NOTESTS
- travis/check-executable-files.sh $DB $TRAVIS_PHP_VERSION $NOTESTS ./
- sh -c "if [ '$SLOWTESTS' != '1' -a '$DB' = 'mysqli' ]; then phpBB/vendor/bin/phpunit tests/lint_test.php; fi"
- sh -c "if [ '$NOTESTS' != '1' -a '$SLOWTESTS' != '1' ]; then phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml; fi"
- sh -c "if [ '$SLOWTESTS' = '1' ]; then phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml --group slow; fi"
- sh -c "set -x;if [ '$NOTESTS' = '1' -a '$TRAVIS_PULL_REQUEST' != 'false' ]; then git-tools/commit-msg-hook-range.sh origin/$TRAVIS_BRANCH..FETCH_HEAD; fi"

View File

@@ -1,6 +0,0 @@
## CONTRIBUTE
1. [Create an account on phpBB.com](http://www.phpbb.com/community/ucp.php?mode=register)
2. [Create a ticket (unless there already is one)](http://tracker.phpbb.com/secure/CreateIssue!default.jspa)
3. Read our [Coding guidelines](https://wiki.phpbb.com/Coding_guidelines) and [Git Contribution Guidelines](http://wiki.phpbb.com/Git); if you're new to git, also read [the introduction guide](http://wiki.phpbb.com/display/DEV/Working+with+Git)
4. Send us a pull request

View File

@@ -1,36 +0,0 @@
[![phpBB](https://www.phpbb.com/theme/images/logos/blue/160x52.png)](http://www.phpbb.com)
## ABOUT
phpBB is a free bulletin board written in PHP.
## COMMUNITY
Find support and lots more on [phpBB.com](http://www.phpbb.com)! Discuss the development on [area51](http://area51.phpbb.com/phpBB/index.php).
## INSTALLING DEPENDENCIES
To be able to run an installation from the repo (and not from a pre-built package) you need to run the following commands to install phpBB's dependencies.
cd phpBB
php ../composer.phar install --dev
## CONTRIBUTE
1. [Create an account on phpBB.com](http://www.phpbb.com/community/ucp.php?mode=register)
2. [Create a ticket (unless there already is one)](http://tracker.phpbb.com/secure/CreateIssue!default.jspa)
3. [Read our Git Contribution Guidelines](http://wiki.phpbb.com/Git); if you're new to git, also read [the introduction guide](http://wiki.phpbb.com/display/DEV/Working+with+Git)
4. Send us a pull request
## AUTOMATED TESTING
We have unit and functional tests in order to prevent regressions. You can view the bamboo continuous integration [here](http://bamboo.phpbb.com) or check our travis build below:
* [![Build Status](https://secure.travis-ci.org/phpbb/phpbb.png?branch=master)](http://travis-ci.org/phpbb/phpbb) **master** - Latest development version
* [![Build Status](https://secure.travis-ci.org/phpbb/phpbb.png?branch=3.1.x)](http://travis-ci.org/phpbb/phpbb) **3.1.x** - Development of version 3.1.x
* [![Build Status](https://secure.travis-ci.org/phpbb/phpbb.png?branch=3.0.x)](http://travis-ci.org/phpbb/phpbb) **3.0.x** - Development of version 3.0.x
## LICENSE
[GNU General Public License v2](http://opensource.org/licenses/gpl-2.0.php)

View File

@@ -1,487 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="phpBB" description="The phpBB forum software" default="all" basedir="../">
<!-- a few settings for the build -->
<property name="newversion" value="3.2.0-b2" />
<property name="prevversion" value="3.2.0-b1" />
<property name="olderversions" value="3.0.14, 3.1.0, 3.1.1, 3.1.2, 3.1.3, 3.1.4, 3.1.5, 3.1.6, 3.1.7, 3.1.7-pl1, 3.1.8, 3.2.0-a1, 3.2.0-a2" />
<!-- no configuration should be needed beyond this point -->
<property name="oldversions" value="${olderversions}, ${prevversion}" />
<property name="versions" value="${oldversions}, ${newversion}" />
<!-- These are the main targets which you will probably want to use -->
<target name="all" depends="clean,prepare,composer,test,docs,package" />
<target name="build" depends="clean,prepare,composer,test,docs" />
<target name="prepare">
<mkdir dir="build/logs" />
<mkdir dir="build/api" />
<mkdir dir="build/codebrowser" />
<mkdir dir="build/coverage" />
<mkdir dir="build/cpd" />
<mkdir dir="build/dependencies" />
<mkdir dir="build/new_version" />
<mkdir dir="build/new_version/files" />
<mkdir dir="build/new_version/patches" />
<mkdir dir="build/new_version/release_files" />
<mkdir dir="build/new_version/update" />
<mkdir dir="build/old_versions" />
<mkdir dir="build/save" />
</target>
<target name="clean">
<delete dir="build/logs" />
<delete dir="build/api" />
<delete dir="build/codebrowser" />
<delete dir="build/coverage" />
<delete dir="build/cpd" />
<delete dir="build/dependencies" />
<delete dir="build/new_version" />
<delete dir="build/old_versions" />
<delete dir="build/save" />
</target>
<!--
This target basically just runs composer in the phpBB tree to ensure
all dependencies are loaded. Additional development dependencies are
loaded because testing framework may depend on them.
-->
<target name="composer">
<exec dir="phpBB"
command="php ../composer.phar install --dev"
checkreturn="true"
passthru="true" />
</target>
<target name="test" depends="clean,prepare,composer">
<exec dir="."
command="phpBB/vendor/bin/phpunit
--log-junit build/logs/phpunit.xml
--coverage-clover build/logs/clover.xml
--coverage-html build/coverage"
passthru="true" />
</target>
<target name="test-slow" depends="clean,prepare,composer">
<exec dir="."
command="phpBB/vendor/bin/phpunit
--log-junit build/logs/phpunit.xml
--group slow
--coverage-clover build/logs/clover-slow.xml
--coverage-html build/coverage-slow"
passthru="true" />
</target>
<target name="sniff">
<exec command="phpBB/vendor/bin/phpcs
-s -p
--extensions=php
--standard=build/code_sniffer/ruleset-php-strict-core.xml
--ignore=${project.basedir}/phpBB/phpbb/db/migration/data/v30x/*
phpBB/phpbb"
dir="." returnProperty="retval-php-strict" passthru="true" />
<exec command="phpBB/vendor/bin/phpcs
-s -p
--extensions=php
--standard=build/code_sniffer/ruleset-php-legacy-core.xml
--ignore=${project.basedir}/phpBB/cache/*
--ignore=${project.basedir}/phpBB/develop/*
--ignore=${project.basedir}/phpBB/ext/*
--ignore=${project.basedir}/phpBB/includes/diff/*.php
--ignore=${project.basedir}/phpBB/includes/sphinxapi.php
--ignore=${project.basedir}/phpBB/includes/utf/data/*
--ignore=${project.basedir}/phpBB/install/data/*
--ignore=${project.basedir}/phpBB/install/database_update.php
--ignore=${project.basedir}/phpBB/phpbb/*
--ignore=${project.basedir}/phpBB/vendor/*
phpBB"
dir="." returnProperty="retval-php-legacy" passthru="true" />
<exec command="phpBB/vendor/bin/phpcs
-s -p
--extensions=php
--standard=build/code_sniffer/ruleset-php-extensions.xml
--ignore=${project.basedir}/phpBB/ext/*/tests/*
--ignore=${project.basedir}/phpBB/ext/*/vendor/*
phpBB/ext"
dir="." returnProperty="retval-php-ext" passthru="true" />
<if>
<or>
<not><equals arg1="${retval-php-strict}" arg2="0" /></not>
<not><equals arg1="${retval-php-legacy}" arg2="0" /></not>
<not><equals arg1="${retval-php-ext}" arg2="0" /></not>
</or>
<then>
<fail message="PHP Code Sniffer failed." />
</then>
</if>
</target>
<!-- Builds docs for current branch into build/api/output/master -->
<target name="docs">
<exec dir="."
command="phpBB/vendor/bin/sami.php update build/sami-checkout.conf.php"
passthru="true" />
</target>
<!-- Builds docs for multiple branches/tags into build/api/output/$branch -->
<target name="docs-all">
<exec dir="."
command="phpBB/vendor/bin/sami.php update build/sami-all.conf.php"
passthru="true" />
</target>
<target name="old-version-diffs">
<foreach list="${oldversions}" param="version" target="old-version-diff" />
</target>
<!-- This target retrieves an old version from the git tag release-${version}
and creates a diff between that release and the new one -->
<target name="old-version-diff">
<echo msg="Retrieving version ${version}" />
<mkdir dir="build/old_versions/release-${version}" />
<phingcall target="export">
<property name="revision" value="release-${version}" />
<property name="dir" value="build/old_versions/release-${version}" />
</phingcall>
<phingcall target="clean-diff-dir">
<property name="dir" value="build/old_versions/release-${version}" />
</phingcall>
<exec dir="build/old_versions" command="LC_ALL=C diff -crNEBZbd release-${version} release-${newversion} >
../new_version/patches/phpBB-${version}_to_${newversion}.patch" escape="false" />
<exec dir="build/old_versions" command="LC_ALL=C diff -qr release-${version} release-${newversion} | grep 'Only in release-${version}' > ../new_version/patches/phpBB-${version}_to_${newversion}.deleted" escape="false" />
</target>
<target name="prepare-new-version">
<!-- select the currently checked out commit (HEAD) for packaging -->
<mkdir dir="build/new_version/phpBB3" />
<phingcall target="export">
<property name="revision" value="HEAD" />
<property name="dir" value="build/new_version/phpBB3" />
</phingcall>
<!-- copy into directory for diffs -->
<exec dir="build" command="cp -rp new_version/phpBB3 old_versions/release-${newversion}" />
<!-- and clean up -->
<phingcall target="clean-diff-dir">
<property name="dir" value="build/old_versions/release-${newversion}" />
</phingcall>
<!-- create an empty config.php file (not for diffs) -->
<touch file="build/new_version/phpBB3/config.php" />
</target>
<target name="package" depends="clean,prepare,prepare-new-version,old-version-diffs">
<exec dir="build" command="php -f package.php '${versions}' > logs/package.log" escape="false" />
<exec dir="build" escape="false"
command="LC_ALL=C diff -crNEBZbd old_versions/release-${prevversion}/language new_version/phpBB3/language >
save/phpbb-${prevversion}_to_${newversion}_language.patch" />
<exec dir="build" escape="false"
command="LC_ALL=C diff -crNEBZbd old_versions/release-${prevversion}/styles/prosilver new_version/phpBB3/styles/prosilver >
save/phpbb-${prevversion}_to_${newversion}_prosilver.patch" />
<exec dir="build" escape="false"
command="git shortlog --summary --numbered release-${prevversion}...HEAD >
save/phpbb-${prevversion}_to_${newversion}_git_shortlog.txt" />
<exec dir="build" escape="false"
command="git diff --stat release-${prevversion}...HEAD >
save/phpbb-${prevversion}_to_${newversion}_git_diffstat.txt" />
<phingcall target="checksum-dir">
<property name="dir" value="build/new_version/release_files" />
</phingcall>
</target>
<target name="checksum-dir">
<foreach param="filename" absparam="absfilename" target="checksum-file">
<fileset dir="${dir}">
<type type="file" />
</fileset>
</foreach>
</target>
<target name="checksum-file">
<echo msg="Creating checksum file for ${absfilename}" />
<php function="dirname" returnProperty="dir"><param value="${absfilename}"/></php>
<exec dir="${dir}" command="sha256sum ${filename} > ${filename}.sha256" />
</target>
<target name="announcement" depends="prepare">
<echo msg="Writing download links and checksums for email announcement to save/announcement_email_${newversion}.txt" />
<exec dir="build" escape="false"
command="php -f build_announcement.php email '${newversion}' 'new_version/release_files' sha256 >
save/announcement_email_${newversion}.txt" />
<echo msg="Writing download links and checksums for bbcode announcement to save/announcement_bbcode_${newversion}.txt" />
<exec dir="build" escape="false"
command="php -f build_announcement.php bbcode '${newversion}' 'new_version/release_files' sha256 >
save/announcement_bbcode_${newversion}.txt" />
</target>
<target name="changelog" depends="prepare">
<exec dir="build" escape="false"
command="php -f build_changelog.php '${newversion}' >
save/changelog_${newversion}.html" />
</target>
<!--
This target can be called using phingcall to retrieve a clean
checkout of a commit from git. It will only export the phpBB directory.
The properties revision and dir are required.
This target will remove directories that are not needed in distribution
and set correct permissions.
-->
<target name="export">
<exec dir="phpBB"
command="git archive ${revision} | tar -xf - -C ../${dir}"
checkreturn="true" />
<!-- Install composer dependencies, if there are any. -->
<exec dir="${dir}"
command='php -r "\$j = json_decode(file_get_contents(\"composer.json\")); echo isset(\$j->require);"'
checkreturn="true"
outputProperty='composer-has-dependencies' />
<if>
<equals arg1="${composer-has-dependencies}" arg2="1" trim="true" />
<then>
<!-- We have non-dev composer dependencies -->
<exec dir="."
command="git ls-tree ${revision} composer.phar"
checkreturn="true"
outputProperty='composer-ls-tree-output' />
<if>
<equals arg1="${composer-ls-tree-output}" arg2="" trim="true" />
<then>
<fail message="There are composer dependencies, but composer.phar is missing." />
</then>
<else>
<!-- Export the phar, install dependencies, delete phar. -->
<exec dir="."
command="git archive ${revision} composer.phar | tar -xf - -C ${dir}"
checkreturn="true" />
<exec dir="${dir}"
command="php composer.phar install --no-dev --optimize-autoloader"
checkreturn="true"
passthru="true" />
<delete file="${dir}/composer.phar" />
</else>
</if>
</then>
<else>
<!-- We do not have composer dependencies, do not ship composer files -->
<delete file="${dir}/composer.json" />
<delete file="${dir}/composer.lock" />
</else>
</if>
<!-- Create schema.json -->
<exec dir="${dir}" command="php develop/create_schema_files.php" />
<delete file="${dir}/config.php" />
<delete dir="${dir}/develop" />
<delete dir="${dir}/install/data" />
<delete dir="${dir}/config/development" />
<delete dir="${dir}/config/test" />
<phingcall target="clean-vendor-dir">
<property name="dir" value="${dir}" />
</phingcall>
<echo msg="Setting permissions for checkout of ${revision} in ${dir}" />
<!-- set permissions of all files to 644, directories to 755 -->
<exec dir="${dir}" command="find . -type f|xargs chmod 644" escape="false" />
<exec dir="${dir}" command="find . -type d|xargs chmod 755" escape="false" />
<!-- set permissions of some directories to 777 -->
<chmod mode="0777" file="${dir}/cache" />
<chmod mode="0777" file="${dir}/store" />
<chmod mode="0777" file="${dir}/files" />
<chmod mode="0777" file="${dir}/images/avatars/upload" />
</target>
<target name="clean-vendor-dir">
<!-- Delete unrelated files from vendor/, see PHPBB3-12390 -->
<delete dir="${dir}/vendor/bantu/ini-get-wrapper/tests" />
<delete file="${dir}/vendor/bantu/ini-get-wrapper/.gitignore" />
<delete file="${dir}/vendor/bantu/ini-get-wrapper/.scrutinizer.yml" />
<delete file="${dir}/vendor/bantu/ini-get-wrapper/.travis.yml" />
<delete file="${dir}/vendor/bantu/ini-get-wrapper/phpunit.xml.dist" />
<delete file="${dir}/vendor/bantu/ini-get-wrapper/README.md" />
<delete dir="${dir}/vendor/google/recaptcha/examples" />
<delete dir="${dir}/vendor/google/recaptcha/tests" />
<delete file="${dir}/vendor/google/recaptcha/.gitignore" />
<delete file="${dir}/vendor/google/recaptcha/.travis.yml" />
<delete file="${dir}/vendor/google/recaptcha/CONTRIBUTING.md" />
<delete file="${dir}/vendor/google/recaptcha/phpunit.xml.dist" />
<delete file="${dir}/vendor/google/recaptcha/README.md" />
<delete dir="${dir}/vendor/guzzlehttp/guzzle/build" />
<delete dir="${dir}/vendor/guzzlehttp/guzzle/docs" />
<delete dir="${dir}/vendor/guzzlehttp/guzzle/tests" />
<delete file="${dir}/vendor/guzzlehttp/guzzle/CHANGELOG.md" />
<delete file="${dir}/vendor/guzzlehttp/guzzle/.editorconfig" />
<delete file="${dir}/vendor/guzzlehttp/guzzle/.gitignore" />
<delete file="${dir}/vendor/guzzlehttp/guzzle/Makefile" />
<delete file="${dir}/vendor/guzzlehttp/guzzle/phpunit.xml.dist" />
<delete file="${dir}/vendor/guzzlehttp/guzzle/README.md" />
<delete file="${dir}/vendor/guzzlehttp/guzzle/.travis.yml" />
<delete file="${dir}/vendor/guzzlehttp/guzzle/UPGRADING.md" />
<delete dir="${dir}/vendor/guzzlehttp/ringphp/docs" />
<delete dir="${dir}/vendor/guzzlehttp/ringphp/tests" />
<delete file="${dir}/vendor/guzzlehttp/ringphp/CHANGELOG.md" />
<delete file="${dir}/vendor/guzzlehttp/ringphp/.gitignore" />
<delete file="${dir}/vendor/guzzlehttp/ringphp/Makefile" />
<delete file="${dir}/vendor/guzzlehttp/ringphp/phpunit.xml.dist" />
<delete file="${dir}/vendor/guzzlehttp/ringphp/README.rst" />
<delete file="${dir}/vendor/guzzlehttp/ringphp/.travis.yml" />
<delete dir="${dir}/vendor/guzzlehttp/streams/tests" />
<delete file="${dir}/vendor/guzzlehttp/streams/CHANGELOG.rst" />
<delete file="${dir}/vendor/guzzlehttp/streams/.gitignore" />
<delete file="${dir}/vendor/guzzlehttp/streams/Makefile" />
<delete file="${dir}/vendor/guzzlehttp/streams/phpunit.xml.dist" />
<delete file="${dir}/vendor/guzzlehttp/streams/README.rst" />
<delete file="${dir}/vendor/guzzlehttp/streams/.travis.yml" />
<delete dir="${dir}/vendor/lusitanian/oauth/examples" />
<delete dir="${dir}/vendor/lusitanian/oauth/tests" />
<delete file="${dir}/vendor/lusitanian/oauth/.gitignore" />
<delete file="${dir}/vendor/lusitanian/oauth/.scrutinizer.yml" />
<delete file="${dir}/vendor/lusitanian/oauth/.travis.yml" />
<delete file="${dir}/vendor/lusitanian/oauth/phpunit.xml.dist" />
<delete file="${dir}/vendor/lusitanian/oauth/README.md" />
<delete dir="${dir}/vendor/paragonie/random_compat/dist" />
<delete dir="${dir}/vendor/paragonie/random_compat/other" />
<delete file="${dir}/vendor/paragonie/random_compat/CHANGELOG.md" />
<delete file="${dir}/vendor/paragonie/random_compat/ERRATA.md" />
<delete file="${dir}/vendor/paragonie/random_compat/README.md" />
<delete file="${dir}/vendor/paragonie/random_compat/SECURITY.md" />
<delete file="${dir}/vendor/patchwork/utf8/.travis.yml" />
<delete file="${dir}/vendor/patchwork/utf8/CHANGELOG.md" />
<delete file="${dir}/vendor/patchwork/utf8/phpunit.xml.dist" />
<delete file="${dir}/vendor/patchwork/utf8/README.md" />
<delete dir="${dir}/vendor/psr/log/Psr/Log/Test" />
<delete file="${dir}/vendor/psr/log/.gitignore" />
<delete file="${dir}/vendor/psr/log/README.md" />
<delete dir="${dir}/vendor/react/promise/tests" />
<delete file="${dir}/vendor/react/promise/CHANGELOG.md" />
<delete file="${dir}/vendor/react/promise/.gitignore" />
<delete file="${dir}/vendor/react/promise/phpunit.xml.dist" />
<delete file="${dir}/vendor/react/promise/README.md" />
<delete file="${dir}/vendor/react/promise/.travis.yml" />
<delete dir="${dir}/vendor/s9e/text-formatter/.git" />
<delete dir="${dir}/vendor/symfony/config/.git" />
<delete dir="${dir}/vendor/symfony/config/Tests" />
<delete file="${dir}/vendor/symfony/config/.gitignore" />
<delete file="${dir}/vendor/symfony/config/CHANGELOG.md" />
<delete file="${dir}/vendor/symfony/config/README.md" />
<delete file="${dir}/vendor/symfony/config/phpunit.xml.dist" />
<delete dir="${dir}/vendor/symfony/console/.git" />
<delete dir="${dir}/vendor/symfony/console/Tests" />
<delete file="${dir}/vendor/symfony/console/.gitignore" />
<delete file="${dir}/vendor/symfony/console/CHANGELOG.md" />
<delete file="${dir}/vendor/symfony/console/README.md" />
<delete file="${dir}/vendor/symfony/console/phpunit.xml.dist" />
<delete dir="${dir}/vendor/symfony/debug/.git" />
<delete dir="${dir}/vendor/symfony/debug/Tests" />
<delete file="${dir}/vendor/symfony/debug/.gitignore" />
<delete file="${dir}/vendor/symfony/debug/CHANGELOG.md" />
<delete file="${dir}/vendor/symfony/debug/README.md" />
<delete file="${dir}/vendor/symfony/debug/phpunit.xml.dist" />
<delete dir="${dir}/vendor/symfony/dependency-injection/.git" />
<delete dir="${dir}/vendor/symfony/dependency-injection/Tests" />
<delete file="${dir}/vendor/symfony/dependency-injection/.gitignore" />
<delete file="${dir}/vendor/symfony/dependency-injection/CHANGELOG.md" />
<delete file="${dir}/vendor/symfony/dependency-injection/README.md" />
<delete file="${dir}/vendor/symfony/dependency-injection/phpunit.xml.dist" />
<delete dir="${dir}/vendor/symfony/event-dispatcher/.git" />
<delete dir="${dir}/vendor/symfony/event-dispatcher/Tests" />
<delete file="${dir}/vendor/symfony/event-dispatcher/.gitignore" />
<delete file="${dir}/vendor/symfony/event-dispatcher/CHANGELOG.md" />
<delete file="${dir}/vendor/symfony/event-dispatcher/README.md" />
<delete file="${dir}/vendor/symfony/event-dispatcher/phpunit.xml.dist" />
<delete dir="${dir}/vendor/symfony/filesystem/.git" />
<delete dir="${dir}/vendor/symfony/filesystem/Tests" />
<delete file="${dir}/vendor/symfony/filesystem/.gitignore" />
<delete file="${dir}/vendor/symfony/filesystem/CHANGELOG.md" />
<delete file="${dir}/vendor/symfony/filesystem/README.md" />
<delete file="${dir}/vendor/symfony/filesystem/phpunit.xml.dist" />
<delete dir="${dir}/vendor/symfony/finder/.git" />
<delete dir="${dir}/vendor/symfony/finder/Tests" />
<delete file="${dir}/vendor/symfony/finder/.gitignore" />
<delete file="${dir}/vendor/symfony/finder/CHANGELOG.md" />
<delete file="${dir}/vendor/symfony/finder/README.md" />
<delete file="${dir}/vendor/symfony/finder/phpunit.xml.dist" />
<delete dir="${dir}/vendor/symfony/http-foundation/.git" />
<delete dir="${dir}/vendor/symfony/http-foundation/Tests" />
<delete file="${dir}/vendor/symfony/http-foundation/.gitignore" />
<delete file="${dir}/vendor/symfony/http-foundation/CHANGELOG.md" />
<delete file="${dir}/vendor/symfony/http-foundation/README.md" />
<delete file="${dir}/vendor/symfony/http-foundation/phpunit.xml.dist" />
<delete dir="${dir}/vendor/symfony/http-kernel/.git" />
<delete dir="${dir}/vendor/symfony/http-kernel/Tests" />
<delete file="${dir}/vendor/symfony/http-kernel/.gitignore" />
<delete file="${dir}/vendor/symfony/http-kernel/CHANGELOG.md" />
<delete file="${dir}/vendor/symfony/http-kernel/README.md" />
<delete file="${dir}/vendor/symfony/http-kernel/phpunit.xml.dist" />
<delete dir="${dir}/vendor/symfony/routing/.git" />
<delete dir="${dir}/vendor/symfony/routing/Tests" />
<delete file="${dir}/vendor/symfony/routing/.gitignore" />
<delete file="${dir}/vendor/symfony/routing/CHANGELOG.md" />
<delete file="${dir}/vendor/symfony/routing/README.md" />
<delete file="${dir}/vendor/symfony/routing/phpunit.xml.dist" />
<delete dir="${dir}/vendor/symfony/twig-bridge/.git" />
<delete dir="${dir}/vendor/symfony/twig-bridge/Tests" />
<delete file="${dir}/vendor/symfony/twig-bridge/.gitignore" />
<delete file="${dir}/vendor/symfony/twig-bridge/CHANGELOG.md" />
<delete file="${dir}/vendor/symfony/twig-bridge/README.md" />
<delete file="${dir}/vendor/symfony/twig-bridge/phpunit.xml.dist" />
<delete dir="${dir}/vendor/symfony/yaml/.git" />
<delete dir="${dir}/vendor/symfony/yaml/Tests" />
<delete file="${dir}/vendor/symfony/yaml/.gitignore" />
<delete file="${dir}/vendor/symfony/yaml/CHANGELOG.md" />
<delete file="${dir}/vendor/symfony/yaml/README.md" />
<delete file="${dir}/vendor/symfony/yaml/phpunit.xml.dist" />
<delete dir="${dir}/vendor/twig/twig/doc" />
<delete dir="${dir}/vendor/twig/twig/ext" />
<delete dir="${dir}/vendor/twig/twig/test" />
<delete file="${dir}/vendor/twig/twig/.editorconfig" />
<delete file="${dir}/vendor/twig/twig/.gitignore" />
<delete file="${dir}/vendor/twig/twig/.travis.yml" />
<delete file="${dir}/vendor/twig/twig/CHANGELOG" />
<delete file="${dir}/vendor/twig/twig/phpunit.xml.dist" />
<delete file="${dir}/vendor/twig/twig/README.rst" />
</target>
<target name="clean-diff-dir">
<delete dir="${dir}/cache" />
<delete dir="${dir}/docs" />
<delete dir="${dir}/files" />
<delete dir="${dir}/install" />
<delete dir="${dir}/store" />
<delete dir="${dir}/vendor" />
</target>
</project>

View File

@@ -1,84 +0,0 @@
#!/usr/bin/env php
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
if (php_sapi_name() !== 'cli' || $_SERVER['argc'] != 5)
{
echo "Usage (CLI only): build_announcement.php email|bbcode new_version release_files_dir checksum_algorithm\n";
exit(1);
}
$mode = $_SERVER['argv'][1];
$version = $_SERVER['argv'][2];
$root = $_SERVER['argv'][3];
$checksum_algorithm = $_SERVER['argv'][4];
$series_version = substr($version, 0, 3);
$base_url = "https://download.phpbb.com/pub/release/$series_version";
if (version_compare($version, "$series_version.0", '<'))
{
// Everything before 3.x.0, i.e. unstable (e.g. alpha, beta, rc)
$url = "$base_url/unstable/$version";
}
else if (strpos($version, 'RC') !== false)
{
// Release candidate of stable release
$url = "$base_url/qa/$version";
}
else
{
// Stable release (e.g. 3.x.0, 3.x.1, 3.x.2, 3.x.3-PL1)
$url = "$base_url/$version";
}
if ($mode === 'bbcode')
{
$template = "[url=%1\$s/%2\$s]%2\$s[/url]\n{$checksum_algorithm}sum: %3\$s\n";
}
else
{
$template = "%s/%s\n{$checksum_algorithm}sum: %s\n";
}
function phpbb_rnatsort($array)
{
$strrnatcmp = function($a, $b)
{
return strnatcmp($b, $a);
};
usort($array, $strrnatcmp);
return $array;
}
function phpbb_string_ends_with($haystack, $needle)
{
return substr($haystack, -strlen($needle)) === $needle;
}
function phpbb_get_checksum($checksum_file)
{
return array_shift(explode(' ', file_get_contents($checksum_file)));
}
foreach (phpbb_rnatsort(array_diff(scandir($root), array('.', '..'))) as $filename)
{
if (phpbb_string_ends_with($filename, $checksum_algorithm))
{
continue;
}
else
{
printf($template, $url, $filename, phpbb_get_checksum("$root/$filename.$checksum_algorithm"));
}
}

View File

@@ -1,57 +0,0 @@
#!/usr/bin/env php
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
if ($_SERVER['argc'] != 2)
{
echo "Please specify the new version as argument (e.g. build_changelog.php '1.0.2').\n";
exit(1);
}
$fixVersion = $_SERVER['argv'][1];
$query = 'project IN (PHPBB3, SECURITY)
AND resolution = Fixed
AND fixVersion = "' . $fixVersion . '"
AND status IN ("Unverified Fix", Closed)';
$url = 'http://tracker.phpbb.com/sr/jira.issueviews:searchrequest-xml/temp/SearchRequest.xml?jqlQuery=' . urlencode($query) . '&tempMax=1000';
$xml = simplexml_load_string(file_get_contents($url));
foreach ($xml->xpath('//item') as $item)
{
$key = (string) $item->key;
$keyUrl = 'http://tracker.phpbb.com/browse/' . $key;
$keyLink = '<a href="' . $keyUrl . '">' . $key . '</a>';
$value = str_replace($key, $keyLink, htmlspecialchars($item->title));
$value = str_replace(']', '] -', $value);
$types[(string) $item->type][$key] = $value;
}
ksort($types);
foreach ($types as $type => $tickets)
{
echo "<h4>$type</h4>\n";
echo "<ul>\n";
uksort($tickets, 'strnatcasecmp');
foreach ($tickets as $ticket)
{
echo "<li>$ticket</li>\n";
}
echo "</ul>\n";
}

View File

@@ -1,378 +0,0 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
class build_package
{
var $package_infos;
var $old_packages;
var $versions;
var $locations;
// -c - context diff
// -r - compare recursive
// -N - Treat missing files as empty
// -E - Ignore tab expansions
// -Z - Ignore white space at line end.
// -b - Ignore changes in the amount of white space.
// -B - Ignore blank lines
// -d - Try to find smaller set of changes
var $diff_options = '-crNEBZbd';
var $diff_options_long = '-x images -crNEB'; // -x fonts -x imageset //imageset not used here, because it includes the imageset.cfg file. ;)
var $verbose = false;
var $status_begun = false;
var $num_dots = 0;
function build_package($versions, $verbose = false)
{
$this->versions = $versions;
$this->verbose = $verbose;
// Get last two entries
$_latest = $this->versions[sizeof($this->versions) - 1];
$_before = $this->versions[sizeof($this->versions) - 2];
$this->locations = array(
'new_version' => dirname(dirname(__FILE__)) . '/phpBB/',
'old_versions' => dirname(__FILE__) . '/old_versions/',
'root' => dirname(__FILE__) . '/',
'package_dir' => dirname(__FILE__) . '/new_version/'
);
$this->package_infos = array(
'package_name' => 'phpBB3',
'name_prefix' => 'phpbb',
'simple_name' => 'release-' . $_latest,
'new_version_number' => $_latest,
'short_version_number' => str_replace('.', '', $_latest),
'release_filename' => 'phpBB-' . $_latest,
'last_version' => 'release-' . $_before,
'last_version_number' => $_before,
);
$this->package_infos['dest_dir'] = $this->locations['package_dir'] . $this->package_infos['package_name'];
$this->package_infos['diff_dir'] = $this->locations['old_versions'] . $this->package_infos['simple_name'];
$this->package_infos['patch_directory'] = $this->locations['package_dir'] . 'patches';
$this->package_infos['files_directory'] = $this->locations['package_dir'] . 'files';
$this->package_infos['update_directory'] = $this->locations['package_dir'] . 'update';
$this->package_infos['release_directory'] = $this->locations['package_dir'] . 'release_files';
// Old packages always exclude the latest version. ;)
$this->old_packages = array();
foreach ($this->versions as $package_version)
{
if ($package_version == $_latest)
{
continue;
}
$this->old_packages['release-' . $package_version] = $package_version . '_to_';
}
}
function get($var)
{
return $this->package_infos[$var];
}
function begin_status($headline)
{
if ($this->status_begun)
{
echo "\nDone.\n\n";
}
$this->num_dots = 0;
echo $headline . "\n ";
$this->status_begun = true;
}
function run_command($command)
{
$result = trim(`$command`);
if ($this->verbose)
{
echo " command : " . getcwd() . '$ ' . $command . "\n";
echo " result : " . $result . "\n";
}
else
{
if ($this->num_dots > 70)
{
echo "\n";
$this->num_dots = 0;
}
echo '.';
$this->num_dots++;
}
flush();
}
function create_directory($directory, $dir_struct)
{
if (!file_exists($directory))
{
$this->run_command("mkdir $directory");
}
if (is_array($dir_struct))
{
foreach ($dir_struct as $_dir => $_dir_struct)
{
$this->create_directory($directory . '/' . $_dir, $_dir_struct);
}
}
}
function collect_diff_files($diff_filename, $package_name)
{
$diff_result = $binary = array();
$diff_contents = file($diff_filename);
$special_diff_contents = array();
foreach ($diff_contents as $num => $line)
{
$line = trim($line);
if (!$line)
{
continue;
}
// Special diff content?
if (strpos($line, 'diff ' . $this->diff_options . ' ') === 0 || strpos($line, '*** ') === 0 || strpos($line, '--- ') === 0 || (strpos($line, ' Exp $') !== false && strpos($line, '$Id:') !== false))
{
$special_diff_contents[] = $line;
}
else if (strpos($line, 'diff ' . $this->diff_options . ' ') === 0 || strpos($line, '*** ') === 0 || strpos($line, '--- ') === 0 || (strpos($line, ' Exp $') !== false && strpos($line, '$Id:') !== false) || (strpos($line, ' $') !== false && strpos($line, '$Id:') !== false))
{
$special_diff_contents[] = $line;
}
// Is diffing line?
if (strstr($line, 'diff ' . $this->diff_options . ' '))
{
$next_line = $diff_contents[$num+1];
if (strpos($next_line, '***') === 0)
{
// *** phpbb208/admin/admin_board.php Sat Jul 10 20:16:26 2004
$next_line = explode("\t", $next_line);
$next_line = trim($next_line[0]);
$next_line = str_replace('*** ' . $package_name . '/', '', $next_line);
$diff_result[] = $next_line;
}
}
// Is binary?
if (preg_match('/^Binary files ' . $package_name . '\/(.*) and [a-z0-9._-]+\/\1 differ/i', $line, $match))
{
$binary[] = trim($match[1]);
}
}
// Now go through the list again and find out which files have how many changes...
$num_changes = array();
/* [1070] => diff -crN phpbb200/includes/usercp_avatar.php phpbb2023/includes/usercp_avatar.php
[1071] => *** phpbb200/includes/usercp_avatar.php Sat Jul 10 20:16:13 2004
[1072] => --- phpbb2023/includes/usercp_avatar.php Wed Feb 6 22:28:04 2008
[1073] => *** 6,12 ****
[1074] => ! * $Id$
[1075] => --- 6,12 ----
[1076] => *** 51,59 ****
[1077] => --- 51,60 ----
[1078] => *** 62,80 ****
[1079] => --- 63,108 ----
[1080] => *** 87,97 ****
*/
while (($line = array_shift($special_diff_contents)) !== NULL)
{
$line = trim($line);
if (!$line)
{
continue;
}
// Is diffing line?
if (strstr($line, 'diff ' . $this->diff_options . ' '))
{
$next_line = array_shift($special_diff_contents);
if (strpos($next_line, '*** ') === 0)
{
// *** phpbb208/admin/admin_board.php Sat Jul 10 20:16:26 2004
$next_line = explode("\t", $next_line);
$next_line = trim($next_line[0]);
$next_line = str_replace('*** ' . $package_name . '/', '', $next_line);
$is_reached = false;
$prev_line = '';
while (!$is_reached)
{
$line = array_shift($special_diff_contents);
if (strpos($line, 'diff ' . $this->diff_options) === 0 || empty($special_diff_contents))
{
$is_reached = true;
array_unshift($special_diff_contents, $line);
continue;
}
if (strpos($line, '*** ') === 0 && strpos($line, ' ****') !== false)
{
$is_comment = false;
while (!(strpos($line, '--- ') === 0 && strpos($line, ' ----') !== false))
{
$line = array_shift($special_diff_contents);
if (strpos($line, ' Exp $') !== false || strpos($line, '$Id:') !== false)
{
$is_comment = true;
}
}
if (!$is_comment)
{
if (!isset($num_changes[$next_line]))
{
$num_changes[$next_line] = 1;
}
else
{
$num_changes[$next_line]++;
}
}
}
}
}
}
}
// Now remove those results not having changes
$return = array();
foreach ($diff_result as $key => $value)
{
if (isset($num_changes[$value]))
{
$return[] = $value;
}
}
foreach ($binary as $value)
{
$return[] = $value;
}
$diff_result = $return;
unset($return);
unset($special_diff_contents);
$result = array(
'files' => array(),
'binary' => array(),
'all' => $diff_result,
);
$binary_extensions = array('gif', 'jpg', 'jpeg', 'png', 'ttf');
// Split into file and binary
foreach ($diff_result as $filename)
{
if (strpos($filename, '.') === false)
{
$result['files'][] = $filename;
continue;
}
$extension = explode('.', $filename);
$extension = array_pop($extension);
if (in_array($extension, $binary_extensions))
{
$result['binary'][] = $filename;
}
else
{
$result['files'][] = $filename;
}
}
return $result;
}
/**
* Collect the list of the deleted files from a list of deleted files and folders.
*
* @param string $deleted_filename The full path to a file containing the list of deleted files and directories
* @param string $package_name The name of the package
* @return array
*/
public function collect_deleted_files($deleted_filename, $package_name)
{
$result = array();
$file_contents = file($deleted_filename);
foreach ($file_contents as $filename)
{
$filename = trim($filename);
if (!$filename)
{
continue;
}
$filename = str_replace('Only in ' . $package_name, '', $filename);
$filename = ltrim($filename, '/');
if (substr($filename, 0, 1) == ':')
{
$replace = '';
}
else
{
$replace = '/';
}
$filename = str_replace(': ', $replace, $filename);
if (is_dir("{$this->locations['old_versions']}{$package_name}/{$filename}"))
{
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator(
"{$this->locations['old_versions']}{$package_name}/{$filename}",
\FilesystemIterator::UNIX_PATHS | \FilesystemIterator::SKIP_DOTS
),
\RecursiveIteratorIterator::LEAVES_ONLY
);
foreach ($iterator as $file_info)
{
$result[] = "{$filename}/{$iterator->getSubPathname()}";
}
}
else
{
$result[] = $filename;
}
}
return $result;
}
}

View File

@@ -1,232 +0,0 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
/**
* Checks that each PHP source file contains a valid header as defined by the
* phpBB Coding Guidelines.
*
* @package code_sniffer
* @author Manuel Pichler <mapi@phpundercontrol.org>
*/
class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
{
/**
* Returns an array of tokens this test wants to listen for.
*
* @return array
*/
public function register()
{
return array(T_OPEN_TAG);
}
/**
* Processes this test, when one of its tokens is encountered.
*
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token
* in the stack passed in $tokens.
*
* @return null
*/
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
// We are only interested in the first file comment.
if ($stackPtr !== 0)
{
if ($phpcsFile->findPrevious(T_OPEN_TAG, $stackPtr - 1) !== false)
{
return;
}
}
// Fetch next non whitespace token
$tokens = $phpcsFile->getTokens();
$start = $phpcsFile->findNext(T_WHITESPACE, $stackPtr + 1, null, true);
// Skip empty files
if ($tokens[$start]['code'] === T_CLOSE_TAG)
{
return;
}
// Mark as error if this is not a doc comment
else if ($start === false || $tokens[$start]['code'] !== T_DOC_COMMENT_OPEN_TAG)
{
$phpcsFile->addError('Missing required file doc comment.', $stackPtr);
return;
}
// Find comment end token
$end = $tokens[$start]['comment_closer'];
// If there is no end, skip processing here
if ($end === false)
{
return;
}
// check comment lines without the first(/**) an last(*/) line
for ($token = $start + 1, $c = $end - 2; $token <= $c; ++$token)
{
// Check that each line starts with a '*'
if ($tokens[$token]['column'] === 1 && (($tokens[$token]['content'] !== '*' && $tokens[$token]['content'] !== ' ') || ($tokens[$token]['content'] === ' ' && $tokens[$token + 1]['content'] !== '*')))
{
$message = 'The file doc comment should not be indented.';
$phpcsFile->addWarning($message, $token);
}
}
// Check that the first and last line is empty
// /**T_WHITESPACE
// (T_WHITESPACE)*T_WHITESPACE
// (T_WHITESPACE)* ...
// (T_WHITESPACE)*T_WHITESPACE
// T_WHITESPACE*/
if (!(($tokens[$start + 2]['content'] !== '*' && $tokens[$start + 4]['content'] !== '*') || ($tokens[$start + 3]['content'] !== '*' && $tokens[$start + 6]['content'] !== '*')))
{
$message = 'The first file comment line should be empty.';
$phpcsFile->addWarning($message, ($start + 1));
}
if ($tokens[$end - 3]['content'] !== '*' && $tokens[$end - 6]['content'] !== '*')
{
$message = 'The last file comment line should be empty.';
$phpcsFile->addWarning($message, $end - 1);
}
//$this->processPackage($phpcsFile, $start, $tags);
//$this->processVersion($phpcsFile, $start, $tags);
$this->processCopyright($phpcsFile, $start, $tokens[$start]['comment_tags']);
$this->processLicense($phpcsFile, $start, $tokens[$start]['comment_tags']);
}
/**
* Checks that the tags array contains a valid package tag
*
* @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
* @param integer The stack pointer for the first comment token.
* @param array(string=>array) $tags The found file doc comment tags.
*
* @return null
*/
protected function processPackage(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
{
if (!isset($tags['package']))
{
$message = 'Missing require @package tag in file doc comment.';
$phpcsFile->addError($message, $ptr);
}
else if (preg_match('/^([\w]+)$/', $tags['package'][0]) === 0)
{
$message = 'Invalid content found for @package tag.';
$phpcsFile->addWarning($message, $tags['package'][1]);
}
}
/**
* Checks that the tags array contains a valid version tag
*
* @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
* @param integer The stack pointer for the first comment token.
* @param array(string=>array) $tags The found file doc comment tags.
*
* @return null
*/
protected function processVersion(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
{
if (!isset($tags['version']))
{
$message = 'Missing require @version tag in file doc comment.';
$phpcsFile->addError($message, $ptr);
}
else if (preg_match('/^\$Id:[^\$]+\$$/', $tags['version'][0]) === 0)
{
$message = 'Invalid content found for @version tag, use "$Id: $".';
$phpcsFile->addError($message, $tags['version'][1]);
}
}
/**
* Checks that the tags array contains a valid copyright tag
*
* @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
* @param integer The stack pointer for the first comment token.
* @param array(string=>array) $tags The found file doc comment tags.
*
* @return null
*/
protected function processCopyright(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
{
$copyright = '(c) phpBB Limited <https://www.phpbb.com>';
$tokens = $phpcsFile->getTokens();
foreach ($tags as $tag)
{
if ($tokens[$tag]['content'] === '@copyright')
{
if ($tokens[$tag + 2]['content'] !== $copyright)
{
$message = 'Invalid content found for the first @copyright tag, use "' . $copyright . '".';
$phpcsFile->addError($message, $tags['copyright'][0][1]);
}
return;
}
}
$message = 'Missing require @copyright tag in file doc comment.';
$phpcsFile->addError($message, $ptr);
}
/**
* Checks that the tags array contains a valid license tag
*
* @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
* @param integer The stack pointer for the first comment token.
* @param array(string=>array) $tags The found file doc comment tags.
*
* @return null
*/
protected function processLicense(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
{
$license = 'GNU General Public License, version 2 (GPL-2.0)';
$tokens = $phpcsFile->getTokens();
$found = false;
foreach ($tags as $tag)
{
if ($tokens[$tag]['content'] === '@license')
{
if ($found)
{
$message = 'It must be only one @license tag in file doc comment.';
$phpcsFile->addError($message, $ptr);
}
$found = true;
if ($tokens[$tag + 2]['content'] !== $license)
{
$message = 'Invalid content found for @license tag, use "' . $license . '".';
$phpcsFile->addError($message, $tags['license'][0][1]);
}
}
}
if (!$found)
{
$message = 'Missing require @license tag in file doc comment.';
$phpcsFile->addError($message, $ptr);
}
}
}

View File

@@ -1,143 +0,0 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
/**
* Checks that the opening brace of a control structures is on the line after.
* From Generic_Sniffs_Functions_OpeningFunctionBraceBsdAllmanSniff
*/
class phpbb_Sniffs_ControlStructures_OpeningBraceBsdAllmanSniff implements PHP_CodeSniffer_Sniff
{
/**
* Registers the tokens that this sniff wants to listen for.
*/
public function register()
{
return array(
T_IF,
T_ELSE,
T_FOREACH,
T_WHILE,
T_DO,
T_FOR,
T_SWITCH,
);
}
/**
* Processes this test, when one of its tokens is encountered.
*
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token in the
* stack passed in $tokens.
*
* @return void
*/
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
if (isset($tokens[$stackPtr]['scope_opener']) === false)
{
return;
}
/*
* ...
* }
* else if ()
* {
* ...
*/
if ($tokens[$stackPtr]['code'] === T_ELSE && $tokens[$stackPtr + 2]['code'] === T_IF)
{
return;
}
$openingBrace = $tokens[$stackPtr]['scope_opener'];
/*
* ...
* do
* {
* <code>
* } while();
* ...
* }
* else
* {
* ...
*/
if ($tokens[$stackPtr]['code'] === T_DO ||$tokens[$stackPtr]['code'] === T_ELSE)
{
$cs_line = $tokens[$stackPtr]['line'];
}
else
{
// The end of the function occurs at the end of the argument list. Its
// like this because some people like to break long function declarations
// over multiple lines.
$cs_line = $tokens[$tokens[$stackPtr]['parenthesis_closer']]['line'];
}
$braceLine = $tokens[$openingBrace]['line'];
$lineDifference = ($braceLine - $cs_line);
if ($lineDifference === 0)
{
$error = 'Opening brace should be on a new line';
$phpcsFile->addError($error, $openingBrace, 'BraceOnSameLine');
return;
}
if ($lineDifference > 1)
{
$error = 'Opening brace should be on the line after the declaration; found %s blank line(s)';
$data = array(($lineDifference - 1));
$phpcsFile->addError($error, $openingBrace, 'BraceSpacing', $data);
return;
}
// We need to actually find the first piece of content on this line,
// as if this is a method with tokens before it (public, static etc)
// or an if with an else before it, then we need to start the scope
// checking from there, rather than the current token.
$lineStart = $stackPtr;
while (($lineStart = $phpcsFile->findPrevious(array(T_WHITESPACE), ($lineStart - 1), null, false)) !== false)
{
if (strpos($tokens[$lineStart]['content'], $phpcsFile->eolChar) !== false)
{
break;
}
}
// We found a new line, now go forward and find the first non-whitespace
// token.
$lineStart = $phpcsFile->findNext(array(T_WHITESPACE), $lineStart, null, true);
// The opening brace is on the correct line, now it needs to be
// checked to be correctly indented.
$startColumn = $tokens[$lineStart]['column'];
$braceIndent = $tokens[$openingBrace]['column'];
if ($braceIndent !== $startColumn)
{
$error = 'Opening brace indented incorrectly; expected %s spaces, found %s';
$data = array(
($startColumn - 1),
($braceIndent - 1),
);
$phpcsFile->addError($error, $openingBrace, 'BraceIndent', $data);
}
}
}

View File

@@ -1,60 +0,0 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
/**
* Checks that there is exactly one space between the keyword and the opening
* parenthesis of a control structures.
*/
class phpbb_Sniffs_ControlStructures_OpeningParenthesisSniff implements PHP_CodeSniffer_Sniff
{
/**
* Registers the tokens that this sniff wants to listen for.
*/
public function register()
{
return array(
T_IF,
T_FOREACH,
T_WHILE,
T_FOR,
T_SWITCH,
T_ELSEIF,
T_CATCH,
);
}
/**
* Processes this test, when one of its tokens is encountered.
*
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token in the
* stack passed in $tokens.
*
* @return void
*/
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
if ($tokens[$stackPtr + 1]['content'] === '(')
{
$error = 'There should be exactly one space between the keyword and opening parenthesis';
$phpcsFile->addError($error, $stackPtr, 'NoSpaceBeforeOpeningParenthesis');
}
else if ($tokens[$stackPtr + 1]['content'] !== ' ')
{
$error = 'There should be exactly one space between the keyword and opening parenthesis';
$phpcsFile->addError($error, $stackPtr, 'IncorrectSpaceBeforeOpeningParenthesis');
}
}
}

View File

@@ -1,242 +0,0 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
/**
* Checks that each use statement is used.
*/
class phpbb_Sniffs_Namespaces_UnusedUseSniff implements PHP_CodeSniffer_Sniff
{
/**
* {@inheritdoc}
*/
public function register()
{
return array(T_USE);
}
protected function check($phpcsFile, $found_name, $full_name, $short_name, $line)
{
if ($found_name === $full_name)
{
$error = 'Either use statement or full name must be used.';
$phpcsFile->addError($error, $line, 'FullName');
}
if ($found_name === $short_name)
{
return true;
}
return false;
}
/**
* {@inheritdoc}
*/
public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
if ($this->should_ignore_use($phpcsFile, $stackPtr) === true)
{
return;
}
$tokens = $phpcsFile->getTokens();
$class_name_start = $phpcsFile->findNext(array(T_NS_SEPARATOR, T_STRING), ($stackPtr + 1));
$find = array(
T_NS_SEPARATOR,
T_STRING,
T_WHITESPACE,
);
$class_name_end = $phpcsFile->findNext($find, ($stackPtr + 1), null, true);
$aliasing_as_position = $phpcsFile->findNext(T_AS, $class_name_end, null, false, null, true);
if ($aliasing_as_position !== false)
{
$alias_position = $phpcsFile->findNext(T_STRING, $aliasing_as_position, null, false, null, true);
$class_name_short = $tokens[$alias_position]['content'];
$class_name_full = $phpcsFile->getTokensAsString($class_name_start, ($class_name_end - $class_name_start - 1));
}
else
{
$class_name_full = $phpcsFile->getTokensAsString($class_name_start, ($class_name_end - $class_name_start));
$class_name_short = $tokens[$class_name_end - 1]['content'];
}
$ok = false;
// Checks in simple statements (new, instanceof and extends)
foreach (array(T_INSTANCEOF, T_NEW, T_EXTENDS) as $keyword)
{
$old_simple_statement = $stackPtr;
while (($simple_statement = $phpcsFile->findNext($keyword, ($old_simple_statement + 1))) !== false)
{
$old_simple_statement = $simple_statement;
$simple_class_name_start = $phpcsFile->findNext(array(T_NS_SEPARATOR, T_STRING), ($simple_statement + 1));
if ($simple_class_name_start === false) {
continue;
}
$simple_class_name_end = $phpcsFile->findNext($find, ($simple_statement + 1), null, true);
$simple_class_name = trim($phpcsFile->getTokensAsString($simple_class_name_start, ($simple_class_name_end - $simple_class_name_start)));
$ok = $this->check($phpcsFile, $simple_class_name, $class_name_full, $class_name_short, $simple_statement) ? true : $ok;
}
}
// Checks paamayim nekudotayim
$old_paamayim_nekudotayim = $stackPtr;
while (($paamayim_nekudotayim = $phpcsFile->findNext(T_PAAMAYIM_NEKUDOTAYIM, ($old_paamayim_nekudotayim + 1))) !== false)
{
$old_paamayim_nekudotayim = $paamayim_nekudotayim;
$paamayim_nekudotayim_class_name_start = $phpcsFile->findPrevious($find, $paamayim_nekudotayim - 1, null, true);
$paamayim_nekudotayim_class_name_end = $paamayim_nekudotayim - 1;
$paamayim_nekudotayim_class_name = trim($phpcsFile->getTokensAsString($paamayim_nekudotayim_class_name_start + 1, ($paamayim_nekudotayim_class_name_end - $paamayim_nekudotayim_class_name_start)));
$ok = $this->check($phpcsFile, $paamayim_nekudotayim_class_name, $class_name_full, $class_name_short, $paamayim_nekudotayim) ? true : $ok;
}
// Checks in implements
$old_implements = $stackPtr;
while (($implements = $phpcsFile->findNext(T_IMPLEMENTS, ($old_implements + 1))) !== false)
{
$old_implements = $implements;
$old_implemented_class = $implements;
while (($implemented_class = $phpcsFile->findNext(T_STRING, ($old_implemented_class + 1), null, false, null, true)) !== false)
{
$old_implemented_class = $implemented_class;
$implements_class_name_start = $phpcsFile->findNext(array(T_NS_SEPARATOR, T_STRING), ($implemented_class - 1));
$implements_class_name_end = $phpcsFile->findNext($find, ($implemented_class - 1), null, true);
$implements_class_name = trim($phpcsFile->getTokensAsString($implements_class_name_start, ($implements_class_name_end - $implements_class_name_start)));
$ok = $this->check($phpcsFile, $implements_class_name, $class_name_full, $class_name_short, $implements) ? true : $ok;
}
}
// Checks in type hinting
$old_function_declaration = $stackPtr;
while (($function_declaration = $phpcsFile->findNext(T_FUNCTION, ($old_function_declaration + 1))) !== false)
{
$old_function_declaration = $function_declaration;
// Check docblocks
$find = array(
T_COMMENT,
T_DOC_COMMENT_CLOSE_TAG,
T_DOC_COMMENT,
T_CLASS,
T_FUNCTION,
T_OPEN_TAG,
);
$comment_end = $phpcsFile->findPrevious($find, ($function_declaration - 1));
if ($comment_end !== false)
{
if ($tokens[$comment_end]['code'] === T_DOC_COMMENT_CLOSE_TAG)
{
$comment_start = $tokens[$comment_end]['comment_opener'];
foreach ($tokens[$comment_start]['comment_tags'] as $tag) {
if ($tokens[$tag]['content'] !== '@param' && $tokens[$tag]['content'] !== '@return' && $tokens[$tag]['content'] !== '@throws') {
continue;
}
$classes = $tokens[($tag + 2)]['content'];
$space = strpos($classes, ' ');
if ($space !== false) {
$classes = substr($classes, 0, $space);
}
$tab = strpos($classes, "\t");
if ($tab !== false) {
$classes = substr($classes, 0, $tab);
}
$classes = explode('|', str_replace('[]', '', $classes));
foreach ($classes as $class)
{
$ok = $this->check($phpcsFile, $class, $class_name_full, $class_name_short, $tokens[$tag + 2]['line']) ? true : $ok;
}
}
}
}
// Check type hint
$params = $phpcsFile->getMethodParameters($function_declaration);
foreach ($params as $param)
{
$ok = $this->check($phpcsFile, $param['type_hint'], $class_name_full, $class_name_short, $function_declaration) ? true : $ok;
}
}
// Checks in catch blocks
$old_catch = $stackPtr;
while (($catch = $phpcsFile->findNext(T_CATCH, ($old_catch + 1))) !== false)
{
$old_catch = $catch;
$caught_class_name_start = $phpcsFile->findNext(array(T_NS_SEPARATOR, T_STRING), $catch + 1);
$caught_class_name_end = $phpcsFile->findNext($find, $caught_class_name_start + 1, null, true);
$caught_class_name = trim($phpcsFile->getTokensAsString($caught_class_name_start, ($caught_class_name_end - $caught_class_name_start)));
$ok = $this->check($phpcsFile, $caught_class_name, $class_name_full, $class_name_short, $catch) ? true : $ok;
}
if (!$ok)
{
$error = 'There must not be unused USE statements.';
$phpcsFile->addError($error, $stackPtr, 'Unused');
}
}
/**
* Check if this use statement is part of the namespace block.
*
* @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
* @param int $stackPtr The position of the current token in
* the stack passed in $tokens.
*
* @return bool
*/
private function should_ignore_use(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
{
$tokens = $phpcsFile->getTokens();
// Ignore USE keywords inside closures.
$next = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true);
if ($tokens[$next]['code'] === T_OPEN_PARENTHESIS)
{
return true;
}
// Ignore USE keywords for traits.
if ($phpcsFile->hasCondition($stackPtr, array(T_CLASS, T_TRAIT)) === true)
{
return true;
}
return false;
}
}

View File

@@ -1,18 +0,0 @@
<?xml version="1.0"?>
<ruleset name="phpBB Minimum Standard">
<description>phpBB minimum coding standard</description>
<!-- All code files MUST use only UTF-8 without BOM. -->
<rule ref="Generic.Files.ByteOrderMark" />
<!-- All code files MUST use the Unix LF (linefeed) line ending. -->
<rule ref="Generic.Files.LineEndings" />
<!-- Tabs MUST be used for indentation -->
<rule ref="Generic.WhiteSpace.DisallowSpaceIndent" />
<!-- ALL braces MUST be on their own lines. -->
<rule ref="./phpbb/Sniffs/ControlStructures/OpeningBraceBsdAllmanSniff.php" />
</ruleset>

View File

@@ -1,8 +0,0 @@
<?xml version="1.0"?>
<ruleset name="phpBB PHP Strict Standard Extensions">
<description>phpBB coding standard for PHP files of phpBB extensions</description>
<rule ref="./ruleset-php-strict.xml" />
</ruleset>

View File

@@ -1,11 +0,0 @@
<?xml version="1.0"?>
<ruleset name="phpBB PHP Legacy Standard Core">
<description>phpBB legacy coding standard for PHP files of phpBB core</description>
<rule ref="./ruleset-php-legacy.xml" />
<!-- Each file MUST start with a valid header as defined by the Coding Guidelines -->
<rule ref="./phpbb/Sniffs/Commenting/FileCommentSniff.php" />
</ruleset>

View File

@@ -1,92 +0,0 @@
<?xml version="1.0"?>
<ruleset name="phpBB PHP Legacy Standard">
<description>phpBB legacy coding standard for PHP files</description>
<rule ref="./ruleset-minimum.xml" />
<!-- "for (; bar; )" should be "while (bar)" instead -->
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop" />
<!-- A method MUST not only call its parent -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod" />
<!-- The body of each structure MUST be enclosed by braces. -->
<rule ref="Generic.ControlStructures.InlineControlStructure" />
<!-- There MUST not be more than one statement per line. -->
<rule ref="Generic.Formatting.DisallowMultipleStatements" />
<!-- Call-time pass-by-reference MUST not be used. -->
<rule ref="Generic.Functions.CallTimePassByReference.NotAllowed" />
<!-- Filenames MUST be lowercase. -->
<rule ref="Generic.Files.LowercasedFilename" />
<!-- The function brace MUST be on the line following the function declaration
and MUST be indented to the same column as the start of the function declaration. -->
<rule ref="Generic.Functions.OpeningFunctionBraceBsdAllman" />
<!-- There MUST be exactly one space after a cast. -->
<rule ref="Generic.Formatting.SpaceAfterCast" />
<!-- Class constants MUST be declared in all upper case with underscore separators. -->
<rule ref="Generic.NamingConventions.UpperCaseConstantName" />
<!-- Only <?php, no short tags. -->
<rule ref="Generic.PHP.DisallowShortOpenTag.EchoFound" />
<!-- Method arguments with default values MUST go at the end of the argument list. -->
<rule ref="PEAR.Functions.ValidDefaultValue" />
<!-- Each file MUST end with exactly one newline character -->
<rule ref="PSR2.Files.EndFileNewline" />
<!-- When referencing arrays there MUST NOT be any whitespace around the opening bracket
or before the closing bracket. -->
<rule ref="Squiz.Arrays.ArrayBracketSpacing" />
<!-- The "else if" statement MUST be written with a space between the words else and if. -->
<rule ref="Squiz.ControlStructures.ElseIfDeclaration" />
<!-- There MUST be a space between each element of a foreach loop. -->
<rule ref="Squiz.ControlStructures.ForEachLoopDeclaration" />
<!-- In a for loop declaration, there MUST be no space inside the brackets
and there MUST be 0 spaces before and 1 space after semicolons. -->
<rule ref="Squiz.ControlStructures.ForLoopDeclaration" />
<!-- In the argument list, there MUST NOT be a space before each comma,
and there MUST be one space after each comma. -->
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing">
<properties>
<property name="equalsSpacing" value="1"/>
</properties>
</rule>
<rule ref="Squiz.Functions.FunctionDeclarationArgumentSpacing.SpacingAfterHint" />
<!-- All built-in PHP functions MUST be called lowercased. -->
<rule ref="Squiz.Functions.LowercaseFunctionKeywords" />
<!-- The eval() function MUST NOT be used. -->
<rule ref="Squiz.PHP.Eval" />
<!-- There MUST NOT be trailing whitespace at the end of lines. -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" />
<!-- There MUST NOT be whitespace before the first content of a file -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.StartFile" />
<!-- There MUST NOT be whitespace after the last content of a file -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EndFile" />
<!-- Functions MUST NOT contain multiple empty lines in a row -->
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace.EmptyLines" />
<!-- The ?> closing tag MUST be omitted from files containing only PHP. -->
<rule ref="Zend.Files.ClosingTag" />
<!-- There MUST be one space between control structure and opening parenthesis -->
<rule ref="./phpbb/Sniffs/ControlStructures/OpeningParenthesisSniff.php" />
</ruleset>

View File

@@ -1,9 +0,0 @@
<?xml version="1.0"?>
<ruleset name="phpBB PHP Strict Standard Core">
<description>phpBB coding standard for PHP files of phpBB core</description>
<rule ref="./ruleset-php-legacy-core.xml" />
<rule ref="./ruleset-php-strict.xml" />
</ruleset>

View File

@@ -1,48 +0,0 @@
<?xml version="1.0"?>
<ruleset name="phpBB PHP Strict Standard">
<description>phpBB coding standard for PHP files</description>
<rule ref="./ruleset-php-legacy.xml" />
<!-- There SHOULD NOT be more than 80 characters per line
There MUST NOT be more than 120 characters per line -->
<!--
<rule ref="Generic.Files.LineLength">
<properties>
<property name="lineLimit" value="80"/>
<property name="absoluteLineLimit" value="120"/>
</properties>
</rule>
-->
<!-- The PHP constants true, false, and null MUST be in lower case. -->
<rule ref="Generic.PHP.LowerCaseConstant" />
<!-- PHP keywords MUST be in lower case. -->
<rule ref="Generic.PHP.LowerCaseKeyword" />
<!-- Constructors MUST be called __construct() instead of after the class. -->
<rule ref="Generic.NamingConventions.ConstructorName" />
<!-- Classes etc. MUST be namespaced -->
<rule ref="PSR1.Classes.ClassDeclaration.MissingNamespace" />
<!-- A file MUST not contain more than one class/interface -->
<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses" />
<!-- Files containing classes MUST not have any side-effects -->
<rule ref="PSR1.Files.SideEffects.FoundWithSymbols" />
<!-- When present, all use declarations MUST go after the namespace declaration.
There MUST be one use keyword per declaration.
There MUST be one blank line after the use block. -->
<rule ref="PSR2.Namespaces.UseDeclaration" />
<!-- There MUST be one blank line after the namespace declaration -->
<rule ref="PSR2.Namespaces.NamespaceDeclaration" />
<!-- There MUST NOT be unused use statements. -->
<rule ref="./phpbb/Sniffs/Namespaces/UnusedUseSniff.php" />
</ruleset>

View File

@@ -1,39 +0,0 @@
#!/usr/bin/env bash
orig_dir="../../phpBB"
rm -rf test_release_files
mkdir test_release_files
cd test_release_files
for ext in "tar.bz2" "zip"
do
cp "../new_version/release_files/$1.$ext" ./
if [ "$ext" = "tar.bz2" ]
then
command="tar -xjf"
else
command="unzip -q"
fi
$command "$1.$ext"
for file in `find phpBB3 -name '.svn' -prune -o -type f -print`
do
orig_file="${file/#phpBB3/$orig_dir}"
diff_result=`diff $orig_file $file`
if [ -n "$diff_result" ]
then
echo "Difference in package $1.$ext"
echo $diff_result
fi
done
rm -rf phpBB3
done
cd ..
rm -rf test_release_files

View File

@@ -1,503 +0,0 @@
#!/usr/bin/env php
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
//$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');
$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";
// 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))
{
chdir($package->locations['old_versions']);
// This array is for holding the filenames change
$diff_file_changes = array();
foreach ($package->old_packages as $_package_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(
$package->get('patch_directory') . '/phpBB-' . $dest_package_filename . $package->get('new_version_number') . '.patch',
$_package_name
);
$diff_file_changes[$_package_name]['deleted'] = $package->collect_deleted_files(
$package->get('patch_directory') . '/phpBB-' . $dest_package_filename . $package->get('new_version_number') . '.deleted',
$_package_name
);
}
// Now put those files determined within the correct directories
foreach ($diff_file_changes as $_package_name => $file_contents)
{
$package->begin_status('Creating files-only informations for ' . $package->old_packages[$_package_name] . $package->get('new_version_number'));
$dest_filename_dir = $package->get('files_directory') . '/' . $package->old_packages[$_package_name] . $package->get('new_version_number');
if (!file_exists($dest_filename_dir))
{
$package->run_command('mkdir ' . $dest_filename_dir);
}
// Now copy the file contents
foreach ($file_contents['all'] as $file)
{
$source_filename = $package->get('dest_dir') . '/' . $file;
$dest_filename = $dest_filename_dir . '/' . $file;
// Create Directories along the way?
$file = explode('/', $file);
// Remove filename portion
$file[sizeof($file)-1] = '';
chdir($dest_filename_dir);
foreach ($file as $entry)
{
$entry = trim($entry);
if ($entry)
{
if (!file_exists('./' . $entry))
{
$package->run_command('mkdir ' . $entry);
}
chdir('./' . $entry);
}
}
$package->run_command('cp ' . $source_filename . ' ' . $dest_filename);
}
}
// Because there might be binary changes, we re-create the patch files... without parsing file differences.
$package->run_command('rm -Rv ' . $package->get('patch_directory'));
if (!file_exists($package->get('patch_directory')))
{
$package->run_command('mkdir ' . $package->get('patch_directory'));
}
chdir($package->locations['old_versions']);
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_long . ' ' . $_package_name . ' ' . $package->get('simple_name') . ' > ' . $dest_package_filename);
}
$packages = $diff_file_changes;
foreach ($packages as $_package_name => $file_contents)
{
$package->begin_status('Building specific update files for ' . $package->old_packages[$_package_name] . $package->get('new_version_number'));
$dest_filename_dir = $package->get('update_directory') . '/' . $package->old_packages[$_package_name] . $package->get('new_version_number');
if (!file_exists($dest_filename_dir))
{
$package->run_command('mkdir ' . $dest_filename_dir);
}
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/docs ' . $dest_filename_dir);
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/install ' . $dest_filename_dir);
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/vendor ' . $dest_filename_dir);
$package->run_command('mkdir ' . $dest_filename_dir . '/install/update');
$package->run_command('mkdir ' . $dest_filename_dir . '/install/update/old');
$package->run_command('mkdir ' . $dest_filename_dir . '/install/update/new');
// Remove some files
$package->run_command('rm -v ' . $dest_filename_dir . '/install/install_install.php');
$package->run_command('rm -v ' . $dest_filename_dir . '/install/install_convert.php');
$package->run_command('rm -Rv ' . $dest_filename_dir . '/install/schemas');
$package->run_command('rm -Rv ' . $dest_filename_dir . '/install/convertors');
foreach ($file_contents['all'] as $index => $file)
{
if (strpos($file, 'recode_cjk') !== false)
{
unset($file_contents['all'][$index]);
}
$source_filename = $package->locations['old_versions'] . $package->get('simple_name') . '/' . $file;
if (!file_exists($source_filename))
{
unset($file_contents['all'][$index]);
}
}
// First of all, fill the 'old' directory
foreach ($file_contents['all'] as $file)
{
$source_filename = $package->locations['old_versions'] . $_package_name . '/' . $file;
$dest_filename = $dest_filename_dir . '/install/update/old/' . $file;
if (!file_exists($source_filename))
{
continue;
}
// Create Directories along the way?
$file = explode('/', $file);
// Remove filename portion
$file[sizeof($file)-1] = '';
chdir($dest_filename_dir . '/install/update/old');
foreach ($file as $entry)
{
$entry = trim($entry);
if ($entry)
{
if (!file_exists('./' . $entry))
{
$package->run_command('mkdir ' . $entry);
}
chdir('./' . $entry);
}
}
$package->run_command('cp ' . $source_filename . ' ' . $dest_filename);
}
/**
* We try to keep the update packages as small as possible while creating them.
* However, we sometimes need to include additional files that are not included
* in the diff in order to be able to correctly include the relatively
* referenced files from the same or subsequent directories.
*/
$copy_relative_directories = array(
'config/' => array(
'recursive' => true,
'copied' => false,
'copy' => array(
'config/*' => 'config',
),
),
);
// Then fill the 'new' directory
foreach ($file_contents['all'] as $file)
{
$source_filename = $package->locations['old_versions'] . $package->get('simple_name') . '/' . $file;
$dest_filename = $dest_filename_dir . '/install/update/new/' . $file;
$filename = $file;
// Create Directories along the way?
$file = explode('/', $file);
// Remove filename portion
$file[sizeof($file)-1] = '';
chdir($dest_filename_dir . '/install/update/new');
foreach ($file as $entry)
{
$entry = trim($entry);
if ($entry)
{
if (!file_exists('./' . $entry))
{
$package->run_command('mkdir ' . $entry);
}
chdir('./' . $entry);
}
}
$package->run_command('cp ' . $source_filename . ' ' . $dest_filename);
foreach ($copy_relative_directories as $reference => $data)
{
// Copy all relative referenced files if needed
if (strpos($filename, $reference) === 0 && !$data['copied'])
{
foreach ($data['copy'] as $source_dir_files => $destination_dir)
{
// Create directories along the way?
$directories = explode('/', $destination_dir);
chdir($dest_filename_dir . '/install/update/new');
foreach ($directories as $dir)
{
$dir = trim($dir);
if ($dir)
{
if (!file_exists('./' . $dir))
{
$package->run_command('mkdir ' . $dir);
}
chdir('./' . $dir);
}
}
$source_dir_files = $package->locations['old_versions'] . $package->get('simple_name') . '/' . $source_dir_files;
$destination_dir = $dest_filename_dir . '/install/update/new/' . $destination_dir;
if (isset($data['recursive']) && $data['recursive'])
{
$package->run_command('cp -Rp ' . $source_dir_files . ' ' . $destination_dir);
}
else
{
$package->run_command('cp ' . $source_dir_files . ' ' . $destination_dir);
}
}
$copy_relative_directories[$reference]['copied'] = true;
}
}
}
/**
* We need to always copy the template and asset files that we need in
* the update, to ensure that the page is displayed correctly.
*/
$copy_update_files = array(
'adm/images/*' => 'adm/images',
'adm/style/admin.css' => 'adm/style',
'adm/style/admin.js' => 'adm/style',
'adm/style/ajax.js' => 'adm/style',
'adm/style/installer_*' => 'adm/style',
'assets/javascript/*' => 'assets/javascript',
);
foreach ($copy_update_files as $source_files => $destination_dir)
{
// Create directories along the way?
$directories = explode('/', $destination_dir);
chdir($dest_filename_dir . '/install/update/new');
foreach ($directories as $dir)
{
$dir = trim($dir);
if ($dir)
{
if (!file_exists('./' . $dir))
{
$package->run_command('mkdir ' . $dir);
}
chdir('./' . $dir);
}
}
$source_dir_files = $package->locations['old_versions'] . $package->get('simple_name') . '/' . $source_files;
$destination_dir = $dest_filename_dir . '/install/update/new/' . $destination_dir;
$package->run_command('cp ' . $source_dir_files . ' ' . $destination_dir);
}
// Build index.php file for holding the file structure
$index_contents = '<?php
if (!defined(\'IN_PHPBB\'))
{
exit;
}
// Set update info with file structure to update
$update_info = array(
\'version\' => array(\'from\' => \'' . str_replace('_to_', '', $package->old_packages[$_package_name]) . '\', \'to\' => \'' . $package->get('new_version_number') . '\'),
';
if (sizeof($file_contents['all']))
{
$index_contents .= "\t'files' => array(\n\t\t'" . implode("',\n\t\t'", $file_contents['all']) . "',\n\t),\n";
}
else
{
$index_contents .= "\t'files' => array(),\n";
}
if (sizeof($file_contents['binary']))
{
$index_contents .= "\t'binary' => array(\n\t\t'" . implode("',\n\t\t'", $file_contents['binary']) . "',\n\t),\n";
}
else
{
$index_contents .= "\t'binary' => array(),\n";
}
if (sizeof($file_contents['deleted']))
{
$index_contents .= "\t'deleted' => array(\n\t\t'" . implode("',\n\t\t'", $file_contents['deleted']) . "',\n\t),\n";
}
else
{
$index_contents .= "\t'deleted' => array(),\n";
}
$index_contents .= ");\n";
$fp = fopen($dest_filename_dir . '/install/update/index.php', 'wt');
fwrite($fp, $index_contents);
fclose($fp);
}
unset($diff_file_changes);
$package->begin_status('Clean up all install files');
// Copy the install files to their respective locations
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/docs ' . $package->get('patch_directory'));
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/install ' . $package->get('patch_directory'));
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/vendor ' . $package->get('patch_directory'));
// Remove some files
chdir($package->get('patch_directory') . '/install');
$package->run_command('rm -v install_install.php');
$package->run_command('rm -v install_update.php');
$package->run_command('rm -v install_convert.php');
$package->run_command('rm -Rv schemas');
$package->run_command('rm -Rv convertors');
}
// Build Main phpBB Release
$compress_programs = array(
// 'tar.gz' => 'tar -czf',
'tar.bz2' => 'tar -cjf',
'zip' => 'zip -r'
);
if (sizeof($package->old_packages))
{
// Build Patch Files
chdir($package->get('patch_directory'));
foreach ($compress_programs as $extension => $compress_command)
{
$package->begin_status('Packaging phpBB Patch Files for ' . $extension);
// Build Package
$package->run_command($compress_command . ' ../release_files/' . $package->get('release_filename') . '-patch.' . $extension . ' *');
}
// Build Files Package
chdir($package->get('files_directory'));
foreach ($compress_programs as $extension => $compress_command)
{
$package->begin_status('Packaging phpBB Files for ' . $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');
$package->run_command('cp -Rp ' . $package->get('dest_dir') . '/vendor ' . $package->get('files_directory') . '/release');
$package->run_command('rm -v ' . $package->get('files_directory') . '/release/install/install_install.php');
$package->run_command('rm -v ' . $package->get('files_directory') . '/release/install/install_update.php');
$package->run_command('rm -v ' . $package->get('files_directory') . '/release/install/install_convert.php');
$package->run_command('rm -Rv ' . $package->get('files_directory') . '/release/install/schemas');
$package->run_command('rm -Rv ' . $package->get('files_directory') . '/release/install/convertors');
// Pack files
foreach ($package->old_packages as $_package_name => $package_path)
{
chdir($package_path . $package->get('new_version_number'));
$command = ($extension == 'zip') ? 'zip -r' : 'tar cf';
$_ext = ($extension == 'zip') ? 'zip' : 'tar';
$package->run_command("$command ../release/phpBB-$package_path" . $package->get('new_version_number') . ".$_ext *");
chdir('..');
}
chdir('./release');
$package->run_command("$compress_command ../../release_files/" . $package->get('release_filename') . '-files.' . $extension . ' *');
chdir('..');
$package->run_command('rm -Rv ' . $package->get('files_directory') . '/release');
}
// Build Update Package
foreach ($compress_programs as $extension => $compress_command)
{
chdir($package->get('update_directory'));
$package->begin_status('Packaging phpBB Update for ' . $extension);
$package->run_command('mkdir ' . $package->get('update_directory') . '/release');
// Pack update files
$packages = $package->old_packages;
foreach ($packages as $_package_name => $package_path)
{
chdir($package_path . $package->get('new_version_number'));
$package->run_command('rm -v install/install_install.php');
$package->run_command('rm -v install/install_convert.php');
$package->run_command('rm -v includes/utf/data/recode_cjk.php');
$package->run_command('rm -Rv install/schemas');
$package->run_command('rm -Rv install/convertors');
$command = ($extension == 'zip') ? 'zip -r' : 'tar cf';
$_ext = ($extension == 'zip') ? 'zip' : 'tar';
$package->run_command("$command ../release/$package_path" . $package->get('new_version_number') . ".$_ext *");
chdir('..');
$last_version = $package_path . $package->get('new_version_number');
// chdir('./release');
// $package->run_command("$compress_command ../../release_files/" . $package->get('release_filename') . '-update.' . $extension . ' *');
// chdir('..');
chdir('./' . $last_version);
// Copy last package over...
$package->run_command('rm -v ../release_files/phpBB-' . $last_version . ".$extension");
$package->run_command("$compress_command ../../release_files/phpBB-$last_version.$extension *");
chdir('..');
}
$package->run_command('rm -Rv ' . $package->get('update_directory') . '/release');
}
}
// Delete updater and convertor from main archive
chdir($package->get('dest_dir') . '/install');
// $package->run_command('rm -v database_update.php');
$package->run_command('rm -v install_update.php');
chdir($package->locations['package_dir']);
foreach ($compress_programs as $extension => $compress_command)
{
$package->begin_status('Packaging phpBB for ' . $extension);
$package->run_command('rm -v ./release_files/' . $package->get('release_filename') . ".{$extension}");
// Build Package
$package->run_command("$compress_command ./release_files/" . $package->get('release_filename') . '.' . $extension . ' ' . $package->get('package_name'));
}
// 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 *");
// verify results
chdir($package->locations['root']);
$package->begin_status('********** Verifying packages **********');
$package->run_command('./compare.sh ' . $package->package_infos['release_filename']);
echo "Done.\n";

View File

@@ -1,31 +0,0 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
require __DIR__ . '/sami-checkout.conf.php';
$config['versions'] = Sami\Version\GitVersionCollection::create(__DIR__ . '/../')
/*
This would be nice, but currently causes various problems that need
debugging.
->addFromTags('release-3.0.*')
->add('3.0.x', '3.0-next (olympus)')
->addFromTags('release-3.1.*')
->add('3.1.x', '3.1-next (ascraeus)')
->add('master')
*/
->add('3.0.x')
->add('3.1.x')
->add('master')
;
return new Sami\Sami($iterator, $config);

View File

@@ -1,44 +0,0 @@
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
// Prevent 'Class "acm" does not exist.' exception on removeClass().
class PhpbbArrayStore extends Sami\Store\ArrayStore
{
public function removeClass(Sami\Project $project, $name)
{
unset($this->classes[$name]);
}
}
$iterator = Symfony\Component\Finder\Finder::create()
->files()
->name('*.php')
->in(__DIR__ . '/../phpBB/')
->notPath('#^cache/#')
->notPath('#^develop/#')
->notPath('#^ext/#')
->notPath('#^vendor/#')
->notPath('data')
;
$config = array(
'theme' => 'enhanced',
'title' => 'phpBB API Documentation',
'build_dir' => __DIR__.'/api/output/%version%',
'cache_dir' => __DIR__.'/api/cache/%version%',
'default_opened_level' => 2,
// Do not use JsonStore. See https://github.com/fabpot/Sami/issues/79
'store' => new PhpbbArrayStore,
);
return new Sami\Sami($iterator, $config);

View File

@@ -1,39 +0,0 @@
/**********************************************************************/
/* 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

View File

@@ -1,15 +0,0 @@
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 $$

View File

@@ -1,13 +0,0 @@
<msdeploy.iisapp>
<iisapp path="phpBB3" />
<dbmysql path="install/mysql.sql" commandDelimiter="$$" removeCommandDelimiter="true" />
<dbfullsql path="install/mssql.sql" />
<setAcl path="phpBB3/cache" setAclAccess="Modify" setAclUser="anonymousAuthenticationUser" />
<setAcl path="phpBB3/files" setAclAccess="Modify" setAclUser="anonymousAuthenticationUser" />
<setAcl path="phpBB3/store" setAclAccess="Modify" setAclUser="anonymousAuthenticationUser" />
<setAcl path="phpBB3/images/avatars/upload" setAclAccess="Modify" setAclUser="anonymousAuthenticationUser" />
<setAcl path="phpBB3/config.php" setAclAccess="Modify" setAclUser="anonymousAuthenticationUser" setAclResourceType="File" />
</msdeploy.iisapp>

View File

@@ -1,256 +0,0 @@
<parameters>
<parameter
name="AppPath"
defaultValue="Default Web Site/phpBB3"
tags="iisapp">
<parameterEntry
type="ProviderPath"
scope="iisapp"
match="phpBB3" />
</parameter>
<!--ACLs-->
<parameter
name="aclCache"
description="Sets the ACL on the cache/ folder"
defaultValue="{AppPath}/cache"
tags="Hidden">
<parameterEntry
type="ProviderPath"
scope="setAcl"
match="phpBB3/cache$" />
</parameter>
<parameter
name="aclFiles"
description="Sets the ACL on the files/ folder"
defaultValue="{AppPath}/files"
tags="Hidden">
<parameterEntry
type="ProviderPath"
scope="setAcl"
match="phpBB3/files$" />
</parameter>
<parameter
name="aclStore"
description="Sets the ACL on the store/ folder"
defaultValue="{AppPath}/store"
tags="Hidden">
<parameterEntry
type="ProviderPath"
scope="setAcl"
match="phpBB3/store$" />
</parameter>
<parameter
name="aclAvatarUpload"
description="Sets the ACL on the avatars/upload/ folder"
defaultValue="{AppPath}/images/avatars/upload"
tags="Hidden">
<parameterEntry
type="ProviderPath"
scope="setAcl"
match="phpBB3/images/avatars/upload$" />
</parameter>
<parameter
name="aclConfig"
description="Sets the ACL on the config.php file"
defaultValue="{AppPath}/config.php"
tags="Hidden">
<parameterEntry
type="ProviderPath"
scope="setAcl"
match="phpBB3/config.php$" />
</parameter>
<!-- SQL parameters -->
<parameter name="SQL Database Server" description="Enter the database server (usually machine name ) " defaultValue="." tags="SQL">
</parameter>
<parameter name="SQL DatabaseServer Instance" description="Enter the database instance name" defaultValue="SQLExpress" tags="SQL">
</parameter>
<!-- Read database server from config.php . Update 'dbhost' in config.php on publish -->
<parameter name="SQL Automatic DatabaseServer" defaultValue="dbhost = '{SQL Database Server}\\{SQL DatabaseServer Instance}';" tags="Hidden,SQL">
<parameterEntry kind="TextFile" scope="\\config\.php$" match="dbhost\s*=\s*'([^']*)'\s*;" />
</parameter>
<parameter
name="SQL DatabaseName" description="Database name for your application." defaultValue="phpbb" tags="SQL, dbName">
<parameterEntry type="TextFile" scope="install/mssql.sql" match="PlaceHolderForDb" />
</parameter>
<!-- Read database name from config.php . Update 'dbname' in config.php on publish -->
<parameter name="SQL Automatic DatabaseName" defaultValue="dbname = '{SQL DatabaseName}';" tags="Hidden,SQL">
<parameterEntry kind="TextFile" scope="\\config\.php$" match="dbname\s*=\s*'([^']*)'\s*;" />
</parameter>
<parameter
name="SQL DatabaseAdministrator"
description="Database server administartor username."
defaultValue="sa"
tags="SQL, DbAdminUsername" >
</parameter>
<parameter
name="SQL DatabaseAdministratorPassword"
description="Database server administrator password."
tags="Password,SQL,DbAdminPassword">
</parameter>
<parameter
name="SQL Database Username"
description="Username to access your database."
defaultValue="phpbb"
tags="SQL, DbUsername">
<parameterEntry
type="TextFile"
scope="install/mssql.sql"
match="PlaceHolderForUser" />
</parameter>
<!-- Read database user from config.php . Update 'dbuser' in config.php on publish -->
<parameter name="SQL Automatic Database User" defaultValue="dbuser = '{SQL Database Username}';" tags="Hidden,SQL">
<parameterEntry kind="TextFile" scope="\\config\.php$" match="dbuser\s*=\s*'([^']*)'\s*;" />
</parameter>
<parameter
name="SQL Database Password"
description="Password for your phpBB database. (Must be at least 8 characters, contain at least one lower case letter, one upper case letter and one digit)"
tags="New, Password,SQL, DbUserPassword">
<parameterValidation
type = "RegularExpression"
validationString = "^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$" />
<parameterEntry
type="TextFile"
scope="install/mssql.sql"
match="PlaceHolderForPassword" />
</parameter>
<!-- Read database user password from config.php . Update 'dbpasswd' in config.php on publish -->
<parameter name="SQL Automatic Database Password" defaultValue="dbpasswd = '{SQL Database Password}';" tags="Hidden,SQL">
<parameterEntry kind="TextFile" scope="\\config\.php$" match="dbpasswd\s*=\s*'([^']*)'\s*;" />
</parameter>
<!-- SQL Connection string -->
<parameter
name="SQL ConnectionString"
description="Automatically sets the connection string for the connection request."
defaultValue="Server={SQL Database Server}\{SQL DatabaseServer Instance};Database={SQL DatabaseName};uid={SQL DatabaseAdministrator};Pwd={SQL DatabaseAdministratorPassword};"
tags="Hidden,SQLConnectionString,Validate">
<parameterEntry
type="ProviderPath"
scope="dbfullsql"
match="install/mssql.sql" />
</parameter>
<parameter
name="SQL Database type"
description="SQL database type"
defaultValue="mssql"
tags="SQL,Hidden">
</parameter>
<!-- MYSQL parameters -->
<parameter
name="MySQL Database Server"
description="Enter the hostname"
defaultValue="localhost"
tags="MySQL, dbServer">
<parameterEntry
type="TextFile"
scope="install/mysql.sql"
match="PlaceHolderForServer" />
</parameter>
<!-- Read database server from config.php . Update 'dbhost' in config.php on publish -->
<parameter name="Automatic MySQL DatabaseServer" defaultValue="dbhost = '{MySQL Database Server}';" tags="Hidden,MySQL">
<parameterEntry kind="TextFile" scope="\\config\.php$" match="dbhost\s*=\s*'([^']*)'\s*;" />
</parameter>
<parameter
name="MySQL Database Name"
description="Database Name for your application."
defaultValue="phpbb"
tags="MySQL, dbName">
<parameterEntry
type="TextFile"
scope="install/mysql.sql"
match="PlaceHolderForDb" />
</parameter>
<!-- Read database name from config.php . Update 'dbname' in config.php on publish -->
<parameter name="Automatic MySQL Database Name" defaultValue="dbname = '{MySQL Database Name}';" tags="Hidden,MySQL">
<parameterEntry kind="TextFile" scope="\\config\.php$" match="dbname\s*=\s*'([^']*)'\s*;" />
</parameter>
<parameter
name="MySQL Database Username"
description="Username to access your phpBB database."
defaultValue="phpbb"
tags="MySQL, DbUsername">
<parameterEntry
type="TextFile"
scope="install/mysql.sql"
match="PlaceHolderForUser" />
</parameter>
<!-- Read database user from config.php . Update 'dbuser' in config.php on publish -->
<parameter name="Automatic MySQL Database User" defaultValue="dbuser = '{MySQL Database Username}';" tags="Hidden,MySQL">
<parameterEntry kind="TextFile" scope="\\config\.php$" match="dbuser\s*=\s*'([^']*)'\s*;" />
</parameter>
<parameter
name="MySQL Database Password"
description="Password for your phpBB database. (Minimum 4 characters)"
tags="New, Password,MySQL,DbUserPassword">
<parameterValidation
type = "RegularExpression"
validationString = "^.{4,}$" />
<parameterEntry
type="TextFile"
scope="install/mysql.sql"
match="PlaceHolderForPassword" />
</parameter>
<!-- Read database password from config.php . Update 'dbpasswd' in config.php on publish -->
<parameter name="MySQL Automatic Database Password" defaultValue="dbpasswd = '{MySQL Database Password}';" tags="Hidden,MySQL">
<parameterEntry kind="TextFile" scope="\\config\.php$" match="dbpasswd\s*=\s*'([^']*)'\s*;" />
</parameter>
<!-- MySQL admin credentials -->
<parameter
name="MySQL Database Administrator"
description="Database administrator username."
defaultValue="root"
tags="MySQL, DbAdminUsername" >
</parameter>
<parameter
name="MySQL Database Administrator Password"
description="Database administrator password."
tags="Password,MySQL,DbAdminPassword" >
</parameter>
<!-- MySQL Connectionstring -->
<parameter
name="MySQLConnectionString"
description="Automatically sets the connection string for the connection request."
defaultValue="Server={MySQL Database Server};Database={MySQL Database Name};uid={MySQL Database Administrator};Pwd={MySQL Database Administrator Password};"
tags="Hidden,MySQLConnectionString,Validate">
<parameterEntry
type="ProviderPath"
scope="dbmysql"
match="install/mysql.sql" />
</parameter>
</parameters>

Binary file not shown.

View File

@@ -1,56 +0,0 @@
#!/bin/bash
#
# This file is part of the phpBB Forum Software package.
#
# @copyright (c) phpBB Limited <https://www.phpbb.com>
# @license GNU General Public License, version 2 (GPL-2.0)
#
# For full copyright and license information, please see
# the docs/CREDITS.txt file.
#
# Calls the git commit-msg hook on all non-merge commits in a given commit range.
#
if [ "$#" -ne 1 ];
then
echo "Expected one argument (commit range, e.g. phpbb/develop..ticket/12345)."
exit
fi
DIR=$(dirname "$0")
COMMIT_RANGE="$1"
COMMIT_MSG_HOOK_PATH="$DIR/hooks/commit-msg"
COMMIT_MSG_HOOK_FATAL=$(git config --bool phpbb.hooks.commit-msg.fatal 2> /dev/null)
git config phpbb.hooks.commit-msg.fatal true
EXIT_STATUS=0
for COMMIT_HASH in $(git rev-list --no-merges "$COMMIT_RANGE")
do
echo "Inspecting commit message of commit $COMMIT_HASH"
# The git commit-msg hook takes a path to a file containing a commit
# message. So we have to extract the commit message into a file first,
# which then also needs to be deleted after our work is done.
COMMIT_MESSAGE_PATH="$DIR/commit_msg.$COMMIT_HASH"
git log -n 1 --pretty=format:%B "$COMMIT_HASH" > "$COMMIT_MESSAGE_PATH"
# Invoke hook on commit message file.
"$COMMIT_MSG_HOOK_PATH" "$COMMIT_MESSAGE_PATH"
# If any commit message hook complains with a non-zero exit status, we
# will send a non-zero exit status upstream.
if [ $? -ne 0 ]
then
EXIT_STATUS=1
fi
rm "$COMMIT_MESSAGE_PATH"
done
# Restore phpbb.hooks.commit-msg.fatal config
if [ -n "$COMMIT_MSG_HOOK_FATAL" ]
then
git config phpbb.hooks.commit-msg.fatal "$COMMIT_MSG_HOOK_FATAL"
fi
exit $EXIT_STATUS

View File

@@ -1,359 +0,0 @@
#!/bin/sh
#
# A hook to check syntax of a phpBB3 commit message, per:
# * <http://wiki.phpbb.com/display/DEV/Git>
# * <http://area51.phpbb.com/phpBB/viewtopic.php?p=209919#p209919>
#
# 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
#
# You can configure whether invalid commit messages abort commits:
#
# git config phpbb.hooks.commit-msg.fatal true (abort)
# git config phpbb.hooks.commit-msg.fatal false (warn only, do not abort)
#
# The default is to warn only.
#
# Warning/error messages use color by default if the output is a terminal
# ("output" here is normally standard error when you run git commit).
# To force or disable the use of color:
#
# git config phpbb.hooks.commit-msg.color true (force color output)
# git config phpbb.hooks.commit-msg.color false (disable color output)
config_ns="phpbb.hooks.commit-msg";
if [ "$(git config --bool $config_ns.fatal)" = "true" ]
then
fatal=1;
severity=Error;
else
fatal=0;
severity=Warning;
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 -eq 0 ] || [ $1 -eq $ERR_UNKNOWN ]
then
# success
exit 0;
elif [ $fatal -eq 0 ]
then
# problems found but fatal is false
complain 'Please run `git commit --amend` and fix the problems mentioned.' 1>&2
exit 0;
else
complain "Aborting commit." 1>&2
exit $1;
fi
}
use_color()
{
if [ -z "$use_color_cached" ]
then
case $(git config --bool $config_ns.color)
in
false)
use_color_cached=1
;;
true)
use_color_cached=0
;;
*)
# tty detection in shell:
# http://hwi.ath.cx/jsh/list/shext/isatty.sh.html
tty 0>/dev/stdout >/dev/null 2>&1
use_color_cached=$?
;;
esac
fi
# return value is the flag inverted -
# if return value is 0, this means use color
return $use_color_cached
}
complain()
{
if use_color
then
# Careful: our argument may include arguments to echo like -n
# ANSI color codes:
# http://pueblo.sourceforge.net/doc/manual/ansi_color_codes.html
printf "\033[31m\033[1m"
if [ "$1" = "-n" ]
then
echo "$@"
printf "\033[0m"
else
# This will print one trailing space.
# Not sure how to avoid this at the moment.
echo "$@" $(printf "\033[0m")
fi
else
echo "$@"
fi
}
# Check for empty commit message
if ! grep -qv '^#' "$1"
then
# Commit message is empty (or contains only comments).
# Let git handle this.
# It will abort with a message like so:
#
# Aborting commit due to empty commit message.
exit 0
fi
msg=$(grep -v '^#' "$1" |grep -nE '.{81,}')
if [ $? -eq 0 ]
then
complain "The following lines are greater than 80 characters long:" >&2;
complain >&2
complain "$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)\] .+$"
result=$?
if ! echo "$line" | grep -Eq "^\[(ticket/[0-9]+|feature/$branch_regex|task/$branch_regex)\] [a-zA-Z].+$"
then
# Don't be too strict.
# Commits may be temporary, intended to be squashed later.
# Just issue a warning here.
complain "$severity: heading should be a sentence beginning with a letter." 1>&2
complain "You entered:" 1>&2
complain "$line" 1>&2
fi
# restore exit code
(exit $result)
;;
"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
;;
"possibly-eof")
# Allow empty and/or comment lines at the end
! tail -n +"$i" "$1" |grep -qvE '^($|#)'
;;
"comment")
echo "$line" | grep -Eq "^#";
;;
*)
complain "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 possibly-eof";
if [ "$tickets" = "" ]
then
tickets="$line";
else
tickets="$tickets $line";
fi
;;
"comment")
# Comments should expect the same thing again
;;
"possibly-eof")
expecting="eof";
;;
*)
complain "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
complain "Syntax error on line $i:" >&2;
complain ">> $line" >&2;
complain -n "Expecting: " >&2;
complain "$expecting" | sed 's/ /, /g' >&2;
quit $err;
fi
i=$(( $i + 1 ));
done
# If EOF is expected exit cleanly
echo "$expecting" | grep -q "eof" || (
# Unexpected EOF, error
complain "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
complain "The following tickets are repeated:" >&2;
complain "$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" || (
complain "Ticket ID [$ticket] of branch missing from list of tickets:" >&2;
complain "$tickets" | sed 's/ /\n/g;s/^/* /g' >&2;
quit $ERR_FOOTER;
) || exit $?;
fi
# Got here okay exit to reality
exit 0;
);
exit $?;

View File

@@ -1,17 +0,0 @@
#!/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

View File

@@ -1,88 +0,0 @@
#!/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
if [ -z "$PHP_BIN" ]
then
PHP_BIN=php
fi
if [ "$(echo -e test)" = test ]
then
echo_e="echo -e"
else
echo_e="echo"
fi
# 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
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 | "$PHP_BIN" -n -l -ddisplay_errors\=1 -derror_reporting\=E_ALL -dlog_errrors\=0 2>&1)
if [ $? -ne 0 ]
then
# Swap back in correct filenames
errors=$(echo "$errors"; echo "$result" | grep ':' | sed -e "s@in - on@in $filename on@g")
fi
done
unset IFS
if [ -n "$errors" ]
then
echo "PHP Syntax check failed: "
$echo_e "$errors"
exit 1
fi

View File

@@ -1,42 +0,0 @@
#!/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="$(printf "\n\nPHPBB3-${branch##ticket/}")";
fi
echo "[$branch] $tail$(cat "$1")" > "$1"
fi

View File

@@ -1,16 +0,0 @@
#!/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

View File

@@ -1,194 +0,0 @@
#!/usr/bin/env php
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
function show_usage()
{
$filename = basename(__FILE__);
echo "$filename merges a github pull request.\n";
echo "\n";
echo "Usage: [php] $filename -p pull_request_id [OPTIONS]\n";
echo "\n";
echo "Options:\n";
echo " -p pull_request_id The pull request id to be merged (mandatory)\n";
echo " -r remote Remote of upstream, defaults to 'upstream' (optional)\n";
echo " -d Outputs the commands instead of running them (optional)\n";
echo " -h This help text\n";
exit(2);
}
// Handle arguments
$opts = getopt('p:r:dh');
if (empty($opts) || isset($opts['h']))
{
show_usage();
}
$pull_id = get_arg($opts, 'p', '');
$remote = get_arg($opts, 'r', 'upstream');
$dry_run = !get_arg($opts, 'd', true);
try
{
exit(work($pull_id, $remote));
}
catch (RuntimeException $e)
{
echo $e->getMessage();
exit($e->getCode());
}
function work($pull_id, $remote)
{
// Get some basic data
$pull = get_pull('phpbb', 'phpbb3', $pull_id);
if (!$pull_id)
{
show_usage();
}
if ($pull['state'] != 'open')
{
throw new RuntimeException(sprintf("Error: pull request is closed\n",
$target_branch), 5);
}
$pull_user = $pull['head'][0];
$pull_branch = $pull['head'][1];
$target_branch = $pull['base'][1];
switch ($target_branch)
{
case 'develop-olympus':
run("git checkout develop-olympus");
run("git pull $remote develop-olympus");
add_remote($pull_user, 'phpbb3');
run("git fetch $pull_user");
run("git merge --no-ff $pull_user/$pull_branch");
run("phpBB/vendor/bin/phpunit");
run("git checkout develop");
run("git pull $remote develop");
run("git merge --no-ff develop-olympus");
run("phpBB/vendor/bin/phpunit");
break;
case 'develop':
run("git checkout develop");
run("git pull $remote develop");
add_remote($pull_user, 'phpbb3');
run("git fetch $pull_user");
run("git merge --no-ff $pull_user/$pull_branch");
run("phpBB/vendor/bin/phpunit");
break;
default:
throw new RuntimeException(sprintf("Error: pull request target branch '%s' is not a main branch\n",
$target_branch), 5);
break;
}
}
function add_remote($username, $repository, $pushable = false)
{
$url = get_repository_url($username, $repository, false);
run("git remote add $username $url", true);
if ($pushable)
{
$ssh_url = get_repository_url($username, $repository, true);
run("git remote set-url --push $username $ssh_url");
}
}
function get_repository_url($username, $repository, $ssh = false)
{
$url_base = ($ssh) ? 'git@github.com:' : 'git://github.com/';
return $url_base . $username . '/' . $repository . '.git';
}
function api_request($query)
{
return api_url_request("https://api.github.com/$query?per_page=100");
}
function api_url_request($url)
{
$contents = file_get_contents($url, false, stream_context_create(array(
'http' => array(
'header' => "User-Agent: phpBB/1.0\r\n",
),
)));
if ($contents === false)
{
throw new RuntimeException("Error: failed to retrieve pull request data\n", 4);
}
$contents = json_decode($contents);
if (isset($contents->message) && strpos($contents->message, 'API Rate Limit') === 0)
{
throw new RuntimeException('Reached github API Rate Limit. Please try again later' . "\n", 4);
}
return $contents;
}
function get_pull($username, $repository, $pull_id)
{
$request = api_request("repos/$username/$repository/pulls/$pull_id");
$pull = $request->pull;
$pull_data = array(
'base' => array($pull->base->user->login, $pull->base->ref),
'head' => array($pull->head->user->login, $pull->head->ref),
'state' => $pull->state,
);
return $pull_data;
}
function get_arg($array, $index, $default)
{
return isset($array[$index]) ? $array[$index] : $default;
}
function run($cmd, $ignore_fail = false)
{
global $dry_run;
if (!empty($dry_run))
{
echo "$cmd\n";
}
else
{
passthru(escapeshellcmd($cmd), $status);
if ($status != 0 && !$ignore_fail)
{
throw new RuntimeException(sprintf("Error: command '%s' failed with status %s'\n",
$cmd, $status), 6);
}
}
}

View File

@@ -1,292 +0,0 @@
#!/usr/bin/env php
<?php
/**
*
* This file is part of the phpBB Forum Software package.
*
* @copyright (c) phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
* For full copyright and license information, please see
* the docs/CREDITS.txt file.
*
*/
function show_usage()
{
$filename = basename(__FILE__);
echo "$filename adds repositories of a github network as remotes to a local git repository.\n";
echo "\n";
echo "Usage: [php] $filename -s collaborators|organisation|contributors|forks [OPTIONS]\n";
echo "\n";
echo "Scopes:\n";
echo " collaborators Repositories of people who have push access to the specified repository\n";
echo " contributors Repositories of people who have contributed to the specified repository\n";
echo " organisation Repositories of members of the organisation at github\n";
echo " forks All repositories of the whole github network\n";
echo "\n";
echo "Options:\n";
echo " -s scope See description above (mandatory)\n";
echo " -u github_username Overwrites the github username (optional)\n";
echo " -r repository_name Overwrites the repository name (optional)\n";
echo " -m your_github_username Sets up ssh:// instead of git:// for pushable repositories (optional)\n";
echo " -d Outputs the commands instead of running them (optional)\n";
echo " -h This help text\n";
exit(1);
}
// Handle arguments
$opts = getopt('s:u:r:m:dh');
if (empty($opts) || isset($opts['h']))
{
show_usage();
}
$scope = get_arg($opts, 's', '');
$username = get_arg($opts, 'u', 'phpbb');
$repository = get_arg($opts, 'r', 'phpbb3');
$developer = get_arg($opts, 'm', '');
$dry_run = !get_arg($opts, 'd', true);
run(null, $dry_run);
exit(work($scope, $username, $repository, $developer));
function work($scope, $username, $repository, $developer)
{
// Get some basic data
$forks = get_forks($username, $repository);
$collaborators = get_collaborators($username, $repository);
if ($forks === false || $collaborators === false)
{
echo "Error: failed to retrieve forks or collaborators\n";
return 1;
}
switch ($scope)
{
case 'collaborators':
$remotes = array_intersect_key($forks, $collaborators);
break;
case 'organisation':
$remotes = array_intersect_key($forks, get_organisation_members($username));
break;
case 'contributors':
$remotes = array_intersect_key($forks, get_contributors($username, $repository));
break;
case 'forks':
$remotes = $forks;
break;
default:
show_usage();
}
if (file_exists('.git'))
{
add_remote($username, $repository, isset($collaborators[$developer]));
}
else
{
clone_repository($username, $repository, isset($collaborators[$developer]));
}
// Add private security repository for developers
if ($username == 'phpbb' && $repository == 'phpbb3' && isset($collaborators[$developer]))
{
run("git remote add $username-security " . get_repository_url($username, "$repository-security", true));
}
// Skip blessed repository.
unset($remotes[$username]);
foreach ($remotes as $remote)
{
add_remote($remote['username'], $remote['repository'], $remote['username'] == $developer);
}
run('git remote update');
}
function clone_repository($username, $repository, $pushable = false)
{
$url = get_repository_url($username, $repository, false);
run("git clone $url ./ --origin $username");
if ($pushable)
{
$ssh_url = get_repository_url($username, $repository, true);
run("git remote set-url --push $username $ssh_url");
}
}
function add_remote($username, $repository, $pushable = false)
{
$url = get_repository_url($username, $repository, false);
run("git remote add $username $url");
if ($pushable)
{
$ssh_url = get_repository_url($username, $repository, true);
run("git remote set-url --push $username $ssh_url");
}
}
function get_repository_url($username, $repository, $ssh = false)
{
$url_base = ($ssh) ? 'git@github.com:' : 'git://github.com/';
return $url_base . $username . '/' . $repository . '.git';
}
function api_request($query)
{
return api_url_request("https://api.github.com/$query?per_page=100");
}
function api_url_request($url)
{
$contents = file_get_contents($url, false, stream_context_create(array(
'http' => array(
'header' => "User-Agent: phpBB/1.0\r\n",
),
)));
$sub_request_result = array();
// Check headers for pagination links
if (!empty($http_response_header))
{
foreach ($http_response_header as $header_element)
{
// Find Link Header which gives us a link to the next page
if (strpos($header_element, 'Link: ') === 0)
{
list($head, $header_content) = explode(': ', $header_element);
foreach (explode(', ', $header_content) as $links)
{
list($url, $rel) = explode('; ', $links);
if ($rel == 'rel="next"')
{
// Found a next link, follow it and merge the results
$sub_request_result = api_url_request(substr($url, 1, -1));
}
}
}
}
}
if ($contents === false)
{
return false;
}
$contents = json_decode($contents);
if (isset($contents->message) && strpos($contents->message, 'API Rate Limit') === 0)
{
throw new RuntimeException('Reached github API Rate Limit. Please try again later' . "\n", 4);
}
return ($sub_request_result) ? array_merge($sub_request_result, $contents) : $contents;
}
function get_contributors($username, $repository)
{
$request = api_request("repos/$username/$repository/stats/contributors");
if ($request === false)
{
return false;
}
$usernames = array();
foreach ($request as $contribution)
{
$usernames[$contribution->author->login] = $contribution->author->login;
}
return $usernames;
}
function get_organisation_members($username)
{
$request = api_request("orgs/$username/public_members");
if ($request === false)
{
return false;
}
$usernames = array();
foreach ($request as $member)
{
$usernames[$member->login] = $member->login;
}
return $usernames;
}
function get_collaborators($username, $repository)
{
$request = api_request("repos/$username/$repository/collaborators");
if ($request === false)
{
return false;
}
$usernames = array();
foreach ($request as $collaborator)
{
$usernames[$collaborator->login] = $collaborator->login;
}
return $usernames;
}
function get_forks($username, $repository)
{
$request = api_request("repos/$username/$repository/forks");
if ($request === false)
{
return false;
}
$usernames = array();
foreach ($request as $fork)
{
$usernames[$fork->owner->login] = array(
'username' => $fork->owner->login,
'repository' => $fork->name,
);
}
return $usernames;
}
function get_arg($array, $index, $default)
{
return isset($array[$index]) ? $array[$index] : $default;
}
function run($cmd, $dry = false)
{
static $dry_run;
if (is_null($cmd))
{
$dry_run = $dry;
}
else if (!empty($dry_run))
{
echo "$cmd\n";
}
else
{
passthru(escapeshellcmd($cmd));
}
}

View File

@@ -1,85 +1,9 @@
<IfModule mod_rewrite.c>
RewriteEngine on
<Files "config.php">
Order Allow,Deny
Deny from All
</Files>
#
# Uncomment the statement below if URL rewriting doesn't
# work properly. If you installed phpBB in a subdirectory
# of your site, properly set the argument for the statement.
# e.g.: if your domain is test.com and you installed phpBB
# in http://www.test.com/phpBB/index.php you have to set
# the statement RewriteBase /phpBB/
#
#RewriteBase /
#
# Uncomment the statement below if you want to make use of
# HTTP authentication and it does not already work.
# This could be required if you are for example using PHP via Apache CGI.
#
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
# The following 3 lines will rewrite URLs passed through the front controller
# to not require app.php in the actual URL. In other words, a controller is
# by default accessed at /app.php/my/controller, but can also be accessed at
# /my/controller
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ app.php [QSA,L]
#
# If symbolic links are not already being followed,
# uncomment the line below.
# http://anothersysadmin.wordpress.com/2008/06/10/mod_rewrite-forbidden-403-with-apache-228/
#
#Options +FollowSymLinks
</IfModule>
# With Apache 2.4 the "Order, Deny" syntax has been deprecated and moved from
# module mod_authz_host to a new module called mod_access_compat (which may be
# disabled) and a new "Require" syntax has been introduced to mod_authz_host.
# We could just conditionally provide both versions, but unfortunately Apache
# does not explicitly tell us its version if the module mod_version is not
# available. In this case, we check for the availability of module
# mod_authz_core (which should be on 2.4 or higher only) as a best guess.
<IfModule mod_version.c>
<IfVersion < 2.4>
<Files "config.php">
Order Allow,Deny
Deny from All
</Files>
<Files "common.php">
Order Allow,Deny
Deny from All
</Files>
</IfVersion>
<IfVersion >= 2.4>
<Files "config.php">
Require all denied
</Files>
<Files "common.php">
Require all denied
</Files>
</IfVersion>
</IfModule>
<IfModule !mod_version.c>
<IfModule !mod_authz_core.c>
<Files "config.php">
Order Allow,Deny
Deny from All
</Files>
<Files "common.php">
Order Allow,Deny
Deny from All
</Files>
</IfModule>
<IfModule mod_authz_core.c>
<Files "config.php">
Require all denied
</Files>
<Files "common.php">
Require all denied
</Files>
</IfModule>
</IfModule>
<Files "common.php">
Order Allow,Deny
Deny from All
</Files>

File diff suppressed because it is too large Load Diff

308
phpBB/adm/admin_ban.php Normal file
View File

@@ -0,0 +1,308 @@
<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
if (!empty($setmodules))
{
if (!$auth->acl_get('a_ban'))
{
return;
}
$filename = basename(__FILE__);
$module['USER']['BAN_USERS'] = $filename . "$SID&amp;mode=user";
$module['USER']['BAN_EMAILS'] = $filename . "$SID&amp;mode=email";
$module['USER']['BAN_IPS'] = $filename . "$SID&amp;mode=ip";
return;
}
define('IN_PHPBB', 1);
// Load default header
$phpbb_root_path = '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/functions_user.'.$phpEx);
// Do we have ban permissions?
if (!$auth->acl_get('a_ban'))
{
trigger_error($user->lang['NO_ADMIN']);
}
// Mode setting
$mode = request_var('mode', '');
$bansubmit = (isset($_POST['bansubmit'])) ? true : false;
$unbansubmit= (isset($_POST['unbansubmit'])) ? true : false;
// Set some vars
$current_time = time();
// Start program
if ($bansubmit)
{
// Grab the list of entries
$ban = request_var('ban', '');
$ban_len = request_var('banlength', 0);
$ban_len_other = request_var('banlengthother', '');
$ban_exclude = request_var('banexclude', 0);
$ban_reason = request_var('banreason', '');
user_ban($mode, $ban, $ban_len, $ban_len_other, $ban_exclude, $ban_reason);
trigger_error($user->lang['BAN_UPDATE_SUCESSFUL']);
}
else if ($unbansubmit)
{
$ban = request_var('unban', '');
user_unban($mode, $ban);
trigger_error($user->lang['BAN_UPDATE_SUCESSFUL']);
}
//
// Output relevant entry page
//
//
// Ban length options
//
$ban_end_text = array(0 => $user->lang['PERMANENT'], 30 => $user->lang['30_MINS'], 60 => $user->lang['1_HOUR'], 360 => $user->lang['6_HOURS'], 1440 => $user->lang['1_DAY'], 10080 => $user->lang['7_DAYS'], 20160 => $user->lang['2_WEEKS'], 40320 => $user->lang['1_MONTH'], -1 => $user->lang['OTHER'] . ' -&gt; ');
$ban_end_options = '';
foreach ($ban_end_text as $length => $text)
{
$ban_end_options .= '<option value="' . $length . '">' . $text . '</option>';
}
// Title
switch ($mode)
{
case 'user':
$l_title = $user->lang['BAN_USERS'];
break;
case 'email':
$l_title = $user->lang['BAN_EMAILS'];
break;
case 'ip':
$l_title = $user->lang['BAN_IPS'];
break;
}
// Output page
adm_page_header($l_title);
?>
<p><?php echo $user->lang['BAN_EXPLAIN']; ?></p>
<?php
switch ($mode)
{
case 'user':
$field = 'username';
$l_ban_title = $user->lang['BAN_USERS'];
$l_ban_explain = $user->lang['BAN_USERNAME_EXPLAIN'];
$l_ban_exclude_explain = $user->lang['BAN_USER_EXCLUDE_EXPLAIN'];
$l_unban_title = $user->lang['UNBAN_USERNAME'];
$l_unban_explain = $user->lang['UNBAN_USERNAME_EXPLAIN'];
$l_ban_cell = $user->lang['USERNAME'] . ': <br /><span class="gensmall">[ <a href="' . "../memberlist.$phpEx$SID&amp;mode=searchuser&amp;form=banning&amp;field=ban\" onclick=\"window.open('../memberlist.$phpEx$SID&amp;mode=searchuser&amp;form=banning&amp;field=ban', '_phpbbsearch', 'HEIGHT=500,resizable=yes,scrollbars=yes,WIDTH=740');return false;\">" . $user->lang['FIND_USERNAME'] .'</a> ]</span>';
$l_no_ban_cell = $user->lang['NO_BANNED_USERS'];
$sql = 'SELECT b.*, u.user_id, u.username
FROM ' . BANLIST_TABLE . ' b, ' . USERS_TABLE . ' u
WHERE (b.ban_end >= ' . time() . '
OR b.ban_end = 0)
AND u.user_id = b.ban_userid
AND b.ban_userid <> 0
AND u.user_id <> ' . ANONYMOUS . '
ORDER BY u.user_id ASC';
break;
case 'ip':
$field = 'ban_ip';
$l_ban_title = $user->lang['BAN_IPS'];
$l_ban_explain = $user->lang['BAN_IP_EXPLAIN'];
$l_ban_exclude_explain = $user->lang['BAN_IP_EXCLUDE_EXPLAIN'];
$l_unban_title = $user->lang['UNBAN_IP'];
$l_unban_explain = $user->lang['UNBAN_IP_EXPLAIN'];
$l_ban_cell = $user->lang['IP_HOSTNAME'] . ':';
$l_no_ban_cell = $user->lang['NO_BANNED_IP'];
$sql = 'SELECT *
FROM ' . BANLIST_TABLE . '
WHERE (ban_end >= ' . time() . "
OR ban_end = 0)
AND ban_ip <> ''";
break;
case 'email':
$field = 'ban_email';
$l_ban_title = $user->lang['BAN_EMAILS'];
$l_ban_explain = $user->lang['BAN_EMAIL_EXPLAIN'];
$l_ban_exclude_explain = $user->lang['BAN_EMAIL_EXCLUDE_EXPLAIN'];
$l_unban_title = $user->lang['UNBAN_EMAIL'];
$l_unban_explain = $user->lang['UNBAN_EMAIL_EXPLAIN'];
$l_ban_cell = $user->lang['EMAIL_ADDRESS'] . ':';
$l_no_ban_cell = $user->lang['NO_BANNED_EMAIL'];
$sql = 'SELECT *
FROM ' . BANLIST_TABLE . '
WHERE (ban_end >= ' . time() . "
OR ban_end = 0)
AND ban_email <> ''";
break;
}
$result = $db->sql_query($sql);
$banned_options = '';
$ban_length = $ban_reasons = array();
if ($row = $db->sql_fetchrow($result))
{
do
{
$banned_options .= '<option' . (($row['ban_exclude']) ? ' class="sep"' : '') . ' value="' . $row['ban_id'] . '">' . $row[$field] . '</option>';
$time_length = (!empty($row['ban_end'])) ? ($row['ban_end'] - $row['ban_start']) / 60 : 0;
$ban_length[$row['ban_id']] = (!empty($ban_end_text[$time_length])) ? $ban_end_text[$time_length] : $user->lang['OTHER'] . ' -> ' . gmdate('Y-m-d', $row['ban_end']);
$ban_reasons[$row['ban_id']] = addslashes($row['ban_reason']);
}
while ($row = $db->sql_fetchrow($result));
}
$db->sql_freeresult($result);
?>
<h1><?php echo $l_ban_title; ?></h1>
<p><?php echo $l_ban_explain; ?></p>
<script language="Javascript" type="text/javascript">
<!--
var ban_length = new Array();
<?php
if (sizeof($ban_length))
{
foreach ($ban_length as $ban_id => $length)
{
echo "ban_length['$ban_id'] = \"$length\";\n";
}
}
?>
var ban_reason = new Array();
<?php
if (sizeof($ban_reasons))
{
foreach ($ban_reasons as $ban_id => $reason)
{
echo "ban_reason['$ban_id'] = \"$reason\";\n";
}
}
?>
function display_details(option)
{
document.forms[0].unbanreason.value = ban_reason[option];
document.forms[0].unbanlength.value = ban_length[option];
}
//-->
</script>
<form name="banning" method="post" action="<?php echo "admin_ban.$phpEx$SID&amp;mode=$mode"; ?>"><table class="bg" width="80%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $l_ban_title; ?></th>
</tr>
<tr>
<td class="row1" width="45%"><?php echo $l_ban_cell; ?></td>
<td class="row2"><textarea cols="40" rows="3" name="ban"></textarea></td>
</tr>
<tr>
<td class="row1" width="45%"><?php echo $user->lang['BAN_LENGTH']; ?>:</td>
<td class="row2"><select name="banlength"><?php echo $ban_end_options; ?></select>&nbsp; <input class="post" type="text" name="banlengthother" maxlength="10" size="10" /></td>
</tr>
<tr>
<td class="row1" width="45%"><?php echo $user->lang['BAN_EXCLUDE']; ?>: <br /><span class="gensmall"><?php echo $l_ban_exclude_explain;;?></span></td>
<td class="row2"><input type="radio" name="banexclude" value="1" /> <?php echo $user->lang['YES']; ?> &nbsp; <input type="radio" name="banexclude" value="0" checked="checked" /> <?php echo $user->lang['NO']; ?></td>
</tr>
<tr>
<td class="row1" width="45%"><?php echo $user->lang['BAN_REASON']; ?>:</td>
<td class="row2"><input class="post" type="text" name="banreason" maxlength="255" size="40" /></td>
</tr>
<tr>
<td class="cat" colspan="2" align="center"> <input type="submit" name="bansubmit" value="<?php echo $user->lang['SUBMIT']; ?>" class="btnmain" />&nbsp; <input type="reset" value="<?php echo $user->lang['RESET']; ?>" class="btnlite" />&nbsp;</td>
</tr>
</table>
<h1><?php echo $l_unban_title; ?></h1>
<p><?php echo $l_unban_explain; ?></p>
<table class="bg" width="80%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $l_unban_title; ?></th>
</tr>
<?php
if ($banned_options)
{
?>
<tr>
<td class="row1" width="45%"><?php echo $l_ban_cell; ?>: <br /></td>
<td class="row2"> <select name="unban[]" multiple="multiple" size="5" onchange="display_details(this.options[this.selectedIndex].value)"><?php echo $banned_options; ?></select></td>
</tr>
<tr>
<td class="row1" width="45%"><?php echo $user->lang['BAN_REASON']; ?>:</td>
<td class="row2"><input class="row1" style="border:0px" type="text" name="unbanreason" size="40" /></td>
</tr>
<tr>
<td class="row1" width="45%"><?php echo $user->lang['BAN_LENGTH']; ?>:</td>
<td class="row2"><input class="row1" style="border:0px" type="text" name="unbanlength" size="40" /></td>
</tr>
<tr>
<td class="cat" colspan="2" align="center"><input type="submit" name="unbansubmit" value="<?php echo $user->lang['SUBMIT']; ?>" class="btnmain" />&nbsp; <input type="reset" value="<?php echo $user->lang['RESET']; ?>" class="btnlite" /></td>
</tr>
<?php
}
else
{
?>
<tr>
<td class="row2" colspan="2" align="center"><?php echo $l_no_ban_cell; ?></td>
</tr>
<?php
}
?>
</table></form>
<?php
adm_page_footer();
?>

440
phpBB/adm/admin_bbcodes.php Normal file
View File

@@ -0,0 +1,440 @@
<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
if (!empty($setmodules))
{
if (!$auth->acl_get('a_bbcode'))
{
return;
}
$module['POST']['BBCODES'] = basename(__FILE__) . $SID;
return;
}
define('IN_PHPBB', 1);
// Include files
$phpbb_root_path = '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
// Do we have general permissions?
if (!$auth->acl_get('a_bbcode'))
{
trigger_error('NO_ADMIN');
}
// Set up general vars
$mode = request_var('mode', '');
$bbcode_id = request_var('bbcode', 0);
// Set up mode-specific vars
switch ($mode)
{
case 'add':
$bbcode_match = $bbcode_tpl = '';
break;
case 'edit':
$sql = 'SELECT bbcode_match, bbcode_tpl
FROM ' . BBCODES_TABLE . '
WHERE bbcode_id = ' . $bbcode_id;
$result = $db->sql_query($sql);
if (!$row = $db->sql_fetchrow($result))
{
trigger_error('BBCODE_NOT_EXIST');
}
$db->sql_freeresult($result);
$bbcode_match = $row['bbcode_match'];
$bbcode_tpl = htmlspecialchars($row['bbcode_tpl']);
break;
case 'modify':
$sql = 'SELECT bbcode_id
FROM ' . BBCODES_TABLE . '
WHERE bbcode_id = ' . $bbcode_id;
$result = $db->sql_query($sql);
if (!$row = $db->sql_fetchrow($result))
{
trigger_error('BBCODE_NOT_EXIST');
}
$db->sql_freeresult($result);
// No break here
case 'create':
$bbcode_match = htmlspecialchars(stripslashes($_POST['bbcode_match']));
$bbcode_tpl = stripslashes($_POST['bbcode_tpl']);
break;
}
// Do major work
switch ($mode)
{
case 'edit':
case 'add':
adm_page_header($user->lang['BBCODES']);
?>
<h1><?php echo $user->lang['BBCODES'] ?></h1>
<p><?php echo $user->lang['BBCODES_EXPLAIN'] ?></p>
<form method="post" action="admin_bbcodes.<?php echo $phpEx . $SID . '&amp;mode=' . (($mode == 'add') ? 'create' : 'modify') . (($bbcode_id) ? "&amp;bbcode=$bbcode_id" : '') ?>">
<table cellspacing="1" cellpadding="0" border="0" align="center" width="90%">
<tr>
<td><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang['BBCODE_USAGE'] ?></th>
</tr>
<tr>
<td class="row3" colspan="2"><?php echo $user->lang['BBCODE_USAGE_EXPLAIN'] ?></td>
</tr>
<tr valign="top">
<td class="row1" width="40%"><b><?php echo $user->lang['EXAMPLES'] ?></b><br /><br /><?php echo $user->lang['BBCODE_USAGE_EXAMPLE'] ?></td>
<td class="row2"><textarea name="bbcode_match" cols="60" rows="5"><?php echo $bbcode_match ?></textarea></td>
</tr>
</table></td>
</tr>
</table>
<br clear="all" />
<table cellspacing="1" cellpadding="0" border="0" align="center" width="90%">
<tr>
<td><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang['HTML_REPLACEMENT'] ?></th>
</tr>
<tr>
<td class="row3" colspan="2"><?php echo $user->lang['HTML_REPLACEMENT_EXPLAIN'] ?></td>
</tr>
<tr valign="top">
<td class="row1" width="40%"><b><?php echo $user->lang['EXAMPLES'] ?></b><br /><br /><?php echo $user->lang['HTML_REPLACEMENT_EXAMPLE'] ?></td>
<td class="row2"><textarea name="bbcode_tpl" cols="60" rows="8"><?php echo $bbcode_tpl ?></textarea></td>
</tr>
<tr>
<td class="cat" colspan="2" align="center"><input type="submit" value="<?php echo $user->lang['SUBMIT'] ?>" class="btnmain" /></td>
</tr>
</table></td>
</tr>
</table>
<br clear="all" />
<table cellspacing="1" cellpadding="0" border="0" align="center" width="90%">
<tr>
<td><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang['TOKENS'] ?></th>
</tr>
<tr>
<td class="row3" colspan="2"><?php echo $user->lang['TOKENS_EXPLAIN'] ?></td>
</tr>
<tr>
<th><?php echo $user->lang['TOKEN'] ?></th>
<th><?php echo $user->lang['TOKEN_DEFINITION'] ?></th>
</tr>
<?php
foreach ($user->lang['tokens'] as $token => $token_explain)
{
?><tr valign="top">
<td class="row1">{<?php echo $token ?>}</td>
<td class="row2"><?php echo $token_explain ?></td>
</tr><?php
}
?>
</table></td>
</tr>
</table>
</form>
<?php
adm_page_footer();
break;
case 'modify':
case 'create':
adm_page_header($user->lang['BBCODES']);
$data = build_regexp($bbcode_match, $bbcode_tpl);
$sql_ary = array(
'bbcode_tag' => $data['bbcode_tag'],
'bbcode_match' => $bbcode_match,
'bbcode_tpl' => $bbcode_tpl,
'first_pass_match' => $data['first_pass_match'],
'first_pass_replace' => $data['first_pass_replace'],
'second_pass_match' => $data['second_pass_match'],
'second_pass_replace' => $data['second_pass_replace']
);
if ($mode == 'create')
{
/* TODO: look for SQL incompatibilities
// NOTE: I'm sure there was another simpler (and obvious) way of finding a suitable bbcode_id
$sql = 'SELECT b1.bbcode_id
FROM ' . BBCODES_TABLE . ' b1, ' . BBCODES_TABLE . ' b2
WHERE b2.bbcode_id > b1.bbcode_id
GROUP BY b1.bbcode_id
HAVING MIN(b2.bbcode_id) > b1.bbcode_id + 1
ORDER BY b1.bbcode_id ASC';
$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
*/
$sql = 'SELECT MAX(bbcode_id) as bbcode_id
FROM ' . BBCODES_TABLE;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if ($row)
{
$bbcode_id = $row['bbcode_id'] + 1;
}
else
{
$sql = 'SELECT MIN(bbcode_id) AS min_id, MAX(bbcode_id) AS max_id
FROM ' . BBCODES_TABLE;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (empty($row['min_id']) || $row['min_id'] >= NUM_CORE_BBCODES)
{
$bbcode_id = NUM_CORE_BBCODES + 1;
}
else
{
$bbcode_id = $row['max_id'] + 1;
}
}
if ($bbcode_id > 31)
{
trigger_error('TOO_MANY_BBCODES');
}
$sql_ary['bbcode_id'] = (int) $bbcode_id;
$db->sql_query('INSERT INTO ' . BBCODES_TABLE . $db->sql_build_array('INSERT', $sql_ary));
$lang = 'BBCODE_ADDED';
$log_action = 'LOG_BBCODE_ADD';
}
else
{
$db->sql_query('UPDATE ' . BBCODES_TABLE . ' SET ' . $db->sql_build_array('UPDATE', $sql_ary) . ' WHERE bbcode_id = ' . $bbcode_id);
$lang = 'BBCODE_EDITED';
$log_action = 'LOG_BBCODE_EDIT';
}
add_log('admin', $log_action, $data['bbcode_tag']);
trigger_error($lang);
break;
case 'delete':
$sql = 'SELECT bbcode_tag
FROM ' . BBCODES_TABLE . "
WHERE bbcode_id = $bbcode_id";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
$db->sql_query('DELETE FROM ' . BBCODES_TABLE . " WHERE bbcode_id = $bbcode_id");
add_log('admin', 'LOG_BBCODE_DELETE', $row['bbcode_tag']);
}
$db->sql_freeresult($result);
// No break here
default:
adm_page_header($user->lang['BBCODES']);
?>
<h1><?php echo $user->lang['BBCODES'] ?></h1>
<p><?php echo $user->lang['BBCODES_EXPLAIN'] ?></p>
<form method="post" action="admin_bbcodes.<?php echo $phpEx . $SID ?>&amp;mode=add"><table cellspacing="1" cellpadding="0" border="0" align="center">
<tr>
<td><table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th><?php echo $user->lang['BBCODE_TAG'] ?></th>
<th><?php echo $user->lang['ACTION'] ?></th>
</tr><?php
$sql = 'SELECT *
FROM ' . BBCODES_TABLE . '
ORDER BY bbcode_id';
$result = $db->sql_query($sql);
$row_class = '';
while ($row = $db->sql_fetchrow($result))
{
$row_class = ($row_class == 'row1') ? 'row2' : 'row1';
?>
<tr>
<td class="<?php echo $row_class ?>" align="center"><?php echo $row['bbcode_tag'] ?></td>
<td class="<?php echo $row_class ?>" align="center"><a href="admin_bbcodes.<?php echo $phpEx . $SID ?>&amp;mode=edit&amp;bbcode=<?php echo $row['bbcode_id'] ?>"><?php echo $user->lang['EDIT'] ?></a> | <a href="admin_bbcodes.<?php echo $phpEx . $SID ?>&amp;mode=delete&amp;bbcode=<?php echo $row['bbcode_id'] ?>"><?php echo $user->lang['DELETE'] ?></a></td>
</tr>
<?php
}
$db->sql_freeresult($result);
?>
<tr>
<td class="cat" colspan="2" align="center"><input type="submit" value="<?php echo $user->lang['ADD_BBCODE'] ?>" class="btnmain" /></td>
</tr>
</table></td>
</tr>
</table></form>
<?php
adm_page_footer();
}
// -----------------------------
// Functions
function build_regexp($msg_bbcode, $msg_html)
{
$msg_bbcode = trim($msg_bbcode);
$msg_html = trim($msg_html);
$fp_match = preg_quote($msg_bbcode, '!');
$fp_replace = preg_replace('#^\[(.*?)\]#', '[$1:$uid]', $msg_bbcode);
$fp_replace = preg_replace('#\[/(.*?)\]$#', '[/$1:$uid]', $fp_replace);
$sp_match = preg_quote($msg_bbcode, '!');
$sp_match = preg_replace('#^\\\\\[(.*?)\\\\\]#', '\[$1:$uid\]', $sp_match);
$sp_match = preg_replace('#\\\\\[/(.*?)\\\\\]$#', '\[/$1:$uid\]', $sp_match);
$sp_replace = $msg_html;
$tokens = array(
'URL' => array(
'!([a-z0-9]+://)?([^?].*?[^ \t\n\r<"]*)!ie' => "(('\$1') ? '\$1\$2' : 'http://\$2')"
),
'LOCAL_URL' => array(
'!([^:]+/[^ \t\n\r<"]*)!' => '$1'
),
'EMAIL' => array(
'!([a-z0-9]+[a-z0-9\-\._]*@(?:(?:[0-9]{1,3}\.){3,5}[0-9]{1,3}|[a-z0-9]+[a-z0-9\-\._]*\.[a-z]+))!i' => '$1'
),
'TEXT' => array(
'!(.*?)!es' => "str_replace('\\\"', '&quot;', str_replace('\\'', '&#39;', '\$1'))"
),
'COLOR' => array(
'!([a-z]+|#[0-9abcdef]+!i' => '$1'
),
'NUMBER' => array(
'!([0-9]+)!' => '$1'
)
);
if (preg_match_all('/\{(' . implode('|', array_keys($tokens)) . ')[0-9]*\}/i', $msg_bbcode, $m))
{
$pad = 0;
$modifiers = 'i';
foreach ($m[0] as $n => $token)
{
$token_type = $m[1][$n];
reset($tokens[$token_type]);
list($match, $replace) = each($tokens[$token_type]);
// Pad backreference numbers from tokens
if (preg_match_all('/(?<!\\\\)\$([0-9]+)/', $replace, $repad))
{
$repad = $pad + count(array_unique($repad[0]));
$replace = preg_replace('/(?<!\\\\)\$([0-9]+)/e', "'\$' . (\$1 + \$pad)", $replace);
$pad = $repad;
}
// Obtain pattern modifiers to use and alter the regex accordingly
$regex = preg_replace('/!(.*)!([a-z]*)/', '$1', $match);
$regex_modifiers = preg_replace('/!(.*)!([a-z]*)/', '$2', $match);
for ($i = 0; $i < strlen($regex_modifiers); ++$i)
{
if (strpos($modifiers, $regex_modifiers[$i]) === FALSE)
{
$modifiers .= $regex_modifiers[$i];
if ($regex_modifiers[$i] == 'e')
{
$fp_replace = "'" . str_replace("'", "\\'", $fp_replace) . "'";
}
}
if ($regex_modifiers[$i] == 'e')
{
$replace = "'.$replace.'";
}
}
$fp_match = str_replace(preg_quote($token, '!'), $regex, $fp_match);
$fp_replace = str_replace($token, $replace, $fp_replace);
$sp_match = str_replace(preg_quote($token, '!'), '(.*?)', $sp_match);
$sp_replace = str_replace($token, '$' . ($n + 1), $sp_replace);
}
$fp_match = '!' . $fp_match . '!' . $modifiers;
$sp_match = '!' . $sp_match . '!s';
if (strpos($fp_match, 'e') !== FALSE)
{
$fp_replace = str_replace("'.'", '', $fp_replace);
$fp_replace = str_replace(".''.", '.', $fp_replace);
}
}
else
{
// No replacement is present, no need for a second-pass pattern replacement
// A simple str_replace will suffice
$fp_match = '!' . $fp_match . '!' . $modifiers;
$sp_match = $fp_replace;
$sp_replace = '';
}
// Lowercase tags
$bbcode_tag = preg_replace('/.*?\[([a-z]+).*/i', '$1', $msg_bbcode);
$fp_match = preg_replace('#\[/?' . $bbcode_tag . '#ie', "strtolower('\$0')", $fp_match);
$fp_replace = preg_replace('#\[/?' . $bbcode_tag . '#ie', "strtolower('\$0')", $fp_replace);
$sp_match = preg_replace('#\[/?' . $bbcode_tag . '#ie', "strtolower('\$0')", $sp_match);
$sp_replace = preg_replace('#\[/?' . $bbcode_tag . '#ie', "strtolower('\$0')", $sp_replace);
return array(
'bbcode_tag' => $bbcode_tag,
'first_pass_match' => $fp_match,
'first_pass_replace' => $fp_replace,
'second_pass_match' => $sp_match,
'second_pass_replace' => $sp_replace
);
}
// End Functions
// -----------------------------
?>

517
phpBB/adm/admin_board.php Normal file
View File

@@ -0,0 +1,517 @@
<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
if (!empty($setmodules))
{
$filename = basename(__FILE__);
$module['GENERAL']['AUTH_SETTINGS'] = ($auth->acl_get('a_server')) ? "$filename$SID&amp;mode=auth" : '';
$module['GENERAL']['AVATAR_SETTINGS'] = ($auth->acl_get('a_board')) ? "$filename$SID&amp;mode=avatar" : '';
$module['GENERAL']['BOARD_DEFAULTS'] = ($auth->acl_get('a_defaults')) ? "$filename$SID&amp;mode=default" : '';
$module['GENERAL']['BOARD_SETTINGS'] = ($auth->acl_get('a_board')) ? "$filename$SID&amp;mode=setting" : '';
$module['GENERAL']['COOKIE_SETTINGS'] = ($auth->acl_get('a_cookies')) ? "$filename$SID&amp;mode=cookie" : '';
$module['GENERAL']['EMAIL_SETTINGS'] = ($auth->acl_get('a_server')) ? "$filename$SID&amp;mode=email" : '';
$module['GENERAL']['LOAD_SETTINGS'] = ($auth->acl_get('a_server')) ? "$filename$SID&amp;mode=load" : '';
$module['GENERAL']['SERVER_SETTINGS'] = ($auth->acl_get('a_server')) ? "$filename$SID&amp;mode=server" : '';
$module['GENERAL']['MESSAGE_SETTINGS'] = ($auth->acl_get('a_defaults')) ? "$filename$SID&amp;mode=message" : '';
return;
}
define('IN_PHPBB', 1);
// Load default header
$phpbb_root_path = '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
// Get mode
$mode = request_var('mode', '');
$action = request_var('action', '');
$submit = (isset($_POST['submit'])) ? true : false;
// Set config vars
$display_vars = array(
'cookie' => array(
'auth' => 'a_cookies',
'title' => 'COOKIE_SETTINGS',
'vars' => array(
'cookie_domain' => array('lang' => 'COOKIE_DOMAIN', 'type' => 'text::255', 'explain' => false),
'cookie_name' => array('lang' => 'COOKIE_NAME', 'type' => 'text::16', 'explain' => false),
'cookie_path' => array('lang' => 'COOKIE_PATH', 'type' => 'text::255', 'explain' => false),
'cookie_secure' => array('lang' => 'COOKIE_SECURE', 'type' => 'radio:disabled_enabled', 'explain' => true)
)
),
'avatar' => array(
'auth' => 'a_board',
'title' => 'AVATAR_SETTINGS',
'vars' => array(
'avatar_min_height' => false, 'avatar_min_width' => false, 'avatar_max_height' => false, 'avatar_max_width' => false,
'allow_avatar_local' => array('lang' => 'ALLOW_LOCAL', 'type' => 'radio:yes_no', 'explain' => false),
'allow_avatar_remote' => array('lang' => 'ALLOW_REMOTE', 'type' => 'radio:yes_no', 'explain' => true),
'allow_avatar_upload' => array('lang' => 'ALLOW_UPLOAD', 'type' => 'radio:yes_no', 'explain' => false),
'avatar_filesize' => array('lang' => 'MAX_FILESIZE', 'type' => 'text:4:10', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']),
'avatar_min' => array('lang' => 'MIN_AVATAR_SIZE', 'type' => 'dimension:3:4', 'explain' => true),
'avatar_max' => array('lang' => 'MAX_AVATAR_SIZE', 'type' => 'dimension:3:4', 'explain' => true),
'avatar_path' => array('lang' => 'AVATAR_STORAGE_PATH', 'type' => 'text:20:255', 'explain' => true),
'avatar_gallery_path' => array('lang' => 'AVATAR_GALLERY_PATH', 'type' => 'text:20:255', 'explain' => true)
)
),
'email' => array(
'auth' => 'a_server',
'title' => 'EMAIL_SETTINGS',
'vars' => array(
'email_enable' => array('lang' => 'ENABLE_EMAIL', 'type' => 'radio:enabled_disabled', 'explain' => true),
'board_email_form' => array('lang' => 'BOARD_EMAIL_FORM', 'type' => 'radio:enabled_disabled', 'explain' => true),
'board_hide_emails' => array('lang' => 'BOARD_HIDE_EMAILS', 'type' => 'radio:enabled_disabled', 'explain' => true),
'email_function_name' => array('lang' => 'EMAIL_FUNCTION_NAME', 'type' => 'text:20:50', 'explain' => true),
'email_package_size' => array('lang' => 'EMAIL_PACKAGE_SIZE', 'type' => 'text:5:5', 'explain' => true),
'board_contact' => array('lang' => 'CONTACT_EMAIL', 'type' => 'text:25:100', 'explain' => true),
'board_email' => array('lang' => 'ADMIN_EMAIL', 'type' => 'text:25:100', 'explain' => true),
'board_email_sig' => array('lang' => 'EMAIL_SIG', 'type' => 'textarea:5:30', 'explain' => true),
'smtp_delivery' => array('lang' => 'USE_SMTP', 'type' => 'radio:yes_no', 'explain' => true),
'smtp_host' => array('lang' => 'SMTP_SERVER', 'type' => 'text:25:50', 'explain' => false),
'smtp_port' => array('lang' => 'SMTP_PORT', 'type' => 'text:4:5', 'explain' => true),
'smtp_auth_method' => array('lang' => 'SMTP_AUTH_METHOD', 'type' => 'select', 'options' => 'mail_auth_select(\'{VALUE}\')', 'explain' => true),
'smtp_username' => array('lang' => 'SMTP_USERNAME', 'type' => 'text:25:255', 'explain' => true),
'smtp_password' => array('lang' => 'SMTP_PASSWORD', 'type' => 'password:25:255', 'explain' => true)
)
),
'load' => array(
'auth' => 'a_server',
'title' => 'SERVER_SETTINGS',
'vars' => array(
'limit_load' => array('lang' => 'LIMIT_LOAD', 'type' => 'text:4:4', 'explain' => true),
'session_length' => array('lang' => 'SESSION_LENGTH', 'type' => 'text:5:5', 'explain' => true),
'active_sessions' => array('lang' => 'LIMIT_SESSIONS', 'type' => 'text:4:4', 'explain' => true),
'load_db_track' => array('lang' => 'YES_POST_MARKING', 'type' => 'radio:yes_no', 'explain' => true),
'load_db_lastread' => array('lang' => 'YES_READ_MARKING', 'type' => 'radio:yes_no', 'explain' => true),
'load_online' => array('lang' => 'YES_ONLINE', 'type' => 'radio:yes_no', 'explain' => true),
'load_online_guests'=> array('lang' => 'YES_ONLINE_GUESTS', 'type' => 'radio:yes_no', 'explain' => true),
'load_onlinetrack' => array('lang' => 'YES_ONLINE_TRACK', 'type' => 'radio:yes_no', 'explain' => true),
'load_online_time' => array('lang' => 'ONLINE_LENGTH', 'type' => 'text:4:3', 'explain' => true),
'load_birthdays' => array('lang' => 'YES_BIRTHDAYS', 'type' => 'radio:yes_no', 'explain' => false),
'load_moderators' => array('lang' => 'YES_MODERATORS', 'type' => 'radio:yes_no', 'explain' => false),
'load_jumpbox' => array('lang' => 'YES_JUMPBOX', 'type' => 'radio:yes_no', 'explain' => false),
'load_search' => array('lang' => 'YES_SEARCH', 'type' => 'radio:yes_no', 'explain' => true),
'search_interval' => array('lang' => 'SEARCH_INTERVAL', 'type' => 'text:3:4', 'explain' => true),
'min_search_chars' => array('lang' => 'MIN_SEARCH_CHARS', 'type' => 'text:3:3', 'explain' => true),
'max_search_chars' => array('lang' => 'MAX_SEARCH_CHARS', 'type' => 'text:3:3', 'explain' => true),
'load_search_upd' => array('lang' => 'YES_SEARCH_UPDATE', 'type' => 'radio:yes_no', 'explain' => true),
// 'load_search_phr' => array('lang' => 'YES_SEARCH_PHRASE', 'type' => 'radio:yes_no', 'explain' => true),
'load_tplcompile' => array('lang' => 'RECOMPILE_TEMPLATES', 'type' => 'radio:yes_no', 'explain' => true)
)
),
'default' => array(
'auth' => 'a_defaults',
'title' => 'BOARD_DEFAULTS',
'vars' => array(
'default_style' => array('lang' => 'DEFAULT_STYLE', 'type' => 'select', 'options' => 'style_select(\'{VALUE}\', true)', 'explain' => false),
'override_user_style' => array('lang' => 'OVERRIDE_STYLE', 'type' => 'radio:yes_no', 'explain' => true),
'default_lang' => array('lang' => 'DEFAULT_LANGUAGE', 'type' => 'select', 'options' => 'language_select(\'{VALUE}\')', 'explain' => false),
'default_dateformat' => array('lang' => 'DEFAULT_DATE_FORMAT', 'type' => 'text::255', 'explain' => true),
'board_timezone' => array('lang' => 'SYSTEM_TIMEZONE', 'type' => 'select', 'options' => 'tz_select(\'{VALUE}\')', 'explain' => false),
'board_dst' => array('lang' => 'SYSTEM_DST', 'type' => 'radio:yes_no', 'explain' => false),
'allow_privmsg' => array('lang' => 'BOARD_PM', 'type' => 'radio:yes_no', 'explain' => true),
'allow_topic_notify' => array('lang' => 'ALLOW_TOPIC_NOTIFY', 'type' => 'radio:yes_no', 'explain' => false),
'allow_forum_notify' => array('lang' => 'ALLOW_FORUM_NOTIFY', 'type' => 'radio:yes_no', 'explain' => false),
'allow_namechange' => array('lang' => 'ALLOW_NAME_CHANGE', 'type' => 'radio:yes_no', 'explain' => false),
'allow_attachments' => array('lang' => 'ALLOW_ATTACHMENTS', 'type' => 'radio:yes_no', 'explain' => false),
'allow_html' => array('lang' => 'ALLOW_HTML', 'type' => 'radio:yes_no', 'explain' => false),
'allow_html_tags' => array('lang' => 'ALLOWED_TAGS', 'type' => 'text:30:255', 'explain' => true),
'allow_bbcode' => array('lang' => 'ALLOW_BBCODE', 'type' => 'radio:yes_no', 'explain' => false),
'allow_smilies' => array('lang' => 'ALLOW_SMILIES', 'type' => 'radio:yes_no', 'explain' => false),
'allow_sig' => array('lang' => 'ALLOW_SIG', 'type' => 'radio:yes_no', 'explain' => false),
'max_sig_chars' => array('lang' => 'MAX_SIG_LENGTH', 'type' => 'text:5:4', 'explain' => true),
'allow_nocensors' => array('lang' => 'ALLOW_NO_CENSORS', 'type' => 'radio:yes_no', 'explain' => true),
'allow_bookmarks' => array('lang' => 'ALLOW_BOOKMARKS', 'type' => 'radio:yes_no', 'explain' => true)
)
),
'message' => array(
'auth' => 'a_defaults',
'title' => 'MESSAGE_SETTINGS',
'lang' => 'ucp',
'vars' => array(
'pm_max_boxes' => array('lang' => 'BOXES_MAX', 'type' => 'text:4:4', 'explain' => true),
'pm_max_msgs' => array('lang' => 'BOXES_LIMIT', 'type' => 'text:4:4', 'explain' => true),
'full_folder_action' => array('lang' => 'FULL_FOLDER_ACTION', 'type' => 'select', 'options' => 'full_folder_select(\'{VALUE}\')', 'explain' => true),
'pm_edit_time' => array('lang' => 'PM_EDIT_TIME', 'type' => 'text:3:3', 'explain' => true),
'allow_mass_pm' => array('lang' => 'ALLOW_MASS_PM', 'type' => 'radio:yes_no', 'explain' => false),
'auth_html_pm' => array('lang' => 'ALLOW_HTML_PM', 'type' => 'radio:yes_no', 'explain' => false),
'auth_bbcode_pm' => array('lang' => 'ALLOW_BBCODE_PM', 'type' => 'radio:yes_no', 'explain' => false),
'auth_smilies_pm' => array('lang' => 'ALLOW_SMILIES_PM', 'type' => 'radio:yes_no', 'explain' => false),
'allow_pm_attach' => array('lang' => 'ALLOW_PM_ATTACHMENTS', 'type' => 'radio:yes_no', 'explain' => false),
'auth_download_pm' => array('lang' => 'ALLOW_DOWNLOAD_PM', 'type' => 'radio:yes_no', 'explain' => false),
'auth_report_pm' => array('lang' => 'ALLOW_REPORT_PM', 'type' => 'radio:yes_no', 'explain' => false),
'print_pm' => array('lang' => 'ALLOW_PRINT_PM', 'type' => 'radio:yes_no', 'explain' => false),
'email_pm' => array('lang' => 'ALLOW_EMAIL_PM', 'type' => 'radio:yes_no', 'explain' => false),
'forward_pm' => array('lang' => 'ALLOW_FORWARD_PM', 'type' => 'radio:yes_no', 'explain' => false),
'auth_img_pm' => array('lang' => 'ALLOW_IMG_PM', 'type' => 'radio:yes_no', 'explain' => false),
'auth_flash_pm' => array('lang' => 'ALLOW_FLASH_PM', 'type' => 'radio:yes_no', 'explain' => false),
'enable_pm_icons' => array('lang' => 'ENABLE_PM_ICONS', 'type' => 'radio:yes_no', 'explain' => false)
)
),
'server' => array(
'auth' => 'a_server',
'title' => 'SERVER_SETTINGS',
'vars' => array(
'server_name' => array('lang' => 'SERVER_NAME', 'type' => 'text:40:255', 'explain' => true),
'server_port' => array('lang' => 'SERVER_PORT', 'type' => 'text:5:5', 'explain' => true),
'script_path' => array('lang' => 'SCRIPT_PATH', 'type' => 'text::255', 'explain' => true),
'ip_check' => array('lang' => 'IP_VALID', 'type' => 'custom', 'options' => 'select_ip_check(\'{VALUE}\')', 'explain' => true),
'browser_check' => array('lang' => 'BROWSER_VALID', 'type' => 'radio:yes_no', 'explain' => true),
'gzip_compress' => array('lang' => 'ENABLE_GZIP', 'type' => 'radio:yes_no', 'explain' => false),
'smilies_path' => array('lang' => 'SMILIES_PATH', 'type' => 'text:20:255', 'explain' => true),
'icons_path' => array('lang' => 'ICONS_PATH', 'type' => 'text:20:255', 'explain' => true),
'upload_icons_path' => array('lang' => 'UPLOAD_ICONS_PATH', 'type' => 'text:20:255', 'explain' => true),
'ranks_path' => array('lang' => 'RANKS_PATH', 'type' => 'text:20:255', 'explain' => true)
)
),
'setting' => array(
'auth' => 'a_board',
'title' => 'BOARD_SETTINGS',
'vars' => array(
'board_disable_msg' => false, 'max_name_chars' => false, 'max_pass_chars' => false, 'bump_type' => false,
'sitename' => array('lang' => 'SITE_NAME', 'type' => 'text:40:255', 'explain' => false),
'site_desc' => array('lang' => 'SITE_DESC', 'type' => 'text:40:255', 'explain' => false),
'board_disable' => array('lang' => 'DISABLE_BOARD', 'type' => 'custom', 'options' => 'board_disable(\'{VALUE}\')', 'explain' => true),
'require_activation'=> array('lang' => 'ACC_ACTIVATION', 'type' => 'custom', 'options' => 'select_acc_activation(\'{VALUE}\')', 'explain' => true),
'allow_autologin' => array('lang' => 'ALLOW_AUTOLOGIN', 'type' => 'radio:yes_no', 'explain' => true),
'max_autologin_time'=> array('lang' => 'AUTOLOGIN_LENGTH', 'type' => 'text:3:3', 'explain' => true),
'coppa_enable' => array('lang' => 'ENABLE_COPPA', 'type' => 'radio:yes_no', 'explain' => true),
'coppa_fax' => array('lang' => 'COPPA_FAX', 'type' => 'text:25:100', 'explain' => false),
'coppa_mail' => array('lang' => 'COPPA_MAIL', 'type' => 'textarea:5:40', 'explain' => true),
'enable_confirm' => array('lang' => 'VISUAL_CONFIRM', 'type' => 'radio:yes_no', 'explain' => true),
'max_reg_attempts' => array('lang' => 'REG_LIMIT', 'type' => 'text:4:4', 'explain' => true),
'min_name_chars' => array('lang' => 'USERNAME_LENGTH', 'type' => 'custom', 'options' => 'username_length(\'{VALUE}\')', 'explain' => true),
'allow_name_chars' => array('lang' => 'USERNAME_CHARS', 'type' => 'select', 'options' => 'select_username_chars(\'{VALUE}\')', 'explain' => true),
'min_pass_chars' => array('lang' => 'PASSWORD_LENGTH', 'type' => 'custom', 'options' => 'password_length(\'{VALUE}\')', 'explain' => true),
'pass_complex' => array('lang' => 'PASSWORD_TYPE', 'type' => 'select', 'options' => 'select_password_chars(\'{VALUE}\')', 'explain' => true),
'chg_passforce' => array('lang' => 'FORCE_PASS_CHANGE', 'type' => 'text:3:3', 'explain' => true),
'save_passwd' => array('lang' => 'SAVE_PASSWORDS', 'type' => 'text:2:2', 'explain' => true),
'max_login_attempts'=> array('lang' => 'LOGIN_LIMIT', 'type' => 'text:4:4', 'explain' => true),
'allow_emailreuse' => array('lang' => 'ALLOW_EMAIL_REUSE', 'type' => 'radio:yes_no', 'explain' => true),
'edit_time' => array('lang' => 'EDIT_TIME', 'type' => 'text:3:3', 'explain' => true),
'display_last_edited' => array('lang' => 'DISPLAY_LAST_EDITED', 'type' => 'radio:yes_no', 'explain' => true),
'flood_interval' => array('lang' => 'FLOOD_INTERVAL', 'type' => 'text:3:4', 'explain' => true),
'bump_interval' => array('lang' => 'BUMP_INTERVAL', 'type' => 'custom', 'options' => 'bump_interval(\'{VALUE}\')', 'explain' => true),
'topics_per_page' => array('lang' => 'TOPICS_PER_PAGE', 'type' => 'text:3:4', 'explain' => false),
'posts_per_page' => array('lang' => 'POSTS_PER_PAGE', 'type' => 'text:3:4', 'explain' => false),
'hot_threshold' => array('lang' => 'HOT_THRESHOLD', 'type' => 'text:3:4', 'explain' => false),
'max_poll_options' => array('lang' => 'MAX_POLL_OPTIONS', 'type' => 'text:4:4', 'explain' => false),
'max_post_chars' => array('lang' => 'CHAR_LIMIT', 'type' => 'text:4:6', 'explain' => true),
'max_post_smilies' => array('lang' => 'SMILIES_LIMIT', 'type' => 'text:4:4', 'explain' => true),
'max_quote_depth' => array('lang' => 'QUOTE_DEPTH_LIMIT', 'type' => 'text:4:4', 'explain' => true)
)
),
'auth' => array(
'auth' => 'a_server',
'title' => 'AUTH_SETTINGS',
'vars' => array(
'auth_method' => array('lang' => 'AUTH_METHOD', 'type' => 'select', 'options' => 'select_auth_method(\'{VALUE}\')', 'explain' => false)
)
)
);
if (!in_array($mode, array_keys($display_vars)))
{
return;
}
// Perform the current mode
$display_vars = $display_vars[$mode];
// Check permissions
if (!$auth->acl_get($display_vars['auth']))
{
trigger_error($user->lang['NO_ADMIN']);
}
if (isset($display_vars['lang']))
{
$user->add_lang($display_vars['lang']);
}
$new = $config;
$cfg_array = (isset($_REQUEST['config'])) ? request_var('config', array('' => '')) : $new;
// We go through the display_vars to make sure no one is trying to set variables he/she is not allowed to...
foreach ($display_vars['vars'] as $config_name => $null)
{
if (!isset($cfg_array[$config_name]))
{
continue;
}
$config_value = $cfg_array[$config_name];
$new[$config_name] = $config_value;
if ($config_name == 'email_function_name')
{
$new['email_function_name'] = (empty($new['email_function_name']) || !function_exists($new['email_function_name'])) ? 'mail' : str_replace(array('(', ')'), array('', ''), trim($new['email_function_name']));
}
if ($submit)
{
set_config($config_name, $config_value);
}
}
if ($submit)
{
add_log('admin', 'LOG_' . strtoupper($mode) . '_CONFIG');
trigger_error($user->lang['CONFIG_UPDATED']);
}
adm_page_header($user->lang[$display_vars['title']]);
?>
<h1><?php echo $user->lang[$display_vars['title']]; ?></h1>
<p><?php echo $user->lang[$display_vars['title'] . '_EXPLAIN']; ?></p>
<form action="<?php echo "admin_board.$phpEx$SID&amp;mode=$mode"; ?>" method="post"><table class="bg" width="95%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang[$display_vars['title']]; ?></th>
</tr>
<?php
// Output relevant page
foreach ($display_vars['vars'] as $config_key => $vars)
{
if (!is_array($vars))
{
continue;
}
$type = explode(':', $vars['type']);
?>
<tr>
<td class="row1" width="50%"><b><?php echo $user->lang[$vars['lang']]; ?>: </b><?php echo ($vars['explain']) ? '<br /><span class="gensmall">' . $user->lang[$vars['lang'] . '_EXPLAIN'] . '</span>' : ''; ?></td>
<td class="row2"><?php echo build_cfg_template($type, $config_key, ((isset($vars['options'])) ? $vars['options'] : '')) . ((isset($vars['append'])) ? str_replace('{VALUE}', $new[$config_key], $vars['append']) : ''); ?></td>
</tr>
<?php
unset($display_vars['vars'][$config_key]);
}
if ($mode == 'auth')
{
$auth_plugins = array();
$dp = opendir($phpbb_root_path . 'includes/auth');
while ($file = readdir($dp))
{
if (preg_match('#^auth_(.*?)\.' . $phpEx . '$#', $file))
{
$auth_plugins[] = preg_replace('#^auth_(.*?)\.' . $phpEx . '$#', '\1', $file);
}
}
sort($auth_plugins);
foreach ($auth_plugins as $method)
{
if ($method && file_exists($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx))
{
include_once($phpbb_root_path . 'includes/auth/auth_' . $method . '.' . $phpEx);
$method = 'admin_' . $method;
if (function_exists($method))
{
if ($config_fields = $method($new))
{
// Check if we need to create config fields for this plugin
foreach ($config_fields as $field)
{
if (!isset($config[$field]))
{
set_config($field, '');
}
}
}
unset($config_fields);
}
}
}
}
?>
<tr>
<td class="cat" colspan="2" align="center"><input type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" class="btnmain" />&nbsp;&nbsp;<input type="reset" value="<?php echo $user->lang['RESET']; ?>" class="btnlite" /></td>
</tr>
</table></form>
<?php
adm_page_footer();
function select_auth_method($selected_method)
{
global $new, $phpbb_root_path, $phpEx;
$auth_plugins = array();
$dp = opendir($phpbb_root_path . 'includes/auth');
while ($file = readdir($dp))
{
if (preg_match('#^auth_(.*?)\.' . $phpEx . '$#', $file))
{
$auth_plugins[] = preg_replace('#^auth_(.*?)\.' . $phpEx . '$#', '\1', $file);
}
}
sort($auth_plugins);
$auth_select = '';
foreach ($auth_plugins as $method)
{
$selected = ($selected_method == $method) ? ' selected="selected"' : '';
$auth_select .= '<option value="' . $method . '"' . $selected . '>' . ucfirst($method) . '</option>';
}
return $auth_select;
}
function mail_auth_select($selected_method)
{
global $user;
$auth_methods = array('PLAIN', 'LOGIN', 'CRAM-MD5', 'DIGEST-MD5', 'POP-BEFORE-SMTP');
$s_smtp_auth_options = '';
foreach ($auth_methods as $method)
{
$s_smtp_auth_options .= '<option value="' . $method . '"' . (($selected_method == $method) ? ' selected="selected"' : '') . '>' . $user->lang['SMTP_' . str_replace('-', '_', $method)] . '</option>';
}
return $s_smtp_auth_options;
}
function full_folder_select($value)
{
global $user;
return '<option value="1"' . (($value == 1) ? ' selected="selected"' : '') . '>' . $user->lang['DELETE_OLDEST_MESSAGES'] . '</option><option value="2"' . (($value == 2) ? ' selected="selected"' : '') . '>' . $user->lang['HOLD_NEW_MESSAGES'] . '</option>';
}
function select_ip_check($value)
{
global $user;
$ip_all = ($value == 4) ? ' checked="checked"' : '';
$ip_classc = ($value == 3) ? ' checked="checked"' : '';
$ip_classb = ($value == 2) ? ' checked="checked"' : '';
$ip_none = ($value == 0) ? ' checked="checked"' : '';
$options = <<<EOT
<input type="radio" name="config[ip_check]" value="4"$ip_all /> {$user->lang['ALL']}&nbsp;&nbsp;<input type="radio" name="config[ip_check]" value="3"$ip_classc /> {$user->lang['CLASS_C']}&nbsp;&nbsp;<input type="radio" name="config[ip_check]" value="2"$ip_classb /> {$user->lang['CLASS_B']}&nbsp;&nbsp;<input type="radio" name="config[ip_check]" value="0"$ip_none /> {$user->lang['NONE']}&nbsp;&nbsp;
EOT;
return $options;
}
function select_acc_activation($value)
{
global $user, $config;
$activation_none = ($value == USER_ACTIVATION_NONE) ? ' checked="checked"' : '';
$activation_user = ($value == USER_ACTIVATION_SELF) ? ' checked="checked"' : '';
$activation_admin = ($value == USER_ACTIVATION_ADMIN) ? ' checked="checked"' : '';
$activation_disable = ($value == USER_ACTIVATION_DISABLE) ? ' checked="checked"' : '';
$options = '<input type="radio" name="config[require_activation]" value="' . USER_ACTIVATION_NONE . '"' . $activation_none . ' /> ' . $user->lang['ACC_NONE'];
if ($config['email_enable'])
{
$options .= '&nbsp;&nbsp;<input type="radio" name="config[require_activation]" value="' . USER_ACTIVATION_SELF . '"' . $activation_user . ' /> ' . $user->lang['ACC_USER'];
$options .= '&nbsp;&nbsp;<input type="radio" name="config[require_activation]" value="' . USER_ACTIVATION_ADMIN . '"' . $activation_admin . ' /> ' . $user->lang['ACC_ADMIN'];
}
$options .= '&nbsp;&nbsp;<input type="radio" name="config[require_activation]" value="' . USER_ACTIVATION_DISABLE . '"' . $activation_disable . ' /> ' . $user->lang['ACC_DISABLE'];
return $options;
}
function username_length($value)
{
global $new, $user;
return '<input class="post" type="text" size="3" maxlength="3" name="config[min_name_chars]" value="' . $value . '" /> ' . $user->lang['MIN_CHARS'] . '&nbsp;&nbsp;<input class="post" type="text" size="3" maxlength="3" name="config[max_name_chars]" value="' . $new['max_name_chars'] . '" /> ' . $user->lang['MAX_CHARS'];
}
function select_username_chars($selected_value)
{
global $user;
$user_char_ary = array('USERNAME_CHARS_ANY' => '.*', 'USERNAME_ALPHA_ONLY' => '[\w]+', 'USERNAME_ALPHA_SPACERS' => '[\w_\+\. \-\[\]]+');
$user_char_options = '';
foreach ($user_char_ary as $lang => $value)
{
$selected = ($selected_value == $value) ? ' selected="selected"' : '';
$user_char_options .= '<option value="' . $value . '"' . $selected . '>' . $user->lang[$lang] . '</option>';
}
return $user_char_options;
}
function password_length($value)
{
global $new, $user;
return '<input class="post" type="text" size="3" maxlength="3" name="config[min_pass_chars]" value="' . $value . '" /> ' . $user->lang['MIN_CHARS'] . '&nbsp;&nbsp;<input class="post" type="text" size="3" maxlength="3" name="config[max_pass_chars]" value="' . $new['max_pass_chars'] . '" /> ' . $user->lang['MAX_CHARS'];
}
function select_password_chars($selected_value)
{
global $user;
$pass_type_ary = array('PASS_TYPE_ANY' => '.*', 'PASS_TYPE_CASE' => '[a-zA-Z]', 'PASS_TYPE_ALPHA' => '[a-zA-Z0-9]', 'PASS_TYPE_SYMBOL' => '[a-zA-Z\W]');
$pass_char_options = '';
foreach ($pass_type_ary as $lang => $value)
{
$selected = ($selected_value == $value) ? ' selected="selected"' : '';
$pass_char_options .= '<option value="' . $value . '"' . $selected . '>' . $user->lang[$lang] . '</option>';
}
return $pass_char_options;
}
function bump_interval($value)
{
global $new, $user;
$s_bump_type = '';
$types = array('m' => 'MINUTES', 'h' => 'HOURS', 'd' => 'DAYS');
foreach ($types as $type => $lang)
{
$selected = ($new['bump_type'] == $type) ? 'selected="selected" ' : '';
$s_bump_type .= '<option value="' . $type . '" ' . $selected . '>' . $user->lang[$lang] . '</option>';
}
return '<input class="post" type="text" size="3" maxlength="4" name="config[bump_interval]" value="' . $value . '" />&nbsp;<select name="config[bump_type]">' . $s_bump_type . '</select>';
}
function board_disable($value)
{
global $new, $user;
$board_disable_yes = ($value) ? ' checked="checked"' : '';
$board_disable_no = (!$value) ? ' checked="checked"' : '';
return '<input type="radio" name="config[board_disable]" value="1"' . $board_disable_yes . ' /> ' . $user->lang['YES'] . '&nbsp;&nbsp;<input type="radio" name="config[board_disable]" value="0"' . $board_disable_no . ' /> ' . $user->lang['NO'] . '<br /><input class="post" type="text" name="config[board_disable_msg]" maxlength="255" size="40" value="' . $new['board_disable_msg'] . '" />';
}
?>

394
phpBB/adm/admin_bots.php Normal file
View File

@@ -0,0 +1,394 @@
<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
if (!empty($setmodules))
{
if (!$auth->acl_get('a_server'))
{
return;
}
$module['USER']['BOTS'] = basename(__FILE__) . $SID;
return;
}
define('IN_PHPBB', 1);
// Include files
$phpbb_root_path = '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
// Do we have permission?
if (!$auth->acl_get('a_server'))
{
trigger_error($user->lang['NO_ADMIN']);
}
// Set various vars
$submit = (isset($_POST['submit'])) ? true : false;
$action = request_var('action', '');
$mark = request_var('mark', 0);
$id = request_var('id', 0);
if (isset($_POST['add']))
{
$action = 'add';
}
$error = array();
// User wants to do something, how inconsiderate of them!
switch ($action)
{
case 'activate':
if ($id || $mark)
{
$id = ($id) ? " = $id" : ' IN (' . implode(', ', $mark) . ')';
$sql = 'UPDATE ' . BOTS_TABLE . "
SET bot_active = 1
WHERE bot_id $id";
$db->sql_query($sql);
}
$cache->destroy('bots');
break;
case 'deactivate':
if ($id || $mark)
{
$id = ($id) ? " = $id" : ' IN (' . implode(', ', $mark) . ')';
$sql = 'UPDATE ' . BOTS_TABLE . "
SET bot_active = 0
WHERE bot_id $id";
$db->sql_query($sql);
}
$cache->destroy('bots');
break;
case 'delete':
if ($id || $mark)
{
// We need to delete the relevant user, usergroup and bot entries ...
$id = ($id) ? " = $id" : ' IN (' . implode(', ', $mark) . ')';
$sql = 'SELECT bot_name, user_id
FROM ' . BOTS_TABLE . "
WHERE bot_id $id";
$result = $db->sql_query($sql);
$user_id_ary = $bot_name_ary = array();
while ($row = $db->sql_fetchrow($result))
{
$user_id_ary[] = (int) $row['user_id'];
$bot_name_ary[] = $row['bot_name'];
}
$db->sql_freeresult($result);
$db->sql_transaction();
$sql = 'DELETE FROM ' . BOTS_TABLE . "
WHERE bot_id $id";
$db->sql_query($sql);
foreach (array(USERS_TABLE, USER_GROUP_TABLE) as $table)
{
$sql = "DELETE FROM $table
WHERE user_id IN (" . implode(', ', $user_id_ary) . ')';
$db->sql_query($sql);
}
$db->sql_transaction('commit');
$cache->destroy('bots');
add_log('admin', 'LOG_BOT_DELETE', implode(', ', $bot_name_ary));
trigger_error($user->lang['BOT_DELETED']);
}
break;
case 'edit':
case 'add':
$bot_name = request_var('bot_name', '');
$bot_agent = request_var('bot_agent', '');
$bot_ip = request_var('bot_ip', '');
$bot_active = request_var('bot_active', true);
$bot_lang = request_var('bot_lang', $config['default_lang']);
$bot_style = request_var('bot_style' , $config['default_style']);
if ($submit)
{
if (!$bot_agent && !$bot_ip)
{
$error[] = $user->lang['ERR_BOT_NO_MATCHES'];
}
if ($bot_ip && !preg_match('#^[\d\.,:]+$#', $bot_ip))
{
if (!$ip_list = gethostbynamel($bot_ip))
{
$error[] = $user->lang['ERR_BOT_NO_IP'];
}
else
{
$bot_ip = implode(',', $ip_list);
}
}
$bot_ip = str_replace(' ', '', $bot_ip);
if (!sizeof($error))
{
$db->sql_transaction();
// New bot? Create a new user and group entry
if ($action == 'add')
{
$sql = 'SELECT group_id, group_colour
FROM ' . GROUPS_TABLE . "
WHERE group_name = 'BOTS'
AND group_type = " . GROUP_SPECIAL;
$result = $db->sql_query($sql);
if (!extract($db->sql_fetchrow($result)))
{
trigger_error($user->lang['NO_GROUP']);
}
$db->sql_freeresult($result);
$sql = 'INSERT INTO ' . USERS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'group_id' => (int) $group_id,
'username' => (string) $bot_name,
'user_type' => (int) USER_IGNORE,
'user_colour' => (string) $group_colour,
'user_lang' => (string) $bot_lang,
'user_style' => (int) $bot_style,
'user_options' => 0)
);
$db->sql_query($sql);
$user_id = $db->sql_nextid();
// Add to Bots usergroup
$sql = 'INSERT INTO ' . USER_GROUP_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'user_id' => $user_id,
'group_id' => $group_id)
);
$db->sql_query($sql);
$sql = 'INSERT INTO ' . BOTS_TABLE . ' ' . $db->sql_build_array('INSERT', array(
'user_id' => (int) $user_id,
'bot_name' => (string) $bot_name,
'bot_active' => (int) $bot_active,
'bot_agent' => (string) $bot_agent,
'bot_ip' => (string) $bot_ip,)
);
$log = 'ADDED';
}
else
{
$sql = 'SELECT user_id
FROM ' . BOTS_TABLE . "
WHERE bot_id = $id";
$result = $db->sql_query($sql);
if (!extract($db->sql_fetchrow($result)))
{
trigger_error($user->lang['NO_BOT']);
}
$sql = 'UPDATE ' . USERS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array(
'user_style' => (int) $bot_style,
'user_lang' => (string) $bot_lang,)
) . " WHERE user_id = $user_id";
$db->sql_query($sql);
$sql = 'UPDATE ' . BOTS_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array(
'bot_name' => (string) $bot_name,
'bot_active' => (int) $bot_active,
'bot_agent' => (string) $bot_agent,
'bot_ip' => (string) $bot_ip,)
) . " WHERE bot_id = $id";
$log = 'UPDATED';
}
$db->sql_query($sql);
$db->sql_transaction('commit');
$cache->destroy('bots');
add_log('admin', 'LOG_BOT_' . $log, $bot_name);
trigger_error($user->lang['BOT_' . $log]);
}
}
else if ($id)
{
$sql = 'SELECT b.*, u.user_lang, u.user_style
FROM ' . BOTS_TABLE . ' b, ' . USERS_TABLE . " u
WHERE b.bot_id = $id
AND u.user_id = b.user_id";
$result = $db->sql_query($sql);
if (!extract($db->sql_fetchrow($result)))
{
trigger_error($user->lang['NO_BOT']);
}
$db->sql_freeresult($result);
$bot_lang = $user_lang;
$bot_style = $user_style;
}
$s_active_options = '';
foreach (array('0' => 'NO', '1' => 'YES') as $value => $lang)
{
$selected = ($bot_active == $value) ? ' selected="selected"' : '';
$s_active_options .= '<option value="' . $value . '"' . $selected . '>' . $user->lang[$lang] . '</option>';
}
$style_select = style_select($bot_style, true);
$lang_select = language_select($bot_lang);
$l_title = ($action == 'edit') ? 'EDIT' : 'ADD';
// Output relevant page
adm_page_header($user->lang['BOT_' . $l_title]);
?>
<h1><?php echo $user->lang['BOT_' . $l_title]; ?></h1>
<p><?php echo $user->lang['BOT_EDIT_EXPLAIN']; ?></p>
<form method="post" action="<?php echo "admin_bots.$phpEx$SID&amp;action=$action&amp;id=$id"; ?>"><table class="bg" width="90%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang['BOT_' . $l_title]; ?></th>
</tr>
<?php
if (sizeof($error))
{
?>
<tr>
<td class="row3" colspan="2" align="center"><span style="color:red"><?php echo implode('<br />', $error); ?></span></td>
</tr>
<?php
}
?>
<tr>
<td class="row1" width="40%"><b class="genmed"><?php echo $user->lang['BOT_NAME']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['BOT_NAME_EXPLAIN']; ?></span></td>
<td class="row2"><input class="post" type="text" name="bot_name" size="30" maxlength="255" value="<?php echo $bot_name; ?>" /></td>
</tr>
<tr>
<td class="row1" width="40%"><b class="genmed"><?php echo $user->lang['BOT_STYLE']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['BOT_STYLE_EXPLAIN']; ?></span></td>
<td class="row2"><select name="bot_style"><?php echo $style_select; ?></select></td>
</tr>
<tr>
<td class="row1" width="40%"><b class="genmed"><?php echo $user->lang['BOT_LANG']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['BOT_LANG_EXPLAIN']; ?></span></td>
<td class="row2"><select name="bot_lang"><?php echo $lang_select; ?></select></td>
</tr>
<tr>
<td class="row1" width="40%"><b class="genmed"><?php echo $user->lang['BOT_ACTIVE']; ?>: </b></td>
<td class="row2"><select name="bot_active"><?php echo $s_active_options; ?></select></td>
</tr>
<tr>
<td class="row1" width="40%"><b class="genmed"><?php echo $user->lang['BOT_AGENT']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['BOT_AGENT_EXPLAIN']; ?></span></td>
<td class="row2"><input class="post" type="text" name="bot_agent" size="30" maxlength="255" value="<?php echo $bot_agent; ?>" /></td>
</tr>
<tr>
<td class="row1" width="40%"><b class="genmed"><?php echo $user->lang['BOT_IP']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['BOT_IP_EXPLAIN']; ?></span></td>
<td class="row2"><input class="post" type="text" name="bot_ip" size="30" maxlength="255" value="<?php echo $bot_ip; ?>" /></td>
</tr>
<tr>
<td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" />&nbsp;&nbsp;<input class="btnlite" type="reset" value="<?php echo $user->lang['RESET']; ?>" /></td>
</tr>
</table></form>
<?php
adm_page_footer();
break;
}
// Output relevant page
adm_page_header($user->lang['BOTS']);
?>
<h1><?php echo $user->lang['BOTS']; ?></h1>
<p><?php echo $user->lang['BOTS_EXPLAIN']; ?></p>
<form method="post" action="<?php "admin_bots.$phpEx$SID"; ?>"><table class="bg" width="90%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th nowrap="nowrap"><?php echo $user->lang['BOT_NAME']; ?></th>
<th nowrap="nowrap"><?php echo $user->lang['BOT_LAST_VISIT']; ?></th>
<th colspan="3" nowrap="nowrap"><?php echo $user->lang['OPTIONS']; ?></th>
<th nowrap="nowrap"><?php echo $user->lang['MARK']; ?></th>
</tr>
<?php
$s_options = '';
foreach (array('activate' => 'BOT_ACTIVATE', 'deactivate' => 'BOT_DEACTIVATE', 'delete' => 'DELETE') as $value => $lang)
{
$s_options .= '<option value="' . $value . '">' . $user->lang[$lang] . '</option>';
}
$sql = 'SELECT b.bot_id, b.bot_name, b.bot_active, u.user_lastvisit
FROM ' . BOTS_TABLE . ' b, ' . USERS_TABLE . ' u
WHERE u.user_id = b.user_id
ORDER BY u.user_lastvisit DESC';
$result = $db->sql_query($sql);
$row_class = '';
while ($row = $db->sql_fetchrow($result))
{
$row_class = ($row_class == 'row1') ? 'row2' : 'row1';
$active_lang = (!$row['bot_active']) ? 'BOT_ACTIVATE' : 'BOT_DEACTIVATE';
$active_value = (!$row['bot_active']) ? 'activate' : 'deactivate';
$id = $row['bot_id'];
?>
<tr>
<td class="<?php echo $row_class; ?>" width="50%"><?php echo $row['bot_name']; ?></td>
<td class="<?php echo $row_class; ?>" width="15%" align="center" nowrap="nowrap">&nbsp;<?php echo ($row['user_lastvisit']) ? $user->format_date($row['user_lastvisit']) : $user->lang['BOT_NEVER']; ?>&nbsp;</td>
<td class="<?php echo $row_class; ?>" width="1%"align="center">&nbsp;<a href="<?php echo "admin_bots.$phpEx$SID&amp;id=$id&amp;action=$active_value"; ?>"><?php echo $user->lang[$active_lang]; ?></a>&nbsp;</td>
<td class="<?php echo $row_class; ?>" width="1%" align="center">&nbsp;<a href="<?php echo "admin_bots.$phpEx$SID&amp;id=$id&amp;action=edit"; ?>"><?php echo $user->lang['EDIT']; ?></a>&nbsp;</td>
<td class="<?php echo $row_class; ?>" width="1%" align="center">&nbsp;<a href="<?php echo "admin_bots.$phpEx$SID&amp;id=$id&amp;action=delete"; ?>"><?php echo $user->lang['DELETE']; ?></a>&nbsp;</td>
<td class="<?php echo $row_class; ?>" width="1%" align="center"><input type="checkbox" name="mark[]" value="<?php echo $id; ?>" /></td>
</tr>
<?php
}
$db->sql_freeresult($result);
?>
<tr>
<td class="cat" colspan="6"><table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td><input class="btnlite" type="submit" name="add" value="<?php echo $user->lang['BOT_ADD']; ?>" /></td>
<td align="right"><select name="action"><?php echo $s_options; ?></select> <input class="btnlite" type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" /></td>
</tr>
</table></td>
</tr>
</table></form>
<?php
adm_page_footer();
?>

View File

@@ -0,0 +1,994 @@
<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
if (!empty($setmodules))
{
$filename = basename(__FILE__);
$module['DB']['DB_BACKUP'] = ($auth->acl_get('a_backup')) ? $filename . "$SID&amp;mode=backup" : '';
$file_uploads = @ini_get('file_uploads');
if (!empty($file_uploads) && $file_uploads !== 0 && strtolower($file_uploads) != 'off' && $auth->acl_get('a_restore'))
{
$module['DB']['DB_RESTORE'] = "$filename$SID&amp;mode=restore";
}
return;
}
define('IN_PHPBB', 1);
// Load default header
$phpbb_root_path = '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/functions_compress.'.$phpEx);
@set_time_limit(1200);
// Get some vars
$mode = (isset($_GET['mode'])) ? htmlspecialchars($_GET['mode']) : '';
$action = (isset($_REQUEST['action'])) ? htmlspecialchars($_REQUEST['action']) : '';
// --------------------
// Begin program proper
// --------------------
switch($mode)
{
case 'backup':
if (!$auth->acl_get('a_backup'))
{
trigger_error($user->lang['NO_ADMIN']);
}
$db_type = '';
switch (SQL_LAYER)
{
case 'oracle':
$db_type = 'Oracle';
break;
case 'odbc':
$db_type = 'ODBC';
break;
case 'mssql':
$db_type = 'MSSQL';
break;
}
if ($db_type)
{
trigger_error($user->lang['Backups_not_supported']);
}
$additional_tables = (isset($_REQUEST['tables'])) ? htmlspecialchars($_REQUEST['tables']) : '';
$backup_type = (isset($_REQUEST['type'])) ? intval($_REQUEST['type']) : false;
$search = (!empty($_REQUEST['search'])) ? true : false;
$store = (!empty($_REQUEST['store'])) ? true : false;
$compress = (isset($_REQUEST['compress'])) ? htmlspecialchars($_REQUEST['compress']) : '';
if (!isset($_POST['backupstart']) && !isset($_GET['backupstart']))
{
adm_page_header($user->lang['DB_BACKUP']);
?>
<h1><?php echo $user->lang['DB_BACKUP']; ?></h1>
<p><?php echo $user->lang['Backup_explain']; ?></p>
<form method="post" action="<?php echo "admin_database.$phpEx$SID&amp;mode=$mode"; ?>"><table class="bg" width="95%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang['Backup_options']; ?></th>
</tr>
<tr>
<td class="row1" width="40%"><b><?php echo $user->lang['Backup_type']; ?>: </b></td>
<td class="row2"><input type="radio" name="type" value="full" checked="checked" /> <?php echo $user->lang['Full_backup']; ?>&nbsp;&nbsp;<input type="radio" name="type" value="structure" /> <?php echo $user->lang['Structure_only']; ?>&nbsp;&nbsp;<input type="radio" name="type" value="data" /> <?php echo $user->lang['Data_only']; ?></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['Additional_tables']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['Additional_tables_explain']; ?></span></td>
<td class="row2"><input class="post" type="text" name="tables" maxlength="255" size="40" /></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['INC_SEARCH_INDEX']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['INC_SEARCH_INDEX_EXPLAIN']; ?></span></td>
<td class="row2"><input type="radio" name="search" value="1" checked="checked" /> <?php echo $user->lang['YES']; ?>&nbsp;&nbsp;<input type="radio" name="search" value="0" /> <?php echo $user->lang['NO']; ?></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['DOWNLOAD_STORE']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['DOWNLOAD_STORE_EXPLAIN']; ?></span></td>
<td class="row2"><input type="radio" name="store" value="0" checked="checked" /> <?php echo $user->lang['EXPORT_DOWNLOAD']; ?>&nbsp;&nbsp;<input type="radio" name="store" value="1" /> <?php echo $user->lang['EXPORT_STORE']; ?></td>
</tr>
<?php
if (@extension_loaded('zlib') || extension_loaded('bz2'))
{
?>
<tr>
<td class="row1"><b><?php echo $user->lang['Compress_file']; ?>: </b></td>
<td class="row2"><input type="radio" name="compress" value="none" checked="checked" /> <?php echo $user->lang['NONE']; ?><?php
if (extension_loaded('zlib'))
{
?>&nbsp;&nbsp;<input type="radio" name="compress" value="gzip" />.gz&nbsp;&nbsp;<input type="radio" name="compress" value="zip" />.zip<?php
}
if (extension_loaded('bz2'))
{
?>&nbsp;&nbsp;<input type="radio" name="compress" value="bzip" />.bz2<?php
}
?></td>
</tr>
<?php
}
?>
<tr>
<td class="cat" colspan="2" align="center"><input type="submit" name="backupstart" value="<?php echo $user->lang['Start_backup']; ?>" class="btnmain" /></td>
</tr>
</table></form>
<?php
break;
}
else if (!isset($_POST['startdownload']) && !isset($_GET['startdownload']))
{
$meta = "<meta http-equiv=\"refresh\" content=\"0;url=admin_database.$phpEx?mode=backup&amp;type=$backup_type&amp;tables=" . quotemeta($additional_tables) . "&amp;search=$search&amp;store=" . quotemeta($store_path) . "&amp;compress=$compress&amp;backupstart=1&amp;startdownload=1\">";
$message = (empty($store_path)) ? $user->lang['Backup_download'] : $user->lang['Backup_writing'];
adm_page_header($user->lang['DB_Backup'], $meta);
page_message($user->lang['DB_Backup'], $message);
adm_page_footer();
}
$tables = (SQL_LAYER != 'postgresql') ? mysql_get_tables() : pg_get_tables();
@sort($tables);
if (!empty($additional_tables))
{
$additional_tables = explode(',', $additional_tables);
for($i = 0; $i < count($additional_tables); $i++)
{
$tables[] = trim($additional_tables[$i]);
}
unset($additional_tables);
}
// Enable output buffering
@ob_start();
@ob_implicit_flush(0);
// Build the sql script file...
echo "#\n";
echo "# phpBB Backup Script\n";
echo "# Dump of tables for $dbname\n";
echo "#\n# DATE : " . gmdate("d-m-Y H:i:s", time()) . " GMT\n";
echo "#\n";
if (SQL_LAYER == 'postgresql')
{
echo "\n" . pg_get_sequences("\n", $backup_type);
}
for($i = 0; $i < count($tables); $i++)
{
$table_name = $tables[$i];
if (SQL_LAYER != 'mysql4')
{
$table_def_function = "get_table_def_" . SQL_LAYER;
$table_content_function = "get_table_content_" . SQL_LAYER;
}
else
{
$table_def_function = "get_table_def_mysql";
$table_content_function = "get_table_content_mysql";
}
if ($backup_type != 'data')
{
echo "#\n# TABLE: " . $table_name . "\n#\n";
echo $table_def_function($table_name, "\n") . "\n";
}
if ($backup_type != 'structure')
{
//
// Skip search table data?
//
if ($search || (!$search && !preg_match('/search_word/', $table_name)))
{
$table_content_function($table_name, "output_table_content");
}
}
}
// Flush the buffer, send the file
switch ($compress)
{/*
case 'gzip':
$extension = 'sql.gz';
$contents = gzencode(ob_get_contents());
ob_end_clean();
break;
case 'zip':
$extension = 'zip';
$zip = new zipfile;
$zip->add_file(ob_get_contents(), "phpbb_db_backup.sql", time());
ob_end_clean();
$contents = $zip->file();
break;
case 'bzip':
$extension = 'bz2';
$contents = bzcompress(ob_get_contents());
ob_end_clean();
break;*/
default:
$extension = 'sql';
$contents = ob_get_contents();
ob_end_clean();
}
add_log('admin', 'log_db_backup');
if (empty($store_path))
{
header("Pragma: no-cache");
header("Content-Type: text/x-delimtext; name=\"phpbb_db_backup.$extension\"");
header("Content-disposition: attachment; filename=phpbb_db_backup.$extension");
echo $contents;
unset($contents);
}
else
{
if (!($fp = fopen('./../' . $store_path . "/phpbb_db_backup.$extension", 'wb')))
{
message_die(ERROR, 'Could not open backup file');
}
if (!fwrite($fp, $contents))
{
message_die(ERROR, 'Could not write backup file content');
}
fclose($fp);
unset($contents);
trigger_error($user->lang['Backup_success']);
}
exit;
break;
case 'restore':
if (!$auth->acl_get('a_restore'))
{
trigger_error($user->lang['NO_ADMIN']);
}
if (isset($_POST['restorestart']))
{
// Handle the file upload ....
// If no file was uploaded report an error...
if (!empty($_POST['local']))
{
$file_tmpname = './../' . str_replace('\\\\', '/', $_POST['local']);
$filename = substr($file_tmpname, strrpos($file_tmpname, '/'));
}
else
{
$filename = (!empty($_POST['backup_file']['name'])) ? $HTTP_POST_FILES['backup_file']['name'] : '';
$file_tmpname = ($HTTP_POST_FILES['backup_file']['tmp_name'] != 'none') ? $HTTP_POST_FILES['backup_file']['tmp_name'] : '';
}
if ($file_tmpname == '' || $filename == '' || !file_exists($file_tmpname))
{
trigger_error($user->lang['Restore_Error_no_file']);
}
$ext = substr($filename, strrpos($filename, '.') + 1);
if (!preg_match('/^(sql|gz|bz2)$/', $ext))
{
trigger_error($user->lang['Restore_Error_filename']);
}
if ((!extension_loaded('zlib') && $ext == 'gz') || (!extension_loaded('zip') && $ext == 'zip') || ($ext == 'bz2' && !extension_loaded('bz2')))
{
trigger_error($user->lang['Compress_unsupported']);
}
$sql_query = '';
switch ($ext)
{
case 'gz':
$fp = gzopen($file_tmpname, 'rb');
while (!gzeof($fp))
{
$sql_query .= gzgets($fp, 100000);
}
gzclose($fp);
break;
case 'bz2':
$sql_query = bzdecompress(fread(fopen($file_tmpname, 'rb'), filesize($file_tmpname)));
break;
case 'zip':
default;
$sql_query = fread(fopen($file_tmpname, 'r'), filesize($file_tmpname));
}
if ($sql_query != '')
{
// Strip out sql comments...
remove_remarks($sql_query);
$pieces = split_sql_file($sql_query, ';');
$sql_count = count($pieces);
for($i = 0; $i < $sql_count; $i++)
{
$sql = trim($pieces[$i]);
if (!empty($sql) && $sql[0] != '#')
{
$db->sql_query($sql);
}
}
}
add_log('admin', 'log_db_restore');
trigger_error($user->lang['Restore_success']);
}
//
// Restore page
//
adm_page_header($user->lang['DB_RESTORE']);
?>
<h1><?php echo $user->lang['DB_RESTORE']; ?></h1>
<p><?php echo $user->lang['Restore_explain']; ?></p>
<form enctype="multipart/form-data" method="post" action="<?php echo "admin_database.$phpEx$SID&amp;mode=$mode"; ?>"><table class="bg" width="80%" cellspacing="1" cellpadding="4" border="0" align="center">
<th colspan="2"><?php echo $user->lang['Select_file']; ?></th>
</tr>
<tr>
<td class="row1"><?php echo $user->lang['Upload_file']; ?>: <br /><span class="gensmall"><?php
echo $user->lang['Supported_extensions'];
$types = ': <u>sql</u>';
if (extension_loaded('zlib'))
{
$types .= ', <u>sql.gz</u>';
}
if (extension_loaded('bz2'))
{
$types .= ', <u>bz2</u>';
}
echo $types;
?></span></td>
<td class="row2"><input type="file" name="backup_file" /></td>
</tr>
<tr>
<td class="row1"><?php echo $user->lang['Local_backup_file']; ?>: <br /><span class="gensmall"><?php echo $user->lang['Local_backup_file_explain']; ?></span></td>
<td class="row2"><input type="text" name="local" size="40" /></td>
</tr>
<tr>
<td class="cat" colspan="2" align="center"><input type="submit" name="restorestart" value="<?php echo $user->lang['Start_Restore']; ?>" class="btnmain" /></td>
</tr>
</table></form>
<?php
break;
default:
trigger_error($user->lang['No_admin']);
exit;
}
adm_page_footer();
// -----------------------------------------------
// Begin Functions
//
//
// Table defns (not from phpMyAdmin)
//
function mysql_get_tables()
{
global $db, $table_prefix;
$tables = array();
$result = mysql_list_tables($db->dbname, $db->db_connect_id);
if ($row = $db->sql_fetchrow($result))
{
do
{
if (preg_match('/^' . $table_prefix . '/', $row[0]))
{
$tables[] = $row[0];
}
}
while ($row = $db->sql_fetchrow($result));
}
return $tables;
}
//
// The following functions are adapted from phpMyAdmin and upgrade_20.php
//
// This function is used for grabbing the sequences for postgres...
//
function pg_get_sequences($crlf, $backup_type)
{
global $db;
$get_seq_sql = "SELECT relname FROM pg_class WHERE NOT relname ~ 'pg_.*'
AND relkind = 'S' ORDER BY relname";
$seq = $db->sql_query($get_seq_sql);
if (!$num_seq = $db->sql_numrows($seq))
{
$return_val = "# No Sequences Found $crlf";
}
else
{
$return_val = "# Sequences $crlf";
$i_seq = 0;
while($i_seq < $num_seq)
{
$row = $db->sql_fetchrow($seq);
$sequence = $row['relname'];
$get_props_sql = "SELECT * FROM $sequence";
$seq_props = $db->sql_query($get_props_sql);
if ($db->sql_numrows($seq_props) > 0)
{
$row1 = $db->sql_fetchrow($seq_props);
if ($backup_type == 'structure')
{
$row['last_value'] = 1;
}
$return_val .= "CREATE SEQUENCE $sequence start " . $row['last_value'] . ' increment ' . $row['increment_by'] . ' maxvalue ' . $row['max_value'] . ' minvalue ' . $row['min_value'] . ' cache ' . $row['cache_value'] . "; $crlf";
} // End if numrows > 0
if (($row['last_value'] > 1) && ($backup_type != 'structure'))
{
$return_val .= "SELECT NEXTVALE('$sequence'); $crlf";
unset($row['last_value']);
}
$i_seq++;
} // End while..
} // End else...
return $returnval;
} // End function...
//
// The following functions will return the "CREATE TABLE syntax for the
// varying DBMS's
//
// This function returns, will return the table def's for postgres...
//
function get_table_def_postgresql($table, $crlf)
{
global $db;
$schema_create = "";
//
// Get a listing of the fields, with their associated types, etc.
//
$field_query = "SELECT a.attnum, a.attname AS field, t.typname as type, a.attlen AS length, a.atttypmod as lengthvar, a.attnotnull as notnull
FROM pg_class c, pg_attribute a, pg_type t
WHERE c.relname = '$table'
AND a.attnum > 0
AND a.attrelid = c.oid
AND a.atttypid = t.oid
ORDER BY a.attnum";
$result = $db->sql_query($field_query);
if (!$result)
{
message_die(GENERAL_ERROR, "Failed in get_table_def (show fields)", "", __LINE__, __FILE__, $field_query);
} // end if..
$schema_create .= "DROP TABLE $table;$crlf";
//
// Ok now we actually start building the SQL statements to restore the tables
//
$schema_create .= "CREATE TABLE $table($crlf";
while ($row = $db->sql_fetchrow($result))
{
//
// Get the data from the table
//
$sql_get_default = "SELECT d.adsrc AS rowdefault
FROM pg_attrdef d, pg_class c
WHERE (c.relname = '$table')
AND (c.oid = d.adrelid)
AND d.adnum = " . $row['attnum'];
$def_res = $db->sql_query($sql_get_default);
if (!$def_res)
{
unset($row['rowdefault']);
}
else
{
$row['rowdefault'] = @pg_result($def_res, 0, 'rowdefault');
}
if ($row['type'] == 'bpchar')
{
// Internally stored as bpchar, but isn't accepted in a CREATE TABLE statement.
$row['type'] = 'char';
}
$schema_create .= ' ' . $row['field'] . ' ' . $row['type'];
if (eregi('char', $row['type']))
{
if ($row['lengthvar'] > 0)
{
$schema_create .= '(' . ($row['lengthvar'] -4) . ')';
}
}
if (eregi('numeric', $row['type']))
{
$schema_create .= '(';
$schema_create .= sprintf("%s,%s", (($row['lengthvar'] >> 16) & 0xffff), (($row['lengthvar'] - 4) & 0xffff));
$schema_create .= ')';
}
if (!empty($row['rowdefault']))
{
$schema_create .= ' DEFAULT ' . $row['rowdefault'];
}
if ($row['notnull'] == 't')
{
$schema_create .= ' NOT NULL';
}
$schema_create .= ",$crlf";
}
//
// Get the listing of primary keys.
//
$sql_pri_keys = "SELECT ic.relname AS index_name, bc.relname AS tab_name, ta.attname AS column_name, i.indisunique AS unique_key, i.indisprimary AS primary_key
FROM pg_class bc, pg_class ic, pg_index i, pg_attribute ta, pg_attribute ia
WHERE (bc.oid = i.indrelid)
AND (ic.oid = i.indexrelid)
AND (ia.attrelid = i.indexrelid)
AND (ta.attrelid = bc.oid)
AND (bc.relname = '$table')
AND (ta.attrelid = i.indrelid)
AND (ta.attnum = i.indkey[ia.attnum-1])
ORDER BY index_name, tab_name, column_name ";
$result = $db->sql_query($sql_pri_keys);
if (!$result)
{
message_die(GENERAL_ERROR, "Failed in get_table_def (show fields)", "", __LINE__, __FILE__, $sql_pri_keys);
}
while ($row = $db->sql_fetchrow($result))
{
if ($row['primary_key'] == 't')
{
if (!empty($primary_key))
{
$primary_key .= ', ';
}
$primary_key .= $row['column_name'];
$primary_key_name = $row['index_name'];
}
else
{
//
// We have to store this all this info because it is possible to have a multi-column key...
// we can loop through it again and build the statement
//
$index_rows[$row['index_name']]['table'] = $table;
$index_rows[$row['index_name']]['unique'] = ($row['unique_key'] == 't') ? ' UNIQUE ' : '';
$index_rows[$row['index_name']]['column_names'] .= $row['column_name'] . ', ';
}
}
if (!empty($index_rows))
{
while(list($idx_name, $props) = each($index_rows))
{
$props['column_names'] = ereg_replace(", $", "" , $props['column_names']);
$index_create .= 'CREATE ' . $props['unique'] . " INDEX $idx_name ON $table (" . $props['column_names'] . ");$crlf";
}
}
if (!empty($primary_key))
{
$schema_create .= " CONSTRAINT $primary_key_name PRIMARY KEY ($primary_key),$crlf";
}
//
// Generate constraint clauses for CHECK constraints
//
$sql_checks = "SELECT rcname as index_name, rcsrc
FROM pg_relcheck, pg_class bc
WHERE rcrelid = bc.oid
AND bc.relname = '$table'
AND NOT EXISTS (
SELECT *
FROM pg_relcheck as c, pg_inherits as i
WHERE i.inhrelid = pg_relcheck.rcrelid
AND c.rcname = pg_relcheck.rcname
AND c.rcsrc = pg_relcheck.rcsrc
AND c.rcrelid = i.inhparent
)";
$result = $db->sql_query($sql_checks);
if (!$result)
{
message_die(GENERAL_ERROR, "Failed in get_table_def (show fields)", "", __LINE__, __FILE__, $sql_checks);
}
//
// Add the constraints to the sql file.
//
while ($row = $db->sql_fetchrow($result))
{
$schema_create .= ' CONSTRAINT ' . $row['index_name'] . ' CHECK ' . $row['rcsrc'] . ",$crlf";
}
$schema_create = ereg_replace(',' . $crlf . '$', '', $schema_create);
$index_create = ereg_replace(',' . $crlf . '$', '', $index_create);
$schema_create .= "$crlf);$crlf";
if (!empty($index_create))
{
$schema_create .= $index_create;
}
//
// Ok now we've built all the sql return it to the calling function.
//
return (stripslashes($schema_create));
}
//
// This function returns the "CREATE TABLE" syntax for mysql dbms...
//
function get_table_def_mysql($table, $crlf)
{
global $db;
$schema_create = "";
$field_query = "SHOW FIELDS FROM $table";
$key_query = "SHOW KEYS FROM $table";
// If the user has selected to drop existing tables when doing a restore.
// Then we add the statement to drop the tables....
$schema_create .= "DROP TABLE IF EXISTS $table;$crlf";
$schema_create .= "CREATE TABLE $table($crlf";
// Ok lets grab the fields...
$result = $db->sql_query($field_query);
while ($row = $db->sql_fetchrow($result))
{
$schema_create .= ' ' . $row['Field'] . ' ' . $row['Type'];
if (!empty($row['Default']))
{
$schema_create .= ' DEFAULT \'' . $row['Default'] . '\'';
}
if ($row['Null'] != "YES")
{
$schema_create .= ' NOT NULL';
}
if ($row['Extra'] != "")
{
$schema_create .= ' ' . $row['Extra'];
}
$schema_create .= ",$crlf";
}
//
// Drop the last ',$crlf' off ;)
//
$schema_create = ereg_replace(',' . $crlf . '$', "", $schema_create);
//
// Get any Indexed fields from the database...
//
$result = $db->sql_query($key_query);
while($row = $db->sql_fetchrow($result))
{
$kname = $row['Key_name'];
if (($kname != 'PRIMARY') && ($row['Non_unique'] == 0))
{
$kname = "UNIQUE|$kname";
}
if (!is_array($index[$kname]))
{
$index[$kname] = array();
}
$index[$kname][] = $row['Column_name'];
}
foreach ($index as $x => $columns)
{
$schema_create .= ", $crlf";
if ($x == 'PRIMARY')
{
$schema_create .= ' PRIMARY KEY (' . implode($columns, ', ') . ')';
}
elseif (substr($x,0,6) == 'UNIQUE')
{
$schema_create .= ' UNIQUE ' . substr($x,7) . ' (' . implode($columns, ', ') . ')';
}
else
{
$schema_create .= " KEY $x (" . implode($columns, ', ') . ')';
}
}
$schema_create .= "$crlf);";
if (get_magic_quotes_runtime())
{
return stripslashes($schema_create);
}
else
{
return $schema_create;
}
} // End get_table_def_mysql
//
// This fuction will return a tables create definition to be used as an sql
// statement.
//
//
// The following functions Get the data from the tables and format it as a
// series of INSERT statements, for each different DBMS...
// After every row a custom callback function $handler gets called.
// $handler must accept one parameter ($sql_insert);
//
//
// Here is the function for postgres...
//
function get_table_content_postgresql($table, $handler)
{
global $db;
// Grab all of the data from current table.
$result = $db->sql_query("SELECT * FROM $table");
$i_num_fields = $db->sql_numfields($result);
for ($i = 0; $i < $i_num_fields; $i++)
{
$aryType[] = $db->sql_fieldtype($i, $result);
$aryName[] = $db->sql_fieldname($i, $result);
}
$iRec = 0;
while ($row = $db->sql_fetchrow($result))
{
unset($schema_vals);
unset($schema_fields);
unset($schema_insert);
// Build the SQL statement to recreate the data.
for($i = 0; $i < $i_num_fields; $i++)
{
$strVal = $row[$aryName[$i]];
if (preg_match('#char|text|bool#i', $aryType[$i]))
{
$strQuote = "'";
$strEmpty = "";
$strVal = addslashes($strVal);
}
elseif (preg_match('#date|timestamp#i', $aryType[$i]))
{
if ($empty($strVal))
{
$strQuote = "";
}
else
{
$strQuote = "'";
}
}
else
{
$strQuote = "";
$strEmpty = "NULL";
}
if (empty($strVal) && $strVal != "0")
{
$strVal = $strEmpty;
}
$schema_vals .= " $strQuote$strVal$strQuote,";
$schema_fields .= " $aryName[$i],";
}
$schema_vals = preg_replace('#,$#', '', $schema_vals);
$schema_vals = preg_replace('#^ #', '', $schema_vals);
$schema_fields = preg_replace('#,$#', '', $schema_fields);
$schema_fields = preg_replace('#^ #', '', $schema_fields);
// Take the ordered fields and their associated data and build it
// into a valid sql statement to recreate that field in the data.
$schema_insert = "INSERT INTO $table ($schema_fields) VALUES($schema_vals);";
$handler(trim($schema_insert));
}
return(true);
}// end function get_table_content_postgres...
//
// This function is for getting the data from a mysql table.
//
function get_table_content_mysql($table, $handler)
{
global $db;
// Grab the data from the table.
$result = $db->sql_query("SELECT * FROM $table");
// Loop through the resulting rows and build the sql statement.
$schema_insert = "";
if ($row = $db->sql_fetchrow($result))
{
$schema_insert = "\n#\n# Table Data for $table\n#\n";
$handler($schema_insert);
do
{
$table_list = '(';
$num_fields = $db->sql_numfields($result);
//
// Grab the list of field names.
//
for ($j = 0; $j < $num_fields; $j++)
{
$table_list .= $db->sql_fieldname($j, $result) . ', ';
}
//
// Get rid of the last comma
//
$table_list = preg_replace('#, $#', '', $table_list);
$table_list .= ')';
//
// Start building the SQL statement.
//
$schema_insert = "INSERT INTO $table $table_list VALUES(";
//
// Loop through the rows and fill in data for each column
//
for ($j = 0; $j < $num_fields; $j++)
{
if (!isset($row[$j]))
{
//
// If there is no data for the column set it to null.
// There was a problem here with an extra space causing the
// sql file not to reimport if the last column was null in
// any table. Should be fixed now :) JLH
//
$schema_insert .= ' NULL,';
}
elseif ($row[$j] != '')
{
$schema_insert .= ' \'' . addslashes($row[$j]) . '\',';
}
else
{
$schema_insert .= '\'\',';
}
}
//
// Get rid of the the last comma.
//
$schema_insert = preg_replace('#,$#', '', $schema_insert);
$schema_insert .= ');';
//
// Go ahead and send the insert statement to the handler function.
//
$handler(trim($schema_insert));
}
while ($row = $db->sql_fetchrow($result));
}
return true;
}
function output_table_content($content)
{
global $tempfile;
//fwrite($tempfile, $content . "\n");
//$backup_sql .= $content . "\n";
echo $content ."\n";
return;
}
//
// End Functions
// -----------------------------------------------
?>

View File

@@ -0,0 +1,157 @@
<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
if (!empty($setmodules))
{
if (!$auth->acl_get('a_names'))
{
return;
}
$module['USER']['DISALLOW'] = basename(__FILE__) . $SID;
return;
}
define('IN_PHPBB', 1);
// Include files
$phpbb_root_path = '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
require($phpbb_root_path . 'includes/functions_user.'.$phpEx);
// Check permissions
if (!$auth->acl_get('a_names'))
{
trigger_error($user->lang['NO_ADMIN']);
}
if (isset($_POST['disallow']))
{
$disallowed_user = (isset($_REQUEST['disallowed_user'])) ? htmlspecialchars($_REQUEST['disallowed_user']) : '';
$disallowed_user = str_replace('*', '%', $disallowed_user);
if (validate_username($disallowed_user))
{
$message = $user->lang['Disallowed_already'];
}
else
{
$sql = 'INSERT INTO ' . DISALLOW_TABLE . " (disallow_username)
VALUES('" . $db->sql_escape(stripslashes($disallowed_user)) . "')";
$result = $db->sql_query($sql);
$message = $user->lang['Disallow_successful'];
}
add_log('admin', 'log_disallow_add', str_replace('%', '*', $disallowed_user));
trigger_error($message);
}
else if (isset($_POST['allow']))
{
$disallowed_id = (isset($_REQUEST['disallowed_id'])) ? intval($_REQUEST['disallowed_id']) : '';
if (empty($disallowed_id))
{
trigger_error($user->lang['No_user_selected']);
}
$sql = 'DELETE FROM ' . DISALLOW_TABLE . "
WHERE disallow_id = $disallowed_id";
$db->sql_query($sql);
add_log('admin', 'log_disallow_delete');
trigger_error($user->lang['Disallowed_deleted']);
}
// Grab the current list of disallowed usernames...
$sql = 'SELECT *
FROM ' . DISALLOW_TABLE;
$result = $db->sql_query($sql);
$disallow_select = '';
if ($row = $db->sql_fetchrow($result))
{
do
{
$disallow_select .= '<option value="' . $row['disallow_id'] . '">' . str_replace('%', '*', $row['disallow_username']) . '</option>';
}
while ($row = $db->sql_fetchrow($result));
}
// Output page
adm_page_header($user->lang['DISALLOW']);
?>
<h1><?php echo $user->lang['DISALLOW']; ?></h1>
<p><?php echo $user->lang['Disallow_explain']; ?></p>
<form method="post" action="<?php echo "admin_disallow.$phpEx$SID"; ?>"><table class="bg" width="80%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang['Add_disallow_title']; ?></th>
</tr>
<tr>
<td class="row1"><?php echo $user->lang['USERNAME']; ?><br /><span class="gensmall"><?php echo $user->lang['Add_disallow_explain']; ?></span></td>
<td class="row2"><input class="post" type="text" name="disallowed_user" size="30" />&nbsp;</td>
</tr>
<tr>
<td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="disallow" value="<?php echo $user->lang['SUBMIT']; ?>" />&nbsp;&nbsp;<input class="btnlite" type="reset" value="<?php echo $user->lang['RESET']; ?>" />
</tr>
</table>
<h1><?php echo $user->lang['Delete_disallow_title']; ?></h1>
<p><?php echo $user->lang['Delete_disallow_explain']; ?></p>
<table class="bg" width="80%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang['Delete_disallow_title']; ?></th>
</tr>
<?php
if ($disallow_select != '')
{
?>
<tr>
<td class="row1"><?php echo $user->lang['USERNAME']; ?></td>
<td class="row2"><select class="post" name="disallowed_id"><?php echo $disallow_select; ?></select></td>
</tr>
<tr>
<td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="allow" value="<?php echo $user->lang['SUBMIT']; ?>" />&nbsp;&nbsp;<input class="btnlite" type="reset" value="<?php echo $user->lang['RESET']; ?>" />
</tr>
<?php
}
else
{
?>
<tr>
<td class="row1" colspan="2" align="center"><?php echo $user->lang['No_disallowed']; ?></td>
</tr>
<?php
}
?>
</table></form>
<?php
adm_page_footer();
?>

274
phpBB/adm/admin_email.php Normal file
View File

@@ -0,0 +1,274 @@
<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
if (!empty($setmodules))
{
$file = basename(__FILE__);
$module['GENERAL']['MASS_EMAIL'] = ($auth->acl_get('a_email')) ? "$file$SID" : '';
return;
}
define('IN_PHPBB', 1);
// Include files
$phpbb_root_path = './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
// Check permissions
if (!$auth->acl_get('a_email'))
{
trigger_error($user->lang['NO_ADMIN']);
}
// Set some vars
$message = $subject = $group_id = '';
// Do the job ...
if (isset($_POST['submit']))
{
// Error checking needs to go here ... if no subject and/or no message then skip
// over the send and return to the form
$group_id = request_var('g', 0);
$usernames = request_var('usernames', '');
$subject = preg_replace('#&(\#[0-9]+;)#', '&\1', strtr(request_var('subject', ''), array_flip(get_html_translation_table(HTML_ENTITIES))));
$message = preg_replace('#&(\#[0-9]+;)#', '&\1', strtr(request_var('message', ''), array_flip(get_html_translation_table(HTML_ENTITIES))));
$use_queue = (isset($_POST['send_immediatly'])) ? false : true;
$priority = request_var('mail_priority_flag', MAIL_NORMAL_PRIORITY);
// NOTE: Only temporary, i do not think this is a good idea for the final code, but i have to test this more than once. ;)
$log_session= (isset($_POST['log_session'])) ? true : false;
$error = array();
if (!$subject)
{
$error[] = $user->lang['NO_EMAIL_SUBJECT'];
}
if (!$message)
{
$error[] = $user->lang['NO_EMAIL_MESSAGE'];
}
if (!sizeof($error))
{
if ($usernames)
{
$usernames = implode(', ', preg_replace('#^[\s]*?(.*?)[\s]*?$#e', "\"'\" . \$db->sql_escape('\\1') . \"'\"", explode("\n", $usernames)));
$sql = 'SELECT username, user_email, user_jabber, user_notify_type, user_lang
FROM ' . USERS_TABLE . "
WHERE username IN ($usernames)
AND user_allow_massemail = 1
ORDER BY user_lang, user_notify_type, SUBSTRING(user_email FROM INSTR(user_email,'@'))";
}
else
{
$sql = ($group_id) ? 'SELECT u.user_email, u.username, u.user_lang, u.user_jabber, u.user_notify_type FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug WHERE ug.group_id = $group_id AND ug.user_pending <> 1 AND u.user_id = ug.user_id AND u.user_allow_massemail = 1" : 'SELECT u.username, u.user_email, u.user_jabber, u.user_notify_type, u.user_lang FROM ' . USERS_TABLE . ' u WHERE u.user_allow_massemail = 1';
// TODO: different for other db servers?
$sql .= " ORDER BY u.user_lang, u.user_notify_type, SUBSTRING(u.user_email FROM INSTR(u.user_email,'@'))";
}
$result = $db->sql_query($sql);
if (!($row = $db->sql_fetchrow($result)))
{
trigger_error($user->lang['NO_USER']);
}
$db->sql_freeresult($result);
$i = $j = 0;
// Send with BCC, no more than 50 recipients for one mail (to not exceed the limit)
$max_chunk_size = 50;
$email_list = array();
$old_lang = $row['user_lang'];
$old_notify_type = $row['user_notify_type'];
do
{
if (($row['user_notify'] == NOTIFY_EMAIL && $row['user_email']) ||
($row['user_notify'] == NOTIFY_IM && $row['user_jabber']) ||
($row['user_notify'] == NOTIFY_BOTH && $row['user_email'] && $row['user_jabber']))
{
if ($i == $max_chunk_size || $row['user_lang'] != $old_lang || $row['user_notify_type'] != $old_notify_type)
{
$i = 0;
$j++;
$old_lang = $row['user_lang'];
$old_notify_type = $row['user_notify_type'];
}
$email_list[$j][$i]['lang'] = $row['user_lang'];
$email_list[$j][$i]['method'] = $row['user_notify_type'];
$email_list[$j][$i]['email'] = $row['user_email'];
$email_list[$j][$i]['name'] = $row['username'];
$email_list[$j][$i]['jabber'] = $row['user_jabber'];
$i++;
}
}
while ($row = $db->sql_fetchrow($result));
$db->sql_freeresult($result);
// Send the messages
include_once($phpbb_root_path . 'includes/functions_messenger.'.$phpEx);
$messenger = new messenger($use_queue);
$errored = false;
for ($i = 0; $i < sizeof($email_list); $i++)
{
$used_lang = $email_list[$i][0]['lang'];
$used_method = $email_list[$i][0]['method'];
for ($j = 0; $j < sizeof($email_list[$i]); $j++)
{
$email_row = $email_list[$i][$j];
$messenger->{((sizeof($email_list[$i]) == 1) ? 'to' : 'bcc')}($email_row['email'], $email_row['name']);
$messenger->im($email_row['jabber'], $email_row['name']);
}
$messenger->template('admin_send_email', $used_lang);
$messenger->headers('X-AntiAbuse: Board servername - ' . $config['server_name']);
$messenger->headers('X-AntiAbuse: User_id - ' . $user->data['user_id']);
$messenger->headers('X-AntiAbuse: Username - ' . $user->data['username']);
$messenger->headers('X-AntiAbuse: User IP - ' . $user->ip);
$messenger->subject($subject);
$messenger->replyto($config['board_email']);
$messenger->set_mail_priority($priority);
$messenger->assign_vars(array(
'SITENAME' => $config['sitename'],
'CONTACT_EMAIL' => $config['board_contact'],
'MESSAGE' => $message)
);
if (!($messenger->send($used_method, $log_session)))
{
$errored = true;
}
}
unset($email_list);
$messenger->save_queue();
if ($group_id)
{
$sql = 'SELECT group_name
FROM ' . GROUPS_TABLE . "
WHERE group_id = $group_id";
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
extract($row);
}
else
{
// Not great but the logging routine doesn't cope well with localising
// on the fly
$group_name = $user->lang['ALL_USERS'];
}
add_log('admin', 'LOG_MASS_EMAIL', $group_name);
$message = (!$errored) ? $user->lang['EMAIL_SENT'] : sprintf($user->lang['EMAIL_SEND_ERROR'], '<a href="admin_viewlogs.' . $phpEx . $SID . '&amp;mode=critical" class="gen">', '</a>');
trigger_error($message);
}
}
// Initial selection
$sql = 'SELECT group_id, group_type, group_name
FROM ' . GROUPS_TABLE . '
ORDER BY group_type DESC, group_name ASC';
$result = $db->sql_query($sql);
$select_list = '<option value="0"' . ((!$group_id) ? ' selected="selected"' : '') . '>' . $user->lang['ALL_USERS'] . '</option>';
if ($row = $db->sql_fetchrow($result))
{
do
{
$selected = ($group_id == $row['group_id']) ? ' selected="selected"' : '';
$select_list .= '<option value = "' . $row['group_id'] . '"' . (($row['group_type'] == GROUP_SPECIAL) ? ' class="blue"' : '') . $selected . '>' . (($row['group_type'] == GROUP_SPECIAL) ? $user->lang['G_' . $row['group_name']] : $row['group_name']) . '</option>';
}
while ($row = $db->sql_fetchrow($result));
}
$db->sql_freeresult($result);
$s_priority_options = '<option value="' . MAIL_LOW_PRIORITY . '">' . $user->lang['MAIL_LOW_PRIORITY'] . '</option>';
$s_priority_options .= '<option value="' . MAIL_NORMAL_PRIORITY . '" selected="selected">' . $user->lang['MAIL_NORMAL_PRIORITY'] . '</option>';
$s_priority_options .= '<option value="' . MAIL_HIGH_PRIORITY . '">' . $user->lang['MAIL_HIGH_PRIORITY'] . '</option>';
adm_page_header($user->lang['MASS_EMAIL']);
?>
<h1><?php echo $user->lang['MASS_EMAIL']; ?></h1>
<p><?php echo $user->lang['MASS_EMAIL_EXPLAIN']; ?></p>
<form method="post" action="<?php echo "admin_email.$phpEx$SID"; ?>" name="email"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang['COMPOSE']; ?></th>
</tr>
<?php
if (sizeof($error))
{
?>
<tr>
<td class="row3" colspan="2" align="center"><span class="error"><?php echo implode('<br />', $error); ?></span></td>
</tr>
<?php
}
?>
<tr>
<td class="row1" width="40%"><b><?php echo $user->lang['SEND_TO_GROUP']; ?>: </b></td>
<td class="row2"><select name="g"><?php echo $select_list; ?></select></td>
</tr>
<tr>
<td class="row1" valign="top"><b><?php echo $user->lang['SEND_TO_USERS']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['SEND_TO_USERS_EXPLAIN']; ?><br />[ <a href="" onclick="window.open('<?php echo "../memberlist.$phpEx$SID"; ?>&amp;mode=searchuser&amp;form=email&amp;field=usernames', '_phpbbsearch', 'HEIGHT=500,resizable=yes,scrollbars=yes,WIDTH=740');return false;"><?php echo $user->lang['FIND_USERNAME']; ?></a> ]</span></td>
<td class="row2" align="left"><textarea name="usernames" rows="5" cols="40"><?php echo $usernames; ?></textarea></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['SUBJECT']; ?>: </b></td>
<td class="row2"><input class="post" type="text" name="subject" size="45" maxlength="100" tabindex="2" value="<?php echo $subject; ?>" /></td>
</tr>
<tr>
<td class="row1" valign="top"><span class="gen"><b><?php echo $user->lang['MASS_MESSAGE']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['MASS_MESSAGE_EXPLAIN']; ?></span></td>
<td class="row2"><textarea class="post" name="message" rows="10" cols="60" tabindex="3"><?php echo $message; ?></textarea></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['MAIL_PRIORITY']; ?>: </b></td>
<td class="row2"><select name="mail_priority_flag"><?php echo $s_priority_options; ?></select></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['SEND_IMMEDIATLY']; ?>: </b></td>
<td class="row2"><input type="checkbox" name="send_immediatly" class="text" checked="checked" /></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['LOG_SESSION']; ?>: </b></td>
<td class="row2"><input type="checkbox" name="log_session" class="text" /></td>
</tr>
<tr>
<td class="cat" colspan="2" align="center"><input type="submit" value="<?php echo $user->lang['EMAIL']; ?>" name="submit" class="btnmain" /></td>
</tr>
</table></form>
<?php
adm_page_footer();
?>

1582
phpBB/adm/admin_forums.php Normal file

File diff suppressed because it is too large Load Diff

956
phpBB/adm/admin_groups.php Normal file
View File

@@ -0,0 +1,956 @@
<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
* @todo Avatar gallery ...
* @todo Mass user pref setting via group membership
*/
/**
*/
if (!empty($setmodules))
{
if (!$auth->acl_get('a_group'))
{
return;
}
$module['USER']['GROUP_MANAGE'] = basename(__FILE__) . "$SID&amp;mode=manage";
return;
}
define('IN_PHPBB', 1);
// Include files
$phpbb_root_path = '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/functions_user.'.$phpEx);
// Do we have general permissions?
if (!$auth->acl_get('a_group'))
{
trigger_error($user->lang['NO_ADMIN']);
}
// Check and set some common vars
$mode = request_var('mode', '');
$action = (isset($_POST['add'])) ? 'add' : ((isset($_POST['addusers'])) ? 'addusers' : request_var('action', ''));
$group_id = request_var('g', 0);
$mark_ary = request_var('mark', array(0));
$name_ary = request_var('usernames', '');
$leader = request_var('leader', 0);
$default = request_var('default', 0);
$start = request_var('start', 0);
$update = (isset($_POST['update'])) ? true : false;
$confirm = (isset($_POST['confirm'])) ? true : false;
$cancel = (isset($_POST['cancel'])) ? true : false;
// Clear some vars
$can_upload = (file_exists($phpbb_root_path . $config['avatar_path']) && is_writeable($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
if ($group_id)
{
$sql = 'SELECT *
FROM ' . GROUPS_TABLE . "
WHERE group_id = $group_id";
$result = $db->sql_query($sql);
$group_row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
if (!$group_row)
{
trigger_error($user->lang['NO_GROUP']);
}
}
switch ($mode)
{
case 'manage':
// Page header
adm_page_header($user->lang['MANAGE']);
// Common javascript
?>
<script language="javascript" type="text/javascript">
<!--
function marklist(match, status)
{
len = eval('document.' + match + '.length');
for (i = 0; i < len; i++)
{
eval('document.' + match + '.elements[i].checked = ' + status);
}
}
//-->
</script>
<?php
// Which page?
switch ($action)
{
case 'approve':
case 'demote':
case 'promote':
if (!$group_id)
{
trigger_error($user->lang['NO_GROUP']);
}
group_user_attributes($action, $group_id, $mark_ary, false, ($group_id) ? $group_row['group_name'] : false);
switch ($action)
{
case 'demote':
$message = 'GROUP_MODS_DEMOTED';
break;
case 'promote':
$message = 'GROUP_MODS_PROMOTED';
break;
case 'approve':
$message = 'USERS_APPROVED';
break;
}
trigger_error($user->lang[$message]);
break;
case 'default':
if (!$group_id)
{
trigger_error($user->lang['NO_GROUP']);
}
if (!$mark_ary)
{
$start = 0;
do
{
$sql = 'SELECT user_id
FROM ' . USER_GROUP_TABLE . "
WHERE group_id = $group_id
ORDER BY user_id";
$result = $db->sql_query_limit($sql, 200, $start);
$mark_ary = array();
if ($row = $db->sql_fetchrow($result))
{
do
{
$mark_ary[] = $row['user_id'];
}
while ($row = $db->sql_fetchrow($result));
group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row);
$start = (sizeof($user_id_ary) < 200) ? 0 : $start + 200;
}
else
{
$start = 0;
}
$db->sql_freeresult($result);
}
while ($start);
}
else
{
group_user_attributes('default', $group_id, $mark_ary, false, $group_row['group_name'], $group_row);
}
trigger_error($user->lang['GROUP_DEFS_UPDATED']);
break;
case 'deleteusers':
case 'delete':
if (!$cancel && !$confirm)
{
adm_page_confirm($user->lang['CONFIRM'], $user->lang['CONFIRM_OPERATION']);
}
else
{
if (!$group_id)
{
trigger_error($user->lang['NO_GROUP']);
}
switch ($action)
{
case 'delete':
$error = group_delete($group_id, $group_row['group_name']);
break;
case 'deleteusers':
$error = group_user_del($group_id, $mark_ary, false, $group_row['group_name']);
break;
}
if ($error)
{
trigger_error($user->lang[$error]);
}
$message = ($action == 'delete') ? 'GROUP_DELETED' : 'GROUP_USERS_REMOVE';
trigger_error($user->lang[$message]);
}
break;
case 'addusers':
if (!$group_id)
{
trigger_error($user->lang['NO_GROUP']);
}
if (!$name_ary)
{
trigger_error($user->lang['NO_USERS']);
}
$name_ary = array_unique(explode("\n", $name_ary));
// Add user/s to group
if ($error = group_user_add($group_id, false, $name_ary, $group_row['group_name'], $default, $leader, $group_row))
{
trigger_error($user->lang[$error]);
}
$message = ($action == 'addleaders') ? 'GROUP_MODS_ADDED' : 'GROUP_USERS_ADDED';
trigger_error($user->lang[$message]);
break;
case 'edit':
case 'add':
$data = $submit_ary = array();
if ($action == 'edit' && !$group_id)
{
trigger_error($user->lang['NO_GROUP']);
}
$error = array();
$user->add_lang('ucp');
// Did we submit?
if ($update)
{
$group_name = request_var('group_name', '');
$group_desc = request_var('group_description', '');
$group_type = request_var('group_type', GROUP_FREE);
$data['uploadurl'] = request_var('uploadurl', '');
$data['remotelink'] = request_var('remotelink', '');
$delete = request_var('delete', '');
$submit_ary = array(
'colour' => request_var('group_colour', ''),
'rank' => request_var('group_rank', 0),
'receive_pm' => isset($_REQUEST['group_receive_pm']) ? 1 : 0,
'message_limit' => request_var('group_message_limit', 0)
);
$avatar = '';
if (!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl'] || $data['remotelink'])
{
$data['width'] = request_var('width', '');
$data['height'] = request_var('height', '');
// Avatar stuff
$var_ary = array(
'uploadurl' => array('string', true, 5, 255),
'remotelink' => array('string', true, 5, 255),
'width' => array('string', true, 1, 3),
'height' => array('string', true, 1, 3),
);
if (!($error = validate_data($data, $var_ary)))
{
$data['user_id'] = "g$group_id";
if ((!empty($_FILES['uploadfile']['tmp_name']) || $data['uploadurl']) && $can_upload)
{
list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_upload($data, $error);
}
else if ($data['remotelink'])
{
list($submit_ary['avatar_type'], $submit_ary['avatar'], $submit_ary['avatar_width'], $submit_ary['avatar_height']) = avatar_remote($data, $error);
}
}
}
else if ($delete)
{
$submit_ary['avatar'] = '';
$submit_ary['avatar_type'] = $submit_ary['avatar_width'] = $submit_ary['avatar_height'] = 0;
}
if (($submit_ary['avatar'] && (!isset($group_row['group_avatar']) || $group_row['group_avatar'] != $submit_ary['avatar'])) || $delete)
{
if (isset($group_row['group_avatar']) && $group_row['group_avatar'])
{
avatar_delete($group_row['group_avatar']);
}
}
// Only set the rank, colour, etc. if it's changed or if we're adding a new
// group. This prevents existing group members being updated if no changes
// were made.
$group_attributes = array();
foreach (array('rank', 'colour', 'avatar', 'avatar_type', 'avatar_width', 'avatar_height', 'receive_pm', 'message_limit') as $test)
{
if ($action == 'add' || (isset($group_row['group_' . $test]) && $group_row['group_' . $test] != $submit_ary[$test]))
{
$group_attributes[$test] = $group_row['group_' . $test] = $submit_ary[$test];
}
}
if (!($error = group_create($group_id, $group_type, $group_name, $group_description, $group_attributes)))
{
$message = ($action == 'edit') ? 'GROUP_UPDATED' : 'GROUP_CREATED';
trigger_error($message);
}
}
else if (!$group_id)
{
$group_name = request_var('group_name', '');
$group_description = '';
$group_type = GROUP_OPEN;
}
else
{
$group_name = $group_row['group_name'];
$group_description = $group_row['group_description'];
$group_type = $group_row['group_type'];
}
?>
<h1><?php echo $user->lang['MANAGE']; ?></h1>
<p><?php echo $user->lang['GROUP_EDIT_EXPLAIN']; ?></p>
<?php
$sql = 'SELECT *
FROM ' . RANKS_TABLE . '
WHERE rank_special = 1
ORDER BY rank_title';
$result = $db->sql_query($sql);
$rank_options = '<option value="-1"' . ((empty($group_rank)) ? 'selected="selected" ' : '') . '>' . $user->lang['USER_DEFAULT'] . '</option>';
if ($row = $db->sql_fetchrow($result))
{
do
{
$selected = (!empty($group_rank) && $row['rank_id'] == $group_rank) ? ' selected="selected"' : '';
$rank_options .= '<option value="' . $row['rank_id'] . '"' . $selected . '>' . $row['rank_title'] . '</option>';
}
while ($row = $db->sql_fetchrow($result));
}
$db->sql_freeresult($result);
$type_free = ($group_type == GROUP_FREE) ? ' checked="checked"' : '';
$type_open = ($group_type == GROUP_OPEN) ? ' checked="checked"' : '';
$type_closed = ($group_type == GROUP_CLOSED) ? ' checked="checked"' : '';
$type_hidden = ($group_type == GROUP_HIDDEN) ? ' checked="checked"' : '';
if (isset($group_row['group_avatar']) && $group_row['group_avatar'])
{
switch ($group_row['group_avatar_type'])
{
case AVATAR_UPLOAD:
$avatar_img = $phpbb_root_path . $config['avatar_path'] . '/';
break;
case AVATAR_GALLERY:
$avatar_img = $phpbb_root_path . $config['avatar_gallery_path'] . '/';
break;
}
$avatar_img .= $group_row['group_avatar'];
$avatar_img = '<img src="' . $avatar_img . '" width="' . $group_row['group_avatar_width'] . '" height="' . $group_row['group_avatar_height'] . '" alt="" />';
}
else
{
$avatar_img = '<img src="images/no_avatar.gif" alt="" />';
}
$display_gallery = (isset($_POST['displaygallery'])) ? true : false;
?>
<script language="javascript" type="text/javascript">
<!--
function swatch()
{
window.open('./swatch.<?php echo $phpEx; ?>?form=settings&name=group_colour', '_swatch', 'HEIGHT=115,resizable=yes,scrollbars=no,WIDTH=636');
return false;
}
//-->
</script>
<form name="settings" method="post" action="<?php echo "admin_groups.$phpEx$SID&amp;mode=$mode&amp;action=$action&amp;g=$group_id"; ?>"<?php echo ($can_upload) ? ' enctype="multipart/form-data"' : ''; ?>>
<table class="bg" width="95%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang['GROUP_DETAILS']; ?></th>
</tr>
<?php
if (sizeof($error))
{
?>
<tr>
<td class="row1" colspan="2" align="center"><span style="color:red"><?php echo implode('<br />', $error); ?></span></td>
</tr>
<?php
}
?>
<tr>
<td class="row2" width="40%"><b><?php echo $user->lang['GROUP_NAME']; ?>:</b></td>
<td class="row1"><?php
if ($group_type != GROUP_SPECIAL)
{
?><input class="post" type="text" name="group_name" value="<?php echo ($group_name) ? $group_name : ''; ?>" size="40" maxlength="40" /><?php
}
else
{
?><b><?php echo ($group_type == GROUP_SPECIAL) ? $user->lang['G_' . $group_name] : $group_name; ?></b><?php
}
?></td>
</tr>
<tr>
<td class="row2"><b><?php echo $user->lang['GROUP_DESC']; ?>:</b></td>
<td class="row1"><input class="post" type="text" name="group_description" value="<?php echo ($group_description) ? $group_description : ''; ?>" size="40" maxlength="255" /></td>
</tr>
<?php
if ($group_type != GROUP_SPECIAL)
{
?>
<tr>
<td class="row2"><b><?php echo $user->lang['GROUP_TYPE']; ?>:</b><br /><span class="gensmall"><?php echo $user->lang['GROUP_TYPE_EXPLAIN']; ?></span></td>
<td class="row1" nowrap="nowrap"><input type="radio" name="group_type" value="<?php echo GROUP_FREE . '"' . $type_free; ?> /> <?php echo $user->lang['GROUP_OPEN']; ?> &nbsp; <input type="radio" name="group_type" value="<?php echo GROUP_OPEN . '"' . $type_open; ?> /> <?php echo $user->lang['GROUP_REQUEST']; ?> &nbsp; <input type="radio" name="group_type" value="<?php echo GROUP_CLOSED . '"' . $type_closed; ?> /> <?php echo $user->lang['GROUP_CLOSED']; ?> &nbsp; <input type="radio" name="group_type" value="<?php echo GROUP_HIDDEN . '"' . $type_hidden; ?>" /> <?php echo $user->lang['GROUP_HIDDEN']; ?></td>
</tr>
<?php
}
?>
<tr>
<th colspan="2"><?php echo $user->lang['GROUP_SETTINGS_SAVE']; ?></th>
</tr>
<tr>
<td class="row2"><b><?php echo $user->lang['GROUP_RECEIVE_PM']; ?>:</b></td>
<td class="row1" nowrap="nowrap"><input type="checkbox" name="group_receive_pm"<?php echo (isset($group_row['group_receive_pm']) && $group_row['group_receive_pm']) ? ' checked="checked"' : ''; ?> /></td>
</tr>
<tr>
<td class="row2"><b><?php echo $user->lang['GROUP_MESSAGE_LIMIT']; ?>:</b><br /><span class="gensmall"><?php echo $user->lang['GROUP_MESSAGE_LIMIT_EXPLAIN']; ?></span></td>
<td class="row1" nowrap="nowrap"><input class="post" type="text" maxlength="4" size="4" name="group_message_limit" value="<?php echo (isset($group_row['group_message_limit'])) ? $group_row['group_message_limit'] : 0; ?>" /></td>
</tr>
<tr>
<td class="row2"><b><?php echo $user->lang['GROUP_COLOR']; ?>:</b><br /><span class="gensmall"><?php echo $user->lang['GROUP_COLOR_EXPLAIN']; ?></span></td>
<td class="row1" nowrap="nowrap"><input class="post" type="text" name="group_colour" value="<?php echo (isset($group_row['group_colour'])) ? $group_row['group_colour'] : ''; ?>" size="6" maxlength="6" /> &nbsp; [ <a href="<?php echo "swatch.$phpEx"; ?>" onclick="swatch();return false" target="_swatch"><?php echo $user->lang['COLOUR_SWATCH']; ?></a> ]</td>
</tr>
<tr>
<td class="row2"><b><?php echo $user->lang['GROUP_RANK']; ?>:</b></td>
<td class="row1"><select name="group_rank"><?php echo $rank_options; ?></select></td>
</tr>
<tr>
<th colspan="2"><?php echo $user->lang['GROUP_AVATAR']; ?></th>
</tr>
<tr>
<td class="row2" width="35%"><b><?php echo $user->lang['CURRENT_IMAGE']; ?>: </b><br /><span class="gensmall"><?php echo sprintf($user->lang['AVATAR_EXPLAIN'], $config['avatar_max_width'], $config['avatar_max_height'], round($config['avatar_filesize'] / 1024)); ?></span></td>
<td class="row1" align="center"><br /><?php echo $avatar_img; ?><br /><br /><input type="checkbox" name="delete" />&nbsp;<span class="gensmall"><?php echo $user->lang['DELETE_AVATAR']; ?></span></td>
</tr>
<?php
// Can we upload?
if ($can_upload)
{
?>
<tr>
<td class="row2" width="35%"><b><?php echo $user->lang['UPLOAD_AVATAR_FILE']; ?>: </b></td>
<td class="row1"><input type="hidden" name="MAX_FILE_SIZE" value="<?php echo $config['avatar_max_filesize']; ?>" /><input class="post" type="file" name="uploadfile" /></td>
</tr>
<tr>
<td class="row2" width="35%"><b><?php echo $user->lang['UPLOAD_AVATAR_URL']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['UPLOAD_AVATAR_URL_EXPLAIN']; ?></span></td>
<td class="row1"><input class="post" type="text" name="uploadurl" size="40" value="" /></td>
</tr>
<?php
}
?>
<tr>
<td class="row2" width="35%"><b><?php echo $user->lang['LINK_REMOTE_AVATAR']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['LINK_REMOTE_AVATAR_EXPLAIN']; ?></span></td>
<td class="row1"><input class="post" type="text" name="remotelink" size="40" value="" /></td>
</tr>
<tr>
<td class="row2" width="35%"><b><?php echo $user->lang['LINK_REMOTE_SIZE']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['LINK_REMOTE_SIZE_EXPLAIN']; ?></span></td>
<td class="row1"><input class="post" type="text" name="width" size="3" value="<?php echo (isset($group_row['group_avatar_width'])) ? $group_row['group_avatar_width'] : ''; ?>" /> <span class="gen">px X </span> <input class="post" type="text" name="height" size="3" value="<?php echo (isset($group_row['group_avatar_height'])) ? $group_row['group_avatar_height'] : ''; ?>" /> <span class="gen">px</span></td>
</tr>
<?php
// Do we have a gallery?
if ($config['allow_avatar_local'] && !$display_gallery)
{
?>
<tr>
<td class="row2" width="35%"><b><?php echo $user->lang['AVATAR_GALLERY']; ?>: </b></td>
<td class="row1"><input class="btnlite" type="submit" name="displaygallery" value="<?php echo $user->lang['DISPLAY_GALLERY']; ?>" /></td>
</tr>
<?php
}
// Do we want to display it?
if ($config['allow_avatar_local'] && $display_gallery)
{
?>
<tr>
<th colspan="2"><?php echo $user->lang['AVATAR_GALLERY']; ?></th>
</tr>
<tr>
<td class="cat" colspan="2" align="center" valign="middle"><span class="genmed"><?php echo $user->lang['AVATAR_CATEGORY']; ?>: </span><select name="avatarcat">{S_CAT_OPTIONS}</select>&nbsp; <span class="genmed"><?php echo $user->lang['AVATAR_PAGE']; ?>: </span><select name="avatarpage">{S_PAGE_OPTIONS}</select>&nbsp;<input class="btnlite" type="submit" value="<?php echo $user->lang['GO']; ?>" name="avatargallery" /></td>
</tr>
<tr>
<td class="row1" colspan="2" align="center">
<table cellspacing="1" cellpadding="4" border="0">
<!-- BEGIN avatar_row -->
<tr>
<!-- BEGIN avatar_column -->
<td class="row1" align="center"><img src="{avatar_row.avatar_column.AVATAR_IMAGE}" alt="{avatar_row.avatar_column.AVATAR_NAME}" title="{avatar_row.avatar_column.AVATAR_NAME}" /></td>
<!-- END avatar_column -->
</tr>
<tr>
<!-- BEGIN avatar_option_column -->
<td class="row2" align="center"><input type="radio" name="avatarselect" value="{avatar_row.avatar_option_column.S_OPTIONS_AVATAR}" /></td>
<!-- END avatar_option_column -->
</tr>
<!-- END avatar_row -->
</table>
</td>
</tr>
<?php
}
?>
<tr>
<td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="update" value="<?php echo $user->lang['SUBMIT']; ?>" /> &nbsp; <input class="btnlite" type="reset" value="<?php echo $user->lang['RESET']; ?>" /></td>
</tr>
</table>
</form>
<?php
adm_page_footer();
break;
}
if ($mode == 'list' || $group_id)
{
if (!$group_id)
{
trigger_error($user->lang['NO_GROUP']);
}
?>
<h1><?php echo $user->lang['GROUP_MEMBERS']; ?></h1>
<p><?php echo $user->lang['GROUP_MEMBERS_EXPLAIN']; ?></p>
<form name="list" method="post" action="<?php echo "admin_groups.$phpEx$SID&amp;mode=$mode&amp;g=$group_id"; ?>">
<table class="bg" width="95%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th width="55%"><?php echo $user->lang['USERNAME']; ?></th>
<th width="3%" nowrap="nowrap"><?php echo $user->lang['GROUP_DEFAULT']; ?></th>
<th width="20%"><?php echo $user->lang['JOINED']; ?></th>
<th width="20%"><?php echo $user->lang['POSTS']; ?></th>
<th width="2%"><?php echo $user->lang['MARK']; ?></th>
</tr>
<?php
// Total number of group leaders
$sql = 'SELECT COUNT(user_id) AS total_leaders
FROM ' . USER_GROUP_TABLE . "
WHERE group_id = $group_id
AND group_leader = 1";
$result = $db->sql_query($sql);
$total_leaders = ($row = $db->sql_fetchrow($result)) ? $row['total_leaders'] : 0;
$db->sql_freeresult($result);
// Total number of group members (non-leaders)
$sql = 'SELECT COUNT(user_id) AS total_members
FROM ' . USER_GROUP_TABLE . "
WHERE group_id = $group_id
AND group_leader <> 1";
$result = $db->sql_query($sql);
$total_members = ($row = $db->sql_fetchrow($result)) ? $row['total_members'] : 0;
$db->sql_freeresult($result);
// Grab the members
$sql = 'SELECT u.user_id, u.username, u.user_regdate, u.user_posts, u.group_id, ug.group_leader, ug.user_pending
FROM ' . USERS_TABLE . ' u, ' . USER_GROUP_TABLE . " ug
WHERE ug.group_id = $group_id
AND u.user_id = ug.user_id
ORDER BY ug.group_leader DESC, ug.user_pending ASC, u.username ";
$result = $db->sql_query_limit($sql, $config['topics_per_page'], $start);
$leader = $member = 0;
$group_data = array();
if ($row = $db->sql_fetchrow($result))
{
do
{
$type = ($row['group_leader']) ? 'leader' : 'member';
$group_data[$type][$$type]['user_id'] = $row['user_id'];
$group_data[$type][$$type]['group_id'] = $row['group_id'];
$group_data[$type][$$type]['username'] = $row['username'];
$group_data[$type][$$type]['user_regdate'] = $row['user_regdate'];
$group_data[$type][$$type]['user_posts'] = $row['user_posts'];
$group_data[$type][$$type]['user_pending'] = ($row['user_pending']) ? 1 : 0;
$$type++;
}
while ($row = $db->sql_fetchrow($result));
}
$db->sql_freeresult($result);
if ($group_row['group_type'] != GROUP_SPECIAL)
{
?>
<tr>
<td class="row3" colspan="5"><b><?php echo $user->lang['GROUP_LEAD']; ?></b></td>
</tr>
<?php
if (sizeof($group_data['leader']))
{
$row_class = '';
foreach ($group_data['leader'] as $row)
{
$row_class = ($row_class == 'row1') ? 'row2' : 'row1';
?>
<tr>
<td class="<?php echo $row_class; ?>"><a href="<?php echo "admin_users.$phpEx$SID&amp;mode=edit&amp;u=" . $row['user_id']; ?>"><?php echo $row['username']; ?></a></td>
<td class="<?php echo $row_class; ?>" align="center"><?php echo ($row['group_id'] == $group_id) ? $user->lang['YES'] : $user->lang['NO']; ?></td>
<td class="<?php echo $row_class; ?>" align="center"><?php echo $user->format_date($row['user_regdate'], $user->lang['DATE_FORMAT']); ?></td>
<td class="<?php echo $row_class; ?>" align="center"><?php echo $row['user_posts']; ?></td>
<td class="<?php echo $row_class; ?>" align="center"><input class="checkbox" type="checkbox" name="mark[]" value="<?php echo $row['user_id']; ?>" /></td>
</tr>
<?php
}
}
else
{
?>
<tr>
<td class="row1" colspan="5" align="center"><?php echo $user->lang['GROUPS_NO_MODS']; ?></td>
</tr>
<?php
}
}
?>
<tr>
<td class="row3" colspan="5"><b><?php echo $user->lang['GROUP_APPROVED']; ?></b></td>
</tr>
<?php
if (sizeof($group_data['member']))
{
$row_class = '';
$pending = false;
foreach ($group_data['member'] as $row)
{
$row_class = ($row_class == 'row1') ? 'row2' : 'row1';
if ($row['user_pending'] && !$pending)
{
?>
<tr>
<td class="row3" colspan="5"><b><?php echo $user->lang['GROUP_PENDING']; ?></b></td>
</tr>
<?php
$pending = true;
}
?>
<tr class="<?php echo $row_class; ?>">
<td><a href="<?php echo "admin_users.$phpEx$SID&amp;mode=edit&amp;u=" . $row['user_id']; ?>"><?php echo $row['username']; ?></a></td>
<td align="center"><?php echo ($row['group_id'] == $group_id) ? $user->lang['YES'] : $user->lang['NO']; ?></td>
<td align="center"><?php echo ($row['user_regdate']) ? $user->format_date($row['user_regdate'], $user->lang['DATE_FORMAT']) : '-'; ?></td>
<td align="center"><?php echo $row['user_posts']; ?></td>
<td align="center"><input class="checkbox" type="checkbox" name="mark[]" value="<?php echo $row['user_id']; ?>" /></td>
</tr>
<?php
}
}
else
{
?>
<tr>
<td class="row1" colspan="5" align="center"><?php echo $user->lang['GROUPS_NO_MEMBERS']; ?></td>
</tr>
<?php
}
?>
<tr>
<td class="cat" colspan="5" align="right">
<select name="action"><option class="sep" value=""><?php echo $user->lang['SELECT_OPTION']; ?></option><?php
foreach (array('default' => 'DEFAULT', 'approve' => 'APPROVE', 'demote' => 'DEMOTE', 'promote' => 'PROMOTE', 'deleteusers' => 'DELETE') as $option => $lang)
{
echo '<option value="' . $option . '">' . $user->lang['GROUP_' . $lang] . '</option>';
}
?>
</select> <input class="btnmain" type="submit" name="update" value="<?php echo $user->lang['SUBMIT']; ?>" />&nbsp;
</td>
</tr>
</table>
<table width="95%" cellspacing="1" cellpadding="1" border="0" align="center">
<tr>
<td valign="top"><?php echo on_page($total_members, $config['topics_per_page'], $start); ?></td>
<td align="right">
<b class="gensmall"><a href="javascript:marklist('list', true);"><?php echo $user->lang['MARK_ALL']; ?></a> :: <a href="javascript:marklist('list', false);"><?php echo $user->lang['UNMARK_ALL']; ?></a></b>&nbsp;<br />
<span class="nav"><?php echo generate_pagination("admin_groups.$phpEx$SID&amp;action=$action&amp;mode=$mode&amp;g=$group_id", $total_members, $config['topics_per_page'], $start, true); ?></span>
</td>
</tr>
</table>
<h1><?php echo $user->lang['ADD_USERS']; ?></h1>
<p><?php echo $user->lang['ADD_USERS_EXPLAIN']; ?></p>
<table class="bg" width="95%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang['ADD_USERS']; ?></th>
</tr>
<tr>
<td class="row1" width="40%"><b><?php echo $user->lang['USER_GROUP_LEADER']; ?>:</b></span></td>
<td class="row2"><input type="radio" name="leader" value="1" /> <?php echo $user->lang['YES']; ?> &nbsp; <input type="radio" name="leader" value="0" checked="checked" /> <?php echo $user->lang['NO']; ?></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['USER_GROUP_DEFAULT']; ?>:</b> <br /><span class="gensmall"><?php echo $user->lang['USER_GROUP_DEFAULT_EXPLAIN']; ?></span></td>
<td class="row2"><input type="radio" name="default" value="1" /> <?php echo $user->lang['YES']; ?> &nbsp; <input type="radio" name="default" value="0" checked="checked" /> <?php echo $user->lang['NO']; ?></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['USERNAME']; ?>:</b><br /><span class="gensmall"><?php echo $user->lang['USERNAMES_EXPLAIN']; ?><br />[ <a href="<?php echo "../memberlist.$phpEx$SID&amp;mode=searchuser&amp;form=list&amp;field=usernames"; ?>" target="usersearch"><?php echo $user->lang['FIND_USERNAME']; ?></a> ]</span></td>
<td class="row2"><textarea name="usernames" cols="40" rows="5"></textarea></td>
</tr>
<tr>
<td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="addusers" value="<?php echo $user->lang['SUBMIT']; ?>" /></td>
</tr>
</table>
</form>
<?php
adm_page_footer();
}
?>
<h1><?php echo $user->lang['GROUP_MANAGE']; ?></h1>
<p><?php echo $user->lang['GROUP_MANAGE_EXPLAIN']; ?></p>
<h1><?php echo $user->lang['USER_DEF_GROUPS']; ?></h1>
<p><?php echo $user->lang['USER_DEF_GROUPS_EXPLAIN']; ?></p>
<form method="post" action="<?php echo "admin_groups.$phpEx$SID&amp;mode=$mode"; ?>">
<table class="bg" width="95%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th width="95%"><?php echo $user->lang['MANAGE']; ?></th>
<th nowrap="nowrap"><?php echo $user->lang['TOTAL_MEMBERS']; ?></th>
<th colspan="3"><?php echo $user->lang['OPTIONS']; ?></th>
</tr>
<?php
$sql = 'SELECT g.group_id, g.group_name, g.group_type, COUNT(ug.user_id) AS total_members
FROM (' . GROUPS_TABLE . ' g
LEFT JOIN ' . USER_GROUP_TABLE . ' ug USING (group_id))
GROUP BY g.group_id
ORDER BY g.group_type ASC, g.group_name';
$result = $db->sql_query($sql);
$special = $normal = 0;
$group_ary = array();
while ($row = $db->sql_fetchrow($result) )
{
$type = ($row['group_type'] == GROUP_SPECIAL) ? 'special' : 'normal';
$group_ary[$type][$$type]['group_id'] = $row['group_id'];
$group_ary[$type][$$type]['group_name'] = $row['group_name'];
$group_ary[$type][$$type]['group_type'] = $row['group_type'];
$group_ary[$type][$$type]['total_members'] = $row['total_members'];
$$type++;
}
$db->sql_freeresult($result);
$special_toggle = false;
foreach ($group_ary as $type => $row_ary)
{
if ($type == 'special')
{
?>
<tr>
<td class="cat" colspan="5" align="right"><?php echo $user->lang['CREATE_GROUP']; ?>: <input class="post" type="text" name="group_name" maxlength="30" /> <input class="btnmain" type="submit" name="add" value="<?php echo $user->lang['SUBMIT']; ?>" /></td>
</tr>
</table>
<h1><?php echo $user->lang['SPECIAL_GROUPS']; ?></h1>
<p><?php echo $user->lang['SPECIAL_GROUPS_EXPLAIN']; ?></p>
<table class="bg" width="95%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th width="95%"><?php echo $user->lang['MANAGE']; ?></th>
<th><?php echo $user->lang['TOTAL_MEMBERS']; ?></th>
<th colspan="3"><?php echo $user->lang['OPTIONS']; ?></th>
</tr>
<?php
}
$row_class = '';
foreach ($row_ary as $row)
{
$row_class = ($row_class != 'row1') ? 'row1' : 'row2';
$group_id = $row['group_id'];
$group_name = (!empty($user->lang['G_' . $row['group_name']]))? $user->lang['G_' . $row['group_name']] : $row['group_name'];
?>
<tr class="<?php echo $row_class; ?>">
<td width="95%"><a href="admin_groups.<?php echo "$phpEx$SID&amp;mode=$mode&amp;action=list&amp;g=$group_id"; ?>"><?php echo $group_name; ?></a></td>
<td align="center" nowrap="nowrap">&nbsp;<?php echo $row['total_members']; ?>&nbsp;</td>
<td align="center" nowrap="nowrap">&nbsp;<a href="<?php echo "admin_groups.$phpEx$SID&amp;mode=$mode&amp;action=default&amp;g=$group_id"; ?>"><?php echo $user->lang['GROUP_DEFAULT']; ?></a>&nbsp;</td>
<td align="center" nowrap="nowrap">&nbsp;<a href="<?php echo "admin_groups.$phpEx$SID&amp;mode=$mode&amp;action=edit&amp;g=$group_id"; ?>"><?php echo $user->lang['EDIT']; ?></a>&nbsp;</td>
<td align="center" nowrap="nowrap">&nbsp;<?php
echo ($row['group_type'] != GROUP_SPECIAL) ? "<a href=\"admin_groups.$phpEx$SID&amp;mode=$mode&amp;action=delete&amp;g=$group_id\">" . $user->lang['DELETE'] . '</a>' : $user->lang['DELETE'];
?>&nbsp;</td>
</tr>
<?php
}
}
?>
<tr>
<td class="cat" colspan="5">&nbsp;</td>
</tr>
</table>
</form>
<?php
adm_page_footer();
break;
// Setting groupwide preferences
case 'prefs':
adm_page_header($user->lang['GROUP_PREFS']);
if ($update)
{
$user_lang = request_var('lang', '');
$user_tz = request_var('tz', 0.0);
$user_dst = request_var('dst', 0);
}
else
{
}
?>
<h1><?php echo $user->lang['GROUP_SETTINGS']; ?></h1>
<p><?php echo $user->lang['GROUP_SETTINGS_EXPLAIN']; ?></p>
<form method="post" action="<?php echo "admin_groups.$phpEx$SID&amp;action=edit&amp;g=$group_id"; ?>"><table class="bg" width="90%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang['GROUP_SETTINGS']; ?></th>
</tr>
<tr>
<td class="row2"><?php echo $user->lang['GROUP_LANG']; ?>:</td>
<td class="row1"><select name="user_lang"><?php echo '<option value="-1" selected="selected">' . $user->lang['USER_DEFAULT'] . '</option>' . language_select(); ?></select></td>
</tr>
<tr>
<td class="row2"><?php echo $user->lang['GROUP_TIMEZONE']; ?>:</td>
<td class="row1"><select name="user_tz"><?php echo '<option value="-14" selected="selected">' . $user->lang['USER_DEFAULT'] . '</option>' . tz_select(); ?></select></td>
</tr>
<tr>
<td class="row2"><?php echo $user->lang['GROUP_DST']; ?>:</td>
<td class="row1" nowrap="nowrap"><input type="radio" name="user_dst" value="0" /> <?php echo $user->lang['DISABLED']; ?> &nbsp; <input type="radio" name="user_dst" value="1" /> <?php echo $user->lang['ENABLED']; ?> &nbsp; <input type="radio" name="user_dst" value="-1" checked="checked" /> <?php echo $user->lang['USER_DEFAULT']; ?></td>
</tr>
<tr>
<td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="submitprefs" value="<?php echo $user->lang['SUBMIT']; ?>" /> &nbsp; <input class="btnlite" type="reset" value="<?php echo $user->lang['RESET']; ?>" /></td>
</tr>
</table></form>
<?php
adm_page_footer();
break;
default:
trigger_error($user->lang['NO_MODE']);
}
exit;
?>

776
phpBB/adm/admin_icons.php Normal file
View File

@@ -0,0 +1,776 @@
<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
if (!empty($setmodules))
{
if (!$auth->acl_get('a_icons'))
{
return;
}
$filename = basename(__FILE__);
$module['POST']['SMILIES'] = "$filename$SID&amp;mode=smilies";
$module['POST']['ICONS'] = "$filename$SID&amp;mode=icons";
return;
}
define('IN_PHPBB', 1);
// Include files
$phpbb_root_path = './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
// Do we have general permissions?
if (!$auth->acl_get('a_icons'))
{
trigger_error($user->lang['NO_ADMIN']);
}
// Grab some basic parameters
$mode = request_var('mode', '');
$action = request_var('action', '');
$action = (isset($_POST['add'])) ? 'add' : $action;
$action = (isset($_POST['edit'])) ? 'edit' : $action;
$id = request_var('id', 0);
// What are we working on?
switch ($mode)
{
case 'smilies':
$table = SMILIES_TABLE;
$lang = 'SMILIES';
$fields = 'smiley';
$img_path = $config['smilies_path'];
break;
case 'icons':
$table = ICONS_TABLE;
$lang = 'ICONS';
$fields = 'icons';
$img_path = $config['icons_path'];
break;
}
// Clear some arrays
$_images = $_paks = array();
$notice = '';
// Grab file list of paks and images
if ($action == 'edit' || $action == 'add' || $action == 'import')
{
$imglist = filelist($phpbb_root_path . $img_path, '');
foreach ($imglist as $path => $img_ary)
{
foreach ($img_ary as $img)
{
$img_size = @getimagesize($phpbb_root_path . $img_path . '/' . $path . $img);
$_images[$path.$img]['file'] = $path.$img;
$_images[$path.$img]['width'] = $img_size[0];
$_images[$path.$img]['height'] = $img_size[1];
}
}
unset($imglist);
$dir = @opendir($phpbb_root_path . $img_path);
while ($file = @readdir($dir))
{
if (is_file($phpbb_root_path . $img_path . '/' . $file) && preg_match('#\.pak$#i', $file))
{
$_paks[] = $file;
}
}
@closedir($dir);
}
// What shall we do today? Oops, I believe that's trademarked ...
switch ($action)
{
case 'edit':
unset($_images);
$_images = array();
case 'add':
$order_list = '';
$sql = "SELECT *
FROM $table
ORDER BY {$fields}_order " . (($id || $action == 'add') ? 'DESC' : 'ASC');
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
do
{
if ($action == 'add')
{
unset($_images[$row[$fields . '_url']]);
}
if ($row[$fields . '_id'] == $id)
{
$after = TRUE;
$data[$row[$fields . '_url']] = $row;
}
else
{
if ($action == 'edit' && !$id)
{
$data[$row[$fields . '_url']] = $row;
}
$selected = '';
if (!empty($after))
{
$selected = ' selected="selected"';
$after = FALSE;
}
$after_txt = ($mode == 'smilies') ? $row['code'] : $row['icons_url'];
$order_list = '<option value="' . ($row[$fields . '_order']) . '"' . $selected . '>' . sprintf($user->lang['AFTER_' . $lang], ' -&gt; ' . htmlspecialchars($after_txt)) . '</option>' . $order_list;
}
}
while ($row = $db->sql_fetchrow($result));
}
$db->sql_freeresult($result);
$order_list = '<option value="1"' . ((!isset($after)) ? ' selected="selected"' : '') . '>' . $user->lang['FIRST'] . '</option>' . $order_list;
if ($action == 'add')
{
$data = $_images;
}
$colspan = (($mode == 'smilies') ? '7' : '5');
$colspan += ($id) ? 1 : 0;
$colspan += ($action == 'add') ? 2 : 0;
adm_page_header($user->lang[$lang]);
?>
<h1><?php echo $user->lang[$lang]; ?></h1>
<p><?php echo $user->lang[$lang .'_EXPLAIN']; ?></p>
<form method="post" action="admin_icons.<?php echo $phpEx . $SID . "&amp;mode=$mode&amp;action=" . (($action == 'add') ? 'create' : 'modify'); ?>">
<table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="<?php echo $colspan; ?>"><?php echo $user->lang[$lang . '_CONFIG'] ?></th>
</tr>
<tr>
<td class="cat"><?php echo $user->lang[$lang . '_URL'] ?></td>
<td class="cat"><?php echo $user->lang[$lang . '_LOCATION'] ?></td>
<?php
if ($mode == 'smilies')
{
?>
<td class="cat"><?php echo $user->lang[$lang . '_CODE'] ?></td>
<td class="cat"><?php echo $user->lang[$lang . '_EMOTION'] ?></td>
<?php
}
?>
<td class="cat"><?php echo $user->lang[$lang . '_WIDTH'] ?></td>
<td class="cat"><?php echo $user->lang[$lang . '_HEIGHT'] ?></td>
<td class="cat"><?php echo $user->lang['DISPLAY_ON_POSTING'] ?></td>
<?php
if ($id || $action == 'add')
{
?>
<td class="cat"><?php echo $user->lang[$lang . '_ORDER'] ?></td>
<?php
}
?>
<?php
if ($action == 'add')
{
?>
<td class="cat"><?php echo $user->lang['ADD'] ?></td>
<?php
}
?>
</tr>
<?php
$row = 0;
foreach ($data as $img => $img_row)
{
$row_class = (($row % 2) == 0) ? 'row1' : 'row2';
?>
<tr>
<td align="center" class="<?php echo $row_class; ?>"><img src="<?php echo $phpbb_root_path . $img_path . '/' . $img ?>" border="0" alt="" title="" /><input type="hidden" name="image[<?php echo $img; ?>]" value="1" /></td>
<td valign="top" class="<?php echo $row_class; ?>">[<?php echo $img; ?>]</td>
<?php
if ($mode == 'smilies')
{
?>
<td class="<?php echo $row_class; ?>"><input class="post" type="text" name="code[<?php echo $img; ?>]" value="<?php echo (!empty($img_row['code'])) ? $img_row['code'] : '' ?>" size="10" /></td>
<td class="<?php echo $row_class; ?>"><input class="post" type="text" name="emotion[<?php echo $img; ?>]" value="<?php echo (!empty($img_row['emotion'])) ? $img_row['emotion'] : '' ?>" size="10" /></td>
<?php
}
?>
<td class="<?php echo $row_class; ?>"><input class="post" type="text" size="3" name="width[<?php echo $img; ?>]" value="<?php echo (!empty($img_row[$fields .'_width'])) ? $img_row[$fields .'_width'] : $img_row['width'] ?>" /></td>
<td class="<?php echo $row_class; ?>"><input class="post" type="text" size="3" name="height[<?php echo $img; ?>]" value="<?php echo (!empty($img_row[$fields .'_height'])) ? $img_row[$fields .'_height'] : $img_row['height'] ?>" /></td>
<td class="<?php echo $row_class; ?>"><input type="checkbox" name="display_on_posting[<?php echo $img; ?>]"<?php echo (!empty($img_row['display_on_posting']) || $action == 'add') ? ' checked="checked"' : '' ?> /></td>
<?php
if ($id || $action == 'add')
{
?>
<td class="<?php echo $row_class; ?>"><select name="order[<?php echo $img; ?>]"><?php echo $order_list ?></select></td>
<?php
}
if ($action == 'add')
{
?>
<td class="<?php echo $row_class; ?>"><input type="checkbox" name="add_img[<?php echo $img; ?>]" value="1" /><?php
}
?>
</tr>
<?php
if (isset($img_row[$fields . '_id']))
{
?><input type="hidden" name="id[<?php echo $img; ?>]" value="<?php echo $img_row[$fields . '_id'] ?>" /><?php
}
$row++;
}
?>
<tr>
<td class="cat" colspan="<?php echo $colspan; ?>" align="center"><?php
?><input class="btnmain" type="submit" value="<?php echo $user->lang['SUBMIT'] ?>" /></td>
</tr>
</table></form>
<?php
adm_page_footer();
break;
case 'create':
case 'modify':
// Get items to create/modify
$images = (isset($_POST['image'])) ? array_keys($_POST['image']) : array();
// Now really get the items
$image_id = (isset($_POST['id'])) ? array_map('intval', $_POST['id']) : array();
$image_order = (isset($_POST['order'])) ? array_map('intval', $_POST['order']) : array();
$image_width = (isset($_POST['width'])) ? array_map('intval', $_POST['width']) : array();
$image_height = (isset($_POST['height'])) ? array_map('intval', $_POST['height']) : array();
$image_add = (isset($_POST['add_img'])) ? array_map('intval', $_POST['add_img']) : array();
$image_emotion = request_var('emotion', '');
$image_code = request_var('code', '');
$image_display_on_posting = (isset($_POST['display_on_posting'])) ? array_map('intval', $_POST['display_on_posting']) : array();
foreach ($images as $image)
{
if (($mode == 'smilies' && ($image_emotion[$image] == '' || $image_code[$image] == '')) ||
($action == 'create' && !isset($image_add[$image])))
{
}
else
{
if ($image_width[$image] == 0 || $image_height[$image] == 0)
{
$img_size = @getimagesize($phpbb_root_path . $img_path . '/' . $image);
$image_width[$image] = $img_size[0];
$image_height[$image] = $img_size[1];
}
$img_sql = array(
$fields . '_url' => $image,
$fields . '_width' => $image_width[$image],
$fields . '_height' => $image_height[$image],
'display_on_posting'=> (isset($image_display_on_posting[$image])) ? 1 : 0,
);
if ($mode == 'smilies')
{
$img_sql = array_merge($img_sql, array(
'emotion' => $image_emotion[$image],
'code' => $image_code[$image])
);
}
if (!empty($image_order[$image]))
{
$img_sql = array_merge($img_sql, array(
$fields . '_order' => $image_order[$image] . '.5')
);
}
if ($action == 'modify')
{
$sql = "UPDATE $table
SET " . $db->sql_build_array('UPDATE', $img_sql) . "
WHERE {$fields}_id = " . $image_id[$image];
$db->sql_query($sql);
}
else
{
$sql = "INSERT INTO $table " . $db->sql_build_array('INSERT', $img_sql);
$db->sql_query($sql);
}
$update = FALSE;
if ($action == 'modify' && !empty($image_order[$image]))
{
$update = TRUE;
$result = $db->sql_query("SELECT {$fields}_order
FROM $table
WHERE {$fields}_id = " . $image_id[$image]);
$order_old = $db->sql_fetchfield($fields . '_order', 0, $result);
if ($order_old == $image_order[$image])
{
$update = FALSE;
}
if ($order_old > $image_order[$image])
{
$sign = '+';
$where = $fields . '_order >= ' . $image_order[$image] . " AND {$fields}_order < $order_old";
}
else if ($order_old < $image_order[$image])
{
$sign = '-';
$where = "{$fields}_order > $order_old AND {$fields}_order < " . $image_order[$image];
$sql[$fields . '_order'] = $image_order[$image] - 1;
}
}
if ($update)
{
$sql = "UPDATE $table
SET {$fields}_order = {$fields}_order $sign 1
WHERE $where";
$db->sql_query($sql);
}
}
}
$cache->destroy('icons');
if ($action == 'modify')
{
trigger_error($user->lang[$lang . '_EDITED']);
}
else
{
trigger_error($user->lang[$lang . '_ADDED']);
}
break;
case 'import':
$pak = request_var('pak', '');
$current = request_var('current', '');
if ($pak != '')
{
$order = 0;
// The user has already selected a smilies_pak file
if ($current == 'delete')
{
$db->sql_query("TRUNCATE $table");
switch ($mode)
{
case 'smilies':
break;
case 'icons':
// Reset all icon_ids
$db->sql_query('UPDATE ' . TOPICS_TABLE . '
SET icon_id = 0');
$db->sql_query('UPDATE ' . POSTS_TABLE . '
SET icon_id = 0');
break;
}
}
else
{
$cur_img = array();
$field_sql = ($mode == 'smilies') ? 'code' : 'icons_url';
$result = $db->sql_query("SELECT $field_sql FROM $table");
while ($row = $db->sql_fetchrow($result))
{
++$order;
$cur_img[$row[$field_sql]] = 1;
}
$db->sql_freeresult($result);
}
if (!($pak_ary = @file($phpbb_root_path . $img_path . '/' . $pak)))
{
trigger_error('Could not read pak file', E_USER_ERROR);
}
foreach ($pak_ary as $pak_entry)
{
$data = array();
if (preg_match_all("#'(.*?)', #", $pak_entry, $data))
{
if ((sizeof($data[1]) != 3 && $mode == 'icons') ||
(sizeof($data[1]) != 5 && $mode == 'smilies'))
{
trigger_error($user->lang['WRONG_PAK_TYPE']);
}
$img = stripslashes($data[1][0]);
$width = stripslashes($data[1][1]);
$height = stripslashes($data[1][2]);
if (isset($data[1][3]) && isset($data[1][4]))
{
$emotion = stripslashes($data[1][3]);
$code = htmlentities(stripslashes($data[1][4]));
}
if ($current == 'replace' &&
(($mode == 'smilies' && !empty($cur_img[$code])) ||
($mode == 'icons' && !empty($cur_img[$img]))))
{
$replace_sql = ($mode == 'smilies') ? $code : $img;
$sql = array(
$fields . '_url' => $img,
$fields . '_height' => (int) $height,
$fields . '_width' => (int) $width,
);
if ($mode == 'smilies')
{
$sql = array_merge($sql, array(
'emotion' => $emotion
));
}
$db->sql_query("UPDATE $table SET " . $db->sql_build_array('UPDATE', $sql) . "
WHERE $field_sql = '" . $db->sql_escape($replace_sql) . "'");
}
else
{
++$order;
$sql = array(
$fields . '_url' => $img,
$fields . '_height' => (int) $height,
$fields . '_width' => (int) $width,
$fields . '_order' => (int) $order,
);
if ($mode == 'smilies')
{
$sql = array_merge($sql, array(
'code' => $code,
'emotion' => $emotion
));
}
$db->sql_query("INSERT INTO $table " . $db->sql_build_array('INSERT', $sql));
}
}
}
$cache->destroy('icons');
trigger_error($user->lang[$lang . '_IMPORT_SUCCESS']);
}
else
{
$pak_options = '';
foreach ($_paks as $pak)
{
$pak_options .= '<option value="' . $pak . '">' . htmlspecialchars($pak) . '</option>';
}
adm_page_header($user->lang[$lang]);
?>
<h1><?php echo $user->lang[$lang] ?></h1>
<p><?php echo $user->lang[$lang .'_EXPLAIN'] ?></p>
<form method="post" action="admin_icons.<?php echo $phpEx . $SID . '&amp;mode=' . $mode . '&amp;action=import'; ?>">
<table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang[$lang . '_IMPORT'] ?></th>
</tr>
<?php
if ($pak_options == '')
{
?>
<tr>
<td class="row1" colspan="2"><?php echo $user->lang['NO_' . $lang . '_PAK']; ?></td>
</tr>
<?php
}
else
{
?>
<tr>
<td class="row2"><?php echo $user->lang['SELECT_PACKAGE'] ?></td>
<td class="row1"><select name="pak"><?php echo $pak_options ?></select></td>
</tr>
<tr>
<td class="row2"><?php echo $user->lang['CURRENT_' . $lang] ?><br /><span class="gensmall"><?php echo $user->lang['CURRENT_' . $lang . '_EXPLAIN'] ?></span></td>
<td class="row1"><input type="radio" name="current" value="keep" checked="checked" /> <?php echo $user->lang['KEEP_ALL'] ?>&nbsp; &nbsp;<input type="radio" name="current" value="replace" /> <?php echo $user->lang['REPLACE_MATCHES'] ?>&nbsp; &nbsp;<input type="radio" name="current" value="delete" /> <?php echo $user->lang['DELETE_ALL'] ?>&nbsp;</td>
</tr>
<tr>
<td class="cat" colspan="2" align="center"><input class="btnmain" name="import" type="submit" value="<?php echo $user->lang['IMPORT_' . $lang] ?>" /></td>
</tr>
<?php
}
?>
</table></form>
<?php
adm_page_footer();
}
break;
case 'export':
adm_page_header($user->lang['EXPORT_' . $lang]);
trigger_error(sprintf($user->lang['EXPORT_' . $lang . '_EXPLAIN'], '<a href="admin_icons.' . $phpEx . $SID . '&amp;mode=' . $mode . '&amp;action=send">', '</a>'));
break;
case 'send':
$sql = "SELECT *
FROM $table
ORDER BY {$fields}_order";
$result = $db->sql_query($sql);
$pak = '';
while ($row = $db->sql_fetchrow($result))
{
$pak .= "'" . addslashes($row[$fields . '_url']) . "', ";
$pak .= "'" . addslashes($row[$fields . '_height']) . "', ";
$pak .= "'" . addslashes($row[$fields . '_width']) . "', ";
if ($mode == 'smilies')
{
$pak .= "'" . addslashes($row['emotion']) . "', ";
$pak .= "'" . addslashes($row['code']) . "', ";
}
$pak .= "\n";
}
$db->sql_freeresult($result);
if ($pak != '')
{
$db->sql_close();
header('Content-Type: text/x-delimtext; name="' . $fields . '.pak"');
header('Content-disposition: attachment; filename=' . $fields . '.pak"');
echo $pak;
exit;
}
else
{
trigger_error($user->lang['NO_' . $fields . '_EXPORT']);
}
break;
case 'delete':
$db->sql_query("DELETE FROM $table
WHERE {$fields}_id = $id");
switch ($mode)
{
case 'smilies':
break;
case 'icons':
// Reset appropriate icon_ids
$db->sql_query('UPDATE ' . TOPICS_TABLE . "
SET icon_id = 0
WHERE icon_id = $id");
$db->sql_query('UPDATE ' . POSTS_TABLE . "
SET icon_id = 0
WHERE icon_id = $id");
break;
}
$notice = $user->lang[$lang . '_DELETED'];
case 'move_up':
case 'move_down':
if ($action != 'delete')
{
$image_order = intval($_GET['order']);
$order_total = $image_order * 2 + (($action == 'move_up') ? -1 : 1);
$sql = 'UPDATE ' . $table . '
SET ' . $fields . "_order = $order_total - " . $fields . '_order
WHERE ' . $fields . "_order IN ($image_order, " . (($action == 'move_up') ? $image_order - 1 : $image_order + 1) . ')';
$db->sql_query($sql);
$cache->destroy('icons');
}
// No break; here, display the smilies admin back
default:
// By default, check that image_order is valid and fix it if necessary
$sql = "SELECT {$fields}_id AS order_id, {$fields}_order AS fields_order
FROM $table
ORDER BY {$fields}_order";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
$order = 0;
do
{
++$order;
if ($row['fields_order'] != $order)
{
$db->sql_query("UPDATE $table
SET {$fields}_order = $order
WHERE {$fields}_id = " . $row['order_id']);
}
}
while ($row = $db->sql_fetchrow($result));
}
$db->sql_freeresult($result);
// Output the page
adm_page_header($user->lang[$lang]);
?>
<h1><?php echo $user->lang[$lang]; ?></h1>
<p><?php echo $user->lang[$lang .'_EXPLAIN']; ?></p>
<?php
if ($notice != '')
{
?>
<b style="color:green"><?php echo $notice; ?></b>
<?php
}
?>
<form method="post" action="admin_icons.<?php echo $phpEx . $SID . '&amp;mode=' . $mode ?>">
<table cellspacing="1" cellpadding="0" border="0" align="center">
<tr>
<td align="right"> &nbsp;&nbsp; <a href="admin_icons.<?php echo $phpEx . $SID . '&amp;mode=' . $mode . '&amp;action=import'; ?>"><?php echo $user->lang['IMPORT_' . $lang]; ?></a> | <a href="admin_icons.<?php echo $phpEx . $SID . '&amp;mode=' . $mode . '&amp;action=export'; ?>"><?php echo $user->lang['EXPORT_' . $lang]; ?></a></td>
</tr>
<tr>
<td>
<table class="bg" width="100%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th><?php echo $user->lang[$lang]; ?></th>
<?php
if ($mode == 'smilies')
{
?>
<th><?php echo $user->lang['CODE']; ?></th>
<th><?php echo $user->lang['EMOTION']; ?></th>
<?php
}
?>
<th><?php echo $user->lang['ACTION']; ?></th>
<th><?php echo $user->lang['REORDER']; ?></th>
</tr>
<?php
$spacer = FALSE;
$sql = "SELECT *
FROM $table
ORDER BY display_on_posting DESC, {$fields}_order ASC";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
if (!$spacer && !$row['display_on_posting'])
{
$spacer = TRUE;
?>
<tr>
<td class="row3" colspan="<?php echo ($mode == 'smilies') ? 5 : 3; ?>" align="center"><?php echo $user->lang[$lang . '_NOT_DISPLAYED'] ?></td>
</tr>
<?php
}
$row_class = ($row_class != 'row1') ? 'row1' : 'row2';
$alt_text = ($mode == 'smilies') ? htmlspecialchars($row['code']) : '';
?>
<tr>
<td class="<?php echo $row_class; ?>" align="center"><img src="<?php echo $phpbb_root_path . $img_path . '/' . $row[$fields . '_url']; ?>" width="<?php echo $row[$fields . '_width']; ?>" height="<?php echo $row[$fields . '_height']; ?>" alt="<?php echo $alt_text; ?>" title="<?php echo $alt_text; ?>" /></td>
<?php
if ($mode == 'smilies')
{
?>
<td class="<?php echo $row_class; ?>" align="center"><?php echo htmlspecialchars($row['code']); ?></td>
<td class="<?php echo $row_class; ?>" align="center"><?php echo $row['emotion']; ?></td>
<?php
}
?>
<td class="<?php echo $row_class; ?>" align="center"><a href="<?php echo "admin_icons.$phpEx$SID&amp;mode=$mode&amp;action=edit&amp;id=" . $row[$fields . '_id']; ?>"><?php echo $user->lang['EDIT']; ?></a> | <a href="<?php echo "admin_icons.$phpEx$SID&amp;mode=$mode&amp;action=delete&amp;id=" . $row[$fields . '_id']; ?>"><?php echo $user->lang['DELETE']; ?></a></td>
<td class="<?php echo $row_class; ?>" align="center"><a href="<?php echo "admin_icons.$phpEx$SID&amp;mode=$mode&amp;action=move_up&amp;order=" . $row[$fields . '_order']; ?>"><?php echo $user->lang['MOVE_UP']; ?></a> <br /> <a href="<?php echo "admin_icons.$phpEx$SID&amp;mode=$mode&amp;action=move_down&amp;order=" . $row[$fields . '_order']; ?>"><?php echo $user->lang['MOVE_DOWN']; ?></a></td>
</tr>
<?php
}
$db->sql_freeresult($result);
?>
<tr>
<td class="cat" colspan="<?php echo ($mode == 'smilies') ? 5 : 3; ?>" align="center"><input type="submit" name="add" value="<?php echo $user->lang['ADD_' . $lang]; ?>" class="btnmain" />&nbsp;<input type="submit" name="edit" value="<?php echo $user->lang['EDIT_' . $lang]; ?>" class="btnmain" /></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<?php
adm_page_footer();
break;
}
?>

212
phpBB/adm/admin_jabber.php Normal file
View File

@@ -0,0 +1,212 @@
<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
* @todo Check/enter/update transport info
*/
/**
*/
if (!empty($setmodules))
{
if (!$auth->acl_get('a_server'))
{
return;
}
$module['GENERAL']['IM'] = basename(__FILE__) . $SID;
return;
}
define('IN_PHPBB', 1);
// Include files
$phpbb_root_path = '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/functions_jabber.'.$phpEx);
// Do we have general permissions?
if (!$auth->acl_get('a_server'))
{
trigger_error($user->lang['NO_ADMIN']);
}
// Grab some basic parameters
$submit = (isset($_POST['submit'])) ? true : false;
$jab_enable = request_var('jab_enable', $config['jab_enable']);
$jab_host = request_var('jab_host', $config['jab_host']);
$jab_port = request_var('jab_port', $config['jab_port']);
$jab_username = request_var('jab_username', $config['jab_username']);
$jab_password = request_var('jab_password', $config['jab_password']);
$jab_resource = request_var('jab_resource', $config['jab_resource']);
$jabber = new jabber();
$error = array();
// Setup the basis vars for jabber connection
$jabber->server = $jab_host;
$jabber->port = ($jab_port) ? $jab_port : 5222;
$jabber->username = $jab_username;
$jabber->password = $jab_password;
$jabber->resource = $jab_resource;
// Are changing (or initialising) a new host or username? If so run some checks and
// try to create account if it doesn't exist
if ($jab_enable)
{
if ($jab_host != $config['jab_host'] || $jab_username != $config['jab_username'])
{
if (!$jabber->Connect())
{
trigger_error('Could not connect to Jabber server', E_USER_ERROR);
}
// First we'll try to authorise using this account, if that fails we'll
// try to create it.
if (!($result = $jabber->SendAuth()))
{
if (($result = $jabber->AccountRegistration($config['board_email'], $config['sitename'])) <> 2)
{
$error[] = ($result == 1) ? $user->lang['ERR_JAB_USERNAME'] : sprintf($user->lang['ERR_JAB_REGISTER'], $result);
}
else
{
$message = $user->lang['JAB_REGISTERED'];
$log = 'JAB_REGISTER';
}
}
else
{
$message = $user->lang['JAB_CHANGED'];
$log = 'JAB_CHANGED';
}
sleep(1);
$jabber->Disconnect();
}
else if ($jab_password != $config['jab_password'])
{
if (!$jabber->Connect())
{
trigger_error('Could not connect to Jabber server', E_USER_ERROR);
}
if (!$jabber->SendAuth())
{
trigger_error('Could not authorise on Jabber server', E_USER_ERROR);
}
$jabber->SendPresence(NULL, NULL, 'online');
if (($result = $jabber->ChangePassword($jab_password)) <> 2)
{
$error[] = ($result == 1) ? $user->lang['ERR_JAB_PASSCHG'] : sprintf($user->lang['ERR_JAB_PASSFAIL'], $result);
}
else
{
$message = $user->lang['JAB_PASS_CHANGED'];
$log = 'JAB_PASSCHG';
}
sleep(1);
$jabber->Disconnect();
}
}
// Pull relevant config data
$sql = 'SELECT *
FROM ' . CONFIG_TABLE . "
WHERE config_name LIKE 'jab_%'";
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$config_name = $row['config_name'];
$config_value = $row['config_value'];
$default_config[$config_name] = $config_value;
$new[$config_name] = (isset($_POST[$config_name])) ? request_var($config_name, '') : $default_config[$config_name];
if ($submit && !sizeof($error))
{
set_config($config_name, $new[$config_name]);
}
}
if ($submit && !sizeof($error))
{
add_log('admin', 'LOG_' . $log);
trigger_error($message);
}
// Output the page
adm_page_header($user->lang['IM']);
$jab_enable_yes = ($new['jab_enable']) ? 'checked="checked"' : '';
$jab_enable_no = (!$new['jab_enable']) ? 'checked="checked"' : '';
?>
<h1><?php echo $user->lang['IM']; ?></h1>
<p><?php echo $user->lang['IM_EXPLAIN']; ?></p>
<form method="post" action="<?php echo "admin_jabber.$phpEx$SID"; ?>"><table class="bg" width="95%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang['IM']; ?></th>
</tr>
<?php
if (sizeof($error))
{
?>
<tr>
<td class="row3" colspan="2" align="center"><span style="color:red"><?php echo implode('<br />', $error); ?></td>
</tr>
<?php
}
?>
<tr>
<td class="row1" width="40%"><b><?php echo $user->lang['JAB_ENABLE']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['JAB_ENABLE_EXPLAIN']; ?></span></td>
<td class="row2"><input type="radio" name="jab_enable" value="1"<?php echo $jab_enable_yes; ?> /><?php echo $user->lang['ENABLED']; ?>&nbsp; &nbsp;<input type="radio" name="jab_enable" value="0"<?php echo $jab_enable_no; ?> /><?php echo $user->lang['DISABLED']; ?></td>
</tr>
<tr>
<td class="row1" width="40%"><b><?php echo $user->lang['JAB_SERVER']; ?>: </b><br /><span class="gensmall"><?php echo sprintf($user->lang['JAB_SERVER_EXPLAIN'], '<a href="http://www.jabber.org/user/publicservers.php" target="_blank">', '</a>'); ?></span></td>
<td class="row2"><input class="post" type="text" name="jab_host" value="<?php echo $new['jab_host']; ?>" /></td>
</tr>
<tr>
<td class="row1" width="40%"><b><?php echo $user->lang['JAB_PORT']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['JAB_PORT_EXPLAIN']; ?></span></td>
<td class="row2"><input class="post" type="text" name="jab_port" value="<?php echo $new['jab_port']; ?>" /></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['JAB_USERNAME']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['JAB_USERNAME_EXPLAIN']; ?></span></td>
<td class="row2"><input class="post" type="text" name="jab_username" value="<?php echo $new['jab_username']; ?>" /></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['JAB_PASSWORD']; ?>: </b></td>
<td class="row2"><input class="post" type="text" name="jab_password" value="<?php echo $new['jab_password']; ?>" /></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['JAB_RESOURCE']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['JAB_RESOURCE_EXPLAIN']; ?></span></td>
<td class="row2"><input class="post" type="text" name="jab_resource" value="<?php echo $new['jab_resource']; ?>" /></td>
</tr>
<tr>
<td class="cat" colspan="2" align="center"><input class="btnmain" type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" />&nbsp;&nbsp;<input class="btnlite" type="reset" value="<?php echo $user->lang['RESET']; ?>" /></td>
</tr>
</table></form>
<?php
adm_page_footer();
?>

1039
phpBB/adm/admin_language.php Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,85 @@
<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
if (!empty($setmodules))
{
$module['GENERAL']['PHP_INFO'] = ($auth->acl_get('a_server')) ? basename(__FILE__) . $SID : '';
return;
}
define('IN_PHPBB', 1);
// Load default header
$phpbb_root_path = '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
// Check permissions
if (!$auth->acl_get('a_server'))
{
trigger_error($user->lang['NO_ADMIN']);
}
ob_start();
phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES | INFO_VARIABLES);
$phpinfo = ob_get_contents();
ob_end_clean();
// Get used layout
$layout = (preg_match('#bgcolor#i', $phpinfo)) ? 'old' : 'new';
// Here we play around a little with the PHP Info HTML to try and stylise
// it along phpBB's lines ... hopefully without breaking anything. The idea
// for this was nabbed from the PHP annotated manual
preg_match_all('#<body[^>]*>(.*)</body>#siU', $phpinfo, $output);
switch ($layout)
{
case 'old':
$output = preg_replace('#<table#', '<table class="bg"', $output[1][0]);
$output = preg_replace('# bgcolor="\#(\w){6}"#', '', $output);
$output = preg_replace('#(\w),(\w)#', '\1, \2', $output);
$output = preg_replace('#border="0" cellpadding="3" cellspacing="1" width="600"#', 'border="0" cellspacing="1" cellpadding="4" width="95%"', $output);
$output = preg_replace('#<tr valign="top"><td align="left">(.*?<a .*?</a>)(.*?)</td></tr>#s', '<tr class="row1"><td style="{background-color: #9999cc;}"><table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td style="{background-color: #9999cc;}">\2</td><td style="{background-color: #9999cc;}">\1</td></tr></table></td></tr>', $output);
$output = preg_replace('#<tr valign="baseline"><td[ ]{0,1}><b>(.*?)</b>#', '<tr><td class="row1" nowrap="nowrap">\1', $output);
$output = preg_replace('#<td align="(center|left)">#', '<td class="row2">', $output);
$output = preg_replace('#<td>#', '<td class="row2">', $output);
$output = preg_replace('#valign="middle"#', '', $output);
$output = preg_replace('#<tr >#', '<tr>', $output);
$output = preg_replace('#<hr(.*?)>#', '', $output);
$output = preg_replace('#<h1 align="center">#i', '<h1>', $output);
$output = preg_replace('#<h2 align="center">#i', '<h2>', $output);
break;
case 'new':
$output = preg_replace('#<table#', '<table class="bg" align="center"', $output[1][0]);
$output = preg_replace('#(\w),(\w)#', '\1, \2', $output);
$output = preg_replace('#border="0" cellpadding="3" width="600"#', 'border="0" cellspacing="1" cellpadding="4" width="95%"', $output);
$output = preg_replace('#<tr class="v"><td>(.*?<a .*?</a>)(.*?)</td></tr>#s', '<tr class="row1"><td><table width="100%" cellspacing="0" cellpadding="0" border="0"><tr><td>\2</td><td>\1</td></tr></table></td></tr>', $output);
$output = preg_replace('#<td>#', '<td style="{background-color: #9999cc;}">', $output);
$output = preg_replace('#class="e"#', 'class="row1" nowrap="nowrap"', $output);
$output = preg_replace('#class="v"#', 'class="row2"', $output);
$output = preg_replace('# class="h"#', '', $output);
$output = preg_replace('#<hr />#', '', $output);
preg_match_all('#<div class="center">(.*)</div>#siU', $output, $output);
$output = $output[1][0];
break;
}
adm_page_header($user->lang['PHP_INFO']);
echo '<h1>' . $user->lang['PHP_INFO'] . '</h1>';
echo '<p>' . $user->lang['PHP_INFO_EXPLAIN'] . '</p>';
echo $output;
adm_page_footer();
?>

1335
phpBB/adm/admin_profile.php Normal file

File diff suppressed because it is too large Load Diff

254
phpBB/adm/admin_prune.php Normal file
View File

@@ -0,0 +1,254 @@
<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
if (!empty($setmodules))
{
if (!$auth->acl_get('a_prune'))
{
return;
}
$module['FORUM']['PRUNE'] = basename(__FILE__) . $SID . '&amp;mode=forums';
return;
}
define('IN_PHPBB', 1);
// Include files
$phpbb_root_path = '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
// Do we have permission?
if (!$auth->acl_get('a_prune'))
{
trigger_error($user->lang['NO_ADMIN']);
}
// Get the forum ID for pruning
$forum_id = (isset($_REQUEST['f'])) ? array_map('intval', $_REQUEST['f']) : array();
// Check for submit to be equal to Prune. If so then proceed with the pruning.
if (isset($_POST['submit']))
{
$prune_posted = (isset($_POST['prune_days'])) ? intval($_POST['prune_days']) : 0;
$prune_viewed = (isset($_POST['prune_vieweddays'])) ? intval($_POST['prune_vieweddays']) : 0;
$prune_all = !$prune_posted && !$prune_viewed;
$prune_flags = 0;
$prune_flags += (!empty($_POST['prune_old_polls'])) ? 2 : 0;
$prune_flags += (!empty($_POST['prune_announce'])) ? 4 : 0;
$prune_flags += (!empty($_POST['prune_sticky'])) ? 8 : 0;
// Convert days to seconds for timestamp functions...
$prunedate_posted = time() - ($prune_posted * 86400);
$prunedate_viewed = time() - ($prune_viewed * 86400);
adm_page_header($user->lang['PRUNE']);
?>
<h1><?php echo $user->lang['PRUNE']; ?></h1>
<p><?php echo $user->lang['PRUNE_SUCCESS']; ?></p>
<table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th><?php echo $user->lang['FORUM']; ?></th>
<th><?php echo $user->lang['TOPICS_PRUNED']; ?></th>
<th><?php echo $user->lang['POSTS_PRUNED']; ?></th>
</tr>
<?php
$sql_forum = (sizeof($forum_id)) ? ' AND forum_id IN (' . implode(', ', $forum_id) . ')' : '';
// Get a list of forum's or the data for the forum that we are pruning.
$sql = 'SELECT forum_id, forum_name
FROM ' . FORUMS_TABLE . '
WHERE forum_type = ' . FORUM_POST . "
$sql_forum
ORDER BY left_id ASC";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
$prune_ids = array();
$p_result['topics'] = 0;
$p_result['posts'] = 0;
$log_data = '';
do
{
if ($auth->acl_get('f_list', $row['forum_id']))
{
if ($prune_all)
{
$p_result = prune($row['forum_id'], 'posted', time(), $prune_flags, false);
}
else
{
if ($prune_posted)
{
$return = prune($row['forum_id'], 'posted', $prunedate_posted, $prune_flags, false);
$p_result['topics'] += $return['topics'];
$p_result['posts'] += $return['posts'];
}
if ($prune_viewed)
{
$return = prune($row['forum_id'], 'viewed', $prunedate_viewed, $prune_flags, false);
$p_result['topics'] += $return['topics'];
$p_result['posts'] += $return['posts'];
}
}
$prune_ids[] = $row['forum_id'];
$row_class = ($row_class == 'row1') ? 'row2' : 'row1';
?>
<tr>
<td class="<?php echo $row_class; ?>" align="center"><?php echo $row['forum_name']; ?></td>
<td class="<?php echo $row_class; ?>" align="center"><?php echo $p_result['topics']; ?></td>
<td class="<?php echo $row_class; ?>" align="center"><?php echo $p_result['posts']; ?></td>
</tr>
<?php
$log_data .= (($log_data != '') ? ', ' : '') . $row['forum_name'];
}
}
while ($row = $db->sql_fetchrow($result));
// Sync all pruned forums at once
sync('forum', 'forum_id', $prune_ids, TRUE);
add_log('admin', 'LOG_PRUNE', $log_data);
}
else
{
?>
<tr>
<td class="row1" align="center"><?php echo $user->lang['NO_PRUNE']; ?></td>
</tr>
<?php
}
$db->sql_freeresult($result);
?>
</table>
<br clear="all" />
<?php
adm_page_footer();
}
adm_page_header($user->lang['PRUNE']);
?>
<h1><?php echo $user->lang['PRUNE']; ?></h1>
<p><?php echo $user->lang['FORUM_PRUNE_EXPLAIN']; ?></p>
<?php
// If they haven't selected a forum for pruning yet then
// display a select box to use for pruning.
if (!$forum_id)
{
?>
<form method="post" action="<?php echo "admin_prune.$phpEx$SID"; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th align="center"><?php echo $user->lang['SELECT_FORUM']; ?></th>
</tr>
<tr>
<td class="row1" align="center"><select name="f[]" multiple="true" size="5"><?php echo make_forum_select(false, false, false); ?></select></td>
</tr>
<tr>
<td class="cat" align="center"><input class="btnmain" type="submit" value="<?php echo $user->lang['LOOK_UP_FORUM']; ?>" />&nbsp; <input type="reset" value="<?php echo $user->lang['RESET']; ?>" class="btnlite" /></td>
</tr>
</table></form>
<?php
}
else
{
$sql = 'SELECT forum_id, forum_name
FROM ' . FORUMS_TABLE . '
WHERE forum_id IN (' . implode(', ', $forum_id) . ')';
$result = $db->sql_query($sql);
if (!($row = $db->sql_fetchrow($result)))
{
trigger_error($user->lang['NO_FORUM']);
}
$forum_list = $s_hidden_fields = '';
do
{
$forum_list .= (($forum_list != '') ? ', ' : '') . '<b>' . $row['forum_name'] . '</b>';
$s_hidden_fields .= '<input type="hidden" name="f[]" value="' . $row['forum_id'] . '" />';
}
while ($row = $db->sql_fetchrow($result));
$db->sql_freeresult($result);
$l_selected_forums = (sizeof($forum_id) == 1) ? 'SELECTED_FORUM' : 'SELECTED_FORUMS';
?>
<h2><?php echo $user->lang['FORUM']; ?></h2>
<p><?php echo $user->lang[$l_selected_forums] . ': ' . $forum_list; ?></p>
<form method="post" action="<?php echo "admin_prune.$phpEx$SID"; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang['FORUM_PRUNE']; ?></th>
</tr>
<tr>
<td class="row1"><?php echo $user->lang['PRUNE_NOT_POSTED']; ?></td>
<td class="row2"><input type="text" name="prune_days" size="4" /></td>
</tr>
<tr>
<td class="row1"><?php echo $user->lang['PRUNE_NOT_VIEWED']; ?></td>
<td class="row2"><input type="text" name="prune_vieweddays" size="4" /></td>
</tr>
<tr>
<td class="row1"><?php echo $user->lang['PRUNE_OLD_POLLS'] ?>: <br /><span class="gensmall"><?php echo $user->lang['PRUNE_OLD_POLLS_EXPLAIN']; ?></span></td>
<td class="row2"><input type="radio" name="prune_old_polls" value="1" /> <?php echo $user->lang['YES']; ?> &nbsp; <input type="radio" name="prune_old_polls" value="0" checked="checked" /> <?php echo $user->lang['NO']; ?></td>
</tr>
<tr>
<td class="row1"><?php echo $user->lang['PRUNE_ANNOUNCEMENTS'] ?>: </td>
<td class="row2"><input type="radio" name="prune_announce" value="1" /> <?php echo $user->lang['YES']; ?> &nbsp; <input type="radio" name="prune_announce" value="0" checked="checked" /> <?php echo $user->lang['NO']; ?></td>
</tr>
<tr>
<td class="row1"><?php echo $user->lang['PRUNE_STICKY'] ?>: </td>
<td class="row2"><input type="radio" name="prune_sticky" value="1" /> <?php echo $user->lang['YES']; ?> &nbsp; <input type="radio" name="prune_sticky" value="0" checked="checked" /> <?php echo $user->lang['NO']; ?></td>
</tr>
<tr>
<td class="cat" colspan="2" align="center"><?php echo $s_hidden_fields; ?><input type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" class="btnmain"></td>
</tr>
</table></form>
<?php
}
adm_page_footer();
?>

View File

@@ -0,0 +1,254 @@
<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
if (!empty($setmodules))
{
if (!$auth->acl_get('a_userdel'))
{
return;
}
$module['USER']['PRUNE_USERS'] = basename(__FILE__) . $SID;
return;
}
define('IN_PHPBB', 1);
// Include files
$phpbb_root_path = '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
// Do we have forum admin permissions?
if (!$auth->acl_get('a_userdel'))
{
trigger_error($user->lang['NO_ADMIN']);
}
// Set mode
$mode = (isset($_REQUEST['mode'])) ? htmlspecialchars($_REQUEST['mode']) : '';
// Do prune
if (isset($_POST['prune']))
{
if (empty($_POST['confirm']))
{
$values = array('prune', 'deactivate', 'delete', 'users', 'username', 'email', 'joined_select', 'active_select', 'count_select', 'joined', 'active', 'count', 'deleteposts');
$l_message = '<form method="post" action="admin_prune_users.' . $phpEx . $SID . '">' . $user->lang['Confirm_prune_users'] . '<br /><br /><input class="btnlite" type="submit" name="confirm" value="' . $user->lang['Yes'] . '" />&nbsp;&nbsp;<input class="btnlite" type="submit" name="cancel" value="' . $user->lang['No'] . '" />';
foreach ($values as $field)
{
$l_message .= (!empty($_POST[$field])) ? '<input type="hidden" name="' . $field . '" value="' . urlencode($_POST[$field]) . '" />' : '';
}
$l_message .= '</form>';
adm_page_header($user->lang['Prune_users']);
?>
<h1><?php echo $user->lang['PRUNE_USERS']; ?></h1>
<p><?php echo $user->lang['PRUNE_USERS_EXPLAIN']; ?></p>
<?php
page_message($user->lang['CONFIRM'], $l_message, false);
adm_page_footer();
}
else if (isset($_POST['confirm']))
{
if (!empty($_POST['users']))
{
$users = explode("\n", urldecode($_POST['users']));
$where_sql = '';
foreach ($users as $username)
{
$where_sql .= (($where_sql != '') ? ', ' : '') . '\'' . trim($username) . '\'';
}
$where_sql = " AND username IN ($where_sql)";
}
else
{
$username = (!empty($_POST['username'])) ? urldecode($_POST['username']) : '';
$email = (!empty($_POST['email'])) ? urldecode($_POST['email']) : '';
$joined_select = (!empty($_POST['joined_select'])) ? $_POST['joined_select'] : 'lt';
$active_select = (!empty($_POST['active_select'])) ? $_POST['active_select'] :'lt';
$count_select = (!empty($_POST['count_select'])) ? $_POST['count_select'] : 'eq';
$joined = (!empty($_POST['joined'])) ? explode('-', $_POST['joined']) : array();
$active = (!empty($_POST['active'])) ? explode('-', $_POST['active']) :array();
$count = (!empty($_POST['count'])) ? intval($_POST['count']) : '';
$key_match = array('lt' => '<', 'gt' => '>', 'eq' => '=');
$sort_by_types = array('username', 'user_email', 'user_posts', 'user_regdate', 'user_lastvisit');
$where_sql = '';
$where_sql .= ($username) ? " AND username LIKE '" . str_replace('*', '%', $username) ."'" : '';
$where_sql .= ($email) ? " AND user_email LIKE '" . str_replace('*', '%', $email) ."' " : '';
$where_sql .= ($joined) ? " AND user_regdate " . $key_match[$joined_select] . " " . gmmktime(0, 0, 0, intval($joined[1]), intval($joined[2]), intval($joined[0])) : '';
$where_sql .= ($count) ? " AND user_posts " . $key_match[$count_select] . " $count " : '';
$where_sql .= ($active) ? " AND user_lastvisit " . $key_match[$active_select] . " " . gmmktime(0, 0, 0, $active[1], intval($active[2]), intval($active[0])) : '';
}
$sql = 'SELECT username, user_id FROM ' . USERS_TABLE . '
WHERE user_id <> ' . ANONYMOUS . "
$where_sql";
$result = $db->sql_query($sql);
$where_sql = '';
$user_ids = array();
$usernames = array();
if ($row = $db->sql_fetchrow($result))
{
do
{
$where_sql .= (($where_sql != '') ? ', ' : '') . $row['user_id'];
$user_ids[] = $row['user_id'];
$usernames[] = $row['username'];
}
while ($row = $db->sql_fetchrow($result));
$where_sql = " AND user_id IN ($where_sql)";
}
$db->sql_freeresult($result);
if ($where_sql != '')
{
$sql = '';
if (!empty($_POST['delete']))
{
if (!empty($_POST['deleteposts']))
{
// Call unified post deletion routine?
$l_log = 'LOG_PRUNE_USER_DEL_DEL';
}
else
{
for($i = 0; $i < sizeof($user_ids); $i++)
{
$sql = 'UPDATE ' . POSTS_TABLE . '
SET poster_id = ' . ANONYMOUS . ", post_username = '" . $usernames[$i] . "'
WHERE user_id = " . $userids[$i];
// $db->sql_query($sql);
}
$l_log = 'LOG_PRUNE_USER_DEL_ANON';
}
$sql = 'DELETE FROM ' . USERS_TABLE;
}
else if (!empty($_POST['deactivate']))
{
$sql = 'UPDATE ' . USERS_TABLE . "
SET user_active = 0";
$l_log = 'LOG_PRUNE_USER_DEAC';
}
$sql .= ' WHERE user_id <> ' . ANONYMOUS . "
$where_sql";
// $db->sql_query($sql);
add_log('admin', $l_log, implode(', ', $usernames));
unset($user_ids);
unset($usernames);
}
trigger_error($user->lang['SUCCESS_USER_PRUNE']);
}
}
// Front end
$find_count = array('lt' => $user->lang['LESS_THAN'], 'eq' => $user->lang['EQUAL_TO'], 'gt' => $user->lang['MORE_THAN']);
$s_find_count = '';
foreach ($find_count as $key => $value)
{
$selected = ($key == 'eq') ? ' selected="selected"' : '';
$s_find_count .= '<option value="' . $key . '"' . $selected . '>' . $value . '</option>';
}
$find_time = array('lt' => $user->lang['BEFORE'], 'gt' => $user->lang['AFTER']);
$s_find_join_time = '';
foreach ($find_time as $key => $value)
{
$s_find_join_time .= '<option value="' . $key . '">' . $value . '</option>';
}
$s_find_active_time = '';
foreach ($find_time as $key => $value)
{
$s_find_active_time .= '<option value="' . $key . '">' . $value . '</option>';
}
//
//
//
adm_page_header($user->lang['PRUNE_USERS']);
?>
<h1><?php echo $user->lang['PRUNE_USERS']; ?></h1>
<p><?php echo $user->lang['PRUNE_USERS_EXPLAIN']; ?></p>
<form method="post" name="post" action="<?php echo "admin_prune_users.$phpEx$SID"; ?>"><table class="bg" width="95%" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang['PRUNE_USERS']; ?></th>
</tr>
<tr>
<td class="row1" width="40%"><b><?php echo $user->lang['USERNAME']; ?>: </b></td>
<td class="row2"><input class="post" type="text" name="username" /></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['EMAIL']; ?>: </b></td>
<td class="row2"><input class="post" type="text" name="email" /></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['JOINED']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['Joined_explain']; ?></span></td>
<td class="row2"><select name="joined_select"><?php echo $s_find_join_time; ?></select> <input class="post" type="text" name="joined" maxlength="10" size="10" /></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['LAST_ACTIVE']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['Last_active_explain']; ?></span></td>
<td class="row2"><select name="active_select"><?php echo $s_find_active_time; ?></select> <input class="post" type="text" name="active" maxlength="10" size="10" /></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['POSTS']; ?>: </b></td>
<td class="row2"><select name="count_select"><?php echo $s_find_count; ?></select> <input class="post" type="text" name="count" /></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['PRUNE_USERS']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['SELECT_USERS_EXPLAIN']; ?></span></td>
<td class="row2"><textarea name="users" cols="40" rows="5"></textarea></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['DELETE_USER_POSTS']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['DELETE_USER_POSTS_EXPLAIN']; ?></span></td>
<td class="row2"><input type="radio" name="deleteposts" value="1" /> <?php echo $user->lang['YES']; ?>&nbsp;&nbsp;<input type="radio" name="deleteposts" value="0" checked="checked" /> <?php echo $user->lang['NO']; ?></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['DEACTIVATE_DELETE']; ?>: </b><br /><span class="gensmall"><?php echo $user->lang['DEACTIVATE_DELETE_EXPLAIN']; ?></span></td>
<td class="row2"><input type="radio" name="action" value="delete" /> <?php echo $user->lang['DELETE_USERS']; ?>&nbsp;&nbsp;<input type="radio" name="action" value="deactivate" checked="checked" /> <?php echo $user->lang['DEACTIVATE']; ?></td>
</tr>
<tr>
<td class="cat" colspan="2" align="center"><input class="btnlite" type="submit" name="update" value="<?php echo $user->lang['SUBMIT']; ?>" />&nbsp;&nbsp;<input type="submit" name="usersubmit" value="<?php echo $user->lang['FIND_USERNAME']; ?>" class="btnlite" onClick="window.open('<?php echo "../search.$phpEx$SID&amp;mode=searchuser&amp;field=users"; ?>', '_phpbbsearch', 'HEIGHT=500,resizable=yes,scrollbars=yes,WIDTH=650');return false;" /><input type="hidden" name="prune" value="1" /></td>
</tr>
</table></form>
<?php
adm_page_footer();
?>

324
phpBB/adm/admin_ranks.php Normal file
View File

@@ -0,0 +1,324 @@
<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
if (!empty($setmodules))
{
if (!$auth->acl_get('a_ranks'))
{
return;
}
$module['USER']['RANKS'] = basename(__FILE__) . $SID;
return;
}
define('IN_PHPBB', 1);
// Let's set the root dir for phpBB
$phpbb_root_path = '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
// Do we have permission?
if (!$auth->acl_get('a_ranks'))
{
trigger_error($user->lang['NO_ADMIN']);
}
// Check mode
if (isset($_REQUEST['mode']))
{
$mode = $_REQUEST['mode'];
}
else
{
// These could be entered via a form button
if (isset($_POST['add']))
{
$mode = 'add';
}
else if (isset($_POST['save']))
{
$mode = 'save';
}
else
{
$mode = '';
}
}
$rank_id = (isset($_GET['id'])) ? intval($_GET['id']) : 0;
//
switch ($mode)
{
case 'edit':
case 'add':
$data = $ranks = $existing_imgs = array();
$result = $db->sql_query('SELECT *
FROM ' . RANKS_TABLE . '
ORDER BY rank_special DESC, rank_min DESC');
if ($row = $db->sql_fetchrow($result))
{
do
{
$existing_imgs[] = $row['rank_image'];
if ($mode == 'edit' && $rank_id == $row['rank_id'])
{
$ranks = $row;
}
}
while ($row = $db->sql_fetchrow($result));
}
$db->sql_freeresult($result);
$imglist = filelist($phpbb_root_path . $config['ranks_path'], '');
$edit_img = $filename_list = '';
foreach ($imglist as $path => $img_ary)
{
foreach ($img_ary as $img)
{
$img = substr($path, 1) . (($path != '') ? '/' : '') . $img;
if (!in_array($img, $existing_imgs) || $mode == 'edit')
{
if ($ranks && $img == $ranks['rank_image'])
{
$selected = ' selected="selected"';
$edit_img = $img;
}
else
{
$selected = '';
}
$filename_list .= '<option value="' . htmlspecialchars($img) . '"' . $selected . '>' . $img . '</option>';
}
}
}
$filename_list = '<option value=""' . (($edit_img == '') ? ' selected="selected"' : '') . '>----------</option>' . $filename_list;
unset($existing_imgs);
unset($imglist);
// They want to add a new rank, show the form.
$s_hidden_fields = '<input type="hidden" name="mode" value="save" />';
adm_page_header($user->lang['RANKS']);
?>
<script language="javascript" type="text/javascript" defer="defer">
<!--
function update_image(newimage)
{
document.image.src = (newimage) ? "<?php echo $phpbb_root_path . $config['ranks_path']; ?>/" + newimage : "../images/spacer.gif";
}
function update_image_dimensions()
{
if (document.image.height && document.forms[0].height)
{
document.forms[0].height.value = document.image.height;
document.forms[0].width.value = document.image.width;
}
}
//-->
</script>
<h1><?php echo $user->lang['RANKS']; ?></h1>
<p><?php echo $user->lang['RANKS_EXPLAIN']; ?></p>
<form method="post" action="<?php echo "admin_ranks.$phpEx$SID&amp;id=$rank_id"; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang['RANKS']; ?></th>
</tr>
<tr>
<td class="row1" width="40%"><?php echo $user->lang['RANK_TITLE']; ?>: </td>
<td class="row2"><input class="post" type="text" name="title" size="25" maxlength="40" value="<?php echo $ranks['rank_title']; ?>" /></td>
</tr>
<tr>
<td class="row1" width="40%"><?php echo $user->lang['RANK_IMAGE']; ?>:</td>
<td class="row2"><table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td valign="middle"><select name="rank_image" onchange="update_image(this.options[selectedIndex].value);"><?php echo $filename_list ?></select></td>
<td>&nbsp;&nbsp;</td>
<td valign="middle"><img src="<?php echo ($edit_img) ? $phpbb_root_path . $config['ranks_path'] . '/' . $edit_img : '../images/spacer.gif' ?>" name="image" border="0" alt="" title="" onload="update_image_dimensions()" /></td>
</tr>
</table></td>
</tr>
<tr>
<td class="row1"><?php echo $user->lang['RANK_SPECIAL']; ?>: </td>
<td class="row2"><input type="radio" name="special_rank" value="1"<?php echo ($ranks['rank_special']) ? ' checked="checked"' : ''; ?> /><?php echo $user->lang['YES']; ?> &nbsp;&nbsp;<input type="radio" name="special_rank" value="0"<?php echo (!$ranks['rank_special']) ? ' checked="checked"' : ''; ?> /> <?php echo $user->lang['NO']; ?></td>
</tr>
<tr>
<td class="row1"><?php echo $user->lang['RANK_MINIMUM']; ?>: </td>
<td class="row2"><input class="post" type="text" name="min_posts" size="5" maxlength="10" value="<?php echo ($ranks['rank_special']) ? '' : $ranks['rank_min']; ?>" /></td>
</tr>
<tr>
<td class="cat" colspan="2" align="center"><?php echo $s_hidden_fields; ?><input type="submit" name="submit" value="<?php echo $user->lang['SUBMIT']; ?>" class="btnmain" />&nbsp;&nbsp;<input type="reset" value="<?php echo $user->lang['RESET']; ?>" class="btnlite" /></td>
</tr>
</table></form>
<?php
adm_page_footer();
break;
case 'save':
//
// Ok, they sent us our info, let's update it.
//
$rank_id = (isset($_REQUEST['id'])) ? intval($_REQUEST['id']) : 0;
$rank_title = (isset($_POST['title'])) ? trim($_POST['title']) : '';
$special_rank = (!empty($_POST['special_rank'])) ? 1 : 0;
$min_posts = (isset($_POST['min_posts'])) ? intval($_POST['min_posts']) : -1;
$rank_image = (isset($_POST['rank_image'])) ? trim(htmlspecialchars($_POST['rank_image'])) : '';
if ($special_rank == 1)
{
$min_posts = -1;
}
// The rank image has to be a jpg, gif or png
if ($rank_image != '' && !preg_match('#(\.gif|\.png|\.jpg|\.jpeg)$#i', $rank_image))
{
$rank_image = '';
}
if ($rank_id)
{
$sql = "UPDATE " . RANKS_TABLE . "
SET rank_title = '" . $db->sql_escape($rank_title) . "', rank_special = $special_rank, rank_min = $min_posts, rank_image = '" . $db->sql_escape($rank_image) . "'
WHERE rank_id = $rank_id";
$message = $user->lang['RANK_UPDATED'];
}
else
{
$sql = "INSERT INTO " . RANKS_TABLE . " (rank_title, rank_special, rank_min, rank_image)
VALUES ('" . $db->sql_escape($rank_title) . "', $special_rank, $min_posts, '" . $db->sql_escape($rank_image) . "')";
$message = $user->lang['RANK_ADDED'];
}
$db->sql_query($sql);
$cache->destroy('ranks');
trigger_error($message);
break;
case 'delete':
// Ok, they want to delete their rank
$rank_id = (isset($_REQUEST['id'])) ? intval($_REQUEST['id']) : 0;
if ($rank_id)
{
$sql = "DELETE FROM " . RANKS_TABLE . "
WHERE rank_id = $rank_id";
$db->sql_query($sql);
$sql = "UPDATE " . USERS_TABLE . "
SET user_rank = 0
WHERE user_rank = $rank_id";
$db->sql_query($sql);
$cache->destroy('ranks');
trigger_error($user->lang['RANK_REMOVED']);
}
else
{
trigger_error($user->lang['MUST_SELECT_RANK']);
}
break;
default:
adm_page_header($user->lang['RANKS']);
?>
<h1><?php echo $user->lang['RANKS']; ?></h1>
<p><?php echo $user->lang['RANKS_EXPLAIN']; ?></p>
<form method="post" action="<?php echo "admin_ranks.$phpEx$SID"; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th><?php echo $user->lang['RANK_IMAGE']; ?></th>
<th><?php echo $user->lang['RANK_TITLE']; ?></th>
<th><?php echo $user->lang['RANK_MINIMUM']; ?></th>
<th><?php echo $user->lang['ACTION']; ?></th>
</tr>
<?php
// Show the default page
$sql = "SELECT * FROM " . RANKS_TABLE . "
ORDER BY rank_min ASC, rank_special ASC";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
do
{
$row_class = ($row_class != 'row1') ? 'row1' : 'row2';
?>
<tr>
<td class="<?php echo $row_class; ?>" align="center"><?php
if ($row['rank_image'])
{
?><img src="<?php echo $phpbb_root_path . $config['ranks_path'] . '/' . $row['rank_image']; ?>"" border="0" alt="<?php echo $row['rank_title']; ?>" title="<?php echo $row['rank_title']; ?>" /><?php
}
else
{
echo '-';
}
?></td>
<td class="<?php echo $row_class; ?>" align="center"><?php echo $row['rank_title']; ?></td>
<td class="<?php echo $row_class; ?>" align="center"><?php echo ($row['rank_special']) ? '-' : $row['rank_min']; ?></td>
<td class="<?php echo $row_class; ?>" align="center">&nbsp;<a href="<?php echo "admin_ranks.$phpEx$SID&amp;mode=edit&amp;id=" . $row['rank_id']; ?>"><?php echo $user->lang['EDIT']; ?></a> | <a href="<?php echo "admin_ranks.$phpEx$SID&amp;mode=delete&amp;id=" . $row['rank_id']; ?>"><?php echo $user->lang['DELETE']; ?></a>&nbsp;</td>
</tr>
<?php
}
while ($row = $db->sql_fetchrow($result));
}
?>
<tr>
<td class="cat" colspan="5" align="center"><input type="submit" class="btnmain" name="add" value="<?php echo $user->lang['ADD_RANK']; ?>" /></td>
</tr>
</table></form>
<?php
adm_page_footer();
break;
}
?>

175
phpBB/adm/admin_search.php Normal file
View File

@@ -0,0 +1,175 @@
<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
if (!empty($setmodules))
{
if (!$auth->acl_get('a_search'))
{
return;
}
$module['DB']['SEARCH_INDEX'] = basename(__FILE__) . $SID;
return;
}
define('IN_PHPBB', 1);
// Include files
$phpbb_root_path = '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
include($phpbb_root_path . 'includes/message_parser.'.$phpEx);
// Check permissions
if (!$auth->acl_get('a_search'))
{
trigger_error($user->lang['NO_ADMIN']);
}
// Start indexing
if (isset($_POST['start']) || isset($_GET['batchstart']))
{
$batchsize = 5000; // Process this many posts per batch
$batchcount = request_var('batchcount', 1);
$batchstart = request_var('batchstart', 0);
$loopcount = 0;
$fulltext = new fulltext_search();
// Search re-indexing is tough on the server ... so we'll check the load
// each loop and if we're on a 1min load of 3 or more we'll re-load the page
// and try again. No idea how well this will work in practice so we'll see ...
if (file_exists('/proc/loadavg'))
{
if ($load = @file('/proc/loadavg'))
{
list($load) = explode(' ', $load[0]);
if ($load > 3)
{
redirect("adm/admin_search.$phpEx$SID&batchstart=$batchstart&batchcount=$batchcount", 3);
}
}
}
if (!$batchstart)
{
// Take board offline
set_config('board_disable', 1);
// Empty existing tables
$db->sql_query("TRUNCATE " . SEARCH_TABLE);
$db->sql_query("TRUNCATE " . SEARCH_WORD_TABLE);
$db->sql_query("TRUNCATE " . SEARCH_MATCH_TABLE);
}
// Fetch a batch of posts_text entries
$sql = "SELECT COUNT(*) AS total, MAX(post_id) AS max_post_id, MIN(post_id) AS min_post_id
FROM " . POSTS_TABLE;
$result = $db->sql_query($sql);
$row = $db->sql_fetchrow($result);
$totalposts = $row['total'];
$max_post_id = $row['max_post_id'];
$batchstart = (!$batchstart) ? $row['min_post_id'] : $batchstart;
$batchend = $batchstart + $batchsize;
$db->sql_freeresult($result);
$sql = "SELECT *
FROM " . POSTS_TABLE . "
WHERE post_id
BETWEEN $batchstart
AND $batchend";
$result = $db->sql_query($sql);
if ($row = $db->sql_fetchrow($result))
{
do
{
$fulltext->add('admin', $row['post_id'], $row['post_text'], $row['post_subject']);
}
while ($row = $db->sql_fetchrow($result));
}
$db->sql_freeresult($result);
$batchcount++;
if (($batchstart + $batchsize) < $max_post_id)
{
redirect("adm/admin_search.$phpEx$SID&batchstart=" . ($batchstart + $batchsize) . "&batchcount=$batchcount", 3);
}
else
{
set_config('board_disable', 0);
// search tidy
$fulltext->search_tidy();
adm_page_header($user->lang['SEARCH_INDEX']);
?>
<h1><?php echo $user->lang['SEARCH_INDEX']; ?></h1>
<p><?php echo $user->lang['SEARCH_INDEX_COMPLETE']; ?></p>
<?php
adm_page_footer();
}
exit;
}
else if (isset($_POST['cancel']))
{
set_config('board_disable', 0);
adm_page_header($user->lang['SEARCH_INDEX']);
?>
<h1><?php echo $user->lang['SEARCH_INDEX']; ?></h1>
<p><?php echo $user->lang['SEARCH_INDEX_CANCEL']; ?></p>
<?php
adm_page_footer();
}
else
{
adm_page_header($user->lang['SEARCH_INDEX']);
?>
<h1><?php echo $user->lang['SEARCH_INDEX']; ?></h1>
<p><?php echo $user->lang['SEARCH_INDEX_EXPLAIN']; ?></p>
<form method="post" action="<?php echo "admin_search.$phpEx$SID"; ?>"><table cellspacing="1" cellpadding="4" border="0" align="center" bgcolor="#98AAB1">
<tr>
<td class="cat" height="28" align="center">&nbsp;<input type="submit" name="start" value="<?php echo $user->lang['START']; ?>" class="btnmain" /> &nbsp; <input type="submit" name="cancel" value="<?php echo $user->lang['CANCEL']; ?>" class="btnmain" />&nbsp;</td>
</tr>
</table></form>
<?php
adm_page_footer();
}
?>

3377
phpBB/adm/admin_styles.php Normal file

File diff suppressed because it is too large Load Diff

2032
phpBB/adm/admin_users.php Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,253 @@
<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
if (!empty($setmodules))
{
if (!$auth->acl_get('a_'))
{
return;
}
$filename = basename(__FILE__);
$module['LOG']['ADMIN_LOGS'] = $filename . "$SID&amp;mode=admin";
$module['LOG']['MOD_LOGS'] = $filename . "$SID&amp;mode=mod";
$module['LOG']['CRITICAL_LOGS'] = $filename . "$SID&amp;mode=critical";
return;
}
define('IN_PHPBB', 1);
// Include files
$phpbb_root_path = '../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
// Do we have styles admin permissions?
if (!$auth->acl_get('a_'))
{
trigger_error($user->lang['NO_ADMIN']);
}
// Set some variables
$mode = request_var('mode', 'admin');
$forum_id = request_var('f', 0);
$start = request_var('start', 0);
$deletemark = (isset($_POST['delmarked'])) ? true : false;
$deleteall = (isset($_POST['delall'])) ? true : false;
$marked = request_var('mark', array(0));
// Sort keys
$sort_days = request_var('st', 0);
$sort_key = request_var('sk', 't');
$sort_dir = request_var('sd', 'd');
// Define some vars depending on which logs we're looking at
$log_type = ($mode == 'admin') ? LOG_ADMIN : (($mode == 'mod') ? LOG_MOD : LOG_CRITICAL);
$user->add_lang('mcp');
// Delete entries if requested and able
if (($deletemark || $deleteall) && $auth->acl_get('a_clearlogs'))
{
$where_sql = '';
if ($deletemark && $marked)
{
$sql_in = array();
foreach ($marked as $mark)
{
$sql_in[] = $mark;
}
$where_sql = ' AND log_id IN (' . implode(', ', $sql_in) . ')';
unset($sql_in);
}
$sql = 'DELETE FROM ' . LOG_TABLE . "
WHERE log_type = $log_type
$where_sql";
$db->sql_query($sql);
add_log('admin', 'LOG_' . strtoupper($mode) . '_CLEAR');
}
// Sorting
$limit_days = array(0 => $user->lang['ALL_ENTRIES'], 1 => $user->lang['1_DAY'], 7 => $user->lang['7_DAYS'], 14 => $user->lang['2_WEEKS'], 30 => $user->lang['1_MONTH'], 90 => $user->lang['3_MONTHS'], 180 => $user->lang['6_MONTHS'], 364 => $user->lang['1_YEAR']);
$sort_by_text = array('u' => $user->lang['SORT_USERNAME'], 't' => $user->lang['SORT_DATE'], 'i' => $user->lang['SORT_IP'], 'o' => $user->lang['SORT_ACTION']);
$sort_by_sql = array('u' => 'l.user_id', 't' => 'l.log_time', 'i' => 'l.log_ip', 'o' => 'l.log_operation');
$s_limit_days = $s_sort_key = $s_sort_dir = $u_sort_param = '';
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);
// Define where and sort sql for use in displaying logs
$sql_where = ($sort_days) ? (time() - ($sort_days * 86400)) : 0;
$sql_sort = $sort_by_sql[$sort_key] . ' ' . (($sort_dir == 'd') ? 'DESC' : 'ASC');
$l_title = $user->lang[strtoupper($mode) . '_LOGS'];
$l_title_explain = $user->lang[strtoupper($mode) . '_LOGS_EXPLAIN'];
// Output page
adm_page_header($l_title);
?>
<h1><?php echo $l_title; ?></h1>
<p><?php echo $l_title_explain; ?></p>
<form name="list" method="post" action="<?php echo "admin_viewlogs.$phpEx$SID&amp;mode=$mode"; ?>">
<?php
// Define forum list if we're looking @ mod logs
if ($mode == 'mod')
{
$forum_box = '<option value="0">' . $user->lang['ALL_FORUMS'] . '</option>' . make_forum_select($forum_id);
?>
<table width="100%" cellpadding="1" cellspacing="1" border="0">
<tr>
<td align="right"><?php echo $user->lang['SELECT_FORUM']; ?>: <select name="f" onchange="if(this.options[this.selectedIndex].value != -1){ this.form.submit() }"><?php echo $forum_box; ?></select> <input class="btnlite" type="submit" value="<?php echo $user->lang['GO']; ?>" /></td>
</tr>
</table>
<?php
}
//
// Grab log data
//
$log_data = array();
$log_count = 0;
view_log($mode, $log_data, $log_count, $config['topics_per_page'], $start, $forum_id, 0, 0, $sql_where, $sql_sort);
?>
<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
<tr>
<td align="left" valign="top">&nbsp;<span class="nav"><?php echo on_page($log_count, $config['topics_per_page'], $start); ?></span></td>
<td align="right" valign="top" nowrap="nowrap">
<span class="nav"><?php echo generate_pagination("admin_viewlogs.$phpEx$SID&amp;mode=$mode&amp;$u_sort_param", $log_count, $config['topics_per_page'], $start, true); ?></span>
</td>
</tr>
</table>
<table class="bg" width="100%" cellpadding="4" cellspacing="1" border="0">
<tr>
<td class="cat" colspan="5" height="28" align="center"><?php echo $user->lang['DISPLAY_LOG']; ?>: &nbsp;<?php echo $s_limit_days; ?>&nbsp;<?php echo $user->lang['SORT_BY']; ?>: <?php echo $s_sort_key; ?> <?php echo $s_sort_dir; ?>&nbsp;<input class="btnlite" type="submit" value="<?php echo $user->lang['GO']; ?>" name="sort" /></td>
</tr>
<tr>
<th width="15%" height="25" nowrap="nowrap"><?php echo $user->lang['USERNAME']; ?></th>
<th width="15%" nowrap="nowrap"><?php echo $user->lang['IP']; ?></th>
<th width="20%" nowrap="nowrap"><?php echo $user->lang['TIME']; ?></th>
<th width="45%" nowrap="nowrap"><?php echo $user->lang['ACTION']; ?></th>
<th nowrap="nowrap"><?php echo $user->lang['MARK']; ?></th>
</tr>
<?php
$row_class = '';
if ($log_count)
{
for ($i = 0; $i < sizeof($log_data); $i++)
{
$row_class = ($row_class == 'row1') ? 'row2' : 'row1';
?>
<tr>
<td class="<?php echo $row_class; ?>" nowrap="nowrap"><?php echo $log_data[$i]['username']; ?></td>
<td class="<?php echo $row_class; ?>" align="center" nowrap="nowrap"><?php echo $log_data[$i]['ip']; ?></td>
<td class="<?php echo $row_class; ?>" align="center" nowrap="nowrap"><?php echo $user->format_date($log_data[$i]['time']); ?></td>
<td class="<?php echo $row_class; ?>"><?php
echo $log_data[$i]['action'];
$data = array();
foreach (array('viewtopic', 'viewlogs', 'viewforum') as $check)
{
if (isset($log_data[$i][$check]) && $log_data[$i][$check])
{
$data[] = '<a href="' . $log_data[$i][$check] . '">' . $user->lang['LOGVIEW_' . strtoupper($check)] . '</a>';
}
}
if (sizeof($data))
{
echo '<br />&#187; <span class="gensmall">[ ' . implode(' | ', $data) . ' ]</span>';
}
?>
</td>
<td class="<?php echo $row_class; ?>" align="center" nowrap="nowrap"><input type="checkbox" name="mark[]" value="<?php echo $log_data[$i]['id']; ?>" /></td>
</tr>
<?php
}
if ($auth->acl_get('a_clearlogs'))
{
?>
<tr>
<td class="cat" colspan="5" height="28" align="right"><input class="btnlite" type="submit" name="delmarked" value="<?php echo $user->lang['DELETE_MARKED']; ?>" />&nbsp; <input class="btnlite" type="submit" name="delall" value="<?php echo $user->lang['DELETE_ALL']; ?>" />&nbsp;</td>
</tr>
<?php
}
}
else
{
?>
<tr>
<td class="row1" colspan="5" align="center" nowrap="nowrap"><?php echo $user->lang['NO_ENTRIES']; ?></td>
</tr>
<?php
}
?>
</table>
<table width="100%" cellspacing="2" cellpadding="2" border="0" align="center">
<tr>
<td align="left" valign="top">&nbsp;<span class="nav"><?php echo on_page($log_count, $config['topics_per_page'], $start); ?></span></td>
<td align="right" valign="top" nowrap="nowrap"><span class="nav"><?php
if ($auth->acl_get('a_clearlogs'))
{
?><b><a href="javascript:marklist('list', true);"><?php echo $user->lang['MARK_ALL']; ?></a> :: <a href="javascript:marklist('list', false);"><?php echo $user->lang['UNMARK_ALL']; ?></a></b>&nbsp;<br /><br /><?php
}
echo generate_pagination("admin_viewlogs.$phpEx$SID&amp;mode=$mode&amp;$u_sort_param", $log_count, $config['topics_per_page'], $start, true);
?></span></td>
</tr>
</table></form>
<script language="Javascript" type="text/javascript">
<!--
function marklist(match, status)
{
len = eval('document.' + match + '.length');
for (i = 0; i < len; i++)
{
eval('document.' + match + '.elements[i].checked = ' + status);
}
}
//-->
</script>
<?php
adm_page_footer();
?>

200
phpBB/adm/admin_words.php Normal file
View File

@@ -0,0 +1,200 @@
<?php
/**
*
* @package acp
* @version $Id$
* @copyright (c) 2005 phpBB Group
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/**
*/
if (!empty($setmodules))
{
if (!$auth->acl_get('a_words'))
{
return;
}
$module['POST']['WORD_CENSOR'] = basename(__FILE__) . $SID;
return;
}
define('IN_PHPBB', 1);
// Include files
$phpbb_root_path = './../';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
require('pagestart.' . $phpEx);
// Do we have forum admin permissions?
if (!$auth->acl_get('a_words'))
{
trigger_error($user->lang['NO_ADMIN']);
}
$mode = request_var('mode', '');
$mode = (isset($_POST['add'])) ? 'add' : ((isset($_POST['save'])) ? 'save' : $mode);
$s_hidden_fields = '';
$word_info = array();
switch ($mode)
{
case 'edit':
$word_id = request_var('id', 0);
if (!$word_id)
{
trigger_error($user->lang['NO_WORD']);
}
$sql = 'SELECT *
FROM ' . WORDS_TABLE . "
WHERE word_id = $word_id";
$result = $db->sql_query_limit($sql, 1);
$word_info = $db->sql_fetchrow($result);
$db->sql_freeresult($result);
$s_hidden_fields .= '<input type="hidden" name="id" value="' . $word_id . '" />';
case 'add':
adm_page_header($user->lang['WORDS_TITLE']);
?>
<h1><?php echo $user->lang['WORDS_TITLE']; ?></h1>
<p><?php echo $user->lang['WORDS_EXPLAIN']; ?></p>
<form method="post" action="<?php echo "admin_words.$phpEx$SID"; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th colspan="2"><?php echo $user->lang['EDIT_WORD']; ?></th>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['WORD']; ?>: </b></td>
<td class="row2"><input class="post" type="text" name="word" value="<?php echo $word_info['word']; ?>" /></td>
</tr>
<tr>
<td class="row1"><b><?php echo $user->lang['REPLACEMENT']; ?>: </b></td>
<td class="row2"><input class="post" type="text" name="replacement" value="<?php echo $word_info['replacement']; ?>" /></td>
</tr>
<tr>
<td class="cat" colspan="2" align="center"><?php echo $s_hidden_fields; ?><input class="btnmain" type="submit" name="save" value="<?php echo $user->lang['SUBMIT']; ?>" /></td>
</tr>
</table></form>
<?php
adm_page_footer();
break;
case 'save':
$word_id = request_var('id', 0);
$word = request_var('word', '');
$replacement = request_var('replacement', '');
if (!$word || !$replacement)
{
trigger_error($user->lang['ENTER_WORD']);
}
$sql = ($word_id) ? "UPDATE " . WORDS_TABLE . " SET word = '" . $db->sql_escape($word) . "', replacement = '" . $db->sql_escape($replacement) . "' WHERE word_id = $word_id" : "INSERT INTO " . WORDS_TABLE . " (word, replacement) VALUES ('" . $db->sql_escape($word) . "', '" . $db->sql_escape($replacement) . "')";
$db->sql_query($sql);
$cache->destroy('word_censors');
$log_action = ($word_id) ? 'LOG_EDIT_WORD' : 'LOG_ADD_WORD';
add_log('admin', $log_action, $word);
$message = ($word_id) ? $user->lang['WORD_UPDATED'] : $user->lang['WORD_ADDED'];
trigger_error($message);
break;
case 'delete':
$word_id = request_var('id', 0);
if (!$word_id)
{
trigger_error($user->lang['NO_WORD']);
}
$sql = 'SELECT word
FROM ' . WORDS_TABLE . "
WHERE word_id = $word_id";
$result = $db->sql_query($sql);
$deleted_word = $db->sql_fetchfield('word', 0, $result);
$db->sql_freeresult($result);
$sql = 'DELETE FROM ' . WORDS_TABLE . "
WHERE word_id = $word_id";
$db->sql_query($sql);
$cache->destroy('word_censors');
add_log('admin', 'LOG_DELETE_WORD', $deleted_word);
$message = $user->lang['WORD_REMOVE'];
trigger_error($message);
break;
default:
adm_page_header($user->lang['WORDS_TITLE']);
?>
<h1><?php echo $user->lang['WORDS_TITLE']; ?></h1>
<p><?php echo $user->lang['WORDS_EXPLAIN']; ?></p>
<form method="post" action="admin_words.<?php echo $phpEx . $SID; ?>"><table class="bg" cellspacing="1" cellpadding="4" border="0" align="center">
<tr>
<th><?php echo $user->lang['WORD']; ?></th>
<th><?php echo $user->lang['REPLACEMENT']; ?></th>
<th colspan="2"><?php echo $user->lang['ACTION']; ?></th>
</tr>
<?php
$sql = 'SELECT *
FROM ' . WORDS_TABLE . '
ORDER BY word';
$result = $db->sql_query($sql);
$row_class = '';
if ($row = $db->sql_fetchrow($result))
{
do
{
$row_class = ($row_class == 'row1') ? 'row2' : 'row1';
?>
<tr>
<td class="<?php echo $row_class; ?>" align="center"><?php echo $row['word']; ?></td>
<td class="<?php echo $row_class; ?>" align="center"><?php echo $row['replacement']; ?></td>
<td class="<?php echo $row_class; ?>">&nbsp;<a href="<?php echo "admin_words.$phpEx$SID&amp;mode=edit&amp;id=" . $row['word_id']; ?>"><?php echo $user->lang['EDIT']; ?></a>&nbsp;</td>
<td class="<?php echo $row_class; ?>">&nbsp;<a href="<?php echo "admin_words.$phpEx$SID&amp;mode=delete&amp;id=" . $row['word_id']; ?>"><?php echo $user->lang['DELETE']; ?></a>&nbsp;</td>
</tr>
<?php
}
while ($row = $db->sql_fetchrow($result));
}
$db->sql_freeresult($result);
?>
<tr>
<td class="cat" colspan="5" height="28" align="center"><?php echo $s_hidden_fields; ?><input class="btnmain" type="submit" name="add" value="<?php echo $user->lang['ADD_WORD']; ?>" /></td>
</tr>
</table></form>
<?php
adm_page_footer();
break;
}
?>

306
phpBB/adm/editor.js Normal file
View File

@@ -0,0 +1,306 @@
// bbCode control by subBlue design [ www.subBlue.com ]
// Includes unixsafe colour palette selector by SHS`
// Startup variables
var imageTag = false;
var theSelection = false;
// Check for Browser & Platform for PC & IE specific bits
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
var clientVer = parseInt(navigator.appVersion); // Get browser version
var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
&& (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
&& (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
var is_mac = (clientPC.indexOf("mac")!=-1);
// Shows the help messages in the helpline window
function helpline(help) {
document.forms[form_name].helpbox.value = eval(help + "_help");
}
// Replacement for arrayname.length property
function getarraysize(thearray) {
for (i = 0; i < thearray.length; i++) {
if ((thearray[i] == "undefined") || (thearray[i] == "") || (thearray[i] == null))
return i;
}
return thearray.length;
}
// Replacement for arrayname.push(value) not implemented in IE until version 5.5
// Appends element to the array
function arraypush(thearray,value) {
thearray[ getarraysize(thearray) ] = value;
}
// Replacement for arrayname.pop() not implemented in IE until version 5.5
// Removes and returns the last element of an array
function arraypop(thearray) {
thearraysize = getarraysize(thearray);
retval = thearray[thearraysize - 1];
delete thearray[thearraysize - 1];
return retval;
}
function smiley(text) {
text = ' ' + text + ' ';
if (document.forms[form_name].elements[text_name].createTextRange && document.forms[form_name].elements[text_name].caretPos) {
var caretPos = document.forms[form_name].elements[text_name].caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
document.forms[form_name].elements[text_name].focus();
} else {
var selStart = document.forms[form_name].elements[text_name].selectionStart;
var selEnd = document.forms[form_name].elements[text_name].selectionEnd;
mozWrap(document.forms[form_name].elements[text_name], text, '')
document.forms[form_name].elements[text_name].focus();
document.forms[form_name].elements[text_name].selectionStart = selStart + text.length;
document.forms[form_name].elements[text_name].selectionEnd = selEnd + text.length;
}
}
function bbfontstyle(bbopen, bbclose) {
if ((clientVer >= 4) && is_ie && is_win) {
theSelection = document.selection.createRange().text;
if (!theSelection) {
insert_text(bbopen + bbclose);
document.forms[form_name].elements[text_name].focus();
return;
}
document.selection.createRange().text = bbopen + theSelection + bbclose;
document.forms[form_name].elements[text_name].focus();
return;
} else {
insert_text(bbopen + bbclose);
document.forms[form_name].elements[text_name].focus();
return;
}
storeCaret(document.forms[form_name].elements[text_name]);
}
function insert_text(text) {
if (document.forms[form_name].elements[text_name].createTextRange && document.forms[form_name].elements[text_name].caretPos) {
var caretPos = document.forms[form_name].elements[text_name].caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : caretPos.text + text;
} else {
var selStart = document.forms[form_name].elements[text_name].selectionStart;
var selEnd = document.forms[form_name].elements[text_name].selectionEnd;
mozWrap(document.forms[form_name].elements[text_name], text, '')
document.forms[form_name].elements[text_name].selectionStart = selStart + text.length;
document.forms[form_name].elements[text_name].selectionEnd = selEnd + text.length;
}
}
function attach_inline() {
insert_text('[attachment=' + document.forms[form_name].elements['attachments'].value + ']' + document.forms[form_name].elements['attachments'].options[document.forms[form_name].elements['attachments'].selectedIndex].text + '[/attachment]');
}
function bbstyle(bbnumber) {
donotinsert = false;
theSelection = false;
bblast = 0;
document.forms[form_name].elements[text_name].focus();
if (bbnumber == -1) { // Close all open tags & default button names
while (bbcode[0]) {
butnumber = arraypop(bbcode) - 1;
document.forms[form_name].elements[text_name].value += bbtags[butnumber + 1];
buttext = eval('document.forms[form_name].addbbcode' + butnumber + '.value');
if (buttext != "[*]")
{
eval('document.forms[form_name].addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
}
}
document.forms[form_name].addbbcode10.value = "List";
bbtags[10] = "[list]";
document.forms[form_name].addbbcode12.value = "List=";
bbtags[12] = "[list=]";
imageTag = false; // All tags are closed including image tags :D
document.forms[form_name].elements[text_name].focus();
return;
}
if ((clientVer >= 4) && is_ie && is_win)
{
theSelection = document.selection.createRange().text; // Get text selection
if (theSelection) {
// Add tags around selection
document.selection.createRange().text = bbtags[bbnumber] + theSelection + bbtags[bbnumber+1];
document.forms[form_name].elements[text_name].focus();
theSelection = '';
return;
}
}
else if (document.forms[form_name].elements[text_name].selectionEnd && (document.forms[form_name].elements[text_name].selectionEnd - document.forms[form_name].elements[text_name].selectionStart > 0))
{
mozWrap(document.forms[form_name].elements[text_name], bbtags[bbnumber], bbtags[bbnumber+1]);
document.forms[form_name].elements[text_name].focus();
theSelection = '';
return;
}
// Find last occurance of an open tag the same as the one just clicked
for (i = 0; i < bbcode.length; i++) {
if (bbcode[i] == bbnumber+1) {
bblast = i;
donotinsert = true;
}
}
if ((bbnumber == 10) && (bbtags[10] != "[*]"))
{
if (donotinsert)
{
document.forms[form_name].addbbcode12.value = "List=";
tmp_help = o_help;
o_help = e_help;
e_help = tmp_help;
bbtags[12] = "[list=]";
}
else
{
document.forms[form_name].addbbcode12.value = "[*]";
tmp_help = o_help;
o_help = e_help;
e_help = tmp_help;
bbtags[12] = "[*]";
}
}
if ((bbnumber == 12) && (bbtags[12] != "[*]"))
{
if (donotinsert)
{
document.forms[form_name].addbbcode10.value = "List";
tmp_help = l_help;
l_help = e_help;
e_help = tmp_help;
bbtags[10] = "[list]";
}
else
{
document.forms[form_name].addbbcode10.value = "[*]";
tmp_help = l_help;
l_help = e_help;
e_help = tmp_help;
bbtags[10] = "[*]";
}
}
if (donotinsert) { // Close all open tags up to the one just clicked & default button names
while (bbcode[bblast]) {
butnumber = arraypop(bbcode) - 1;
if (bbtags[butnumber] != "[*]")
{
insert_text(bbtags[butnumber + 1]);
}
else
{
insert_text(bbtags[butnumber]);
}
buttext = eval('document.forms[form_name].addbbcode' + butnumber + '.value');
if (bbtags[butnumber] != "[*]")
{
eval('document.forms[form_name].addbbcode' + butnumber + '.value ="' + buttext.substr(0,(buttext.length - 1)) + '"');
}
imageTag = false;
}
document.forms[form_name].elements[text_name].focus();
return;
} else { // Open tags
if (imageTag && (bbnumber != 14)) { // Close image tag before adding another
insert_text(bbtags[15]);
lastValue = arraypop(bbcode) - 1; // Remove the close image tag from the list
document.forms[form_name].addbbcode14.value = "Img"; // Return button back to normal state
imageTag = false;
}
// Open tag
insert_text(bbtags[bbnumber]);
if ((bbnumber == 14) && (imageTag == false)) imageTag = 1; // Check to stop additional tags after an unclosed image tag
if (bbtags[bbnumber] != "[*]")
{
arraypush(bbcode,bbnumber+1);
eval('document.forms[form_name].addbbcode'+bbnumber+'.value += "*"');
}
document.forms[form_name].elements[text_name].focus();
return;
}
storeCaret(document.forms[form_name].elements[text_name]);
}
// From http://www.massless.org/mozedit/
function mozWrap(txtarea, open, close)
{
var selLength = txtarea.textLength;
var selStart = txtarea.selectionStart;
var selEnd = txtarea.selectionEnd;
if (selEnd == 1 || selEnd == 2)
selEnd = selLength;
var s1 = (txtarea.value).substring(0,selStart);
var s2 = (txtarea.value).substring(selStart, selEnd)
var s3 = (txtarea.value).substring(selEnd, selLength);
txtarea.value = s1 + open + s2 + close + s3;
return;
}
// Insert at Claret position. Code from
// http://www.faqts.com/knowledge_base/view.phtml/aid/1052/fid/130
function storeCaret(textEl) {
if (textEl.createTextRange) { textEl.caretPos = document.selection.createRange().duplicate(); }
}
function colorPalette(dir, width, height)
{
var r = 0, g = 0, b = 0;
var numberList = new Array(6);
numberList[0] = "00";
numberList[1] = "40";
numberList[2] = "80";
numberList[3] = "BF";
numberList[4] = "FF";
document.writeln('<table cellspacing="1" cellpadding="0" border="0">');
for(r = 0; r < 5; r++)
{
if (dir == 'h')
{
document.writeln('<tr>');
}
for(g = 0; g < 5; g++)
{
if (dir == 'v')
{
document.writeln('<tr>');
}
for(b = 0; b < 5; b++)
{
color = String(numberList[r]) + String(numberList[g]) + String(numberList[b]);
document.write('<td bgcolor="#' + color + '">');
document.write('<a href="javascript:bbfontstyle(\'[color=#' + color + ']\', \'[/color]\');" onmouseover="helpline(\'s\');"><img src="images/spacer.gif" width="' + width + '" height="' + height + '" border="0" alt="#' + color + '" title="#' + color + '" /></a>');
document.writeln('</td>');
}
if (dir == 'v')
{
document.writeln('</tr>');
}
}
if (dir == 'h')
{
document.writeln('</tr>');
}
}
document.writeln('</table>');
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 51 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 48 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 416 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 420 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 344 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 357 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 570 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 357 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 B

View File

Before

Width:  |  Height:  |  Size: 385 B

After

Width:  |  Height:  |  Size: 385 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 239 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 662 B

After

Width:  |  Height:  |  Size: 677 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 708 B

After

Width:  |  Height:  |  Size: 714 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 681 B

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 725 B

After

Width:  |  Height:  |  Size: 705 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 307 B

Some files were not shown because too many files have changed in this diff Show More