From: Grant Slater Date: Tue, 2 Aug 2022 20:42:54 +0000 (+0300) Subject: Merge remote-tracking branch 'tigerfell/pr257' X-Git-Url: https://git.openstreetmap.org/chef.git/commitdiff_plain/2bfb0ef07fb64314f5c4ded641a8c280df9c1d0b?hp=2f0b6f10a1269e4a0a3ae8897d6fda10dd14fb4d Merge remote-tracking branch 'tigerfell/pr257' --- diff --git a/.github/workflows/cookstyle.yml b/.github/workflows/cookstyle.yml index 56603f598..62d14b8af 100644 --- a/.github/workflows/cookstyle.yml +++ b/.github/workflows/cookstyle.yml @@ -1,27 +1,23 @@ name: Cookstyle + on: - push - pull_request + +concurrency: + group: ${{ github.workflow }}-{{ github.head_ref || github.ref }} + cancel-in-progress: true + jobs: cookstyle: name: Cookstyle runs-on: ubuntu-latest steps: - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup ruby - uses: actions/setup-ruby@v1.1.3 - - name: Cache gems - uses: actions/cache@v2.1.4 + uses: ruby/setup-ruby@v1 with: - path: vendor/bundle - key: bundle-${{ runner.OS }}-${{ hashFiles('Gemfile.lock') }} - restore-keys: | - bundle-${{ runner.OS }}- - - name: Install gems - run: | - gem install bundler - bundle config set deployment true - bundle install --jobs 4 --retry 3 + bundler-cache: true - name: Run cookstyle run: bundle exec cookstyle --format fuubar diff --git a/.github/workflows/test-kitchen.yml b/.github/workflows/test-kitchen.yml index 297d0bbfe..5c622df16 100644 --- a/.github/workflows/test-kitchen.yml +++ b/.github/workflows/test-kitchen.yml @@ -1,7 +1,13 @@ name: Test Kitchen + on: - push - pull_request + +concurrency: + group: ${{ github.workflow }}-{{ github.head_ref || github.ref }} + cancel-in-progress: true + jobs: kitchen: name: Test Kitchen @@ -18,6 +24,7 @@ jobs: - blogs - civicrm - clamav + - community - db-backup - db-base - db-master @@ -49,6 +56,7 @@ jobs: - logstash-forwarder - mail - mailman + - matomo - memcached - munin - munin-plugins @@ -63,11 +71,11 @@ jobs: - osmosis - osqa - otrs + - overpass - passenger - php - php-apache - php-fpm - - piwik - planet - planet-current - planet-dump @@ -81,7 +89,6 @@ jobs: - serverinfo - snmpd - spamassassin - - squid - ssl - stateofthemap - subversion @@ -91,11 +98,9 @@ jobs: - sysfs - taginfo - tile - - tilecache - tilelog - tools - trac - - web-backend - web-cgimap - web-frontend - web-rails @@ -103,33 +108,13 @@ jobs: - wiki os: - ubuntu-2004 - include: - - suite: trac - os: ubuntu-1804 - exclude: - - suite: trac - os: ubuntu-2004 fail-fast: false steps: - name: Check out code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup ruby - uses: actions/setup-ruby@v1.1.3 - - name: Cache gems - uses: actions/cache@v2.1.4 + uses: ruby/setup-ruby@v1 with: - path: vendor/bundle - key: bundle-${{ runner.OS }}-${{ hashFiles('Gemfile.lock') }} - restore-keys: | - bundle-${{ runner.OS }}- - - name: Disable apparmor for mysqld - run: | - sudo apt-get install apparmor-utils - sudo aa-disable /usr/sbin/mysqld - - name: Install gems - run: | - gem install bundler - bundle config set deployment true - bundle install --jobs 4 --retry 3 + bundler-cache: true - name: Run kitchen test ${{ matrix.suite }}-${{ matrix.os }} run: bundle exec kitchen test ${{ matrix.suite }}-${{ matrix.os }} diff --git a/.kitchen.yml b/.kitchen.yml index 58a63e3b9..84a501546 100644 --- a/.kitchen.yml +++ b/.kitchen.yml @@ -1,7 +1,9 @@ --- driver: name: dokken - chef_version: 16 + chef_version: 17 + volumes: + - /var/lib/docker env: - container=dokken @@ -18,13 +20,6 @@ verifier: sudo: false platforms: - - name: ubuntu-18.04 - driver: - image: dokken/ubuntu-18.04 - privileged: true - pid_one_command: /bin/systemd - intermediate_instructions: - - RUN /usr/bin/apt-get update -y - name: ubuntu-20.04 driver: image: dokken/ubuntu-20.04 @@ -64,6 +59,9 @@ suites: - name: clamav run_list: - recipe[clamav::default] + - name: community + run_list: + - recipe[community::default] - name: db-backup run_list: - recipe[db::backup] @@ -179,17 +177,23 @@ suites: attributes: logstash: forwarder: - filebeat.prospectors: - - input_type: log + filebeat.inputs: + - type: filestream + id: apache paths: - /var/log/apache2/access.log - type: apache + fields: + type: apache + fields_under_root: true - name: mail run_list: - role[mail] - name: mailman run_list: - recipe[mailman::default] + - name: matomo + run_list: + - recipe[matomo::default] - name: memcached run_list: - recipe[memcached::default] @@ -232,6 +236,9 @@ suites: - name: otrs run_list: - recipe[otrs::default] + - name: overpass + run_list: + - recipe[overpass::default] - name: passenger run_list: - recipe[passenger::default] @@ -244,9 +251,6 @@ suites: - name: php-fpm run_list: - recipe[php::fpm] - - name: piwik - run_list: - - recipe[piwik::default] - name: planet run_list: - recipe[planet::default] @@ -290,6 +294,9 @@ suites: - name: prometheus-server run_list: - recipe[prometheus::server] + attributes: + prometheus: + promscale: true - name: python run_list: - recipe[python::default] @@ -305,9 +312,6 @@ suites: - name: spamassassin run_list: - recipe[spamassassin::default] - - name: squid - run_list: - - recipe[squid::default] - name: ssl run_list: - recipe[ssl::default] @@ -339,9 +343,6 @@ suites: - name: tile run_list: - recipe[tile::default] - - name: tilecache - run_list: - - recipe[tilecache::default] - name: tilelog run_list: - recipe[tilelog::default] @@ -354,9 +355,6 @@ suites: - name: trac run_list: - recipe[trac::default] - - name: web-backend - run_list: - - recipe[web::backend] - name: web-cgimap run_list: - recipe[web::cgimap] diff --git a/.rubocop.yml b/.rubocop.yml index 80bd36dad..75bc2d9d8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,10 +1,13 @@ inherit_from: .rubocop_todo.yml AllCops: - TargetRubyVersion: 2.7 + TargetRubyVersion: 3.0 ChefModernize/IncludingAptDefaultRecipe: Enabled: false + +Chef/Modernize/CronDFileOrTemplate: + Enabled: false Layout/ExtraSpacing: AllowForAlignment: true diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bdb397acf..a92cef294 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,19 +1,14 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2020-07-30 08:39:06 UTC using RuboCop version 0.88.0. +# on 2021-05-11 07:26:15 UTC using RuboCop version 1.14.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 1038 +# Offense count: 1124 # Cop supports --auto-correct. # Configuration parameters: . # SupportedStyles: strings, symbols -ChefStyle/AttributeKeys: +Chef/Style/AttributeKeys: EnforcedStyle: symbols - -# Offense count: 3 -# Configuration parameters: CountBlocks. -Metrics/BlockNesting: - Max: 4 diff --git a/.ruby-version b/.ruby-version index 860487ca1..b0f2dcb32 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.1 +3.0.4 diff --git a/Gemfile.lock b/Gemfile.lock index 65ffe696d..c541d8c09 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -4,26 +4,29 @@ GEM ast (2.4.2) bcrypt_pbkdf (1.1.0) builder (3.2.4) - chef-utils (16.10.17) - cookstyle (7.9.0) - rubocop (= 1.11.0) - diff-lcs (1.4.4) - docker-api (2.0.0) + chef-utils (17.10.0) + concurrent-ruby + concurrent-ruby (1.1.10) + cookstyle (7.32.1) + rubocop (= 1.25.1) + diff-lcs (1.5.0) + docker-api (2.2.0) excon (>= 0.47.0) multi_json - ed25519 (1.2.4) + ed25519 (1.3.0) erubi (1.10.0) - excon (0.79.0) - ffi (1.14.2) + excon (0.92.4) + ffi (1.15.5) gssapi (1.3.1) ffi (>= 1.0.1) - gyoku (1.3.1) + gyoku (1.4.0) builder (>= 2.1.2) + rexml (~> 3.0) httpclient (2.8.3) - kitchen-dokken (2.12.1) + kitchen-dokken (2.17.3) docker-api (>= 1.33, < 3) lockfile (~> 2.1) - test-kitchen (>= 1.15, < 3) + test-kitchen (>= 1.15, < 4) license-acceptance (2.1.13) pastel (~> 0.7) tomlrb (>= 1.2, < 3.0) @@ -31,14 +34,14 @@ GEM tty-prompt (~> 0.20) little-plugger (1.1.4) lockfile (2.1.3) - logging (2.3.0) + logging (2.3.1) little-plugger (~> 1.1) multi_json (~> 1.14) - mixlib-install (3.12.7) + mixlib-install (3.12.19) mixlib-shellout mixlib-versioning thor - mixlib-shellout (3.2.5) + mixlib-shellout (3.2.7) chef-utils mixlib-versioning (1.2.12) multi_json (1.15.0) @@ -49,61 +52,61 @@ GEM net-ssh (>= 4.0.0) net-telnet (0.1.1) nori (2.6.0) - parallel (1.20.1) - parser (3.0.0.0) + parallel (1.21.0) + parser (3.1.1.0) ast (~> 2.4.1) pastel (0.8.0) tty-color (~> 0.5) - rainbow (3.0.0) - regexp_parser (2.1.1) - rexml (3.2.4) - rspec (3.9.0) - rspec-core (~> 3.9.0) - rspec-expectations (~> 3.9.0) - rspec-mocks (~> 3.9.0) - rspec-core (3.9.2) - rspec-support (~> 3.9.3) - rspec-expectations (3.9.2) + rainbow (3.1.1) + regexp_parser (2.2.1) + rexml (3.2.5) + rspec (3.10.0) + rspec-core (~> 3.10.0) + rspec-expectations (~> 3.10.0) + rspec-mocks (~> 3.10.0) + rspec-core (3.10.2) + rspec-support (~> 3.10.0) + rspec-expectations (3.10.2) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) + rspec-support (~> 3.10.0) rspec-its (1.3.0) rspec-core (>= 3.0.0) rspec-expectations (>= 3.0.0) - rspec-mocks (3.9.1) + rspec-mocks (3.10.3) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.9.0) - rspec-support (3.9.3) - rubocop (1.11.0) + rspec-support (~> 3.10.0) + rspec-support (3.10.3) + rubocop (1.25.1) parallel (~> 1.10) - parser (>= 3.0.0.0) + parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.2.0, < 2.0) + rubocop-ast (>= 1.15.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.4.1) - parser (>= 2.7.1.5) + rubocop-ast (1.16.0) + parser (>= 3.1.1.0) ruby-progressbar (1.11.0) rubyntlm (0.6.3) - rubyzip (2.3.0) - serverspec (2.41.5) + rubyzip (2.3.2) + serverspec (2.42.0) multi_json rspec (~> 3.0) rspec-its specinfra (~> 2.72) sfl (2.3) - specinfra (2.82.19) + specinfra (2.83.1) net-scp net-ssh (>= 2.7) net-telnet (= 0.1.1) sfl - strings (0.2.0) + strings (0.2.1) strings-ansi (~> 0.2) - unicode-display_width (~> 1.5) + unicode-display_width (>= 1.5, < 3.0) unicode_utils (~> 1.4) strings-ansi (0.2.0) - test-kitchen (2.11.1) + test-kitchen (3.3.1) bcrypt_pbkdf (~> 1.0) chef-utils (>= 16.4.35) ed25519 (~> 1.2) @@ -117,15 +120,15 @@ GEM winrm (~> 2.0) winrm-elevated (~> 1.0) winrm-fs (~> 1.1) - thor (1.1.0) - tomlrb (2.0.1) + thor (1.2.1) + tomlrb (2.0.3) tty-box (0.7.0) pastel (~> 0.8) strings (~> 0.2.0) tty-cursor (~> 0.7) tty-color (0.6.0) tty-cursor (0.7.1) - tty-prompt (0.23.0) + tty-prompt (0.23.1) pastel (~> 0.8) tty-reader (~> 0.8) tty-reader (0.9.0) @@ -133,7 +136,7 @@ GEM tty-screen (~> 0.8) wisper (~> 2.0) tty-screen (0.8.1) - unicode-display_width (1.7.0) + unicode-display_width (2.2.0) unicode_utils (1.4.0) winrm (2.3.6) builder (>= 2.1.2) @@ -165,4 +168,4 @@ DEPENDENCIES test-kitchen BUNDLED WITH - 2.1.4 + 2.2.16 diff --git a/cookbooks/accounts/files/default/grant/.ssh/authorized_keys b/cookbooks/accounts/files/default/grant/.ssh/authorized_keys index 26a4f44a9..fa33091a6 100644 --- a/cookbooks/accounts/files/default/grant/.ssh/authorized_keys +++ b/cookbooks/accounts/files/default/grant/.ssh/authorized_keys @@ -1,3 +1,5 @@ # DO NOT EDIT - This file is being maintained by Chef - use authorized_keys2 instead ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC6Hw67b4cRzXDvs88XSuKpXTJmFyietVqaQvJRedQflurHay5lGdFyzfPF0P+mG9l5O/qlKzXo5xvZNe6YOGcMCuxzOYiw/bAkEd7oHYVXVJr8jWL2zqusBmf5dLZDEjMtUX9w6IQWiuSvm3To3Fsohn2UjUqEi5aULu6h39O1JtcdtmIvjB4iTmIO4Eme8FxubktDImyCvwOAJVsYQASljeaTDa+31ANqMDehXZSRjFKaVECw1RNyvYclmkbj8rLiw648/IV9xRi/SMtZlNyxrcIKQ6hKmmiyaBA6a5QEqWj7OMVYCECAoNwlWKhBmkMx7fwOh1eKKOLFeFz2kdSt grant@home-desktop-key ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDuVegqS8l8WgH1T1LMGyJ4OvPeI5Kek5f5bYsHy62DLOhd4aDHCjJPegfiKCdpYde/b2kOQuwG90cl1a+6DDvNXvIDarQvfNzNWGONOtb+NM0/+IuAfSeonh8ROWRLW5ciOQi0PuPGnjD9vYdFMKtCh1lyi9KOq9DJNR0HFqEJgoZg8BoclAUdtgPzYU/fVpgwAS5mdBUTIQga3CbVsRcTWLPFKNlgY46eWYEKb9XqZIoa5AlxqH6AtYjaUQBdGzRpo/PW71VZzpZMP/dhf6illQBUyFJXL+PyVZGsckq94fkb6j3E5OkuGT55o4fEVLQaIDh2sIUB5n2emnP5On44kNTCPZiAMAC2weLv9PD7RFgTuxVTa1WsxbDqqaTueHJH1P+K4TNx2w0wfTfxqXjXKQPwGED1+xHWwOQoWT9eSarvUQF1jtQdseNsljPkJtpTiD2CHIUuCohYm0DxGYbQSl7uTLDK5HfuMMhAfBry/kNDb7CFTWKzN98Zbam8fx7e9TnCoL4MOMR8GOZyw/ITMbjmWRV5JGFfNUvqrteb9DLh99ZNDrcAawoESFLQTaXGPNYwCMcsxHxZAo8obfRGM/RbGvS+njfib6tkMwh6H/7uA1MPVLEbLejosMUzylDcfaoqGB5SryzZSVO0f7lx4JadQDCAimGBb0N3Fem8Rw== grant.slater@FRIDAY +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGW+K3RYYU26wSOp0DWA4OA94UeX9AZdk8aaaiV1KopY grant@home +ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIG+dY7nSVDShpfzDrgs1UaDeFbQUlXVWl4eECFu0Zo3a grant.slater@LONGS22-M diff --git a/cookbooks/accounts/files/default/matt/.ssh/authorized_keys b/cookbooks/accounts/files/default/matt/.ssh/authorized_keys index a5f67e78a..de66ccbbc 100644 --- a/cookbooks/accounts/files/default/matt/.ssh/authorized_keys +++ b/cookbooks/accounts/files/default/matt/.ssh/authorized_keys @@ -1,2 +1,3 @@ # DO NOT EDIT - This file is being maintained by Chef - use authorized_keys2 instead ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAyBrnrkjzAJqXtRP0MFKlc3v4fTnrRzzebIFH8YpFRCaLKpIXWVbg5BqXuxHB/vqf/1Gknycb7bgLPbhWr+b50D+nnodiJ35HPqrQVLG6nsqxnbbVXO1IR7KsctL+Wr3GW5pBeWct9GAALn8ACAR8zZ/4V6qXDgUvh0inefcqpks1YgdPdyAGLMFy7hzI5lY8kGh58kVPXMpyJLVnGX0yUjrip9IkPrGBvMDiGDiPwLOfKGDR0s1An1GK2i4k2rPxkZzdQSbqZXaaCw3MNJkDvwSmQNQp4Rprfy5BqptwJg4PLnGGePfYbzsqYA0/Pq4ccO+NPCDxZxb2XuVjgXEg8Q== matt@horntail.openstreetmap.org +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDntpfnmWsP/9nh3JvT/AuNz3t4azrH54vKLrdtovYQ14QC66GA9EyAJel2eamyhevHQw5JU3Ic6H0ycXZus6QNn5vZKBn72/HXc/mvfRO2F5PvWVVF5LROoe1YBmYJugqpRwFekt9pIs49bbu3lZolnmmVT/uQP3sTFgErc/eqBtzgB+0OYijddQl3otzOZaZh1o4YaUvyutVb8ND3D1xgPxavWKW8B3BTDLF/Lr0wyh+CTWc1LtXVifIWpe9Muv+l+iww8AScyryLdMfcrUY+k76HwmkLbNV01hWMbfnB+4KoshFHnpmFN/Q4maoEXQpwP1II3iEKVs6QWFc4dImREtpiUJm5XeznlmfBuMac2gZPyPqSQPoUmxDTV7+umbcpw5IMGKFom6GJJJN2Az40TqNoQBAwnrJrmxzvLU8POpfYdZZfPLUB8l9nELGvIMhbRTBVpq6t99AxqvHlk3hc6yPTBFfltiBDB62QyOIEggbecnMaD1VvAkrthRITNJ9h0zdvrXM+X0pMo1QM8dBqRvrbBD7fr3gy2Oo+/XMsxf6Q8Fd7iu8oU8HYCwDexqZ8y9Nb54dOglWzSEPsTBAWf6PtBtZaXZ/VnNy3zjnJuOA99STQmqH5OPCY0eg6yRE6TILj9J4wWAXytXL9lF5YAW8JIT4+8pa4WhJoUGQz1w== zerebubuth@gmail.com diff --git a/cookbooks/accounts/files/default/tomh/.zshrc b/cookbooks/accounts/files/default/tomh/.zshrc index 20211c3c8..1eae8a392 100644 --- a/cookbooks/accounts/files/default/tomh/.zshrc +++ b/cookbooks/accounts/files/default/tomh/.zshrc @@ -28,6 +28,8 @@ unset zle_bracketed_paste # Keep tramp happy if [[ "$TERM" = "dumb" ]] then + unsetopt PROMPT_SP + unsetopt PROMPT_CR unsetopt ZLE fi diff --git a/cookbooks/apache/recipes/default.rb b/cookbooks/apache/recipes/default.rb index d443f1e40..c927b87b5 100644 --- a/cookbooks/apache/recipes/default.rb +++ b/cookbooks/apache/recipes/default.rb @@ -71,6 +71,10 @@ apache_module "status" do variables :hosts => admins["hosts"] end +apache_module "brotli" do + conf "brotli.conf.erb" +end + apache_module "deflate" do conf "deflate.conf.erb" end diff --git a/cookbooks/apache/resources/conf.rb b/cookbooks/apache/resources/conf.rb index 12daf87ab..9f1efb24f 100644 --- a/cookbooks/apache/resources/conf.rb +++ b/cookbooks/apache/resources/conf.rb @@ -17,6 +17,8 @@ # limitations under the License. # +unified_mode true + default_action [:create, :enable] property :conf, :kind_of => String, :name_property => true diff --git a/cookbooks/apache/resources/module.rb b/cookbooks/apache/resources/module.rb index 6658d52a6..5de2bfcaa 100644 --- a/cookbooks/apache/resources/module.rb +++ b/cookbooks/apache/resources/module.rb @@ -17,6 +17,8 @@ # limitations under the License. # +unified_mode true + default_action [:install, :enable] property :module, :kind_of => String, :name_property => true diff --git a/cookbooks/apache/resources/site.rb b/cookbooks/apache/resources/site.rb index e039e3ac5..598f841ff 100644 --- a/cookbooks/apache/resources/site.rb +++ b/cookbooks/apache/resources/site.rb @@ -17,6 +17,8 @@ # limitations under the License. # +unified_mode true + default_action [:create, :enable] property :site, :kind_of => String, :name_property => true diff --git a/cookbooks/apache/templates/default/brotli.conf.erb b/cookbooks/apache/templates/default/brotli.conf.erb new file mode 100644 index 000000000..7000e590e --- /dev/null +++ b/cookbooks/apache/templates/default/brotli.conf.erb @@ -0,0 +1,12 @@ +# DO NOT EDIT - This file is being maintained by Chef + + + + AddOutputFilterByType BROTLI_COMPRESS text/html text/plain text/xml + AddOutputFilterByType BROTLI_COMPRESS text/css + AddOutputFilterByType BROTLI_COMPRESS application/x-javascript application/javascript application/ecmascript + AddOutputFilterByType BROTLI_COMPRESS application/rss+xml + AddOutputFilterByType BROTLI_COMPRESS application/xml + AddOutputFilterByType BROTLI_COMPRESS image/svg+xml + + diff --git a/cookbooks/apt/recipes/default.rb b/cookbooks/apt/recipes/default.rb index 6ab6afb7e..f69db4f3e 100644 --- a/cookbooks/apt/recipes/default.rb +++ b/cookbooks/apt/recipes/default.rb @@ -58,11 +58,6 @@ repository_actions = Hash.new do |_, repository| node[:apt][:sources].include?(repository) ? :add : :remove end -apt_repository "brightbox-ruby-ng" do - action repository_actions["brightbox-ruby-ng"] - uri "ppa:brightbox/ruby-ng" -end - apt_repository "ubuntugis-stable" do action repository_actions["ubuntugis-stable"] uri "ppa:ubuntugis/ppa" @@ -88,21 +83,6 @@ apt_repository "openstreetmap" do uri "ppa:osmadmins/ppa" end -apt_repository "squid2" do - action repository_actions["squid2"] - uri "ppa:osmadmins/squid2" -end - -apt_repository "squid3" do - action repository_actions["squid3"] - uri "ppa:osmadmins/squid3" -end - -apt_repository "squid4" do - action repository_actions["squid4"] - uri "ppa:osmadmins/squid4" -end - apt_repository "management-component-pack" do action repository_actions["management-component-pack"] uri "https://downloads.linux.hpe.com/SDR/repo/mcp" @@ -135,9 +115,9 @@ apt_repository "elasticsearch5.x" do key "D27D666CD88E42B4" end -apt_repository "elasticsearch6.x" do - action repository_actions["elasticsearch6.x"] - uri "https://artifacts.elastic.co/packages/6.x/apt" +apt_repository "elasticsearch8.x" do + action repository_actions["elasticsearch8.x"] + uri "https://artifacts.elastic.co/packages/8.x/apt" distribution "stable" components ["main"] key "D27D666CD88E42B4" @@ -158,14 +138,6 @@ apt_repository "postgresql" do key "7FCC7D46ACCC4CF8" end -apt_repository "mediawiki" do - action repository_actions["mediawiki"] - uri "https://releases.wikimedia.org/debian" - distribution "jessie-mediawiki" - components ["main"] - key "AF380A3036A03444" -end - apt_repository "docker" do action repository_actions["docker"] uri "https://download.docker.com/linux/ubuntu" @@ -184,7 +156,9 @@ end apt_repository "timescaledb" do action repository_actions["timescaledb"] - uri "ppa:timescale/timescaledb-ppa" + uri "https://packagecloud.io/timescale/timescaledb/ubuntu" + components ["main"] + key "https://packagecloud.io/timescale/timescaledb/gpgkey" end package "unattended-upgrades" diff --git a/cookbooks/backup/files/default/expire-backups b/cookbooks/backup/files/default/expire-backups index 0cd75a502..81834d437 100644 --- a/cookbooks/backup/files/default/expire-backups +++ b/cookbooks/backup/files/default/expire-backups @@ -48,14 +48,18 @@ my $keep = qr/^${prefix}(?:${dates})\./; opendir(DIR, "$dir") || die "Can't open ${dir}: $!"; -while (my $file = readdir(DIR)) -{ -# print "Expiring $file\n" if $file =~ $match && $file !~ $keep; - unlink("${dir}/${file}") if $file =~ $match && $file !~ $keep; -} +my @files = sort(grep($match, readdir(DIR))); closedir(DIR); +pop @files; + +for my $file (@files) +{ +# print "Expiring $file\n" if $file !~ $keep; + unlink("${dir}/${file}") if $file !~ $keep; +} + exit 0; sub Monday diff --git a/cookbooks/backup/templates/default/expire.cron.erb b/cookbooks/backup/templates/default/expire.cron.erb index dc4f7e15e..bcdc6aaa2 100644 --- a/cookbooks/backup/templates/default/expire.cron.erb +++ b/cookbooks/backup/templates/default/expire.cron.erb @@ -2,7 +2,7 @@ # DO NOT EDIT - This file is being maintained by Chef -for prefix in chef-server chef-repository chef-git forum git lists munin osm-blog osm-donate osmf-crm osmf-ledgersmb wiki-wiki.osmfoundation.org osqa otrs prometheus sotm svn switch2osm trac wiki-board.osmfoundation.org wiki-dwg.osmfoundation.org wiki-mwg.osmfoundation.org wiki-wiki.openstreetmap.org +for prefix in blogs chef-server chef-repository chef-git community forum git lists munin osm-blog osm-donate osmf-crm osmf-ledgersmb wiki-wiki.osmfoundation.org osqa otrs prometheus sotm svn switch2osm trac wiki-board.osmfoundation.org wiki-dwg.osmfoundation.org wiki-mwg.osmfoundation.org wiki-wiki.openstreetmap.org do /usr/local/bin/expire-backups --days=3 --weeks=3 --months=3 /store/backup $prefix done diff --git a/cookbooks/bind/recipes/default.rb b/cookbooks/bind/recipes/default.rb index 77c777e1a..78db7466f 100644 --- a/cookbooks/bind/recipes/default.rb +++ b/cookbooks/bind/recipes/default.rb @@ -31,13 +31,7 @@ end.flatten package "bind9" -service_name = if node[:lsb][:release].to_f < 20.04 - "bind9" - else - "named" - end - -service service_name do +service "named" do action [:enable, :start] end @@ -46,7 +40,7 @@ template "/etc/bind/named.conf.local" do owner "root" group "root" mode "644" - notifies :restart, "service[#{service_name}]" + notifies :restart, "service[named]" end template "/etc/bind/named.conf.options" do @@ -55,7 +49,7 @@ template "/etc/bind/named.conf.options" do group "root" mode "644" variables :ipv4_clients => ipv4_clients, :ipv6_clients => ipv6_clients - notifies :restart, "service[#{service_name}]" + notifies :restart, "service[named]" end template "/etc/bind/db.10" do @@ -63,7 +57,7 @@ template "/etc/bind/db.10" do owner "root" group "root" mode "644" - notifies :reload, "service[#{service_name}]" + notifies :reload, "service[named]" end firewall_rule "accept-dns-udp" do diff --git a/cookbooks/bind/templates/default/db.10.erb b/cookbooks/bind/templates/default/db.10.erb index 05dc9d618..55c99e6f6 100644 --- a/cookbooks/bind/templates/default/db.10.erb +++ b/cookbooks/bind/templates/default/db.10.erb @@ -2,7 +2,7 @@ $TTL 604800 @ IN SOA <%= node[:fdqn] %>. root.openstreetmap.org. ( - 2019040301 ; Serial + 2021092001 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire @@ -11,6 +11,7 @@ $TTL 604800 @ IN NS <%= node[:fdqn] %>. 3.0.0 IN PTR ridley.ucl.openstreetmap.org. +4.0.0 IN PTR snap-02.ucl.openstreetmap.org. 5.0.0 IN PTR norbert.ucl.openstreetmap.org. 6.0.0 IN PTR urmel.ucl.openstreetmap.org. 7.0.0 IN PTR faffy.ucl.openstreetmap.org. @@ -21,7 +22,7 @@ $TTL 604800 12.0.0 IN PTR sarel.ucl.openstreetmap.org. 13.0.0 IN PTR noquiklos.ucl.openstreetmap.org. 14.0.0 IN PTR errol.ucl.openstreetmap.org. -15.0.0 IN PTR yevaud.ucl.openstreetmap.org. +15.0.0 IN PTR ysera.ucl.openstreetmap.org. 17.0.0 IN PTR clifford.ucl.openstreetmap.org. 19.0.0 IN PTR grindtooth.ucl.openstreetmap.org. 20.0.0 IN PTR pummelzacken.ucl.openstreetmap.org. @@ -39,6 +40,7 @@ $TTL 604800 51.0.0 IN PTR tiamat-23.ucl.openstreetmap.org. 3.1.0 IN PTR ridley.oob.openstreetmap.org. +4.1.0 IN PTR snap-02.oob.openstreetmap.org. 5.1.0 IN PTR norbert.oob.openstreetmap.org. 6.1.0 IN PTR urmel.oob.openstreetmap.org. 8.1.0 IN PTR zark.oob.openstreetmap.org. @@ -48,7 +50,7 @@ $TTL 604800 12.1.0 IN PTR sarel.oob.openstreetmap.org. 13.1.0 IN PTR noquiklos.oob.openstreetmap.org. 14.1.0 IN PTR errol.oob.openstreetmap.org. -15.1.0 IN PTR yevaud.oob.openstreetmap.org. +15.1.0 IN PTR ysera.oob.openstreetmap.org. 17.1.0 IN PTR clifford.oob.openstreetmap.org. 19.1.0 IN PTR grindtooth.oob.openstreetmap.org. 20.1.0 IN PTR pummelzacken.oob.openstreetmap.org. @@ -82,12 +84,6 @@ $TTL 604800 41.33.0 IN PTR thorn-04.oob.openstreetmap.org. 42.33.0 IN PTR thorn-05.oob.openstreetmap.org. -3.48.0 IN PTR orm.ams.openstreetmap.org. -4.48.0 IN PTR ouroboros.ams.openstreetmap.org. -5.48.0 IN PTR ramoth.ams.openstreetmap.org. -6.48.0 IN PTR spike-01.ams.openstreetmap.org. -7.48.0 IN PTR spike-02.ams.openstreetmap.org. -8.48.0 IN PTR spike-03.ams.openstreetmap.org. 9.48.0 IN PTR dulcy.ams.openstreetmap.org. 10.48.0 IN PTR ironbelly.ams.openstreetmap.org. 11.48.0 IN PTR spike-06.ams.openstreetmap.org. @@ -95,19 +91,15 @@ $TTL 604800 13.48.0 IN PTR spike-08.ams.openstreetmap.org. 14.48.0 IN PTR tabaluga.ams.openstreetmap.org. 15.48.0 IN PTR odin.ams.openstreetmap.org. +16.48.0 IN PTR lockheed.ams.openstreetmap.org. +49.48.0 IN PTR snap-01.ams.openstreetmap.org. 50.48.0 IN PTR karm.ams.openstreetmap.org. -51.48.0 IN PTR thorn-01.ams.openstreetmap.org. 52.48.0 IN PTR thorn-02.ams.openstreetmap.org. 53.48.0 IN PTR thorn-03.ams.openstreetmap.org. -100.48.0 IN PTR pdu1.openstreetmap.org. -101.48.0 IN PTR pdu2.openstreetmap.org. +100.48.0 IN PTR pdu1.ams.openstreetmap.org. +101.48.0 IN PTR pdu2.ams.openstreetmap.org. +102.48.0 IN PTR oob1.ams.openstreetmap.org. -3.49.0 IN PTR orm.oob.openstreetmap.org. -4.49.0 IN PTR ouroboros.oob.openstreetmap.org. -5.49.0 IN PTR ramoth.oob.openstreetmap.org. -6.49.0 IN PTR spike-01.oob.openstreetmap.org. -7.49.0 IN PTR spike-02.oob.openstreetmap.org. -8.49.0 IN PTR spike-03.oob.openstreetmap.org. 9.49.0 IN PTR dulcy.oob.openstreetmap.org. 10.49.0 IN PTR ironbelly.oob.openstreetmap.org. 11.49.0 IN PTR spike-06.oob.openstreetmap.org. @@ -115,7 +107,31 @@ $TTL 604800 13.49.0 IN PTR spike-08.oob.openstreetmap.org. 14.49.0 IN PTR tabaluga.oob.openstreetmap.org. 15.49.0 IN PTR odin.oob.openstreetmap.org. +16.49.0 IN PTR lockheed.oob.openstreetmap.org. +49.49.0 IN PTR snap-01.oob.openstreetmap.org. 50.49.0 IN PTR karm.oob.openstreetmap.org. -51.49.0 IN PTR thorn-01.oob.openstreetmap.org. 52.49.0 IN PTR thorn-02.oob.openstreetmap.org. 53.49.0 IN PTR thorn-03.oob.openstreetmap.org. + +2.64.0 IN PTR fafnir.dub.openstreetmap.org. +3.64.0 IN PTR spike-01.dub.openstreetmap.org. +4.64.0 IN PTR spike-02.dub.openstreetmap.org. +5.64.0 IN PTR spike-03.dub.openstreetmap.org. +6.64.0 IN PTR idris.dub.openstreetmap.org. +7.64.0 IN PTR konqi.dub.openstreetmap.org. +8.64.0 IN PTR naga.dub.openstreetmap.org. +9.64.0 IN PTR culebre.dub.openstreetmap.org. +50.64.0 IN PTR snap-03.dub.openstreetmap.org. +100.64.0 IN PTR pdu1.dub.openstreetmap.org. +101.64.0 IN PTR pdu2.dub.openstreetmap.org. +102.64.0 IN PTR oob1.dub.openstreetmap.org. + +2.65.0 IN PTR fafnir.oob.openstreetmap.org. +3.65.0 IN PTR spike-01.oob.openstreetmap.org. +4.65.0 IN PTR spike-02.oob.openstreetmap.org. +5.65.0 IN PTR spike-03.oob.openstreetmap.org. +6.65.0 IN PTR idris.oob.openstreetmap.org. +7.65.0 IN PTR konqi.oob.openstreetmap.org. +8.65.0 IN PTR naga.oob.openstreetmap.org. +9.65.0 IN PTR culebre.oob.openstreetmap.org. +50.65.0 IN PTR snap-03.oob.openstreetmap.org. diff --git a/cookbooks/blog/recipes/default.rb b/cookbooks/blog/recipes/default.rb index 2f80e2b13..820731a49 100644 --- a/cookbooks/blog/recipes/default.rb +++ b/cookbooks/blog/recipes/default.rb @@ -53,10 +53,16 @@ wordpress_plugin "blog.openstreetmap.org-google-analytics-for-wordpress" do end wordpress_plugin "blog.openstreetmap.org-google-sitemap-generator" do + action :delete plugin "google-sitemap-generator" site "blog.openstreetmap.org" end +# wordpress_plugin "blog.openstreetmap.org-www-xml-sitemap-generator-org" do +# plugin "www-xml-sitemap-generator-org" +# site "blog.openstreetmap.org" +# end + wordpress_plugin "blog.openstreetmap.org-shareadraft" do plugin "shareadraft" site "blog.openstreetmap.org" @@ -66,7 +72,8 @@ wordpress_plugin "blog.openstreetmap.org-sitepress-multilingual-cms" do plugin "sitepress-multilingual-cms" site "blog.openstreetmap.org" repository "https://git.openstreetmap.org/private/sitepress-multilingual-cms.git" - not_if { ENV["TEST_KITCHEN"] } + revision "master" + not_if { kitchen? } end wordpress_plugin "blog.openstreetmap.org-wordpress-importer" do @@ -74,6 +81,11 @@ wordpress_plugin "blog.openstreetmap.org-wordpress-importer" do site "blog.openstreetmap.org" end +wordpress_plugin "blog.openstreetmap.org-wp-piwik" do + plugin "wp-piwik" + site "blog.openstreetmap.org" +end + git "/srv/blog.openstreetmap.org/casts" do action :sync repository "https://github.com/openstreetmap/opengeodata-podcasts.git" diff --git a/cookbooks/blogs/metadata.rb b/cookbooks/blogs/metadata.rb index 19d88bcfe..e63df4125 100644 --- a/cookbooks/blogs/metadata.rb +++ b/cookbooks/blogs/metadata.rb @@ -9,3 +9,4 @@ supports "ubuntu" depends "accounts" depends "apache" depends "git" +depends "ruby" diff --git a/cookbooks/blogs/recipes/default.rb b/cookbooks/blogs/recipes/default.rb index 165befb5e..51e6b62f4 100644 --- a/cookbooks/blogs/recipes/default.rb +++ b/cookbooks/blogs/recipes/default.rb @@ -20,29 +20,16 @@ include_recipe "accounts" include_recipe "apache" include_recipe "git" - -ruby_version = if node[:lsb][:release].to_f < 20.04 - "2.5" - else - "2.7" - end +include_recipe "ruby" package %W[ - ruby#{ruby_version} - ruby#{ruby_version}-dev make gcc g++ libsqlite3-dev + sqlite3 ] -gem_package "bundler#{ruby_version}" do - package_name "bundler" - version "~> 2.1.4" - gem_binary "gem#{ruby_version}" - options "--format-executable" -end - directory "/srv/blogs.openstreetmap.org" do owner "blogs" group "blogs" @@ -55,22 +42,20 @@ git "/srv/blogs.openstreetmap.org" do depth 1 user "blogs" group "blogs" - notifies :run, "execute[/srv/blogs.openstreetmap.org/Gemfile]", :immediately + notifies :run, "bundle_install[/srv/blogs.openstreetmap.org]", :immediately end -execute "/srv/blogs.openstreetmap.org/Gemfile" do +bundle_install "/srv/blogs.openstreetmap.org" do action :nothing - command "bundle#{ruby_version} install --deployment" - cwd "/srv/blogs.openstreetmap.org" - user "blogs" - group "blogs" - notifies :run, "execute[/srv/blogs.openstreetmap.org]", :immediately + options "--deployment" + user "root" + group "root" + notifies :run, "bundle_exec[/srv/blogs.openstreetmap.org]", :immediately end -execute "/srv/blogs.openstreetmap.org" do +bundle_exec "/srv/blogs.openstreetmap.org" do action :nothing - command "bundle#{ruby_version} exec pluto build -t osm -o build" - cwd "/srv/blogs.openstreetmap.org" + command "pluto build -t osm -o build" user "blogs" group "blogs" end @@ -91,7 +76,6 @@ template "/usr/local/bin/blogs-update" do owner "root" group "root" mode "0755" - variables :ruby_version => ruby_version end cron_d "blogs" do @@ -100,3 +84,10 @@ cron_d "blogs" do command "/usr/local/bin/blogs-update" mailto "admins@openstreetmap.org" end + +template "/etc/cron.daily/blogs-backup" do + source "backup.cron.erb" + owner "root" + group "root" + mode "0755" +end diff --git a/cookbooks/blogs/templates/default/backup.cron.erb b/cookbooks/blogs/templates/default/backup.cron.erb new file mode 100644 index 000000000..382989ab2 --- /dev/null +++ b/cookbooks/blogs/templates/default/backup.cron.erb @@ -0,0 +1,17 @@ +#!/bin/sh + +# DO NOT EDIT - This file is being maintained by Chef + +T=$(mktemp -d -t -p /var/tmp blogs.XXXXXXXXXX) +D=$(date +%Y-%m-%d) +B=blogs-$D.tar.gz + +mkdir $T/blogs-$D +sqlite3 /srv/blogs.openstreetmap.org/planet.db ".backup $T/blogs-$D/planet.db" + +export RSYNC_RSH="ssh -ax" + +nice tar --create --dereference --directory=$T blogs-$D | nice gzip --rsyncable -9 > $T/$B +nice rsync --preallocate --fuzzy $T/$B backup::backup + +rm -rf $T diff --git a/cookbooks/blogs/templates/default/blogs-update.erb b/cookbooks/blogs/templates/default/blogs-update.erb index ef880cdf8..15cc82483 100644 --- a/cookbooks/blogs/templates/default/blogs-update.erb +++ b/cookbooks/blogs/templates/default/blogs-update.erb @@ -2,7 +2,7 @@ cd /srv/blogs.openstreetmap.org -/usr/local/bin/bundle<%= @ruby_version %> exec pluto \ +<%= node[:ruby][:bundle] %> exec pluto \ --quieter \ --config=/srv/blogs.openstreetmap.org build \ --dbpath=/srv/blogs.openstreetmap.org \ diff --git a/cookbooks/chef/attributes/default.rb b/cookbooks/chef/attributes/default.rb index 41b03e63a..00c241a96 100644 --- a/cookbooks/chef/attributes/default.rb +++ b/cookbooks/chef/attributes/default.rb @@ -5,4 +5,4 @@ default[:apt][:sources] = node[:apt][:sources] | ["opscode"] default[:chef][:server][:version] = "12.17.33" # Set the default client version -default[:chef][:client][:version] = "16.8.14" +default[:chef][:client][:version] = "17.10.3" diff --git a/cookbooks/chef/libraries/subversion.rb b/cookbooks/chef/libraries/subversion.rb index 8e9f1e3d2..a2a6e2ba9 100644 --- a/cookbooks/chef/libraries/subversion.rb +++ b/cookbooks/chef/libraries/subversion.rb @@ -5,6 +5,12 @@ class Chef class Subversion extend Chef::Mixin::ShellOut + def shell_out!(*args, **options) + options = args.pop if options.empty? && args.last.is_a?(Hash) + + super(*args, **options) + end + def sync_command if current_repository_matches_target_repository? c = scm :update, new_resource.svn_arguments, verbose, authentication, proxy, "-r#{revision_int}", new_resource.destination @@ -42,20 +48,18 @@ class Chef def svn_info command = scm(:info) - shell_out!(command, run_options(:cwd => cwd, :returns => [0, 1])).stdout + shell_out!(command, **run_options(:cwd => cwd, :returns => [0, 1])).stdout end def revision_int - @revision_int ||= begin - if new_resource.revision =~ /^\d+$/ - new_resource.revision - else - command = scm(:info, new_resource.repository, new_resource.svn_info_args, authentication, "-r#{new_resource.revision}") - svn_info = shell_out!(command, run_options(:returns => [0, 1])).stdout - - extract_revision_info(svn_info) - end - end + @revision_int ||= if new_resource.revision =~ /^\d+$/ + new_resource.revision + else + command = scm(:info, new_resource.repository, new_resource.svn_info_args, authentication, "-r#{new_resource.revision}") + svn_info = shell_out!(command, **run_options(:returns => [0, 1])).stdout + + extract_revision_info(svn_info) + end end end end diff --git a/cookbooks/chef/recipes/default.rb b/cookbooks/chef/recipes/default.rb index 61ac42415..bd22671a7 100644 --- a/cookbooks/chef/recipes/default.rb +++ b/cookbooks/chef/recipes/default.rb @@ -36,8 +36,14 @@ Dir.glob("#{cache_dir}/chef_*.deb").each do |deb| end end +ubuntu_release = if node[:lsb][:release].to_f < 22.04 + node[:lsb][:release] + else + "20.04" + end + remote_file "#{cache_dir}/#{chef_package}" do - source "https://packages.chef.io/files/stable/chef/#{chef_version}/ubuntu/#{node[:lsb][:release]}/#{chef_package}" + source "https://packages.chef.io/files/stable/chef/#{chef_version}/ubuntu/#{ubuntu_release}/#{chef_package}" owner "root" group "root" mode "644" diff --git a/cookbooks/chef/recipes/knife.rb b/cookbooks/chef/recipes/knife.rb new file mode 100644 index 000000000..2c965084f --- /dev/null +++ b/cookbooks/chef/recipes/knife.rb @@ -0,0 +1,26 @@ +# +# Cookbook:: chef +# Recipe:: knife +# +# Copyright:: 2021, OpenStreetMap Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +package %w[ + gcc + libc6-dev + make +] + +chef_gem "knife" diff --git a/cookbooks/chef/recipes/repository.rb b/cookbooks/chef/recipes/repository.rb index d5d8d2bc2..752938bf3 100644 --- a/cookbooks/chef/recipes/repository.rb +++ b/cookbooks/chef/recipes/repository.rb @@ -17,6 +17,7 @@ # limitations under the License. # +include_recipe "chef::knife" include_recipe "git" keys = data_bag_item("chef", "keys") diff --git a/cookbooks/chef/recipes/server.rb b/cookbooks/chef/recipes/server.rb index cd4968b73..cd54cf426 100644 --- a/cookbooks/chef/recipes/server.rb +++ b/cookbooks/chef/recipes/server.rb @@ -18,6 +18,7 @@ # include_recipe "apache" +include_recipe "chef::knife" include_recipe "munin" # cache_dir = Chef::Config[:file_cache_path] diff --git a/cookbooks/chef/templates/default/post-receive.erb b/cookbooks/chef/templates/default/post-receive.erb index b402265c1..28ef5b434 100644 --- a/cookbooks/chef/templates/default/post-receive.erb +++ b/cookbooks/chef/templates/default/post-receive.erb @@ -5,6 +5,8 @@ umask 0002 unset GIT_DIR +knife="/opt/chef/embedded/bin/knife" + while read oldrev newrev refname do if [[ "$refname" = "refs/heads/master" ]] @@ -25,17 +27,17 @@ do if [[ $file == roles/*.rb ]] then case "$action" in - A|M) knife role from file "${file}";; - D) knife role delete -y "${file:t:r}";; + A|M) $knife role from file "${file}";; + D) $knife role delete -y "${file:t:r}";; esac elif [[ $file == data_bags/*/*.json ]] then case "$action" in A|M) - knife data bag create "${file:h:t}" - knife data bag from file "${file:h:t}" "${file:t}";; + $knife data bag create "${file:h:t}" + $knife data bag from file "${file:h:t}" "${file:t}";; D) - knife data bag delete -y "${file:h:t}" "${file:t:r}";; + $knife data bag delete -y "${file:h:t}" "${file:t:r}";; esac elif [[ $file == cookbooks/* ]] then @@ -52,14 +54,14 @@ do if [[ -n "$updated_cookbooks" ]] then - knife cookbook upload "${(ou)updated_cookbooks[@]}" + $knife cookbook upload "${(ou)updated_cookbooks[@]}" fi if [[ -n "$deleted_cookbooks" ]] then for cookbook in "${(ou)deleted_cookbooks[@]}" do - knife cookbook delete -y "$cookbook" + $knife cookbook delete -y "$cookbook" done fi fi diff --git a/cookbooks/civicrm/attributes/default.rb b/cookbooks/civicrm/attributes/default.rb index f0143f6f7..2375a92c9 100644 --- a/cookbooks/civicrm/attributes/default.rb +++ b/cookbooks/civicrm/attributes/default.rb @@ -1,16 +1,16 @@ -default[:civicrm][:version] = "5.34.0" +default[:civicrm][:version] = "5.51.1" default[:civicrm][:extensions][:cividiscount][:name] = "org.civicrm.module.cividiscount" default[:civicrm][:extensions][:cividiscount][:repository] = "https://github.com/dlobo/org.civicrm.module.cividiscount.git" -default[:civicrm][:extensions][:cividiscount][:revision] = "3.8.2" +default[:civicrm][:extensions][:cividiscount][:revision] = "3.8.4" default[:civicrm][:extensions][:osm][:name] = "de.systopia.osm" default[:civicrm][:extensions][:osm][:repository] = "https://github.com/systopia/de.systopia.osm.git" -default[:civicrm][:extensions][:osm][:revision] = "1.2.1" +default[:civicrm][:extensions][:osm][:revision] = "1.3" default[:civicrm][:extensions][:emailapi][:name] = "org.civicoop.emailapi" -default[:civicrm][:extensions][:emailapi][:repository] = "https://github.com/CiviCooP/org.civicoop.emailapi.git" -default[:civicrm][:extensions][:emailapi][:revision] = "1.19" +default[:civicrm][:extensions][:emailapi][:repository] = "https://lab.civicrm.org/extensions/emailapi.git" +default[:civicrm][:extensions][:emailapi][:revision] = "2.8" default[:civicrm][:extensions][:civiruleshttppost][:name] = "org.civicoop.civiruleshttppost" default[:civicrm][:extensions][:civiruleshttppost][:repository] = "https://github.com/CiviCooP/org.civicoop.civiruleshttppost.git" @@ -18,11 +18,11 @@ default[:civicrm][:extensions][:civiruleshttppost][:revision] = "e2c7de5f0fee319 default[:civicrm][:extensions][:civirules][:name] = "org.civicoop.civirules" default[:civicrm][:extensions][:civirules][:repository] = "https://lab.civicrm.org/extensions/civirules.git" -default[:civicrm][:extensions][:civirules][:revision] = "2.22" +default[:civicrm][:extensions][:civirules][:revision] = "2.43" default[:civicrm][:extensions][:mailchimp][:name] = "uk.co.vedaconsulting.mailchimp" default[:civicrm][:extensions][:mailchimp][:repository] = "https://github.com/veda-consulting/uk.co.vedaconsulting.mailchimp.git" -default[:civicrm][:extensions][:mailchimp][:revision] = "124083b29ab28246883bc83f207498a85f01ecde" +default[:civicrm][:extensions][:mailchimp][:revision] = "0065ee6de2c2d653e49d10e9563349e8ffb1f9be" default[:civicrm][:extensions][:username][:name] = "org.openstreetmap.username" default[:civicrm][:extensions][:username][:repository] = "https://github.com/grischard/org.openstreetmap.username.git" @@ -34,4 +34,12 @@ default[:civicrm][:extensions][:donotsendreportemail][:revision] = "3b31c2e0c621 default[:civicrm][:extensions][:shoreditch][:name] = "org.civicrm.shoreditch" default[:civicrm][:extensions][:shoreditch][:repository] = "https://github.com/civicrm/org.civicrm.shoreditch.git" -default[:civicrm][:extensions][:shoreditch][:revision] = "1.0.0-beta.1" +default[:civicrm][:extensions][:shoreditch][:revision] = "1.0.0-beta.11" + +default[:civicrm][:extensions][:membershipextra][:name] = "com.skvare.membershipextra" +default[:civicrm][:extensions][:membershipextra][:repository] = "https://github.com/lemniscus/com.skvare.membershipextra.git" +default[:civicrm][:extensions][:membershipextra][:revision] = "1593911d6bfe184b45d59773fed27bab69cbb93a" + +default[:civicrm][:extensions][:osmfverifycontributor][:name] = "osmf-verify-contributor" +default[:civicrm][:extensions][:osmfverifycontributor][:repository] = "https://github.com/openstreetmap/osmf-verify-contributor.git" +default[:civicrm][:extensions][:osmfverifycontributor][:revision] = "bb0cd61783033fb2e108c30e47224e5a818987f8" diff --git a/cookbooks/civicrm/recipes/default.rb b/cookbooks/civicrm/recipes/default.rb index a8881fc0d..a6c449434 100644 --- a/cookbooks/civicrm/recipes/default.rb +++ b/cookbooks/civicrm/recipes/default.rb @@ -24,9 +24,9 @@ package %w[ php-xml php-curl rsync - unzip wkhtmltopdf php-bcmath + php-intl ] cache_dir = Chef::Config[:file_cache_path] @@ -61,12 +61,6 @@ wordpress_plugin "registration-honeypot" do site "join.osmfoundation.org" end -wordpress_plugin "sitepress-multilingual-cms" do - site "join.osmfoundation.org" - repository "https://git.openstreetmap.org/private/sitepress-multilingual-cms.git" - not_if { ENV["TEST_KITCHEN"] } -end - wordpress_plugin "contact-form-7" do site "join.osmfoundation.org" end @@ -102,22 +96,22 @@ remote_file "#{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz" do backup false end -execute "#{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip" do +archive_file "#{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip" do action :nothing - command "unzip -o -qq #{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip" - cwd "/opt/civicrm-#{civicrm_version}" - user "wordpress" + destination "/opt/civicrm-#{civicrm_version}" + overwrite true + owner "wordpress" group "wordpress" - subscribes :run, "remote_file[#{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip]", :immediately + subscribes :extract, "remote_file[#{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip]", :immediately end -execute "#{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz" do +archive_file "#{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz" do action :nothing - command "tar -zxf #{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz" - cwd "/opt/civicrm-#{civicrm_version}/civicrm" - user "wordpress" + destination "/opt/civicrm-#{civicrm_version}/civicrm" + overwrite true + owner "wordpress" group "wordpress" - subscribes :run, "remote_file[#{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz]", :immediately + subscribes :extract, "remote_file[#{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz]", :immediately end execute "/opt/civicrm-#{civicrm_version}/civicrm" do @@ -125,8 +119,8 @@ execute "/opt/civicrm-#{civicrm_version}/civicrm" do command "rsync --archive --delete /opt/civicrm-#{civicrm_version}/civicrm/ #{civicrm_directory}" user "wordpress" group "wordpress" - subscribes :run, "execute[#{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip]", :immediately - subscribes :run, "execute[#{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz]", :immediately + subscribes :run, "archive_file[#{cache_dir}/civicrm-#{civicrm_version}-wordpress.zip]", :immediately + subscribes :run, "archive_file[#{cache_dir}/civicrm-#{civicrm_version}-l10n.tar.gz]", :immediately end directory "/srv/join.osmfoundation.org/wp-content/uploads" do diff --git a/cookbooks/community/README.md b/cookbooks/community/README.md new file mode 100644 index 000000000..97ee9be2a --- /dev/null +++ b/cookbooks/community/README.md @@ -0,0 +1,3 @@ +# Community Cookbook + +This installs and configures the community.openstreetmap.org website. diff --git a/cookbooks/community/attributes/default.rb b/cookbooks/community/attributes/default.rb new file mode 100644 index 000000000..68a98c736 --- /dev/null +++ b/cookbooks/community/attributes/default.rb @@ -0,0 +1 @@ +default[:accounts][:users][:community][:status] = :role diff --git a/cookbooks/community/metadata.rb b/cookbooks/community/metadata.rb new file mode 100644 index 000000000..4d159c4ad --- /dev/null +++ b/cookbooks/community/metadata.rb @@ -0,0 +1,13 @@ +name "community" +maintainer "OpenStreetMap Administrators" +maintainer_email "admins@openstreetmap.org" +license "Apache-2.0" +description "Installs and configures community site" + +version "1.0.0" +supports "ubuntu" +depends "accounts" +depends "docker" +depends "geoipupdate" +depends "git" +depends "ssl" diff --git a/cookbooks/community/recipes/default.rb b/cookbooks/community/recipes/default.rb new file mode 100644 index 000000000..89743de31 --- /dev/null +++ b/cookbooks/community/recipes/default.rb @@ -0,0 +1,149 @@ +# +# Cookbook:: community +# Recipe:: default +# +# Copyright:: 2021, OpenStreetMap Foundation +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +include_recipe "accounts" +include_recipe "docker" +include_recipe "geoipupdate" +include_recipe "git" +include_recipe "ssl" + +passwords = data_bag_item("community", "passwords") +license_keys = data_bag_item("geoipupdate", "license-keys") unless kitchen? + +directory "/srv/community.openstreetmap.org" do + owner "root" + group "root" + mode "755" +end + +directory "/srv/community.openstreetmap.org/shared" do + owner "community" + group "community" + mode "755" +end + +git "/srv/community.openstreetmap.org/docker" do + action :sync + repository "https://github.com/discourse/discourse_docker.git" + revision "main" + depth 1 + user "root" + group "root" + notifies :run, "execute[discourse_container_data_rebuild]" + notifies :run, "execute[discourse_container_web_only_bootstrap]" + notifies :run, "execute[discourse_container_mail_receiver_rebuild]" +end + +template "/srv/community.openstreetmap.org/docker/containers/data.yml" do + source "data.yml.erb" + owner "root" + group "root" + mode "644" + variables :passwords => passwords + notifies :run, "execute[discourse_container_data_rebuild]" +end + +template "/srv/community.openstreetmap.org/docker/containers/web_only.yml" do + source "web_only.yml.erb" + owner "root" + group "root" + mode "644" + variables :license_keys => license_keys, :passwords => passwords + notifies :run, "execute[discourse_container_web_only_bootstrap]" +end + +template "/srv/community.openstreetmap.org/docker/containers/mail-receiver.yml" do + source "mail-receiver.yml.erb" + owner "root" + group "root" + mode "644" + variables :passwords => passwords + notifies :run, "execute[discourse_container_mail_receiver_rebuild]" +end + +# Destroy Bootstap Start +execute "discourse_container_data_rebuild" do + action :nothing + command "./launcher rebuild data" + cwd "/srv/community.openstreetmap.org/docker/" + user "root" + group "root" +end + +ssl_certificate "community.openstreetmap.org" do + domains ["community.openstreetmap.org", "community.osm.org", "communities.openstreetmap.org", "communities.osm.org"] + notifies :run, "execute[discourse_container_web_only_bootstrap]" +end + +execute "discourse_container_data_start" do + action :run + command "./launcher start data" + cwd "/srv/community.openstreetmap.org/docker/" + user "root" + group "root" +end + +execute "discourse_container_web_only_bootstrap" do + action :nothing + command "./launcher bootstrap web_only" + cwd "/srv/community.openstreetmap.org/docker/" + user "root" + group "root" + notifies :run, "execute[discourse_container_web_only_destroy]", :immediately +end + +execute "discourse_container_web_only_destroy" do + action :nothing + command "./launcher destroy web_only" + cwd "/srv/community.openstreetmap.org/docker/" + user "root" + group "root" + notifies :run, "execute[discourse_container_web_only_start]", :immediately +end + +execute "discourse_container_web_only_start" do + action :run + command "./launcher start web_only" + cwd "/srv/community.openstreetmap.org/docker/" + user "root" + group "root" + notifies :run, "execute[discourse_container_data_start]", :before +end + +# Destroy Bootstap Start +execute "discourse_container_mail_receiver_rebuild" do + action :nothing + command "./launcher rebuild mail-receiver" + cwd "/srv/community.openstreetmap.org/docker/" + user "root" + group "root" +end + +template "/etc/cron.daily/community-backup" do + source "backup.cron.erb" + owner "root" + group "root" + mode "750" +end + +node.default[:prometheus][:exporters][443] = { + :name => "community", + :address => "#{node[:prometheus][:address]}:443", + :sni => "community.openstreetmap.org" +} diff --git a/cookbooks/community/templates/default/backup.cron.erb b/cookbooks/community/templates/default/backup.cron.erb new file mode 100644 index 000000000..994485c4d --- /dev/null +++ b/cookbooks/community/templates/default/backup.cron.erb @@ -0,0 +1,20 @@ +#!/bin/sh + +# DO NOT EDIT - This file is being maintained by Chef + +T=$(mktemp -d -t -p /var/tmp community.XXXXXXXXXX) +D=$(date +%Y-%m-%d) +B=community-$D.tar.gz + +mkdir $T/community-$D +ln -s /srv/community.openstreetmap.org/docker/containers $T/community-$D/containers +ln -s /srv/community.openstreetmap.org/shared/web-only $T/community-$D/shared-web-only +ln -s /srv/community.openstreetmap.org/shared/data/redis_data $T/community-$D/shared-data-redis_data +ln -s /srv/community.openstreetmap.org/shared/data/postgres_backup $T/community-$D/shared-data-postgres_backup + +export RSYNC_RSH="ssh -ax" + +nice tar --create --numeric-owner --dereference --directory=$T community-$D | nice gzip --rsyncable -9 > $T/$B +nice rsync --preallocate --fuzzy $T/$B backup::backup + +rm -rf $T diff --git a/cookbooks/community/templates/default/data.yml.erb b/cookbooks/community/templates/default/data.yml.erb new file mode 100644 index 000000000..2aa4de023 --- /dev/null +++ b/cookbooks/community/templates/default/data.yml.erb @@ -0,0 +1,50 @@ +# A container for all things Data, be sure to set a secret password for +# discourse account, SOME_SECRET is just an example +# + +templates: + - "templates/postgres.template.yml" + - "templates/redis.template.yml" + +# any extra arguments for Docker? +# docker_args: + +params: + db_default_text_search_config: "pg_catalog.english" + + ## Set db_shared_buffers to a max of 25% of the total memory. + ## will be set automatically by bootstrap based on detected RAM, or you can override + db_shared_buffers: "4096MB" + + ## can improve sorting performance, but adds memory usage per-connection + #db_work_mem: "40MB" + +env: + # ensure locale exists in container, you may need to install it + LC_ALL: en_US.UTF-8 + LANG: en_US.UTF-8 + LANGUAGE: en_US.UTF-8 + +volumes: + - volume: + host: /srv/community.openstreetmap.org/shared/data + guest: /shared + - volume: + host: /srv/community.openstreetmap.org/shared/data/log/var-log + guest: /var/log + +# TODO: SOME_SECRET to a password for the discourse user +hooks: + after_postgres: + - exec: + stdin: | + alter user discourse with password '<%= @passwords["database"] %>'; + cmd: su - postgres -c 'psql discourse' + + raise_on_fail: false + - file: + path: /var/spool/cron/crontabs/postgres + contents: | + # m h dom mon dow command + # MAILTO=? + 0 4 * * * /var/lib/postgresql/take-database-backup diff --git a/cookbooks/community/templates/default/mail-receiver.yml.erb b/cookbooks/community/templates/default/mail-receiver.yml.erb new file mode 100644 index 000000000..2d214e942 --- /dev/null +++ b/cookbooks/community/templates/default/mail-receiver.yml.erb @@ -0,0 +1,51 @@ +## this is the incoming mail receiver container template +## +## After making changes to this file, you MUST rebuild +## /var/discourse/launcher rebuild mail-receiver +## +## BE *VERY* CAREFUL WHEN EDITING! +## YAML FILES ARE SUPER SUPER SENSITIVE TO MISTAKES IN WHITESPACE OR ALIGNMENT! +## visit http://www.yamllint.com/ to validate this file as needed + +base_image: discourse/mail-receiver:release +update_pups: false + +expose: + - "2500:25" # SMTP + +env: + LC_ALL: en_US.UTF-8 + LANG: en_US.UTF-8 + LANGUAGE: en_US.UTF-8 + + ## Where e-mail to your forum should be sent. In general, it's perfectly fine + ## to use the same domain as the forum itself here. + MAIL_DOMAIN: community.openstreetmap.org + POSTCONF_smtpd_tls_key_file: /shared/ssl/ssl.key + POSTCONF_smtpd_tls_cert_file: /shared/ssl/ssl.crt + POSTCONF_smtpd_tls_security_level: may + + ## The URL of the mail processing endpoint of your Discourse forum. + ## This is simply your forum's base URL, with `/admin/email/handle_mail` + ## appended. Be careful if you're running a subfolder setup -- in that case, + ## the URL needs to have the subfolder included! + DISCOURSE_MAIL_ENDPOINT: 'https://community.openstreetmap.org/admin/email/handle_mail' + + ## The master API key of your Discourse forum. You can get this from + ## the "API" tab of your admin panel. + DISCOURSE_API_KEY: '<%= @passwords["mail_receiver_api_key"] %>' + + ## The username to use for processing incoming e-mail. Unless you have + ## renamed the `system` user, you should leave this as-is. + DISCOURSE_API_USERNAME: system + +volumes: + - volume: + host: /srv/community.openstreetmap.org/shared/mail-receiver/postfix-spool + guest: /var/spool/postfix + - volume: + host: /etc/ssl/certs/community.openstreetmap.org.pem + guest: /shared/ssl/ssl.crt + - volume: + host: /etc/ssl/private/community.openstreetmap.org.key + guest: /shared/ssl/ssl.key diff --git a/cookbooks/community/templates/default/web_only.yml.erb b/cookbooks/community/templates/default/web_only.yml.erb new file mode 100644 index 000000000..5794e498d --- /dev/null +++ b/cookbooks/community/templates/default/web_only.yml.erb @@ -0,0 +1,116 @@ +templates: + - "templates/web.template.yml" + - "templates/web.ratelimited.template.yml" + - "templates/web.ssl.template.yml" + +## which TCP/IP ports should this container expose? +## If you want Discourse to share a port with another webserver like Apache or nginx, +## see https://meta.discourse.org/t/17247 for details +expose: + - "80:80" # http + - "443:443" # https + +# Use 'links' key to link containers together, aka use Docker --link flag. +links: + - link: + name: data + alias: data + +# any extra arguments for Docker? +# docker_args: + +# Workaround bug: https://github.com/discourse/discourse_docker/pull/505 +# params: +# version: v2.8.7 + +env: + LC_ALL: en_US.UTF-8 + LANG: en_US.UTF-8 + LANGUAGE: en_US.UTF-8 + EMBER_CLI_PROD_ASSETS: 1 + DISCOURSE_FORCE_HTTPS: true + + ## How many concurrent web requests are supported? Depends on memory and CPU cores. + ## will be set automatically by bootstrap based on detected CPUs, or you can override + UNICORN_WORKERS: 8 + + ## TODO: The domain name this Discourse instance will respond to + DISCOURSE_HOSTNAME: community.openstreetmap.org + + ## Uncomment if you want the container to be started with the same + ## hostname (-h option) as specified above (default "$hostname-$config") + #DOCKER_USE_HOSTNAME: true + + ## TODO: List of comma delimited emails that will be made admin and developer + ## on initial signup example 'user1@example.com,user2@example.com' + DISCOURSE_DEVELOPER_EMAILS: 'operations@openstreetmap.org' + + ## TODO: The SMTP mail server used to validate new accounts and send notifications + # SMTP ADDRESS, username, and password are required + # WARNING the char '#' in SMTP password can cause problems! + DISCOURSE_SMTP_ADDRESS: mail.openstreetmap.org + DISCOURSE_SMTP_PORT: 26 + DISCOURSE_SMTP_USER_NAME: + DISCOURSE_SMTP_PASSWORD: + # DISCOURSE_SMTP_ENABLE_START_TLS: true # (optional, default true) + DISCOURSE_SMTP_DOMAIN: community.openstreetmap.org + DISCOURSE_NOTIFICATION_EMAIL: community@noreply.openstreetmap.org + + ## TODO: configure connectivity to the databases + DISCOURSE_DB_SOCKET: '' + #DISCOURSE_DB_USERNAME: discourse + DISCOURSE_DB_PASSWORD: '<%= @passwords["database"] %>' + DISCOURSE_DB_HOST: data + DISCOURSE_REDIS_HOST: data + + ## The maxmind geolocation IP address key for IP address lookup + ## see https://meta.discourse.org/t/-/137387/23 for details +<% if @license_keys -%> + DISCOURSE_MAXMIND_LICENSE_KEY: '<%= @license_keys[node[:geoipupdate][:account]] %>' +<% end -%> + +volumes: + - volume: + host: /srv/community.openstreetmap.org/shared/web-only + guest: /shared + - volume: + host: /srv/community.openstreetmap.org/shared/web-only/log/var-log + guest: /var/log + - volume: + host: /etc/ssl/certs/community.openstreetmap.org.pem + guest: /shared/ssl/ssl.crt + - volume: + host: /etc/ssl/private/community.openstreetmap.org.key + guest: /shared/ssl/ssl.key + +## Plugins go here +## see https://meta.discourse.org/t/19157 for details +hooks: + after_code: + - exec: + cd: $home/plugins + cmd: + - git clone --depth 1 https://github.com/discourse/discourse-oauth2-basic.git + - git clone --depth 1 https://github.com/discourse/discourse-solved.git + - git clone --depth 1 https://github.com/discourse/discourse-canned-replies.git + - git clone --depth 1 https://github.com/discourse/discourse-reactions.git + - git clone --depth 1 https://github.com/discourse/discourse-prometheus.git + - git clone --depth 1 https://github.com/discourse/discourse-translator.git + - exec: + cd: $home + cmd: + - git fetch --depth=1 origin tag v2.8.7 --no-tags + - git checkout v2.8.7 + after_ssl: + - replace: + filename: "/etc/nginx/conf.d/discourse.conf" + from: /listen 80;/ + to: | + listen 80; + rewrite ^/\.well-known/acme-challenge/(.*)$ http://acme.openstreetmap.org/.well-known/acme-challenge/$1 permanent; + + - replace: + filename: "/etc/nginx/conf.d/discourse.conf" + from: /add_header.+/ + to: | + add_header Strict-Transport-Security 'max-age=63072000'; diff --git a/cookbooks/db/metadata.rb b/cookbooks/db/metadata.rb index aadfe47db..d52927a75 100644 --- a/cookbooks/db/metadata.rb +++ b/cookbooks/db/metadata.rb @@ -10,4 +10,5 @@ depends "accounts" depends "git" depends "postgresql" depends "python" +depends "ruby" depends "web" diff --git a/cookbooks/db/recipes/base.rb b/cookbooks/db/recipes/base.rb index 617392701..520fbe2e8 100644 --- a/cookbooks/db/recipes/base.rb +++ b/cookbooks/db/recipes/base.rb @@ -21,15 +21,11 @@ include_recipe "accounts" include_recipe "git" include_recipe "postgresql" include_recipe "python" +include_recipe "ruby" passwords = data_bag_item("db", "passwords") wal_secrets = data_bag_item("db", "wal-secrets") -ruby_version = node[:passenger][:ruby_version] -db_version = node[:db][:cluster].split("/").first -pg_config = "/usr/lib/postgresql/#{db_version}/bin/pg_config" -function_directory = "/srv/www.openstreetmap.org/rails/db/functions/#{db_version}" - postgresql_munin "openstreetmap" do cluster node[:db][:cluster] database "openstreetmap" @@ -41,7 +37,6 @@ directory "/srv/www.openstreetmap.org" do end rails_port "www.openstreetmap.org" do - ruby ruby_version directory "/srv/www.openstreetmap.org/rails" user "rails" group "rails" @@ -52,29 +47,6 @@ rails_port "www.openstreetmap.org" do database_name "openstreetmap" database_username "openstreetmap" database_password passwords["openstreetmap"] - gpx_dir "/store/rails/gpx" -end - -directory function_directory do - owner "rails" - group "rails" - mode "755" -end - -execute function_directory do - action :nothing - command "make BUNDLE=bundle#{ruby_version} PG_CONFIG=#{pg_config} DESTDIR=#{function_directory}" - cwd "/srv/www.openstreetmap.org/rails/db/functions" - user "rails" - group "rails" - subscribes :run, "directory[#{function_directory}]" - subscribes :run, "git[/srv/www.openstreetmap.org/rails]" -end - -link "/usr/lib/postgresql/#{db_version}/lib/libpgosm.so" do - to "#{function_directory}/libpgosm.so" - owner "root" - group "root" end package %w[ @@ -93,40 +65,68 @@ package %w[ git "/opt/osmdbt" do action :sync repository "https://github.com/openstreetmap/osmdbt.git" - revision "v0.2" + revision "v0.5" depth 1 user "root" group "root" end -directory "/opt/osmdbt/build-#{db_version}" do - owner "root" - group "root" - mode "755" -end - -execute "/opt/osmdbt/CMakeLists.txt" do - action :nothing - command "cmake -DPG_CONFIG=/usr/lib/postgresql/#{db_version}/bin/pg_config .." - cwd "/opt/osmdbt/build-#{db_version}" - user "root" - group "root" - subscribes :run, "git[/opt/osmdbt]" -end - -execute "/opt/osmdbt/build-#{db_version}/postgresql-plugin/Makefile" do - action :nothing - command "make" - cwd "/opt/osmdbt/build-#{db_version}/postgresql-plugin" - user "root" - group "root" - subscribes :run, "execute[/opt/osmdbt/CMakeLists.txt]" -end - -link "/usr/lib/postgresql/#{db_version}/lib/osm-logical.so" do - to "/opt/osmdbt/build-#{db_version}/postgresql-plugin/osm-logical.so" - owner "root" - group "root" +node[:postgresql][:versions].each do |db_version| + pg_config = "/usr/lib/postgresql/#{db_version}/bin/pg_config" + function_directory = "/srv/www.openstreetmap.org/rails/db/functions/#{db_version}" + + directory function_directory do + owner "rails" + group "rails" + mode "755" + end + + execute function_directory do + action :nothing + command "make BUNDLE=#{node[:ruby][:bundle]} PG_CONFIG=#{pg_config} DESTDIR=#{function_directory}" + cwd "/srv/www.openstreetmap.org/rails/db/functions" + user "rails" + group "rails" + subscribes :run, "directory[#{function_directory}]" + subscribes :run, "git[/srv/www.openstreetmap.org/rails]" + end + + link "/usr/lib/postgresql/#{db_version}/lib/libpgosm.so" do + to "#{function_directory}/libpgosm.so" + owner "root" + group "root" + end + + directory "/opt/osmdbt/build-#{db_version}" do + owner "root" + group "root" + mode "755" + end + + execute "/opt/osmdbt/build-#{db_version}" do + action :nothing + command "cmake -DPG_CONFIG=/usr/lib/postgresql/#{db_version}/bin/pg_config .." + cwd "/opt/osmdbt/build-#{db_version}" + user "root" + group "root" + subscribes :run, "directory[/opt/osmdbt/build-#{db_version}]" + subscribes :run, "git[/opt/osmdbt]" + end + + execute "/opt/osmdbt/build-#{db_version}/postgresql-plugin/Makefile" do + action :nothing + command "make" + cwd "/opt/osmdbt/build-#{db_version}/postgresql-plugin" + user "root" + group "root" + subscribes :run, "execute[/opt/osmdbt/build-#{db_version}]" + end + + link "/usr/lib/postgresql/#{db_version}/lib/osm-logical.so" do + to "/opt/osmdbt/build-#{db_version}/postgresql-plugin/osm-logical.so" + owner "root" + group "root" + end end package "lzop" @@ -146,3 +146,19 @@ template "/usr/local/bin/openstreetmap-wal-e" do mode "750" variables :s3_key => wal_secrets["s3_key"] end + +remote_file "/usr/local/bin/wal-g" do + action :create + source "https://github.com/wal-g/wal-g/releases/download/v1.1/wal-g-pg-ubuntu-20.04-amd64" + owner "root" + group "root" + mode "755" +end + +template "/usr/local/bin/openstreetmap-wal-g" do + source "wal-g.erb" + owner "root" + group "postgres" + mode "750" + variables :s3_key => wal_secrets["s3_key"] +end diff --git a/cookbooks/db/templates/default/wal-g.erb b/cookbooks/db/templates/default/wal-g.erb new file mode 100644 index 000000000..867bdacfc --- /dev/null +++ b/cookbooks/db/templates/default/wal-g.erb @@ -0,0 +1,10 @@ +#!/bin/sh + +# DO NOT EDIT - This file is being maintained by Chef + +export WALE_S3_PREFIX="s3://openstreetmap-wal/" +export AWS_ACCESS_KEY_ID="AKIAIQX2LTDOBIW4CZUQ" +export AWS_SECRET_ACCESS_KEY="<%= @s3_key %>" +export AWS_REGION="eu-west-2" + +exec /usr/local/bin/wal-g "$@" < /dev/null diff --git a/cookbooks/dev/metadata.rb b/cookbooks/dev/metadata.rb index 457e46dd0..29e665a43 100644 --- a/cookbooks/dev/metadata.rb +++ b/cookbooks/dev/metadata.rb @@ -18,5 +18,6 @@ depends "nodejs" depends "php" depends "postgresql" depends "python" +depends "ruby" depends "tools" depends "web" diff --git a/cookbooks/dev/recipes/default.rb b/cookbooks/dev/recipes/default.rb index e4a977f8a..d2477273d 100644 --- a/cookbooks/dev/recipes/default.rb +++ b/cookbooks/dev/recipes/default.rb @@ -31,6 +31,7 @@ include_recipe "nodejs" include_recipe "php::fpm" include_recipe "postgresql" include_recipe "python" +include_recipe "ruby" package %w[ php-cgi @@ -57,6 +58,7 @@ package %w[ autoconf automake libtool + libargon2-dev libfcgi-dev libxml2-dev libmemcached-dev @@ -69,7 +71,10 @@ package %w[ libpqxx-dev libcrypto++-dev libyajl-dev + libfmt-dev zlib1g-dev + nano + osm2pgsql ] nodejs_package "svgo" @@ -201,9 +206,9 @@ search(:accounts, "*:*").each do |account| end end -if node[:postgresql][:clusters][:"12/main"] +if node[:postgresql][:clusters][:"14/main"] postgresql_user "apis" do - cluster "12/main" + cluster "14/main" end template "/usr/local/bin/cleanup-rails-assets" do @@ -214,14 +219,12 @@ if node[:postgresql][:clusters][:"12/main"] mode "755" end - ruby_version = node[:passenger][:ruby_version] - systemd_service "rails-jobs@" do description "Rails job queue runner" type "simple" user "apis" working_directory "/srv/%i.apis.dev.openstreetmap.org/rails" - exec_start "/usr/local/bin/bundle#{ruby_version} exec rake jobs:work" + exec_start "#{node[:ruby][:bundle]} exec rails jobs:work" restart "on-failure" private_tmp true private_devices true @@ -247,6 +250,10 @@ if node[:postgresql][:clusters][:"12/main"] cgimap_port = 9000 + Dir.glob("/srv/*.apis.dev.openstreetmap.org").each do |dir| + node.default_unless[:dev][:rails][File.basename(dir).split(".").first] = {} + end + node[:dev][:rails].each do |name, details| database_name = details[:database] || "apis_#{name}" site_name = "#{name}.apis.dev.openstreetmap.org" @@ -261,12 +268,12 @@ if node[:postgresql][:clusters][:"12/main"] secret_key_base = persistent_token("dev", "rails", name, "secret_key_base") postgresql_database database_name do - cluster "12/main" + cluster "14/main" owner "apis" end postgresql_extension "#{database_name}_btree_gist" do - cluster "12/main" + cluster "14/main" database database_name extension "btree_gist" end @@ -302,13 +309,12 @@ if node[:postgresql][:clusters][:"12/main"] end rails_port site_name do - ruby ruby_version directory rails_directory user "apis" group "apis" repository details[:repository] revision details[:revision] - database_port node[:postgresql][:clusters][:"12/main"][:port] + database_port node[:postgresql][:clusters][:"14/main"][:port] database_name database_name database_username "apis" email_from "OpenStreetMap " @@ -352,7 +358,7 @@ if node[:postgresql][:clusters][:"12/main"] cwd cgimap_directory user "apis" group "apis" - subscribes :run, "git[#{cgimap_directory}]", :immediate + subscribes :run, "git[#{cgimap_directory}]", :immediately end execute "#{cgimap_directory}/configure" do @@ -361,7 +367,7 @@ if node[:postgresql][:clusters][:"12/main"] cwd cgimap_directory user "apis" group "apis" - subscribes :run, "execute[#{cgimap_directory}/autogen.sh]", :immediate + subscribes :run, "execute[#{cgimap_directory}/autogen.sh]", :immediately end execute "#{cgimap_directory}/Makefile" do @@ -370,7 +376,7 @@ if node[:postgresql][:clusters][:"12/main"] cwd cgimap_directory user "apis" group "apis" - subscribes :run, "execute[#{cgimap_directory}/configure]", :immediate + subscribes :run, "execute[#{cgimap_directory}/configure]", :immediately notifies :restart, "service[cgimap@#{name}]" end @@ -380,7 +386,7 @@ if node[:postgresql][:clusters][:"12/main"] group "root" mode "640" variables :cgimap_port => cgimap_port, - :database_port => node[:postgresql][:clusters][:"12/main"][:port], + :database_port => node[:postgresql][:clusters][:"14/main"][:port], :database_name => database_name, :log_directory => log_directory notifies :restart, "service[cgimap@#{name}]" @@ -433,6 +439,10 @@ if node[:postgresql][:clusters][:"12/main"] action :delete end + service "rails-jobs@#{name}" do + action [:stop, :disable] + end + directory site_directory do action :delete recursive true @@ -444,7 +454,7 @@ if node[:postgresql][:clusters][:"12/main"] postgresql_database database_name do action :drop - cluster "12/main" + cluster "14/main" end end end diff --git a/cookbooks/dev/templates/default/cgimap.environment.erb b/cookbooks/dev/templates/default/cgimap.environment.erb index b9f71ee7a..743599b52 100644 --- a/cookbooks/dev/templates/default/cgimap.environment.erb +++ b/cookbooks/dev/templates/default/cgimap.environment.erb @@ -8,3 +8,7 @@ CGIMAP_LOGFILE="<%= @log_directory %>/cgimap.log" CGIMAP_MEMCACHE="127.0.0.1" CGIMAP_RATELIMIT="204800" CGIMAP_MAXDEBT="250" +CGIMAP_MAP_AREA="<%= node[:web][:max_request_area] %>" +CGIMAP_MAP_NODES"<%= node[:web][:max_number_of_nodes] %>" +CGIMAP_MAX_WAY_NODES="<%= node[:web][:max_number_of_way_nodes] %>" +CGIMAP_MAX_RELATION_MEMBERS="<%= node[:web][:max_number_of_relation_members] %>" diff --git a/cookbooks/dev/templates/default/dev.html.erb b/cookbooks/dev/templates/default/dev.html.erb index 3b4ab2fba..f1ec14248 100644 --- a/cookbooks/dev/templates/default/dev.html.erb +++ b/cookbooks/dev/templates/default/dev.html.erb @@ -5,6 +5,6 @@ You've reached errol, the OpenStreetMap dev server.
If you are a user...
You probably want OpenStreetMap itself.
If you are a developer...
-
You might be interested in live instances of various Rails Port code branches in SVN for testing clients against.
+
You might be interested in live instances of various Rails Port code branches for testing clients against.
diff --git a/cookbooks/dev/templates/default/rails.setup.rb.erb b/cookbooks/dev/templates/default/rails.setup.rb.erb index ad42b68f7..c25ea13e2 100644 --- a/cookbooks/dev/templates/default/rails.setup.rb.erb +++ b/cookbooks/dev/templates/default/rails.setup.rb.erb @@ -51,4 +51,36 @@ OpenStreetMap::Application.config.after_initialize do OAUTH_KEY = website.key end end + + if ActiveRecord::Base.connection.table_exists?(:oauth_applications) + unless id = webmaster.oauth2_applications.find_by_name("iD") + id = webmaster.oauth2_applications.new + id.name = "iD" + id.redirect_uri = "https://<%= @site %>/id" + id.scopes = Oauth.scopes.map(&:name) + id.confidential = true + id.save! + end + + if Kernel.const_defined?("Settings") + Settings.id_application = id.uid + else + ID_APPLICATION = id.uid + end + + unless website = webmaster.oauth2_applications.find_by_name("Web Site") + website = webmaster.oauth2_applications.new + website.name = "Web Site" + website.redirect_uri = "https://<%= @site %>/" + website.scopes = Oauth.scopes.map(&:name) + website.confidential = true + website.save! + end + + if Kernel.const_defined?("Settings") + Settings.oauth_application = website.uid + else + OAUTH_APPLICATION = website.uid + end + end end diff --git a/cookbooks/devices/templates/default/udev.rules.erb b/cookbooks/devices/templates/default/udev.rules.erb index 2c687566c..be9903891 100644 --- a/cookbooks/devices/templates/default/udev.rules.erb +++ b/cookbooks/devices/templates/default/udev.rules.erb @@ -92,6 +92,9 @@ SUBSYSTEM=="net", ACTION=="add", ATTRS{vendor}=="0x8086", ATTRS{device}=="0x1f41 # Ethernet controller: Intel Corporation Ethernet Connection X722 for 10GBASE-T SUBSYSTEM=="net", ACTION=="add", ATTRS{vendor}=="0x8086", ATTRS{device}=="0x37d2", RUN+="/sbin/ethtool -G $name rx 4096 tx 4096" +# Disable Firmware Based LLDP handler +SUBSYSTEM=="net", ACTION=="add", ENV{INTERFACE}=="*", DRIVERS=="i40e", RUN+="/sbin/ethtool --set-priv-flags $name disable-fw-lldp on" + # Workaround unreliable Western Digital WD RE3/RE4 disks (ATA only) # Set sufficent Linux subsystem timeout and fix severe NCQ performance issue ACTION=="add", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", ENV{ID_BUS}=="ata", ENV{ID_MODEL}=="WDC_WD5002ABYS-02B1B0", ATTR{device/timeout}="90", ATTR{device/queue_depth}="1", ATTR{queue/nr_requests}="256" diff --git a/cookbooks/dhcpd/recipes/default.rb b/cookbooks/dhcpd/recipes/default.rb index a8f0dd6f7..4304ce006 100644 --- a/cookbooks/dhcpd/recipes/default.rb +++ b/cookbooks/dhcpd/recipes/default.rb @@ -19,7 +19,31 @@ include_recipe "networking" -package "isc-dhcp-server" +package %w[ + isc-dhcp-server + tftpd-hpa +] + +service "tftpd-hpa" do + action [:enable, :start] + supports :status => true, :restart => true +end + +remote_file "/srv/tftp/netboot.xyz.efi" do + action :create + source "https://boot.netboot.xyz/ipxe/netboot.xyz.efi" + owner "root" + group "root" + mode "644" +end + +remote_file "/srv/tftp/netboot.xyz.kpxe" do + action :create + source "https://boot.netboot.xyz/ipxe/netboot.xyz.kpxe" + owner "root" + group "root" + mode "644" +end domain = "#{node[:networking][:roles][:external][:zone]}.openstreetmap.org" @@ -36,3 +60,7 @@ service "isc-dhcp-server" do supports :status => true, :restart => true subscribes :restart, "template[/etc/dhcp/dhcpd.conf]" end + +service "isc-dhcp-server6" do + action [:disable, :stop] +end diff --git a/cookbooks/dhcpd/templates/default/dhcpd.conf.erb b/cookbooks/dhcpd/templates/default/dhcpd.conf.erb index af2496dec..b5c8dae33 100644 --- a/cookbooks/dhcpd/templates/default/dhcpd.conf.erb +++ b/cookbooks/dhcpd/templates/default/dhcpd.conf.erb @@ -1,5 +1,7 @@ # DO NOT EDIT - This file is being maintained by Chef +option architecture-type code 93 = unsigned integer 16; + default-lease-time 600; max-lease-time 7200; <% node.interfaces(:role => :internal).each do |interface| -%> @@ -12,9 +14,26 @@ subnet <%= interface[:network] %> netmask <%= interface[:netmask] %> { option domain-name "<%= @domain %>"; option domain-name-servers <%= interface[:gateway] %>; option ntp-servers <%= node[:ntp][:servers].first %>; + + class "pxeclients" { + match if substring (option vendor-class-identifier, 0, 9) = "PXEClient"; + next-server <%= interface[:gateway] %>; + + if option architecture-type = 00:07 { + filename "netboot.xyz.efi"; + } else { + filename "netboot.xyz.kpxe"; + } + } } <% end -%> +host oob1.ams.openstreetmap.org { + hardware ethernet ea:e4:8e:c2:5b:19; + server-name "oob1.ams.openstreetmap.org"; + fixed-address oob1.ams.openstreetmap.org; +} + host pdu1.ams.openstreetmap.org { hardware ethernet 00:c0:b7:e3:e8:f2; server-name "pdu1.ams.openstreetmap.org"; @@ -27,12 +46,36 @@ host pdu2.ams.openstreetmap.org { fixed-address pdu2.ams.openstreetmap.org; } +host oob1.dub.openstreetmap.org { + hardware ethernet 62:bd:62:a6:05:25; + server-name "oob1.dub.openstreetmap.org"; + fixed-address oob1.dub.openstreetmap.org; +} + +host pdu1.dub.openstreetmap.org { + hardware ethernet 28:29:86:48:f7:f5; + server-name "pdu1.dub.openstreetmap.org"; + fixed-address pdu1.dub.openstreetmap.org; +} + +host pdu2.dub.openstreetmap.org { + hardware ethernet 28:29:86:48:f8:64; + server-name "pdu2.dub.openstreetmap.org"; + fixed-address pdu2.dub.openstreetmap.org; +} + host clifford.oob.openstreetmap.org { hardware ethernet 1c:c1:de:78:20:d6; server-name "clifford.oob.openstreetmap.org"; fixed-address clifford.oob.openstreetmap.org; } +host culebre.oob.openstreetmap.org { + hardware ethernet 3c:ec:ef:2f:29:41; + server-name "culebre.oob.openstreetmap.org"; + fixed-address culebre.oob.openstreetmap.org; +} + host draco.oob.openstreetmap.org { hardware ethernet 9c:8e:99:25:99:7d; server-name "draco.oob.openstreetmap.org"; @@ -63,60 +106,102 @@ host eustace.oob.openstreetmap.org { fixed-address eustace.oob.openstreetmap.org; } +host fafnir.oob.openstreetmap.org { + hardware ethernet 38:63:bb:39:f0:96; + server-name "fafnir.oob.openstreetmap.org"; + fixed-address fafnir.oob.openstreetmap.org; +} + +host gorwen.oob.openstreetmap.org { + hardware ethernet d8:9d:67:5f:bd:bc; + server-name "gorwen.oob.openstreetmap.org"; + fixed-address gorwen.oob.openstreetmap.org; +} + host grindtooth.oob.openstreetmap.org { hardware ethernet 98:4b:e1:6d:77:85; server-name "grindtooth.oob.openstreetmap.org"; fixed-address grindtooth.oob.openstreetmap.org; } +host horntail.oob.openstreetmap.org { + hardware ethernet 3c:ec:ef:82:ac:d2; + server-name "horntail.oob.openstreetmap.org"; + fixed-address horntail.oob.openstreetmap.org; +} + +host idris.oob.openstreetmap.org { + hardware ethernet 94:57:a5:50:b5:a0; + server-name "idris.oob.openstreetmap.org"; + fixed-address idris.oob.openstreetmap.org; +} + host ironbelly.oob.openstreetmap.org { hardware ethernet 00:25:90:cd:14:84; server-name "ironbelly.oob.openstreetmap.org"; fixed-address ironbelly.oob.openstreetmap.org; } +host jakelong.oob.openstreetmap.org { + hardware ethernet d8:9d:67:66:02:9e; + server-name "jakelong.oob.openstreetmap.org"; + fixed-address jakelong.oob.openstreetmap.org; +} + host karm.oob.openstreetmap.org { hardware ethernet 0c:c4:7a:67:cf:c4; server-name "karm.oob.openstreetmap.org"; fixed-address karm.oob.openstreetmap.org; } +host konqi.oob.openstreetmap.org { + hardware ethernet ec:b1:d7:7a:ea:64; + server-name "konqi.oob.openstreetmap.org"; + fixed-address konqi.oob.openstreetmap.org; +} + +host lockheed.oob.openstreetmap.org { + hardware ethernet 44:1e:a1:57:8f:fe; + server-name "lockheed.oob.openstreetmap.org"; + fixed-address lockheed.oob.openstreetmap.org; +} + +host longma.oob.openstreetmap.org { + hardware ethernet 3c:ec:ef:2f:6d:4e; + server-name "longma.oob.openstreetmap.org"; + fixed-address longma.oob.openstreetmap.org; +} + +host naga.oob.openstreetmap.org { + hardware ethernet 94:57:a5:5f:11:f2; + server-name "naga.oob.openstreetmap.org"; + fixed-address naga.oob.openstreetmap.org; +} + host noquiklos.oob.openstreetmap.org { hardware ethernet 18:a9:05:70:b0:1e; server-name "noquiklos.oob.openstreetmap.org"; fixed-address noquiklos.oob.openstreetmap.org; } +host norbert.oob.openstreetmap.org { + hardware ethernet 3c:ec:ef:82:ac:cf; + server-name "norbert.oob.openstreetmap.org"; + fixed-address norbert.oob.openstreetmap.org; +} + host odin.oob.openstreetmap.org { hardware ethernet ac:1f:6b:c0:59:a3; server-name "odin.oob.openstreetmap.org"; fixed-address odin.oob.openstreetmap.org; } -host orm.oob.openstreetmap.org { - hardware ethernet 00:e0:81:c5:26:80; - server-name "orm.oob.openstreetmap.org"; - fixed-address orm.oob.openstreetmap.org; -} - -host ouroboros.oob.openstreetmap.org { - hardware ethernet d4:85:64:4c:3d:00; - server-name "ouroboros.oob.openstreetmap.org"; - fixed-address ouroboros.oob.openstreetmap.org; -} - host pummelzacken.oob.openstreetmap.org { hardware ethernet 00:25:90:cf:72:73; server-name "pummelzacken.oob.openstreetmap.org"; fixed-address pummelzacken.oob.openstreetmap.org; } -host ramoth.oob.openstreetmap.org { - hardware ethernet 0c:c4:7a:af:75:eb; - server-name "ramoth.oob.openstreetmap.org"; - fixed-address ramoth.oob.openstreetmap.org; -} - host ridley.oob.openstreetmap.org { hardware ethernet d4:85:64:52:2d:d8; server-name "ridley.oob.openstreetmap.org"; @@ -141,6 +226,12 @@ host snap-02.oob.openstreetmap.org { fixed-address snap-02.oob.openstreetmap.org; } +host snap-03.oob.openstreetmap.org { + hardware ethernet 3c:ec:ef:82:ab:f2; + server-name "snap-03.oob.openstreetmap.org"; + fixed-address snap-03.oob.openstreetmap.org; +} + host smaug.oob.openstreetmap.org { hardware ethernet 00:30:48:9d:57:ff; server-name "smaug.oob.openstreetmap.org"; @@ -148,19 +239,19 @@ host smaug.oob.openstreetmap.org { } host spike-01.oob.openstreetmap.org { - hardware ethernet 1c:c1:de:e8:1a:1c; + hardware ethernet 3c:a8:2a:11:78:d6; server-name "spike-01.oob.openstreetmap.org"; fixed-address spike-01.oob.openstreetmap.org; } host spike-02.oob.openstreetmap.org { - hardware ethernet 68:b5:99:af:d6:9c; + hardware ethernet 14:58:d0:5d:74:44; server-name "spike-02.oob.openstreetmap.org"; fixed-address spike-02.oob.openstreetmap.org; } host spike-03.oob.openstreetmap.org { - hardware ethernet 1c:c1:de:79:61:98; + hardware ethernet 38:63:bb:3a:b0:ce; server-name "spike-03.oob.openstreetmap.org"; fixed-address spike-03.oob.openstreetmap.org; } @@ -249,12 +340,6 @@ host tiamat-23.oob.openstreetmap.org { fixed-address tiamat-23.oob.openstreetmap.org; } -host thorn-01.oob.openstreetmap.org { - hardware ethernet 44:1e:a1:57:8f:fe; - server-name "thorn-01.oob.openstreetmap.org"; - fixed-address thorn-01.oob.openstreetmap.org; -} - host thorn-02.oob.openstreetmap.org { hardware ethernet e4:11:5b:ce:e8:aa; server-name "thorn-02.oob.openstreetmap.org"; diff --git a/cookbooks/dmca/files/default/html/HTML/Common.php b/cookbooks/dmca/files/default/html/HTML/Common.php deleted file mode 100644 index 8823ea4f7..000000000 --- a/cookbooks/dmca/files/default/html/HTML/Common.php +++ /dev/null @@ -1,465 +0,0 @@ - - * @copyright 2001-2009 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id: Common.php,v 1.15 2009/04/03 15:26:22 avb Exp $ - * @link http://pear.php.net/package/HTML_Common/ - */ - -/** - * Base class for all HTML classes - * - * @category HTML - * @package HTML_Common - * @author Adam Daniel - * @version Release: 1.2.5 - * @abstract - */ -class HTML_Common -{ - /** - * Associative array of attributes - * @var array - * @access private - */ - var $_attributes = array(); - - /** - * Tab offset of the tag - * @var int - * @access private - */ - var $_tabOffset = 0; - - /** - * Tab string - * @var string - * @since 1.7 - * @access private - */ - var $_tab = "\11"; - - /** - * Contains the line end string - * @var string - * @since 1.7 - * @access private - */ - var $_lineEnd = "\12"; - - /** - * HTML comment on the object - * @var string - * @since 1.5 - * @access private - */ - var $_comment = ''; - - /** - * Class constructor - * @param mixed $attributes Associative array of table tag attributes - * or HTML attributes name="value" pairs - * @param int $tabOffset Indent offset in tabs - * @access public - */ - function HTML_Common($attributes = null, $tabOffset = 0) - { - $this->setAttributes($attributes); - $this->setTabOffset($tabOffset); - } // end constructor - - /** - * Returns the current API version - * @access public - * @returns double - */ - function apiVersion() - { - return 1.7; - } // end func apiVersion - - /** - * Returns the lineEnd - * - * @since 1.7 - * @access private - * @return string - */ - function _getLineEnd() - { - return $this->_lineEnd; - } // end func getLineEnd - - /** - * Returns a string containing the unit for indenting HTML - * - * @since 1.7 - * @access private - * @return string - */ - function _getTab() - { - return $this->_tab; - } // end func _getTab - - /** - * Returns a string containing the offset for the whole HTML code - * - * @return string - * @access private - */ - function _getTabs() - { - return str_repeat($this->_getTab(), $this->_tabOffset); - } // end func _getTabs - - /** - * Returns an HTML formatted attribute string - * @param array $attributes - * @return string - * @access private - */ - function _getAttrString($attributes) - { - $strAttr = ''; - - if (is_array($attributes)) { - $charset = HTML_Common::charset(); - foreach ($attributes as $key => $value) { - $strAttr .= ' ' . $key . '="' . htmlspecialchars($value, ENT_COMPAT, $charset) . '"'; - } - } - return $strAttr; - } // end func _getAttrString - - /** - * Returns a valid atrributes array from either a string or array - * @param mixed $attributes Either a typical HTML attribute string or an associative array - * @access private - * @return array - */ - function _parseAttributes($attributes) - { - if (is_array($attributes)) { - $ret = array(); - foreach ($attributes as $key => $value) { - if (is_int($key)) { - $key = $value = strtolower($value); - } else { - $key = strtolower($key); - } - $ret[$key] = $value; - } - return $ret; - - } elseif (is_string($attributes)) { - $preg = "/(([A-Za-z_:]|[^\\x00-\\x7F])([A-Za-z0-9_:.-]|[^\\x00-\\x7F])*)" . - "([ \\n\\t\\r]+)?(=([ \\n\\t\\r]+)?(\"[^\"]*\"|'[^']*'|[^ \\n\\t\\r]*))?/"; - if (preg_match_all($preg, $attributes, $regs)) { - for ($counter=0; $counter $value) { - $attr1[$key] = $value; - } - } // end func _updateAtrrArray - - /** - * Removes the given attribute from the given array - * - * @param string $attr Attribute name - * @param array $attributes Attribute array - * @since 1.4 - * @access private - * @return void - */ - function _removeAttr($attr, &$attributes) - { - $attr = strtolower($attr); - if (isset($attributes[$attr])) { - unset($attributes[$attr]); - } - } //end func _removeAttr - - /** - * Returns the value of the given attribute - * - * @param string $attr Attribute name - * @since 1.5 - * @access public - * @return string|null returns null if an attribute does not exist - */ - function getAttribute($attr) - { - $attr = strtolower($attr); - if (isset($this->_attributes[$attr])) { - return $this->_attributes[$attr]; - } - return null; - } //end func getAttribute - - /** - * Sets the value of the attribute - * - * @param string Attribute name - * @param string Attribute value (will be set to $name if omitted) - * @access public - */ - function setAttribute($name, $value = null) - { - $name = strtolower($name); - if (is_null($value)) { - $value = $name; - } - $this->_attributes[$name] = $value; - } // end func setAttribute - - /** - * Sets the HTML attributes - * @param mixed $attributes Either a typical HTML attribute string or an associative array - * @access public - */ - function setAttributes($attributes) - { - $this->_attributes = $this->_parseAttributes($attributes); - } // end func setAttributes - - /** - * Returns the assoc array (default) or string of attributes - * - * @param bool Whether to return the attributes as string - * @since 1.6 - * @access public - * @return mixed attributes - */ - function getAttributes($asString = false) - { - if ($asString) { - return $this->_getAttrString($this->_attributes); - } else { - return $this->_attributes; - } - } //end func getAttributes - - /** - * Updates the passed attributes without changing the other existing attributes - * @param mixed $attributes Either a typical HTML attribute string or an associative array - * @access public - */ - function updateAttributes($attributes) - { - $this->_updateAttrArray($this->_attributes, $this->_parseAttributes($attributes)); - } // end func updateAttributes - - /** - * Removes an attribute - * - * @param string $attr Attribute name - * @since 1.4 - * @access public - * @return void - */ - function removeAttribute($attr) - { - $this->_removeAttr($attr, $this->_attributes); - } //end func removeAttribute - - /** - * Sets the line end style to Windows, Mac, Unix or a custom string. - * - * @param string $style "win", "mac", "unix" or custom string. - * @since 1.7 - * @access public - * @return void - */ - function setLineEnd($style) - { - switch ($style) { - case 'win': - $this->_lineEnd = "\15\12"; - break; - case 'unix': - $this->_lineEnd = "\12"; - break; - case 'mac': - $this->_lineEnd = "\15"; - break; - default: - $this->_lineEnd = $style; - } - } // end func setLineEnd - - /** - * Sets the tab offset - * - * @param int $offset - * @access public - */ - function setTabOffset($offset) - { - $this->_tabOffset = $offset; - } // end func setTabOffset - - /** - * Returns the tabOffset - * - * @since 1.5 - * @access public - * @return int - */ - function getTabOffset() - { - return $this->_tabOffset; - } //end func getTabOffset - - /** - * Sets the string used to indent HTML - * - * @since 1.7 - * @param string $string String used to indent ("\11", "\t", ' ', etc.). - * @access public - * @return void - */ - function setTab($string) - { - $this->_tab = $string; - } // end func setTab - - /** - * Sets the HTML comment to be displayed at the beginning of the HTML string - * - * @param string - * @since 1.4 - * @access public - * @return void - */ - function setComment($comment) - { - $this->_comment = $comment; - } // end func setHtmlComment - - /** - * Returns the HTML comment - * - * @since 1.5 - * @access public - * @return string - */ - function getComment() - { - return $this->_comment; - } //end func getComment - - /** - * Abstract method. Must be extended to return the objects HTML - * - * @access public - * @return string - * @abstract - */ - function toHtml() - { - return ''; - } // end func toHtml - - /** - * Displays the HTML to the screen - * - * @access public - */ - function display() - { - print $this->toHtml(); - } // end func display - - /** - * Sets the charset to use by htmlspecialchars() function - * - * Since this parameter is expected to be global, the function is designed - * to be called statically: - * - * HTML_Common::charset('utf-8'); - * - * or - * - * $charset = HTML_Common::charset(); - * - * - * @param string New charset to use. Omit if just getting the - * current value. Consult the htmlspecialchars() docs - * for a list of supported character sets. - * @return string Current charset - * @access public - * @static - */ - function charset($newCharset = null) - { - static $charset = 'ISO-8859-1'; - - if (!is_null($newCharset)) { - $charset = $newCharset; - } - return $charset; - } // end func charset -} // end class HTML_Common -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm.php b/cookbooks/dmca/files/default/html/HTML/QuickForm.php deleted file mode 100644 index f769b1f21..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm.php +++ /dev/null @@ -1,2073 +0,0 @@ - - * @author Bertrand Mansion - * @author Alexey Borzov - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * PEAR and PEAR_Error classes, for error handling - */ -require_once 'PEAR.php'; -/** - * Base class for all HTML classes - */ -require_once 'HTML/Common.php'; -/** - * Static utility methods - */ -require_once 'HTML/QuickForm/utils.php'; - -/** - * Element types known to HTML_QuickForm - * @see HTML_QuickForm::registerElementType(), HTML_QuickForm::getRegisteredTypes(), - * HTML_QuickForm::isTypeRegistered() - * @global array $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'] - */ -$GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'] = - array( - 'group' =>array('HTML/QuickForm/group.php','HTML_QuickForm_group'), - 'hidden' =>array('HTML/QuickForm/hidden.php','HTML_QuickForm_hidden'), - 'reset' =>array('HTML/QuickForm/reset.php','HTML_QuickForm_reset'), - 'checkbox' =>array('HTML/QuickForm/checkbox.php','HTML_QuickForm_checkbox'), - 'file' =>array('HTML/QuickForm/file.php','HTML_QuickForm_file'), - 'image' =>array('HTML/QuickForm/image.php','HTML_QuickForm_image'), - 'password' =>array('HTML/QuickForm/password.php','HTML_QuickForm_password'), - 'radio' =>array('HTML/QuickForm/radio.php','HTML_QuickForm_radio'), - 'button' =>array('HTML/QuickForm/button.php','HTML_QuickForm_button'), - 'submit' =>array('HTML/QuickForm/submit.php','HTML_QuickForm_submit'), - 'select' =>array('HTML/QuickForm/select.php','HTML_QuickForm_select'), - 'hiddenselect' =>array('HTML/QuickForm/hiddenselect.php','HTML_QuickForm_hiddenselect'), - 'text' =>array('HTML/QuickForm/text.php','HTML_QuickForm_text'), - 'textarea' =>array('HTML/QuickForm/textarea.php','HTML_QuickForm_textarea'), - 'link' =>array('HTML/QuickForm/link.php','HTML_QuickForm_link'), - 'advcheckbox' =>array('HTML/QuickForm/advcheckbox.php','HTML_QuickForm_advcheckbox'), - 'date' =>array('HTML/QuickForm/date.php','HTML_QuickForm_date'), - 'static' =>array('HTML/QuickForm/static.php','HTML_QuickForm_static'), - 'header' =>array('HTML/QuickForm/header.php', 'HTML_QuickForm_header'), - 'html' =>array('HTML/QuickForm/html.php', 'HTML_QuickForm_html'), - 'hierselect' =>array('HTML/QuickForm/hierselect.php', 'HTML_QuickForm_hierselect'), - 'autocomplete' =>array('HTML/QuickForm/autocomplete.php', 'HTML_QuickForm_autocomplete'), - 'xbutton' =>array('HTML/QuickForm/xbutton.php','HTML_QuickForm_xbutton') - ); - -/** - * Validation rules known to HTML_QuickForm - * @see HTML_QuickForm::registerRule(), HTML_QuickForm::getRegisteredRules(), - * HTML_QuickForm::isRuleRegistered() - * @global array $GLOBALS['_HTML_QuickForm_registered_rules'] - */ -$GLOBALS['_HTML_QuickForm_registered_rules'] = array( - 'required' => array('html_quickform_rule_required', 'HTML/QuickForm/Rule/Required.php'), - 'maxlength' => array('html_quickform_rule_range', 'HTML/QuickForm/Rule/Range.php'), - 'minlength' => array('html_quickform_rule_range', 'HTML/QuickForm/Rule/Range.php'), - 'rangelength' => array('html_quickform_rule_range', 'HTML/QuickForm/Rule/Range.php'), - 'email' => array('html_quickform_rule_email', 'HTML/QuickForm/Rule/Email.php'), - 'regex' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), - 'lettersonly' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), - 'alphanumeric' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), - 'numeric' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), - 'nopunctuation' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), - 'nonzero' => array('html_quickform_rule_regex', 'HTML/QuickForm/Rule/Regex.php'), - 'callback' => array('html_quickform_rule_callback', 'HTML/QuickForm/Rule/Callback.php'), - 'compare' => array('html_quickform_rule_compare', 'HTML/QuickForm/Rule/Compare.php') -); - -// {{{ error codes - -/**#@+ - * Error codes for HTML_QuickForm - * - * Codes are mapped to textual messages by errorMessage() method, if you add a - * new code be sure to add a new message for it to errorMessage() - * - * @see HTML_QuickForm::errorMessage() - */ -define('QUICKFORM_OK', 1); -define('QUICKFORM_ERROR', -1); -define('QUICKFORM_INVALID_RULE', -2); -define('QUICKFORM_NONEXIST_ELEMENT', -3); -define('QUICKFORM_INVALID_FILTER', -4); -define('QUICKFORM_UNREGISTERED_ELEMENT', -5); -define('QUICKFORM_INVALID_ELEMENT_NAME', -6); -define('QUICKFORM_INVALID_PROCESS', -7); -define('QUICKFORM_DEPRECATED', -8); -define('QUICKFORM_INVALID_DATASOURCE', -9); -/**#@-*/ - -// }}} - -/** - * Create, validate and process HTML forms - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @author Alexey Borzov - * @version Release: 3.2.16 - */ -class HTML_QuickForm extends HTML_Common -{ - // {{{ properties - - /** - * Array containing the form fields - * @since 1.0 - * @var array - * @access private - */ - var $_elements = array(); - - /** - * Array containing element name to index map - * @since 1.1 - * @var array - * @access private - */ - var $_elementIndex = array(); - - /** - * Array containing indexes of duplicate elements - * @since 2.10 - * @var array - * @access private - */ - var $_duplicateIndex = array(); - - /** - * Array containing required field IDs - * @since 1.0 - * @var array - * @access private - */ - var $_required = array(); - - /** - * Prefix message in javascript alert if error - * @since 1.0 - * @var string - * @access public - */ - var $_jsPrefix = 'Invalid information entered.'; - - /** - * Postfix message in javascript alert if error - * @since 1.0 - * @var string - * @access public - */ - var $_jsPostfix = 'Please correct these fields.'; - - /** - * Datasource object implementing the informal - * datasource protocol - * @since 3.3 - * @var object - * @access private - */ - var $_datasource; - - /** - * Array of default form values - * @since 2.0 - * @var array - * @access private - */ - var $_defaultValues = array(); - - /** - * Array of constant form values - * @since 2.0 - * @var array - * @access private - */ - var $_constantValues = array(); - - /** - * Array of submitted form values - * @since 1.0 - * @var array - * @access private - */ - var $_submitValues = array(); - - /** - * Array of submitted form files - * @since 1.0 - * @var integer - * @access public - */ - var $_submitFiles = array(); - - /** - * Value for maxfilesize hidden element if form contains file input - * @since 1.0 - * @var integer - * @access public - */ - var $_maxFileSize = 1048576; // 1 Mb = 1048576 - - /** - * Flag to know if all fields are frozen - * @since 1.0 - * @var boolean - * @access private - */ - var $_freezeAll = false; - - /** - * Array containing the form rules - * @since 1.0 - * @var array - * @access private - */ - var $_rules = array(); - - /** - * Form rules, global variety - * @var array - * @access private - */ - var $_formRules = array(); - - /** - * Array containing the validation errors - * @since 1.0 - * @var array - * @access private - */ - var $_errors = array(); - - /** - * Note for required fields in the form - * @var string - * @since 1.0 - * @access private - */ - var $_requiredNote = '* denotes required field'; - - /** - * Whether the form was submitted - * @var boolean - * @access private - */ - var $_flagSubmitted = false; - - // }}} - // {{{ constructor - - /** - * Class constructor - * @param string $formName Form's name. - * @param string $method (optional)Form's method defaults to 'POST' - * @param string $action (optional)Form's action - * @param string $target (optional)Form's target defaults to '_self' - * @param mixed $attributes (optional)Extra attributes for
tag - * @param bool $trackSubmit (optional)Whether to track if the form was submitted by adding a special hidden field - * @access public - */ - function HTML_QuickForm($formName='', $method='post', $action='', $target='', $attributes=null, $trackSubmit = false) - { - HTML_Common::HTML_Common($attributes); - $method = (strtoupper($method) == 'GET') ? 'get' : 'post'; - $action = ($action == '') ? $_SERVER['PHP_SELF'] : $action; - $target = empty($target) ? array() : array('target' => $target); - $attributes = array('action'=>$action, 'method'=>$method, 'name'=>$formName, 'id'=>$formName) + $target; - $this->updateAttributes($attributes); - if (!$trackSubmit || isset($_REQUEST['_qf__' . $formName])) { - if (1 == get_magic_quotes_gpc()) { - $this->_submitValues = $this->_recursiveFilter('stripslashes', 'get' == $method? $_GET: $_POST); - foreach ($_FILES as $keyFirst => $valFirst) { - foreach ($valFirst as $keySecond => $valSecond) { - if ('name' == $keySecond) { - $this->_submitFiles[$keyFirst][$keySecond] = $this->_recursiveFilter('stripslashes', $valSecond); - } else { - $this->_submitFiles[$keyFirst][$keySecond] = $valSecond; - } - } - } - } else { - $this->_submitValues = 'get' == $method? $_GET: $_POST; - $this->_submitFiles = $_FILES; - } - $this->_flagSubmitted = count($this->_submitValues) > 0 || count($this->_submitFiles) > 0; - } - if ($trackSubmit) { - unset($this->_submitValues['_qf__' . $formName]); - $this->addElement('hidden', '_qf__' . $formName, null); - } - if (preg_match('/^([0-9]+)([a-zA-Z]*)$/', ini_get('upload_max_filesize'), $matches)) { - // see http://www.php.net/manual/en/faq.using.php#faq.using.shorthandbytes - switch (strtoupper($matches['2'])) { - case 'G': - $this->_maxFileSize = $matches['1'] * 1073741824; - break; - case 'M': - $this->_maxFileSize = $matches['1'] * 1048576; - break; - case 'K': - $this->_maxFileSize = $matches['1'] * 1024; - break; - default: - $this->_maxFileSize = $matches['1']; - } - } - } // end constructor - - // }}} - // {{{ apiVersion() - - /** - * Returns the current API version - * - * @since 1.0 - * @access public - * @return float - */ - function apiVersion() - { - return 3.2; - } // end func apiVersion - - // }}} - // {{{ registerElementType() - - /** - * Registers a new element type - * - * @param string $typeName Name of element type - * @param string $include Include path for element type - * @param string $className Element class name - * @since 1.0 - * @access public - * @return void - */ - function registerElementType($typeName, $include, $className) - { - $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'][strtolower($typeName)] = array($include, $className); - } // end func registerElementType - - // }}} - // {{{ registerRule() - - /** - * Registers a new validation rule - * - * @param string $ruleName Name of validation rule - * @param string $type Either: 'regex', 'function' or 'rule' for an HTML_QuickForm_Rule object - * @param string $data1 Name of function, regular expression or HTML_QuickForm_Rule classname - * @param string $data2 Object parent of above function or HTML_QuickForm_Rule file path - * @since 1.0 - * @access public - * @return void - */ - function registerRule($ruleName, $type, $data1, $data2 = null) - { - include_once('HTML/QuickForm/RuleRegistry.php'); - $registry =& HTML_QuickForm_RuleRegistry::singleton(); - $registry->registerRule($ruleName, $type, $data1, $data2); - } // end func registerRule - - // }}} - // {{{ elementExists() - - /** - * Returns true if element is in the form - * - * @param string $element form name of element to check - * @since 1.0 - * @access public - * @return boolean - */ - function elementExists($element=null) - { - return isset($this->_elementIndex[$element]); - } // end func elementExists - - // }}} - // {{{ setDatasource() - - /** - * Sets a datasource object for this form object - * - * Datasource default and constant values will feed the QuickForm object if - * the datasource implements defaultValues() and constantValues() methods. - * - * @param object $datasource datasource object implementing the informal datasource protocol - * @param mixed $defaultsFilter string or array of filter(s) to apply to default values - * @param mixed $constantsFilter string or array of filter(s) to apply to constants values - * @since 3.3 - * @access public - * @return void - * @throws HTML_QuickForm_Error - */ - function setDatasource(&$datasource, $defaultsFilter = null, $constantsFilter = null) - { - if (is_object($datasource)) { - $this->_datasource =& $datasource; - if (is_callable(array($datasource, 'defaultValues'))) { - $this->setDefaults($datasource->defaultValues($this), $defaultsFilter); - } - if (is_callable(array($datasource, 'constantValues'))) { - $this->setConstants($datasource->constantValues($this), $constantsFilter); - } - } else { - return PEAR::raiseError(null, QUICKFORM_INVALID_DATASOURCE, null, E_USER_WARNING, "Datasource is not an object in QuickForm::setDatasource()", 'HTML_QuickForm_Error', true); - } - } // end func setDatasource - - // }}} - // {{{ setDefaults() - - /** - * Initializes default form values - * - * @param array $defaultValues values used to fill the form - * @param mixed $filter (optional) filter(s) to apply to all default values - * @since 1.0 - * @access public - * @return void - * @throws HTML_QuickForm_Error - */ - function setDefaults($defaultValues = null, $filter = null) - { - if (is_array($defaultValues)) { - if (isset($filter)) { - if (is_array($filter) && (2 != count($filter) || !is_callable($filter))) { - foreach ($filter as $val) { - if (!is_callable($val)) { - return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setDefaults()", 'HTML_QuickForm_Error', true); - } else { - $defaultValues = $this->_recursiveFilter($val, $defaultValues); - } - } - } elseif (!is_callable($filter)) { - return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setDefaults()", 'HTML_QuickForm_Error', true); - } else { - $defaultValues = $this->_recursiveFilter($filter, $defaultValues); - } - } - $this->_defaultValues = HTML_QuickForm::arrayMerge($this->_defaultValues, $defaultValues); - foreach (array_keys($this->_elements) as $key) { - $this->_elements[$key]->onQuickFormEvent('updateValue', null, $this); - } - } - } // end func setDefaults - - // }}} - // {{{ setConstants() - - /** - * Initializes constant form values. - * These values won't get overridden by POST or GET vars - * - * @param array $constantValues values used to fill the form - * @param mixed $filter (optional) filter(s) to apply to all default values - * - * @since 2.0 - * @access public - * @return void - * @throws HTML_QuickForm_Error - */ - function setConstants($constantValues = null, $filter = null) - { - if (is_array($constantValues)) { - if (isset($filter)) { - if (is_array($filter) && (2 != count($filter) || !is_callable($filter))) { - foreach ($filter as $val) { - if (!is_callable($val)) { - return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setConstants()", 'HTML_QuickForm_Error', true); - } else { - $constantValues = $this->_recursiveFilter($val, $constantValues); - } - } - } elseif (!is_callable($filter)) { - return PEAR::raiseError(null, QUICKFORM_INVALID_FILTER, null, E_USER_WARNING, "Callback function does not exist in QuickForm::setConstants()", 'HTML_QuickForm_Error', true); - } else { - $constantValues = $this->_recursiveFilter($filter, $constantValues); - } - } - $this->_constantValues = HTML_QuickForm::arrayMerge($this->_constantValues, $constantValues); - foreach (array_keys($this->_elements) as $key) { - $this->_elements[$key]->onQuickFormEvent('updateValue', null, $this); - } - } - } // end func setConstants - - // }}} - // {{{ setMaxFileSize() - - /** - * Sets the value of MAX_FILE_SIZE hidden element - * - * @param int $bytes Size in bytes - * @since 3.0 - * @access public - * @return void - */ - function setMaxFileSize($bytes = 0) - { - if ($bytes > 0) { - $this->_maxFileSize = $bytes; - } - if (!$this->elementExists('MAX_FILE_SIZE')) { - $this->addElement('hidden', 'MAX_FILE_SIZE', $this->_maxFileSize); - } else { - $el =& $this->getElement('MAX_FILE_SIZE'); - $el->updateAttributes(array('value' => $this->_maxFileSize)); - } - } // end func setMaxFileSize - - // }}} - // {{{ getMaxFileSize() - - /** - * Returns the value of MAX_FILE_SIZE hidden element - * - * @since 3.0 - * @access public - * @return int max file size in bytes - */ - function getMaxFileSize() - { - return $this->_maxFileSize; - } // end func getMaxFileSize - - // }}} - // {{{ &createElement() - - /** - * Creates a new form element of the given type. - * - * This method accepts variable number of parameters, their - * meaning and count depending on $elementType - * - * @param string $elementType type of element to add (text, textarea, file...) - * @since 1.0 - * @access public - * @return HTML_QuickForm_Element - * @throws HTML_QuickForm_Error - */ - function &createElement($elementType) - { - $args = func_get_args(); - $element =& HTML_QuickForm::_loadElement('createElement', $elementType, array_slice($args, 1), null); - return $element; - } // end func createElement - - // }}} - // {{{ _loadElement() - - /** - * Returns a form element of the given type - * - * @param string $event event to send to newly created element ('createElement' or 'addElement') - * @param string $type element type - * @param array $args arguments for event - * @since 2.0 - * @access private - * @return HTML_QuickForm_Element - * @throws HTML_QuickForm_Error - */ - function &_loadElement($event, $type, $args, $form) - { - $type = strtolower($type); - if (!HTML_QuickForm::isTypeRegistered($type)) { - $error = PEAR::raiseError(null, QUICKFORM_UNREGISTERED_ELEMENT, null, E_USER_WARNING, "Element '$type' does not exist in HTML_QuickForm::_loadElement()", 'HTML_QuickForm_Error', true); - return $error; - } - $className = $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'][$type][1]; - $includeFile = $GLOBALS['HTML_QUICKFORM_ELEMENT_TYPES'][$type][0]; - include_once($includeFile); - $elementObject = new $className(); - for ($i = 0; $i < 5; $i++) { - if (!isset($args[$i])) { - $args[$i] = null; - } - } - $err = $elementObject->onQuickFormEvent($event, $args, $form); - if ($err !== true) { - return $err; - } - return $elementObject; - } // end func _loadElement - - // }}} - // {{{ addElement() - - /** - * Adds an element into the form - * - * If $element is a string representing element type, then this - * method accepts variable number of parameters, their meaning - * and count depending on $element - * - * @param mixed $element element object or type of element to add (text, textarea, file...) - * @since 1.0 - * @return HTML_QuickForm_Element a reference to newly added element - * @access public - * @throws HTML_QuickForm_Error - */ - function &addElement($element) - { - if (is_object($element) && is_subclass_of($element, 'html_quickform_element')) { - $elementObject = &$element; - $elementObject->onQuickFormEvent('updateValue', null, $this); - } else { - $args = func_get_args(); - $elementObject =& $this->_loadElement('addElement', $element, array_slice($args, 1), $this); - if (PEAR::isError($elementObject)) { - return $elementObject; - } - } - $elementName = $elementObject->getName(); - - // Add the element if it is not an incompatible duplicate - if (!empty($elementName) && isset($this->_elementIndex[$elementName])) { - if ($this->_elements[$this->_elementIndex[$elementName]]->getType() == - $elementObject->getType()) { - $this->_elements[] =& $elementObject; - $elKeys = array_keys($this->_elements); - $this->_duplicateIndex[$elementName][] = end($elKeys); - } else { - $error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, "Element '$elementName' already exists in HTML_QuickForm::addElement()", 'HTML_QuickForm_Error', true); - return $error; - } - } else { - $this->_elements[] =& $elementObject; - $elKeys = array_keys($this->_elements); - $this->_elementIndex[$elementName] = end($elKeys); - } - if ($this->_freezeAll) { - $elementObject->freeze(); - } - - return $elementObject; - } // end func addElement - - // }}} - // {{{ insertElementBefore() - - /** - * Inserts a new element right before the other element - * - * Warning: it is not possible to check whether the $element is already - * added to the form, therefore if you want to move the existing form - * element to a new position, you'll have to use removeElement(): - * $form->insertElementBefore($form->removeElement('foo', false), 'bar'); - * - * @access public - * @since 3.2.4 - * @param HTML_QuickForm_element Element to insert - * @param string Name of the element before which the new - * one is inserted - * @return HTML_QuickForm_element reference to inserted element - * @throws HTML_QuickForm_Error - */ - function &insertElementBefore(&$element, $nameAfter) - { - if (!empty($this->_duplicateIndex[$nameAfter])) { - $error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, 'Several elements named "' . $nameAfter . '" exist in HTML_QuickForm::insertElementBefore().', 'HTML_QuickForm_Error', true); - return $error; - } elseif (!$this->elementExists($nameAfter)) { - $error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$nameAfter' does not exist in HTML_QuickForm::insertElementBefore()", 'HTML_QuickForm_Error', true); - return $error; - } - $elementName = $element->getName(); - $targetIdx = $this->_elementIndex[$nameAfter]; - $duplicate = false; - // Like in addElement(), check that it's not an incompatible duplicate - if (!empty($elementName) && isset($this->_elementIndex[$elementName])) { - if ($this->_elements[$this->_elementIndex[$elementName]]->getType() != $element->getType()) { - $error = PEAR::raiseError(null, QUICKFORM_INVALID_ELEMENT_NAME, null, E_USER_WARNING, "Element '$elementName' already exists in HTML_QuickForm::insertElementBefore()", 'HTML_QuickForm_Error', true); - return $error; - } - $duplicate = true; - } - // Move all the elements after added back one place, reindex _elementIndex and/or _duplicateIndex - $elKeys = array_keys($this->_elements); - for ($i = end($elKeys); $i >= $targetIdx; $i--) { - if (isset($this->_elements[$i])) { - $currentName = $this->_elements[$i]->getName(); - $this->_elements[$i + 1] =& $this->_elements[$i]; - if ($this->_elementIndex[$currentName] == $i) { - $this->_elementIndex[$currentName] = $i + 1; - } else { - $dupIdx = array_search($i, $this->_duplicateIndex[$currentName]); - $this->_duplicateIndex[$currentName][$dupIdx] = $i + 1; - } - unset($this->_elements[$i]); - } - } - // Put the element in place finally - $this->_elements[$targetIdx] =& $element; - if (!$duplicate) { - $this->_elementIndex[$elementName] = $targetIdx; - } else { - $this->_duplicateIndex[$elementName][] = $targetIdx; - } - $element->onQuickFormEvent('updateValue', null, $this); - if ($this->_freezeAll) { - $element->freeze(); - } - // If not done, the elements will appear in reverse order - ksort($this->_elements); - return $element; - } - - // }}} - // {{{ addGroup() - - /** - * Adds an element group - * @param array $elements array of elements composing the group - * @param string $name (optional)group name - * @param string $groupLabel (optional)group label - * @param string $separator (optional)string to separate elements - * @param string $appendName (optional)specify whether the group name should be - * used in the form element name ex: group[element] - * @return HTML_QuickForm_group reference to a newly added group - * @since 2.8 - * @access public - * @throws HTML_QuickForm_Error - */ - function &addGroup($elements, $name=null, $groupLabel='', $separator=null, $appendName = true) - { - static $anonGroups = 1; - - if (0 == strlen($name)) { - $name = 'qf_group_' . $anonGroups++; - $appendName = false; - } - $group =& $this->addElement('group', $name, $groupLabel, $elements, $separator, $appendName); - return $group; - } // end func addGroup - - // }}} - // {{{ &getElement() - - /** - * Returns a reference to the element - * - * @param string $element Element name - * @since 2.0 - * @access public - * @return HTML_QuickForm_element reference to element - * @throws HTML_QuickForm_Error - */ - function &getElement($element) - { - if (isset($this->_elementIndex[$element])) { - return $this->_elements[$this->_elementIndex[$element]]; - } else { - $error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElement()", 'HTML_QuickForm_Error', true); - return $error; - } - } // end func getElement - - // }}} - // {{{ &getElementValue() - - /** - * Returns the element's raw value - * - * This returns the value as submitted by the form (not filtered) - * or set via setDefaults() or setConstants() - * - * @param string $element Element name - * @since 2.0 - * @access public - * @return mixed element value - * @throws HTML_QuickForm_Error - */ - function &getElementValue($element) - { - if (!isset($this->_elementIndex[$element])) { - $error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::getElementValue()", 'HTML_QuickForm_Error', true); - return $error; - } - $value = $this->_elements[$this->_elementIndex[$element]]->getValue(); - if (isset($this->_duplicateIndex[$element])) { - foreach ($this->_duplicateIndex[$element] as $index) { - if (null !== ($v = $this->_elements[$index]->getValue())) { - if (is_array($value)) { - $value[] = $v; - } else { - $value = (null === $value)? $v: array($value, $v); - } - } - } - } - return $value; - } // end func getElementValue - - // }}} - // {{{ getSubmitValue() - - /** - * Returns the elements value after submit and filter - * - * @param string Element name - * @since 2.0 - * @access public - * @return mixed submitted element value or null if not set - */ - function getSubmitValue($elementName) - { - $value = null; - if (isset($this->_submitValues[$elementName]) || isset($this->_submitFiles[$elementName])) { - $value = isset($this->_submitValues[$elementName])? $this->_submitValues[$elementName]: array(); - if (is_array($value) && isset($this->_submitFiles[$elementName])) { - foreach ($this->_submitFiles[$elementName] as $k => $v) { - $value = HTML_QuickForm::arrayMerge($value, $this->_reindexFiles($this->_submitFiles[$elementName][$k], $k)); - } - } - - } elseif ('file' == $this->getElementType($elementName)) { - return $this->getElementValue($elementName); - - } elseif (false !== ($pos = strpos($elementName, '['))) { - $base = str_replace( - array('\\', '\''), array('\\\\', '\\\''), - substr($elementName, 0, $pos) - ); - - $keys = str_replace( - array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), - substr($elementName, $pos + 1, -1) - ); - $idx = "['" . $keys . "']"; - $keyArray = explode("']['", $keys); - - if (isset($this->_submitValues[$base])) { - $value = HTML_QuickForm_utils::recursiveValue($this->_submitValues[$base], $keyArray, NULL); - } - - if ((is_array($value) || null === $value) && isset($this->_submitFiles[$base])) { - $props = array('name', 'type', 'size', 'tmp_name', 'error'); - $code = "if (!isset(\$this->_submitFiles['{$base}']['name']{$idx})) {\n" . - " return null;\n" . - "} else {\n" . - " \$v = array();\n"; - foreach ($props as $prop) { - $code .= " \$v = HTML_QuickForm::arrayMerge(\$v, \$this->_reindexFiles(\$this->_submitFiles['{$base}']['{$prop}']{$idx}, '{$prop}'));\n"; - } - $fileValue = eval($code . " return \$v;\n}\n"); - if (null !== $fileValue) { - $value = null === $value? $fileValue: HTML_QuickForm::arrayMerge($value, $fileValue); - } - } - } - - // This is only supposed to work for groups with appendName = false - if (null === $value && 'group' == $this->getElementType($elementName)) { - $group =& $this->getElement($elementName); - $elements =& $group->getElements(); - foreach (array_keys($elements) as $key) { - $name = $group->getElementName($key); - // prevent endless recursion in case of radios and such - if ($name != $elementName) { - if (null !== ($v = $this->getSubmitValue($name))) { - $value[$name] = $v; - } - } - } - } - return $value; - } // end func getSubmitValue - - // }}} - // {{{ _reindexFiles() - - /** - * A helper function to change the indexes in $_FILES array - * - * @param mixed Some value from the $_FILES array - * @param string The key from the $_FILES array that should be appended - * @return array - */ - function _reindexFiles($value, $key) - { - if (!is_array($value)) { - return array($key => $value); - } else { - $ret = array(); - foreach ($value as $k => $v) { - $ret[$k] = $this->_reindexFiles($v, $key); - } - return $ret; - } - } - - // }}} - // {{{ getElementError() - - /** - * Returns error corresponding to validated element - * - * @param string $element Name of form element to check - * @since 1.0 - * @access public - * @return string error message corresponding to checked element - */ - function getElementError($element) - { - if (isset($this->_errors[$element])) { - return $this->_errors[$element]; - } - } // end func getElementError - - // }}} - // {{{ setElementError() - - /** - * Set error message for a form element - * - * @param string $element Name of form element to set error for - * @param string $message Error message, if empty then removes the current error message - * @since 1.0 - * @access public - * @return void - */ - function setElementError($element, $message = null) - { - if (!empty($message)) { - $this->_errors[$element] = $message; - } else { - unset($this->_errors[$element]); - } - } // end func setElementError - - // }}} - // {{{ getElementType() - - /** - * Returns the type of the given element - * - * @param string $element Name of form element - * @since 1.1 - * @access public - * @return string Type of the element, false if the element is not found - */ - function getElementType($element) - { - if (isset($this->_elementIndex[$element])) { - return $this->_elements[$this->_elementIndex[$element]]->getType(); - } - return false; - } // end func getElementType - - // }}} - // {{{ updateElementAttr() - - /** - * Updates Attributes for one or more elements - * - * @param mixed $elements Array of element names/objects or string of elements to be updated - * @param mixed $attrs Array or sting of html attributes - * @since 2.10 - * @access public - * @return void - */ - function updateElementAttr($elements, $attrs) - { - if (is_string($elements)) { - $elements = preg_split('/[ ]?,[ ]?/', $elements); - } - foreach (array_keys($elements) as $key) { - if (is_object($elements[$key]) && is_a($elements[$key], 'HTML_QuickForm_element')) { - $elements[$key]->updateAttributes($attrs); - } elseif (isset($this->_elementIndex[$elements[$key]])) { - $this->_elements[$this->_elementIndex[$elements[$key]]]->updateAttributes($attrs); - if (isset($this->_duplicateIndex[$elements[$key]])) { - foreach ($this->_duplicateIndex[$elements[$key]] as $index) { - $this->_elements[$index]->updateAttributes($attrs); - } - } - } - } - } // end func updateElementAttr - - // }}} - // {{{ removeElement() - - /** - * Removes an element - * - * The method "unlinks" an element from the form, returning the reference - * to the element object. If several elements named $elementName exist, - * it removes the first one, leaving the others intact. - * - * @param string $elementName The element name - * @param boolean $removeRules True if rules for this element are to be removed too - * @access public - * @since 2.0 - * @return HTML_QuickForm_element a reference to the removed element - * @throws HTML_QuickForm_Error - */ - function &removeElement($elementName, $removeRules = true) - { - if (!isset($this->_elementIndex[$elementName])) { - $error = PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$elementName' does not exist in HTML_QuickForm::removeElement()", 'HTML_QuickForm_Error', true); - return $error; - } - $el =& $this->_elements[$this->_elementIndex[$elementName]]; - unset($this->_elements[$this->_elementIndex[$elementName]]); - if (empty($this->_duplicateIndex[$elementName])) { - unset($this->_elementIndex[$elementName]); - } else { - $this->_elementIndex[$elementName] = array_shift($this->_duplicateIndex[$elementName]); - } - if ($removeRules) { - $this->_required = array_diff($this->_required, array($elementName)); - unset($this->_rules[$elementName], $this->_errors[$elementName]); - if ('group' == $el->getType()) { - foreach (array_keys($el->getElements()) as $key) { - unset($this->_rules[$el->getElementName($key)]); - } - } - } - return $el; - } // end func removeElement - - // }}} - // {{{ addRule() - - /** - * Adds a validation rule for the given field - * - * If the element is in fact a group, it will be considered as a whole. - * To validate grouped elements as separated entities, - * use addGroupRule instead of addRule. - * - * @param string $element Form element name - * @param string $message Message to display for invalid data - * @param string $type Rule type, use getRegisteredRules() to get types - * @param string $format (optional)Required for extra rule data - * @param string $validation (optional)Where to perform validation: "server", "client" - * @param boolean $reset Client-side validation: reset the form element to its original value if there is an error? - * @param boolean $force Force the rule to be applied, even if the target form element does not exist - * @since 1.0 - * @access public - * @throws HTML_QuickForm_Error - */ - function addRule($element, $message, $type, $format=null, $validation='server', $reset = false, $force = false) - { - if (!$force) { - if (!is_array($element) && !$this->elementExists($element)) { - return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$element' does not exist in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true); - } elseif (is_array($element)) { - foreach ($element as $el) { - if (!$this->elementExists($el)) { - return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Element '$el' does not exist in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true); - } - } - } - } - if (false === ($newName = $this->isRuleRegistered($type, true))) { - return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addRule()", 'HTML_QuickForm_Error', true); - } elseif (is_string($newName)) { - $type = $newName; - } - if (is_array($element)) { - $dependent = $element; - $element = array_shift($dependent); - } else { - $dependent = null; - } - if ($type == 'required' || $type == 'uploadedfile') { - $this->_required[] = $element; - } - if (!isset($this->_rules[$element])) { - $this->_rules[$element] = array(); - } - if ($validation == 'client') { - $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $this->_attributes['id'] . '; } catch(e) { return true; } return myValidator(this);')); - } - $this->_rules[$element][] = array( - 'type' => $type, - 'format' => $format, - 'message' => $message, - 'validation' => $validation, - 'reset' => $reset, - 'dependent' => $dependent - ); - } // end func addRule - - // }}} - // {{{ addGroupRule() - - /** - * Adds a validation rule for the given group of elements - * - * Only groups with a name can be assigned a validation rule - * Use addGroupRule when you need to validate elements inside the group. - * Use addRule if you need to validate the group as a whole. In this case, - * the same rule will be applied to all elements in the group. - * Use addRule if you need to validate the group against a function. - * - * @param string $group Form group name - * @param mixed $arg1 Array for multiple elements or error message string for one element - * @param string $type (optional)Rule type use getRegisteredRules() to get types - * @param string $format (optional)Required for extra rule data - * @param int $howmany (optional)How many valid elements should be in the group - * @param string $validation (optional)Where to perform validation: "server", "client" - * @param bool $reset Client-side: whether to reset the element's value to its original state if validation failed. - * @since 2.5 - * @access public - * @throws HTML_QuickForm_Error - */ - function addGroupRule($group, $arg1, $type='', $format=null, $howmany=0, $validation = 'server', $reset = false) - { - if (!$this->elementExists($group)) { - return PEAR::raiseError(null, QUICKFORM_NONEXIST_ELEMENT, null, E_USER_WARNING, "Group '$group' does not exist in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true); - } - - $groupObj =& $this->getElement($group); - if (is_array($arg1)) { - $required = 0; - foreach ($arg1 as $elementIndex => $rules) { - $elementName = $groupObj->getElementName($elementIndex); - foreach ($rules as $rule) { - $format = (isset($rule[2])) ? $rule[2] : null; - $validation = (isset($rule[3]) && 'client' == $rule[3])? 'client': 'server'; - $reset = isset($rule[4]) && $rule[4]; - $type = $rule[1]; - if (false === ($newName = $this->isRuleRegistered($type, true))) { - return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true); - } elseif (is_string($newName)) { - $type = $newName; - } - - $this->_rules[$elementName][] = array( - 'type' => $type, - 'format' => $format, - 'message' => $rule[0], - 'validation' => $validation, - 'reset' => $reset, - 'group' => $group); - - if ('required' == $type || 'uploadedfile' == $type) { - $groupObj->_required[] = $elementName; - $this->_required[] = $elementName; - $required++; - } - if ('client' == $validation) { - $this->updateAttributes(array('onsubmit' => 'try { var myValidator = validate_' . $this->_attributes['id'] . '; } catch(e) { return true; } return myValidator(this);')); - } - } - } - if ($required > 0 && count($groupObj->getElements()) == $required) { - $this->_required[] = $group; - } - } elseif (is_string($arg1)) { - if (false === ($newName = $this->isRuleRegistered($type, true))) { - return PEAR::raiseError(null, QUICKFORM_INVALID_RULE, null, E_USER_WARNING, "Rule '$type' is not registered in HTML_QuickForm::addGroupRule()", 'HTML_QuickForm_Error', true); - } elseif (is_string($newName)) { - $type = $newName; - } - - // addGroupRule() should also handle form elements - */ -require_once 'HTML/QuickForm/input.php'; - -/** - * HTML class for an elements - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @version Release: 3.2.16 - * @since 1.0 - */ -class HTML_QuickForm_button extends HTML_QuickForm_input -{ - // {{{ constructor - - /** - * Class constructor - * - * @param string $elementName (optional)Input field name attribute - * @param string $value (optional)Input field value - * @param mixed $attributes (optional)Either a typical HTML attribute string - * or an associative array - * @since 1.0 - * @access public - * @return void - */ - function HTML_QuickForm_button($elementName=null, $value=null, $attributes=null) - { - HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); - $this->_persistantFreeze = false; - $this->setValue($value); - $this->setType('button'); - } //end constructor - - // }}} - // {{{ freeze() - - /** - * Freeze the element so that only its value is returned - * - * @access public - * @return void - */ - function freeze() - { - return false; - } //end func freeze - - // }}} - -} //end class HTML_QuickForm_button -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/checkbox.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/checkbox.php deleted file mode 100644 index 0bebe08ad..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/checkbox.php +++ /dev/null @@ -1,277 +0,0 @@ - - * @author Bertrand Mansion - * @author Alexey Borzov - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Base class for form elements - */ -require_once 'HTML/QuickForm/input.php'; - -/** - * HTML class for a checkbox type field - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @author Alexey Borzov - * @version Release: 3.2.16 - * @since 1.0 - */ -class HTML_QuickForm_checkbox extends HTML_QuickForm_input -{ - // {{{ properties - - /** - * Checkbox display text - * @var string - * @since 1.1 - * @access private - */ - var $_text = ''; - - // }}} - // {{{ constructor - - /** - * Class constructor - * - * @param string $elementName (optional)Input field name attribute - * @param string $elementLabel (optional)Input field value - * @param string $text (optional)Checkbox display text - * @param mixed $attributes (optional)Either a typical HTML attribute string - * or an associative array - * @since 1.0 - * @access public - * @return void - */ - function HTML_QuickForm_checkbox($elementName=null, $elementLabel=null, $text='', $attributes=null) - { - HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); - $this->_persistantFreeze = true; - $this->_text = $text; - $this->setType('checkbox'); - $this->updateAttributes(array('value'=>1)); - $this->_generateId(); - } //end constructor - - // }}} - // {{{ setChecked() - - /** - * Sets whether a checkbox is checked - * - * @param bool $checked Whether the field is checked or not - * @since 1.0 - * @access public - * @return void - */ - function setChecked($checked) - { - if (!$checked) { - $this->removeAttribute('checked'); - } else { - $this->updateAttributes(array('checked'=>'checked')); - } - } //end func setChecked - - // }}} - // {{{ getChecked() - - /** - * Returns whether a checkbox is checked - * - * @since 1.0 - * @access public - * @return bool - */ - function getChecked() - { - return (bool)$this->getAttribute('checked'); - } //end func getChecked - - // }}} - // {{{ toHtml() - - /** - * Returns the checkbox element in HTML - * - * @since 1.0 - * @access public - * @return string - */ - function toHtml() - { - if (0 == strlen($this->_text)) { - $label = ''; - } elseif ($this->_flagFrozen) { - $label = $this->_text; - } else { - $label = ''; - } - return HTML_QuickForm_input::toHtml() . $label; - } //end func toHtml - - // }}} - // {{{ getFrozenHtml() - - /** - * Returns the value of field without HTML tags - * - * @since 1.0 - * @access public - * @return string - */ - function getFrozenHtml() - { - if ($this->getChecked()) { - return '[x]' . - $this->_getPersistantData(); - } else { - return '[ ]'; - } - } //end func getFrozenHtml - - // }}} - // {{{ setText() - - /** - * Sets the checkbox text - * - * @param string $text - * @since 1.1 - * @access public - * @return void - */ - function setText($text) - { - $this->_text = $text; - } //end func setText - - // }}} - // {{{ getText() - - /** - * Returns the checkbox text - * - * @since 1.1 - * @access public - * @return string - */ - function getText() - { - return $this->_text; - } //end func getText - - // }}} - // {{{ setValue() - - /** - * Sets the value of the form element - * - * @param string $value Default value of the form element - * @since 1.0 - * @access public - * @return void - */ - function setValue($value) - { - return $this->setChecked($value); - } // end func setValue - - // }}} - // {{{ getValue() - - /** - * Returns the value of the form element - * - * @since 1.0 - * @access public - * @return bool - */ - function getValue() - { - return $this->getChecked(); - } // end func getValue - - // }}} - // {{{ onQuickFormEvent() - - /** - * Called by HTML_QuickForm whenever form event is made on this element - * - * @param string $event Name of event - * @param mixed $arg event arguments - * @param object &$caller calling object - * @since 1.0 - * @access public - * @return void - */ - function onQuickFormEvent($event, $arg, &$caller) - { - switch ($event) { - case 'updateValue': - // constant values override both default and submitted ones - // default values are overriden by submitted - $value = $this->_findValue($caller->_constantValues); - if (null === $value) { - // if no boxes were checked, then there is no value in the array - // yet we don't want to display default value in this case - if ($caller->isSubmitted()) { - $value = $this->_findValue($caller->_submitValues); - } else { - $value = $this->_findValue($caller->_defaultValues); - } - } - if (null !== $value || $caller->isSubmitted()) { - $this->setChecked($value); - } - break; - case 'setGroupValue': - $this->setChecked($arg); - break; - default: - parent::onQuickFormEvent($event, $arg, $caller); - } - return true; - } // end func onQuickFormEvent - - // }}} - // {{{ exportValue() - - /** - * Return true if the checkbox is checked, null if it is not checked (getValue() returns false) - */ - function exportValue(&$submitValues, $assoc = false) - { - $value = $this->_findValue($submitValues); - if (null === $value) { - $value = $this->getChecked()? true: null; - } - return $this->_prepareValue($value, $assoc); - } - - // }}} -} //end class HTML_QuickForm_checkbox -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/date.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/date.php deleted file mode 100644 index c14cca8ff..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/date.php +++ /dev/null @@ -1,544 +0,0 @@ - - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Class for a group of form elements - */ -require_once 'HTML/QuickForm/group.php'; -/** - * Class for elements - */ -require_once 'HTML/QuickForm/select.php'; - -/** - * Class for a group of elements used to input dates (and times). - * - * Inspired by original 'date' element but reimplemented as a subclass - * of HTML_QuickForm_group - * - * @category HTML - * @package HTML_QuickForm - * @author Alexey Borzov - * @version Release: 3.2.16 - * @since 3.1 - */ -class HTML_QuickForm_date extends HTML_QuickForm_group -{ - // {{{ properties - - /** - * Various options to control the element's display. - * - * @access private - * @var array - */ - var $_options = array( - 'language' => 'en', - 'format' => 'dMY', - 'minYear' => 2001, - 'maxYear' => null, // set in the constructor - 'addEmptyOption' => false, - 'emptyOptionValue' => '', - 'emptyOptionText' => ' ', - 'optionIncrement' => array('i' => 1, 's' => 1) - ); - - /** - * These complement separators, they are appended to the resultant HTML - * @access private - * @var array - */ - var $_wrap = array('', ''); - - /** - * Options in different languages - * - * Note to potential translators: to avoid encoding problems please send - * your translations with "weird" letters encoded as HTML Unicode entities - * - * @access private - * @var array - */ - var $_locale = array( - 'en' => array ( - 'weekdays_short'=> array ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'), - 'weekdays_long' => array ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'), - 'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), - 'months_long' => array ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December') - ), - 'de' => array ( - 'weekdays_short'=> array ('So', 'Mon', 'Di', 'Mi', 'Do', 'Fr', 'Sa'), - 'weekdays_long' => array ('Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'), - 'months_short' => array ('Jan', 'Feb', 'März', 'April', 'Mai', 'Juni', 'Juli', 'Aug', 'Sept', 'Okt', 'Nov', 'Dez'), - 'months_long' => array ('Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember') - ), - 'fr' => array ( - 'weekdays_short'=> array ('Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'), - 'weekdays_long' => array ('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'), - 'months_short' => array ('Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Juin', 'Juil', 'Août', 'Sep', 'Oct', 'Nov', 'Déc'), - 'months_long' => array ('Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre') - ), - 'hu' => array ( - 'weekdays_short'=> array ('V', 'H', 'K', 'Sze', 'Cs', 'P', 'Szo'), - 'weekdays_long' => array ('vasárnap', 'hétfő', 'kedd', 'szerda', 'csütörtök', 'péntek', 'szombat'), - 'months_short' => array ('jan', 'feb', 'márc', 'ápr', 'máj', 'jún', 'júl', 'aug', 'szept', 'okt', 'nov', 'dec'), - 'months_long' => array ('január', 'február', 'március', 'április', 'május', 'június', 'július', 'augusztus', 'szeptember', 'október', 'november', 'december') - ), - 'pl' => array ( - 'weekdays_short'=> array ('Nie', 'Pn', 'Wt', 'Śr', 'Czw', 'Pt', 'Sob'), - 'weekdays_long' => array ('Niedziela', 'Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota'), - 'months_short' => array ('Sty', 'Lut', 'Mar', 'Kwi', 'Maj', 'Cze', 'Lip', 'Sie', 'Wrz', 'Paź', 'Lis', 'Gru'), - 'months_long' => array ('Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień') - ), - 'sl' => array ( - 'weekdays_short'=> array ('Ned', 'Pon', 'Tor', 'Sre', 'Cet', 'Pet', 'Sob'), - 'weekdays_long' => array ('Nedelja', 'Ponedeljek', 'Torek', 'Sreda', 'Cetrtek', 'Petek', 'Sobota'), - 'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Avg', 'Sep', 'Okt', 'Nov', 'Dec'), - 'months_long' => array ('Januar', 'Februar', 'Marec', 'April', 'Maj', 'Junij', 'Julij', 'Avgust', 'September', 'Oktober', 'November', 'December') - ), - 'ru' => array ( - 'weekdays_short'=> array ('Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб'), - 'weekdays_long' => array ('Воскресенье', 'Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота'), - 'months_short' => array ('Янв', 'Фев', 'Мар', 'Апр', 'Май', 'Июн', 'Июл', 'Авг', 'Сен', 'Окт', 'Ноя', 'Дек'), - 'months_long' => array ('Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь') - ), - 'es' => array ( - 'weekdays_short'=> array ('Dom', 'Lun', 'Mar', 'Mié', 'Jue', 'Vie', 'Sáb'), - 'weekdays_long' => array ('Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'), - 'months_short' => array ('Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'), - 'months_long' => array ('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre') - ), - 'da' => array ( - 'weekdays_short'=> array ('Søn', 'Man', 'Tir', 'Ons', 'Tor', 'Fre', 'Lør'), - 'weekdays_long' => array ('Søndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'Lørdag'), - 'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'), - 'months_long' => array ('Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December') - ), - 'is' => array ( - 'weekdays_short'=> array ('Sun', 'Mán', 'Þri', 'Mið', 'Fim', 'Fös', 'Lau'), - 'weekdays_long' => array ('Sunnudagur', 'Mánudagur', 'Þriðjudagur', 'Miðvikudagur', 'Fimmtudagur', 'Föstudagur', 'Laugardagur'), - 'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maí', 'Jún', 'Júl', 'Ágú', 'Sep', 'Okt', 'Nóv', 'Des'), - 'months_long' => array ('Janúar', 'Febrúar', 'Mars', 'Apríl', 'Maí', 'Júní', 'Júlí', 'Ágúst', 'September', 'Október', 'Nóvember', 'Desember') - ), - 'it' => array ( - 'weekdays_short'=> array ('Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab'), - 'weekdays_long' => array ('Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'), - 'months_short' => array ('Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'), - 'months_long' => array ('Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre') - ), - 'sk' => array ( - 'weekdays_short'=> array ('Ned', 'Pon', 'Uto', 'Str', 'Štv', 'Pia', 'Sob'), - 'weekdays_long' => array ('Nedeža', 'Pondelok', 'Utorok', 'Streda', 'Štvrtok', 'Piatok', 'Sobota'), - 'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Máj', 'Jún', 'Júl', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'), - 'months_long' => array ('Január', 'Február', 'Marec', 'Apríl', 'Máj', 'Jún', 'Júl', 'August', 'September', 'Október', 'November', 'December') - ), - 'cs' => array ( - 'weekdays_short'=> array ('Ne', 'Po', 'Út', 'St', 'Čt', 'Pá', 'So'), - 'weekdays_long' => array ('Neděle', 'Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota'), - 'months_short' => array ('Led', 'Úno', 'Bře', 'Dub', 'Kvě', 'Čen', 'Čec', 'Srp', 'Zář', 'Říj', 'Lis', 'Pro'), - 'months_long' => array ('Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec') - ), - 'hy' => array ( - 'weekdays_short'=> array ('Կրկ', 'Երկ', 'Երք', 'Չրք', 'Հնգ', 'Ուր', 'Շբթ'), - 'weekdays_long' => array ('Կիրակի', 'Երկուշաբթի', 'Երեքշաբթի', 'Չորեքշաբթի', 'Հինգշաբթի', 'Ուրբաթ', 'Շաբաթ'), - 'months_short' => array ('Հնվ', 'Փտր', 'Մրտ', 'Ապր', 'Մյս', 'Հնս', 'Հլս', 'Օգս', 'Սպտ', 'Հկտ', 'Նյմ', 'Դկտ'), - 'months_long' => array ('Հունվար', 'Փետրվար', 'Մարտ', 'Ապրիլ', 'Մայիս', 'Հունիս', 'Հուլիս', 'Օգոստոս', 'Սեպտեմբեր', 'Հոկտեմբեր', 'Նոյեմբեր', 'Դեկտեմբեր') - ), - 'nl' => array ( - 'weekdays_short'=> array ('Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za'), - 'weekdays_long' => array ('Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'), - 'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'), - 'months_long' => array ('Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December') - ), - 'et' => array ( - 'weekdays_short'=> array ('P', 'E', 'T', 'K', 'N', 'R', 'L'), - 'weekdays_long' => array ('Pühapäev', 'Esmaspäev', 'Teisipäev', 'Kolmapäev', 'Neljapäev', 'Reede', 'Laupäev'), - 'months_short' => array ('Jaan', 'Veebr', 'Märts', 'Aprill', 'Mai', 'Juuni', 'Juuli', 'Aug', 'Sept', 'Okt', 'Nov', 'Dets'), - 'months_long' => array ('Jaanuar', 'Veebruar', 'Märts', 'Aprill', 'Mai', 'Juuni', 'Juuli', 'August', 'September', 'Oktoober', 'November', 'Detsember') - ), - 'tr' => array ( - 'weekdays_short'=> array ('Paz', 'Pzt', 'Sal', 'Çar', 'Per', 'Cum', 'Cts'), - 'weekdays_long' => array ('Pazar', 'Pazartesi', 'Salı', 'Çarşamba', 'Perşembe', 'Cuma', 'Cumartesi'), - 'months_short' => array ('Ock', 'Şbt', 'Mrt', 'Nsn', 'Mys', 'Hzrn', 'Tmmz', 'Ağst', 'Eyl', 'Ekm', 'Ksm', 'Arlk'), - 'months_long' => array ('Ocak', 'Şubat', 'Mart', 'Nisan', 'Mayıs', 'Haziran', 'Temmuz', 'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık') - ), - 'no' => array ( - 'weekdays_short'=> array ('Søn', 'Man', 'Tir', 'Ons', 'Tor', 'Fre', 'Lør'), - 'weekdays_long' => array ('Søndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'Lørdag'), - 'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Des'), - 'months_long' => array ('Januar', 'Februar', 'Mars', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Desember') - ), - 'eo' => array ( - 'weekdays_short'=> array ('Dim', 'Lun', 'Mar', 'Mer', 'Ĵaŭ', 'Ven', 'Sab'), - 'weekdays_long' => array ('Dimanĉo', 'Lundo', 'Mardo', 'Merkredo', 'Ĵaŭdo', 'Vendredo', 'Sabato'), - 'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aŭg', 'Sep', 'Okt', 'Nov', 'Dec'), - 'months_long' => array ('Januaro', 'Februaro', 'Marto', 'Aprilo', 'Majo', 'Junio', 'Julio', 'Aŭgusto', 'Septembro', 'Oktobro', 'Novembro', 'Decembro') - ), - 'ua' => array ( - 'weekdays_short'=> array('Ндл', 'Пнд', 'Втр', 'Срд', 'Чтв', 'Птн', 'Сбт'), - 'weekdays_long' => array('Неділя', 'Понеділок', 'Вівторок', 'Середа', 'Четвер', 'П\'ятниця', 'Субота'), - 'months_short' => array('Січ', 'Лют', 'Бер', 'Кві', 'Тра', 'Чер', 'Лип', 'Сер', 'Вер', 'Жов', 'Лис', 'Гру'), - 'months_long' => array('Січень', 'Лютий', 'Березень', 'Квітень', 'Травень', 'Червень', 'Липень', 'Серпень', 'Вересень', 'Жовтень', 'Листопад', 'Грудень') - ), - 'ro' => array ( - 'weekdays_short'=> array ('Dum', 'Lun', 'Mar', 'Mie', 'Joi', 'Vin', 'Sam'), - 'weekdays_long' => array ('Duminica', 'Luni', 'Marti', 'Miercuri', 'Joi', 'Vineri', 'Sambata'), - 'months_short' => array ('Ian', 'Feb', 'Mar', 'Apr', 'Mai', 'Iun', 'Iul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), - 'months_long' => array ('Ianuarie', 'Februarie', 'Martie', 'Aprilie', 'Mai', 'Iunie', 'Iulie', 'August', 'Septembrie', 'Octombrie', 'Noiembrie', 'Decembrie') - ), - 'he' => array ( - 'weekdays_short'=> array ('ראשון', 'שני', 'שלישי', 'רביעי', 'חמישי', 'שישי', 'שבת'), - 'weekdays_long' => array ('יום ראשון', 'יום שני', 'יום שלישי', 'יום רביעי', 'יום חמישי', 'יום שישי', 'שבת'), - 'months_short' => array ('ינואר', 'פברואר', 'מרץ', 'אפריל', 'מאי', 'יוני', 'יולי', 'אוגוסט', 'ספטמבר', 'אוקטובר', 'נובמבר', 'דצמבר'), - 'months_long' => array ('ינואר', 'פברואר', 'מרץ', 'אפריל', 'מאי', 'יוני', 'יולי', 'אוגוסט', 'ספטמבר', 'אוקטובר', 'נובמבר', 'דצמבר') - ), - 'sv' => array ( - 'weekdays_short'=> array ('Sön', 'Mån', 'Tis', 'Ons', 'Tor', 'Fre', 'Lör'), - 'weekdays_long' => array ('Söndag', 'Måndag', 'Tisdag', 'Onsdag', 'Torsdag', 'Fredag', 'Lördag'), - 'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'), - 'months_long' => array ('Januari', 'Februari', 'Mars', 'April', 'Maj', 'Juni', 'Juli', 'Augusti', 'September', 'Oktober', 'November', 'December') - ), - 'pt' => array ( - 'weekdays_short'=> array ('Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'), - 'weekdays_long' => array ('Domingo', 'Segunda-feira', 'Terça-feira', 'Quarta-feira', 'Quinta-feira', 'Sexta-feira', 'Sábado'), - 'months_short' => array ('Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'), - 'months_long' => array ('Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro') - ), - 'tw' => array ( - 'weekdays_short'=> array ('週日','週一', '週二','週三', '週四','週五', '週六'), - 'weekdays_long' => array ('星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'), - 'months_short' => array ('一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'), - 'months_long' => array ('一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月') - ), - 'pt-br' => array ( - 'weekdays_short'=> array ('Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'), - 'weekdays_long' => array ('Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado'), - 'months_short' => array ('Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'), - 'months_long' => array ('Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro') - ), - 'sr' => array ( - 'weekdays_short'=> array ('Нед', 'Пон', 'Уто', 'Сре', 'Чет', 'Пет', 'Суб'), - 'weekdays_long' => array ('Недеља', 'Понедељак', 'Уторак', 'Среда', 'Четвртак', 'Петак', 'Субота'), - 'months_short' => array ('Јан', 'Феб', 'Мар', 'Апр', 'Мај', 'Јун', 'Јул', 'Авг', 'Сеп', 'Окт', 'Нов', 'Дец'), - 'months_long' => array ('Јануар', 'Фебруар', 'Март', 'Април', 'Мај', 'Јун', 'Јул', 'Август', 'Септембар', 'Октобар', 'Новембар', 'Децембар') - ), - 'el' => array ( - 'weekdays_short'=> array ('Δευ', 'Τρί', 'Τετ', 'Πέμ', 'Παρ', 'Σάβ', 'Κυρ'), - 'weekdays_long' => array ('Δευτέρα', 'Τρίτη', 'Τετάρτη', 'Πέμπτη', 'Παρασκευή', 'Σάββατο', 'Κυριακή'), - 'months_short' => array ('Ιαν', 'Φεβ', 'Μάρ', 'Απρ', 'Μάϊ', 'Ioύν', 'Ιούλ', 'Αύγ', 'Σεπ', 'Οκτ', 'Νοέ', 'Δεκ'), - 'months_long' => array ('Ιανουάριος', 'Φεβρουάριος', 'Μάρτιος', 'Απρίλιος', 'Μάϊος', 'Ιούνιος', 'Ioύλιος', 'Αύγουστος', 'Σεπτέμβριος', 'Οκτώβριος', 'Νοέμβριος', 'Δεκέμβριος') - ) - ); - - // }}} - // {{{ constructor - - /** - * Class constructor - * - * The following keys may appear in $options array: - * - 'language': date language - * - 'format': Format of the date, based on PHP's date() function. - * The following characters are currently recognised in format string: - *
-    *       D => Short names of days
-    *       l => Long names of days
-    *       d => Day numbers
-    *       M => Short names of months
-    *       F => Long names of months
-    *       m => Month numbers
-    *       Y => Four digit year
-    *       y => Two digit year
-    *       h => 12 hour format
-    *       H => 23 hour  format
-    *       i => Minutes
-    *       s => Seconds
-    *       a => am/pm
-    *       A => AM/PM
-    *   
- * - 'minYear': Minimum year in year select - * - 'maxYear': Maximum year in year select - * - 'addEmptyOption': Should an empty option be added to the top of - * each select box? - * - 'emptyOptionValue': The value passed by the empty option. - * - 'emptyOptionText': The text displayed for the empty option. - * - 'optionIncrement': Step to increase the option values by (works for 'i' and 's') - * - * @access public - * @param string Element's name - * @param mixed Label(s) for an element - * @param array Options to control the element's display - * @param mixed Either a typical HTML attribute string or an associative array - */ - function HTML_QuickForm_date($elementName = null, $elementLabel = null, $options = array(), $attributes = null) - { - $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes); - $this->_persistantFreeze = true; - $this->_appendName = true; - $this->_type = 'date'; - - // http://pear.php.net/bugs/bug.php?id=18171 - $this->_options['maxYear'] = date('Y'); - - // set the options, do not bother setting bogus ones - if (is_array($options)) { - foreach ($options as $name => $value) { - if ('language' == $name) { - $this->_options['language'] = isset($this->_locale[$value])? $value: 'en'; - } elseif (isset($this->_options[$name])) { - if (is_array($value) && is_array($this->_options[$name])) { - $this->_options[$name] = @array_merge($this->_options[$name], $value); - } else { - $this->_options[$name] = $value; - } - } - } - } - } - - // }}} - // {{{ _createElements() - - function _createElements() - { - $this->_separator = $this->_elements = array(); - $separator = ''; - $locale =& $this->_locale[$this->_options['language']]; - $backslash = false; - for ($i = 0, $length = strlen($this->_options['format']); $i < $length; $i++) { - $sign = $this->_options['format']{$i}; - if ($backslash) { - $backslash = false; - $separator .= $sign; - } else { - $loadSelect = true; - switch ($sign) { - case 'D': - // Sunday is 0 like with 'w' in date() - $options = $locale['weekdays_short']; - break; - case 'l': - $options = $locale['weekdays_long']; - break; - case 'd': - $options = $this->_createOptionList(1, 31); - break; - case 'M': - $options = $locale['months_short']; - array_unshift($options , ''); - unset($options[0]); - break; - case 'm': - $options = $this->_createOptionList(1, 12); - break; - case 'F': - $options = $locale['months_long']; - array_unshift($options , ''); - unset($options[0]); - break; - case 'Y': - $options = $this->_createOptionList( - $this->_options['minYear'], - $this->_options['maxYear'], - $this->_options['minYear'] > $this->_options['maxYear']? -1: 1 - ); - break; - case 'y': - $options = $this->_createOptionList( - $this->_options['minYear'], - $this->_options['maxYear'], - $this->_options['minYear'] > $this->_options['maxYear']? -1: 1 - ); - array_walk($options, create_function('&$v,$k','$v = substr($v,-2);')); - break; - case 'h': - $options = $this->_createOptionList(1, 12); - break; - case 'g': - $options = $this->_createOptionList(1, 12); - array_walk($options, create_function('&$v,$k', '$v = intval($v);')); - break; - case 'H': - $options = $this->_createOptionList(0, 23); - break; - case 'i': - $options = $this->_createOptionList(0, 59, $this->_options['optionIncrement']['i']); - break; - case 's': - $options = $this->_createOptionList(0, 59, $this->_options['optionIncrement']['s']); - break; - case 'a': - $options = array('am' => 'am', 'pm' => 'pm'); - break; - case 'A': - $options = array('AM' => 'AM', 'PM' => 'PM'); - break; - case 'W': - $options = $this->_createOptionList(1, 53); - break; - case '\\': - $backslash = true; - $loadSelect = false; - break; - default: - $separator .= (' ' == $sign? ' ': $sign); - $loadSelect = false; - } - - if ($loadSelect) { - if (0 < count($this->_elements)) { - $this->_separator[] = $separator; - } else { - $this->_wrap[0] = $separator; - } - $separator = ''; - // Should we add an empty option to the top of the select? - if (!is_array($this->_options['addEmptyOption']) && $this->_options['addEmptyOption'] || - is_array($this->_options['addEmptyOption']) && !empty($this->_options['addEmptyOption'][$sign])) { - - // Using '+' array operator to preserve the keys - if (is_array($this->_options['emptyOptionText']) && !empty($this->_options['emptyOptionText'][$sign])) { - $options = array($this->_options['emptyOptionValue'] => $this->_options['emptyOptionText'][$sign]) + $options; - } else { - $options = array($this->_options['emptyOptionValue'] => $this->_options['emptyOptionText']) + $options; - } - } - $this->_elements[] =& new HTML_QuickForm_select($sign, null, $options, $this->getAttributes()); - } - } - } - $this->_wrap[1] = $separator . ($backslash? '\\': ''); - } - - // }}} - // {{{ _createOptionList() - - /** - * Creates an option list containing the numbers from the start number to the end, inclusive - * - * @param int The start number - * @param int The end number - * @param int Increment by this value - * @access private - * @return array An array of numeric options. - */ - function _createOptionList($start, $end, $step = 1) - { - for ($i = $start, $options = array(); $start > $end? $i >= $end: $i <= $end; $i += $step) { - $options[$i] = sprintf('%02d', $i); - } - return $options; - } - - // }}} - // {{{ _trimLeadingZeros() - - /** - * Trims leading zeros from the (numeric) string - * - * @param string A numeric string, possibly with leading zeros - * @return string String with leading zeros removed - */ - function _trimLeadingZeros($str) - { - if (0 == strcmp($str, $this->_options['emptyOptionValue'])) { - return $str; - } - $trimmed = ltrim($str, '0'); - return strlen($trimmed)? $trimmed: '0'; - } - - // }}} - // {{{ setValue() - - function setValue($value) - { - if (empty($value)) { - $value = array(); - } elseif (is_scalar($value)) { - if (!is_numeric($value)) { - $value = strtotime($value); - } - // might be a unix epoch, then we fill all possible values - $arr = explode('-', date('w-j-n-Y-g-G-i-s-a-A-W', (int)$value)); - $value = array( - 'D' => $arr[0], - 'l' => $arr[0], - 'd' => $arr[1], - 'M' => $arr[2], - 'm' => $arr[2], - 'F' => $arr[2], - 'Y' => $arr[3], - 'y' => $arr[3], - 'h' => $arr[4], - 'g' => $arr[4], - 'H' => $arr[5], - 'i' => $this->_trimLeadingZeros($arr[6]), - 's' => $this->_trimLeadingZeros($arr[7]), - 'a' => $arr[8], - 'A' => $arr[9], - 'W' => $this->_trimLeadingZeros($arr[10]) - ); - } else { - $value = array_map(array($this, '_trimLeadingZeros'), $value); - } - parent::setValue($value); - } - - // }}} - // {{{ toHtml() - - function toHtml() - { - include_once('HTML/QuickForm/Renderer/Default.php'); - $renderer =& new HTML_QuickForm_Renderer_Default(); - $renderer->setElementTemplate('{element}'); - parent::accept($renderer); - return $this->_wrap[0] . $renderer->toHtml() . $this->_wrap[1]; - } - - // }}} - // {{{ accept() - - function accept(&$renderer, $required = false, $error = null) - { - $renderer->renderElement($this, $required, $error); - } - - // }}} - // {{{ onQuickFormEvent() - - function onQuickFormEvent($event, $arg, &$caller) - { - if ('updateValue' == $event) { - // we need to call setValue(), 'cause the default/constant value - // may be in fact a timestamp, not an array - return HTML_QuickForm_element::onQuickFormEvent($event, $arg, $caller); - } else { - return parent::onQuickFormEvent($event, $arg, $caller); - } - } - - // }}} -} -?> \ No newline at end of file diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/element.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/element.php deleted file mode 100644 index caa35b082..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/element.php +++ /dev/null @@ -1,501 +0,0 @@ - - * @author Bertrand Mansion - * @author Alexey Borzov - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Base class for all HTML classes - */ -require_once 'HTML/Common.php'; -/** - * Static utility methods - */ -require_once 'HTML/QuickForm/utils.php'; - -/** - * Base class for form elements - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @author Alexey Borzov - * @version Release: 3.2.16 - * @since 1.0 - * @abstract - */ -class HTML_QuickForm_element extends HTML_Common -{ - // {{{ properties - - /** - * Label of the field - * @var string - * @since 1.3 - * @access private - */ - var $_label = ''; - - /** - * Form element type - * @var string - * @since 1.0 - * @access private - */ - var $_type = ''; - - /** - * Flag to tell if element is frozen - * @var boolean - * @since 1.0 - * @access private - */ - var $_flagFrozen = false; - - /** - * Does the element support persistant data when frozen - * @var boolean - * @since 1.3 - * @access private - */ - var $_persistantFreeze = false; - - // }}} - // {{{ constructor - - /** - * Class constructor - * - * @param string Name of the element - * @param mixed Label(s) for the element - * @param mixed Associative array of tag attributes or HTML attributes name="value" pairs - * @since 1.0 - * @access public - * @return void - */ - function HTML_QuickForm_element($elementName=null, $elementLabel=null, $attributes=null) - { - HTML_Common::HTML_Common($attributes); - if (isset($elementName)) { - $this->setName($elementName); - } - if (isset($elementLabel)) { - $this->setLabel($elementLabel); - } - } //end constructor - - // }}} - // {{{ apiVersion() - - /** - * Returns the current API version - * - * @since 1.0 - * @access public - * @return float - */ - function apiVersion() - { - return 3.2; - } // end func apiVersion - - // }}} - // {{{ getType() - - /** - * Returns element type - * - * @since 1.0 - * @access public - * @return string - */ - function getType() - { - return $this->_type; - } // end func getType - - // }}} - // {{{ setName() - - /** - * Sets the input field name - * - * @param string $name Input field name attribute - * @since 1.0 - * @access public - * @return void - */ - function setName($name) - { - // interface method - } //end func setName - - // }}} - // {{{ getName() - - /** - * Returns the element name - * - * @since 1.0 - * @access public - * @return string - */ - function getName() - { - // interface method - } //end func getName - - // }}} - // {{{ setValue() - - /** - * Sets the value of the form element - * - * @param string $value Default value of the form element - * @since 1.0 - * @access public - * @return void - */ - function setValue($value) - { - // interface - } // end func setValue - - // }}} - // {{{ getValue() - - /** - * Returns the value of the form element - * - * @since 1.0 - * @access public - * @return mixed - */ - function getValue() - { - // interface - return null; - } // end func getValue - - // }}} - // {{{ freeze() - - /** - * Freeze the element so that only its value is returned - * - * @access public - * @return void - */ - function freeze() - { - $this->_flagFrozen = true; - } //end func freeze - - // }}} - // {{{ unfreeze() - - /** - * Unfreezes the element so that it becomes editable - * - * @access public - * @return void - * @since 3.2.4 - */ - function unfreeze() - { - $this->_flagFrozen = false; - } - - // }}} - // {{{ getFrozenHtml() - - /** - * Returns the value of field without HTML tags - * - * @since 1.0 - * @access public - * @return string - */ - function getFrozenHtml() - { - $value = $this->getValue(); - return (strlen($value)? htmlspecialchars($value): ' ') . - $this->_getPersistantData(); - } //end func getFrozenHtml - - // }}} - // {{{ _getPersistantData() - - /** - * Used by getFrozenHtml() to pass the element's value if _persistantFreeze is on - * - * @access private - * @return string - */ - function _getPersistantData() - { - if (!$this->_persistantFreeze) { - return ''; - } else { - $id = $this->getAttribute('id'); - return '_getAttrString(array( - 'type' => 'hidden', - 'name' => $this->getName(), - 'value' => $this->getValue() - ) + (isset($id)? array('id' => $id): array())) . ' />'; - } - } - - // }}} - // {{{ isFrozen() - - /** - * Returns whether or not the element is frozen - * - * @since 1.3 - * @access public - * @return bool - */ - function isFrozen() - { - return $this->_flagFrozen; - } // end func isFrozen - - // }}} - // {{{ setPersistantFreeze() - - /** - * Sets wether an element value should be kept in an hidden field - * when the element is frozen or not - * - * @param bool $persistant True if persistant value - * @since 2.0 - * @access public - * @return void - */ - function setPersistantFreeze($persistant=false) - { - $this->_persistantFreeze = $persistant; - } //end func setPersistantFreeze - - // }}} - // {{{ setLabel() - - /** - * Sets display text for the element - * - * @param string $label Display text for the element - * @since 1.3 - * @access public - * @return void - */ - function setLabel($label) - { - $this->_label = $label; - } //end func setLabel - - // }}} - // {{{ getLabel() - - /** - * Returns display text for the element - * - * @since 1.3 - * @access public - * @return string - */ - function getLabel() - { - return $this->_label; - } //end func getLabel - - // }}} - // {{{ _findValue() - - /** - * Tries to find the element value from the values array - * - * @since 2.7 - * @access private - * @return mixed - */ - function _findValue(&$values) - { - if (empty($values)) { - return null; - } - $elementName = $this->getName(); - if (isset($values[$elementName])) { - return $values[$elementName]; - } elseif (strpos($elementName, '[')) { - - $keys = str_replace( - array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), - $elementName - ); - $arrayKeys = explode("']['", $keys); - return HTML_QuickForm_utils::recursiveValue($values, $arrayKeys); - - } else { - return null; - } - } //end func _findValue - - // }}} - // {{{ onQuickFormEvent() - - /** - * Called by HTML_QuickForm whenever form event is made on this element - * - * @param string $event Name of event - * @param mixed $arg event arguments - * @param object &$caller calling object - * @since 1.0 - * @access public - * @return void - */ - function onQuickFormEvent($event, $arg, &$caller) - { - switch ($event) { - case 'createElement': - $className = get_class($this); - $this->$className($arg[0], $arg[1], $arg[2], $arg[3], $arg[4]); - break; - case 'addElement': - $this->onQuickFormEvent('createElement', $arg, $caller); - $this->onQuickFormEvent('updateValue', null, $caller); - break; - case 'updateValue': - // constant values override both default and submitted ones - // default values are overriden by submitted - $value = $this->_findValue($caller->_constantValues); - if (null === $value) { - $value = $this->_findValue($caller->_submitValues); - if (null === $value) { - $value = $this->_findValue($caller->_defaultValues); - } - } - if (null !== $value) { - $this->setValue($value); - } - break; - case 'setGroupValue': - $this->setValue($arg); - } - return true; - } // end func onQuickFormEvent - - // }}} - // {{{ accept() - - /** - * Accepts a renderer - * - * @param HTML_QuickForm_Renderer renderer object - * @param bool Whether an element is required - * @param string An error message associated with an element - * @access public - * @return void - */ - function accept(&$renderer, $required=false, $error=null) - { - $renderer->renderElement($this, $required, $error); - } // end func accept - - // }}} - // {{{ _generateId() - - /** - * Automatically generates and assigns an 'id' attribute for the element. - * - * Currently used to ensure that labels work on radio buttons and - * checkboxes. Per idea of Alexander Radivanovich. - * - * @access private - * @return void - */ - function _generateId() - { - static $idx = 1; - - if (!$this->getAttribute('id')) { - $this->updateAttributes(array('id' => 'qf_' . substr(md5(microtime() . $idx++), 0, 6))); - } - } // end func _generateId - - // }}} - // {{{ exportValue() - - /** - * Returns a 'safe' element's value - * - * @param array array of submitted values to search - * @param bool whether to return the value as associative array - * @access public - * @return mixed - */ - function exportValue(&$submitValues, $assoc = false) - { - $value = $this->_findValue($submitValues); - if (null === $value) { - $value = $this->getValue(); - } - return $this->_prepareValue($value, $assoc); - } - - // }}} - // {{{ _prepareValue() - - /** - * Used by exportValue() to prepare the value for returning - * - * @param mixed the value found in exportValue() - * @param bool whether to return the value as associative array - * @access private - * @return mixed - */ - function _prepareValue($value, $assoc) - { - if (null === $value) { - return null; - } elseif (!$assoc) { - return $value; - } else { - $name = $this->getName(); - if (!strpos($name, '[')) { - return array($name => $value); - } else { - - $keys = str_replace( - array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), - $name - ); - $keysArray = explode("']['", $keys); - return HTML_QuickForm_utils::recursiveBuild($keysArray, $value); - } - } - } - - // }}} -} // end class HTML_QuickForm_element -?> \ No newline at end of file diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/file.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/file.php deleted file mode 100644 index 02b220d19..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/file.php +++ /dev/null @@ -1,360 +0,0 @@ - - * @author Bertrand Mansion - * @author Alexey Borzov - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Base class for form elements - */ -require_once 'HTML/QuickForm/input.php'; - -// register file-related rules -if (class_exists('HTML_QuickForm')) { - HTML_QuickForm::registerRule('uploadedfile', 'callback', '_ruleIsUploadedFile', 'HTML_QuickForm_file'); - HTML_QuickForm::registerRule('maxfilesize', 'callback', '_ruleCheckMaxFileSize', 'HTML_QuickForm_file'); - HTML_QuickForm::registerRule('mimetype', 'callback', '_ruleCheckMimeType', 'HTML_QuickForm_file'); - HTML_QuickForm::registerRule('filename', 'callback', '_ruleCheckFileName', 'HTML_QuickForm_file'); -} - -/** - * HTML class for a file upload field - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @author Alexey Borzov - * @version Release: 3.2.16 - * @since 1.0 - */ -class HTML_QuickForm_file extends HTML_QuickForm_input -{ - // {{{ properties - - /** - * Uploaded file data, from $_FILES - * @var array - */ - var $_value = null; - - // }}} - // {{{ constructor - - /** - * Class constructor - * - * @param string Input field name attribute - * @param string Input field label - * @param mixed (optional)Either a typical HTML attribute string - * or an associative array - * @since 1.0 - * @access public - */ - function HTML_QuickForm_file($elementName=null, $elementLabel=null, $attributes=null) - { - HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); - $this->setType('file'); - } //end constructor - - // }}} - // {{{ setSize() - - /** - * Sets size of file element - * - * @param int Size of file element - * @since 1.0 - * @access public - */ - function setSize($size) - { - $this->updateAttributes(array('size' => $size)); - } //end func setSize - - // }}} - // {{{ getSize() - - /** - * Returns size of file element - * - * @since 1.0 - * @access public - * @return int - */ - function getSize() - { - return $this->getAttribute('size'); - } //end func getSize - - // }}} - // {{{ freeze() - - /** - * Freeze the element so that only its value is returned - * - * @access public - * @return bool - */ - function freeze() - { - return false; - } //end func freeze - - // }}} - // {{{ setValue() - - /** - * Sets value for file element. - * - * Actually this does nothing. The function is defined here to override - * HTML_Quickform_input's behaviour of setting the 'value' attribute. As - * no sane user-agent uses 's value for anything - * (because of security implications) we implement file's value as a - * read-only property with a special meaning. - * - * @param mixed Value for file element - * @since 3.0 - * @access public - */ - function setValue($value) - { - return null; - } //end func setValue - - // }}} - // {{{ getValue() - - /** - * Returns information about the uploaded file - * - * @since 3.0 - * @access public - * @return array - */ - function getValue() - { - return $this->_value; - } // end func getValue - - // }}} - // {{{ onQuickFormEvent() - - /** - * Called by HTML_QuickForm whenever form event is made on this element - * - * @param string Name of event - * @param mixed event arguments - * @param object calling object - * @since 1.0 - * @access public - * @return bool - */ - function onQuickFormEvent($event, $arg, &$caller) - { - switch ($event) { - case 'updateValue': - if ($caller->getAttribute('method') == 'get') { - return PEAR::raiseError('Cannot add a file upload field to a GET method form'); - } - $this->_value = $this->_findValue(); - $caller->updateAttributes(array('enctype' => 'multipart/form-data')); - $caller->setMaxFileSize(); - break; - case 'addElement': - $this->onQuickFormEvent('createElement', $arg, $caller); - return $this->onQuickFormEvent('updateValue', null, $caller); - break; - case 'createElement': - $className = get_class($this); - $this->$className($arg[0], $arg[1], $arg[2]); - break; - } - return true; - } // end func onQuickFormEvent - - // }}} - // {{{ moveUploadedFile() - - /** - * Moves an uploaded file into the destination - * - * @param string Destination directory path - * @param string New file name - * @access public - * @return bool Whether the file was moved successfully - */ - function moveUploadedFile($dest, $fileName = '') - { - if ($dest != '' && substr($dest, -1) != '/') { - $dest .= '/'; - } - $fileName = ($fileName != '') ? $fileName : basename($this->_value['name']); - return move_uploaded_file($this->_value['tmp_name'], $dest . $fileName); - } // end func moveUploadedFile - - // }}} - // {{{ isUploadedFile() - - /** - * Checks if the element contains an uploaded file - * - * @access public - * @return bool true if file has been uploaded, false otherwise - */ - function isUploadedFile() - { - return $this->_ruleIsUploadedFile($this->_value); - } // end func isUploadedFile - - // }}} - // {{{ _ruleIsUploadedFile() - - /** - * Checks if the given element contains an uploaded file - * - * @param array Uploaded file info (from $_FILES) - * @access private - * @return bool true if file has been uploaded, false otherwise - */ - function _ruleIsUploadedFile($elementValue) - { - if ((isset($elementValue['error']) && $elementValue['error'] == 0) || - (!empty($elementValue['tmp_name']) && $elementValue['tmp_name'] != 'none')) { - return is_uploaded_file($elementValue['tmp_name']); - } else { - return false; - } - } // end func _ruleIsUploadedFile - - // }}} - // {{{ _ruleCheckMaxFileSize() - - /** - * Checks that the file does not exceed the max file size - * - * @param array Uploaded file info (from $_FILES) - * @param int Max file size - * @access private - * @return bool true if filesize is lower than maxsize, false otherwise - */ - function _ruleCheckMaxFileSize($elementValue, $maxSize) - { - if (!empty($elementValue['error']) && - (UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error'])) { - return false; - } - if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) { - return true; - } - return ($maxSize >= @filesize($elementValue['tmp_name'])); - } // end func _ruleCheckMaxFileSize - - // }}} - // {{{ _ruleCheckMimeType() - - /** - * Checks if the given element contains an uploaded file of the right mime type - * - * @param array Uploaded file info (from $_FILES) - * @param mixed Mime Type (can be an array of allowed types) - * @access private - * @return bool true if mimetype is correct, false otherwise - */ - function _ruleCheckMimeType($elementValue, $mimeType) - { - if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) { - return true; - } - if (is_array($mimeType)) { - return in_array($elementValue['type'], $mimeType); - } - return $elementValue['type'] == $mimeType; - } // end func _ruleCheckMimeType - - // }}} - // {{{ _ruleCheckFileName() - - /** - * Checks if the given element contains an uploaded file of the filename regex - * - * @param array Uploaded file info (from $_FILES) - * @param string Regular expression - * @access private - * @return bool true if name matches regex, false otherwise - */ - function _ruleCheckFileName($elementValue, $regex) - { - if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) { - return true; - } - return (bool)preg_match($regex, $elementValue['name']); - } // end func _ruleCheckFileName - - // }}} - // {{{ _findValue() - - /** - * Tries to find the element value from the values array - * - * Needs to be redefined here as $_FILES is populated differently from - * other arrays when element name is of the form foo[bar] - * - * @param bool $sc1 unused, for signature compatibility - * - * @access private - * @return mixed - */ - function _findValue(&$sc1 = null) - { - if (empty($_FILES)) { - return null; - } - $elementName = $this->getName(); - if (isset($_FILES[$elementName])) { - return $_FILES[$elementName]; - } elseif (false !== ($pos = strpos($elementName, '['))) { - $base = str_replace( - array('\\', '\''), array('\\\\', '\\\''), - substr($elementName, 0, $pos) - ); - $idx = "['" . str_replace( - array('\\', '\'', ']', '['), array('\\\\', '\\\'', '', "']['"), - substr($elementName, $pos + 1, -1) - ) . "']"; - $props = array('name', 'type', 'size', 'tmp_name', 'error'); - $code = "if (!isset(\$_FILES['{$base}']['name']{$idx})) {\n" . - " return null;\n" . - "} else {\n" . - " \$value = array();\n"; - foreach ($props as $prop) { - $code .= " \$value['{$prop}'] = \$_FILES['{$base}']['{$prop}']{$idx};\n"; - } - return eval($code . " return \$value;\n}\n"); - } else { - return null; - } - } - - // }}} -} // end class HTML_QuickForm_file -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/group.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/group.php deleted file mode 100644 index af1b27f2b..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/group.php +++ /dev/null @@ -1,588 +0,0 @@ - - * @author Bertrand Mansion - * @author Alexey Borzov - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Base class for form elements - */ -require_once 'HTML/QuickForm/element.php'; - -/** - * HTML class for a form element group - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @author Alexey Borzov - * @version Release: 3.2.16 - * @since 1.0 - */ -class HTML_QuickForm_group extends HTML_QuickForm_element -{ - // {{{ properties - - /** - * Name of the element - * @var string - * @since 1.0 - * @access private - */ - var $_name = ''; - - /** - * Array of grouped elements - * @var array - * @since 1.0 - * @access private - */ - var $_elements = array(); - - /** - * String to separate elements - * @var mixed - * @since 2.5 - * @access private - */ - var $_separator = null; - - /** - * Required elements in this group - * @var array - * @since 2.5 - * @access private - */ - var $_required = array(); - - /** - * Whether to change elements' names to $groupName[$elementName] or leave them as is - * @var bool - * @since 3.0 - * @access private - */ - var $_appendName = true; - - // }}} - // {{{ constructor - - /** - * Class constructor - * - * @param string $elementName (optional)Group name - * @param array $elementLabel (optional)Group label - * @param array $elements (optional)Group elements - * @param mixed $separator (optional)Use a string for one separator, - * use an array to alternate the separators. - * @param bool $appendName (optional)whether to change elements' names to - * the form $groupName[$elementName] or leave - * them as is. - * @since 1.0 - * @access public - * @return void - */ - function HTML_QuickForm_group($elementName=null, $elementLabel=null, $elements=null, $separator=null, $appendName = true) - { - $this->HTML_QuickForm_element($elementName, $elementLabel); - $this->_type = 'group'; - if (isset($elements) && is_array($elements)) { - $this->setElements($elements); - } - if (isset($separator)) { - $this->_separator = $separator; - } - if (isset($appendName)) { - $this->_appendName = $appendName; - } - } //end constructor - - // }}} - // {{{ setName() - - /** - * Sets the group name - * - * @param string $name Group name - * @since 1.0 - * @access public - * @return void - */ - function setName($name) - { - $this->_name = $name; - } //end func setName - - // }}} - // {{{ getName() - - /** - * Returns the group name - * - * @since 1.0 - * @access public - * @return string - */ - function getName() - { - return $this->_name; - } //end func getName - - // }}} - // {{{ setValue() - - /** - * Sets values for group's elements - * - * @param mixed Values for group's elements - * @since 1.0 - * @access public - * @return void - */ - function setValue($value) - { - $this->_createElementsIfNotExist(); - foreach (array_keys($this->_elements) as $key) { - if (!$this->_appendName) { - $v = $this->_elements[$key]->_findValue($value); - if (null !== $v) { - $this->_elements[$key]->onQuickFormEvent('setGroupValue', $v, $this); - } - - } else { - $elementName = $this->_elements[$key]->getName(); - $index = strlen($elementName) ? $elementName : $key; - if (is_array($value)) { - if (isset($value[$index])) { - $this->_elements[$key]->onQuickFormEvent('setGroupValue', $value[$index], $this); - } - } elseif (isset($value)) { - $this->_elements[$key]->onQuickFormEvent('setGroupValue', $value, $this); - } - } - } - } //end func setValue - - // }}} - // {{{ getValue() - - /** - * Returns the value of the group - * - * @since 1.0 - * @access public - * @return mixed - */ - function getValue() - { - $value = null; - foreach (array_keys($this->_elements) as $key) { - $element =& $this->_elements[$key]; - switch ($element->getType()) { - case 'radio': - $v = $element->getChecked()? $element->getValue(): null; - break; - case 'checkbox': - $v = $element->getChecked()? true: null; - break; - default: - $v = $element->getValue(); - } - if (null !== $v) { - $elementName = $element->getName(); - if (is_null($elementName)) { - $value = $v; - } else { - if (!is_array($value)) { - $value = is_null($value)? array(): array($value); - } - if ('' === $elementName) { - $value[] = $v; - } else { - $value[$elementName] = $v; - } - } - } - } - return $value; - } // end func getValue - - // }}} - // {{{ setElements() - - /** - * Sets the grouped elements - * - * @param array $elements Array of elements - * @since 1.1 - * @access public - * @return void - */ - function setElements($elements) - { - $this->_elements = array_values($elements); - if ($this->_flagFrozen) { - $this->freeze(); - } - } // end func setElements - - // }}} - // {{{ getElements() - - /** - * Gets the grouped elements - * - * @since 2.4 - * @access public - * @return array - */ - function &getElements() - { - $this->_createElementsIfNotExist(); - return $this->_elements; - } // end func getElements - - // }}} - // {{{ getGroupType() - - /** - * Gets the group type based on its elements - * Will return 'mixed' if elements contained in the group - * are of different types. - * - * @access public - * @return string group elements type - */ - function getGroupType() - { - $this->_createElementsIfNotExist(); - $prevType = ''; - foreach (array_keys($this->_elements) as $key) { - $type = $this->_elements[$key]->getType(); - if ($type != $prevType && $prevType != '') { - return 'mixed'; - } - $prevType = $type; - } - return $type; - } // end func getGroupType - - // }}} - // {{{ toHtml() - - /** - * Returns Html for the group - * - * @since 1.0 - * @access public - * @return string - */ - function toHtml() - { - include_once('HTML/QuickForm/Renderer/Default.php'); - $renderer = new HTML_QuickForm_Renderer_Default(); - $renderer->setElementTemplate('{element}'); - $this->accept($renderer); - return $renderer->toHtml(); - } //end func toHtml - - // }}} - // {{{ getElementName() - - /** - * Returns the element name inside the group such as found in the html form - * - * @param mixed $index Element name or element index in the group - * @since 3.0 - * @access public - * @return mixed string with element name, false if not found - */ - function getElementName($index) - { - $this->_createElementsIfNotExist(); - $elementName = false; - if (is_int($index) && isset($this->_elements[$index])) { - $elementName = $this->_elements[$index]->getName(); - if (isset($elementName) && $elementName == '') { - $elementName = $index; - } - if ($this->_appendName) { - if (is_null($elementName)) { - $elementName = $this->getName(); - } else { - $elementName = $this->getName().'['.$elementName.']'; - } - } - - } elseif (is_string($index)) { - foreach (array_keys($this->_elements) as $key) { - $elementName = $this->_elements[$key]->getName(); - if ($index == $elementName) { - if ($this->_appendName) { - $elementName = $this->getName().'['.$elementName.']'; - } - break; - } elseif ($this->_appendName && $this->getName().'['.$elementName.']' == $index) { - break; - } - } - } - return $elementName; - } //end func getElementName - - // }}} - // {{{ getFrozenHtml() - - /** - * Returns the value of field without HTML tags - * - * @since 1.3 - * @access public - * @return string - */ - function getFrozenHtml() - { - $flags = array(); - $this->_createElementsIfNotExist(); - foreach (array_keys($this->_elements) as $key) { - if (false === ($flags[$key] = $this->_elements[$key]->isFrozen())) { - $this->_elements[$key]->freeze(); - } - } - $html = $this->toHtml(); - foreach (array_keys($this->_elements) as $key) { - if (!$flags[$key]) { - $this->_elements[$key]->unfreeze(); - } - } - return $html; - } //end func getFrozenHtml - - // }}} - // {{{ onQuickFormEvent() - - /** - * Called by HTML_QuickForm whenever form event is made on this element - * - * @param string $event Name of event - * @param mixed $arg event arguments - * @param object &$caller calling object - * @since 1.0 - * @access public - * @return void - */ - function onQuickFormEvent($event, $arg, &$caller) - { - switch ($event) { - case 'updateValue': - $this->_createElementsIfNotExist(); - foreach (array_keys($this->_elements) as $key) { - if ($this->_appendName) { - $elementName = $this->_elements[$key]->getName(); - if (is_null($elementName)) { - $this->_elements[$key]->setName($this->getName()); - } elseif ('' === $elementName) { - $this->_elements[$key]->setName($this->getName() . '[' . $key . ']'); - } else { - $this->_elements[$key]->setName($this->getName() . '[' . $elementName . ']'); - } - } - $this->_elements[$key]->onQuickFormEvent('updateValue', $arg, $caller); - if ($this->_appendName) { - $this->_elements[$key]->setName($elementName); - } - } - break; - - default: - parent::onQuickFormEvent($event, $arg, $caller); - } - return true; - } // end func onQuickFormEvent - - // }}} - // {{{ accept() - - /** - * Accepts a renderer - * - * @param HTML_QuickForm_Renderer renderer object - * @param bool Whether a group is required - * @param string An error message associated with a group - * @access public - * @return void - */ - function accept(&$renderer, $required = false, $error = null) - { - $this->_createElementsIfNotExist(); - $renderer->startGroup($this, $required, $error); - $name = $this->getName(); - foreach (array_keys($this->_elements) as $key) { - $element =& $this->_elements[$key]; - - if ($this->_appendName) { - $elementName = $element->getName(); - if (isset($elementName)) { - $element->setName($name . '['. (strlen($elementName)? $elementName: $key) .']'); - } else { - $element->setName($name); - } - } - - $required = !$element->isFrozen() && in_array($element->getName(), $this->_required); - - $element->accept($renderer, $required); - - // restore the element's name - if ($this->_appendName) { - $element->setName($elementName); - } - } - $renderer->finishGroup($this); - } // end func accept - - // }}} - // {{{ exportValue() - - /** - * As usual, to get the group's value we access its elements and call - * their exportValue() methods - */ - function exportValue(&$submitValues, $assoc = false) - { - $value = null; - foreach (array_keys($this->_elements) as $key) { - $elementName = $this->_elements[$key]->getName(); - if ($this->_appendName) { - if (is_null($elementName)) { - $this->_elements[$key]->setName($this->getName()); - } elseif ('' === $elementName) { - $this->_elements[$key]->setName($this->getName() . '[' . $key . ']'); - } else { - $this->_elements[$key]->setName($this->getName() . '[' . $elementName . ']'); - } - } - $v = $this->_elements[$key]->exportValue($submitValues, $assoc); - if ($this->_appendName) { - $this->_elements[$key]->setName($elementName); - } - if (null !== $v) { - // Make $value an array, we will use it like one - if (null === $value) { - $value = array(); - } - if ($assoc) { - // just like HTML_QuickForm::exportValues() - $value = HTML_QuickForm::arrayMerge($value, $v); - } else { - // just like getValue(), but should work OK every time here - if (is_null($elementName)) { - $value = $v; - } elseif ('' === $elementName) { - $value[] = $v; - } else { - $value[$elementName] = $v; - } - } - } - } - // do not pass the value through _prepareValue, we took care of this already - return $value; - } - - // }}} - // {{{ _createElements() - - /** - * Creates the group's elements. - * - * This should be overriden by child classes that need to create their - * elements. The method will be called automatically when needed, calling - * it from the constructor is discouraged as the constructor is usually - * called _twice_ on element creation, first time with _no_ parameters. - * - * @access private - * @abstract - */ - function _createElements() - { - // abstract - } - - // }}} - // {{{ _createElementsIfNotExist() - - /** - * A wrapper around _createElements() - * - * This method calls _createElements() if the group's _elements array - * is empty. It also performs some updates, e.g. freezes the created - * elements if the group is already frozen. - * - * @access private - */ - function _createElementsIfNotExist() - { - if (empty($this->_elements)) { - $this->_createElements(); - if ($this->_flagFrozen) { - $this->freeze(); - } - } - } - - // }}} - // {{{ freeze() - - function freeze() - { - parent::freeze(); - foreach (array_keys($this->_elements) as $key) { - $this->_elements[$key]->freeze(); - } - } - - // }}} - // {{{ unfreeze() - - function unfreeze() - { - parent::unfreeze(); - foreach (array_keys($this->_elements) as $key) { - $this->_elements[$key]->unfreeze(); - } - } - - // }}} - // {{{ setPersistantFreeze() - - function setPersistantFreeze($persistant = false) - { - parent::setPersistantFreeze($persistant); - foreach (array_keys($this->_elements) as $key) { - $this->_elements[$key]->setPersistantFreeze($persistant); - } - } - - // }}} -} //end class HTML_QuickForm_group -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/header.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/header.php deleted file mode 100644 index 6265a39d4..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/header.php +++ /dev/null @@ -1,76 +0,0 @@ - - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * HTML class for static data - */ -require_once 'HTML/QuickForm/static.php'; - -/** - * A pseudo-element used for adding headers to form - * - * @category HTML - * @package HTML_QuickForm - * @author Alexey Borzov - * @version Release: 3.2.16 - * @since 3.0 - */ -class HTML_QuickForm_header extends HTML_QuickForm_static -{ - // {{{ constructor - - /** - * Class constructor - * - * @param string $elementName Header name - * @param string $text Header text - * @access public - * @return void - */ - function HTML_QuickForm_header($elementName = null, $text = null) - { - $this->HTML_QuickForm_static($elementName, null, $text); - $this->_type = 'header'; - } - - // }}} - // {{{ accept() - - /** - * Accepts a renderer - * - * @param HTML_QuickForm_Renderer renderer object - * @param bool $sc1 unused, for signature compatibility - * @param bool $sc2 unused, for signature compatibility - * @access public - * @return void - */ - function accept(&$renderer, $sc1 = false, $sc2 = null) - { - $renderer->renderHeader($this); - } // end func accept - - // }}} - -} //end class HTML_QuickForm_header -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/hidden.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/hidden.php deleted file mode 100644 index e3a9a8b59..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/hidden.php +++ /dev/null @@ -1,96 +0,0 @@ - - * @author Bertrand Mansion - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Base class for form elements - */ -require_once 'HTML/QuickForm/input.php'; - -/** - * HTML class for a hidden type element - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @version Release: 3.2.16 - * @since 1.0 - */ -class HTML_QuickForm_hidden extends HTML_QuickForm_input -{ - // {{{ constructor - - /** - * Class constructor - * - * @param string $elementName (optional)Input field name attribute - * @param string $value (optional)Input field value - * @param mixed $attributes (optional)Either a typical HTML attribute string - * or an associative array - * @since 1.0 - * @access public - * @return void - */ - function HTML_QuickForm_hidden($elementName=null, $value='', $attributes=null) - { - HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); - $this->setType('hidden'); - $this->setValue($value); - } //end constructor - - // }}} - // {{{ freeze() - - /** - * Freeze the element so that only its value is returned - * - * @access public - * @return void - */ - function freeze() - { - return false; - } //end func freeze - - // }}} - // {{{ accept() - - /** - * Accepts a renderer - * - * @param HTML_QuickForm_Renderer renderer object - * @param bool $sc1 unused, for signature compatibility - * @param bool $sc2 unused, for signature compatibility - * @access public - * @return void - */ - function accept(&$renderer, $sc1 = false, $sc2 = null) - { - $renderer->renderHidden($this); - } // end func accept - - // }}} - -} //end class HTML_QuickForm_hidden -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/hiddenselect.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/hiddenselect.php deleted file mode 100644 index be32ddf49..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/hiddenselect.php +++ /dev/null @@ -1,122 +0,0 @@ - - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Class for elements - */ -require_once 'HTML/QuickForm/select.php'; - -/** - * Hidden select pseudo-element - * - * This class takes the same arguments as a select element, but instead - * of creating a select ring it creates hidden elements for all values - * already selected with setDefault or setConstant. This is useful if - * you have a select ring that you don't want visible, but you need all - * selected values to be passed. - * - * @category HTML - * @package HTML_QuickForm - * @author Isaac Shepard - * @version Release: 3.2.16 - * @since 2.1 - */ -class HTML_QuickForm_hiddenselect extends HTML_QuickForm_select -{ - // {{{ constructor - - /** - * Class constructor - * - * @param string Select name attribute - * @param mixed Label(s) for the select (not used) - * @param mixed Data to be used to populate options - * @param mixed Either a typical HTML attribute string or an associative array (not used) - * @since 1.0 - * @access public - * @return void - */ - function HTML_QuickForm_hiddenselect($elementName=null, $elementLabel=null, $options=null, $attributes=null) - { - HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes); - $this->_persistantFreeze = true; - $this->_type = 'hiddenselect'; - if (isset($options)) { - $this->load($options); - } - } //end constructor - - // }}} - // {{{ toHtml() - - /** - * Returns the SELECT in HTML - * - * @since 1.0 - * @access public - * @return string - * @throws - */ - function toHtml() - { - if (empty($this->_values)) { - return ''; - } - - $tabs = $this->_getTabs(); - $name = $this->getPrivateName(); - $strHtml = ''; - - foreach ($this->_values as $key => $val) { - for ($i = 0, $optCount = count($this->_options); $i < $optCount; $i++) { - if ($val == $this->_options[$i]['attr']['value']) { - $strHtml .= $tabs . '_getAttrString(array( - 'type' => 'hidden', - 'name' => $name, - 'value' => $val - )) . " />\n" ; - } - } - } - - return $strHtml; - } //end func toHtml - - // }}} - // {{{ accept() - - /** - * This is essentially a hidden element and should be rendered as one - * - * @param HTML_QuickForm_Renderer renderer object - * @param bool $sc1 unused, for signature compatibility - * @param bool $sc2 unused, for signature compatibility - */ - function accept(&$renderer, $sc1 = false, $sc2 = null) - { - $renderer->renderHidden($this); - } - - // }}} -} //end class HTML_QuickForm_hiddenselect -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/hierselect.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/hierselect.php deleted file mode 100644 index e63a8b7d1..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/hierselect.php +++ /dev/null @@ -1,650 +0,0 @@ - - * @author Bertrand Mansion - * @author Alexey Borzov - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Class for a group of form elements - */ -require_once 'HTML/QuickForm/group.php'; -/** - * Class for elements - */ -require_once 'HTML/QuickForm/select.php'; -/** - * Static utility methods - */ -require_once 'HTML/QuickForm/utils.php'; - -/** - * Hierarchical select element - * - * Class to dynamically create two or more HTML Select elements - * The first select changes the content of the second select and so on. - * This element is considered as a group. Selects will be named - * groupName[0], groupName[1], groupName[2]... - * - * @category HTML - * @package HTML_QuickForm - * @author Herim Vasquez - * @author Bertrand Mansion - * @author Alexey Borzov - * @version Release: 3.2.16 - * @since 3.1 - */ -class HTML_QuickForm_hierselect extends HTML_QuickForm_group -{ - // {{{ properties - - /** - * Options for all the select elements - * - * @see setOptions() - * @var array - * @access private - */ - var $_options = array(); - - /** - * Number of select elements on this group - * - * @var int - * @access private - */ - var $_nbElements = 0; - - /** - * The javascript used to set and change the options - * - * @var string - * @access private - */ - var $_js = ''; - - // }}} - // {{{ constructor - - /** - * Class constructor - * - * @param string $elementName (optional)Input field name attribute - * @param string $elementLabel (optional)Input field label in form - * @param mixed $attributes (optional)Either a typical HTML attribute string - * or an associative array. Date format is passed along the attributes. - * @param mixed $separator (optional)Use a string for one separator, - * use an array to alternate the separators. - * @access public - * @return void - */ - function HTML_QuickForm_hierselect($elementName=null, $elementLabel=null, $attributes=null, $separator=null) - { - $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes); - $this->_persistantFreeze = true; - if (isset($separator)) { - $this->_separator = $separator; - } - $this->_type = 'hierselect'; - $this->_appendName = true; - } //end constructor - - // }}} - // {{{ setOptions() - - /** - * Initialize the array structure containing the options for each select element. - * Call the functions that actually do the magic. - * - * Format is a bit more complex than for a simple select as we need to know - * which options are related to the ones in the previous select: - * - * Ex: - * - * // first select - * $select1[0] = 'Pop'; - * $select1[1] = 'Classical'; - * $select1[2] = 'Funeral doom'; - * - * // second select - * $select2[0][0] = 'Red Hot Chil Peppers'; - * $select2[0][1] = 'The Pixies'; - * $select2[1][0] = 'Wagner'; - * $select2[1][1] = 'Strauss'; - * $select2[2][0] = 'Pantheist'; - * $select2[2][1] = 'Skepticism'; - * - * // If only need two selects - * // - and using the deprecated functions - * $sel =& $form->addElement('hierselect', 'cds', 'Choose CD:'); - * $sel->setMainOptions($select1); - * $sel->setSecOptions($select2); - * - * // - and using the new setOptions function - * $sel =& $form->addElement('hierselect', 'cds', 'Choose CD:'); - * $sel->setOptions(array($select1, $select2)); - * - * // If you have a third select with prices for the cds - * $select3[0][0][0] = '15.00$'; - * $select3[0][0][1] = '17.00$'; - * // etc - * - * // You can now use - * $sel =& $form->addElement('hierselect', 'cds', 'Choose CD:'); - * $sel->setOptions(array($select1, $select2, $select3)); - * - * - * @param array $options Array of options defining each element - * @access public - * @return void - */ - function setOptions($options) - { - $this->_options = $options; - - if (empty($this->_elements)) { - $this->_nbElements = count($this->_options); - $this->_createElements(); - } else { - // setDefaults has probably been called before this function - // check if all elements have been created - $totalNbElements = count($this->_options); - for ($i = $this->_nbElements; $i < $totalNbElements; $i ++) { - $this->_elements[] =& new HTML_QuickForm_select($i, null, array(), $this->getAttributes()); - $this->_nbElements++; - } - } - - $this->_setOptions(); - } // end func setMainOptions - - // }}} - // {{{ setMainOptions() - - /** - * Sets the options for the first select element. Deprecated. setOptions() should be used. - * - * @param array $array Options for the first select element - * - * @access public - * @deprecated Deprecated since release 3.2.2 - * @return void - */ - function setMainOptions($array) - { - $this->_options[0] = $array; - - if (empty($this->_elements)) { - $this->_nbElements = 2; - $this->_createElements(); - } - } // end func setMainOptions - - // }}} - // {{{ setSecOptions() - - /** - * Sets the options for the second select element. Deprecated. setOptions() should be used. - * The main _options array is initialized and the _setOptions function is called. - * - * @param array $array Options for the second select element - * - * @access public - * @deprecated Deprecated since release 3.2.2 - * @return void - */ - function setSecOptions($array) - { - $this->_options[1] = $array; - - if (empty($this->_elements)) { - $this->_nbElements = 2; - $this->_createElements(); - } else { - // setDefaults has probably been called before this function - // check if all elements have been created - $totalNbElements = 2; - for ($i = $this->_nbElements; $i < $totalNbElements; $i ++) { - $this->_elements[] =& new HTML_QuickForm_select($i, null, array(), $this->getAttributes()); - $this->_nbElements++; - } - } - - $this->_setOptions(); - } // end func setSecOptions - - // }}} - // {{{ _setOptions() - - /** - * Sets the options for each select element - * - * @access private - * @return void - */ - function _setOptions() - { - $arrayKeys = array(); - foreach (array_keys($this->_elements) AS $key) { - if (isset($this->_options[$key])) { - if ((empty($arrayKeys)) || HTML_QuickForm_utils::recursiveIsset($this->_options[$key], $arrayKeys)) { - $array = empty($arrayKeys) ? $this->_options[$key] : HTML_QuickForm_utils::recursiveValue($this->_options[$key], $arrayKeys); - if (is_array($array)) { - $select =& $this->_elements[$key]; - $select->_options = array(); - $select->loadArray($array); - - $value = is_array($v = $select->getValue()) ? $v[0] : key($array); - $arrayKeys[] = $value; - } - } - } - } - } // end func _setOptions - - // }}} - // {{{ setValue() - - /** - * Sets values for group's elements - * - * @param array $value An array of 2 or more values, for the first, - * the second, the third etc. select - * - * @access public - * @return void - */ - function setValue($value) - { - // fix for bug #6766. Hope this doesn't break anything more - // after bug #7961. Forgot that _nbElements was used in - // _createElements() called in several places... - $this->_nbElements = max($this->_nbElements, count($value)); - parent::setValue($value); - $this->_setOptions(); - } // end func setValue - - // }}} - // {{{ _createElements() - - /** - * Creates all the elements for the group - * - * @access private - * @return void - */ - function _createElements() - { - for ($i = 0; $i < $this->_nbElements; $i++) { - $this->_elements[] =& new HTML_QuickForm_select($i, null, array(), $this->getAttributes()); - } - } // end func _createElements - - // }}} - // {{{ toHtml() - - function toHtml() - { - $this->_js = ''; - if (!$this->_flagFrozen) { - // set the onchange attribute for each element except last - $keys = array_keys($this->_elements); - $onChange = array(); - for ($i = 0; $i < count($keys) - 1; $i++) { - $select =& $this->_elements[$keys[$i]]; - $onChange[$i] = $select->getAttribute('onchange'); - $select->updateAttributes( - array('onchange' => '_hs_swapOptions(this.form, \'' . $this->_escapeString($this->getName()) . '\', ' . $keys[$i] . ');' . $onChange[$i]) - ); - } - - // create the js function to call - if (!defined('HTML_QUICKFORM_HIERSELECT_EXISTS')) { - $this->_js .= <<_nbElements; $i++) { - $jsParts[] = $this->_convertArrayToJavascript($this->_prepareOptions($this->_options[$i], $i)); - } - $this->_js .= "\n_hs_options['" . $this->_escapeString($this->getName()) . "'] = [\n" . - implode(",\n", $jsParts) . - "\n];\n"; - // default value; if we don't actually have any values yet just use - // the first option (for single selects) or empty array (for multiple) - $values = array(); - foreach (array_keys($this->_elements) as $key) { - if (is_array($v = $this->_elements[$key]->getValue())) { - $values[] = count($v) > 1? $v: $v[0]; - } else { - // XXX: accessing the supposedly private _options array - $values[] = $this->_elements[$key]->getMultiple() || empty($this->_elements[$key]->_options[0])? - array(): - $this->_elements[$key]->_options[0]['attr']['value']; - } - } - $this->_js .= "_hs_defaults['" . $this->_escapeString($this->getName()) . "'] = " . - $this->_convertArrayToJavascript($values) . ";\n"; - } - include_once('HTML/QuickForm/Renderer/Default.php'); - $renderer =& new HTML_QuickForm_Renderer_Default(); - $renderer->setElementTemplate('{element}'); - parent::accept($renderer); - - if (!empty($onChange)) { - $keys = array_keys($this->_elements); - for ($i = 0; $i < count($keys) - 1; $i++) { - $this->_elements[$keys[$i]]->updateAttributes(array('onchange' => $onChange[$i])); - } - } - return (empty($this->_js)? '': "") . - $renderer->toHtml(); - } // end func toHtml - - // }}} - // {{{ accept() - - function accept(&$renderer, $required = false, $error = null) - { - $renderer->renderElement($this, $required, $error); - } // end func accept - - // }}} - // {{{ onQuickFormEvent() - - function onQuickFormEvent($event, $arg, &$caller) - { - if ('updateValue' == $event) { - // we need to call setValue() so that the secondary option - // matches the main option - return HTML_QuickForm_element::onQuickFormEvent($event, $arg, $caller); - } else { - $ret = parent::onQuickFormEvent($event, $arg, $caller); - // add onreset handler to form to properly reset hierselect (see bug #2970) - if ('addElement' == $event) { - $onReset = $caller->getAttribute('onreset'); - if (strlen($onReset)) { - if (strpos($onReset, '_hs_setupOnReset')) { - $caller->updateAttributes(array('onreset' => str_replace('_hs_setupOnReset(this, [', "_hs_setupOnReset(this, ['" . $this->_escapeString($this->getName()) . "', ", $onReset))); - } else { - $caller->updateAttributes(array('onreset' => "var temp = function() { {$onReset} } ; if (!temp()) { return false; } ; if (typeof _hs_setupOnReset != 'undefined') { return _hs_setupOnReset(this, ['" . $this->_escapeString($this->getName()) . "']); } ")); - } - } else { - $caller->updateAttributes(array('onreset' => "if (typeof _hs_setupOnReset != 'undefined') { return _hs_setupOnReset(this, ['" . $this->_escapeString($this->getName()) . "']); } ")); - } - } - return $ret; - } - } // end func onQuickFormEvent - - // }}} - // {{{ _prepareOptions() - - /** - * Prepares options for JS encoding - * - * We need to preserve order of options when adding them via javascript, so - * cannot use object literal and for/in loop (see bug #16603). Therefore we - * convert an associative array of options to two arrays of their values - * and texts. Backport from HTML_QuickForm2. - * - * @param array Options array - * @param int Depth within options array - * @link http://pear.php.net/bugs/bug.php?id=16603 - * @return array - * @access private - */ - function _prepareOptions($ary, $depth) - { - if (!is_array($ary)) { - $ret = $ary; - } elseif (0 == $depth) { - $ret = array('values' => array_keys($ary), 'texts' => array_values($ary)); - } else { - $ret = array(); - foreach ($ary as $k => $v) { - $ret[$k] = $this->_prepareOptions($v, $depth - 1); - } - } - return $ret; - } - - // }}} - // {{{ _convertArrayToJavascript() - - /** - * Converts PHP array to its Javascript analog - * - * @access private - * @param array PHP array to convert - * @return string Javascript representation of the value - */ - function _convertArrayToJavascript($array) - { - if (!is_array($array)) { - return $this->_convertScalarToJavascript($array); - } elseif (count($array) && array_keys($array) != range(0, count($array) - 1)) { - return '{' . implode(',', array_map( - array($this, '_encodeNameValue'), - array_keys($array), array_values($array) - )) . '}'; - } else { - return '[' . implode(',', array_map( - array($this, '_convertArrayToJavascript'), - $array - )) . ']'; - } - } - - // }}} - // {{{ _encodeNameValue() - - /** - * Callback for array_map used to generate JS name-value pairs - * - * @param mixed - * @param mixed - * @return string - */ - function _encodeNameValue($name, $value) - { - return $this->_convertScalarToJavascript((string)$name) . ':' - . $this->_convertArrayToJavascript($value); - } - - // }}} - // {{{ _convertScalarToJavascript() - - /** - * Converts PHP's scalar value to its Javascript analog - * - * @access private - * @param mixed PHP value to convert - * @return string Javascript representation of the value - */ - function _convertScalarToJavascript($val) - { - if (is_bool($val)) { - return $val ? 'true' : 'false'; - } elseif (is_int($val) || is_double($val)) { - return $val; - } elseif (is_string($val)) { - return "'" . $this->_escapeString($val) . "'"; - } elseif (is_null($val)) { - return 'null'; - } else { - // don't bother - return '{}'; - } - } - - // }}} - // {{{ _escapeString() - - /** - * Quotes the string so that it can be used in Javascript string constants - * - * @access private - * @param string - * @return string - */ - function _escapeString($str) - { - return strtr($str,array( - "\r" => '\r', - "\n" => '\n', - "\t" => '\t', - "'" => "\\'", - '"' => '\"', - '\\' => '\\\\' - )); - } - - // }}} -} // end class HTML_QuickForm_hierselect -?> \ No newline at end of file diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/html.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/html.php deleted file mode 100644 index 64ac85899..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/html.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * HTML class for static data - */ -require_once 'HTML/QuickForm/static.php'; - -/** - * A pseudo-element used for adding raw HTML to form - * - * Intended for use with the default renderer only, template-based - * ones may (and probably will) completely ignore this - * - * @category HTML - * @package HTML_QuickForm - * @author Alexey Borzov - * @version Release: 3.2.16 - * @since 3.0 - * @deprecated Please use the templates rather than add raw HTML via this element - */ -class HTML_QuickForm_html extends HTML_QuickForm_static -{ - // {{{ constructor - - /** - * Class constructor - * - * @param string $text raw HTML to add - * @access public - * @return void - */ - function HTML_QuickForm_html($text = null) - { - $this->HTML_QuickForm_static(null, null, $text); - $this->_type = 'html'; - } - - // }}} - // {{{ accept() - - /** - * Accepts a renderer - * - * @param HTML_QuickForm_Renderer renderer object (only works with Default renderer!) - * @param bool $sc1 unused, for signature compatibility - * @param bool $sc2 unused, for signature compatibility - * @access public - * @return void - */ - function accept(&$renderer, $sc1 = false, $sc2 = null) - { - $renderer->renderHtml($this); - } // end func accept - - // }}} - -} //end class HTML_QuickForm_html -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/image.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/image.php deleted file mode 100644 index bf8a8aaa2..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/image.php +++ /dev/null @@ -1,127 +0,0 @@ - element - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 3.01 of the PHP license - * that is available through the world-wide-web at the following URI: - * http://www.php.net/license/3_01.txt If you did not receive a copy of - * the PHP License and are unable to obtain it through the web, please - * send a note to license@php.net so we can mail you a copy immediately. - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Base class for form elements - */ -require_once 'HTML/QuickForm/input.php'; - -/** - * HTML class for an element - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @version Release: 3.2.16 - * @since 1.0 - */ -class HTML_QuickForm_image extends HTML_QuickForm_input -{ - // {{{ constructor - - /** - * Class constructor - * - * @param string $elementName (optional)Element name attribute - * @param string $src (optional)Image source - * @param mixed $attributes (optional)Either a typical HTML attribute string - * or an associative array - * @since 1.0 - * @access public - * @return void - */ - function HTML_QuickForm_image($elementName=null, $src='', $attributes=null) - { - HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); - $this->setType('image'); - $this->setSource($src); - } // end class constructor - - // }}} - // {{{ setSource() - - /** - * Sets source for image element - * - * @param string $src source for image element - * @since 1.0 - * @access public - * @return void - */ - function setSource($src) - { - $this->updateAttributes(array('src' => $src)); - } // end func setSource - - // }}} - // {{{ setBorder() - - /** - * Sets border size for image element - * - * @param string $border border for image element - * @since 1.0 - * @access public - * @return void - */ - function setBorder($border) - { - $this->updateAttributes(array('border' => $border)); - } // end func setBorder - - // }}} - // {{{ setAlign() - - /** - * Sets alignment for image element - * - * @param string $align alignment for image element - * @since 1.0 - * @access public - * @return void - */ - function setAlign($align) - { - $this->updateAttributes(array('align' => $align)); - } // end func setAlign - - // }}} - // {{{ freeze() - - /** - * Freeze the element so that only its value is returned - * - * @access public - * @return void - */ - function freeze() - { - return false; - } //end func freeze - - // }}} - -} // end class HTML_QuickForm_image -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/input.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/input.php deleted file mode 100644 index 0a1f3aad7..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/input.php +++ /dev/null @@ -1,209 +0,0 @@ - form elements - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 3.01 of the PHP license - * that is available through the world-wide-web at the following URI: - * http://www.php.net/license/3_01.txt If you did not receive a copy of - * the PHP License and are unable to obtain it through the web, please - * send a note to license@php.net so we can mail you a copy immediately. - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Base class for form elements - */ -require_once 'HTML/QuickForm/element.php'; - -/** - * Base class for form elements - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @version Release: 3.2.16 - * @since 1.0 - * @abstract - */ -class HTML_QuickForm_input extends HTML_QuickForm_element -{ - // {{{ constructor - - /** - * Class constructor - * - * @param string Input field name attribute - * @param mixed Label(s) for the input field - * @param mixed Either a typical HTML attribute string or an associative array - * @since 1.0 - * @access public - * @return void - */ - function HTML_QuickForm_input($elementName=null, $elementLabel=null, $attributes=null) - { - $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes); - } //end constructor - - // }}} - // {{{ setType() - - /** - * Sets the element type - * - * @param string $type Element type - * @since 1.0 - * @access public - * @return void - */ - function setType($type) - { - $this->_type = $type; - $this->updateAttributes(array('type'=>$type)); - } // end func setType - - // }}} - // {{{ setName() - - /** - * Sets the input field name - * - * @param string $name Input field name attribute - * @since 1.0 - * @access public - * @return void - */ - function setName($name) - { - $this->updateAttributes(array('name'=>$name)); - } //end func setName - - // }}} - // {{{ getName() - - /** - * Returns the element name - * - * @since 1.0 - * @access public - * @return string - */ - function getName() - { - return $this->getAttribute('name'); - } //end func getName - - // }}} - // {{{ setValue() - - /** - * Sets the value of the form element - * - * @param string $value Default value of the form element - * @since 1.0 - * @access public - * @return void - */ - function setValue($value) - { - $this->updateAttributes(array('value'=>$value)); - } // end func setValue - - // }}} - // {{{ getValue() - - /** - * Returns the value of the form element - * - * @since 1.0 - * @access public - * @return string - */ - function getValue() - { - return $this->getAttribute('value'); - } // end func getValue - - // }}} - // {{{ toHtml() - - /** - * Returns the input field in HTML - * - * @since 1.0 - * @access public - * @return string - */ - function toHtml() - { - if ($this->_flagFrozen) { - return $this->getFrozenHtml(); - } else { - return $this->_getTabs() . '_getAttrString($this->_attributes) . ' />'; - } - } //end func toHtml - - // }}} - // {{{ onQuickFormEvent() - - /** - * Called by HTML_QuickForm whenever form event is made on this element - * - * @param string $event Name of event - * @param mixed $arg event arguments - * @param object &$caller calling object - * @since 1.0 - * @access public - * @return void - * @throws - */ - function onQuickFormEvent($event, $arg, &$caller) - { - // do not use submit values for button-type elements - $type = $this->getType(); - if (('updateValue' != $event) || - ('submit' != $type && 'reset' != $type && 'image' != $type && 'button' != $type)) { - parent::onQuickFormEvent($event, $arg, $caller); - } else { - $value = $this->_findValue($caller->_constantValues); - if (null === $value) { - $value = $this->_findValue($caller->_defaultValues); - } - if (null !== $value) { - $this->setValue($value); - } - } - return true; - } // end func onQuickFormEvent - - // }}} - // {{{ exportValue() - - /** - * We don't need values from button-type elements (except submit) and files - */ - function exportValue(&$submitValues, $assoc = false) - { - $type = $this->getType(); - if ('reset' == $type || 'image' == $type || 'button' == $type || 'file' == $type) { - return null; - } else { - return parent::exportValue($submitValues, $assoc); - } - } - - // }}} -} // end class HTML_QuickForm_element -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/link.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/link.php deleted file mode 100644 index acca0e29f..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/link.php +++ /dev/null @@ -1,200 +0,0 @@ - - * @author Bertrand Mansion - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * HTML class for static data - */ -require_once 'HTML/QuickForm/static.php'; - -/** - * HTML class for a link type field - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @version Release: 3.2.16 - * @since 2.0 - */ -class HTML_QuickForm_link extends HTML_QuickForm_static -{ - // {{{ properties - - /** - * Link display text - * @var string - * @since 1.0 - * @access private - */ - var $_text = ""; - - // }}} - // {{{ constructor - - /** - * Class constructor - * - * @param string $elementLabel (optional)Link label - * @param string $href (optional)Link href - * @param string $text (optional)Link display text - * @param mixed $attributes (optional)Either a typical HTML attribute string - * or an associative array - * @since 1.0 - * @access public - * @return void - * @throws - */ - function HTML_QuickForm_link($elementName=null, $elementLabel=null, $href=null, $text=null, $attributes=null) - { - HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes); - $this->_persistantFreeze = false; - $this->_type = 'link'; - $this->setHref($href); - $this->_text = $text; - } //end constructor - - // }}} - // {{{ setName() - - /** - * Sets the input field name - * - * @param string $name Input field name attribute - * @since 1.0 - * @access public - * @return void - * @throws - */ - function setName($name) - { - $this->updateAttributes(array('name'=>$name)); - } //end func setName - - // }}} - // {{{ getName() - - /** - * Returns the element name - * - * @since 1.0 - * @access public - * @return string - * @throws - */ - function getName() - { - return $this->getAttribute('name'); - } //end func getName - - // }}} - // {{{ setValue() - - /** - * Sets value for textarea element - * - * @param string $value Value for password element - * @since 1.0 - * @access public - * @return void - * @throws - */ - function setValue($value) - { - return; - } //end func setValue - - // }}} - // {{{ getValue() - - /** - * Returns the value of the form element - * - * @since 1.0 - * @access public - * @return void - * @throws - */ - function getValue() - { - return; - } // end func getValue - - - // }}} - // {{{ setHref() - - /** - * Sets the links href - * - * @param string $href - * @since 1.0 - * @access public - * @return void - * @throws - */ - function setHref($href) - { - $this->updateAttributes(array('href'=>$href)); - } // end func setHref - - // }}} - // {{{ toHtml() - - /** - * Returns the textarea element in HTML - * - * @since 1.0 - * @access public - * @return string - * @throws - */ - function toHtml() - { - $tabs = $this->_getTabs(); - $html = "$tabs_getAttrString($this->_attributes).">"; - $html .= $this->_text; - $html .= ""; - return $html; - } //end func toHtml - - // }}} - // {{{ getFrozenHtml() - - /** - * Returns the value of field without HTML tags (in this case, value is changed to a mask) - * - * @since 1.0 - * @access public - * @return string - * @throws - */ - function getFrozenHtml() - { - return; - } //end func getFrozenHtml - - // }}} - -} //end class HTML_QuickForm_textarea -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/password.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/password.php deleted file mode 100644 index 5d41e9a31..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/password.php +++ /dev/null @@ -1,115 +0,0 @@ - - * @author Bertrand Mansion - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Base class for form elements - */ -require_once 'HTML/QuickForm/input.php'; - -/** - * HTML class for a password type field - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @version Release: 3.2.16 - * @since 1.0 - */ -class HTML_QuickForm_password extends HTML_QuickForm_input -{ - // {{{ constructor - - /** - * Class constructor - * - * @param string $elementName (optional)Input field name attribute - * @param string $elementLabel (optional)Input field label - * @param mixed $attributes (optional)Either a typical HTML attribute string - * or an associative array - * @since 1.0 - * @access public - * @return void - * @throws - */ - function HTML_QuickForm_password($elementName=null, $elementLabel=null, $attributes=null) - { - HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); - $this->setType('password'); - } //end constructor - - // }}} - // {{{ setSize() - - /** - * Sets size of password element - * - * @param string $size Size of password field - * @since 1.0 - * @access public - * @return void - */ - function setSize($size) - { - $this->updateAttributes(array('size'=>$size)); - } //end func setSize - - // }}} - // {{{ setMaxlength() - - /** - * Sets maxlength of password element - * - * @param string $maxlength Maximum length of password field - * @since 1.0 - * @access public - * @return void - */ - function setMaxlength($maxlength) - { - $this->updateAttributes(array('maxlength'=>$maxlength)); - } //end func setMaxlength - - // }}} - // {{{ getFrozenHtml() - - /** - * Returns the value of field without HTML tags (in this case, value is changed to a mask) - * - * @since 1.0 - * @access public - * @return string - * @throws - */ - function getFrozenHtml() - { - $value = $this->getValue(); - return ('' != $value? '**********': ' ') . - $this->_getPersistantData(); - } //end func getFrozenHtml - - // }}} - -} //end class HTML_QuickForm_password -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/radio.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/radio.php deleted file mode 100644 index 97b4ebaa5..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/radio.php +++ /dev/null @@ -1,251 +0,0 @@ - - * @author Bertrand Mansion - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Base class for form elements - */ -require_once 'HTML/QuickForm/input.php'; - -/** - * HTML class for a radio type element - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @version Release: 3.2.16 - * @since 1.0 - */ -class HTML_QuickForm_radio extends HTML_QuickForm_input -{ - // {{{ properties - - /** - * Radio display text - * @var string - * @since 1.1 - * @access private - */ - var $_text = ''; - - // }}} - // {{{ constructor - - /** - * Class constructor - * - * @param string Input field name attribute - * @param mixed Label(s) for a field - * @param string Text to display near the radio - * @param string Input field value - * @param mixed Either a typical HTML attribute string or an associative array - * @since 1.0 - * @access public - * @return void - */ - function HTML_QuickForm_radio($elementName=null, $elementLabel=null, $text=null, $value=null, $attributes=null) - { - $this->HTML_QuickForm_element($elementName, $elementLabel, $attributes); - if (isset($value)) { - $this->setValue($value); - } - $this->_persistantFreeze = true; - $this->setType('radio'); - $this->_text = $text; - $this->_generateId(); - } //end constructor - - // }}} - // {{{ setChecked() - - /** - * Sets whether radio button is checked - * - * @param bool $checked Whether the field is checked or not - * @since 1.0 - * @access public - * @return void - */ - function setChecked($checked) - { - if (!$checked) { - $this->removeAttribute('checked'); - } else { - $this->updateAttributes(array('checked'=>'checked')); - } - } //end func setChecked - - // }}} - // {{{ getChecked() - - /** - * Returns whether radio button is checked - * - * @since 1.0 - * @access public - * @return string - */ - function getChecked() - { - return $this->getAttribute('checked'); - } //end func getChecked - - // }}} - // {{{ toHtml() - - /** - * Returns the radio element in HTML - * - * @since 1.0 - * @access public - * @return string - */ - function toHtml() - { - if (0 == strlen($this->_text)) { - $label = ''; - } elseif ($this->_flagFrozen) { - $label = $this->_text; - } else { - $label = ''; - } - return HTML_QuickForm_input::toHtml() . $label; - } //end func toHtml - - // }}} - // {{{ getFrozenHtml() - - /** - * Returns the value of field without HTML tags - * - * @since 1.0 - * @access public - * @return string - */ - function getFrozenHtml() - { - if ($this->getChecked()) { - return '(x)' . - $this->_getPersistantData(); - } else { - return '( )'; - } - } //end func getFrozenHtml - - // }}} - // {{{ setText() - - /** - * Sets the radio text - * - * @param string $text Text to display near the radio button - * @since 1.1 - * @access public - * @return void - */ - function setText($text) - { - $this->_text = $text; - } //end func setText - - // }}} - // {{{ getText() - - /** - * Returns the radio text - * - * @since 1.1 - * @access public - * @return string - */ - function getText() - { - return $this->_text; - } //end func getText - - // }}} - // {{{ onQuickFormEvent() - - /** - * Called by HTML_QuickForm whenever form event is made on this element - * - * @param string $event Name of event - * @param mixed $arg event arguments - * @param object &$caller calling object - * @since 1.0 - * @access public - * @return void - */ - function onQuickFormEvent($event, $arg, &$caller) - { - switch ($event) { - case 'updateValue': - // constant values override both default and submitted ones - // default values are overriden by submitted - $value = $this->_findValue($caller->_constantValues); - if (null === $value) { - $value = $this->_findValue($caller->_submitValues); - if (null === $value) { - $value = $this->_findValue($caller->_defaultValues); - } - } - if (!is_null($value) && $value == $this->getValue()) { - $this->setChecked(true); - } else { - $this->setChecked(false); - } - break; - case 'setGroupValue': - if ($arg == $this->getValue()) { - $this->setChecked(true); - } else { - $this->setChecked(false); - } - break; - default: - parent::onQuickFormEvent($event, $arg, $caller); - } - return true; - } // end func onQuickFormLoad - - // }}} - // {{{ exportValue() - - /** - * Returns the value attribute if the radio is checked, null if it is not - */ - function exportValue(&$submitValues, $assoc = false) - { - $value = $this->_findValue($submitValues); - if (null === $value) { - $value = $this->getChecked()? $this->getValue(): null; - } elseif ($value != $this->getValue()) { - $value = null; - } - return $this->_prepareValue($value, $assoc); - } - - // }}} -} //end class HTML_QuickForm_radio -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/reset.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/reset.php deleted file mode 100644 index 6c8dade13..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/reset.php +++ /dev/null @@ -1,79 +0,0 @@ - - * @author Bertrand Mansion - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Base class for form elements - */ -require_once 'HTML/QuickForm/input.php'; - -/** - * HTML class for a reset type element - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @version Release: 3.2.16 - * @since 1.0 - */ -class HTML_QuickForm_reset extends HTML_QuickForm_input -{ - // {{{ constructor - - /** - * Class constructor - * - * @param string $elementName (optional)Input field name attribute - * @param string $value (optional)Input field value - * @param mixed $attributes (optional)Either a typical HTML attribute string - * or an associative array - * @since 1.0 - * @access public - * @return void - */ - function HTML_QuickForm_reset($elementName=null, $value=null, $attributes=null) - { - HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); - $this->setValue($value); - $this->setType('reset'); - } //end constructor - - // }}} - // {{{ freeze() - - /** - * Freeze the element so that only its value is returned - * - * @access public - * @return void - */ - function freeze() - { - return false; - } //end func freeze - - // }}} - -} //end class HTML_QuickForm_reset -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/select.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/select.php deleted file mode 100644 index c6ada5488..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/select.php +++ /dev/null @@ -1,614 +0,0 @@ - - * @author Bertrand Mansion - * @author Alexey Borzov - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Base class for form elements - */ -require_once 'HTML/QuickForm/element.php'; - -/** - * Class to dynamically create an HTML SELECT - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @author Alexey Borzov - * @version Release: 3.2.16 - * @since 1.0 - */ -class HTML_QuickForm_select extends HTML_QuickForm_element { - - // {{{ properties - - /** - * Contains the select options - * - * @var array - * @since 1.0 - * @access private - */ - var $_options = array(); - - /** - * Default values of the SELECT - * - * @var string - * @since 1.0 - * @access private - */ - var $_values = null; - - // }}} - // {{{ constructor - - /** - * Class constructor - * - * @param string Select name attribute - * @param mixed Label(s) for the select - * @param mixed Data to be used to populate options - * @param mixed Either a typical HTML attribute string or an associative array - * @since 1.0 - * @access public - * @return void - */ - function HTML_QuickForm_select($elementName=null, $elementLabel=null, $options=null, $attributes=null) - { - HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes); - $this->_persistantFreeze = true; - $this->_type = 'select'; - if (isset($options)) { - $this->load($options); - } - } //end constructor - - // }}} - // {{{ apiVersion() - - /** - * Returns the current API version - * - * @since 1.0 - * @access public - * @return double - */ - function apiVersion() - { - return 2.3; - } //end func apiVersion - - // }}} - // {{{ setSelected() - - /** - * Sets the default values of the select box - * - * @param mixed $values Array or comma delimited string of selected values - * @since 1.0 - * @access public - * @return void - */ - function setSelected($values) - { - if (is_string($values) && $this->getMultiple()) { - $values = preg_split("/[ ]?,[ ]?/", $values); - } - if (is_array($values)) { - $this->_values = array_values($values); - } else { - $this->_values = array($values); - } - } //end func setSelected - - // }}} - // {{{ getSelected() - - /** - * Returns an array of the selected values - * - * @since 1.0 - * @access public - * @return array of selected values - */ - function getSelected() - { - return $this->_values; - } // end func getSelected - - // }}} - // {{{ setName() - - /** - * Sets the input field name - * - * @param string $name Input field name attribute - * @since 1.0 - * @access public - * @return void - */ - function setName($name) - { - $this->updateAttributes(array('name' => $name)); - } //end func setName - - // }}} - // {{{ getName() - - /** - * Returns the element name - * - * @since 1.0 - * @access public - * @return string - */ - function getName() - { - return $this->getAttribute('name'); - } //end func getName - - // }}} - // {{{ getPrivateName() - - /** - * Returns the element name (possibly with brackets appended) - * - * @since 1.0 - * @access public - * @return string - */ - function getPrivateName() - { - if ($this->getAttribute('multiple')) { - return $this->getName() . '[]'; - } else { - return $this->getName(); - } - } //end func getPrivateName - - // }}} - // {{{ setValue() - - /** - * Sets the value of the form element - * - * @param mixed $values Array or comma delimited string of selected values - * @since 1.0 - * @access public - * @return void - */ - function setValue($value) - { - $this->setSelected($value); - } // end func setValue - - // }}} - // {{{ getValue() - - /** - * Returns an array of the selected values - * - * @since 1.0 - * @access public - * @return array of selected values - */ - function getValue() - { - return $this->_values; - } // end func getValue - - // }}} - // {{{ setSize() - - /** - * Sets the select field size, only applies to 'multiple' selects - * - * @param int $size Size of select field - * @since 1.0 - * @access public - * @return void - */ - function setSize($size) - { - $this->updateAttributes(array('size' => $size)); - } //end func setSize - - // }}} - // {{{ getSize() - - /** - * Returns the select field size - * - * @since 1.0 - * @access public - * @return int - */ - function getSize() - { - return $this->getAttribute('size'); - } //end func getSize - - // }}} - // {{{ setMultiple() - - /** - * Sets the select mutiple attribute - * - * @param bool $multiple Whether the select supports multi-selections - * @since 1.2 - * @access public - * @return void - */ - function setMultiple($multiple) - { - if ($multiple) { - $this->updateAttributes(array('multiple' => 'multiple')); - } else { - $this->removeAttribute('multiple'); - } - } //end func setMultiple - - // }}} - // {{{ getMultiple() - - /** - * Returns the select mutiple attribute - * - * @since 1.2 - * @access public - * @return bool true if multiple select, false otherwise - */ - function getMultiple() - { - return (bool)$this->getAttribute('multiple'); - } //end func getMultiple - - // }}} - // {{{ addOption() - - /** - * Adds a new OPTION to the SELECT - * - * @param string $text Display text for the OPTION - * @param string $value Value for the OPTION - * @param mixed $attributes Either a typical HTML attribute string - * or an associative array - * @since 1.0 - * @access public - * @return void - */ - function addOption($text, $value, $attributes=null) - { - if (null === $attributes) { - $attributes = array('value' => (string)$value); - } else { - $attributes = $this->_parseAttributes($attributes); - if (isset($attributes['selected'])) { - // the 'selected' attribute will be set in toHtml() - $this->_removeAttr('selected', $attributes); - if (is_null($this->_values)) { - $this->_values = array($value); - } elseif (!in_array($value, $this->_values)) { - $this->_values[] = $value; - } - } - $this->_updateAttrArray($attributes, array('value' => (string)$value)); - } - $this->_options[] = array('text' => $text, 'attr' => $attributes); - } // end func addOption - - // }}} - // {{{ loadArray() - - /** - * Loads the options from an associative array - * - * @param array $arr Associative array of options - * @param mixed $values (optional) Array or comma delimited string of selected values - * @since 1.0 - * @access public - * @return PEAR_Error on error or true - * @throws PEAR_Error - */ - function loadArray($arr, $values=null) - { - if (!is_array($arr)) { - return PEAR::raiseError('Argument 1 of HTML_Select::loadArray is not a valid array'); - } - if (isset($values)) { - $this->setSelected($values); - } - foreach ($arr as $key => $val) { - // Warning: new API since release 2.3 - $this->addOption($val, $key); - } - return true; - } // end func loadArray - - // }}} - // {{{ loadDbResult() - - /** - * Loads the options from DB_result object - * - * If no column names are specified the first two columns of the result are - * used as the text and value columns respectively - * @param object $result DB_result object - * @param string $textCol (optional) Name of column to display as the OPTION text - * @param string $valueCol (optional) Name of column to use as the OPTION value - * @param mixed $values (optional) Array or comma delimited string of selected values - * @since 1.0 - * @access public - * @return PEAR_Error on error or true - * @throws PEAR_Error - */ - function loadDbResult(&$result, $textCol=null, $valueCol=null, $values=null) - { - if (!is_object($result) || !is_a($result, 'db_result')) { - return PEAR::raiseError('Argument 1 of HTML_Select::loadDbResult is not a valid DB_result'); - } - if (isset($values)) { - $this->setValue($values); - } - $fetchMode = ($textCol && $valueCol) ? DB_FETCHMODE_ASSOC : DB_FETCHMODE_ORDERED; - while (is_array($row = $result->fetchRow($fetchMode)) ) { - if ($fetchMode == DB_FETCHMODE_ASSOC) { - $this->addOption($row[$textCol], $row[$valueCol]); - } else { - $this->addOption($row[0], $row[1]); - } - } - return true; - } // end func loadDbResult - - // }}} - // {{{ loadQuery() - - /** - * Queries a database and loads the options from the results - * - * @param mixed $conn Either an existing DB connection or a valid dsn - * @param string $sql SQL query string - * @param string $textCol (optional) Name of column to display as the OPTION text - * @param string $valueCol (optional) Name of column to use as the OPTION value - * @param mixed $values (optional) Array or comma delimited string of selected values - * @since 1.1 - * @access public - * @return void - * @throws PEAR_Error - */ - function loadQuery(&$conn, $sql, $textCol=null, $valueCol=null, $values=null) - { - if (is_string($conn)) { - require_once('DB.php'); - $dbConn = &DB::connect($conn, true); - if (DB::isError($dbConn)) { - return $dbConn; - } - } elseif (is_subclass_of($conn, "db_common")) { - $dbConn = &$conn; - } else { - return PEAR::raiseError('Argument 1 of HTML_Select::loadQuery is not a valid type'); - } - $result = $dbConn->query($sql); - if (DB::isError($result)) { - return $result; - } - $this->loadDbResult($result, $textCol, $valueCol, $values); - $result->free(); - if (is_string($conn)) { - $dbConn->disconnect(); - } - return true; - } // end func loadQuery - - // }}} - // {{{ load() - - /** - * Loads options from different types of data sources - * - * This method is a simulated overloaded method. The arguments, other than the - * first are optional and only mean something depending on the type of the first argument. - * If the first argument is an array then all arguments are passed in order to loadArray. - * If the first argument is a db_result then all arguments are passed in order to loadDbResult. - * If the first argument is a string or a DB connection then all arguments are - * passed in order to loadQuery. - * @param mixed $options Options source currently supports assoc array or DB_result - * @param mixed $param1 (optional) See function detail - * @param mixed $param2 (optional) See function detail - * @param mixed $param3 (optional) See function detail - * @param mixed $param4 (optional) See function detail - * @since 1.1 - * @access public - * @return PEAR_Error on error or true - * @throws PEAR_Error - */ - function load(&$options, $param1=null, $param2=null, $param3=null, $param4=null) - { - switch (true) { - case is_array($options): - return $this->loadArray($options, $param1); - break; - case (is_a($options, 'db_result')): - return $this->loadDbResult($options, $param1, $param2, $param3); - break; - case (is_string($options) && !empty($options) || is_subclass_of($options, "db_common")): - return $this->loadQuery($options, $param1, $param2, $param3, $param4); - break; - } - } // end func load - - // }}} - // {{{ toHtml() - - /** - * Returns the SELECT in HTML - * - * @since 1.0 - * @access public - * @return string - */ - function toHtml() - { - if ($this->_flagFrozen) { - return $this->getFrozenHtml(); - } else { - $tabs = $this->_getTabs(); - $strHtml = ''; - - if ($this->getComment() != '') { - $strHtml .= $tabs . '\n"; - } - - if (!$this->getMultiple()) { - $attrString = $this->_getAttrString($this->_attributes); - } else { - $myName = $this->getName(); - $this->setName($myName . '[]'); - $attrString = $this->_getAttrString($this->_attributes); - $this->setName($myName); - } - $strHtml .= $tabs . '\n"; - - $strValues = is_array($this->_values)? array_map('strval', $this->_values): array(); - foreach ($this->_options as $option) { - if (!empty($strValues) && in_array($option['attr']['value'], $strValues, true)) { - $option['attr']['selected'] = 'selected'; - } - $strHtml .= $tabs . "\t_getAttrString($option['attr']) . '>' . - $option['text'] . "\n"; - } - - return $strHtml . $tabs . ''; - } - } //end func toHtml - - // }}} - // {{{ getFrozenHtml() - - /** - * Returns the value of field without HTML tags - * - * @since 1.0 - * @access public - * @return string - */ - function getFrozenHtml() - { - $value = array(); - if (is_array($this->_values)) { - foreach ($this->_values as $key => $val) { - for ($i = 0, $optCount = count($this->_options); $i < $optCount; $i++) { - if (0 == strcmp($val, $this->_options[$i]['attr']['value'])) { - $value[$key] = $this->_options[$i]['text']; - break; - } - } - } - } - $html = empty($value)? ' ': join('
', $value); - if ($this->_persistantFreeze) { - $name = $this->getPrivateName(); - // Only use id attribute if doing single hidden input - if (1 == count($value)) { - $id = $this->getAttribute('id'); - $idAttr = isset($id)? array('id' => $id): array(); - } else { - $idAttr = array(); - } - foreach ($value as $key => $item) { - $html .= '_getAttrString(array( - 'type' => 'hidden', - 'name' => $name, - 'value' => $this->_values[$key] - ) + $idAttr) . ' />'; - } - } - return $html; - } //end func getFrozenHtml - - // }}} - // {{{ exportValue() - - /** - * We check the options and return only the values that _could_ have been - * selected. We also return a scalar value if select is not "multiple" - */ - function exportValue(&$submitValues, $assoc = false) - { - $value = $this->_findValue($submitValues); - if (is_null($value)) { - $value = $this->getValue(); - } elseif(!is_array($value)) { - $value = array($value); - } - if (is_array($value) && !empty($this->_options)) { - $cleanValue = null; - foreach ($value as $v) { - for ($i = 0, $optCount = count($this->_options); $i < $optCount; $i++) { - if (0 == strcmp($v, $this->_options[$i]['attr']['value'])) { - $cleanValue[] = $v; - break; - } - } - } - } else { - $cleanValue = $value; - } - if (is_array($cleanValue) && !$this->getMultiple()) { - return $this->_prepareValue($cleanValue[0], $assoc); - } else { - return $this->_prepareValue($cleanValue, $assoc); - } - } - - // }}} - // {{{ onQuickFormEvent() - - function onQuickFormEvent($event, $arg, &$caller) - { - if ('updateValue' == $event) { - $value = $this->_findValue($caller->_constantValues); - if (null === $value) { - $value = $this->_findValue($caller->_submitValues); - // Fix for bug #4465 & #5269 - // XXX: should we push this to element::onQuickFormEvent()? - if (null === $value && (!$caller->isSubmitted() || !$this->getMultiple())) { - $value = $this->_findValue($caller->_defaultValues); - } - } - if (null !== $value) { - $this->setValue($value); - } - return true; - } else { - return parent::onQuickFormEvent($event, $arg, $caller); - } - } - - // }}} -} //end class HTML_QuickForm_select -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/static.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/static.php deleted file mode 100644 index acff7c320..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/static.php +++ /dev/null @@ -1,201 +0,0 @@ - - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Base class for form elements - */ -require_once 'HTML/QuickForm/element.php'; - -/** - * HTML class for static data - * - * @category HTML - * @package HTML_QuickForm - * @author Wojciech Gdela - * @version Release: 3.2.16 - * @since 2.7 - */ -class HTML_QuickForm_static extends HTML_QuickForm_element { - - // {{{ properties - - /** - * Display text - * @var string - * @access private - */ - var $_text = null; - - // }}} - // {{{ constructor - - /** - * Class constructor - * - * @param string $elementLabel (optional)Label - * @param string $text (optional)Display text - * @access public - * @return void - */ - function HTML_QuickForm_static($elementName=null, $elementLabel=null, $text=null) - { - HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel); - $this->_persistantFreeze = false; - $this->_type = 'static'; - $this->_text = $text; - } //end constructor - - // }}} - // {{{ setName() - - /** - * Sets the element name - * - * @param string $name Element name - * @access public - * @return void - */ - function setName($name) - { - $this->updateAttributes(array('name'=>$name)); - } //end func setName - - // }}} - // {{{ getName() - - /** - * Returns the element name - * - * @access public - * @return string - */ - function getName() - { - return $this->getAttribute('name'); - } //end func getName - - // }}} - // {{{ setText() - - /** - * Sets the text - * - * @param string $text - * @access public - * @return void - */ - function setText($text) - { - $this->_text = $text; - } // end func setText - - // }}} - // {{{ setValue() - - /** - * Sets the text (uses the standard setValue call to emulate a form element. - * - * @param string $text - * @access public - * @return void - */ - function setValue($text) - { - $this->setText($text); - } // end func setValue - - // }}} - // {{{ toHtml() - - /** - * Returns the static text element in HTML - * - * @access public - * @return string - */ - function toHtml() - { - return $this->_getTabs() . $this->_text; - } //end func toHtml - - // }}} - // {{{ getFrozenHtml() - - /** - * Returns the value of field without HTML tags - * - * @access public - * @return string - */ - function getFrozenHtml() - { - return $this->toHtml(); - } //end func getFrozenHtml - - // }}} - // {{{ onQuickFormEvent() - - /** - * Called by HTML_QuickForm whenever form event is made on this element - * - * @param string $event Name of event - * @param mixed $arg event arguments - * @param object &$caller calling object - * @since 1.0 - * @access public - * @return void - * @throws - */ - function onQuickFormEvent($event, $arg, &$caller) - { - switch ($event) { - case 'updateValue': - // do NOT use submitted values for static elements - $value = $this->_findValue($caller->_constantValues); - if (null === $value) { - $value = $this->_findValue($caller->_defaultValues); - } - if (null !== $value) { - $this->setValue($value); - } - break; - default: - parent::onQuickFormEvent($event, $arg, $caller); - } - return true; - } // end func onQuickFormEvent - - // }}} - // {{{ exportValue() - - /** - * We override this here because we don't want any values from static elements - */ - function exportValue(&$submitValues, $assoc = false) - { - return null; - } - - // }}} -} //end class HTML_QuickForm_static -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/submit.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/submit.php deleted file mode 100644 index cd39475b7..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/submit.php +++ /dev/null @@ -1,89 +0,0 @@ - - * @author Bertrand Mansion - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Base class for form elements - */ -require_once 'HTML/QuickForm/input.php'; - -/** - * HTML class for a submit type element - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @version Release: 3.2.16 - * @since 1.0 - */ -class HTML_QuickForm_submit extends HTML_QuickForm_input -{ - // {{{ constructor - - /** - * Class constructor - * - * @param string Input field name attribute - * @param string Input field value - * @param mixed Either a typical HTML attribute string or an associative array - * @since 1.0 - * @access public - * @return void - */ - function HTML_QuickForm_submit($elementName=null, $value=null, $attributes=null) - { - HTML_QuickForm_input::HTML_QuickForm_input($elementName, null, $attributes); - $this->setValue($value); - $this->setType('submit'); - } //end constructor - - // }}} - // {{{ freeze() - - /** - * Freeze the element so that only its value is returned - * - * @access public - * @return void - */ - function freeze() - { - return false; - } //end func freeze - - // }}} - // {{{ exportValue() - - /** - * Only return the value if it is found within $submitValues (i.e. if - * this particular submit button was clicked) - */ - function exportValue(&$submitValues, $assoc = false) - { - return $this->_prepareValue($this->_findValue($submitValues), $assoc); - } - - // }}} -} //end class HTML_QuickForm_submit -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/text.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/text.php deleted file mode 100644 index 76b9849d6..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/text.php +++ /dev/null @@ -1,98 +0,0 @@ - - * @author Bertrand Mansion - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Base class for form elements - */ -require_once 'HTML/QuickForm/input.php'; - -/** - * HTML class for a text field - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @version Release: 3.2.16 - * @since 1.0 - */ -class HTML_QuickForm_text extends HTML_QuickForm_input -{ - - // {{{ constructor - - /** - * Class constructor - * - * @param string $elementName (optional)Input field name attribute - * @param string $elementLabel (optional)Input field label - * @param mixed $attributes (optional)Either a typical HTML attribute string - * or an associative array - * @since 1.0 - * @access public - * @return void - */ - function HTML_QuickForm_text($elementName=null, $elementLabel=null, $attributes=null) - { - HTML_QuickForm_input::HTML_QuickForm_input($elementName, $elementLabel, $attributes); - $this->_persistantFreeze = true; - $this->setType('text'); - } //end constructor - - // }}} - // {{{ setSize() - - /** - * Sets size of text field - * - * @param string $size Size of text field - * @since 1.3 - * @access public - * @return void - */ - function setSize($size) - { - $this->updateAttributes(array('size'=>$size)); - } //end func setSize - - // }}} - // {{{ setMaxlength() - - /** - * Sets maxlength of text field - * - * @param string $maxlength Maximum length of text field - * @since 1.3 - * @access public - * @return void - */ - function setMaxlength($maxlength) - { - $this->updateAttributes(array('maxlength'=>$maxlength)); - } //end func setMaxlength - - // }}} - -} //end class HTML_QuickForm_text -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/textarea.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/textarea.php deleted file mode 100644 index 492c2705b..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/textarea.php +++ /dev/null @@ -1,229 +0,0 @@ - - * @author Bertrand Mansion - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Base class for form elements - */ -require_once 'HTML/QuickForm/element.php'; - -/** - * HTML class for a textarea type field - * - * @category HTML - * @package HTML_QuickForm - * @author Adam Daniel - * @author Bertrand Mansion - * @version Release: 3.2.16 - * @since 1.0 - */ -class HTML_QuickForm_textarea extends HTML_QuickForm_element -{ - // {{{ properties - - /** - * Field value - * @var string - * @since 1.0 - * @access private - */ - var $_value = null; - - // }}} - // {{{ constructor - - /** - * Class constructor - * - * @param string Input field name attribute - * @param mixed Label(s) for a field - * @param mixed Either a typical HTML attribute string or an associative array - * @since 1.0 - * @access public - * @return void - */ - function HTML_QuickForm_textarea($elementName=null, $elementLabel=null, $attributes=null) - { - HTML_QuickForm_element::HTML_QuickForm_element($elementName, $elementLabel, $attributes); - $this->_persistantFreeze = true; - $this->_type = 'textarea'; - } //end constructor - - // }}} - // {{{ setName() - - /** - * Sets the input field name - * - * @param string $name Input field name attribute - * @since 1.0 - * @access public - * @return void - */ - function setName($name) - { - $this->updateAttributes(array('name'=>$name)); - } //end func setName - - // }}} - // {{{ getName() - - /** - * Returns the element name - * - * @since 1.0 - * @access public - * @return string - */ - function getName() - { - return $this->getAttribute('name'); - } //end func getName - - // }}} - // {{{ setValue() - - /** - * Sets value for textarea element - * - * @param string $value Value for textarea element - * @since 1.0 - * @access public - * @return void - */ - function setValue($value) - { - $this->_value = $value; - } //end func setValue - - // }}} - // {{{ getValue() - - /** - * Returns the value of the form element - * - * @since 1.0 - * @access public - * @return string - */ - function getValue() - { - return $this->_value; - } // end func getValue - - // }}} - // {{{ setWrap() - - /** - * Sets wrap type for textarea element - * - * @param string $wrap Wrap type - * @since 1.0 - * @access public - * @return void - */ - function setWrap($wrap) - { - $this->updateAttributes(array('wrap' => $wrap)); - } //end func setWrap - - // }}} - // {{{ setRows() - - /** - * Sets height in rows for textarea element - * - * @param string $rows Height expressed in rows - * @since 1.0 - * @access public - * @return void - */ - function setRows($rows) - { - $this->updateAttributes(array('rows' => $rows)); - } //end func setRows - - // }}} - // {{{ setCols() - - /** - * Sets width in cols for textarea element - * - * @param string $cols Width expressed in cols - * @since 1.0 - * @access public - * @return void - */ - function setCols($cols) - { - $this->updateAttributes(array('cols' => $cols)); - } //end func setCols - - // }}} - // {{{ toHtml() - - /** - * Returns the textarea element in HTML - * - * @since 1.0 - * @access public - * @return string - */ - function toHtml() - { - if ($this->_flagFrozen) { - return $this->getFrozenHtml(); - } else { - return $this->_getTabs() . - '_getAttrString($this->_attributes) . '>' . - // because we wrap the form later we don't want the text indented - preg_replace("/(\r\n|\n|\r)/", ' ', htmlspecialchars($this->_value)) . - ''; - } - } //end func toHtml - - // }}} - // {{{ getFrozenHtml() - - /** - * Returns the value of field without HTML tags (in this case, value is changed to a mask) - * - * @since 1.0 - * @access public - * @return string - */ - function getFrozenHtml() - { - $value = htmlspecialchars($this->getValue()); - if ($this->getAttribute('wrap') == 'off') { - $html = $this->_getTabs() . '
' . $value."
\n"; - } else { - $html = nl2br($value)."\n"; - } - return $html . $this->_getPersistantData(); - } //end func getFrozenHtml - - // }}} - -} //end class HTML_QuickForm_textarea -?> diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/utils.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/utils.php deleted file mode 100644 index 3b606796b..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/utils.php +++ /dev/null @@ -1,159 +0,0 @@ - - * @copyright 2001-2018 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Provides a collection of static methods for array manipulation. - * - * (courtesy of CiviCRM project (https://civicrm.org/) - * - * @category HTML - * @package HTML_QuickForm - * @author Chuck Burgess - * @version Release: 3.2.16 - * @since 3.2 - */ -class HTML_QuickForm_utils -{ - /** - * Get a single value from an array-tree. - * - * @param array $values Ex: ['foo' => ['bar' => 123]]. - * @param array $path Ex: ['foo', 'bar']. - * @param mixed $default - * @return mixed Ex 123. - * - * @access public - * @static - */ - function pathGet($values, $path, $default = NULL) { - foreach ($path as $key) { - if (!is_array($values) || !isset($values[$key])) { - return $default; - } - $values = $values[$key]; - } - return $values; - } - - /** - * Check if a key isset which may be several layers deep. - * - * This is a helper for when the calling function does not know how many layers deep - * the path array is so cannot easily check. - * - * @param array $values - * @param array $path - * @return bool - * - * @access public - * @static - */ - function pathIsset($values, $path) { - foreach ($path as $key) { - if (!is_array($values) || !isset($values[$key])) { - return FALSE; - } - $values = $values[$key]; - } - return TRUE; - } - - /** - * Set a single value in an array tree. - * - * @param array $values Ex: ['foo' => ['bar' => 123]]. - * @param array $pathParts Ex: ['foo', 'bar']. - * @param mixed $value Ex: 456. - * @return void - * - * @access public - * @static - */ - function pathSet(&$values, $pathParts, $value) { - $r = &$values; - $last = array_pop($pathParts); - foreach ($pathParts as $part) { - if (!isset($r[$part])) { - $r[$part] = array(); - } - $r = &$r[$part]; - } - $r[$last] = $value; - } - - /** - * Check if a key isset which may be several layers deep. - * - * This is a helper for when the calling function does not know how many layers deep the - * path array is so cannot easily check. - * - * @param array $array - * @param array $path - * @return bool - * - * @access public - * @static - */ - function recursiveIsset($array, $path) { - return self::pathIsset($array, $path); - } - - /** - * Check if a key isset which may be several layers deep. - * - * This is a helper for when the calling function does not know how many layers deep the - * path array is so cannot easily check. - * - * @param array $array - * @param array $path An array of keys, - * e.g [0, 'bob', 8] where we want to check if $array[0]['bob'][8] - * @param mixed $default Value to return if not found. - * @return bool - * - * @access public - * @static - */ - function recursiveValue($array, $path, $default = NULL) { - return self::pathGet($array, $path, $default); - } - - /** - * Append the value to the array using the key provided. - * - * e.g if value is 'llama' & path is [0, 'email', 'location'] result will be - * [0 => ['email' => ['location' => 'llama']] - * - * @param $path - * @param $value - * @param array $source - * @return array - * - * @access public - * @static - */ - function recursiveBuild($path, $value, $source = array()) { - self::pathSet($source, $path, $value); - return $source; - } -} -?> \ No newline at end of file diff --git a/cookbooks/dmca/files/default/html/HTML/QuickForm/xbutton.php b/cookbooks/dmca/files/default/html/HTML/QuickForm/xbutton.php deleted file mode 100644 index 0737e39c2..000000000 --- a/cookbooks/dmca/files/default/html/HTML/QuickForm/xbutton.php +++ /dev/null @@ -1,153 +0,0 @@ - element - * - * PHP versions 4 and 5 - * - * LICENSE: This source file is subject to version 3.01 of the PHP license - * that is available through the world-wide-web at the following URI: - * http://www.php.net/license/3_01.txt If you did not receive a copy of - * the PHP License and are unable to obtain it through the web, please - * send a note to license@php.net so we can mail you a copy immediately. - * - * @category HTML - * @package HTML_QuickForm - * @author Alexey Borzov - * @copyright 2001-2011 The PHP Group - * @license http://www.php.net/license/3_01.txt PHP License 3.01 - * @version CVS: $Id$ - * @link http://pear.php.net/package/HTML_QuickForm - */ - -/** - * Base class for form elements - */ -require_once 'HTML/QuickForm/element.php'; - -/** - * Class for HTML 4.0 tags) - * @param mixed Either a typical HTML attribute string or an associative array - * @access public - */ - function HTML_QuickForm_xbutton($elementName = null, $elementContent = null, $attributes = null) - { - $this->HTML_QuickForm_element($elementName, null, $attributes); - $this->setContent($elementContent); - $this->setPersistantFreeze(false); - $this->_type = 'xbutton'; - } - - - function toHtml() - { - return 'getAttributes(true) . '>' . $this->_content . ''; - } - - - function getFrozenHtml() - { - return $this->toHtml(); - } - - - function freeze() - { - return false; - } - - - function setName($name) - { - $this->updateAttributes(array( - 'name' => $name - )); - } - - - function getName() - { - return $this->getAttribute('name'); - } - - - function setValue($value) - { - $this->updateAttributes(array( - 'value' => $value - )); - } - - - function getValue() - { - return $this->getAttribute('value'); - } - - - /** - * Sets the contents of the button element - * - * @param string Button content (HTML to add between tags) - */ - function setContent($content) - { - $this->_content = $content; - } - - - function onQuickFormEvent($event, $arg, &$caller) - { - if ('updateValue' != $event) { - return parent::onQuickFormEvent($event, $arg, $caller); - } else { - $value = $this->_findValue($caller->_constantValues); - if (null === $value) { - $value = $this->_findValue($caller->_defaultValues); - } - if (null !== $value) { - $this->setValue($value); - } - } - return true; - } - - - /** - * Returns a 'safe' element's value - * - * The value is only returned if the button's type is "submit" and if this - * particlular button was clicked - */ - function exportValue(&$submitValues, $assoc = false) - { - if ('submit' == $this->getAttribute('type')) { - return $this->_prepareValue($this->_findValue($submitValues), $assoc); - } else { - return null; - } - } -} -?> diff --git a/cookbooks/dmca/files/default/html/favicon.ico b/cookbooks/dmca/files/default/html/favicon.ico deleted file mode 100644 index 27b042b5c..000000000 Binary files a/cookbooks/dmca/files/default/html/favicon.ico and /dev/null differ diff --git a/cookbooks/dmca/files/default/html/index.php b/cookbooks/dmca/files/default/html/index.php deleted file mode 100644 index 47e1afb06..000000000 --- a/cookbooks/dmca/files/default/html/index.php +++ /dev/null @@ -1,117 +0,0 @@ -Thank you'; - echo 'Your report has been submitted'; - $email_body = 'OpenStreetMap - Claim of Copyright Infringement form:'."\n\n"; - $email_body .= 'Automated Email - Form Posted.'."\n\n"; - $email_body .= print_r($values, true); - $reply_address = $values['name_first'].' '.$values['name_last'].' <'.$values['email'].'>'; - $email_body .= 'Formatted address: '.$reply_address."\n\n"; - $email_header = 'From: OSMF Copyright Form ' . "\r\n" . 'Content-Type: text/plain; charset="utf-8"'; - mail('dmca@osmfoundation.org','OSM Claim of Copyright Infringement', $email_body, $email_header, '-fdmca@osmfoundation.org'); -} -?> - - - -OpenStreetMap Legal - Claim of Copyright Infringement - - - - -
-addElement('header', null, 'OpenStreetMap: Claim of Copyright Infringement'); - -$form->addElement('static', null, '

To file a copyright infringement notification with us, you will need to send a written communication that includes the following (please consult your legal counsel or see Section 512(c)(3) of the Digital Millennium Copyright Act to confirm these requirements):

-
  • A physical or electronic signature of a person authorized to act on behalf of the owner of an exclusive right that is allegedly infringed. -
  • Identification of the copyrighted work claimed to have been infringed or, if multiple copyrighted works at a single online site are covered by a single notification, a representative list of such works at that site. -
  • Identification of the material that is claimed to be infringing or to be the subject of infringing activity and that is to be removed or access to which is to be disabled, and information reasonably sufficient to permit the service provider to locate the material. Providing URLs in the body of an email is the best way to help us locate content quickly. -
  • Information reasonably sufficient to permit the service provider to contact the complaining party, such as an address, telephone number, and, if available, an electronic mail address at which the complaining party may be contacted. -
  • A statement that the complaining party has a good faith belief that use of the material in the manner complained of is not authorized by the copyright owner, its agent, or the law. -
  • A statement that the information in the notification is accurate and, under penalty of perjury, that the complaining party is authorized to act on behalf of the owner of an exclusive right that is allegedly infringed. -

To expedite our ability to process your request, such written notice should be sent to our designated agent via our online copyright complaint form below.

-

This form is only for cases where you believe that material on OpenStreetMap\'s websites or in its geodata database infringes your copyright or that of your clients. For example, you claim someone has copied material from a map belonging to you.

-

If you have come here for reporting map inaccuracies, privacy issues or another reason, Read here.

'); - -$form->addElement('text', 'url', 'URL of Allegedly Infringing Material', array('size' => 50, 'maxlength' => 255)); -$form->addRule('url', 'Please enter URL of Allegedly Infringing Material', 'required', null, 'client'); - -$form->addElement('textarea', 'work', 'Describe the work allegedly infringed. For example, which map has been copied and what specifically has been copied.', array('rows' => 20, 'cols' => 70)); -$form->addRule('work', 'Please describe the work allegedly infringed', 'required', null, 'client'); - -$form->addElement('text', 'territory', 'Territories where infringement occurred', array('size' => 50, 'maxlength' => 255)); -$form->addRule('territory', 'Please enter the territories where infringement occurred', 'required', null, 'client'); - -$form->addElement('text', 'name_first', 'First Name', array('size' => 50, 'maxlength' => 255)); -$form->addRule('name_first', 'Please enter your First Name', 'required', null, 'client'); - -$form->addElement('text', 'name_last', 'Last Name', array('size' => 50, 'maxlength' => 255)); -$form->addRule('name_last', 'Please enter your Last Name', 'required', null, 'client'); - - -$form->addElement('text', 'company', 'Company Name', array('size' => 50, 'maxlength' => 255)); -$form->addElement('text', 'company_tile', 'Title/Position'); - -$form->addElement('text', 'address', 'Street Address'); -$form->addRule('address', 'Please enter Street Address', 'required', null, 'client'); - -$form->addElement('text', 'city', 'City', array('size' => 50, 'maxlength' => 255)); -$form->addRule('city', 'Please enter City', 'required', null, 'client'); - -$form->addElement('text', 'state', 'State/Province', array('size' => 50, 'maxlength' => 255)); -$form->addElement('text', 'postal_code', 'Zip/Postal Code', array('size' => 50, 'maxlength' => 255)); - -$form->addElement('text', 'country', 'Country', array('size' => 50, 'maxlength' => 255)); -$form->addRule('country', 'Please enter Country', 'required', null, 'client'); - -$form->addElement('text', 'phone_number', 'Phone Number', array('size' => 50, 'maxlength' => 255)); -$form->addRule('phone_number', 'Please enter Phone Number', 'required', null, 'client'); - -$form->addElement('text', 'mobile_number', 'Mobile Number', array('size' => 50, 'maxlength' => 255)); - -$form->addElement('text', 'email', 'Email Address', array('size' => 50, 'maxlength' => 255)); -$form->addRule('email', 'Please enter Email Address', 'required', null, 'client'); -$form->addRule('email', 'Please enter a valid Email Address', 'email', null, 'client'); - -$form->addElement('text', 'fax', 'Fax', array('size' => 50, 'maxlength' => 255)); - -$complaint_options = array(); -$complaint_options[] = &HTML_QuickForm::createElement('checkbox', '1_of_4_owner_or_authorised', null, 'I am the owner, or an agent authorized to act on behalf of the owner, of an exclusive right that is allegedly infringed.'); -$complaint_options[] = &HTML_QuickForm::createElement('checkbox', '2_of_4_good_faith', null, 'I have a good faith belief that the use of the material in the manner complained of is not authorized by the copyright owner, its agent, or the law; and'); -$complaint_options[] = &HTML_QuickForm::createElement('checkbox', '3_of_4_accurate', null, 'This notification is accurate.'); -$complaint_options[] = &HTML_QuickForm::createElement('checkbox', '4_of_4_not_misrepresent', null, 'I acknowledge that under Section 512(f) any person who knowingly materially misrepresents that material or activity is infringing may be subject to liability for damages.'); - -$form->addGroup($complaint_options, 'complaint_confirm', 'By checking the following boxes, I state UNDER PENALTY OF PERJURY that (choose all of the options)', '
'); - -$form->addElement('text', 'signature', 'Typing your full name in this box will act as your digital signature.', array('size' => 25, 'maxlength' => 255)); -$form->addRule('signature', 'Field is required', 'required', null, 'client'); - -$form->addElement('submit', null, 'Send'); - -$form->removeAttribute('name'); -$form->getValidationScript(); - -if ($form->validate()) { - // Do some stuff - $form->freeze(); - $form->process('process_data', false); - -} else { - // Output the form - $form->accept($renderer); - echo $renderer->toHtml(); -} -?> -
- - diff --git a/cookbooks/dmca/files/default/html/robots.txt b/cookbooks/dmca/files/default/html/robots.txt deleted file mode 100644 index 1f53798bb..000000000 --- a/cookbooks/dmca/files/default/html/robots.txt +++ /dev/null @@ -1,2 +0,0 @@ -User-agent: * -Disallow: / diff --git a/cookbooks/dmca/files/default/html/style.css b/cookbooks/dmca/files/default/html/style.css deleted file mode 100644 index d3efdb4a2..000000000 --- a/cookbooks/dmca/files/default/html/style.css +++ /dev/null @@ -1,226 +0,0 @@ -/* Forms ------------------------------------------------------------------------------*/ - -.regForm { - padding: 0; - margin: 0; - max-width: 730px; -} - -.regForm fieldset { - padding: 15px; - border: 1px solid #747577; - margin-top: 20px; -} - -.regForm legend { - padding: 0px 10px 0px 5px; - font-size: 1.1em; - color: #000000; -} - -#regFormHeader { - border-style: none; - padding: 0px; - margin: 10px 0px 2px 0px; - font-size: 1.2em; -} - -#regFormSubHeader { - font-size: 1em; - padding: 0px; - margin: 0px 0px 2px 0px; - border: none; -} - -.regForm fieldset .inputbox { - padding:0!important; - padding-top:0!important; - padding-bottom:0!important; -} - -.regForm input { - color: #747577; - padding: 6px; - margin-bottom: 0px; - margin-top: 0px; - - -webkit-border-radius:5px; - -moz-border-radius:5px; - border-radius: 5px; - border:1px solid #ccc; - -webkit-box-shadow: 0 2px 4px rgba(0,0,0,0.5); - -moz-box-shadow: 0 2px 4px rgba(0,0,0,0.5); - box-sizing: border-box; - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; -} - -.regForm textarea { - color: #747577; - padding: 6px; - margin-bottom: 5px; - - -webkit-border-radius:5px; - -moz-border-radius:5px; - border-radius: 5px; - border:1px solid #ccc; - -webkit-box-shadow: 0 2px 4px rgba(0,0,0,0.5); - -moz-box-shadow: 0 2px 4px rgba(0,0,0,0.5); - box-sizing: border-box; - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; -} - -.regForm select { - color: #747577; - padding: 6px; - margin-bottom: 5px; - - -webkit-border-radius:5px; - -moz-border-radius:5px; - border-radius: 5px; - border:1px solid #ccc; - -webkit-box-shadow: 0 2px 4px rgba(0,0,0,0.5); - -moz-box-shadow: 0 2px 4px rgba(0,0,0,0.5); - box-sizing: border-box; - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; -} - -.regForm button { - padding: 0px 5px 0px 0px; -} - -.regForm ol > li { - list-style: none; - background-image: none; - padding: 3px 0px 5px 0px; - border-top: 1px solid #f0f0f0; - color: #747577; -} - -.regForm li.formList-top { - border-top: none; - font-size: .8em; - padding: 10px 0px; -} - -.regForm li.formList { - font-size: .8em; - padding: 10px 0px; -} - -.regForm li.opt { - border-top: 0; - display: none; -} - -.elementItem { - padding: 0; - display: block; - clear: left; - border-style: none; -} - -.elementItemGroup { - padding: 0; - margin: 0; - display: block; - border-top: 2px solid #C0C0C0; -} - -li.elementItemEnd { - padding: 0; - display: block; - clear: left; - border-style: none; -} - -.elementGroup { - padding: 0; -} - -.elementGroup ul { - float: left; - margin-left: 0px; - margin-top: 0px; - padding: 0; -} - -.elementGroup li { - margin: 0; - margin-left: 0px; - margin-top: 2px; - margin-right: 5px; - padding: 2px 2px 2px 0px; - border-style: none; - min-width: 255px; - list-style: none; -} - -.elementGroupEnd { - border-style: none; - margin: 0; - padding: 0; - height: 1px; -} - -.regForm ol { - margin: 0px; - padding: 0px; -} - -.regForm p { - font-size: 1.2em; -} - -.regForm .error { - color: #ff0000; - font-weight: bold; -} - -.regForm .required { - color: #ff0000; -} - -.regForm label.element { - color: #000000; - padding: 0px 5px 2px 0px; - margin: 0px; -} - -.regForm div.element { - color: #747577; - padding: 1px 0px 0px 0px; -} - -.regForm div.element label { - padding: 0px 15px 0px 4px; -} - -.regForm input[type="submit"] { -/* border: 1px solid #f0f0f0;*/ - color: #747577; - margin: 10px 0px; -} - -.regForm input[type="submit"]:hover { - color: #CCCCCC; - text-decoration: none; -} - -.regForm option { - color: #747577; -} - -.regForm .reqnote { - font-size: 90%; - color: #747577; - font-weight: bold; -} - -.regForm input[type="radio"] { - border: 0; -} - diff --git a/cookbooks/dmca/recipes/default.rb b/cookbooks/dmca/recipes/default.rb index f7f9cfadb..eafadd787 100644 --- a/cookbooks/dmca/recipes/default.rb +++ b/cookbooks/dmca/recipes/default.rb @@ -23,20 +23,21 @@ include_recipe "php::fpm" apache_module "proxy" apache_module "proxy_fcgi" -directory "/srv/dmca.openstreetmap.org" do - owner "root" - group "root" - mode "755" +package "composer" + +git "/srv/dmca.openstreetmap.org" do + action :sync + repository "https://github.com/openstreetmap/dmca-website.git" + revision "main" + depth 1 + notifies :run, "execute[/srv/dmca.openstreetmap.org/composer.json]", :immediately end -remote_directory "/srv/dmca.openstreetmap.org/html" do - source "html" - owner "root" - group "root" - mode "755" - files_owner "root" - files_group "root" - files_mode "644" +execute "/srv/dmca.openstreetmap.org/composer.json" do + action :nothing + command "composer install --no-dev" + cwd "/srv/dmca.openstreetmap.org/" + environment "COMPOSER_HOME" => "/srv/dmca.openstreetmap.org/" end ssl_certificate "dmca.openstreetmap.org" do @@ -45,7 +46,7 @@ ssl_certificate "dmca.openstreetmap.org" do end php_fpm "dmca.openstreetmap.org" do - php_admin_values "open_basedir" => "/srv/dmca.openstreetmap.org/html/:/usr/share/php/:/tmp/", + php_admin_values "open_basedir" => "/srv/dmca.openstreetmap.org/:/usr/share/php/:/tmp/", "disable_functions" => "exec,shell_exec,system,passthru,popen,proc_open" prometheus_port 11201 end diff --git a/cookbooks/dmca/templates/default/apache.erb b/cookbooks/dmca/templates/default/apache.erb index 672a1be3e..41d06aa1c 100644 --- a/cookbooks/dmca/templates/default/apache.erb +++ b/cookbooks/dmca/templates/default/apache.erb @@ -44,12 +44,12 @@ CustomLog /var/log/apache2/<%= @name %>-access.log combined ErrorLog /var/log/apache2/<%= @name %>-error.log - DocumentRoot <%= @directory %>/html + DocumentRoot <%= @directory %> Options -Indexes -/html> +> Require all granted diff --git a/cookbooks/dns/recipes/default.rb b/cookbooks/dns/recipes/default.rb index eaeaf5623..98005c41e 100644 --- a/cookbooks/dns/recipes/default.rb +++ b/cookbooks/dns/recipes/default.rb @@ -41,7 +41,7 @@ package %w[ remote_file "/usr/local/bin/dnscontrol" do action :create - source "https://github.com/StackExchange/dnscontrol/releases/download/v3.5.0/dnscontrol-Linux" + source "https://github.com/StackExchange/dnscontrol/releases/download/v3.12.0/dnscontrol-Linux" owner "root" group "root" mode "755" @@ -128,6 +128,15 @@ template "/var/lib/dns/creds.json" do variables :passwords => passwords end +template "/var/lib/dns/include/geo.js" do + source "geo.js.erb" + owner "git" + group "git" + mode "440" + variables :geoservers => geoservers + only_if { ::Dir.exist?("/var/lib/dns/include") } +end + cookbook_file "#{node[:dns][:repository]}/hooks/post-receive" do source "post-receive" owner "git" diff --git a/cookbooks/dns/templates/default/geo.js.erb b/cookbooks/dns/templates/default/geo.js.erb new file mode 100644 index 000000000..ecc4d1c84 --- /dev/null +++ b/cookbooks/dns/templates/default/geo.js.erb @@ -0,0 +1,5 @@ +var GEO_NS_RECORDS = [ +<% @geoservers.each do |server| -%> + NS("geo", "<%= server %>."), +<% end -%> +]; diff --git a/cookbooks/docker/recipes/default.rb b/cookbooks/docker/recipes/default.rb index 23891f110..1dfe9adde 100644 --- a/cookbooks/docker/recipes/default.rb +++ b/cookbooks/docker/recipes/default.rb @@ -41,5 +41,4 @@ end service "docker" do action [:enable, :start] subscribes :restart, "template[/etc/docker/daemon.json]" - not_if { ENV["TEST_KITCHEN"] } end diff --git a/cookbooks/exim/attributes/default.rb b/cookbooks/exim/attributes/default.rb index 21e999109..638ce5765 100644 --- a/cookbooks/exim/attributes/default.rb +++ b/cookbooks/exim/attributes/default.rb @@ -4,6 +4,7 @@ default[:exim][:relay_from_hosts] = ["127.0.0.1", "::1"] default[:exim][:daemon_smtp_ports] = [25] default[:exim][:trusted_users] = [] default[:exim][:queue_run_max] = 1 +default[:exim][:smtp_accept_max] = 20 default[:exim][:smarthost_name] = nil default[:exim][:smarthost_via] = "mail.openstreetmap.org:26" default[:exim][:routes] = {} diff --git a/cookbooks/exim/files/default/noreply/community b/cookbooks/exim/files/default/noreply/community new file mode 100644 index 000000000..8633e7913 --- /dev/null +++ b/cookbooks/exim/files/default/noreply/community @@ -0,0 +1,9 @@ +This is an automated response to your email, which was sent to an +unattended address. + +You can not reply to this email, please use the +community.openstreetmap.org web site instead. + +Thank you, + +OpenStreetMap Administrators diff --git a/cookbooks/exim/files/default/noreply/web b/cookbooks/exim/files/default/noreply/web index 169d2f6b6..3ad49cf0a 100644 --- a/cookbooks/exim/files/default/noreply/web +++ b/cookbooks/exim/files/default/noreply/web @@ -2,13 +2,13 @@ This is an automated response to your email, which was sent to an unattended address. If you were trying to confirm your email address after signing -up for an account, or after changing your email address, then you +up for an account, or after changing your email address, then you should click on the link in the original email you received. If you need help using OpenStreetMap then you should try our -question and answer site: +community site: - https://help.openstreetmap.org/ + https://community.openstreetmap.org/ If you are having technical problems with the web site then please contact support@openstreetmap.org for assistance. diff --git a/cookbooks/exim/templates/default/exim4.conf.erb b/cookbooks/exim/templates/default/exim4.conf.erb index 2d1d96e12..0830aa141 100644 --- a/cookbooks/exim/templates/default/exim4.conf.erb +++ b/cookbooks/exim/templates/default/exim4.conf.erb @@ -364,6 +364,11 @@ queue_only = true queue_run_max = <%= node[:exim][:queue_run_max] %> +# Maximum number of simultaneous SMTP connections + +smtp_accept_max = <%= node[:exim][:smtp_accept_max] %> + + ###################################################################### # ACL CONFIGURATION # @@ -720,6 +725,7 @@ remote_smtp: signed_smtp: driver = smtp + connect_timeout = 1m dkim_domain = ${lookup{${domain:$h_from:}}partial-lsearch{/etc/exim4/dkim-domains}{$value}} dkim_selector = ${lookup{$dkim_domain}lsearch{/etc/exim4/dkim-selectors}{$value}} dkim_private_key = /etc/exim4/dkim-keys/${dkim_domain} @@ -779,7 +785,7 @@ noreply: to = $sender_address subject = Re: $header_subject: headers = MIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8 - file = /etc/exim4/noreply/$local_part_data + file = ${lookup{$local_part}dsearch,filter=file,ret=full{/etc/exim4/noreply}} user = Debian-exim group = Debian-exim diff --git a/cookbooks/fail2ban/metadata.rb b/cookbooks/fail2ban/metadata.rb index 93f21f14d..13cc6607f 100644 --- a/cookbooks/fail2ban/metadata.rb +++ b/cookbooks/fail2ban/metadata.rb @@ -7,3 +7,4 @@ description "Configures fail2ban" version "1.0.0" supports "ubuntu" depends "munin" +depends "prometheus" diff --git a/cookbooks/fail2ban/recipes/default.rb b/cookbooks/fail2ban/recipes/default.rb index e0e8e2372..ca03d37d6 100644 --- a/cookbooks/fail2ban/recipes/default.rb +++ b/cookbooks/fail2ban/recipes/default.rb @@ -18,8 +18,12 @@ # include_recipe "munin" +include_recipe "prometheus" -package "fail2ban" +package %w[ + fail2ban + ruby-webrick +] template "/etc/fail2ban/jail.d/00-default.conf" do source "jail.default.erb" @@ -42,3 +46,7 @@ service "fail2ban" do end munin_plugin "fail2ban" + +prometheus_exporter "fail2ban" do + port 9635 +end diff --git a/cookbooks/fail2ban/resources/filter.rb b/cookbooks/fail2ban/resources/filter.rb index 3cd173eee..13a778295 100644 --- a/cookbooks/fail2ban/resources/filter.rb +++ b/cookbooks/fail2ban/resources/filter.rb @@ -17,6 +17,8 @@ # limitations under the License. # +unified_mode true + default_action :create property :filter, :kind_of => String, :name_property => true diff --git a/cookbooks/fail2ban/resources/jail.rb b/cookbooks/fail2ban/resources/jail.rb index 6ff5307e3..3af0960e9 100644 --- a/cookbooks/fail2ban/resources/jail.rb +++ b/cookbooks/fail2ban/resources/jail.rb @@ -17,6 +17,8 @@ # limitations under the License. # +unified_mode true + default_action :create property :jail, :kind_of => String, :name_property => true diff --git a/cookbooks/forum/recipes/default.rb b/cookbooks/forum/recipes/default.rb index 728408a0c..ae32e4d01 100644 --- a/cookbooks/forum/recipes/default.rb +++ b/cookbooks/forum/recipes/default.rb @@ -32,7 +32,6 @@ package %w[ php-mysql php-xml php-apcu - unzip ] apache_module "env" @@ -69,22 +68,23 @@ git "/srv/forum.openstreetmap.org/html/" do notifies :reload, "service[apache2]" end -remote_file "#{cache_dir}/air3_v0.8.zip" do +remote_file "#{cache_dir}/air3_v0.8.tar.gz" do action :create_if_missing - source "https://fluxbb.org/resources/styles/air3/releases/0.8/air3_v0.8.zip" + source "https://github.com/natrius/air3/archive/refs/tags/v0.8.tar.gz" owner "root" group "root" mode "644" backup false end -execute "#{cache_dir}/air3_v0.8.zip" do +archive_file "#{cache_dir}/air3_v0.8.tar.gz" do action :nothing - command "unzip -o -qq #{cache_dir}/air3_v0.8.zip Air3.css 'Air3/*'" - cwd "/srv/forum.openstreetmap.org/html/style" - user "forum" + destination "/srv/forum.openstreetmap.org/html/style" + strip_components 1 + overwrite true + owner "forum" group "forum" - subscribes :run, "remote_file[#{cache_dir}/air3_v0.8.zip]", :immediately + subscribes :extract, "remote_file[#{cache_dir}/air3_v0.8.tar.gz]", :immediately end directory "/srv/forum.openstreetmap.org/html/cache/" do diff --git a/cookbooks/foundation/metadata.rb b/cookbooks/foundation/metadata.rb index 8aa888296..426a683c7 100644 --- a/cookbooks/foundation/metadata.rb +++ b/cookbooks/foundation/metadata.rb @@ -9,3 +9,4 @@ supports "ubuntu" depends "apache" depends "git" depends "mediawiki" +depends "ruby" diff --git a/cookbooks/foundation/recipes/board.rb b/cookbooks/foundation/recipes/board.rb index 84d6b24b1..82b2eb8ff 100644 --- a/cookbooks/foundation/recipes/board.rb +++ b/cookbooks/foundation/recipes/board.rb @@ -35,9 +35,7 @@ mediawiki_site "board.osmfoundation.org" do email_sender "webmaster@openstreetmap.org" email_sender_name "OSMF Board Wiki" private_site true - recaptcha_public_key "6LflIQATAAAAAMXyDWpba-FgipVzE-aGF4HIR59N" - recaptcha_private_key passwords["board"]["recaptcha"] - version "1.34" + version "1.37" end cookbook_file "/srv/board.osmfoundation.org/Wiki.png" do diff --git a/cookbooks/foundation/recipes/dwg.rb b/cookbooks/foundation/recipes/dwg.rb index 2eff0db56..f939fb420 100644 --- a/cookbooks/foundation/recipes/dwg.rb +++ b/cookbooks/foundation/recipes/dwg.rb @@ -35,9 +35,7 @@ mediawiki_site "dwg.osmfoundation.org" do email_sender "webmaster@openstreetmap.org" email_sender_name "OSMF Board Wiki" private_site true - recaptcha_public_key "6LflIQATAAAAAMXyDWpba-FgipVzE-aGF4HIR59N" - recaptcha_private_key passwords["dwg"]["recaptcha"] - version "1.34" + version "1.37" end cookbook_file "/srv/dwg.osmfoundation.org/Wiki.png" do diff --git a/cookbooks/foundation/recipes/mwg.rb b/cookbooks/foundation/recipes/mwg.rb index 60bb76fd9..dd0bdab52 100644 --- a/cookbooks/foundation/recipes/mwg.rb +++ b/cookbooks/foundation/recipes/mwg.rb @@ -35,9 +35,7 @@ mediawiki_site "mwg.osmfoundation.org" do email_sender "webmaster@openstreetmap.org" email_sender_name "OSMF Board Wiki" private_site true - recaptcha_public_key "6LflIQATAAAAAMXyDWpba-FgipVzE-aGF4HIR59N" - recaptcha_private_key passwords["mwg"]["recaptcha"] - version "1.34" + version "1.37" end cookbook_file "/srv/mwg.osmfoundation.org/Wiki.png" do diff --git a/cookbooks/foundation/recipes/owg.rb b/cookbooks/foundation/recipes/owg.rb index 31d41aa1f..6c637c62a 100644 --- a/cookbooks/foundation/recipes/owg.rb +++ b/cookbooks/foundation/recipes/owg.rb @@ -19,29 +19,24 @@ include_recipe "apache" include_recipe "git" +include_recipe "ruby" -package %w[ +package %W[ gcc g++ make - ruby - ruby-dev libssl-dev zlib1g-dev pkg-config ] -gem_package "bundler" do - version "1.17.3" -end - git "/srv/operations.osmfoundation.org" do action :sync repository "https://github.com/openstreetmap/owg-website.git" depth 1 user "root" group "root" - notifies :run, "execute[/srv/operations.osmfoundation.org/Gemfile]" + notifies :run, "bundle_install[/srv/operations.osmfoundation.org]" end directory "/srv/operations.osmfoundation.org/_site" do @@ -58,18 +53,17 @@ directory "/srv/operations.osmfoundation.org/.jekyll-cache" do group "nogroup" end -execute "/srv/operations.osmfoundation.org/Gemfile" do +bundle_install "/srv/operations.osmfoundation.org" do action :nothing - command "bundle install --deployment" - cwd "/srv/operations.osmfoundation.org" + options "--deployment" user "root" group "root" - notifies :run, "execute[/srv/operations.osmfoundation.org]" + notifies :run, "bundle_exec[/srv/operations.osmfoundation.org]" end -execute "/srv/operations.osmfoundation.org" do - command "bundle exec jekyll build --trace" - cwd "/srv/operations.osmfoundation.org" +bundle_exec "/srv/operations.osmfoundation.org" do + action :nothing + command "jekyll build --trace" user "nobody" group "nogroup" end diff --git a/cookbooks/foundation/recipes/wiki.rb b/cookbooks/foundation/recipes/wiki.rb index e635b536a..199389d0e 100644 --- a/cookbooks/foundation/recipes/wiki.rb +++ b/cookbooks/foundation/recipes/wiki.rb @@ -36,15 +36,13 @@ mediawiki_site "wiki.osmfoundation.org" do database_password passwords["wiki"]["database"] admin_password passwords["wiki"]["admin"] skin "OSMFoundation" - logo "/Wiki.png" + logo "/w/skins/OSMFoundation/img/logo.png" email_contact "webmaster@openstreetmap.org" email_sender "webmaster@openstreetmap.org" email_sender_name "OSMF Wiki" private_accounts true - recaptcha_public_key "6LflIQATAAAAAMXyDWpba-FgipVzE-aGF4HIR59N" - recaptcha_private_key passwords["wiki"]["recaptcha"] extra_file_extensions ["mp3"] - version "1.34" + version "1.37" end mediawiki_skin "osmf" do diff --git a/cookbooks/geodns/recipes/default.rb b/cookbooks/geodns/recipes/default.rb index 43643c2f9..c006ff9dc 100644 --- a/cookbooks/geodns/recipes/default.rb +++ b/cookbooks/geodns/recipes/default.rb @@ -19,6 +19,10 @@ include_recipe "geoipupdate" +servers = search(:node, "roles:geodns").collect(&:name).sort + +servers << "dummy.example.com" if servers.empty? + package %w[ gdnsd ] @@ -29,7 +33,7 @@ directory "/etc/gdnsd/config.d" do mode "755" end -%w[tile nominatim].each do |zone| +%w[nominatim].each do |zone| %w[map resource weighted].each do |type| template "/etc/gdnsd/config.d/#{zone}.#{type}" do action :create_if_missing @@ -55,6 +59,7 @@ template "/etc/gdnsd/zones/geo.openstreetmap.org" do owner "root" group "root" mode "644" + variables :servers => servers notifies :restart, "service[gdnsd]" end diff --git a/cookbooks/geodns/templates/default/config.erb b/cookbooks/geodns/templates/default/config.erb index 6ceafc737..510e886a8 100644 --- a/cookbooks/geodns/templates/default/config.erb +++ b/cookbooks/geodns/templates/default/config.erb @@ -6,16 +6,13 @@ options => { plugins => { geoip => { maps => { - $include{config.d/tile.map} $include{config.d/nominatim.map} } resources => { - $include{config.d/tile.resource} $include{config.d/nominatim.resource} } }, weighted => { - $include{config.d/tile.weighted} $include{config.d/nominatim.weighted} } } diff --git a/cookbooks/geodns/templates/default/geo.erb b/cookbooks/geodns/templates/default/geo.erb index 9e3064218..719f11a9d 100644 --- a/cookbooks/geodns/templates/default/geo.erb +++ b/cookbooks/geodns/templates/default/geo.erb @@ -1,6 +1,6 @@ $TTL 86400 -@ SOA saphira.openstreetmap.org. hostmaster.openstreetmap.org. ( +@ SOA <%= @servers.first %>. hostmaster.openstreetmap.org. ( 3 ; serial 86400 ; refresh 7200 ; retry @@ -8,12 +8,8 @@ $TTL 86400 3600 ; ncache ) -@ 86400 NS balerion.openstreetmap.org. -@ 86400 NS chrysophylax.openstreetmap.org. -@ 86400 NS katie.openstreetmap.org. -@ 86400 NS saphira.openstreetmap.org. -@ 86400 NS stormfly-04.openstreetmap.org. -@ 86400 NS ridgeback.openstreetmap.org. +<% @servers.each do |server| -%> +@ 86400 NS <%= server %>. +<% end -%> -tile 300 DYNC geoip!tile nominatim 300 DYNC geoip!nominatim diff --git a/cookbooks/geoipupdate/attributes/default.rb b/cookbooks/geoipupdate/attributes/default.rb index 3165aa115..90476814c 100644 --- a/cookbooks/geoipupdate/attributes/default.rb +++ b/cookbooks/geoipupdate/attributes/default.rb @@ -1,4 +1,5 @@ default[:geoipupdate][:account] = "149244" default[:geoipupdate][:editions] = %w[GeoLite2-ASN GeoLite2-City GeoLite2-Country] +default[:geoipupdate][:directory] = "/usr/share/GeoIP" default[:apt][:sources] |= ["maxmind"] diff --git a/cookbooks/geoipupdate/recipes/default.rb b/cookbooks/geoipupdate/recipes/default.rb index fedae0011..036c27881 100644 --- a/cookbooks/geoipupdate/recipes/default.rb +++ b/cookbooks/geoipupdate/recipes/default.rb @@ -35,7 +35,7 @@ execute "geoipupdate" do command "geoipupdate" user "root" group "root" - not_if { ENV.key?("TEST_KITCHEN") || node[:geoipupdate][:editions].all? { |edition| ::File.exist?("/usr/share/GeoIP/#{edition}.mmdb") } } + not_if { kitchen? || node[:geoipupdate][:editions].all? { |edition| ::File.exist?("#{node[:geoipupdate][:directory]}/#{edition}.mmdb") } } end systemd_service "geoipupdate" do @@ -46,7 +46,7 @@ systemd_service "geoipupdate" do private_devices true protect_system "strict" protect_home true - read_write_paths "/usr/share/GeoIP" + read_write_paths node[:geoipupdate][:directory] end systemd_timer "geoipupdate" do diff --git a/cookbooks/git/recipes/server.rb b/cookbooks/git/recipes/server.rb index 9b4e06a45..bd586e9f2 100644 --- a/cookbooks/git/recipes/server.rb +++ b/cookbooks/git/recipes/server.rb @@ -43,6 +43,13 @@ directory "#{git_directory}/private" do mode "2775" end +template "/etc/gitconfig" do + source "gitconfig.erb" + owner "root" + group "root" + mode "644" +end + Dir.glob("#{git_directory}/*/*.git").each do |repository| template "#{repository}/hooks/post-update" do source "post-update.erb" diff --git a/cookbooks/git/recipes/web.rb b/cookbooks/git/recipes/web.rb index 7e1f38cc2..4bdd50160 100644 --- a/cookbooks/git/recipes/web.rb +++ b/cookbooks/git/recipes/web.rb @@ -45,6 +45,13 @@ template "/srv/#{git_site}/robots.txt" do mode "644" end +template "/srv/#{git_site}/indextext.html" do + source "indextext.html.erb" + owner "root" + group "root" + mode "644" +end + ssl_certificate git_site do domains [git_site] + Array(node[:git][:aliases]) notifies :reload, "service[apache2]" diff --git a/cookbooks/git/templates/default/apache.erb b/cookbooks/git/templates/default/apache.erb index 30685fad9..07d11a804 100644 --- a/cookbooks/git/templates/default/apache.erb +++ b/cookbooks/git/templates/default/apache.erb @@ -53,6 +53,12 @@ # KeepaliveTimeout longer than git config uploadpack.keepalive 5 second default KeepAliveTimeout 20 + RewriteEngine on + RewriteRule ^/cgimap\.git.* https://github.com/zerebubuth/openstreetmap-cgimap [QSD,L,R=permanent] + RewriteRule ^/planetdump\.git.* https://github.com/openstreetmap/planetdump [QSD,L,R=permanent] + RewriteRule ^/gpx-import\.git.* https://github.com/openstreetmap/gpx-import [QSD,L,R=permanent] + RewriteRule ^/potlatch2\.git.* https://github.com/openstreetmap/potlatch2 [QSD,L,R=permanent] + ScriptAlias /public /usr/lib/git-core/git-http-backend/public ScriptAlias /private /usr/lib/git-core/git-http-backend/private Alias /gitweb /usr/share/gitweb diff --git a/cookbooks/git/templates/default/gitconfig.erb b/cookbooks/git/templates/default/gitconfig.erb new file mode 100644 index 000000000..e5067f983 --- /dev/null +++ b/cookbooks/git/templates/default/gitconfig.erb @@ -0,0 +1,6 @@ +# DO NOT EDIT - This file is being maintained by Chef + +[safe] + directory = /var/lib/chef/public + directory = /var/lib/chef/private + directory = /var/lib/dns diff --git a/cookbooks/git/templates/default/gitweb.conf.erb b/cookbooks/git/templates/default/gitweb.conf.erb index 5d2eb7469..4cfe1c24f 100644 --- a/cookbooks/git/templates/default/gitweb.conf.erb +++ b/cookbooks/git/templates/default/gitweb.conf.erb @@ -10,7 +10,7 @@ $git_temp = "/tmp"; #$home_link = $my_uri || "/"; # html text to include at home page -$home_text = "indextext.html"; +$home_text = "/srv/<%= node[:git][:host] %>/indextext.html"; # file with project list; by default, simply scan the projectroot dir. $projects_list = $projectroot; diff --git a/cookbooks/git/templates/default/indextext.html.erb b/cookbooks/git/templates/default/indextext.html.erb new file mode 100644 index 000000000..c6493db1f --- /dev/null +++ b/cookbooks/git/templates/default/indextext.html.erb @@ -0,0 +1,3 @@ +

Want to contribute to OpenStreetMap software?

+

Head over to github.com/openstreetmap/

+

git.openstreetmap.org is an internal system we use as part of our deployment system.

diff --git a/cookbooks/gps-tile/recipes/default.rb b/cookbooks/gps-tile/recipes/default.rb index 21a515034..c3fb07796 100644 --- a/cookbooks/gps-tile/recipes/default.rb +++ b/cookbooks/gps-tile/recipes/default.rb @@ -43,7 +43,7 @@ end git "/srv/gps-tile.openstreetmap.org/import" do action :sync - repository "https://github.com/ericfischer/gpx-import.git" + repository "https://github.com/e-n-f/gpx-import.git" revision "live" depth 1 user "gpstile" @@ -61,7 +61,7 @@ end git "/srv/gps-tile.openstreetmap.org/datamaps" do action :sync - repository "https://github.com/ericfischer/datamaps.git" + repository "https://github.com/e-n-f/datamaps.git" revision "live" depth 1 user "gpstile" @@ -79,7 +79,7 @@ end git "/srv/gps-tile.openstreetmap.org/updater" do action :sync - repository "https://github.com/ericfischer/gpx-updater.git" + repository "https://github.com/openstreetmap/gpx-updater.git" revision "live" depth 1 user "gpstile" diff --git a/cookbooks/hardware/attributes/default.rb b/cookbooks/hardware/attributes/default.rb index bbe44348e..d2c1b36bd 100644 --- a/cookbooks/hardware/attributes/default.rb +++ b/cookbooks/hardware/attributes/default.rb @@ -1,8 +1,10 @@ default[:hardware][:modules] = %w[lp] +default[:hardware][:blacklisted_modules] = %w[] default[:hardware][:grub][:cmdline] = %w[nomodeset] default[:hardware][:sensors] = {} default[:hardware][:hwmon] = {} default[:hardware][:ipmi][:excluded_sensors] = [] +default[:hardware][:ipmi][:custom_args] = [] if node[:dmi] && node[:dmi][:system] case node[:dmi][:system][:manufacturer] @@ -13,6 +15,11 @@ if node[:dmi] && node[:dmi][:system] when "ProLiant DL360 G6", "ProLiant DL360 G7", "ProLiant SE326M1R2" default[:hardware][:sensors][:"power_meter-*"][:power][:power1] = { :ignore => true } end + + case node[:dmi][:system][:product_name] + when "ProLiant DL360 G6", "ProLiant DL360 G7", "ProLiant SE326M1R2", "ProLiant DL360e Gen8", "ProLiant DL360p Gen8" + default[:hardware][:ipmi][:custom_args] |= ["--workaround-flags=discretereading"] + end end end @@ -32,6 +39,10 @@ end if node[:kernel][:modules].include?("ipmi_si") default[:hardware][:modules] |= ["ipmi_devintf"] + + if node[:kernel][:modules].include?("acpi_power_meter") + default[:hardware][:modules] |= ["acpi_ipmi"] + end end if File.exist?("/proc/xen") @@ -46,3 +57,13 @@ if File.exist?("/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor") && default[:sysfs][:cpufreq_ondemand][:parameters][:"devices/system/cpu/cpufreq/ondemand/up_threshold"] = "25" default[:sysfs][:cpufreq_ondemand][:parameters][:"devices/system/cpu/cpufreq/ondemand/sampling_down_factor"] = "100" end + +energy_perf_bias = Dir.glob("/sys/devices/system/cpu/cpu*/power/energy_perf_bias") + +unless energy_perf_bias.empty? + default[:sysfs][:cpu_power_energy_perf_bias][:comment] = "Set CPU Energy-Performance Bias Preference to performance" + + energy_perf_bias.sort.each do |path| + default[:sysfs][:cpu_power_energy_perf_bias][:parameters][path.sub(%r{^/sys/}, "")] = "0" + end +end diff --git a/cookbooks/hardware/recipes/default.rb b/cookbooks/hardware/recipes/default.rb index ebdf64bb1..dd4448180 100644 --- a/cookbooks/hardware/recipes/default.rb +++ b/cookbooks/hardware/recipes/default.rb @@ -59,14 +59,29 @@ case manufacturer when "HP" package "hponcfg" + execute "update-ilo" do + action :nothing + command "/usr/sbin/hponcfg -f /etc/ilo-defaults.xml" + end + + template "/etc/ilo-defaults.xml" do + source "ilo-defaults.xml.erb" + owner "root" + group "root" + mode "644" + notifies :run, "execute[update-ilo]" + end + package "hp-health" do action :install notifies :restart, "service[hp-health]" + only_if { node[:lsb][:release].to_f < 22.04 } end service "hp-health" do action [:enable, :start] supports :status => true, :restart => true + only_if { node[:lsb][:release].to_f < 22.04 } end if product.end_with?("Gen8", "Gen9") @@ -141,7 +156,7 @@ if File.exist?("/etc/default/grub") execute "update-grub" do action :nothing command "/usr/sbin/update-grub" - not_if { ENV["TEST_KITCHEN"] } + not_if { kitchen? } end template "/etc/default/grub" do @@ -199,13 +214,17 @@ service "irqbalance" do supports :status => false, :restart => true, :reload => false end -# Link Layer Discovery Protocol Daemon package "lldpd" + service "lldpd" do action [:start, :enable] supports :status => true, :restart => true, :reload => true end +ohai_plugin "lldp" do + template "lldp.rb.erb" +end + tools_packages = [] status_packages = {} @@ -228,9 +247,6 @@ if node[:virtualization][:role] != "guest" || when "mpt2sas", "mpt3sas" tools_packages << "sas2ircu" status_packages["sas2ircu-status"] ||= [] - when "megaraid_mm" - tools_packages << "megactl" - status_packages["megaraid-status"] ||= [] when "megaraid_sas" tools_packages << "megacli" status_packages["megaclisas-status"] ||= [] @@ -274,7 +290,7 @@ if tools_packages.include?("areca") depth 1 user "root" group "root" - not_if { ENV["TEST_KITCHEN"] } + not_if { kitchen? } end else directory "/opt/areca" do @@ -311,7 +327,7 @@ else end end -%w[cciss-vol-status mpt-status sas2ircu-status megaraid-status megaclisas-status aacraid-status].each do |status_package| +%w[cciss-vol-status mpt-status sas2ircu-status megaclisas-status aacraid-status].each do |status_package| if status_packages.include?(status_package) package status_package @@ -353,16 +369,20 @@ nvmes = if node[:hardware][:pci] [] end +unless nvmes.empty? + package "nvme-cli" +end + intel_nvmes = nvmes.select { |pci| pci[:vendor_name] == "Intel Corporation" } if !intel_ssds.empty? || !intel_nvmes.empty? package "unzip" - intel_mas_tool_version = "1.6" - intel_mas_package_version = "#{intel_mas_tool_version}.122-0" + intel_mas_tool_version = "1.10" + intel_mas_package_version = "#{intel_mas_tool_version}.155-0" remote_file "#{Chef::Config[:file_cache_path]}/Intel_MAS_CLI_Tool_#{intel_mas_tool_version}_Linux.zip" do - source "https://downloadmirror.intel.com/30259/eng/Intel%C2%AE_MAS_CLI_Tool_Linux_#{intel_mas_tool_version}.zip" + source "https://downloadmirror.intel.com/646992/Intel_MAS_CLI_Tool_Linux_#{intel_mas_tool_version}-v2.zip" end execute "#{Chef::Config[:file_cache_path]}/Intel_MAS_CLI_Tool_#{intel_mas_tool_version}_Linux.zip" do @@ -540,16 +560,21 @@ if File.exist?("/etc/mdadm/mdadm.conf") end end -template "/etc/modules" do - source "modules.erb" - owner "root" - group "root" - mode "644" +file "/etc/modules" do + action :delete end -service "kmod" do - action :nothing - subscribes :start, "template[/etc/modules]" +node[:hardware][:modules].each do |module_name| + kernel_module module_name do + action :install + not_if { kitchen? } + end +end + +node[:hardware][:blacklisted_modules].each do |module_name| + kernel_module module_name do + action :blacklist + end end if node[:hardware][:watchdog] @@ -627,3 +652,7 @@ if node[:hardware][:shm_size] notifies :run, "execute[remount-dev-shm]" end end + +prometheus_collector "ohai" do + interval "15m" +end diff --git a/cookbooks/hardware/templates/default/ilo-defaults.xml.erb b/cookbooks/hardware/templates/default/ilo-defaults.xml.erb new file mode 100644 index 000000000..feb4f8f98 --- /dev/null +++ b/cookbooks/hardware/templates/default/ilo-defaults.xml.erb @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cookbooks/hardware/templates/default/ipmi_local.yml.erb b/cookbooks/hardware/templates/default/ipmi_local.yml.erb index 4250a62eb..b6ebbd6d0 100644 --- a/cookbooks/hardware/templates/default/ipmi_local.yml.erb +++ b/cookbooks/hardware/templates/default/ipmi_local.yml.erb @@ -7,6 +7,11 @@ modules: - ipmi - dcmi - chassis + custom_args: + ipmi: +<% node[:hardware][:ipmi][:custom_args].each do |arg| -%> + - <%= arg %> +<% end -%> exclude_sensor_ids: <% node[:hardware][:ipmi][:excluded_sensors].each do |sensor| -%> - <%= sensor %> diff --git a/cookbooks/hardware/templates/default/lldp.rb.erb b/cookbooks/hardware/templates/default/lldp.rb.erb new file mode 100644 index 000000000..fb8d8cf0f --- /dev/null +++ b/cookbooks/hardware/templates/default/lldp.rb.erb @@ -0,0 +1,25 @@ +require "json" + +Ohai.plugin(:Lldp) do + provides "lldp" + + collect_data(:default) do + lldp Mash.new + + json = JSON.parse(%x(/usr/sbin/lldpctl -f json)) + + interfaces = if json["lldp"]["interface"].is_a?(Array) + json["lldp"]["interface"] + else + [json["lldp"]["interface"]] + end + + interfaces.each do |interface| + interface.each do |name, details| + lldp[name] = details + end + end + + lldp + end +end diff --git a/cookbooks/hardware/templates/default/modules.erb b/cookbooks/hardware/templates/default/modules.erb deleted file mode 100644 index 9ba59d26d..000000000 --- a/cookbooks/hardware/templates/default/modules.erb +++ /dev/null @@ -1,5 +0,0 @@ -# DO NOT EDIT - This file is being maintained by Chef - -<% node[:hardware][:modules].each do |m| -%> -<%= m %> -<% end -%> diff --git a/cookbooks/hardware/templates/default/ohai.rb.erb b/cookbooks/hardware/templates/default/ohai.rb.erb index c3308eb8c..c7d245b94 100644 --- a/cookbooks/hardware/templates/default/ohai.rb.erb +++ b/cookbooks/hardware/templates/default/ohai.rb.erb @@ -256,24 +256,44 @@ Ohai.plugin(:Hardware) do array = nil File.new("/proc/mdstat", "r").each do |line| - if line =~ /^(md\d+) : active raid(\d+)((?: (?:sd[a-z]|nvme\d+n\d+)\d*\[\d+\](?:\([A-Z]\))*)+)$/ + if line =~ /^(md\d+) : active raid(\d+)((?: (?:sd[a-z]\d*|nvme\d+n\d+(?:p\d+)?)\[\d+\](?:\([A-Z]\))*)+)$/ array = { :id => devices[:arrays].count, :device => "/dev/#{Regexp.last_match(1)}", + :status => "optimal", :raid_level => Regexp.last_match(2), :disks => [] } - Regexp.last_match(3).scan(/ (sd[a-z]+|nvme\d+n\d+)\d*\[\d+\](?:\([A-Z]\))*/).flatten.each do |device| - if disk = devices[:disks].find { |d| d[:device] == "/dev/#{device}" } - disk[:arrays] << array[:id] - array[:disks] << disk[:id] + Regexp.last_match(3).split(" ").each do |member| + if member =~ /^(sd[a-z]+|nvme\d+n\d+).*/ + device = Regexp.last_match(1) + + if disk = devices[:disks].find { |d| d[:device] == "/dev/#{device}" } + if member =~ /\(F\)/ + disk[:status] = "failed" + elsif member =~ /\(S\)/ + disk[:status] = "hotspare" + else + disk[:status] = "online" + end + + disk[:arrays] << array[:id] + array[:disks] << disk[:id] + end end end devices[:arrays] << array - elsif array && line =~ /^\s+(\d+) blocks/ + elsif array && line =~ /^\s+(\d+) blocks.*(?:\[([U_]+)\])?/ array[:size] = format_disk_size(Regexp.last_match(1).to_i) + array[:status] = "degraded" if Regexp.last_match(2) =~ /_/ + elsif array && line =~ /^\s+\[.*\]\s+(\S+)\s+=/ + case Regexp.last_match(1) + when "recovery" then array[:status] = "rebuilding" + when "resync" then array[:status] = "rebuilding" + when "checking" then array[:status] = "checking" + end end end end @@ -287,9 +307,12 @@ Ohai.plugin(:Hardware) do disk = nil IO.popen(%w(ssacli controller all show config detail)).each do |line| + next unless line.valid_encoding? + if line =~ /^Smart (?:Array|HBA) (\S+) / controller = { :id => devices[:controllers].count, + :type => "hp", :model => Regexp.last_match(1), :arrays => [], :disks => [] @@ -334,6 +357,8 @@ Ohai.plugin(:Hardware) do array[:disks] << disk[:id] elsif disk && line =~ /^ (\S[^:]+):\s+(.*\S)\s*$/ case Regexp.last_match(1) + when "Status" then disk[:status] = Regexp.last_match(2) + when "Drive Type" then disk[:drive_type] = Regexp.last_match(2) when "Interface Type" then disk[:interface] = Regexp.last_match(2) when "Size" then disk[:size] = Regexp.last_match(2) when "Rotational Speed" then disk[:rpm] = Regexp.last_match(2) @@ -341,10 +366,17 @@ Ohai.plugin(:Hardware) do when "Serial Number" then disk[:serial_number] = Regexp.last_match(2) when "Model" then disk[:model] = Regexp.last_match(2) end + elsif array && line =~ /^ Status:\s+(.*\S)\s*$/ + case Regexp.last_match(1) + when "OK" then array[:status] = "optimal" + when "Interim Recovery Mode" then array[:status] = "degraded" + else array[:status] = "unknown" + end elsif array && line =~ /^ (\S[^:]+):\s+(.*\S)\s*$/ case Regexp.last_match(1) when "Size" then array[:size] = Regexp.last_match(2) when "Fault Tolerance" then array[:raid_level] = Regexp.last_match(2) + when "Status" then array[:status] = Regexp.last_match(2) when "Disk Name" then array[:device] = Regexp.last_match(2).strip when "Mount Points" then array[:mount_point] = Regexp.last_match(2).split.first when "Unique Identifier" then array[:wwn] = Regexp.last_match(2) @@ -371,7 +403,23 @@ Ohai.plugin(:Hardware) do end devices[:disks].each do |disk| - disk[:smart_device] = "cciss,#{disks.find_index(disk[:location])}" + disk[:smart_device] = "cciss,#{disks.find_index(disk[:location])}" + + if disk[:status] == "Failed" + disk[:status] = "failed" + elsif disk[:status] == "Predictive Failure" + disk[:status] = "failed" + elsif disk[:status] == "OK" && disk[:drive_type] == "Data Drive" + disk[:status] = "online" + elsif disk[:status] == "OK" && disk[:drive_type] == "Spare Drive" + disk[:status] = "hotspare" + elsif disk[:drive_type] == "Unassigned Drive" + disk[:status] = "unconfigured" + else + disk[:status] = "unknown" + end + + disk.delete(:drive_type) end end @@ -387,6 +435,7 @@ Ohai.plugin(:Hardware) do if line =~ /^PCI information for Controller (\d+)$/ controller = { :id => devices[:controllers].count, + :type => "megaraid", :arrays => [], :disks => [] } @@ -394,11 +443,11 @@ Ohai.plugin(:Hardware) do devices[:controllers] << controller controllers << controller - elsif line =~ /^Bus Number\s+:\s+(\d+)$/ + elsif line =~ /^Bus Number\s+:\s+([0-9a-f]+)$/i controller[:pci_slot] = format "0000:%02x", Integer("0x#{Regexp.last_match(1)}") - elsif line =~ /^Device Number\s+:\s+(\d+)$/ + elsif line =~ /^Device Number\s+:\s+([0-9a-f]+)$/i controller[:pci_slot] = format "%s:%02x", controller[:pci_slot], Integer("0x#{Regexp.last_match(1)}") - elsif line =~ /^Function Number\s+:\s+(\d+)$/ + elsif line =~ /^Function Number\s+:\s+([0-9a-f]+)$/i controller[:pci_slot] = format "%s.%01x", controller[:pci_slot], Integer("0x#{Regexp.last_match(1)}") end end @@ -447,16 +496,23 @@ Ohai.plugin(:Hardware) do devices[:disks] << disk controller[:disks] << disk[:id] array[:disks] << disk[:id] - elsif disk && line =~ /^Firmware state:\s+(.*\S)\s*$/ - Regexp.last_match(1).split(/,\s*/).each do |state| - case state - when "Unconfigured(bad)" then disk[:status] = "unconfigured" - when "Online" then disk[:status] = "online" - when "Hotspare" then disk[:status] = "hotspare" - when "Failed" then disk[:status] = "failed" - when "Spun Up" then disk[:state] = "spun_up" - when "Spun down" then disk[:state] = "spun_down" - end + elsif disk && line =~ /^Firmware state:\s+(\S.*)$/ + status, state = Regexp.last_match(1).split(/,\s*/) + case status + when "Unconfigured(good)" then disk[:status] = "unconfigured" + when "Unconfigured(bad)" then disk[:status] = "unconfigured" + when "Hotspare" then disk[:status] = "hotspare" + when "Offline" then disk[:status] = "offline" + when "Online" then disk[:status] = "online" + when "Rebuild" then disk[:status] = "rebuilding" + when "Failed" then disk[:status] = "failed" + when "Copyback" then disk[:status] = "rebuilding" + else disk[:status] = "unknown" + end + case state + when "Spun Up" then disk[:state] = "spun_up" + when "Spun down" then disk[:state] = "spun_down" + else disk[:state] = "unknown" end elsif disk && line =~ /^(\S.*\S)\s*:\s+(\S.*)$/ case Regexp.last_match(1) @@ -466,6 +522,17 @@ Ohai.plugin(:Hardware) do when "Raw Size" then disk[:size] = memory_to_disk_size(Regexp.last_match(2).sub(/\s*\[.*\]$/, "")) when "Inquiry Data" then disk[:vendor], disk[:model], disk[:serial_number] = Regexp.last_match(2).split end + elsif array && line =~ /^State\s*:\s+(.*\S)\s*$/ + case Regexp.last_match(1) + when "Partially Degraded" then array[:status] = "degraded" + when "Degraded" then array[:status] = "degraded" + when "Optimal" then array[:status] = "optimal" + when "Consistency Check" then array[:status] = "checking" + when "Background Initialization" then array[:status] = "initialising" + when "Initialization" then array[:status] = "initialising" + when "Reconstruction" then array[:status] = "rebuilding" + else array[:status] = "unknown" + end elsif array && line =~ /^(\S.*\S)\s*:\s+(\S.*)$/ case Regexp.last_match(1) when "RAID Level" then array[:raid_level] = Regexp.last_match(2).scan(/Primary-(\d+)/).first.first @@ -488,16 +555,23 @@ Ohai.plugin(:Hardware) do devices[:disks] << disk end - elsif disk && line =~ /^Firmware state:\s+(.*\S)\s*$/ - Regexp.last_match(1).split(/,\s*/).each do |state| - case state - when "Unconfigured(bad)" then disk[:status] = "unconfigured" - when "Online" then disk[:status] = "online" - when "Hotspare" then disk[:status] = "hotspare" - when "Failed" then disk[:status] = "failed" - when "Spun Up" then disk[:state] = "spun_up" - when "Spun down" then disk[:state] = "spun_down" - end + elsif disk && line =~ /^Firmware state:\s+(\S.*)$/ + status, state = Regexp.last_match(1).split(/,\s*/) + case status + when "Unconfigured(good)" then disk[:status] = "unconfigured" + when "Unconfigured(bad)" then disk[:status] = "unconfigured" + when "Hotspare" then disk[:status] = "hotspare" + when "Offline" then disk[:status] = "offline" + when "Online" then disk[:status] = "online" + when "Rebuild" then disk[:status] = "rebuilding" + when "Failed" then disk[:status] = "failed" + when "Copyback" then disk[:status] = "rebuilding" + else disk[:status] = "unknown" + end + case state + when "Spun Up" then disk[:state] = "spun_up" + when "Spun down" then disk[:state] = "spun_down" + else disk[:state] = "unknown" end elsif disk && line =~ /^(\S.*\S)\s*:\s+(\S.*)$/ case Regexp.last_match(1) @@ -526,6 +600,7 @@ Ohai.plugin(:Hardware) do if line =~ /^\/proc\/mpt\/ioc(\d+)\s+LSI Logic\s+(\S+)\s+/ controller = { :id => devices[:controllers].count, + :type => "mpt1", :model => Regexp.last_match(1), :arrays => [], :disks => [] @@ -602,6 +677,7 @@ Ohai.plugin(:Hardware) do next unless line =~ /^\s+(\d+)\s+(\S+)\s+\h+h\s+\h+h\s+(\S+)\s+\h+h\s+\h+h\s*$/ controllers[Regexp.last_match(1).to_i] = { :id => devices[:controllers].count, + :type => "mpt2", :model => Regexp.last_match(2), :pci_slot => Regexp.last_match(3).sub(/^(\h{2})h:(\h{2})h:(\h{2})h:0(\h)h$/, "00\\1:\\2:\\3.\\4"), :arrays => [], @@ -642,6 +718,23 @@ Ohai.plugin(:Hardware) do controller[:disks] << disk[:id] disks << disk + elsif disk && line =~ /^ State\s+:\s+(.*\S)\s*$/ + Regexp.last_match(1).split(/,\s*/).each do |state| + case state + when "Online (ONL)" then disk[:status] = "online" + when "Hot Spare (HSP)" then disk[:status] = "hotspare" + when "Ready (RDY)" then disk[:status] = "unconfigured" + when "Available (AVL)" then disk[:status] = "unconfigured" + when "Failed (FLD)" then disk[:status] = "failed" + when "Missing (MIS)" then disk[:status] = "missing" + when "Standby (SBY)" then disk[:status] = "unconfigured" + when "Out of Sync (OSY)" then disk[:status] = "degraded" + when "Degraded (DGD)" then disk[:status] = "degraded" + when "Rebuilding (RBLD)" then disk[:status] = "rebuilding" + when "Optimal (OPT)" then disk[:status] = "online" + else disk[:status] = "unknown" + end + end elsif disk && line =~ /^ (\S.*\S)\s+:\s+(.*\S)\s*$/ case Regexp.last_match(1) when "Enclosure #" then disk[:location] = Regexp.last_match(2) @@ -656,6 +749,18 @@ Ohai.plugin(:Hardware) do end elsif array && line =~ /^ PHY\[\d+\] Enclosure#\/Slot#\s+:\s+(\d+:\d+)\s*$/ array[:disks] << Regexp.last_match(1) + elsif array && line =~ /^ Status of volume\s+:\s+(.*\S)\s*$/ + Regexp.last_match(1).split(/,\s*/).each do |state| + case state + when "Okay (OKY)" then array[:status] = "optimal" + when "Degraded (DGD)" then array[:status] = "degraded" + when "Failed (FLD)" then array[:status] = "failed" + when "Missing (MIS)" then array[:status] = "missing" + when "Initializing (INIT)" then array[:status] = "initialising" + when "Online (ONL)" then array[:status] = "optimal" + else array[:status] = "unknown" + end + end elsif array && line =~ /^ (\S.*\S)\s+:\s+(.*\S)\s*$/ case Regexp.last_match(1) when "Volume wwid" then array[:device] = find_sas_device(Regexp.last_match(2)) @@ -688,6 +793,7 @@ Ohai.plugin(:Hardware) do controller = { :id => devices[:controllers].count, :number => controller_number, + :type => "adaptec", :arrays => [], :disks => [] } @@ -729,6 +835,16 @@ Ohai.plugin(:Hardware) do elsif disk && line =~ /^ Reported Channel,Device\(T:L\)\s*:\s+(\d+),(\d+)\(\d+:0\)\s*$/ disk[:channel_number] = Regexp.last_match(1) disk[:device_number] = Regexp.last_match(2) + elsif disk && line =~ /^ State\s*:\s+(\S.*\S)\s*$/ + case Regexp.last_match(1) + when "Online" then disk[:status] = "online" + when "Online (JBOD)" then disk[:status] = "online" + when "Hot Spare" then disk[:status] = "hotspare" + when "Ready" then disk[:status] = "unconfigured" + when "Global Hot-Spare" then disk[:status] = "hostspare" + when "Dedicated Hot-Spare" then disk[:status] = "hotspare" + else disk[:status] = "unknown" + end elsif disk && line =~ /^ (\S.*\S)\s*:\s+(\S.*\S)\s*$/ case Regexp.last_match(1) when "Reported Location" then disk[:location] = Regexp.last_match(2) @@ -744,6 +860,11 @@ Ohai.plugin(:Hardware) do end elsif array && line =~ / Present \(.*((?:Connector|Enclosure):\d+,\s*(?:Device|Slot):\d+)\) / array[:disks] << Regexp.last_match(1).tr(":", " ").gsub(/,\s*/, ", ") + elsif array && line =~ /^ Status of Logical Device\s*:\s+(\S.*\S)\s*$/ + case Regexp.last_match(1) + when "Optimal" then array[:status] = "optimal" + else array[:status] = "unknown" + end elsif array && line =~ /^ (\S.*\S)\s*:\s+(\S.*\S)\s*$/ case Regexp.last_match(1) when "RAID level" then array[:raid_level] = Regexp.last_match(2) @@ -792,6 +913,7 @@ Ohai.plugin(:Hardware) do def find_areca_disks(devices) controller = { :id => devices[:controllers].count, + :type => "areca", :arrays => [], :disks => [] } @@ -844,6 +966,11 @@ Ohai.plugin(:Hardware) do device = Dir.glob("/sys/bus/pci/devices/#{pci_slot}/host*/target*:0:0/0:#{channel}:#{id}:#{lun}/block/*").first array[:device] = "/dev/#{File.basename(device)}" + elsif line =~ /^Volume State\s+:\s+(.*\S)\s*$/ + case Regexp.last_match(1) + when "Normal" then array[:status] = "optimal" + else array[:status] = "unknown" + end elsif line =~ /^(\S.*\S)\s+:\s+(.*\S)\s*$/ case Regexp.last_match(1) when "Volume Set Name" then array[:volume_set] = Regexp.last_match(2) @@ -885,6 +1012,11 @@ Ohai.plugin(:Hardware) do disk[:smart_device] = "areca,#{Regexp.last_match(1)}" elsif line =~ /^Device Location\s+:\s+Enclosure#(\d+) Slot#?\s*0*(\d+)\s*$/i disk[:smart_device] = "areca,#{Regexp.last_match(2)}/#{Regexp.last_match(1)}" + elsif line =~ /^Device State\s+:\s+(.*\S)\s*$/ + case Regexp.last_match(1) + when "NORMAL" then disk[:status] = "online" + else disk[:status] = "unknown" + end elsif line =~ /^(\S.*\S)\s+:\s+(.*\S)\s*$/ case Regexp.last_match(1) when "Model Name" then disk[:vendor], disk[:model] = Regexp.last_match(2).split diff --git a/cookbooks/imagery/recipes/default.rb b/cookbooks/imagery/recipes/default.rb index 63b33b70f..7a5b55057 100644 --- a/cookbooks/imagery/recipes/default.rb +++ b/cookbooks/imagery/recipes/default.rb @@ -71,10 +71,9 @@ remote_file "#{Chef::Config[:file_cache_path]}/ostn02-ntv2-data.zip" do not_if { ::File.exist?("/srv/imagery/common/ostn02-ntv2-data/OSTN02_NTv2.gsb") } end -execute "unzip-ostn02-ntv2-data" do - command "unzip -q #{Chef::Config[:file_cache_path]}/ostn02-ntv2-data.zip" - cwd "/srv/imagery/common/ostn02-ntv2-data" - user "root" +archive_file "#{Chef::Config[:file_cache_path]}/ostn02-ntv2-data.zip" do + destination "/srv/imagery/common/ostn02-ntv2-data" + owner "root" group "root" not_if { ::File.exist?("/srv/imagery/common/ostn02-ntv2-data/OSTN02_NTv2.gsb") } end diff --git a/cookbooks/imagery/recipes/gb_os_sv.rb b/cookbooks/imagery/recipes/gb_os_sv.rb index b9af18645..c200d0531 100644 --- a/cookbooks/imagery/recipes/gb_os_sv.rb +++ b/cookbooks/imagery/recipes/gb_os_sv.rb @@ -1056,19 +1056,6 @@ imagery_layer "gb_os_sv_diff_2015_11_2016_04" do overlay true end -imagery_layer "gb_os_om_local_2020_04" do - site "os.openstreetmap.org" - title "OS OpenMap Local - April 2020" - projection "EPSG:27700" - source "/data/imagery/gb/openmap-local/2020-04/os-openmap-local-2020-04-combined-sea-average-zstd22.vrt" - copyright "Contains OS data © Crown copyright and database right 2020" - revision 2 - background_colour "213 244 248" # OS OpenMap Local Water Blue - extension "os_om_local_png" - url_aliases ["/om-local-2020-04", "/om-local"] - default_layer true -end - imagery_layer "gb_os_om_local_2016_10" do site "os.openstreetmap.org" title "OS OpenMap Local - October 2016" @@ -1128,3 +1115,56 @@ imagery_layer "gb_os_om_local_2019_04" do background_colour "213 244 248" # OS OpenMap Local Water Blue extension "os_om_local_png" end + +imagery_layer "gb_os_om_local_2020_04" do + site "os.openstreetmap.org" + title "OS OpenMap Local - April 2020" + projection "EPSG:27700" + source "/data/imagery/gb/openmap-local/2020-04/os-openmap-local-2020-04-combined-sea-average-zstd22.vrt" + copyright "Contains OS data © Crown copyright and database right 2020" + revision 2 + background_colour "213 244 248" # OS OpenMap Local Water Blue + extension "os_om_local_png" +end + +imagery_layer "gb_os_om_local_2020_10" do + site "os.openstreetmap.org" + title "OS OpenMap Local - October 2020" + projection "EPSG:27700" + source "/data/imagery/gb/openmap-local/2020-10/os-openmap-local-2020-10.vrt" + copyright "Contains OS data © Crown copyright and database right 2020" + background_colour "213 244 248" # OS OpenMap Local Water Blue + extension "os_om_local_png" +end + +imagery_layer "gb_os_om_local_2021_04" do + site "os.openstreetmap.org" + title "OS OpenMap Local - April 2021" + projection "EPSG:27700" + source "/data/imagery/gb/openmap-local/2021-04/os-openmap-local-2021-04.vrt" + copyright "Contains OS data © Crown copyright and database right 2021" + background_colour "213 244 248" # OS OpenMap Local Water Blue + extension "os_om_local_png" +end + +imagery_layer "gb_os_om_local_2021_10" do + site "os.openstreetmap.org" + title "OS OpenMap Local - October 2021" + projection "EPSG:27700" + source "/data/imagery/gb/openmap-local/2021-10/os-openmap-local-2021-10.vrt" + copyright "Contains OS data © Crown copyright and database right 2021" + background_colour "213 244 248" # OS OpenMap Local Water Blue + extension "os_om_local_png" +end + +imagery_layer "gb_os_om_local_2022_04" do + site "os.openstreetmap.org" + title "OS OpenMap Local - April 2022" + projection "EPSG:27700" + source "/data/imagery/gb/openmap-local/2022-04/os-openmap-local-2022-04.vrt" + copyright "Contains OS data © Crown copyright and database right 2022" + background_colour "213 244 248" # OS OpenMap Local Water Blue + extension "os_om_local_png" + url_aliases ["/om-local-2022-04", "/om-local"] + default_layer true +end diff --git a/cookbooks/imagery/resources/layer.rb b/cookbooks/imagery/resources/layer.rb index 6affe4b80..dc1fd51bb 100644 --- a/cookbooks/imagery/resources/layer.rb +++ b/cookbooks/imagery/resources/layer.rb @@ -19,6 +19,8 @@ require "yaml" +unified_mode true + default_action :create property :layer, String, :name_property => true diff --git a/cookbooks/imagery/resources/site.rb b/cookbooks/imagery/resources/site.rb index c30c26d95..14cb2842e 100644 --- a/cookbooks/imagery/resources/site.rb +++ b/cookbooks/imagery/resources/site.rb @@ -19,6 +19,8 @@ require "yaml" +unified_mode true + default_action :create property :site, String, :name_property => true @@ -98,37 +100,47 @@ action :create do base_domains = [new_resource.site] + Array(new_resource.aliases) tile_domains = base_domains.flat_map { |d| [d, "a.#{d}", "b.#{d}", "c.#{d}"] } - %w[0 1 2 3 4 5 6 7].each do |index| - systemd_service "mapserv-fcgi-#{new_resource.site}-#{index}" do - description "Map server for #{new_resource.site} layer" - environment "MS_MAP_PATTERN" => "^/srv/imagery/mapserver/", - "MS_DEBUGLEVEL" => "0", - "MS_ERRORFILE" => "stderr", - "GDAL_CACHEMAX" => "512" - limit_nofile 16384 - limit_cpu 180 - memory_high "512M" - memory_max "1G" - user "imagery" - group "imagery" - exec_start_pre "/bin/rm -f /run/mapserver-fastcgi/layer-#{new_resource.site}-#{index}.socket" - exec_start "/usr/bin/spawn-fcgi -n -b 8192 -s /run/mapserver-fastcgi/layer-#{new_resource.site}-#{index}.socket -M 0666 -P /run/mapserver-fastcgi/layer-#{new_resource.site}-#{index}.pid -- /usr/lib/cgi-bin/mapserv" - private_tmp true - private_devices true - private_network true - protect_system "full" - protect_home true - no_new_privileges true - restart "always" - pid_file "/run/mapserver-fastcgi/layer-#{new_resource.site}-#{index}.pid" - end - - service "mapserv-fcgi-#{new_resource.site}-#{index}" do - provider Chef::Provider::Service::Systemd - action [:enable, :start] - supports :status => true, :restart => true, :reload => false - subscribes :restart, "systemd_service[mapserv-fcgi-#{new_resource.site}-#{index}]" - end + systemd_service "mapserv-fcgi-#{new_resource.site}" do + description "Map server for #{new_resource.site} layer" + environment "MS_MAP_PATTERN" => "^/srv/imagery/mapserver/", + "=" => "0", + "MS_ERRORFILE" => "stderr", + "GDAL_CACHEMAX" => "512" + limit_nofile 16384 + memory_high "1G" + memory_max "2G" + user "imagery" + group "imagery" + exec_start "/usr/bin/multiwatch -f 12 --signal=TERM -- /usr/lib/cgi-bin/mapserv" + standard_input "socket" + private_tmp true + private_devices true + private_network true + protect_system "full" + protect_home true + no_new_privileges true + # Terminate service after 5mins. Service is socket activated + runtime_max_sec 300 + end + + systemd_socket "mapserv-fcgi-#{new_resource.site}" do + description "Map server for #{new_resource.site} layer socket" + socket_user "imagery" + socket_group "imagery" + listen_stream "/run/mapserver-fastcgi/layer-#{new_resource.site}.socket" + end + + # Ensure service is stopped because otherwise the socket cannot reload + service "mapserv-fcgi-#{new_resource.site}" do + provider Chef::Provider::Service::Systemd + action :nothing + subscribes :stop, "systemd_service[mapserv-fcgi-#{new_resource.site}]" + subscribes :stop, "systemd_socket[mapserv-fcgi-#{new_resource.site}]" + end + + systemd_unit "mapserv-fcgi-#{new_resource.site}.socket" do + action [:enable, :start] + subscribes :restart, "systemd_socket[mapserv-fcgi-#{new_resource.site}]" end ssl_certificate new_resource.site do @@ -143,15 +155,13 @@ action :create do end action :delete do - %w[0 1 2 3 4 5 6 7].each do |index| - service "mapserv-fcgi-#{new_resource.site}-#{index}" do - provider Chef::Provider::Service::Systemd - action [:stop, :disable] - end - - systemd_service "mapserv-fcgi-#{new_resource.site}-#{index}" do - action :delete - end + service "mapserv-fcgi-#{new_resource.site}" do + provider Chef::Provider::Service::Systemd + action [:stop, :disable] + end + + systemd_service "mapserv-fcgi-#{new_resource.site}" do + action :delete end nginx_site new_resource.site do diff --git a/cookbooks/imagery/templates/default/imagery.js.erb b/cookbooks/imagery/templates/default/imagery.js.erb index bee7747ab..e29d86342 100644 --- a/cookbooks/imagery/templates/default/imagery.js.erb +++ b/cookbooks/imagery/templates/default/imagery.js.erb @@ -36,5 +36,9 @@ function createMap(divName) { // Add the permalink control map.addControl(new L.Control.Permalink()); + var lc = L.control.locate({ + position: 'topright' + }).addTo(map); + return map; } diff --git a/cookbooks/imagery/templates/default/index.html.erb b/cookbooks/imagery/templates/default/index.html.erb index c6975cb78..c21d95e04 100644 --- a/cookbooks/imagery/templates/default/index.html.erb +++ b/cookbooks/imagery/templates/default/index.html.erb @@ -4,11 +4,17 @@ <%= @title %> - - - - - + + + + + + + + + + +