Compare commits
423 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 368c1eba1f | |||
| 3be64bb4aa | |||
| cb174356e5 | |||
| 88248b644c | |||
| 24a7381e9f | |||
| d746aa0b93 | |||
| 1fa54ef9bb | |||
| 073e129ffd | |||
| b002cf3f81 | |||
| 0f7c6c00ce | |||
| 8f00f21413 | |||
| e91ec52ebe | |||
| 2e65dc6cb0 | |||
| 2e819d6edd | |||
| 9e64de4024 | |||
| ece08cd03e | |||
| bb5a3bfd75 | |||
| c67261fe46 | |||
| 4bd1ff360b | |||
| f8b103fb13 | |||
| 9d7920755d | |||
| 9a6676e5e7 | |||
| 837c592936 | |||
| 612fb0a243 | |||
| 3bd1e82480 | |||
| cf4a74a538 | |||
| 41c4cb9089 | |||
| 4ab4285a5b | |||
| a146360479 | |||
| 83105438ca | |||
| 9e18531526 | |||
| 503a84c225 | |||
| 9bd5384209 | |||
| 5ec272d268 | |||
| 9282641d06 | |||
| c3c9ad8462 | |||
| e21a0d2105 | |||
| f6ca16a49b | |||
| 09f2ac4ffa | |||
| 26e890eb62 | |||
| 0d97cf019c | |||
| a1454ef518 | |||
| 324922818d | |||
| d5df8870b6 | |||
| 6a4e667d16 | |||
| 7052b0759a | |||
| 8939d41c6c | |||
| 8c3519acf3 | |||
| a5c854705b | |||
| 6c87a0713d | |||
| c38e71d7e1 | |||
| 91133d6fa6 | |||
| 3007ef9970 | |||
| bcbcb78d6d | |||
| ada57de4d8 | |||
| 3cf9c431e4 | |||
| 1a9ac7012d | |||
| 7691176c28 | |||
| 3f7e75c255 | |||
| 543db100d3 | |||
| a77bf8c971 | |||
| a9228e1465 | |||
| 73104b0cdd | |||
| fb334f3c1f | |||
| b8e03090ea | |||
| c05c8ab077 | |||
| 6f488e1684 | |||
| f995d92c46 | |||
| b9ce65655f | |||
| 0825f2c0bb | |||
| 25a051ffeb | |||
| 4b3563a3e3 | |||
| 5e6705a7cd | |||
| ffc3f0702b | |||
| 34ddbc37fc | |||
| b17d34f377 | |||
| d814697fae | |||
| 4436e76959 | |||
| cde6184725 | |||
| ba7b24b9d4 | |||
| 258edce92e | |||
| 62b2940bc8 | |||
| ae54364d7c | |||
| f31d37cb10 | |||
| 07b589cf5f | |||
| 177c7feb01 | |||
| d68cc6292b | |||
| 989d762140 | |||
| afa8f68fe0 | |||
| 8241cfa9c4 | |||
| 469cf60015 | |||
| efde07c4f7 | |||
| 3630cecbe6 | |||
| bee52762cf | |||
| 5c421b753d | |||
| ac98ac34ea | |||
| 3ca199f8bb | |||
| 7a138ca76f | |||
| 7a5f5a1fbe | |||
| 4766184140 | |||
| 474fdef5d4 | |||
| 42a2155136 | |||
| f8004124c8 | |||
| 2cb5123dad | |||
| 55da127c36 | |||
| 74f75e693b | |||
| 68c020004b | |||
| b9199b8f98 | |||
| 81d9ba8045 | |||
| 2a768018aa | |||
| 386044b7e4 | |||
| 9cd3e3b9e9 | |||
| 03494145d4 | |||
| 2f49c9042a | |||
| 1265bfa9b0 | |||
| b1d9657478 | |||
| a5a25eb2a8 | |||
| db30d8621e | |||
| ad9420f7fd | |||
| e02e218a5a | |||
| db7ca534c6 | |||
| 727d95f091 | |||
| d8a596cb00 | |||
| ca6aa13b40 | |||
| 09115c3cda | |||
| a0b3b65fa3 | |||
| 73666ae123 | |||
| 8437dea9ff | |||
| 1bbaea5fce | |||
| 62cc311210 | |||
| eda47816bd | |||
| 9db23b27fd | |||
| 23a5c2887e | |||
| 430ac501e0 | |||
| d5328585dd | |||
| fbd399ff1d | |||
| 9fb1746ff9 | |||
| b0a81b5b0d | |||
| f2eef0ccf8 | |||
| 5f30c84cd4 | |||
| c035fe4cbf | |||
| c50bbc8c04 | |||
| 35a44a6b1c | |||
| c99348113a | |||
| 81578371f8 | |||
| 0e28a6675d | |||
| db946256f9 | |||
| 5bf961b06a | |||
| 253e5f3cff | |||
| 5bf0ede3ef | |||
| 3a5271dd2e | |||
| 52b1f7ea66 | |||
| 57780bfa37 | |||
| 78c2a21836 | |||
| eb92c9bd1b | |||
| 58347e3510 | |||
| 2cdc7b81f1 | |||
| df49bb780b | |||
| d35a22c763 | |||
| 7858ee8896 | |||
| f417741ac9 | |||
| 9fe48e41f8 | |||
| d0142ea1fb | |||
| 01a8af1a1c | |||
| 0516e936db | |||
| af83a62ec5 | |||
| 2e7731cc7b | |||
| c0d45c890f | |||
| 058918d101 | |||
| bb8a274848 | |||
| 9e05781ec2 | |||
| f96405e78a | |||
| 8a1145f607 | |||
| 39dbecdc10 | |||
| 3401cb5358 | |||
| 3bb0f45b9b | |||
| da5fd1a3d0 | |||
| 144a435967 | |||
| c0a8e3f436 | |||
| 2f21225155 | |||
| ea7b980255 | |||
| 395eace356 | |||
| cc948fe354 | |||
| 1a2fad128b | |||
| 67682ec259 | |||
| c840a688ab | |||
| 3ede33a886 | |||
| 4d7910f424 | |||
| 10d97c8140 | |||
| d57b870f3e | |||
| 44119e2051 | |||
| 8596226787 | |||
| 85382a5140 | |||
| 1f4713d320 | |||
| b7dd48b41f | |||
| 4decc86598 | |||
| 6fb5095197 | |||
| 79a7ee656e | |||
| 71679c8921 | |||
| 44dbdd9632 | |||
| 97231e64ba | |||
| cc785e2f1b | |||
| a9f041a702 | |||
| 5daf512405 | |||
| d6bc7757ab | |||
| 94db6c64a9 | |||
| ef159cd863 | |||
| 263da2463a | |||
| 15a485cbdb | |||
| 440828f0f1 | |||
| 5d53e0d5ce | |||
| 07c0cda12d | |||
| 2f08d24743 | |||
| 1b4f249157 | |||
| 410d798e98 | |||
| 34937479a8 | |||
| 41bfd5e1f3 | |||
| e56de16876 | |||
| f385d32331 | |||
| 3c5470358e | |||
| 05db74e7db | |||
| 470e93e4df | |||
| f359c2a716 | |||
| 88516dd8ae | |||
| 3e20032a32 | |||
| f849dd0693 | |||
| a566684564 | |||
| dceb2b7c32 | |||
| 270d1199a6 | |||
| 89bdb78f0a | |||
| 756424b6dd | |||
| e9c710e4fc | |||
| 8f2209680a | |||
| 95cee0eb5d | |||
| ea54fe98f7 | |||
| 939470d771 | |||
| 84754d3d20 | |||
| dd694b5fb4 | |||
| e44e357381 | |||
| ced12cbf76 | |||
| 2854ee56e9 | |||
| fd71023dd6 | |||
| 124e4ba53c | |||
| 85a0ba28d7 | |||
| 54352fe566 | |||
| 326496ff80 | |||
| 6188f07c95 | |||
| 4fa86c4dc3 | |||
| 39a54f5abf | |||
| 52dd0274d3 | |||
| 3ed0960edb | |||
| a12d3834d4 | |||
| 780f2293d6 | |||
| f9c5a0fd4d | |||
| a575e86b88 | |||
| 8f501a928a | |||
| ad762980bb | |||
| b019a57894 | |||
| 8724fe4b11 | |||
| b1b1fe72e8 | |||
| bfff3d3f9b | |||
| cb0666e235 | |||
| cb55229c1e | |||
| 9b1f2462bf | |||
| 3fab16603a | |||
| 66343f977f | |||
| bcb9cf3c06 | |||
| 55d8057b7f | |||
| 5e19854d47 | |||
| 781b579074 | |||
| 77c07615f8 | |||
| 743d01d4a6 | |||
| 12cd67b8d9 | |||
| 6641af720d | |||
| 2d110f25f7 | |||
| 39b6bb8a18 | |||
| 7270be85a4 | |||
| 560d87e26a | |||
| b3245ac327 | |||
| a1a44a3582 | |||
| da5c30efa2 | |||
| 1ffcd33817 | |||
| 9e0a6d86ba | |||
| 501bb0afd6 | |||
| 5f7d053c3a | |||
| 56c8976bac | |||
| 72d6c3246f | |||
| 166edb2cc1 | |||
| 8b31081c52 | |||
| 4619c662cc | |||
| e8a0ceacaf | |||
| 4802f21a9e | |||
| 9c88857364 | |||
| b71cc08ce1 | |||
| 0741598f58 | |||
| e29b0d099f | |||
| 3fde72ea5c | |||
| d022b89063 | |||
| 5b8155a578 | |||
| b7a50a4f6f | |||
| a606131a6a | |||
| 6b413b0d0f | |||
| 693c535a94 | |||
| a25cf8ba83 | |||
| a15a99b304 | |||
| 6e8f970999 | |||
| bbe0cf376f | |||
| f660247b47 | |||
| 1d2d2cf261 | |||
| 50d5ca71d0 | |||
| 189e8ab1e0 | |||
| dbbbfd4b2b | |||
| ece4a843c0 | |||
| d62f138153 | |||
| 7fc1276ac7 | |||
| ba2bba0f66 | |||
| ab7561b2b6 | |||
| 3740ce2854 | |||
| bfd53c5bd7 | |||
| 9691d56713 | |||
| 92829e8f94 | |||
| c518f35e83 | |||
| 3e57a44829 | |||
| 5cf1fd8aa9 | |||
| c64f579518 | |||
| 054c168b32 | |||
| f599267459 | |||
| 3cd416b667 | |||
| 3139636906 | |||
| 0d349e331e | |||
| 51968cfd53 | |||
| 21488bdd7e | |||
| 3945f9cdb1 | |||
| de1b95c8e7 | |||
| 725e733178 | |||
| d226ed697e | |||
| 77b57fbbfe | |||
| 0dc3ffd29a | |||
| 10e45481be | |||
| bfb8436ca2 | |||
| edf3503779 | |||
| a98cfbe868 | |||
| 12ea922389 | |||
| db6fc916cf | |||
| 46e9bf5678 | |||
| c6177d2629 | |||
| 0399a88eb6 | |||
| 8f715e12a9 | |||
| 4b39ce5134 | |||
| 53ae74200a | |||
| 9f570345a5 | |||
| 5d866295d8 | |||
| 9eae10b94a | |||
| ca58aa1644 | |||
| 3b9c10dcf6 | |||
| 28e0fa7d1d | |||
| 3833f2315a | |||
| e65c3ef9c9 | |||
| 552aee93fa | |||
| 1791fbdc49 | |||
| c2e3999f76 | |||
| 677cec6e1c | |||
| 7435064cd3 | |||
| 0c57d94467 | |||
| 366aeb7228 | |||
| 296884b24a | |||
| 2e5ce9f4ec | |||
| cc67ae9dbb | |||
| 71d33fa065 | |||
| db3b0b63da | |||
| 5433932bd4 | |||
| f5c6a22f17 | |||
| f47c64cec6 | |||
| 7feb0f737b | |||
| 5271c1a9ad | |||
| ef3e5899c6 | |||
| badd2908b7 | |||
| 3f3b92a149 | |||
| c3646f5554 | |||
| a97d73d616 | |||
| 50684a5a34 | |||
| f06467b95b | |||
| 9faae4b71c | |||
| e49d5a5f9a | |||
| ed10a5de5b | |||
| e8b84145e8 | |||
| 38f8734014 | |||
| a10564e214 | |||
| ecef3b6b98 | |||
| e65ea6a8b7 | |||
| 7139de2a6e | |||
| b5403de5e5 | |||
| 0966f1358b | |||
| a0ac64cbd6 | |||
| b03b6dfb99 | |||
| c11f9833ac | |||
| 9ee34ef6b3 | |||
| df7e519159 | |||
| 5e60812ad4 | |||
| 1263604703 | |||
| 5904db580f | |||
| 1960067926 | |||
| 33bd9ecd9d | |||
| 7f7c1fcccf | |||
| 34fdd0e839 | |||
| 9de4eccd99 | |||
| a0847dc852 | |||
| 87a3145ba1 | |||
| 85e236d798 | |||
| cb4c3d7a9e | |||
| e55fc87ad3 | |||
| 5398dea0df | |||
| e0eb6bbd28 | |||
| 822b323f8e | |||
| c1f645cd5f | |||
| f1d9359acf | |||
| 550e774db2 | |||
| e23b06ec8c | |||
| 4f8b8a8a59 | |||
| c06d71e662 | |||
| cce43652f0 | |||
| 9f0a4c8edb | |||
| f571cfbf71 |
@@ -1,15 +0,0 @@
|
||||
codecov:
|
||||
branch: master
|
||||
ci:
|
||||
- drone.nextcloud.com
|
||||
- !scrutinizer-ci.com
|
||||
|
||||
coverage:
|
||||
precision: 2
|
||||
round: down
|
||||
range: "70...100"
|
||||
status:
|
||||
project: off
|
||||
patch: off
|
||||
|
||||
comment: off
|
||||
@@ -1,86 +0,0 @@
|
||||
FROM ubuntu:jammy
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# PHP
|
||||
RUN apt-get update -y && \
|
||||
apt install -y apache2 vim software-properties-common sudo nano gnupg2
|
||||
|
||||
RUN apt-get install --no-install-recommends -y \
|
||||
php8.1 \
|
||||
php8.1-common \
|
||||
php8.1-gd \
|
||||
php8.1-zip \
|
||||
php8.1-curl \
|
||||
php8.1-xml \
|
||||
php8.1-xmlrpc \
|
||||
php8.1-mbstring \
|
||||
php8.1-sqlite \
|
||||
php8.1-xdebug \
|
||||
php8.1-pgsql \
|
||||
php8.1-intl \
|
||||
php8.1-imagick \
|
||||
php8.1-gmp \
|
||||
php8.1-apcu \
|
||||
php8.1-bcmath \
|
||||
php8.1-redis \
|
||||
php8.1-soap \
|
||||
php8.1-imap \
|
||||
php8.1-opcache \
|
||||
php8.1-cli \
|
||||
php8.1-dev \
|
||||
libmagickcore-6.q16-3-extra \
|
||||
curl \
|
||||
lsof \
|
||||
make \
|
||||
unzip
|
||||
|
||||
# Composer
|
||||
RUN curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php && \
|
||||
curl -sS https://composer.github.io/installer.sig -o /tmp/composer-setup.sig && \
|
||||
php -r "if (hash_file('sha384', '/tmp/composer-setup.php') !== trim(file_get_contents('/tmp/composer-setup.sig'))) { echo 'Composer installation failed, invalid hash'; exit(1); }" && \
|
||||
php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer && \
|
||||
rm /tmp/composer-setup.php /tmp/composer-setup.sig
|
||||
|
||||
RUN echo "xdebug.remote_enable = 1" >> /etc/php/8.1/cli/conf.d/20-xdebug.ini && \
|
||||
echo "xdebug.remote_autostart = 1" >> /etc/php/8.1/cli/conf.d/20-xdebug.ini && \
|
||||
echo "apc.enable_cli=1" >> /etc/php/8.1/cli/conf.d/20-apcu.ini
|
||||
|
||||
# Autostart XDebug for apache
|
||||
RUN { \
|
||||
echo "xdebug.mode=debug"; \
|
||||
echo "xdebug.start_with_request=yes"; \
|
||||
} >> /etc/php/8.1/apache2/conf.d/20-xdebug.ini
|
||||
|
||||
# Docker
|
||||
RUN apt-get -y install \
|
||||
apt-transport-https \
|
||||
ca-certificates \
|
||||
curl \
|
||||
gnupg-agent \
|
||||
software-properties-common && \
|
||||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - && \
|
||||
add-apt-repository \
|
||||
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
|
||||
$(lsb_release -cs) \
|
||||
stable" && \
|
||||
apt-get update -y && \
|
||||
apt-get install -y docker-ce docker-ce-cli containerd.io && \
|
||||
ln -s /var/run/docker-host.sock /var/run/docker.sock
|
||||
|
||||
# Dedicated DevContainer user runs Apache
|
||||
ENV APACHE_RUN_USER=devcontainer
|
||||
ENV APACHE_RUN_GROUP=devcontainer
|
||||
RUN useradd -ms /bin/bash ${APACHE_RUN_USER} && \
|
||||
adduser ${APACHE_RUN_USER} sudo && \
|
||||
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
|
||||
sed -ri "s/^export APACHE_RUN_USER=.*$/export APACHE_RUN_USER=${APACHE_RUN_USER}/" "/etc/apache2/envvars" && \
|
||||
sed -ri "s/^export APACHE_RUN_GROUP=.*$/export APACHE_RUN_GROUP=${APACHE_RUN_GROUP}/" "/etc/apache2/envvars"
|
||||
|
||||
USER devcontainer
|
||||
|
||||
# NVM
|
||||
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
|
||||
RUN bash --login -i -c 'source /home/devcontainer/.bashrc && nvm install 16'
|
||||
|
||||
WORKDIR /var/www/html
|
||||
@@ -1,72 +0,0 @@
|
||||
# Nextcloud DevContainer
|
||||
|
||||
## Usage
|
||||
|
||||
Make sure you have the [VSCode DevContainer](https://code.visualstudio.com/docs/devcontainers/containers) extensions installed. If you open the project, VSCode will ask you if you want to open it inside of the DevContainer. If that's not the case, use <kbd>F1</kbd>→*Dev Containers: Open Folder in Container*.
|
||||
|
||||
Alternatively open the project directly in [GitHub Codespaces](https://github.com/features/codespaces).
|
||||
|
||||
That's already it. Everything else will be configured automatically by the Containers startup routine.
|
||||
|
||||
## Credentials
|
||||
|
||||
On first start the Container installs and configures Nextcloud with the following credentials:
|
||||
|
||||
**Nextcloud Admin Login**
|
||||
|
||||
Username: `admin` <br>
|
||||
Password: `admin`
|
||||
|
||||
**Postgres credentials**
|
||||
|
||||
Username: `postgres` <br>
|
||||
Password: `postgres` <br>
|
||||
Database: `postgres`
|
||||
|
||||
## Services
|
||||
|
||||
The following services will be started:
|
||||
|
||||
| Service | Local port | Description |
|
||||
|---------|------------|-------------|
|
||||
| Nextcloud (served via Apache) | `80` | The main application |
|
||||
| Mailhog | `8025` | SMTP email delivery for testing |
|
||||
| Adminer | `8080` | Database viewer. Use credentials from above and connect to `localhost` to get access to the NC database |
|
||||
|
||||
## Permissions
|
||||
|
||||
The container runs with the user `devcontainer` who is also running the Apache2 process. All mounted source files have
|
||||
proper permissions so that this user can access everything which is inside the current workspace. If you need to
|
||||
get root permissions for whatever reason, use `sudo su` or `sudo <command>` (for example `sudo service apache2 restart`).
|
||||
Everything else (like building the application, adjusting files, ...) should be done as `devcontainer` user.
|
||||
|
||||
## NodeJs and NVM
|
||||
|
||||
The container comes with [`nvm`](https://github.com/nvm-sh/nvm) and Node 16 installed. This should be sufficient to
|
||||
build Nextcloud Core sources via `make`. If you need a different Node Version (for example for
|
||||
app development), you can easily switch between different versions by running:
|
||||
|
||||
```bash
|
||||
# Install and use Node 14
|
||||
nvm install 14
|
||||
nvm use 14
|
||||
|
||||
# Check version
|
||||
node -v
|
||||
|
||||
# Switch back to Node 16
|
||||
nvm use 16
|
||||
|
||||
# Check version
|
||||
node -v
|
||||
```
|
||||
|
||||
Note that `nvm` is only installed for the user `devcontainer` and won't work out of the box for
|
||||
any other user.
|
||||
|
||||
## Debugging
|
||||
|
||||
The Apache webserver is already configured to automatically try to connect to a debugger process
|
||||
listening on port `9003`. To start the VSCode debugger process, use the delivered debug profile `Listen for XDebug`.
|
||||
After you started the VSCode debugger, just navigate to the appropriate Nextcloud URL to get your
|
||||
debug hits.
|
||||
@@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
$codespaceName = getenv('CODESPACE_NAME');
|
||||
$codespaceDomain = getenv('GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN');
|
||||
|
||||
$CONFIG = [
|
||||
'mail_from_address' => 'no-reply',
|
||||
'mail_smtpmode' => 'smtp',
|
||||
'mail_sendmailmode' => 'smtp',
|
||||
'mail_domain' => 'example.com',
|
||||
'mail_smtphost' => 'localhost',
|
||||
'mail_smtpport' => '1025',
|
||||
'memcache.local' => '\OC\Memcache\APCu',
|
||||
];
|
||||
|
||||
if(is_string($codespaceName) && !empty($codespaceName) && is_string($codespaceDomain) && !empty($codespaceDomain)) {
|
||||
$host = $codespaceName . '-80.' . $codespaceDomain;
|
||||
$CONFIG['overwritehost'] = $host;
|
||||
$CONFIG['overwrite.cli.url'] = 'https://' . $host;
|
||||
$CONFIG['overwriteprotocol'] = 'https';
|
||||
$CONFIG['trusted_domains'] = [ $host ];
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
{
|
||||
"name": "NextcloudServer",
|
||||
"dockerComposeFile": "docker-compose.yml",
|
||||
"service": "nextclouddev",
|
||||
"postCreateCommand": ".devcontainer/setup.sh",
|
||||
"forwardPorts": [
|
||||
80,
|
||||
8080,
|
||||
8025
|
||||
],
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"felixfbecker.php-debug",
|
||||
"felixfbecker.php-intellisense",
|
||||
"ms-azuretools.vscode-docker",
|
||||
"xdebug.php-debug",
|
||||
"donjayamanne.githistory"
|
||||
],
|
||||
"settings": {
|
||||
"php.suggest.basic": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"workspaceFolder": "/var/www/html",
|
||||
"remoteUser": "devcontainer"
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
version: '3'
|
||||
services:
|
||||
nextclouddev:
|
||||
build: .
|
||||
volumes:
|
||||
- .:/workspace:cached
|
||||
- /var/run/docker.sock:/var/run/docker-host.sock
|
||||
- ..:/var/www/html
|
||||
command: /var/www/html/.devcontainer/entrypoint.sh
|
||||
ports:
|
||||
- 80:80
|
||||
- 8080:8080
|
||||
- 8025:8025
|
||||
|
||||
db:
|
||||
image: postgres
|
||||
restart: always
|
||||
environment:
|
||||
POSTGRES_PASSWORD: postgres
|
||||
PGDATA: /data/postgres
|
||||
volumes:
|
||||
- db:/data/postgres
|
||||
network_mode: service:nextclouddev
|
||||
|
||||
adminer:
|
||||
image: adminer
|
||||
restart: always
|
||||
network_mode: service:nextclouddev
|
||||
|
||||
mailhog:
|
||||
image: mailhog/mailhog
|
||||
restart: always
|
||||
network_mode: service:nextclouddev
|
||||
|
||||
volumes:
|
||||
db:
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
sudo service apache2 start
|
||||
|
||||
while sleep 1000; do :; done
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Listen for Xdebug",
|
||||
"type": "php",
|
||||
"request": "launch",
|
||||
"port": 9003
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/bin/bash
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
cd $DIR/
|
||||
|
||||
# Set git safe.directory
|
||||
git config --global --add safe.directory /var/www/html
|
||||
git config --global --add safe.directory /var/www/html/3rdparty
|
||||
|
||||
git submodule update --init
|
||||
|
||||
# Codespace config
|
||||
cp .devcontainer/codespace.config.php config/codespace.config.php
|
||||
|
||||
# VSCode debugger profile
|
||||
mkdir -p .vscode && cp .devcontainer/launch.json .vscode/launch.json
|
||||
|
||||
# Onetime installation setup
|
||||
if [[ ! $(sudo -u ${APACHE_RUN_USER} php occ status) =~ installed:[[:space:]]*true ]]; then
|
||||
echo "Running NC installation"
|
||||
sudo -u ${APACHE_RUN_USER} php occ maintenance:install \
|
||||
--verbose \
|
||||
--database=pgsql \
|
||||
--database-name=postgres \
|
||||
--database-host=127.0.0.1 \
|
||||
--database-port=5432 \
|
||||
--database-user=postgres \
|
||||
--database-pass=postgres \
|
||||
--admin-user admin \
|
||||
--admin-pass admin
|
||||
fi
|
||||
|
||||
sudo service apache2 restart
|
||||
-1941
File diff suppressed because it is too large
Load Diff
@@ -1,29 +0,0 @@
|
||||
# https://editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = tab
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.feature]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
|
||||
[*.yml]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
|
||||
[*.md]
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.svg]
|
||||
insert_final_newline = false
|
||||
|
||||
[build/psalm-baseline.xml]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
@@ -1,12 +0,0 @@
|
||||
# Ignoring folders for eslint
|
||||
node_modules/
|
||||
3rdparty/
|
||||
**/vendor/
|
||||
**/l10n/
|
||||
**/js/*
|
||||
*.config.js
|
||||
tests/lib/
|
||||
apps-extra
|
||||
|
||||
# TODO: remove when comments files is not using handlebar templates anymore
|
||||
apps/comments/src/templates.js
|
||||
@@ -1,38 +0,0 @@
|
||||
module.exports = {
|
||||
globals: {
|
||||
__webpack_nonce__: true,
|
||||
_: true,
|
||||
$: true,
|
||||
moment: true,
|
||||
escapeHTML: true,
|
||||
oc_userconfig: true,
|
||||
dayNames: true,
|
||||
firstDay: true,
|
||||
'cypress/globals': true,
|
||||
},
|
||||
parserOptions: {
|
||||
parser: '@typescript-eslint/parser',
|
||||
},
|
||||
plugins: [
|
||||
'cypress',
|
||||
],
|
||||
extends: [
|
||||
'@nextcloud',
|
||||
'plugin:cypress/recommended',
|
||||
],
|
||||
rules: {
|
||||
'no-tabs': 'warn',
|
||||
// TODO: make sure we fix this as this is bad vue coding style.
|
||||
// Use proper sync modifier
|
||||
'vue/no-mutating-props': 'warn',
|
||||
'vue/custom-event-name-casing': ['error', 'kebab-case', {
|
||||
// allows custom xxxx:xxx events formats
|
||||
ignores: ['/^[a-z]+(?:-[a-z]+)*:[a-z]+(?:-[a-z]+)*$/u'],
|
||||
}],
|
||||
},
|
||||
settings: {
|
||||
jsdoc: {
|
||||
mode: 'typescript',
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
/dist/* binary
|
||||
/package-lock.json merge=binary
|
||||
/core/css/*.css* binary
|
||||
/.devcontainer/*.sh text eol=lf
|
||||
@@ -1,43 +0,0 @@
|
||||
# App maintainers
|
||||
/apps/admin_audit/appinfo/info.xml @luka-nextcloud @blizzz
|
||||
/apps/cloud_federation_api/appinfo/info.xml @mejo-
|
||||
/apps/comments/appinfo/info.xml @marcelklehr @Pytal
|
||||
/apps/contactsinteraction/appinfo/info.xml @kesselb @miaulalala @ChristophWurst @GretaD @hamza221 @st3iny
|
||||
/apps/dashboard/appinfo/info.xml @julien-nc @juliushaertl
|
||||
/apps/dav/lib/CalDAV @ChristophWurst @miaulalala @tcitworld
|
||||
/apps/dav/lib/CardDAV @ChristophWurst @miaulalala @tcitworld
|
||||
/apps/encryption/appinfo/info.xml @come-nc @icewind1991
|
||||
/apps/federatedfilesharing/appinfo/info.xml @icewind1991 @danxuliu
|
||||
/apps/federation/appinfo/info.xml @datenangebot
|
||||
/apps/files/appinfo/info.xml @skjnldsv @Pytal @ArtificialOwl @come-nc @artonge @icewind1991 @szaimen @susnux @Fenn-CS
|
||||
/apps/files_external/appinfo/info.xml @icewind1991 @artonge
|
||||
/apps/files_reminders/appinfo/info.xml @Pytal
|
||||
/apps/files_sharing/appinfo/info.xml @skjnldsv @come-nc
|
||||
/apps/files_trashbin/appinfo/info.xml @Pytal @icewind1991
|
||||
/apps/files_versions/appinfo/info.xml @artonge @icewind1991
|
||||
/apps/oauth2/appinfo/info.xml @julien-nc @ChristophWurst
|
||||
/apps/provisioning_api/appinfo/info.xml @provokateurin @nickvergessen
|
||||
/apps/settings/appinfo/info.xml @Pytal @JuliaKirschenheuter
|
||||
/apps/systemtags/appinfo/info.xml @Antreesy @marcelklehr
|
||||
/apps/theming/appinfo/info.xml @skjnldsv @juliushaertl
|
||||
/apps/twofactor_backupcodes/appinfo/info.xml @st3iny @miaulalala @ChristophWurst
|
||||
/apps/updatenotification/appinfo/info.xml @Pytal @JuliaKirschenheuter
|
||||
/apps/user_ldap/appinfo/info.xml @come-nc @blizzz
|
||||
/apps/user_status/appinfo/info.xml @Antreesy @nickvergessen
|
||||
/apps/weather_status/appinfo/info.xml @julien-nc @juliushaertl
|
||||
/apps/workflowengine/appinfo/info.xml @blizzz @juliushaertl
|
||||
|
||||
# Security team
|
||||
/resources/config/ca-bundle.crt @ChristophWurst @miaulalala @nickvergessen
|
||||
|
||||
# Two-Factor Authentication
|
||||
# https://github.com/nextcloud/wg-two-factor-authentication#members
|
||||
/apps/twofactor_backupcodes @ChristophWurst @miaulalala @nickvergessen
|
||||
*/TwoFactorAuth/* @ChristophWurst @miaulalala @nickvergessen
|
||||
/core/templates/twofactor* @ChristophWurst @miaulalala @nickvergessen
|
||||
|
||||
# Personal interest
|
||||
*/Activity/* @nickvergessen
|
||||
*/Notifications/* @nickvergessen
|
||||
/lib/private/Profiler @CarlSchwan
|
||||
/lib/public/Profiler @CarlSchwan
|
||||
@@ -1,68 +0,0 @@
|
||||
## Submitting issues
|
||||
|
||||
If you have questions about how to install or use Nextcloud, please direct these to our [forum][forum]. We are also available on [IRC][irc].
|
||||
|
||||
### Short version
|
||||
|
||||
* The [**issue templates can be found here**][templates] but be aware of the different repositories! See list below. Please always use an issue template when reporting issues.
|
||||
|
||||
### Guidelines
|
||||
* Please search the existing issues first, it's likely that your issue was already reported or even fixed.
|
||||
- Go to one of the repositories, click "issues" and type any word in the top search/command bar.
|
||||
- You can also filter by appending e. g. "state:open" to the search string.
|
||||
- More info on [search syntax within github](https://help.github.com/articles/searching-issues)
|
||||
* This repository ([server](https://github.com/nextcloud/server/issues)) is *only* for issues within the Nextcloud Server code. This also includes the apps: files, encryption, external storage, sharing, deleted files, versions, LDAP, and WebDAV Auth
|
||||
* __SECURITY__: Report any potential security bug to us via [our HackerOne page](https://hackerone.com/nextcloud) following our [security policy](https://nextcloud.com/security/) instead of filing an issue in our bug tracker.
|
||||
* The issues in other components should be reported in their respective repositories: You will find them in our [GitHub Organization](https://github.com/nextcloud/)
|
||||
|
||||
* Report the issue using one of our [templates][templates], they include all the information we need to track down the issue.
|
||||
|
||||
Help us to maximize the effort we can spend fixing issues and adding new features, by not reporting duplicate issues.
|
||||
|
||||
[templates]: ./ISSUE_TEMPLATE
|
||||
[forum]: https://help.nextcloud.com/
|
||||
[irc]: https://webchat.freenode.net/?channels=nextcloud
|
||||
|
||||
## Contributing to Source Code
|
||||
|
||||
Thanks for wanting to contribute source code to Nextcloud. That's great!
|
||||
|
||||
Please read the [Developer Manuals][devmanual] to learn how to create your first application or how to test the Nextcloud code with PHPUnit.
|
||||
|
||||
### Tests
|
||||
|
||||
In order to constantly increase the quality of our software we can no longer accept pull request which submit un-tested code.
|
||||
It is a must have that changed and added code segments are unit tested.
|
||||
In some areas unit testing is hard (aka almost impossible) as of today - in these areas refactoring WHILE fixing a bug is encouraged to enable unit testing.
|
||||
|
||||
### Sign your work
|
||||
|
||||
We use the Developer Certificate of Origin (DCO) as a additional safeguard
|
||||
for the Nextcloud project. This is a well established and widely used
|
||||
mechanism to assure contributors have confirmed their right to license
|
||||
their contribution under the project's license.
|
||||
Please read [contribute/developer-certificate-of-origin][dcofile].
|
||||
If you can certify it, then just add a line to every git commit message:
|
||||
|
||||
````
|
||||
Signed-off-by: Random J Developer <random@developer.example.org>
|
||||
````
|
||||
|
||||
Use your real name (sorry, no pseudonyms or anonymous contributions).
|
||||
If you set your `user.name` and `user.email` git configs, you can sign your
|
||||
commit automatically with `git commit -s`. You can also use git [aliases](https://git-scm.com/book/tr/v2/Git-Basics-Git-Aliases)
|
||||
like `git config --global alias.ci 'commit -s'`. Now you can commit with
|
||||
`git ci` and the commit will be signed.
|
||||
|
||||
### Apply a license
|
||||
|
||||
In case you are not sure how to add or update the license header correctly please have a look at [contribute/HowToApplyALicense.md][applyalicense]
|
||||
|
||||
[devmanual]: https://docs.nextcloud.com/server/latest/developer_manual/
|
||||
[dcofile]: https://github.com/nextcloud/server/blob/master/contribute/developer-certificate-of-origin
|
||||
[applyalicense]: https://github.com/nextcloud/server/blob/master/contribute/HowToApplyALicense.md
|
||||
|
||||
## Translations
|
||||
Please submit translations via [Transifex][transifex].
|
||||
|
||||
[transifex]: https://www.transifex.com/nextcloud
|
||||
@@ -1 +0,0 @@
|
||||
custom: https://nextcloud.com/include/
|
||||
@@ -1,222 +0,0 @@
|
||||
name: "Bug report: Nextcloud Server"
|
||||
description: "Submit a report and help us improve Nextcloud Server"
|
||||
title: "[Bug]: "
|
||||
labels: ["bug", "0. Needs triage"]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
### 👍 Thank you for contributing to our project!
|
||||
Please note this is a **free and open-source** project. Most people take on their own time to help you, so please, be patient.
|
||||
You can obtain [Enterprise support](https://nextcloud.com/support/) if you run Nextcloud Server in a mission critical environment.
|
||||
- type: checkboxes
|
||||
id: before-posting
|
||||
attributes:
|
||||
label: "⚠️ This issue respects the following points: ⚠️"
|
||||
description: All conditions are **required**. Your issue can be closed if these are checked incorrectly.
|
||||
options:
|
||||
- label: This is a **bug**, not a question or a configuration/webserver/proxy issue.
|
||||
required: true
|
||||
- label: This issue is **not** already reported on Github _(I've searched it)_.
|
||||
required: true
|
||||
- label: Nextcloud Server **is** up to date. See [Maintenance and Release Schedule](https://github.com/nextcloud/server/wiki/Maintenance-and-Release-Schedule) for supported versions.
|
||||
required: true
|
||||
- label: Nextcloud Server **is** running on 64bit capable CPU, PHP and OS.
|
||||
required: true
|
||||
- label: I agree to follow Nextcloud's [Code of Conduct](https://nextcloud.com/contribute/code-of-conduct/).
|
||||
required: true
|
||||
- type: textarea
|
||||
id: bug-description
|
||||
attributes:
|
||||
label: Bug description
|
||||
description: |
|
||||
Provide a description of the bug you're experiencing.
|
||||
Don't just expect someone will guess what your specific problem is and provide full details.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: reproduce
|
||||
attributes:
|
||||
label: Steps to reproduce
|
||||
description: |
|
||||
Describe the steps to reproduce the bug.
|
||||
The better your description is _(go 'here', click 'there'...)_ the fastest you'll get an _(accurate)_ answer.
|
||||
value: |
|
||||
1.
|
||||
2.
|
||||
3.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: expected-behavior
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
description: Describe what you expected to happen instead.
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: install-method
|
||||
attributes:
|
||||
label: Installation method
|
||||
description: |
|
||||
Select installation method you've used.
|
||||
_Describe the method in the "Additional info" section if you chose "Other"._
|
||||
options:
|
||||
- "Official All-in-One appliance"
|
||||
- "Community Web installer on a VPS or web space"
|
||||
- "Community Manual installation with Archive"
|
||||
- "Community Docker image"
|
||||
- "Community NextcloudPi appliance"
|
||||
- "Community SNAP package"
|
||||
- "Community VM appliance"
|
||||
- "Other Community project"
|
||||
- type: dropdown
|
||||
id: nextcloud-version
|
||||
attributes:
|
||||
label: Nextcloud Server version
|
||||
description: |
|
||||
Select Nextcloud Server version.
|
||||
_Versions not listed here are not maintained and not supported anymore_
|
||||
options:
|
||||
- "24"
|
||||
- "25"
|
||||
- "26"
|
||||
- "master"
|
||||
validations:
|
||||
required: true
|
||||
- type: dropdown
|
||||
id: system
|
||||
attributes:
|
||||
label: Operating system
|
||||
description: |
|
||||
Select operating system where Nextcloud Server is installed.
|
||||
_Describe in the "Additional info" section if you chose "Other"._
|
||||
options:
|
||||
- "Debian/Ubuntu"
|
||||
- "RHEL/CentOS"
|
||||
- "Other"
|
||||
- type: dropdown
|
||||
id: php
|
||||
attributes:
|
||||
label: PHP engine version
|
||||
description: |
|
||||
Select PHP engine version serving Nextcloud Server.
|
||||
_Describe in the "Additional info" section if you chose "Other"._
|
||||
options:
|
||||
- "PHP 7.3"
|
||||
- "PHP 7.4"
|
||||
- "PHP 8.0"
|
||||
- "PHP 8.1"
|
||||
- "Other"
|
||||
- type: dropdown
|
||||
id: webserver
|
||||
attributes:
|
||||
label: Web server
|
||||
description: |
|
||||
Select Webserver serving Nextcloud Server.
|
||||
_Describe in the "Additional info" section if you chose "Other"._
|
||||
options:
|
||||
- "Apache (supported)"
|
||||
- "Nginx"
|
||||
- "Lighttpd"
|
||||
- "Other"
|
||||
- type: dropdown
|
||||
id: database
|
||||
attributes:
|
||||
label: Database engine version
|
||||
description: |
|
||||
Select Database engine serving Nextcloud Server.
|
||||
_Describe in the "Additional info" section if you chose "Other"._
|
||||
options:
|
||||
- "MySQL"
|
||||
- "MariaDB"
|
||||
- "PostgreSQL"
|
||||
- "SQlite"
|
||||
- "Oracle"
|
||||
- "Other"
|
||||
- type: dropdown
|
||||
id: fresh
|
||||
attributes:
|
||||
label: Is this bug present after an update or on a fresh install?
|
||||
description: |
|
||||
Select if bug is present after an update or on a fresh install.
|
||||
options:
|
||||
- "Updated from a minor version (ex. 22.2.3 to 22.2.4)"
|
||||
- "Updated to a major version (ex. 22.2.3 to 23.0.1)"
|
||||
- "Fresh Nextcloud Server install"
|
||||
- type: dropdown
|
||||
id: encryption
|
||||
attributes:
|
||||
label: Are you using the Nextcloud Server Encryption module?
|
||||
description: Select if encryption is Enabled on your Nextcloud Server.
|
||||
options:
|
||||
- "Encryption is Enabled"
|
||||
- "Encryption is Disabled"
|
||||
- type: checkboxes
|
||||
id: users
|
||||
attributes:
|
||||
label: What user-backends are you using?
|
||||
description: |
|
||||
Select **all** user-backends Enabled on your Nextcloud Server.
|
||||
_Describe in the "Additional info" section if you chose "Other"._
|
||||
options:
|
||||
- label: "Default user-backend _(database)_"
|
||||
- label: "LDAP/ Active Directory"
|
||||
- label: "SSO - SAML"
|
||||
- label: "Other"
|
||||
- type: textarea
|
||||
id: configs
|
||||
attributes:
|
||||
label: Configuration report
|
||||
description: |
|
||||
Provide information about your configuration.
|
||||
To get this information, execute one of the following commands on the CLI:
|
||||
```shell
|
||||
sudo -u www-data php occ config:list system
|
||||
php occ config:list system
|
||||
./occ config:list system
|
||||
```
|
||||
> NOTE: This will be automatically formatted into code for better readability.
|
||||
render: shell
|
||||
- type: textarea
|
||||
id: apps
|
||||
attributes:
|
||||
label: List of activated Apps
|
||||
description: |
|
||||
Provide information about your apps.
|
||||
To get this information, execute one of the following commands on the CLI:
|
||||
```shell
|
||||
sudo -u www-data php occ app:list
|
||||
php occ app:list
|
||||
./occ app:list
|
||||
```
|
||||
> NOTE: This will be automatically formatted into code for better readability.
|
||||
render: shell
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: nextcloud-signingstatus
|
||||
attributes:
|
||||
label: Nextcloud Signing status
|
||||
description: |
|
||||
Provide Nextcloud Signing status.
|
||||
First, login as Admin user into your Nextcloud, then access this URL:
|
||||
```shell
|
||||
https://yournextcloud.tld/index.php/settings/integrity/failed
|
||||
```
|
||||
> NOTE: This will be automatically formatted into code for better readability.
|
||||
render: shell
|
||||
- type: textarea
|
||||
id: nextcloud-log
|
||||
attributes:
|
||||
label: Nextcloud Logs
|
||||
description: |
|
||||
Provide Nextcloud logs lines.
|
||||
Copy all contents from `data/nextcloud.log` or a RAW from `/settings/admin/logging` section:
|
||||
> NOTE: This will be automatically formatted into code for better readability.
|
||||
render: shell
|
||||
- type: textarea
|
||||
id: additional-info
|
||||
attributes:
|
||||
label: Additional info
|
||||
description: Any additional information related to the issue (ex. browser console errors, software versions).
|
||||
@@ -1,48 +0,0 @@
|
||||
---
|
||||
name: 🚀 Feature request
|
||||
about: Suggest an idea for this project
|
||||
labels: enhancement, 0. Needs triage
|
||||
---
|
||||
|
||||
<!--
|
||||
Thanks for reporting issues back to Nextcloud!
|
||||
|
||||
Note: This is the **issue tracker of Nextcloud**, please do NOT use this to get answers to your questions or get help for fixing your installation. This is a place to report bugs to developers, after your server has been debugged. You can find help debugging your system on our home user forums: https://help.nextcloud.com or, if you use Nextcloud in a large organization, ask our engineers on https://portal.nextcloud.com. See also https://nextcloud.com/support for support options.
|
||||
|
||||
Nextcloud is an open source project backed by Nextcloud GmbH. Most of our volunteers are home users and thus primarily care about issues that affect home users. Our paid engineers prioritize issues of our customers. If you are neither a home user nor a customer, consider paying somebody to fix your issue, do it yourself or become a customer.
|
||||
|
||||
Guidelines for submitting issues:
|
||||
|
||||
* Please search the existing issues first, it's likely that your issue was already reported or even fixed.
|
||||
- Go to https://github.com/nextcloud and type any word in the top search/command bar. You probably see something like "We couldn’t find any repositories matching ..." then click "Issues" in the left navigation.
|
||||
- You can also filter by appending e. g. "state:open" to the search string.
|
||||
- More info on search syntax within github: https://help.github.com/articles/searching-issues
|
||||
|
||||
* This repository https://github.com/nextcloud/server/issues is *only* for issues within the Nextcloud Server code. This also includes the apps: files, encryption, external storage, sharing, deleted files, versions, LDAP, and WebDAV Auth
|
||||
|
||||
* SECURITY: Report any potential security bug to us via our HackerOne page (https://hackerone.com/nextcloud) following our security policy (https://nextcloud.com/security/) instead of filing an issue in our bug tracker.
|
||||
|
||||
* The issues in other components should be reported in their respective repositories: You will find them in our GitHub Organization (https://github.com/nextcloud/)
|
||||
-->
|
||||
|
||||
|
||||
<!--- Please keep this note for other contributors -->
|
||||
|
||||
### How to use GitHub
|
||||
|
||||
* Please use the 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to show that you are interested into the same feature.
|
||||
* Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
|
||||
* Subscribe to receive notifications on status change and new comments.
|
||||
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -1,8 +0,0 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: ❓ Community Support and Help
|
||||
url: https://help.nextcloud.com/
|
||||
about: Configuration, webserver/proxy or performance issues and other questions
|
||||
- name: 💼 Nextcloud Enterprise
|
||||
url: https://portal.nextcloud.com/
|
||||
about: If you are a Nextcloud Enterprise customer, or need Professional support, so it can be resolved directly by our dedicated engineers more quickly
|
||||
@@ -1,3 +0,0 @@
|
||||
firstPRMergeComment: >
|
||||
Thanks for your first pull request and welcome to the community!
|
||||
Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22
|
||||
@@ -1,149 +0,0 @@
|
||||
version: 2
|
||||
updates:
|
||||
# Linting and coding style
|
||||
- package-ecosystem: composer
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: saturday
|
||||
time: "03:00"
|
||||
timezone: Europe/Paris
|
||||
labels:
|
||||
- "3. to review"
|
||||
- "feature: dependencies"
|
||||
reviewers:
|
||||
- "nextcloud/server-dependabot"
|
||||
|
||||
# Main master npm
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: saturday
|
||||
time: "03:00"
|
||||
timezone: Europe/Paris
|
||||
open-pull-requests-limit: 10
|
||||
labels:
|
||||
- "3. to review"
|
||||
- "feature: dependencies"
|
||||
reviewers:
|
||||
- "nextcloud/server-dependabot"
|
||||
# Disable automatic rebasing because without a build CI will likely fail anyway
|
||||
rebase-strategy: "disabled"
|
||||
|
||||
# Testing master npm
|
||||
- package-ecosystem: npm
|
||||
directory: "/build"
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: saturday
|
||||
time: "03:00"
|
||||
timezone: Europe/Paris
|
||||
labels:
|
||||
- "3. to review"
|
||||
- "feature: dependencies"
|
||||
|
||||
# Testing master composer
|
||||
- package-ecosystem: composer
|
||||
directory: "/build/integration"
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: saturday
|
||||
time: "03:00"
|
||||
timezone: Europe/Paris
|
||||
labels:
|
||||
- "3. to review"
|
||||
- "feature: dependencies"
|
||||
|
||||
|
||||
# Main stableXX npm
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: saturday
|
||||
time: "03:00"
|
||||
timezone: Europe/Paris
|
||||
target-branch: stable24
|
||||
labels:
|
||||
- "3. to review"
|
||||
- "feature: dependencies"
|
||||
reviewers:
|
||||
- "nextcloud/server-dependabot"
|
||||
ignore:
|
||||
# ignore all GitHub linguist patch updates
|
||||
- dependency-name: "*"
|
||||
update-types: ["version-update:semver-major", "version-update:semver-minor", "version-update:semver-patch"]
|
||||
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: saturday
|
||||
time: "03:00"
|
||||
timezone: Europe/Paris
|
||||
target-branch: stable25
|
||||
labels:
|
||||
- "3. to review"
|
||||
- "feature: dependencies"
|
||||
reviewers:
|
||||
- "nextcloud/server-dependabot"
|
||||
ignore:
|
||||
# ignore all GitHub linguist patch updates
|
||||
- dependency-name: "*"
|
||||
update-types: ["version-update:semver-major", "version-update:semver-minor", "version-update:semver-patch"]
|
||||
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: saturday
|
||||
time: "03:00"
|
||||
timezone: Europe/Paris
|
||||
target-branch: stable26
|
||||
labels:
|
||||
- "3. to review"
|
||||
- "feature: dependencies"
|
||||
reviewers:
|
||||
- "nextcloud/server-dependabot"
|
||||
ignore:
|
||||
# ignore all GitHub linguist patch updates
|
||||
- dependency-name: "*"
|
||||
update-types: ["version-update:semver-major", "version-update:semver-minor", "version-update:semver-patch"]
|
||||
|
||||
# Testing StableXX composer
|
||||
- package-ecosystem: composer
|
||||
directory: "/build/integration"
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: saturday
|
||||
time: "03:00"
|
||||
timezone: Europe/Paris
|
||||
target-branch: stable24
|
||||
labels:
|
||||
- "3. to review"
|
||||
- "feature: dependencies"
|
||||
reviewers:
|
||||
- "nextcloud/server-dependabot"
|
||||
ignore:
|
||||
# ignore all GitHub linguist patch updates
|
||||
- dependency-name: "*"
|
||||
update-types: ["version-update:semver-major", "version-update:semver-minor", "version-update:semver-patch"]
|
||||
|
||||
- package-ecosystem: composer
|
||||
directory: "/build/integration"
|
||||
schedule:
|
||||
interval: weekly
|
||||
day: saturday
|
||||
time: "03:00"
|
||||
timezone: Europe/Paris
|
||||
target-branch: stable25
|
||||
labels:
|
||||
- "3. to review"
|
||||
- "feature: dependencies"
|
||||
reviewers:
|
||||
- "nextcloud/server-dependabot"
|
||||
ignore:
|
||||
# ignore all GitHub linguist patch updates
|
||||
- dependency-name: "*"
|
||||
update-types: ["version-update:semver-major", "version-update:semver-minor", "version-update:semver-patch"]
|
||||
@@ -1,18 +0,0 @@
|
||||
|
||||
* Resolves: # <!-- related github issue -->
|
||||
|
||||
## Summary
|
||||
|
||||
|
||||
## TODO
|
||||
|
||||
- [ ] ...
|
||||
|
||||
## Checklist
|
||||
|
||||
- Code is [properly formatted](https://docs.nextcloud.com/server/latest/developer_manual/digging_deeper/continuous_integration.html#linting)
|
||||
- [Sign-off message](https://github.com/src-d/guide/blob/master/developer-community/fix-DCO.md) is added to all commits
|
||||
- [ ] Tests ([unit](https://docs.nextcloud.com/server/latest/developer_manual/app_development/tutorial.html#unit-tests), [integration](https://docs.nextcloud.com/server/latest/developer_manual/app_development/tutorial.html#integration-tests), api and/or acceptance) are included
|
||||
- [ ] Screenshots before/after for front-end changes
|
||||
- [ ] Documentation ([manuals](https://github.com/nextcloud/documentation/) or wiki) has been updated or is not required
|
||||
- [ ] [Backports requested](https://github.com/nextcloud/backportbot/#usage) where applicable (ex: critical bugfixes)
|
||||
@@ -1,40 +0,0 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
#
|
||||
# SPDX-FileCopyrightText: 2022-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
name: Block merges for EOL
|
||||
|
||||
on: pull_request
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: block-merge-eol-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
block-merges-eol:
|
||||
name: Block merges for EOL branches
|
||||
|
||||
# Only run on stableXX branches
|
||||
if: startsWith( github.base_ref, 'stable')
|
||||
runs-on: ubuntu-latest-low
|
||||
|
||||
steps:
|
||||
- name: Set server major version environment
|
||||
run: |
|
||||
# retrieve version number from branch reference
|
||||
server_major=$(echo "${{ github.base_ref }}" | sed -En 's/stable//p')
|
||||
echo "server_major=$server_major" >> $GITHUB_ENV
|
||||
echo "current_month=$(date +%Y-%m)" >> $GITHUB_ENV
|
||||
|
||||
- name: Checking if ${{ env.server_major }} is EOL
|
||||
run: |
|
||||
curl -s https://raw.githubusercontent.com/nextcloud-releases/updater_server/production/config/major_versions.json \
|
||||
| jq '.["${{ env.server_major }}"]["eol"] // "9999-99" | . >= "${{ env.current_month }}"' \
|
||||
| grep -q true
|
||||
@@ -1,32 +0,0 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
|
||||
name: Block merges during freezes
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, ready_for_review, reopened, synchronize]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: block-merge-freeze-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
block-merges-during-freeze:
|
||||
name: Block merges during freezes
|
||||
|
||||
if: github.event.pull_request.draft == false
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Download version.php from ${{ github.base_ref }}
|
||||
run: curl https://raw.githubusercontent.com/nextcloud/server/${{ github.base_ref }}/version.php --output version.php
|
||||
|
||||
- name: Run check
|
||||
run: cat version.php | grep 'OC_VersionString' | grep -i -v 'RC'
|
||||
@@ -1,53 +0,0 @@
|
||||
name: Block merging with outdated 3rdparty/
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, ready_for_review, reopened, synchronize]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: block-outdated-3rdparty-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
block-outdated-3rdparty:
|
||||
name: Block merging with outdated 3rdparty/
|
||||
|
||||
runs-on: ubuntu-latest-low
|
||||
|
||||
steps:
|
||||
- name: Check requirement
|
||||
uses: dorny/paths-filter@4512585405083f25c027a35db413c2b3b9006d50 # v2.11.1
|
||||
id: changes
|
||||
continue-on-error: true
|
||||
with:
|
||||
filters: |
|
||||
src:
|
||||
- '3rdparty'
|
||||
- 'version.php'
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
|
||||
|
||||
- name: 3rdparty commit hash on current branch
|
||||
id: actual
|
||||
run: |
|
||||
echo "commit=$(git submodule status | grep ' 3rdparty' | egrep -o '[a-f0-9]{40}')" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Last 3rdparty commit on target branch
|
||||
id: target
|
||||
run: |
|
||||
echo "commit=$(git ls-remote https://github.com/nextcloud/3rdparty ${{ github.base_ref }} | awk '{ print $1}')" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Compare if 3rdparty commits are different
|
||||
run: |
|
||||
echo '3rdparty/ seems to not point to the last commit of the dedicated branch:'
|
||||
echo "Branch has: ${{ steps.actual.outputs.commit }}"
|
||||
echo "${{ github.base_ref }} has: ${{ steps.target.outputs.commit }}"
|
||||
|
||||
- name: Fail if 3rdparty commits are different
|
||||
if: ${{ steps.changes.outputs.src != 'false' && steps.actual.outputs.commit != steps.target.outputs.commit }}
|
||||
run: |
|
||||
exit 1
|
||||
@@ -1,117 +0,0 @@
|
||||
name: Compile Command
|
||||
on:
|
||||
issue_comment:
|
||||
types: [created]
|
||||
|
||||
jobs:
|
||||
init:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# On pull requests and if the comment starts with `/compile`
|
||||
if: github.event.issue.pull_request != '' && startsWith(github.event.comment.body, '/compile')
|
||||
|
||||
outputs:
|
||||
git_path: ${{ steps.git-path.outputs.path }}
|
||||
arg1: ${{ steps.command.outputs.arg1 }}
|
||||
arg2: ${{ steps.command.outputs.arg2 }}
|
||||
head_ref: ${{ steps.comment-branch.outputs.head_ref }}
|
||||
|
||||
steps:
|
||||
- name: Check actor permission
|
||||
uses: skjnldsv/check-actor-permission@e591dbfe838300c007028e1219ca82cc26e8d7c5 # v2
|
||||
with:
|
||||
require: write
|
||||
|
||||
- name: Add reaction on start
|
||||
uses: peter-evans/create-or-update-comment@ca08ebd5dc95aa0cd97021e9708fcd6b87138c9b # v3.0.1
|
||||
with:
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
repository: ${{ github.event.repository.full_name }}
|
||||
comment-id: ${{ github.event.comment.id }}
|
||||
reactions: "+1"
|
||||
|
||||
- name: Parse command
|
||||
uses: skjnldsv/parse-command-comment@7cef1df370a99dfd5bf896d50121390c96785db8 # v2
|
||||
id: command
|
||||
|
||||
# Init path depending on which command is run
|
||||
- name: Init path
|
||||
id: git-path
|
||||
run: |
|
||||
if ${{ startsWith(steps.command.outputs.arg1, '/') }}; then
|
||||
echo "path=${{ github.workspace }}${{steps.command.outputs.arg1}}" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "path=${{ github.workspace }}${{steps.command.outputs.arg2}}" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
- name: Init branch
|
||||
uses: xt0rted/pull-request-comment-branch@d97294d304604fa98a2600a6e2f916a84b596dc7 # v1
|
||||
id: comment-branch
|
||||
|
||||
process:
|
||||
runs-on: ubuntu-latest
|
||||
needs: init
|
||||
|
||||
steps:
|
||||
- name: Checkout ${{ needs.init.outputs.head_ref }}
|
||||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
|
||||
with:
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
fetch-depth: 0
|
||||
ref: ${{ needs.init.outputs.head_ref }}
|
||||
|
||||
- name: Setup git
|
||||
run: |
|
||||
git config --local user.email "nextcloud-command@users.noreply.github.com"
|
||||
git config --local user.name "nextcloud-command"
|
||||
|
||||
- name: Read package.json node and npm engines version
|
||||
uses: skjnldsv/read-package-engines-version-actions@0ce2ed60f6df073a62a77c0a4958dd0fc68e32e7 # v2.1
|
||||
id: package-engines-versions
|
||||
with:
|
||||
fallbackNode: '^16'
|
||||
fallbackNpm: '^7'
|
||||
|
||||
- name: Set up node ${{ steps.package-engines-versions.outputs.nodeVersion }}
|
||||
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
|
||||
with:
|
||||
node-version: ${{ steps.package-engines-versions.outputs.nodeVersion }}
|
||||
cache: npm
|
||||
|
||||
- name: Set up npm ${{ steps.package-engines-versions.outputs.npmVersion }}
|
||||
run: npm i -g npm@"${{ steps.package-engines-versions.outputs.npmVersion }}"
|
||||
|
||||
- name: Install dependencies & build
|
||||
run: |
|
||||
npm ci
|
||||
npm run build --if-present
|
||||
|
||||
- name: Commit and push default
|
||||
if: ${{ needs.init.outputs.arg1 != 'fixup' && needs.init.outputs.arg1 != 'amend' }}
|
||||
run: |
|
||||
git add ${{ needs.init.outputs.git_path }}
|
||||
git commit --signoff -m 'chore(assets): Recompile assets'
|
||||
git push origin ${{ needs.init.outputs.head_ref }}
|
||||
|
||||
- name: Commit and push fixup
|
||||
if: ${{ needs.init.outputs.arg1 == 'fixup' }}
|
||||
run: |
|
||||
git add ${{ needs.init.outputs.git_path }}
|
||||
git commit --fixup=HEAD --signoff
|
||||
git push origin ${{ needs.init.outputs.head_ref }}
|
||||
|
||||
- name: Commit and push amend
|
||||
if: ${{ needs.init.outputs.arg1 == 'amend' }}
|
||||
run: |
|
||||
git add ${{ needs.init.outputs.git_path }}
|
||||
git commit --amend --no-edit --signoff
|
||||
git push --force origin ${{ needs.init.outputs.head_ref }}
|
||||
|
||||
- name: Add reaction on failure
|
||||
uses: peter-evans/create-or-update-comment@ca08ebd5dc95aa0cd97021e9708fcd6b87138c9b # v3.0.1
|
||||
if: failure()
|
||||
with:
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
repository: ${{ github.event.repository.full_name }}
|
||||
comment-id: ${{ github.event.comment.id }}
|
||||
reactions: "-1"
|
||||
@@ -1,55 +0,0 @@
|
||||
name: Update 3rdparty command
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: created
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
rebase:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: none
|
||||
|
||||
# On pull requests and if the comment starts with `/update-3rdparty`
|
||||
if: github.event.issue.pull_request != '' && startsWith(github.event.comment.body, '/update-3rdparty')
|
||||
|
||||
steps:
|
||||
- name: Add reaction on start
|
||||
uses: peter-evans/create-or-update-comment@v2
|
||||
with:
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
repository: ${{ github.event.repository.full_name }}
|
||||
comment-id: ${{ github.event.comment.id }}
|
||||
reaction-type: "+1"
|
||||
|
||||
- name: Checkout the latest code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
|
||||
- name: Setup git
|
||||
run: |
|
||||
git config --local user.email "nextcloud-command@users.noreply.github.com"
|
||||
git config --local user.name "nextcloud-command"
|
||||
|
||||
- name: Pull 3rdparty
|
||||
run: git submodule foreach 'if [ "$sm_path" == "3rdparty" ]; then git pull origin ${{ github.event.issue.pull_request.base.ref }}; fi'
|
||||
|
||||
- name: Commit and push changes
|
||||
run: |
|
||||
git add 3rdparty
|
||||
git commit -s -m "Update submodule 3rdparty to latest ${{ github.event.issue.pull_request.base.ref }}"
|
||||
git push
|
||||
|
||||
- name: Add reaction on failure
|
||||
uses: peter-evans/create-or-update-comment@v2
|
||||
if: failure()
|
||||
with:
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
repository: ${{ github.event.repository.full_name }}
|
||||
comment-id: ${{ github.event.comment.id }}
|
||||
reaction-type: "-1"
|
||||
@@ -1,51 +0,0 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
|
||||
name: Rebase command
|
||||
|
||||
on:
|
||||
issue_comment:
|
||||
types: created
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
rebase:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: none
|
||||
|
||||
# On pull requests and if the comment starts with `/rebase`
|
||||
if: github.event.issue.pull_request != '' && startsWith(github.event.comment.body, '/rebase')
|
||||
|
||||
steps:
|
||||
- name: Add reaction on start
|
||||
uses: peter-evans/create-or-update-comment@ca08ebd5dc95aa0cd97021e9708fcd6b87138c9b # v3.0.1
|
||||
with:
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
repository: ${{ github.event.repository.full_name }}
|
||||
comment-id: ${{ github.event.comment.id }}
|
||||
reaction-type: "+1"
|
||||
|
||||
- name: Checkout the latest code
|
||||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
|
||||
- name: Automatic Rebase
|
||||
uses: cirrus-actions/rebase@b87d48154a87a85666003575337e27b8cd65f691 # 1.8
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
|
||||
- name: Add reaction on failure
|
||||
uses: peter-evans/create-or-update-comment@ca08ebd5dc95aa0cd97021e9708fcd6b87138c9b # v3.0.1
|
||||
if: failure()
|
||||
with:
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
repository: ${{ github.event.repository.full_name }}
|
||||
comment-id: ${{ github.event.comment.id }}
|
||||
reaction-type: "-1"
|
||||
@@ -1,153 +0,0 @@
|
||||
name: Cypress
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
- stable*
|
||||
|
||||
env:
|
||||
# Adjust APP_NAME if your repository name is different
|
||||
APP_NAME: ${{ github.event.repository.name }}
|
||||
# Server requires head_ref instead of base_ref, as we want to test the PR branch
|
||||
BRANCH: ${{ github.head_ref || github.ref_name }}
|
||||
|
||||
jobs:
|
||||
init:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
nodeVersion: ${{ steps.versions.outputs.nodeVersion }}
|
||||
npmVersion: ${{ steps.versions.outputs.npmVersion }}
|
||||
|
||||
steps:
|
||||
- name: Checkout app
|
||||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
|
||||
|
||||
- name: Check composer.json
|
||||
id: check_composer
|
||||
uses: andstor/file-existence-action@20b4d2e596410855db8f9ca21e96fbe18e12930b # v2
|
||||
with:
|
||||
files: "composer.json"
|
||||
|
||||
- name: Install composer dependencies
|
||||
if: steps.check_composer.outputs.files_exists == 'true'
|
||||
run: composer install --no-dev
|
||||
|
||||
- name: Read package.json node and npm engines version
|
||||
uses: skjnldsv/read-package-engines-version-actions@0ce2ed60f6df073a62a77c0a4958dd0fc68e32e7 # v2.1
|
||||
id: versions
|
||||
with:
|
||||
fallbackNode: "^14"
|
||||
fallbackNpm: "^7"
|
||||
|
||||
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
|
||||
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
|
||||
with:
|
||||
node-version: ${{ steps.versions.outputs.nodeVersion }}
|
||||
|
||||
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
|
||||
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
|
||||
|
||||
- name: Install node dependencies & build app
|
||||
run: |
|
||||
npm ci
|
||||
TESTING=true npm run build --if-present
|
||||
|
||||
- name: Save context
|
||||
uses: buildjet/cache/save@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
|
||||
with:
|
||||
key: cypress-context-${{ github.run_id }}
|
||||
path: ./
|
||||
|
||||
cypress:
|
||||
runs-on: ubuntu-latest
|
||||
needs: init
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# Run multiple copies of the current job in parallel
|
||||
# Please increase the number or runners as your tests suite grows
|
||||
containers: ["component", 1, 2]
|
||||
|
||||
name: runner ${{ matrix.containers }}
|
||||
|
||||
steps:
|
||||
- name: Restore context
|
||||
uses: buildjet/cache/restore@e376f15c6ec6dc595375c78633174c7e5f92dc0e # v3
|
||||
with:
|
||||
fail-on-cache-miss: true
|
||||
key: cypress-context-${{ github.run_id }}
|
||||
path: ./
|
||||
|
||||
- name: Set up node ${{ needs.init.outputs.nodeVersion }}
|
||||
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
|
||||
with:
|
||||
node-version: ${{ needs.init.outputs.nodeVersion }}
|
||||
|
||||
- name: Set up npm ${{ needs.init.outputs.npmVersion }}
|
||||
run: npm i -g npm@"${{ needs.init.outputs.npmVersion }}"
|
||||
|
||||
- name: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }} cypress tests
|
||||
uses: cypress-io/github-action@db1693016f23ccf9043f4b2428f9b04e5d502a73 # v5.8.1
|
||||
with:
|
||||
record: true
|
||||
parallel: true
|
||||
# cypress run type
|
||||
component: ${{ matrix.containers == 'component' }}
|
||||
group: Run ${{ matrix.containers == 'component' && 'component' || 'E2E' }}
|
||||
# cypress env
|
||||
ci-build-id: ${{ github.sha }}-${{ github.run_number }}
|
||||
tag: ${{ github.event_name }}
|
||||
env:
|
||||
# Needs to be prefixed with CYPRESS_
|
||||
CYPRESS_BRANCH: ${{ env.BRANCH }}
|
||||
# https://github.com/cypress-io/github-action/issues/124
|
||||
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }}
|
||||
# Needed for some specific code workarounds
|
||||
TESTING: true
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
||||
|
||||
- name: Upload snapshots
|
||||
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
|
||||
if: always()
|
||||
with:
|
||||
name: snapshots_${{ matrix.containers }}
|
||||
path: cypress/snapshots
|
||||
|
||||
- name: Extract NC logs
|
||||
if: failure() && matrix.containers != 'component'
|
||||
run: docker logs nextcloud-cypress-tests-${{ env.APP_NAME }} > nextcloud.log
|
||||
|
||||
- name: Upload NC logs
|
||||
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
|
||||
if: failure() && matrix.containers != 'component'
|
||||
with:
|
||||
name: nc_logs_${{ matrix.containers }}
|
||||
path: nextcloud.log
|
||||
|
||||
- name: Create data dir archive
|
||||
if: failure() && matrix.containers != 'component'
|
||||
run: docker exec nextcloud-cypress-tests-server tar -cvjf - data > data.tar
|
||||
|
||||
- name: Upload data dir archive
|
||||
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
|
||||
if: failure() && matrix.containers != 'component'
|
||||
with:
|
||||
name: nc_data_${{ matrix.containers }}
|
||||
path: data.tar
|
||||
|
||||
summary:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [init, cypress]
|
||||
|
||||
if: always()
|
||||
|
||||
name: cypress-summary
|
||||
|
||||
steps:
|
||||
- name: Summary status
|
||||
run: if ${{ needs.init.result != 'success' || ( needs.cypress.result != 'success' && needs.cypress.result != 'skipped' ) }}; then exit 1; fi
|
||||
@@ -1,40 +0,0 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
|
||||
name: Dependabot
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
- stable*
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: dependabot-approve-merge-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
auto-approve-merge:
|
||||
if: github.actor == 'dependabot[bot]'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
# for hmarr/auto-approve-action to approve PRs
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
# Github actions bot approve
|
||||
- uses: hmarr/auto-approve-action@b40d6c9ed2fa10c9a2749eca7eb004418a705501 # v2
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
# Nextcloud bot approve and merge request
|
||||
- uses: ahmadnassri/action-dependabot-auto-merge@45fc124d949b19b6b8bf6645b6c9d55f4f9ac61a # v2
|
||||
with:
|
||||
target: minor
|
||||
github-token: ${{ secrets.DEPENDABOT_AUTOMERGE_TOKEN }}
|
||||
@@ -1,33 +0,0 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
|
||||
name: Block fixup and squash commits
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types: [opened, ready_for_review, reopened, synchronize]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: fixup-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
commit-message-check:
|
||||
if: github.event.pull_request.draft == false
|
||||
|
||||
permissions:
|
||||
pull-requests: write
|
||||
name: Block fixup and squash commits
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Run check
|
||||
uses: skjnldsv/block-fixup-merge-action@42d26e1b536ce61e5cf467d65fb76caf4aa85acf # v1
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -1,87 +0,0 @@
|
||||
name: FTP unit tests
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- stable*
|
||||
paths:
|
||||
- '.github/**'
|
||||
- 'apps/files_external/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/**'
|
||||
- 'apps/files_external/**'
|
||||
|
||||
env:
|
||||
APP_NAME: files_external
|
||||
|
||||
jobs:
|
||||
ftp-tests:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: ${{ github.repository_owner != 'nextcloud-gmbh' }}
|
||||
|
||||
strategy:
|
||||
# do not stop on another job's failure
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php-versions: ['8.0']
|
||||
ftpd: ['proftpd', 'vsftpd', 'pure-ftpd']
|
||||
|
||||
name: php${{ matrix.php-versions }}-${{ matrix.ftpd }}
|
||||
|
||||
steps:
|
||||
- name: Checkout server
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Set up ftpd
|
||||
run: |
|
||||
sudo mkdir /tmp/ftp
|
||||
sudo chmod -R 0777 /tmp/ftp
|
||||
if [[ "${{ matrix.ftpd }}" == 'proftpd' ]]; then echo '$6$Q7V2n3q2GRVv5YeQ$/AhLu07H76Asojy7bxGXMY1caKLAbp5Vt82LOZYMkD/8uDzyMAEXwk0c1Bdz1DkBsk2Vh/9SF130mOPavRGMo.' > /tmp/secret.txt; fi
|
||||
if [[ "${{ matrix.ftpd }}" == 'proftpd' ]]; then echo 'FTP_ROOT=/home/test' > $GITHUB_ENV; fi
|
||||
if [[ "${{ matrix.ftpd }}" == 'proftpd' ]]; then docker run --name ftp -d --net host -e PASV_ADDRESS=127.0.0.1 -e FTPUSER_NAME=test -v /tmp/secret.txt:/run/secrets/ftp-user-password-secret -v /tmp/ftp:/home/test instantlinux/proftpd; fi
|
||||
if [[ "${{ matrix.ftpd }}" == 'vsftpd' ]]; then docker run --name ftp -d --net host -e FTP_USER=test -e FTP_PASS=test -e PASV_ADDRESS=127.0.0.1 -v /tmp/ftp:/home/vsftpd/test fauria/vsftpd; fi
|
||||
if [[ "${{ matrix.ftpd }}" == 'pure-ftpd' ]]; then docker run --name ftp -d --net host -e "PUBLICHOST=localhost" -e FTP_USER_NAME=test -e FTP_USER_PASS=test -e FTP_USER_HOME=/home/test -v /tmp/ftp:/home/test -v /tmp/ftp:/etc/pure-ftpd/passwd stilliard/pure-ftpd; fi
|
||||
- name: Set up php ${{ matrix.php-versions }}
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
tools: phpunit:9
|
||||
extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, zip, gd
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Nextcloud
|
||||
run: |
|
||||
mkdir data
|
||||
./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
|
||||
./occ app:enable --force ${{ env.APP_NAME }}
|
||||
php -S localhost:8080 &
|
||||
- name: smoketest ftp
|
||||
run: |
|
||||
php -r 'var_dump(file_put_contents("ftp://test:test@localhost${{ env.FTP_ROOT }}/ftp.txt", "asd"));'
|
||||
php -r 'var_dump(file_get_contents("ftp://test:test@localhost${{ env.FTP_ROOT }}/ftp.txt"));'
|
||||
php -r 'var_dump(mkdir("ftp://test:test@localhost${{ env.FTP_ROOT }}/asdads"));'
|
||||
ls -l /tmp/ftp
|
||||
[ -f /tmp/ftp/ftp.txt ]
|
||||
- name: PHPUnit
|
||||
run: |
|
||||
echo "<?php return ['run' => true,'host' => 'localhost','user' => 'test','password' => 'test', 'root' => '${{ env.FTP_ROOT }}'];" > apps/${{ env.APP_NAME }}/tests/config.ftp.php
|
||||
phpunit --configuration tests/phpunit-autotest-external.xml apps/files_external/tests/Storage/FtpTest.php
|
||||
- name: ftpd logs
|
||||
if: always()
|
||||
run: |
|
||||
docker logs ftp
|
||||
|
||||
ftp-summary:
|
||||
runs-on: ubuntu-latest
|
||||
needs: ftp-tests
|
||||
|
||||
if: always()
|
||||
|
||||
steps:
|
||||
- name: Summary status
|
||||
run: if ${{ needs.ftp-tests.result != 'success' }}; then exit 1; fi
|
||||
@@ -1,39 +0,0 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
#
|
||||
# Use lint-eslint together with lint-eslint-when-unrelated to make eslint a required check for GitHub actions
|
||||
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks
|
||||
|
||||
name: Lint eslint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '.github/workflows/**'
|
||||
- 'src/**'
|
||||
- 'apps/**/appinfo/info.xml'
|
||||
- 'package.json'
|
||||
- 'package-lock.json'
|
||||
- 'tsconfig.json'
|
||||
- '.eslintrc.*'
|
||||
- '.eslintignore'
|
||||
- '**.js'
|
||||
- '**.ts'
|
||||
- '**.vue'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
permissions:
|
||||
contents: none
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
name: eslint
|
||||
|
||||
steps:
|
||||
- run: 'echo "No eslint required"'
|
||||
@@ -1,62 +0,0 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
#
|
||||
# Use lint-eslint together with lint-eslint-when-unrelated to make eslint a required check for GitHub actions
|
||||
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks
|
||||
|
||||
name: Lint eslint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/**'
|
||||
- 'src/**'
|
||||
- 'apps/**/appinfo/info.xml'
|
||||
- 'package.json'
|
||||
- 'package-lock.json'
|
||||
- 'tsconfig.json'
|
||||
- '.eslintrc.*'
|
||||
- '.eslintignore'
|
||||
- '**.js'
|
||||
- '**.ts'
|
||||
- '**.vue'
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: lint-eslint-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
name: eslint
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
|
||||
|
||||
- name: Read package.json node and npm engines version
|
||||
uses: skjnldsv/read-package-engines-version-actions@0ce2ed60f6df073a62a77c0a4958dd0fc68e32e7 # v2.1
|
||||
id: versions
|
||||
with:
|
||||
fallbackNode: '^16'
|
||||
fallbackNpm: '^7'
|
||||
|
||||
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
|
||||
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
|
||||
with:
|
||||
node-version: ${{ steps.versions.outputs.nodeVersion }}
|
||||
|
||||
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
|
||||
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Lint
|
||||
run: npm run lint
|
||||
@@ -1,40 +0,0 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
|
||||
name: Lint php-cs
|
||||
|
||||
on: pull_request
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: lint-php-cs-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
name: php-cs
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
|
||||
|
||||
- name: Set up php
|
||||
uses: shivammathur/setup-php@c5fc0d8281aba02c7fda07d3a70cc5371548067d # v2
|
||||
with:
|
||||
php-version: 8.1
|
||||
coverage: none
|
||||
ini-file: development
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Install dependencies
|
||||
run: composer i
|
||||
|
||||
- name: Lint
|
||||
run: composer run cs:check || ( echo 'Please run `composer run cs:fix` to format your code' && exit 1 )
|
||||
@@ -1,60 +0,0 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
|
||||
name: Lint php
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
- stable*
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: lint-php-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
php-lint:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
php-versions: [ "8.0", "8.1", "8.2" ]
|
||||
|
||||
name: php-lint
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
|
||||
|
||||
- name: Set up php ${{ matrix.php-versions }}
|
||||
uses: shivammathur/setup-php@c5fc0d8281aba02c7fda07d3a70cc5371548067d # v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
coverage: none
|
||||
ini-file: development
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Lint
|
||||
run: composer run lint
|
||||
|
||||
summary:
|
||||
permissions:
|
||||
contents: none
|
||||
runs-on: ubuntu-latest
|
||||
needs: php-lint
|
||||
|
||||
if: always()
|
||||
|
||||
name: php-lint-summary
|
||||
|
||||
steps:
|
||||
- name: Summary status
|
||||
run: if ${{ needs.php-lint.result != 'success' && needs.php-lint.result != 'skipped' }}; then exit 1; fi
|
||||
@@ -1,95 +0,0 @@
|
||||
name: Node tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- stable*
|
||||
|
||||
jobs:
|
||||
versions:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: ${{ github.repository_owner != 'nextcloud-gmbh' }}
|
||||
|
||||
outputs:
|
||||
nodeVersion: ${{ steps.versions.outputs.nodeVersion }}
|
||||
npmVersion: ${{ steps.versions.outputs.npmVersion }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Read package.json node and npm engines version
|
||||
uses: skjnldsv/read-package-engines-version-actions@v1.1
|
||||
id: versions
|
||||
with:
|
||||
fallbackNode: '^12'
|
||||
fallbackNpm: '^6'
|
||||
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
needs: versions
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up node ${{ needs.versions.outputs.nodeVersion }}
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ needs.versions.outputs.nodeVersion }}
|
||||
|
||||
- name: Set up npm ${{ needs.versions.outputs.npmVersion }}
|
||||
run: npm i -g npm@"${{ needs.versions.outputs.npmVersion }}"
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Test
|
||||
run: npm run test
|
||||
|
||||
jsunit:
|
||||
runs-on: ubuntu-latest
|
||||
needs: versions
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up node ${{ needs.versions.outputs.nodeVersion }}
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ needs.versions.outputs.nodeVersion }}
|
||||
|
||||
- name: Set up npm ${{ needs.versions.outputs.npmVersion }}
|
||||
run: npm i -g npm@"${{ needs.versions.outputs.npmVersion }}"
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Test
|
||||
run: npm run test:jsunit
|
||||
|
||||
handlebars:
|
||||
runs-on: ubuntu-latest
|
||||
needs: versions
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up node ${{ needs.versions.outputs.nodeVersion }}
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ needs.versions.outputs.nodeVersion }}
|
||||
|
||||
- name: Set up npm ${{ needs.versions.outputs.npmVersion }}
|
||||
run: npm i -g npm@"${{ needs.versions.outputs.npmVersion }}"
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Run compile
|
||||
run: ./build/compile-handlebars-templates.sh
|
||||
@@ -1,43 +0,0 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
#
|
||||
# Use node together with node-when-unrelated to make eslint a required check for GitHub actions
|
||||
# https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks
|
||||
|
||||
name: Node
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '.github/workflows/**'
|
||||
- 'src/**'
|
||||
- 'apps/**/appinfo/info.xml'
|
||||
- 'package.json'
|
||||
- 'package-lock.json'
|
||||
- 'tsconfig.json'
|
||||
- '**.js'
|
||||
- '**.ts'
|
||||
- '**.vue'
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
- stable*
|
||||
|
||||
concurrency:
|
||||
group: node-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
permissions:
|
||||
contents: none
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
name: node
|
||||
steps:
|
||||
- name: Skip
|
||||
run: 'echo "No JS/TS files changed, skipped Node"'
|
||||
@@ -1,71 +0,0 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
|
||||
name: Node
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/**'
|
||||
- 'src/**'
|
||||
- 'apps/**/appinfo/info.xml'
|
||||
- 'package.json'
|
||||
- 'package-lock.json'
|
||||
- 'tsconfig.json'
|
||||
- '**.js'
|
||||
- '**.ts'
|
||||
- '**.vue'
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
- stable*
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: node-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
name: node
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
|
||||
|
||||
- name: Read package.json node and npm engines version
|
||||
uses: skjnldsv/read-package-engines-version-actions@0ce2ed60f6df073a62a77c0a4958dd0fc68e32e7 # v2.1
|
||||
id: versions
|
||||
with:
|
||||
fallbackNode: '^16'
|
||||
fallbackNpm: '^7'
|
||||
|
||||
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
|
||||
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
|
||||
with:
|
||||
node-version: ${{ steps.versions.outputs.nodeVersion }}
|
||||
|
||||
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
|
||||
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
|
||||
|
||||
- name: Install dependencies & build
|
||||
run: |
|
||||
npm ci
|
||||
npm run build --if-present
|
||||
|
||||
- name: Check webpack build changes
|
||||
run: |
|
||||
bash -c "[[ ! \"`git status --porcelain `\" ]] || (echo 'Please recompile and commit the assets, see the section \"Show changes on failure\" for details' && exit 1)"
|
||||
|
||||
- name: Show changes on failure
|
||||
if: failure()
|
||||
run: |
|
||||
git status
|
||||
git --no-pager diff
|
||||
exit 1 # make it red to grab attention
|
||||
@@ -1,71 +0,0 @@
|
||||
# This workflow is provided via the organization template repository
|
||||
#
|
||||
# https://github.com/nextcloud/.github
|
||||
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
|
||||
|
||||
name: Npm audit fix and compile
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
# At 2:30 on Sundays
|
||||
- cron: '30 2 * * 0'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
branches: ["main", "master", "stable27", "stable26", "stable25", "stable24"]
|
||||
|
||||
name: npm-audit-fix-${{ matrix.branches }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2
|
||||
with:
|
||||
ref: ${{ matrix.branches }}
|
||||
|
||||
- name: Read package.json node and npm engines version
|
||||
uses: skjnldsv/read-package-engines-version-actions@0ce2ed60f6df073a62a77c0a4958dd0fc68e32e7 # v2.1
|
||||
id: versions
|
||||
with:
|
||||
fallbackNode: '^16'
|
||||
fallbackNpm: '^7'
|
||||
|
||||
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
|
||||
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
|
||||
with:
|
||||
node-version: ${{ steps.versions.outputs.nodeVersion }}
|
||||
|
||||
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
|
||||
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
|
||||
|
||||
- name: Fix npm audit
|
||||
run: |
|
||||
npm audit fix
|
||||
|
||||
- name: Run npm ci and npm run build
|
||||
if: always()
|
||||
run: |
|
||||
npm ci
|
||||
npm run build --if-present
|
||||
|
||||
- name: Create Pull Request
|
||||
if: always()
|
||||
uses: peter-evans/create-pull-request@284f54f989303d2699d373481a0cfa13ad5a6666 # v5
|
||||
with:
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
commit-message: "chore(deps): fix npm audit"
|
||||
committer: GitHub <noreply@github.com>
|
||||
author: nextcloud-command <nextcloud-command@users.noreply.github.com>
|
||||
signoff: true
|
||||
branch: automated/noid/${{ matrix.branches }}-fix-npm-audit
|
||||
title: "[${{ matrix.branches }}] Fix npm audit"
|
||||
body: |
|
||||
Auto-generated fix of npm audit
|
||||
labels: |
|
||||
dependencies
|
||||
3. to review
|
||||
@@ -1,86 +0,0 @@
|
||||
name: PHPUnit oci
|
||||
|
||||
on: pull_request
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: phpunit-oci-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
phpunit-oci:
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
if: ${{ github.repository_owner != 'nextcloud-gmbh' }}
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
php-versions: ['8.0', '8.1', '8.2']
|
||||
|
||||
services:
|
||||
oracle:
|
||||
image: ghcr.io/gvenzl/oracle-xe:11
|
||||
|
||||
# Provide passwords and other environment variables to container
|
||||
env:
|
||||
ORACLE_RANDOM_PASSWORD: true
|
||||
APP_USER: autotest
|
||||
APP_USER_PASSWORD: owncloud
|
||||
|
||||
# Forward Oracle port
|
||||
ports:
|
||||
- 1521:1521/tcp
|
||||
|
||||
# Provide healthcheck script options for startup
|
||||
options: >-
|
||||
--health-cmd healthcheck.sh
|
||||
--health-interval 10s
|
||||
--health-timeout 5s
|
||||
--health-retries 10
|
||||
|
||||
steps:
|
||||
- name: Checkout server
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Set up php ${{ matrix.php-versions }}
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
extensions: ctype, curl, dom, fileinfo, gd, imagick, intl, json, mbstring, oci8, openssl, pcntl, pdo_sqlite, posix, sqlite, xml, zip
|
||||
tools: phpunit:9
|
||||
coverage: none
|
||||
ini-file: development
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Nextcloud
|
||||
run: |
|
||||
mkdir data
|
||||
./occ maintenance:install --verbose --database=oci --database-name=XE --database-host=127.0.0.1 --database-port=1521 --database-user=autotest --database-pass=owncloud --admin-user admin --admin-pass admin
|
||||
php -f index.php
|
||||
|
||||
- name: PHPUnit
|
||||
working-directory: tests
|
||||
run: phpunit --configuration phpunit-autotest.xml --group DB,SLOWDB
|
||||
|
||||
- name: Run repair steps
|
||||
run: |
|
||||
./occ maintenance:repair --include-expensive
|
||||
|
||||
summary:
|
||||
permissions:
|
||||
contents: none
|
||||
runs-on: ubuntu-latest
|
||||
needs: phpunit-oci
|
||||
|
||||
if: always()
|
||||
|
||||
name: phpunit-oci-summary
|
||||
|
||||
steps:
|
||||
- name: Summary status
|
||||
run: if ${{ needs.phpunit-oci.result != 'success' }}; then exit 1; fi
|
||||
@@ -1,108 +0,0 @@
|
||||
name: Performance testing
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
performance-testing:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: ${{ github.repository_owner != 'nextcloud-gmbh' }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php-versions: ['8.0']
|
||||
|
||||
name: performance-${{ matrix.php-versions }}
|
||||
|
||||
steps:
|
||||
- name: Checkout server before PR
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
ref: ${{ github.event.pull_request.base.ref }}
|
||||
|
||||
- name: Set up php ${{ matrix.php-versions }}
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
tools: phpunit:9
|
||||
extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, zip, gd
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Nextcloud
|
||||
run: |
|
||||
mkdir data
|
||||
./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
|
||||
|
||||
php -S localhost:8080 &
|
||||
- name: Apply blueprint
|
||||
uses: icewind1991/blueprint@v0.1.2
|
||||
with:
|
||||
blueprint: tests/blueprints/basic.toml
|
||||
ref: ${{ github.event.pull_request.head.ref }}
|
||||
- name: Run before measurements
|
||||
uses: nextcloud/profiler@1e66a9de5f76a01e9d1db4f0153bcc1cbf989b3d
|
||||
with:
|
||||
run: |
|
||||
curl -s -X PROPFIND -u test:test http://localhost:8080/remote.php/dav/files/test
|
||||
curl -s -u test:test http://localhost:8080/remote.php/dav/files/test/test.txt
|
||||
curl -s -X PROPFIND -u test:test http://localhost:8080/remote.php/dav/files/test/many_files
|
||||
curl -s -u test:test -T README.md http://localhost:8080/remote.php/dav/files/test/new_file.txt
|
||||
curl -s -u test:test -X DELETE http://localhost:8080/remote.php/dav/files/test/new_file.txt
|
||||
output: before.json
|
||||
profiler-branch: stable27
|
||||
|
||||
- name: Apply PR
|
||||
run: |
|
||||
git remote add pr ${{ github.event.pull_request.head.repo.clone_url }}
|
||||
git fetch pr ${{ github.event.pull_request.head.ref }}
|
||||
git checkout -b pr/${{ github.event.pull_request.head.ref }}
|
||||
git submodule update
|
||||
|
||||
./occ upgrade
|
||||
|
||||
- name: Run after measurements
|
||||
id: compare
|
||||
uses: nextcloud/profiler@1e66a9de5f76a01e9d1db4f0153bcc1cbf989b3d
|
||||
with:
|
||||
run: |
|
||||
curl -s -X PROPFIND -u test:test http://localhost:8080/remote.php/dav/files/test
|
||||
curl -s -u test:test http://localhost:8080/remote.php/dav/files/test/test.txt
|
||||
curl -s -X PROPFIND -u test:test http://localhost:8080/remote.php/dav/files/test/many_files
|
||||
curl -s -u test:test -T README.md http://localhost:8080/remote.php/dav/files/test/new_file.txt
|
||||
curl -s -u test:test -X DELETE http://localhost:8080/remote.php/dav/files/test/new_file.txt
|
||||
output: after.json
|
||||
profiler-branch: stable27
|
||||
compare-with: before.json
|
||||
|
||||
- name: Upload profiles
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: profiles
|
||||
path: |
|
||||
before.json
|
||||
after.json
|
||||
|
||||
- uses: actions/github-script@v5
|
||||
if: failure() && steps.compare.outcome == 'failure'
|
||||
with:
|
||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||
script: |
|
||||
let comment = `Possible performance regression detected\n`;
|
||||
comment += `<details><summary>Show Output</summary>
|
||||
|
||||
\`\`\`
|
||||
${{ steps.compare.outputs.compare }}
|
||||
\`\`\`
|
||||
|
||||
</details>`;
|
||||
|
||||
github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: comment
|
||||
})
|
||||
@@ -1,65 +0,0 @@
|
||||
name: PHPUnit 32bits
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- 'version.php'
|
||||
- '.github/workflows/phpunit-32bits.yml'
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "15 1 * * 1-6"
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: phpunit-32bits-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
phpunit-32bits:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: ${{ github.repository_owner != 'nextcloud-gmbh' }}
|
||||
|
||||
container: shivammathur/node:latest-i386
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
php-versions: ['8.0']
|
||||
|
||||
steps:
|
||||
- name: Checkout server
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Install tools
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y ffmpeg imagemagick libmagickcore-6.q16-3-extra
|
||||
|
||||
- name: Set up php ${{ matrix.php-versions }}
|
||||
uses: shivammathur/setup-php@9c77701ae57b0c47f6732beebfbdec76e4e5c90a #debian bookworm fix
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
extensions: ctype, curl, dom, fileinfo, gd, imagick, intl, json, mbstring, openssl, pdo_sqlite, posix, sqlite, xml, zip, apcu
|
||||
tools: phpunit:9
|
||||
coverage: none
|
||||
ini-values:
|
||||
apc.enabled=on,
|
||||
apc.enable_cli=on
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Nextcloud
|
||||
env:
|
||||
DB_PORT: 4444
|
||||
run: |
|
||||
mkdir data
|
||||
./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-port=$DB_PORT --database-user=autotest --database-pass=rootpassword --admin-user admin --admin-pass admin
|
||||
php -f index.php
|
||||
|
||||
- name: PHPUnit
|
||||
working-directory: tests
|
||||
run: phpunit --configuration phpunit-autotest.xml --exclude-group PRIMARY-azure,PRIMARY-s3,PRIMARY-swift,Memcached,Redis,RoutingWeirdness
|
||||
@@ -1,132 +0,0 @@
|
||||
name: S3 External storage
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- stable*
|
||||
paths:
|
||||
- 'apps/files_external/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'apps/files_external/**'
|
||||
|
||||
env:
|
||||
APP_NAME: files_external
|
||||
|
||||
jobs:
|
||||
s3-external-tests-minio:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: ${{ github.repository_owner != 'nextcloud-gmbh' }}
|
||||
|
||||
strategy:
|
||||
# do not stop on another job's failure
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php-versions: ['8.0', '8.1']
|
||||
|
||||
name: php${{ matrix.php-versions }}-minio
|
||||
|
||||
services:
|
||||
minio:
|
||||
env:
|
||||
MINIO_ACCESS_KEY: minio
|
||||
MINIO_SECRET_KEY: minio123
|
||||
image: bitnami/minio:2021.10.6
|
||||
ports:
|
||||
- "9000:9000"
|
||||
|
||||
steps:
|
||||
- name: Checkout server
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Set up php ${{ matrix.php-versions }}
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
tools: phpunit:9
|
||||
extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, zip, gd
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Nextcloud
|
||||
run: |
|
||||
mkdir data
|
||||
./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
|
||||
./occ app:enable --force ${{ env.APP_NAME }}
|
||||
php -S localhost:8080 &
|
||||
- name: PHPUnit
|
||||
run: |
|
||||
echo "<?php return ['run' => true, 'secret' => 'actually-not-secret', 'passwordsalt' => 'actually-not-secret', 'hostname' => 'localhost','key' => 'minio','secret' => 'minio123', 'bucket' => 'bucket', 'port' => 9000, 'use_ssl' => false, 'autocreate' => true, 'use_path_style' => true];" > apps/${{ env.APP_NAME }}/tests/config.amazons3.php
|
||||
phpunit --configuration tests/phpunit-autotest-external.xml apps/files_external/tests/Storage/Amazons3Test.php
|
||||
phpunit --configuration tests/phpunit-autotest-external.xml apps/files_external/tests/Storage/VersionedAmazonS3Test.php
|
||||
- name: S3 logs
|
||||
if: always()
|
||||
run: |
|
||||
docker ps -a
|
||||
docker logs $(docker ps -aq)
|
||||
s3-external-tests-localstack:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: ${{ github.repository_owner != 'nextcloud-gmbh' }}
|
||||
|
||||
strategy:
|
||||
# do not stop on another job's failure
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php-versions: ['8.0', '8.1']
|
||||
|
||||
name: php${{ matrix.php-versions }}-localstack
|
||||
|
||||
services:
|
||||
minio:
|
||||
env:
|
||||
SERVICES: s3
|
||||
DEBUG: 1
|
||||
image: localstack/localstack:0.12.7
|
||||
ports:
|
||||
- "4566:4566"
|
||||
|
||||
steps:
|
||||
- name: Checkout server
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Set up php ${{ matrix.php-versions }}
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
tools: phpunit:9
|
||||
extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, zip, gd
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Nextcloud
|
||||
run: |
|
||||
mkdir data
|
||||
./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
|
||||
./occ app:enable --force ${{ env.APP_NAME }}
|
||||
php -S localhost:8080 &
|
||||
- name: PHPUnit
|
||||
run: |
|
||||
echo "<?php return ['run' => true,'hostname' => 'localhost','key' => 'ignored','secret' => 'ignored', 'bucket' => 'bucket', 'port' => 4566, 'use_ssl' => false, 'autocreate' => true, 'use_path_style' => true];" > apps/${{ env.APP_NAME }}/tests/config.amazons3.php
|
||||
phpunit --configuration tests/phpunit-autotest-external.xml apps/files_external/tests/Storage/Amazons3Test.php
|
||||
phpunit --configuration tests/phpunit-autotest-external.xml apps/files_external/tests/Storage/VersionedAmazonS3Test.php
|
||||
- name: S3 logs
|
||||
if: always()
|
||||
run: |
|
||||
docker ps -a
|
||||
docker logs $(docker ps -aq)
|
||||
|
||||
s3-external-summary:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [s3-external-tests-minio, s3-external-tests-localstack]
|
||||
|
||||
if: always()
|
||||
|
||||
steps:
|
||||
- name: Summary status
|
||||
run: if ${{ needs.s3-external-tests-minio.result != 'success' }} || ${{ needs.s3-external-tests-localstack.result != 'success' }}; then exit 1; fi
|
||||
@@ -1,86 +0,0 @@
|
||||
name: S3 primary storage integration tests
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- stable*
|
||||
|
||||
jobs:
|
||||
s3-primary-integration-tests-minio:
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
if: ${{ github.repository_owner != 'nextcloud-gmbh' }}
|
||||
|
||||
strategy:
|
||||
# do not stop on another job's failure
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php-versions: ['8.0']
|
||||
key: ['objectstore', 'objectstore_multibucket']
|
||||
|
||||
name: php${{ matrix.php-versions }}-${{ matrix.key }}-minio
|
||||
|
||||
services:
|
||||
redis:
|
||||
image: redis
|
||||
ports:
|
||||
- "6379:6379"
|
||||
minio:
|
||||
env:
|
||||
MINIO_ACCESS_KEY: minio
|
||||
MINIO_SECRET_KEY: minio123
|
||||
image: bitnami/minio:2021.12.29
|
||||
ports:
|
||||
- "9000:9000"
|
||||
|
||||
steps:
|
||||
- name: Checkout server
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Set up php ${{ matrix.php-versions }}
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
tools: phpunit:9
|
||||
extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, zip, gd, redis
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Wait for S3
|
||||
run: |
|
||||
sleep 10
|
||||
curl -f -m 1 --retry-connrefused --retry 10 --retry-delay 10 http://localhost:9000/minio/health/ready
|
||||
|
||||
- name: Set up Nextcloud
|
||||
run: |
|
||||
mkdir data
|
||||
echo '<?php $CONFIG=["${{ matrix.key }}" => ["class" => "OC\Files\ObjectStore\S3", "arguments" => ["bucket" => "nextcloud", "autocreate" => true, "key" => "minio", "secret" => "minio123", "hostname" => "localhost", "port" => 9000, "use_ssl" => false, "use_path_style" => true, "uploadPartSize" => 52428800]]];' > config/config.php
|
||||
echo '<?php $CONFIG=["redis" => ["host" => "localhost", "port" => 6379], "memcache.local" => "\OC\Memcache\Redis", "memcache.distributed" => "\OC\Memcache\Redis"];' > config/redis.config.php
|
||||
./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass admin
|
||||
php -f index.php
|
||||
|
||||
- name: Integration
|
||||
run: |
|
||||
cd build/integration
|
||||
bash run.sh --tags "~@failure-s3" features/webdav-related.feature
|
||||
|
||||
- name: S3 logs
|
||||
if: always()
|
||||
run: |
|
||||
cat data/nextcloud.log
|
||||
docker ps -a
|
||||
docker ps -aq | while read container ; do IMAGE=$(docker inspect --format='{{.Config.Image}}' $container); echo $IMAGE; docker logs $container; echo "\n\n" ; done
|
||||
|
||||
|
||||
s3-primary-integration-summary:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [s3-primary-integration-tests-minio]
|
||||
|
||||
if: always()
|
||||
|
||||
steps:
|
||||
- name: Summary status
|
||||
run: if ${{ needs.s3-primary-integration-tests-minio.result != 'success' }}; then exit 1; fi
|
||||
@@ -1,78 +0,0 @@
|
||||
name: S3 primary storage
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- stable*
|
||||
|
||||
jobs:
|
||||
s3-primary-tests-minio:
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
if: ${{ github.repository_owner != 'nextcloud-gmbh' }}
|
||||
|
||||
strategy:
|
||||
# do not stop on another job's failure
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php-versions: ['8.0']
|
||||
key: ['objectstore', 'objectstore_multibucket']
|
||||
|
||||
name: php${{ matrix.php-versions }}-${{ matrix.key }}-minio
|
||||
|
||||
services:
|
||||
minio:
|
||||
env:
|
||||
MINIO_ACCESS_KEY: minio
|
||||
MINIO_SECRET_KEY: minio123
|
||||
image: bitnami/minio:2021.12.29
|
||||
ports:
|
||||
- "9000:9000"
|
||||
|
||||
steps:
|
||||
- name: Checkout server
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Set up php ${{ matrix.php-versions }}
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
tools: phpunit:9
|
||||
extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, zip, gd
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Nextcloud
|
||||
run: |
|
||||
mkdir data
|
||||
echo '<?php $CONFIG=["${{ matrix.key }}" => ["class" => "OC\Files\ObjectStore\S3", "arguments" => ["bucket" => "nextcloud", "autocreate" => true, "key" => "minio", "secret" => "minio123", "hostname" => "localhost", "port" => 9000, "use_ssl" => false, "use_path_style" => true, "uploadPartSize" => 52428800]]];' > config/config.php
|
||||
./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
|
||||
php -f index.php
|
||||
|
||||
- name: Wait for S3
|
||||
run: |
|
||||
sleep 10
|
||||
curl -f -m 1 --retry-connrefused --retry 10 --retry-delay 10 http://localhost:9000/minio/health/ready
|
||||
|
||||
- name: PHPUnit
|
||||
working-directory: tests
|
||||
run: phpunit --configuration phpunit-autotest.xml --group DB,SLOWDB
|
||||
- name: S3 logs
|
||||
if: always()
|
||||
run: |
|
||||
docker ps -a
|
||||
docker logs $(docker ps -aq)
|
||||
|
||||
|
||||
s3-primary-summary:
|
||||
runs-on: ubuntu-latest
|
||||
needs: [s3-primary-tests-minio]
|
||||
|
||||
if: always()
|
||||
|
||||
steps:
|
||||
- name: Summary status
|
||||
run: if ${{ needs.s3-primary-tests-minio.result != 'success' }}; then exit 1; fi
|
||||
@@ -1,75 +0,0 @@
|
||||
name: SFTP unit tests
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- stable*
|
||||
paths:
|
||||
- 'apps/files_external/**'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'apps/files_external/**'
|
||||
|
||||
env:
|
||||
APP_NAME: files_external
|
||||
|
||||
jobs:
|
||||
sftp-tests:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: ${{ github.repository_owner != 'nextcloud-gmbh' }}
|
||||
|
||||
strategy:
|
||||
# do not stop on another job's failure
|
||||
fail-fast: false
|
||||
matrix:
|
||||
php-versions: ['8.0']
|
||||
sftpd: ['openssh']
|
||||
|
||||
name: php${{ matrix.php-versions }}-${{ matrix.sftpd }}
|
||||
|
||||
steps:
|
||||
- name: Checkout server
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Set up sftpd
|
||||
run: |
|
||||
sudo mkdir /tmp/sftp
|
||||
sudo chown -R 0777 /tmp/sftp
|
||||
if [[ "${{ matrix.sftpd }}" == 'openssh' ]]; then docker run -p 2222:22 --name sftp -d -v /tmp/sftp:/home/test atmoz/sftp "test:test:::data"; fi
|
||||
- name: Set up php ${{ matrix.php-versions }}
|
||||
uses: shivammathur/setup-php@c5fc0d8281aba02c7fda07d3a70cc5371548067d #v2.25.2
|
||||
with:
|
||||
php-version: ${{ matrix.php-versions }}
|
||||
tools: phpunit:9
|
||||
extensions: mbstring, fileinfo, intl, sqlite, pdo_sqlite, zip, gd
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Set up Nextcloud
|
||||
run: |
|
||||
mkdir data
|
||||
./occ maintenance:install --verbose --database=sqlite --database-name=nextcloud --database-host=127.0.0.1 --database-user=root --database-pass=rootpassword --admin-user admin --admin-pass password
|
||||
./occ app:enable --force ${{ env.APP_NAME }}
|
||||
php -S localhost:8080 &
|
||||
- name: PHPUnit
|
||||
run: |
|
||||
echo "<?php return ['run' => true, 'host' => 'localhost:2222','user' => 'test','password' => 'test', 'root' => 'data'];" > apps/${{ env.APP_NAME }}/tests/config.sftp.php
|
||||
phpunit --configuration tests/phpunit-autotest-external.xml apps/files_external/tests/Storage/SftpTest.php
|
||||
- name: sftpd logs
|
||||
if: always()
|
||||
run: |
|
||||
ls -l /tmp/sftp
|
||||
docker logs sftp
|
||||
|
||||
sftp-summary:
|
||||
runs-on: ubuntu-latest
|
||||
needs: sftp-tests
|
||||
|
||||
if: always()
|
||||
|
||||
steps:
|
||||
- name: Summary status
|
||||
run: if ${{ needs.sftp-tests.result != 'success' }}; then exit 1; fi
|
||||
@@ -1,58 +0,0 @@
|
||||
name: Samba Kerberos SSO
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- stable*
|
||||
paths:
|
||||
- 'apps/files_external/**'
|
||||
- '.github/workflows/smb-kerberos.yml'
|
||||
pull_request:
|
||||
paths:
|
||||
- 'apps/files_external/**'
|
||||
- '.github/workflows/smb-kerberos.yml'
|
||||
|
||||
jobs:
|
||||
smb-kerberos-tests:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: ${{ github.repository_owner != 'nextcloud-gmbh' }}
|
||||
|
||||
name: smb-kerberos-sso
|
||||
|
||||
steps:
|
||||
- name: Checkout server
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
- name: Checkout user_saml
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
repository: nextcloud/user_saml
|
||||
path: apps/user_saml
|
||||
ref: stable-5.2
|
||||
- name: Pull images
|
||||
run: |
|
||||
docker pull ghcr.io/icewind1991/samba-krb-test-dc
|
||||
docker pull ghcr.io/icewind1991/samba-krb-test-apache
|
||||
docker pull ghcr.io/icewind1991/samba-krb-test-client
|
||||
docker tag ghcr.io/icewind1991/samba-krb-test-dc icewind1991/samba-krb-test-dc
|
||||
docker tag ghcr.io/icewind1991/samba-krb-test-apache icewind1991/samba-krb-test-apache
|
||||
docker tag ghcr.io/icewind1991/samba-krb-test-client icewind1991/samba-krb-test-client
|
||||
- name: Setup AD-DC
|
||||
run: |
|
||||
DC_IP=$(apps/files_external/tests/sso-setup/start-dc.sh)
|
||||
apps/files_external/tests/sso-setup/start-apache.sh $DC_IP $PWD
|
||||
echo "DC_IP=$DC_IP" >> $GITHUB_ENV
|
||||
- name: Set up Nextcloud
|
||||
run: |
|
||||
apps/files_external/tests/sso-setup/setup-sso-nc.sh
|
||||
- name: Test SSO
|
||||
run: |
|
||||
apps/files_external/tests/sso-setup/test-sso-smb.sh ${{ env.DC_IP }}
|
||||
- name: Show logs
|
||||
if: failure()
|
||||
run: |
|
||||
FILEPATH=$(docker exec --user 33 apache ./occ log:file | grep "Log file:" | cut -d' ' -f3)
|
||||
echo "$FILEPATH:"
|
||||
docker exec --user 33 apache cat $FILEPATH
|
||||
@@ -1,33 +0,0 @@
|
||||
name: Close stale issues
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "0 0 * * *"
|
||||
|
||||
jobs:
|
||||
stale:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: ${{ github.repository_owner != 'nextcloud-gmbh' }}
|
||||
|
||||
permissions:
|
||||
issues: write
|
||||
|
||||
steps:
|
||||
- uses: actions/stale@v5
|
||||
with:
|
||||
repo-token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
stale-issue-message: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
recent activity and seems to be missing some essential information.
|
||||
It will be closed if no further activity occurs. Thank you
|
||||
for your contributions.
|
||||
stale-issue-label: 'stale'
|
||||
only-labels: 'needs info'
|
||||
labels-to-remove-when-unstale: 'needs info,stale'
|
||||
exempt-issue-labels: '1. to develop,2. developing,3. to review,4. to release,security'
|
||||
days-before-stale: 30
|
||||
days-before-close: 14
|
||||
# debug-only: true
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
name: Psalm static code analysis
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- stable*
|
||||
|
||||
jobs:
|
||||
static-code-analysis:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: ${{ github.repository_owner != 'nextcloud-gmbh' }}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Set up php
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.0'
|
||||
extensions: apcu,ctype,curl,dom,fileinfo,ftp,gd,intl,json,ldap,mbstring,openssl,pdo_sqlite,posix,sqlite,xml,zip
|
||||
coverage: none
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Composer install
|
||||
run: composer i
|
||||
|
||||
- name: Psalm
|
||||
run: composer run psalm:ci -- --monochrome --no-progress --output-format=github --update-baseline --report=results.sarif
|
||||
|
||||
- name: Show potential changes in Psalm baseline
|
||||
if: always()
|
||||
run: git diff -- . ':!lib/composer'
|
||||
|
||||
- name: Upload Analysis results to GitHub
|
||||
if: always()
|
||||
uses: github/codeql-action/upload-sarif@v2
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
||||
static-code-analysis-security:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Set up php
|
||||
uses: shivammathur/setup-php@master
|
||||
with:
|
||||
php-version: '8.0'
|
||||
extensions: ctype,curl,dom,fileinfo,ftp,gd,intl,json,ldap,mbstring,openssl,pdo_sqlite,posix,sqlite,xml,zip
|
||||
coverage: none
|
||||
|
||||
- name: Composer install
|
||||
run: composer i
|
||||
|
||||
- name: Psalm taint analysis
|
||||
run: composer run psalm:ci -- --monochrome --no-progress --output-format=github --report=results.sarif --taint-analysis
|
||||
|
||||
- name: Upload Security Analysis results to GitHub
|
||||
if: always()
|
||||
uses: github/codeql-action/upload-sarif@v2
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
|
||||
static-code-analysis-ocp:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: true
|
||||
|
||||
- name: Set up php
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.0'
|
||||
extensions: ctype,curl,dom,fileinfo,gd,intl,json,mbstring,openssl,pdo_sqlite,posix,sqlite,xml,zip
|
||||
coverage: none
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Composer install
|
||||
run: composer i
|
||||
|
||||
- name: Psalm
|
||||
run: composer run psalm:ci -- -c psalm-ocp.xml --monochrome --no-progress --output-format=github --update-baseline
|
||||
|
||||
- name: Show potential changes in Psalm baseline
|
||||
if: always()
|
||||
run: git diff -- . ':!lib/composer'
|
||||
@@ -1,42 +0,0 @@
|
||||
name: Update CA certificate bundle
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "5 2 * * *"
|
||||
|
||||
jobs:
|
||||
update-ca-certificate-bundle:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
branches: ["master", "stable26", "stable25", "stable24", "stable23", "stable22"]
|
||||
|
||||
name: update-ca-certificate-bundle-${{ matrix.branches }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ matrix.branches }}
|
||||
submodules: true
|
||||
|
||||
- name: Download CA certificate bundle from curl
|
||||
run: curl --etag-compare build/ca-bundle-etag.txt --etag-save build/ca-bundle-etag.txt --output resources/config/ca-bundle.crt https://curl.se/ca/cacert.pem
|
||||
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v3
|
||||
with:
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
commit-message: Update CA certificate bundle
|
||||
committer: GitHub <noreply@github.com>
|
||||
author: nextcloud-command <nextcloud-command@users.noreply.github.com>
|
||||
signoff: true
|
||||
branch: automated/noid/${{ matrix.branches }}-update-ca-cert-bundle
|
||||
title: "[${{ matrix.branches }}] Update ca-cert bundle"
|
||||
body: |
|
||||
Auto-generated update of CA certificate bundle from [https://curl.se/docs/caextract.html](https://curl.se/docs/caextract.html)
|
||||
labels: |
|
||||
dependencies
|
||||
3. to review
|
||||
@@ -1,67 +0,0 @@
|
||||
name: Update Psalm baseline
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: "5 2 * * *"
|
||||
|
||||
jobs:
|
||||
update-psalm-baseline:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
if: ${{ github.repository_owner != 'nextcloud-gmbh' }}
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
branches: ["master", "stable26", "stable25", "stable24", "stable23"]
|
||||
|
||||
name: update-psalm-baseline-${{ matrix.branches }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
ref: ${{ matrix.branches }}
|
||||
submodules: true
|
||||
|
||||
- name: Set up php
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.0'
|
||||
extensions: ctype,curl,dom,fileinfo,gd,intl,json,mbstring,openssl,pdo_sqlite,posix,sqlite,xml,zip
|
||||
coverage: none
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Composer install
|
||||
run: composer install
|
||||
|
||||
- name: Psalm
|
||||
run: composer run psalm -- --monochrome --no-progress --output-format=text --update-baseline
|
||||
continue-on-error: true
|
||||
|
||||
- name: Psalm OCP
|
||||
run: composer run psalm -- -c psalm-ocp.xml --monochrome --no-progress --output-format=github --update-baseline
|
||||
continue-on-error: true
|
||||
|
||||
- name: Reset composer
|
||||
run: |
|
||||
git clean -f lib/composer
|
||||
git checkout composer.json composer.lock lib/composer
|
||||
|
||||
- name: Create Pull Request
|
||||
uses: peter-evans/create-pull-request@v4
|
||||
with:
|
||||
token: ${{ secrets.COMMAND_BOT_PAT }}
|
||||
commit-message: Update psalm baseline
|
||||
committer: GitHub <noreply@github.com>
|
||||
author: nextcloud-command <nextcloud-command@users.noreply.github.com>
|
||||
signoff: true
|
||||
branch: automated/noid/${{ matrix.branches }}-update-psalm-baseline
|
||||
title: "[${{ matrix.branches }}] Update psalm-baseline.xml"
|
||||
body: |
|
||||
Auto-generated update psalm-baseline.xml with fixed psalm warnings
|
||||
labels: |
|
||||
automated pr
|
||||
3. to review
|
||||
team-reviewers: server-backend
|
||||
+10
-119
@@ -1,62 +1,9 @@
|
||||
# the default generated dir + db file
|
||||
/data
|
||||
/config/config.php
|
||||
/config/*.config.php
|
||||
/config/mimetype*.json
|
||||
/config/mount.php
|
||||
/apps/inc.php
|
||||
/assets
|
||||
/.htaccess
|
||||
/node_modules
|
||||
/translationfiles
|
||||
/translationtool.phar
|
||||
|
||||
# ignore all apps except core ones
|
||||
/apps*/*
|
||||
!/apps/cloud_federation_api
|
||||
!/apps/comments
|
||||
!/apps/contactsinteraction
|
||||
!/apps/dashboard
|
||||
!/apps/dav
|
||||
!/apps/files
|
||||
!/apps/federation
|
||||
!/apps/federatedfilesharing
|
||||
!/apps/sharebymail
|
||||
!/apps/encryption
|
||||
!/apps/files_external
|
||||
!/apps/files_reminders
|
||||
!/apps/files_sharing
|
||||
!/apps/files_trashbin
|
||||
!/apps/files_versions
|
||||
!/apps/lookup_server_connector
|
||||
!/apps/user_ldap
|
||||
!/apps/oauth2
|
||||
!/apps/provisioning_api
|
||||
!/apps/settings
|
||||
!/apps/systemtags
|
||||
!/apps/testing
|
||||
!/apps/admin_audit
|
||||
!/apps/updatenotification
|
||||
!/apps/theming
|
||||
!/apps/twofactor_backupcodes
|
||||
!/apps/user_status
|
||||
!/apps/weather_status
|
||||
!/apps/workflowengine
|
||||
/apps/files_external/3rdparty/irodsphp/PHPUnitTest
|
||||
/apps/files_external/3rdparty/irodsphp/web
|
||||
/apps/files_external/3rdparty/irodsphp/prods/test
|
||||
/apps/files_external/3rdparty/irodsphp/prods/tutorials
|
||||
/apps/files_external/3rdparty/irodsphp/prods/test*
|
||||
/apps/files_external/tests/config.*.php
|
||||
|
||||
# apps modules
|
||||
/apps/*/node_modules
|
||||
|
||||
|
||||
# ignore themes except the example and the README
|
||||
/themes/*
|
||||
!/themes/example
|
||||
!/themes/README
|
||||
data
|
||||
owncloud
|
||||
config/config.php
|
||||
config/mount.php
|
||||
apps/inc.php
|
||||
|
||||
# just sane ignores
|
||||
.*.sw[po]
|
||||
@@ -73,8 +20,6 @@ CVS/*
|
||||
.svn/*
|
||||
RCS/*
|
||||
*.backup*
|
||||
.php_cs.cache
|
||||
.php-cs-fixer.cache
|
||||
|
||||
# kdevelop
|
||||
.kdev
|
||||
@@ -88,30 +33,21 @@ RCS/*
|
||||
.project
|
||||
.settings
|
||||
|
||||
# netbeans
|
||||
# netbeans
|
||||
nbproject
|
||||
|
||||
# phpStorm
|
||||
.idea
|
||||
*.iml
|
||||
|
||||
# vscode
|
||||
.vscode
|
||||
*.code-workspace
|
||||
|
||||
# geany
|
||||
*.geany
|
||||
|
||||
# Cloud9IDE
|
||||
.settings.xml
|
||||
.c9revisions
|
||||
|
||||
# vim ex mode
|
||||
.vimrc
|
||||
|
||||
# ack(-grep)
|
||||
.ackrc
|
||||
|
||||
|
||||
# Mac OS
|
||||
.DS_Store
|
||||
|
||||
@@ -119,53 +55,8 @@ nbproject
|
||||
.well-known
|
||||
/.buildpath
|
||||
|
||||
# Tests
|
||||
/tests/phpunit.xml
|
||||
|
||||
# Node Modules
|
||||
/build/node_modules/
|
||||
|
||||
# nodejs
|
||||
/build/bin
|
||||
/build/lib/
|
||||
/build/jsdocs/
|
||||
/npm-debug.log
|
||||
/PhantomJS_*
|
||||
|
||||
# puphpet
|
||||
puphpet
|
||||
|
||||
# vagrant
|
||||
.vagrant
|
||||
Vagrantfile
|
||||
|
||||
# Tests - auto-generated files
|
||||
/data-autotest
|
||||
/tests/.phpunit.result.cache
|
||||
#tests - autogenerated filed
|
||||
data-autotest
|
||||
/tests/coverage*
|
||||
/tests/css
|
||||
/tests/karma-coverage
|
||||
/tests/autoconfig*
|
||||
/tests/autotest*
|
||||
/tests/data/lorem-copy.txt
|
||||
/tests/data/testimage-copy.png
|
||||
/tests/ui-regression/out/
|
||||
/tests/ui-regression/node_modules/
|
||||
/tests/ui-regression/package-lock.json
|
||||
/config/config-autotest-backup.php
|
||||
/config/autoconfig.php
|
||||
clover.xml
|
||||
|
||||
# Tests - dependencies
|
||||
tests/acceptance/vendor/
|
||||
|
||||
composer.phar
|
||||
/lib/composer/bin
|
||||
/vendor-bin/**/vendor
|
||||
|
||||
./.htaccess
|
||||
core/js/mimetypelist.js
|
||||
|
||||
# Tests - cypress
|
||||
cypress/snapshots
|
||||
cypress/videos
|
||||
/tests/autotest*
|
||||
@@ -1,3 +0,0 @@
|
||||
[submodule "3rdparty"]
|
||||
path = 3rdparty
|
||||
url = https://github.com/nextcloud/3rdparty.git
|
||||
@@ -1,110 +1,26 @@
|
||||
<IfModule mod_headers.c>
|
||||
<IfModule mod_setenvif.c>
|
||||
<IfModule mod_fcgid.c>
|
||||
SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
|
||||
RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
|
||||
</IfModule>
|
||||
<IfModule mod_proxy_fcgi.c>
|
||||
SetEnvIfNoCase Authorization "(.+)" HTTP_AUTHORIZATION=$1
|
||||
</IfModule>
|
||||
<IfModule mod_lsapi.c>
|
||||
SetEnvIfNoCase ^Authorization$ "(.+)" XAUTHORIZATION=$1
|
||||
RequestHeader set XAuthorization %{XAUTHORIZATION}e env=XAUTHORIZATION
|
||||
</IfModule>
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_env.c>
|
||||
# Add security and privacy related headers
|
||||
|
||||
# Avoid doubled headers by unsetting headers in "onsuccess" table,
|
||||
# then add headers to "always" table: https://github.com/nextcloud/server/pull/19002
|
||||
Header onsuccess unset Referrer-Policy
|
||||
Header always set Referrer-Policy "no-referrer"
|
||||
|
||||
Header onsuccess unset X-Content-Type-Options
|
||||
Header always set X-Content-Type-Options "nosniff"
|
||||
|
||||
Header onsuccess unset X-Frame-Options
|
||||
Header always set X-Frame-Options "SAMEORIGIN"
|
||||
|
||||
Header onsuccess unset X-Permitted-Cross-Domain-Policies
|
||||
Header always set X-Permitted-Cross-Domain-Policies "none"
|
||||
|
||||
Header onsuccess unset X-Robots-Tag
|
||||
Header always set X-Robots-Tag "noindex, nofollow"
|
||||
|
||||
Header onsuccess unset X-XSS-Protection
|
||||
Header always set X-XSS-Protection "1; mode=block"
|
||||
|
||||
SetEnv modHeadersAvailable true
|
||||
</IfModule>
|
||||
|
||||
# Add cache control for static resources
|
||||
<FilesMatch "\.(css|js|mjs|svg|gif|png|jpg|ico|wasm|tflite)$">
|
||||
<If "%{QUERY_STRING} =~ /(^|&)v=/">
|
||||
Header set Cache-Control "max-age=15778463, immutable"
|
||||
</If>
|
||||
<Else>
|
||||
Header set Cache-Control "max-age=15778463"
|
||||
</Else>
|
||||
</FilesMatch>
|
||||
|
||||
# Let browsers cache WOFF files for a week
|
||||
<FilesMatch "\.woff2?$">
|
||||
Header set Cache-Control "max-age=604800"
|
||||
</FilesMatch>
|
||||
ErrorDocument 403 /core/templates/403.php
|
||||
ErrorDocument 404 /core/templates/404.php
|
||||
<IfModule mod_php5.c>
|
||||
php_value upload_max_filesize 513M
|
||||
php_value post_max_size 513M
|
||||
php_value memory_limit 512M
|
||||
<IfModule env_module>
|
||||
SetEnv htaccessWorking true
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_php.c>
|
||||
php_value mbstring.func_overload 0
|
||||
php_value default_charset 'UTF-8'
|
||||
php_value output_buffering 0
|
||||
<IfModule mod_env.c>
|
||||
SetEnv htaccessWorking true
|
||||
</IfModule>
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_mime.c>
|
||||
AddType image/svg+xml svg svgz
|
||||
AddType application/wasm wasm
|
||||
AddEncoding gzip svgz
|
||||
# Serve ESM javascript files (.mjs) with correct mime type
|
||||
AddType text/javascript js mjs
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_dir.c>
|
||||
DirectoryIndex index.php index.html
|
||||
</IfModule>
|
||||
|
||||
<IfModule pagespeed_module>
|
||||
ModPagespeed Off
|
||||
</IfModule>
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine on
|
||||
RewriteCond %{HTTP_USER_AGENT} DavClnt
|
||||
RewriteRule ^$ /remote.php/webdav/ [L,R=302]
|
||||
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||
RewriteRule ^\.well-known/carddav /remote.php/dav/ [R=301,L]
|
||||
RewriteRule ^\.well-known/caldav /remote.php/dav/ [R=301,L]
|
||||
RewriteRule ^remote/(.*) remote.php [QSA,L]
|
||||
RewriteRule ^(?:build|tests|config|lib|3rdparty|templates)/.* - [R=404,L]
|
||||
RewriteRule ^\.well-known/(?!acme-challenge|pki-validation) /index.php [QSA,L]
|
||||
RewriteRule ^ocm-provider/?$ index.php [QSA,L]
|
||||
RewriteRule ^(?:\.(?!well-known)|autotest|occ|issue|indie|db_|console).* - [R=404,L]
|
||||
RewriteEngine on
|
||||
RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
||||
RewriteRule ^.well-known/host-meta /public.php?service=host-meta [QSA,L]
|
||||
RewriteRule ^.well-known/carddav /remote.php/carddav/ [R]
|
||||
RewriteRule ^.well-known/caldav /remote.php/caldav/ [R]
|
||||
RewriteRule ^apps/calendar/caldav.php remote.php/caldav/ [QSA,L]
|
||||
RewriteRule ^apps/contacts/carddav.php remote.php/carddav/ [QSA,L]
|
||||
RewriteRule ^apps/([^/]*)/(.*\.(css|php))$ index.php?app=$1&getfile=$2 [QSA,L]
|
||||
RewriteRule ^remote/(.*) remote.php [QSA,L]
|
||||
</IfModule>
|
||||
|
||||
# Clients like xDavv5 on Android, or Cyberduck, use chunked requests.
|
||||
# When FastCGI or FPM is used with apache, requests arrive to Nextcloud without any content.
|
||||
# This leads to the creation of empty files.
|
||||
# The following directive will force the problematic requests to be buffered before being forwarded to Nextcloud.
|
||||
# This way, the "Transfer-Encoding" header is removed, the "Content-Length" header is set, and the request content is proxied to Nextcloud.
|
||||
# Here are more information about the issue:
|
||||
# - https://docs.cyberduck.io/mountainduck/issues/fastcgi/
|
||||
# - https://docs.nextcloud.com/server/latest/admin_manual/issues/general_troubleshooting.html#troubleshooting-webdav
|
||||
<IfModule mod_setenvif.c>
|
||||
SetEnvIf Transfer-Encoding "chunked" proxy-sendcl=1
|
||||
<IfModule mod_mime.c>
|
||||
AddType image/svg+xml svg svgz
|
||||
AddEncoding gzip svgz
|
||||
</IfModule>
|
||||
|
||||
AddDefaultCharset utf-8
|
||||
Options -Indexes
|
||||
|
||||
Generated
-52
@@ -1,52 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectCodeStyleSettingsManager">
|
||||
<option name="PER_PROJECT_SETTINGS">
|
||||
<value>
|
||||
<option name="RIGHT_MARGIN" value="80" />
|
||||
<PHPCodeStyleSettings>
|
||||
<option name="PHPDOC_BLANK_LINE_BEFORE_TAGS" value="true" />
|
||||
<option name="LOWER_CASE_BOOLEAN_CONST" value="true" />
|
||||
<option name="LOWER_CASE_NULL_CONST" value="true" />
|
||||
</PHPCodeStyleSettings>
|
||||
<XML>
|
||||
<option name="XML_KEEP_BLANK_LINES" value="1" />
|
||||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
||||
</XML>
|
||||
<codeStyleSettings language="CSS">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="HTML">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="JavaScript">
|
||||
<option name="SPACE_BEFORE_METHOD_PARENTHESES" value="true" />
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="PHP">
|
||||
<option name="CLASS_BRACE_STYLE" value="1" />
|
||||
<option name="METHOD_BRACE_STYLE" value="1" />
|
||||
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
||||
<option name="WHILE_BRACE_FORCE" value="3" />
|
||||
<option name="FOR_BRACE_FORCE" value="3" />
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="XML">
|
||||
<indentOptions>
|
||||
<option name="USE_TAB_CHARACTER" value="true" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
</value>
|
||||
</option>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</component>
|
||||
</project>
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"camelcase": true,
|
||||
"eqeqeq": true,
|
||||
"immed": true,
|
||||
"latedef": false,
|
||||
"noarg": true,
|
||||
"nonbsp": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"trailing": true,
|
||||
"maxparams": 5,
|
||||
"curly": true,
|
||||
"jquery": true,
|
||||
"maxlen": 120,
|
||||
"indent": 4,
|
||||
"browser": true,
|
||||
"laxbreak": true,
|
||||
"globals": {
|
||||
"console": true,
|
||||
"it": true,
|
||||
"xit": true,
|
||||
"expect": true,
|
||||
"describe": true,
|
||||
"beforeEach": true,
|
||||
"afterEach": true,
|
||||
"sinon": true,
|
||||
"fakeServer": true,
|
||||
"_": true,
|
||||
"OC": true,
|
||||
"OCA": true,
|
||||
"OCP": true,
|
||||
"t": true,
|
||||
"n": true,
|
||||
"escapeHTML": true,
|
||||
"Promise": true
|
||||
}
|
||||
}
|
||||
@@ -1,433 +0,0 @@
|
||||
Aamir Khan <ak4u2009@gmail.com>
|
||||
Aaron Reichman <areichman.kde@gmail.com>
|
||||
Adam Williamson <awilliam@redhat.com>
|
||||
Aditya Patawari <adimania@gmail.com>
|
||||
Administrator <Administrator@WINDOWS-2012>
|
||||
adrien <adrien.waksberg@believedigital.com>
|
||||
Aldo "xoen" Giambelluca <xoen@xoen.org>
|
||||
Alessandro Cosentino <cosenal@gmail.com>
|
||||
Alexander Bergolth <leo@strike.wu.ac.at> root <leo@strike.wu.ac.at>
|
||||
Alexander Bogdanov <syn@li.ru>
|
||||
Alexander Wigen <alex@wigen.net>
|
||||
Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
|
||||
Anders Nor Berle <anders@berle.cc>
|
||||
Andreas Fischer <bantu@owncloud.com>
|
||||
Andreas Schönebeck <aschoenebeck@web.de>
|
||||
Andreas Ergenzinger <andreas.ergenzinger@gmx.de> AndreasErgenzinger <andreas.ergenzinger@gmx.de>
|
||||
Andrew Brown <andrew@casabrown.com>
|
||||
André Gaul <gaul@web-yard.de>
|
||||
Arthur Schiwon <blizzz@arthur-schiwon.de> Arthur Schiwon <blizzz@owncloud.com>
|
||||
Arthur Schiwon <blizzz@arthur-schiwon.de> blizzz <blizzz@owncloud.com>
|
||||
Artur Duque de Souza <asouza@kde.org>
|
||||
Axel Roenn <axel@mpim-bonn.mpg.de>
|
||||
Bagera <victor@baquero-wihlborg.se>
|
||||
Bart Visscher <bartv@thisnet.nl> Bart Visscher <bart@thisnet.nl>
|
||||
Bart Visscher <bartv@thisnet.nl> Bart Visscher <github@thisnet.nl>
|
||||
Bartek Przybylski <bart.p.pl@gmail.com>
|
||||
Bastien Ho <bastienho@urbancube.fr>
|
||||
ben-denham <bend@catalyst.net.nz>
|
||||
Benjamin Diele <benjamin@diele.be>
|
||||
Benjamin Liles <benliles@arch.tamu.edu>
|
||||
Bernhard Posselt <dev@bernhard-posselt.com> Bernhard Posselt <nukeawhale@gmail.com>
|
||||
Bernhard Posselt <dev@bernhard-posselt.com> Bernhard Posselt <Raydiation@users.noreply.github.com>
|
||||
Bernhard Posselt <dev@bernhard-posselt.com> Bernhard Posselt <BernhardPosselt@users.noreply.github.com>
|
||||
Bernhard Reiter <ockham@raz.or.at>
|
||||
Birk Borkason <daniel.niccoli@gmail.com>
|
||||
Björn Schießle <bjoern@schiessle.org> Bjoern Schiessle <schiesbn@woody.(none)>
|
||||
Björn Schießle <bjoern@schiessle.org> Björn Schießle <schiessle@owncloud.com>
|
||||
Björn Schießle <bjoern@schiessle.org> Björn Schießle <schiesbn@potato.(none)>
|
||||
Björn Schießle <bjoern@schiessle.org> Björn Schiessle <schiessle@owncloud.com>
|
||||
Björn Schießle <bjoern@schiessle.org> Bjoern Schießle <schiessle@owncloud.com>
|
||||
Björn Schießle <bjoern@schiessle.org> Bjoern Schiessle <schiessle@owncloud.com>
|
||||
Björn Schießle <bjoern@schiessle.org> Björn Schießle <schiessle@owncloud.com>
|
||||
BlackEagle <ike.devolder@gmail.com>
|
||||
Boris Rybalkin <ribalkin@gmail.com>
|
||||
Borjan Tchakaloff <borjan@tchakaloff.fr>
|
||||
Brice Maron <brice@bmaron.net>
|
||||
brumsel <brumsel@losecatcher.de> brumsoel <brumsel@losecatcher.de>
|
||||
Byron Marohn <combustible@live.com> eMerzh <brice@bmaron.net>
|
||||
Caio Marcelo de Oliveira Filho <caio.oliveira@openbossa.org>
|
||||
Carla Schroder <carla@owncloud.com>
|
||||
Carlos Cerrillo <ccerrillo@gmail.com>
|
||||
cbhp <cbhp@users.noreply.github.com>
|
||||
cbojar <chris@cbojar.net>
|
||||
Ceri Davies <ceri@submonkey.net>
|
||||
cetra3 <peter@parashift.com.au>
|
||||
Charles-Edouard Coste <contact@ccoste.fr>
|
||||
CharlyCoste <contact@ccoste.fr>
|
||||
chli1 <chli1@users.noreply.github.com>
|
||||
Chris Kankiewicz <Chris@ChrisKankiewicz.com>
|
||||
Chris LeBlanc <chris@leblaaanc.com>
|
||||
Chris Wilson <chris+github@qwirx.com>
|
||||
Christian Berendt <berendt@b1-systems.de>
|
||||
Christian Kampka <christian@kampka.net>
|
||||
Christian Koch <koch.chris@gmail.com>
|
||||
Christian Reiner <github@christian-reiner.info> Christian Reiner <arkascha@balder.site>
|
||||
Christoph Wurst <christoph@winzerhof-wurst.at> Christoph Wurst <ChristophWurst@users.noreply.github.com>
|
||||
Christoph Wurst <christoph@winzerhof-wurst.at> Christoph Wurst <christoph@owncloud.com>
|
||||
Christopher Bunn <b11.chris@gmail.com>
|
||||
Christopher Schäpers <kondou@ts.unde.re> Christopher <kondou@ts.unde.re>
|
||||
Christopher Schäpers <kondou@ts.unde.re> kondou <kondou@ts.unde.re>
|
||||
Christopher Schäpers <kondou@ts.unde.re> root <kondou@ts.unde.re>
|
||||
Christopher T. Johnson <ctjctj@gmail.com>
|
||||
Clark Tomlinson <fallen013@gmail.com>
|
||||
Cloud Dumper <clouddumper@gmail.com>
|
||||
cmeh <cmeh@users.noreply.github.com>
|
||||
Cornelius Schumacher <schumacher@kde.org>
|
||||
Craig Morrissey <craig@owncloud.com>
|
||||
Côme BERNIGAUD <come.bernigaud@laposte.net>
|
||||
dampfklon <me@dampfklon.de>
|
||||
Dan Bartram <daneybartram@gmail.com>
|
||||
Dan Callahan <dan.callahan@gmail.com>
|
||||
Dan Jones <dan@danneh.org>
|
||||
Daniel <daniel@mars.(none)>
|
||||
Daniel Hansson <enoch85@gmail.com>
|
||||
Daniel Kesselberg <mail@danielkesselberg.de> kesselb <mail@danielkesselberg.de>
|
||||
Daniel Köb <daniel.koeb@peony.at>
|
||||
Daniel Molkentin <daniel@molkentin.de>
|
||||
Daniele E. Domenichelli <daniele.domenichelli@gmail.com>
|
||||
David <davidventura>
|
||||
David Iwanowitsch <david+git@unclouded.de> David Iwanowitsch <diw@gmx.de>
|
||||
David Prévot <taffit@debian.org>
|
||||
David Reagan <reagand@lanecc.edu>
|
||||
davidak <davidak@gmx.de>
|
||||
davidgumberg <davidnoizgumberg@gmail.com>
|
||||
Dawid Opis <ncore@ncore.com.pl>
|
||||
Deepak Mittal <dpac.mittal2@gmail.com>
|
||||
DeLtAfOx <edo@ravers.it>
|
||||
denis-b <denis.bonnenfant@diderot.org>
|
||||
Der-Jan <de@r-jan.de>
|
||||
derkostka <sebastian.kostka@gmail.com>
|
||||
Diederik de Haas <diederik@cknow.org>
|
||||
Dominik Schmidt <dev@dominik-schmidt.de>
|
||||
Donald Buczek <buczek@molgen.mpg.de>
|
||||
Donquixote <marjunebatac@gmail.com> Donquixote <marjunebatac@gmailcom>
|
||||
Doug Neiner <doug@pixelgraphics.us>
|
||||
drarko <drarko@users.noreply.github.com>
|
||||
dratini0 <dratini0@gmail.com>
|
||||
Duane Johnson <duane.johnson@gmail.com>
|
||||
eduardo <eduardo@vnexu.net>
|
||||
elchi <niklas1b@yahoo.de>
|
||||
Elias Probst <mail@eliasprobst.eu>
|
||||
Florian <ente@baer.rwth-aachen.de> ente <ente@baer.rwth-aachen.de>
|
||||
Erik Sargent <esthepiking@gmail.com>
|
||||
Evgeni Golov <evgeni@golov.de>
|
||||
fabian <fabian@web2.0-apps.de>
|
||||
Fabian Henze <flyser42@gmx.de>
|
||||
Felix Böhm <felixboehm@gmx.de> felixboehm <felixboehm@gmx.de>
|
||||
Felix Eckhofer <felix@eckhofer.com>
|
||||
Felix Moeller <mail@felixmoeller.de>
|
||||
Felix Niklas <mrflix@gmail.com>
|
||||
Fernando Rodriguez Sela <frsela@tid.es>
|
||||
fibsifan <fi@volans.uberspace.de>
|
||||
Florian Hülsmann <fh@cbix.de>
|
||||
Florian Jacob <fjacob@lavabit.com>
|
||||
Florian Preinstorfer <nblock@archlinux.us>
|
||||
Florian Pritz <bluewind@xinu.at>
|
||||
Florian Scholz <FlorianScholz@bgstyle.de> Florian Scholz <work@bgstyle.de>
|
||||
Florian Vichot <florian.vichot@gmail.com>
|
||||
Florin Peter <github@florin-peter.de> Florin Peter <fp@datawerk.de>
|
||||
Florin Peter <github@florin-peter.de> FlorinPeter <github@florin-peter.de>
|
||||
Francesco Piraneo G. <fpiraneo@iface.ch>
|
||||
Frank Karlitschek <frank@karlitschek.de> Frank Karlitschek <frank@dev.(none)>
|
||||
Frank Karlitschek <frank@karlitschek.de> Frank Karlitschek <frank@devel.(none)>
|
||||
Frank Karlitschek <frank@karlitschek.de> Frank Karlitschek <frank@oc.(none)>
|
||||
Frank Karlitschek <frank@karlitschek.de> Frank Karlitschek <frank@owncloud.org>
|
||||
Frank Karlitschek <frank@karlitschek.de> Frank Karlitschek <karlitschek@kde.org>
|
||||
François Kubler <francois@kubler.org>
|
||||
Frédéric Fortier <frederic.fortier@oronospolytechnique.com> Frédéric Fortier <frederic.fortier@polymtl.ca>
|
||||
Frederik Gladhorn <gladhorn@kde.org>
|
||||
Gadzy <dev@gadzy.fr>
|
||||
ganomi <ganomi@gmail.com>
|
||||
Gaël Beaudoin <gaboo@home.gaboo.org>
|
||||
geez0x1 <geez0x1@users.noreply.github.com>
|
||||
gekmihesg <markus@gekmihesg.de>
|
||||
Georg Ehrke <oc.list@georgehrke.com> Georg Ehrke <dev@georgswebsite.de>
|
||||
Georg Ehrke <oc.list@georgehrke.com> Georg Ehrke <developer@georgehrke.com>
|
||||
Georg Ehrke <oc.list@georgehrke.com> Georg Ehrke <georg.stefan.germany@googlemail.com>
|
||||
Georg Ehrke <oc.list@georgehrke.com> Georg Ehrke <ownclouddev@georgswebsite.de>
|
||||
Georg Ehrke <oc.list@georgehrke.com> Georg Ehrke <devgeorg@ownCloud.com>
|
||||
Georg Ehrke <oc.list@georgehrke.com> Georg Ehrke <georg@ownCloud.com>
|
||||
Georg Ehrke <oc.list@georgehrke.com> Georg Ehrke <georg@owncloud.com>
|
||||
Golnaz Nilieh <g382nilieh@gmail.com>
|
||||
Grundik <grundik@ololo.cc>
|
||||
Guillaume AMAT <guillaume.amat@informatique-libre.com>
|
||||
Hans Bakker <hansmbakker@gmail.com>
|
||||
helix84 <helix84@centrum.sk>
|
||||
Hendrik Langer <hendrik.langer@gmx.de>
|
||||
Henning Becker <h.becker@oedenstockach.de>
|
||||
Henning Oschwald <h.oschwald@gmx.de>
|
||||
Henrik Kjölhede <hkjolhede@gmail.com>
|
||||
herbrechtsmeier <stefan@herbrechtsmeier.net>
|
||||
hkjolhede <hkjolhede@gmail.com>
|
||||
IchEben <andreas@reichster.de>
|
||||
ideaship <ideaship@users.noreply.github.com>
|
||||
Ignacio Daniel Rostagno <ignaciorostagno@vijona.com.ar>
|
||||
infoneo <infoneo@yahoo.pl>
|
||||
Insanemal <insanemal@gmail.com>
|
||||
Tobias Perschon <tobias@perschon.at> Tobias Perschon <tofuSCHNITZEL@users.noreply.github.com>
|
||||
Tobias Ramforth <tobias@ramforth.com> Tobias Ramforth <tobias.ramforth@udo.edu>
|
||||
Tobias Ramforth <tobias@ramforth.com> irgsmirx <tobias.ramforth@udo.edu>
|
||||
Isaac Rosenberg <irosenb7@gmail.com>
|
||||
itheiss <ingo.theiss@i-matrixx.de>
|
||||
j-ed <juergen@eisfair.org>
|
||||
Jake Wilson <jakew@huebnerpetersen.com>
|
||||
Jakob Sack <mail@jakobsack.de> Jakob Sack <kde@jakobsack.de>
|
||||
jamesryanbell <james@james-bell.co.uk>
|
||||
Jamie McClelland <jm@mayfirst.org>
|
||||
Jan-Christoph Borchardt <hey@jancborchardt.net> Jan-Christoph Borchardt <jan@unhosted.org>
|
||||
Jan-Christoph Borchardt <hey@jancborchardt.net> Jan-Christoph Borchardt <JanCBorchardt@fsfe.org>
|
||||
jbtbnl <jbtbnl@users.noreply.github.com>
|
||||
Jean-Louis Dupond <jean-louis@dupond.be>
|
||||
Jenkins for ownCloud <owncloud-bot@tmit.eu> Jenkins for ownCloud <thomas.mueller@tmit.eu>
|
||||
Jens-Christian Fischer <jens-christian.fischer@switch.ch>
|
||||
Jernej Virag <jernej.virag@gmail.com>
|
||||
Jesus Macias Portela <jesus.macias.portela@gmail.com>
|
||||
Jesús Macias <jmacias@solidgear.es> Jesus Macias <jmacias@full-on-net.com>
|
||||
jknockaert <jasper@knockaert.nl>
|
||||
Joan <aseques@gmail.com>
|
||||
Joar Wandborg <git@wandborg.com>
|
||||
Joas Schilling <coding@schilljs.com> Joas Schilling <213943+nickvergessen@users.noreply.github.com>
|
||||
Joas Schilling <coding@schilljs.com> Joas Schilling <nickvergessen@gmx.de>
|
||||
Joas Schilling <coding@schilljs.com> Joas Schilling <nickvergessen@owncloud.com>
|
||||
joel hansson <joel.hansson@gmail.com>
|
||||
Johan Björk <johanimon@gmail.com>
|
||||
Johannes Twittmann <github.com@deryo.de>
|
||||
Johannes Willnecker <johannes@willnecker.com>
|
||||
John Kristensen <John.Kristensen@dpipwe.tas.gov.au>
|
||||
Jonathan Riddell <jriddell@ubuntu.com>
|
||||
Jonny007-MKD <1-23-4-5@web.de>
|
||||
josh4trunks <joshruehlig@gmail.com>
|
||||
Joshua Medeiros <Jammerx2@gmail.com>
|
||||
Juan Carlos Cornejo <jc2@paintblack.com>
|
||||
Julian Müller <julian.mueller.ffb@kabelmail.de>
|
||||
Jörn Friedrich Dreyer <jfd@butonic.de> jfd <jfd@lance>
|
||||
Jörn Friedrich Dreyer <jfd@butonic.de> jfd <jfd@underverse>
|
||||
Kamil Domanski <kdomanski@kdemail.net>
|
||||
Kees Huiberts <snowy@derideal.com>
|
||||
Klaas Freitag <freitag@owncloud.com> Klaas Freitag <freitag@suse.de>
|
||||
Konstantin Popov <konstantin.popov@globalpointagency.comv> Konstantin.Popov <konstantin.popov@globalpointagency.comv>
|
||||
krzaczek <pawel@freshmind.pl>
|
||||
Kshitij Parajuli <kshitijparajuli@gmail.com>
|
||||
Kunal Ghosh <kunal.t2@gmail.com>
|
||||
Tobia De Koninck <tobia@ledfan.be> LEDfan <tobia@ledfan.be>
|
||||
Lennart Rosam <lennart.rosam@medien-systempartner.de>
|
||||
Sebastian Döll <sebastian.doell@libasys.de> libasys <sebastian.doell@libasys.de>
|
||||
Lode Hoste <zillode@zillode.be>
|
||||
lolozere <laurent@chedanne.pro>
|
||||
Louis Chemineau <louis@chmn.me> Louis Chemineau <6653109+artonge@users.noreply.github.com>
|
||||
Lorenzo M. Catucci <lorenzo@sancho.ccd.uniroma2.it>
|
||||
Lukas Reschke <lukas@statuscode.ch> Lukas Reschke <lukas@owncloud.com>
|
||||
Lukas Reschke <lukas@statuscode.ch> Lukas Reschke <lukas@owncloud.org>
|
||||
Luke Policinski <lpolicinski@gmail.com>
|
||||
Lyonel Vincent <lyonel@ezix.org>
|
||||
macjohnny <estebanmarin@gmx.ch>
|
||||
maelzx <maelzx@gmail.com>
|
||||
marc0s <marcos@tenak.net>
|
||||
Marco B <beinbrech@solutica.de>
|
||||
Marco Michelino <michelinux@gmail.com>
|
||||
Markus Goetz <markus@woboq.com>
|
||||
Markus Kalkbrenner <markus.kalkbrenner@bio.logis.de>
|
||||
Martial Saunois <saunois.martial@gmail.com>
|
||||
Martin Mattel <martin.mattel@diemattels.at> Martin <martin.mattel@diemattels.at>
|
||||
Martin Mattel <martin.mattel@diemattels.at> root <martin.mattel@diemattels.at>
|
||||
Martin Grohmann <martin@medi-inf.org>
|
||||
# TODO: the same person
|
||||
Martin Konrad <info@martin-konrad.net>
|
||||
Martin Konrad <konrad@frib.msu.edu>
|
||||
Martin Sandsmark <martin.sandsmark@kde.org> Martin T. H. Sandsmark <sandsmark@samfundet.no>
|
||||
Marvin Thomas Rabe <mrabe@marvinrabe.de> Marvin Thomas Rabe <m.rabe@echtzeitraum.de>
|
||||
Masaki Kawabata Neto <masaki.kawabata@gmail.com> Masaki <masaki.kawabata@gmail.com>
|
||||
Mat Lipe <mat@lipeimagination.info>
|
||||
Matthew Caron <matt@mattcaron.net>
|
||||
Matthew Dawson <matthew@mjdsystems.ca>
|
||||
Matthias Rieber <matthias@zu-con.org>
|
||||
Maximilian Ruta <mr@xtain.net>
|
||||
mh <mh@immerda.ch>
|
||||
Michael Gapczynski <GapczynskiM@gmail.com> Michael Gapczynski <mtgap@owncloud.com>
|
||||
Michael Göhler <somebody.here@gmx.de>
|
||||
Michael Kent <mike@draftx.net>
|
||||
Michael Kuhn <suraia@ikkoku.de>
|
||||
Michael Monreal <michael.monreal@gmail.com>
|
||||
Michael Roitzsch <reactorcontrol@icloud.com>
|
||||
michag86 <micha_g@arcor.de>
|
||||
Michiel de Jong <michiel@unhosted.org> Michiel@unhosted <michiel@unhosted.org>
|
||||
Miguel Prokop <miguel.prokop@vtu.com>
|
||||
miicha <pfitzner@physik.hu-berlin.de>
|
||||
Miquel Rodríguez Telep / Michael Rodríguez-Torrent <miquel@designunbound.co.uk>
|
||||
Morris Jobke <hey@morrisjobke.de> Morris Jobke <morris.jobke@gmail.com>
|
||||
MTRichards <matt@owncloud.com>
|
||||
mvn23 <schopdiedwaas@gmail.com>
|
||||
Myles McNamara <myles@hostt.net> Myles McNamara <myles@smyl.es>
|
||||
NARUKAWA Hiroki <nhirokinet@nhiroki.net>
|
||||
Nathan Dauber <nathan@radialogica.com>
|
||||
Nazar Mokrynskyi <nazar@mokrynskyi.com>
|
||||
nhirokinet <nhirokinet@nhiroki.net>
|
||||
Nico Kaiser <nico.kaiser@boerse-go.de>
|
||||
Nicolai Ehemann <en@enlightened.de>
|
||||
Nicolas Stamm <nicolas.stamm@gmail.com>
|
||||
NIEK Antoine <antoineniek@gmail.com>
|
||||
Niklas Sombert <niklas1b@yahoo.de>
|
||||
Nils Jansen <nilsjansen@gmail.com>
|
||||
nishiki <nishiki@yaegashi.fr>
|
||||
Nmz <nemesiz@nmz.lt>
|
||||
Normal Ra <normalraw@gmail.com> Normal Ra <NormalRa@users.noreply.github.com>
|
||||
Oliver Gasser <oliver.gasser@gmail.com> Oliver Gasser <oliver@flowriver.net>
|
||||
Oliver Kohl D.Sc. <oliver@kohl.bz>
|
||||
Olivier Paroz <github@oparoz.com> Olivier Paroz <oparoz@users.noreply.github.com>
|
||||
Olivier Tétard <olivier.tetard@miskin.fr>
|
||||
Aaron Larisch <aaron.larisch@gmx.de> OpenLarry <aaron.larisch@gmx.de>
|
||||
opensaucesystems <ashley@opensaucesystems.com>
|
||||
Oskar Hollmann <oskarhollmann@gmail.com>
|
||||
Otto Sabart <ottosabart@seberm.com>
|
||||
Owen Winkler <a_github@midnightcircus.com> Owen Winkler <epithet@gmail.com>
|
||||
Owen Winkler <a_github@midnightcircus.com> ringmaster <epithet@gmail.com>
|
||||
Pascal de Bruijn <pmjdebruijn@pcode.nl>
|
||||
Patrick Paysant <ppaysant@linagora.com>
|
||||
Patrick Stricker <stricker@hera.dev.iks-hagen.de>
|
||||
Paul Brown <paul90brown@gmail.com>
|
||||
pdessauw <pdessauw@gmail.com>
|
||||
Pellaeon Lin <nfsmwlin@gmail.com>
|
||||
Pete McFarlane <peterjohnmcfarlane@gmail.com> petemcfarlane <peterjohnmcfarlane@gmail.com>
|
||||
Philipp Kapfer <philipp.kapfer@gmx.at>
|
||||
Philipp Knechtges <philipp-dev@knechtges.com>
|
||||
Philipp Roggan <philipp.roggan@newsletter4free.de>
|
||||
Philipp Schmitt <philipp@schmitt.co>
|
||||
Philippe Jung <phil.jung@free.fr>
|
||||
Philippe Kueck <pk@plusline.de>
|
||||
prcrst <prcrst@hush.com>
|
||||
pzy <pzy@d1sturbed.org>
|
||||
Qingping Hou <dave2008713@gmail.com>
|
||||
Raghu Nayyar <me@iraghu.com> Raghu Nayyar <raghu.nayyar.007@gmail.com>
|
||||
Raghu Nayyar <me@iraghu.com> raghunayyar <me@iraghu.com>
|
||||
Raimund Schlüßler <raimund.schluessler@googlemail.com>
|
||||
Ramiro Aparicio <rapariciog@gmail.com>
|
||||
Randolph Carter <RandolphCarter@fantasymail.de>
|
||||
RealRancor <Fisch.666@gmx.de>
|
||||
Remco Brenninkmeijer <requist1@starmail.nl>
|
||||
Riccardo Iaconelli <riccardo@kde.org>
|
||||
Richard Clarkson <robert@trash-mail.com>
|
||||
rnveach <rveach02@gmail.com>
|
||||
Robert Jäckel <rjaeckel@users.noreply.github.com>
|
||||
Robin Appelman <robin@icewind.nl> icewind1991 <icewind1991@gmail.com>
|
||||
Robin Appelman <robin@icewind.nl> icewind1991 <robin@icewind.nl>
|
||||
Robin Appelman <robin@icewind.nl> Robin <Robin Appelman icewind1991@gmail.com>
|
||||
Robin Appelman <robin@icewind.nl> Robin <robin@Amaya.(none)>
|
||||
Robin Appelman <robin@icewind.nl> Robin Appelman <icewind1991@gmail.com>
|
||||
Robin Appelman <robin@icewind.nl> Robin Appelman <icewind1991@gmail>
|
||||
Robin Appelman <robin@icewind.nl> Robin Appelman <icewind@owncloud.com>
|
||||
Robin McCorkell <robin@mccorkell.me.uk> Robin McCorkell <rmccorkell@karoshi.org.uk>
|
||||
Robin McCorkell <robin@mccorkell.me.uk> Robin McCorkell <rmccorkell@owncloud.com>
|
||||
Rodrigo Hjort <rodrigo.hjort@gmail.com>
|
||||
Roeland Jago Douma <roeland@famdouma.nl> Roeland Jago Douma <rullzer@owncloud.com>
|
||||
Roeland Jago Douma <roeland@famdouma.nl> Roeland Douma <rullzer@users.noreply.github.com>
|
||||
Roeland Jago Douma <roeland@famdouma.nl> Roeland Jago Douma <rullzer@users.noreply.github.com>
|
||||
Roger Szabo <roger.szabo@web.de> root <roger.szabo@web.de>
|
||||
rok <brejktru@gmail.com>
|
||||
Roland Hager <roland.hager@tu-berlin.de>
|
||||
Roland van Laar <roland@micite.net>
|
||||
rolandgeider <roland@geider.net>
|
||||
Roman Geber <rgeber@owncloudapps.com>
|
||||
root <root@asterisk03.ceschia.de>
|
||||
root <root@dev.(none)>
|
||||
root <root@oc.(none)>
|
||||
root <root@plug.(none)>
|
||||
Ross Nicoll <jrn@jrn.me.uk>
|
||||
runky <philipp.boersteken@googlemail.com>
|
||||
Sam Tuke <mail@samtuke.com> Sam Tuke <sam@donttravelempty.com>
|
||||
Sam Tuke <mail@samtuke.com> Sam Tuke <samtuke@jack-laptop.(none)>
|
||||
Sam Tuke <mail@samtuke.com> Sam Tuke <samtuke@owncloud.com>
|
||||
Sander <brantje@gmail.com>
|
||||
Sandro Knauß <bugs@sandroknauss.de> Sandro <hefee@taurin.(none)>
|
||||
Sascha Schmidt <realriot@realriot.de>
|
||||
Sascha Schneider <development@suntsu.org>
|
||||
Sascha Wiswedel <sascha.wiswedel@nextcloud.com> Sascha Wiswedel <wiswedel@users.noreply.github.com>
|
||||
scambra <sergio@entrecables.com>
|
||||
scolebrook <scolebrook@mac.com>
|
||||
Scott Arciszewski <scott@arciszewski.me>
|
||||
Scott Barnett <scott.n.barnett@gmail.com>
|
||||
Scott Shambarger <gitorious@shambarger.net>
|
||||
Scrutinizer Auto-Fixer <auto-fixer@scrutinizer-ci.com>
|
||||
Sean Comeau <sean@ftlnetworks.ca>
|
||||
Sean Leonard <meanderingcode@silverleafstudios.net>
|
||||
Sebastian Bolt <sebastian.bolt@gmx.de>
|
||||
Serge Martin <edb@sigluy.net>
|
||||
Sergei Shuykov <n1nj4p0w3r@gmail.com>
|
||||
Sergi Almacellas Abellana <sergi@koolpi.com>
|
||||
sherbrecher <oss@herbrecher.de>
|
||||
shkdee <louis.traynard@m4x.org>
|
||||
Simon Birnbach <simon@simon-birnbach.de>
|
||||
Simon Könnecke <simonkoennecke@gmail.com>
|
||||
Simon Whittaker <simon@swbh.net>
|
||||
Sjors van der Pluijm <sjors@desjors.nl> Sjors van der Pluijm <sjors@youngguns.nl>
|
||||
John Molakvoæ <skjnldsv@protonmail.com> John Molakvoæ <skjnldsv@users.noreply.github.com>
|
||||
John Molakvoæ <skjnldsv@protonmail.com> John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
|
||||
st3so <st3so@server.fake>
|
||||
Stefan <mu.stefan@googlemail.com>
|
||||
Stefan Göckeritz <admin@s-goecker.de>
|
||||
Stefan Herbrechtsmeier <stefan@herbrechtsmeier.net>
|
||||
Stefan Rado <owncloud@sradonia.net>
|
||||
Stefan Seidel <android@stefanseidel.info>
|
||||
Steffen Lindner <mail@steffen-lindner.de> Steffen Lindner <gomez@flexiabel.de>
|
||||
Stephan Arts <stephan@xfce.org>
|
||||
Stephan Bergemann <st.bergemann@htw-berlin.de>
|
||||
Stephan Peijnik <speijnik@anexia-it.com>
|
||||
Stephane Martin <stef.martin@gmail.com> Stephane Martin <stephane.martin@vesperal.eu>
|
||||
Stephane V <stephane@vergeylen.eu>
|
||||
Stephen Rees-Carter <stephen@rees-carter.net>
|
||||
Steven <wokste@gmail.com>
|
||||
Steven <wokste@Komkommer.(none)>
|
||||
Steven <wwjd2@web.de>
|
||||
Sugaroverdose <n1nj4p0w3r@gmail.com>
|
||||
Susinthiran Sithamparanathan <chesusin@gmail.com>
|
||||
tbelau666 <thomas.belau@gmx.de>
|
||||
TheSFReader <TheSFReader@gmail.com>
|
||||
Thibaut GRIDEL <tgridel@free.fr>
|
||||
thomas <thomas@thomas-VirtualBox.(none)>
|
||||
Thomas Citharel <nextcloud@tcit.fr> Thomas Citharel <tcit@tcit.fr>
|
||||
Thomas Citharel <nextcloud@tcit.fr> Thomas Citharel <github@tcit.fr>
|
||||
Thomas Müller <thomas.mueller@tmit.eu> Thomas Mueller <thomas.mueller@tmit.eu>
|
||||
Thomas Müller <thomas.mueller@tmit.eu> Thomas Müller <DeepDiver1975@users.noreply.github.com>
|
||||
Thomas Olsen <tol@tanghus>
|
||||
Thomas Schmidt <tschmidt@suse.de>
|
||||
Thomas Tanghus <thomas@tanghus.net>
|
||||
Thomas Zander <zander@kde.org>
|
||||
tiezdne <oswald.84@t-online.de>
|
||||
Tigran Mkrtchyan <tigran.mkrtchyan@desy.de>
|
||||
Tobias Kaminsky <tobias@kaminsky.me> tobiasKaminsky <tobias@kaminsky.me>
|
||||
Tom Needham <tom@owncloud.com> Tom Needham <needham.thomas@gmail.com>
|
||||
Tom Needham <tom@owncloud.com> Tom Needham <tom@tre.tomneedham.com>
|
||||
Tom Needham <tom@owncloud.com> tomneedham <needham.thomas@gmail.com>
|
||||
Tom Needham <tom@owncloud.com> tomneedham <tom@owncloud.com>
|
||||
Tony Zelenoff <antonz@parallels.com>
|
||||
tsumi <mail@tsumi.it>
|
||||
twood8 <ted.wood@gtri.gatech.edu>
|
||||
Türker Sezer <turkersezer@tsdesign.info>
|
||||
unclejamal3000 <andreas.pramhaas@posteo.de>
|
||||
unknown <Alain@Alain-PC.(none)>
|
||||
unknown <pnd@.nist.gov>
|
||||
Valerio Ponte <valerio.ponte@gmail.com>
|
||||
Victor Dubiniuk <dubiniuk@owncloud.com> Victor Dubiniuk <victor.dubiniuk@gmail.com>
|
||||
Victor Dubiniuk <dubiniuk@owncloud.com> VicDeo <dubiniuk@owncloud.com>
|
||||
Victor Dubiniuk <dubiniuk@owncloud.com> VicDeo <victor.dubiniuk@gmail.com>
|
||||
Vincent Cloutier <vincent1cloutier@gmail.com>
|
||||
Vincent Petry <vincent@nextcloud.com> Vincent Petry <PVince81@yahoo.fr>
|
||||
Vincent Petry <vincent@nextcloud.com> Vincent Petry <vincent@vvortex.site>
|
||||
Vincent Petry <vincent@nextcloud.com> Vincent Petry <pvince81@owncloud.com>
|
||||
Vinicius Cubas Brand <vinicius@eita.org.br> Vinicius Cubas Brand <viniciuscb@gmail.com>
|
||||
Vitaly Kuznetsov <vitty@altlinux.ru>
|
||||
Vladimir Sapronov <vladimir.sapronov@gmail.com>
|
||||
Volkan Gezer <volkangezer@gmail.com> Volkan Gezer <wakeup@users.noreply.github.com>
|
||||
Volker E. <open@temporaer.net>
|
||||
voxsim <Simon Vocella>
|
||||
vsapronov <vladimir.sapronov@gmail.com>
|
||||
Vsevolod Kukol <v.kukol@rubologic.de>
|
||||
Weng Xuetian <wengxt@gmail.com>
|
||||
Wikinaut <mail@tgries.de>
|
||||
Willi Ballenthin <willi.ballenthin@gmail.com>
|
||||
windaishi <manuel.strider@web.de>
|
||||
Witali Rott <info@hlop.eu>
|
||||
Yann VERRY <yann@verry.org>
|
||||
yannickoo <github@yannickoo.de>
|
||||
zafi <zafirakis.daniel@gmail.com>
|
||||
zombiehugs <gerdsen@gmail.com>
|
||||
@@ -1 +0,0 @@
|
||||
**/*.spec.js
|
||||
@@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once './vendor-bin/cs-fixer/vendor/autoload.php';
|
||||
|
||||
use Nextcloud\CodingStandard\Config;
|
||||
|
||||
$config = new Config();
|
||||
$config
|
||||
->getFinder()
|
||||
->ignoreVCSIgnored(true)
|
||||
->exclude('config')
|
||||
->exclude('data')
|
||||
->notPath('3rdparty')
|
||||
->notPath('build/integration/vendor')
|
||||
->notPath('build/lib')
|
||||
->notPath('build/node_modules')
|
||||
->notPath('build/stubs')
|
||||
->notPath('composer')
|
||||
->notPath('node_modules')
|
||||
->notPath('vendor')
|
||||
->in(__DIR__);
|
||||
return $config;
|
||||
@@ -1,17 +0,0 @@
|
||||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.3.0
|
||||
hooks:
|
||||
- id: end-of-file-fixer
|
||||
- id: check-yaml
|
||||
- id: check-added-large-files
|
||||
- repo: https://github.com/nextcloud/pre-commit-php.git
|
||||
rev: 1.5.1
|
||||
hooks:
|
||||
- id: php-lint
|
||||
- id: php-cs-fixer
|
||||
files: \.(php)$
|
||||
exclude: ^(config|data|composer|lib\/composer)
|
||||
args: []
|
||||
@@ -1,39 +0,0 @@
|
||||
before_commands:
|
||||
- 'git submodule update --init --recursive'
|
||||
|
||||
build:
|
||||
nodes:
|
||||
analysis:
|
||||
tests:
|
||||
override:
|
||||
- php-scrutinizer-run
|
||||
|
||||
checks:
|
||||
php:
|
||||
excluded_dependencies:
|
||||
- etsy/phan
|
||||
|
||||
filter:
|
||||
excluded_paths:
|
||||
- '3rdparty/*'
|
||||
- 'apps/*/3rdparty/*'
|
||||
- 'apps/*/vendor/*'
|
||||
- 'l10n/*'
|
||||
- 'core/l10n/*'
|
||||
- 'apps/*/l10n/*'
|
||||
- 'apps/*/tests/*'
|
||||
- 'lib/l10n/*'
|
||||
- 'core/vendor/*'
|
||||
- 'core/js/tests/lib/*.js'
|
||||
- 'core/js/tests/specs/*.js'
|
||||
- 'core/js/jquery-showpassword.js'
|
||||
- 'core/js/jquery-tipsy.js'
|
||||
- 'core/js/placeholders.js'
|
||||
- 'settings/l10n/*'
|
||||
- 'tests/*'
|
||||
- 'build/*'
|
||||
- 'lib/composer/*'
|
||||
|
||||
imports:
|
||||
- javascript
|
||||
- php
|
||||
-183
@@ -1,183 +0,0 @@
|
||||
[main]
|
||||
host = https://www.transifex.com
|
||||
lang_map = fi_FI: fi, hu_HU: hu, nb_NO: nb, sk_SK: sk, th_TH: th, ja_JP: ja, bg_BG: bg, cs_CZ: cs
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:admin_audit]
|
||||
file_filter = translationfiles/<lang>/admin_audit.po
|
||||
source_file = translationfiles/templates/admin_audit.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:cloud_federation_api]
|
||||
file_filter = translationfiles/<lang>/cloud_federation_api.po
|
||||
source_file = translationfiles/templates/cloud_federation_api.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:comments]
|
||||
file_filter = translationfiles/<lang>/comments.po
|
||||
source_file = translationfiles/templates/comments.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:contactsinteraction]
|
||||
file_filter = translationfiles/<lang>/contactsinteraction.po
|
||||
source_file = translationfiles/templates/contactsinteraction.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:core]
|
||||
file_filter = translationfiles/<lang>/core.po
|
||||
source_file = translationfiles/templates/core.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:dashboard-shipped-with-server]
|
||||
file_filter = translationfiles/<lang>/dashboard.po
|
||||
source_file = translationfiles/templates/dashboard.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:dav]
|
||||
file_filter = translationfiles/<lang>/dav.po
|
||||
source_file = translationfiles/templates/dav.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:federatedfilesharing]
|
||||
file_filter = translationfiles/<lang>/federatedfilesharing.po
|
||||
source_file = translationfiles/templates/federatedfilesharing.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:federation]
|
||||
file_filter = translationfiles/<lang>/federation.po
|
||||
source_file = translationfiles/templates/federation.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:files]
|
||||
file_filter = translationfiles/<lang>/files.po
|
||||
source_file = translationfiles/templates/files.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:files_encryption]
|
||||
file_filter = translationfiles/<lang>/encryption.po
|
||||
source_file = translationfiles/templates/encryption.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:files_external]
|
||||
file_filter = translationfiles/<lang>/files_external.po
|
||||
source_file = translationfiles/templates/files_external.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:files_reminders]
|
||||
file_filter = translationfiles/<lang>/files_reminders.po
|
||||
source_file = translationfiles/templates/files_reminders.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:files_sharing]
|
||||
file_filter = translationfiles/<lang>/files_sharing.po
|
||||
source_file = translationfiles/templates/files_sharing.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:files_trashbin]
|
||||
file_filter = translationfiles/<lang>/files_trashbin.po
|
||||
source_file = translationfiles/templates/files_trashbin.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:files_versions]
|
||||
file_filter = translationfiles/<lang>/files_versions.po
|
||||
source_file = translationfiles/templates/files_versions.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:lib]
|
||||
file_filter = translationfiles/<lang>/lib.po
|
||||
source_file = translationfiles/templates/lib.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:lookup_server_connector]
|
||||
file_filter = translationfiles/<lang>/lookup_server_connector.po
|
||||
source_file = translationfiles/templates/lookup_server_connector.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:oauth2]
|
||||
file_filter = translationfiles/<lang>/oauth2.po
|
||||
source_file = translationfiles/templates/oauth2.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:provisioning_api]
|
||||
file_filter = translationfiles/<lang>/provisioning_api.po
|
||||
source_file = translationfiles/templates/provisioning_api.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:settings-1]
|
||||
file_filter = translationfiles/<lang>/settings.po
|
||||
source_file = translationfiles/templates/settings.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:sharebymail]
|
||||
file_filter = translationfiles/<lang>/sharebymail.po
|
||||
source_file = translationfiles/templates/sharebymail.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:systemtags]
|
||||
file_filter = translationfiles/<lang>/systemtags.po
|
||||
source_file = translationfiles/templates/systemtags.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:theming]
|
||||
file_filter = translationfiles/<lang>/theming.po
|
||||
source_file = translationfiles/templates/theming.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:twofactor_backupcodes]
|
||||
file_filter = translationfiles/<lang>/twofactor_backupcodes.po
|
||||
source_file = translationfiles/templates/twofactor_backupcodes.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:updatenotification]
|
||||
file_filter = translationfiles/<lang>/updatenotification.po
|
||||
source_file = translationfiles/templates/updatenotification.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:user_ldap]
|
||||
file_filter = translationfiles/<lang>/user_ldap.po
|
||||
source_file = translationfiles/templates/user_ldap.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:user_status]
|
||||
file_filter = translationfiles/<lang>/user_status.po
|
||||
source_file = translationfiles/templates/user_status.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:weather_status]
|
||||
file_filter = translationfiles/<lang>/weather_status.po
|
||||
source_file = translationfiles/templates/weather_status.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
|
||||
[o:nextcloud:p:nextcloud:r:workflowengine]
|
||||
file_filter = translationfiles/<lang>/workflowengine.po
|
||||
source_file = translationfiles/templates/workflowengine.pot
|
||||
source_lang = en
|
||||
type = PO
|
||||
@@ -1,4 +0,0 @@
|
||||
mbstring.func_overload=0
|
||||
always_populate_raw_post_data=-1
|
||||
default_charset='UTF-8'
|
||||
output_buffering=0
|
||||
-1
Submodule 3rdparty deleted from 4d76956947
Vendored
+1954
File diff suppressed because it is too large
Load Diff
Vendored
+251
@@ -0,0 +1,251 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2003 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available through the world-wide-web at the following url: |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Andrei Zmievski <andrei@php.net> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id: Getopt.php,v 1.21.4.7 2003/12/05 21:57:01 andrei Exp $
|
||||
|
||||
require_once( 'PEAR.php');
|
||||
|
||||
/**
|
||||
* Command-line options parsing class.
|
||||
*
|
||||
* @author Andrei Zmievski <andrei@php.net>
|
||||
*
|
||||
*/
|
||||
class Console_Getopt {
|
||||
/**
|
||||
* Parses the command-line options.
|
||||
*
|
||||
* The first parameter to this function should be the list of command-line
|
||||
* arguments without the leading reference to the running program.
|
||||
*
|
||||
* The second parameter is a string of allowed short options. Each of the
|
||||
* option letters can be followed by a colon ':' to specify that the option
|
||||
* requires an argument, or a double colon '::' to specify that the option
|
||||
* takes an optional argument.
|
||||
*
|
||||
* The third argument is an optional array of allowed long options. The
|
||||
* leading '--' should not be included in the option name. Options that
|
||||
* require an argument should be followed by '=', and options that take an
|
||||
* option argument should be followed by '=='.
|
||||
*
|
||||
* The return value is an array of two elements: the list of parsed
|
||||
* options and the list of non-option command-line arguments. Each entry in
|
||||
* the list of parsed options is a pair of elements - the first one
|
||||
* specifies the option, and the second one specifies the option argument,
|
||||
* if there was one.
|
||||
*
|
||||
* Long and short options can be mixed.
|
||||
*
|
||||
* Most of the semantics of this function are based on GNU getopt_long().
|
||||
*
|
||||
* @param array $args an array of command-line arguments
|
||||
* @param string $short_options specifies the list of allowed short options
|
||||
* @param array $long_options specifies the list of allowed long options
|
||||
*
|
||||
* @return array two-element array containing the list of parsed options and
|
||||
* the non-option arguments
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
*/
|
||||
function getopt2($args, $short_options, $long_options = null)
|
||||
{
|
||||
return Console_Getopt::doGetopt(2, $args, $short_options, $long_options);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function expects $args to start with the script name (POSIX-style).
|
||||
* Preserved for backwards compatibility.
|
||||
* @see getopt2()
|
||||
*/
|
||||
function getopt($args, $short_options, $long_options = null)
|
||||
{
|
||||
return Console_Getopt::doGetopt(1, $args, $short_options, $long_options);
|
||||
}
|
||||
|
||||
/**
|
||||
* The actual implementation of the argument parsing code.
|
||||
*/
|
||||
function doGetopt($version, $args, $short_options, $long_options = null)
|
||||
{
|
||||
// in case you pass directly readPHPArgv() as the first arg
|
||||
if (PEAR::isError($args)) {
|
||||
return $args;
|
||||
}
|
||||
if (empty($args)) {
|
||||
return array(array(), array());
|
||||
}
|
||||
$opts = array();
|
||||
$non_opts = array();
|
||||
|
||||
settype($args, 'array');
|
||||
|
||||
if ($long_options) {
|
||||
sort($long_options);
|
||||
}
|
||||
|
||||
/*
|
||||
* Preserve backwards compatibility with callers that relied on
|
||||
* erroneous POSIX fix.
|
||||
*/
|
||||
if ($version < 2) {
|
||||
if (isset($args[0]{0}) && $args[0]{0} != '-') {
|
||||
array_shift($args);
|
||||
}
|
||||
}
|
||||
|
||||
reset($args);
|
||||
while (list($i, $arg) = each($args)) {
|
||||
|
||||
/* The special element '--' means explicit end of
|
||||
options. Treat the rest of the arguments as non-options
|
||||
and end the loop. */
|
||||
if ($arg == '--') {
|
||||
$non_opts = array_merge($non_opts, array_slice($args, $i + 1));
|
||||
break;
|
||||
}
|
||||
|
||||
if ($arg{0} != '-' || (strlen($arg) > 1 && $arg{1} == '-' && !$long_options)) {
|
||||
$non_opts = array_merge($non_opts, array_slice($args, $i));
|
||||
break;
|
||||
} elseif (strlen($arg) > 1 && $arg{1} == '-') {
|
||||
$error = Console_Getopt::_parseLongOption(substr($arg, 2), $long_options, $opts, $args);
|
||||
if (PEAR::isError($error))
|
||||
return $error;
|
||||
} else {
|
||||
$error = Console_Getopt::_parseShortOption(substr($arg, 1), $short_options, $opts, $args);
|
||||
if (PEAR::isError($error))
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
|
||||
return array($opts, $non_opts);
|
||||
}
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*
|
||||
*/
|
||||
function _parseShortOption($arg, $short_options, &$opts, &$args)
|
||||
{
|
||||
for ($i = 0; $i < strlen($arg); $i++) {
|
||||
$opt = $arg{$i};
|
||||
$opt_arg = null;
|
||||
|
||||
/* Try to find the short option in the specifier string. */
|
||||
if (($spec = strstr($short_options, $opt)) === false || $arg{$i} == ':')
|
||||
{
|
||||
return PEAR::raiseError("Console_Getopt: unrecognized option -- $opt");
|
||||
}
|
||||
|
||||
if (strlen($spec) > 1 && $spec{1} == ':') {
|
||||
if (strlen($spec) > 2 && $spec{2} == ':') {
|
||||
if ($i + 1 < strlen($arg)) {
|
||||
/* Option takes an optional argument. Use the remainder of
|
||||
the arg string if there is anything left. */
|
||||
$opts[] = array($opt, substr($arg, $i + 1));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* Option requires an argument. Use the remainder of the arg
|
||||
string if there is anything left. */
|
||||
if ($i + 1 < strlen($arg)) {
|
||||
$opts[] = array($opt, substr($arg, $i + 1));
|
||||
break;
|
||||
} else if (list(, $opt_arg) = each($args))
|
||||
/* Else use the next argument. */;
|
||||
else
|
||||
return PEAR::raiseError("Console_Getopt: option requires an argument -- $opt");
|
||||
}
|
||||
}
|
||||
|
||||
$opts[] = array($opt, $opt_arg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*
|
||||
*/
|
||||
function _parseLongOption($arg, $long_options, &$opts, &$args)
|
||||
{
|
||||
@list($opt, $opt_arg) = explode('=', $arg);
|
||||
$opt_len = strlen($opt);
|
||||
|
||||
for ($i = 0; $i < count($long_options); $i++) {
|
||||
$long_opt = $long_options[$i];
|
||||
$opt_start = substr($long_opt, 0, $opt_len);
|
||||
|
||||
/* Option doesn't match. Go on to the next one. */
|
||||
if ($opt_start != $opt)
|
||||
continue;
|
||||
|
||||
$opt_rest = substr($long_opt, $opt_len);
|
||||
|
||||
/* Check that the options uniquely matches one of the allowed
|
||||
options. */
|
||||
if ($opt_rest != '' && $opt{0} != '=' &&
|
||||
$i + 1 < count($long_options) &&
|
||||
$opt == substr($long_options[$i+1], 0, $opt_len)) {
|
||||
return PEAR::raiseError("Console_Getopt: option --$opt is ambiguous");
|
||||
}
|
||||
|
||||
if (substr($long_opt, -1) == '=') {
|
||||
if (substr($long_opt, -2) != '==') {
|
||||
/* Long option requires an argument.
|
||||
Take the next argument if one wasn't specified. */;
|
||||
if (!strlen($opt_arg) && !(list(, $opt_arg) = each($args))) {
|
||||
return PEAR::raiseError("Console_Getopt: option --$opt requires an argument");
|
||||
}
|
||||
}
|
||||
} else if ($opt_arg) {
|
||||
return PEAR::raiseError("Console_Getopt: option --$opt doesn't allow an argument");
|
||||
}
|
||||
|
||||
$opts[] = array('--' . $opt, $opt_arg);
|
||||
return;
|
||||
}
|
||||
|
||||
return PEAR::raiseError("Console_Getopt: unrecognized option --$opt");
|
||||
}
|
||||
|
||||
/**
|
||||
* Safely read the $argv PHP array across different PHP configurations.
|
||||
* Will take care on register_globals and register_argc_argv ini directives
|
||||
*
|
||||
* @access public
|
||||
* @return mixed the $argv PHP array or PEAR error if not registered
|
||||
*/
|
||||
function readPHPArgv()
|
||||
{
|
||||
global $argv;
|
||||
if (!is_array($argv)) {
|
||||
if (!@is_array($_SERVER['argv'])) {
|
||||
if (!@is_array($GLOBALS['HTTP_SERVER_VARS']['argv'])) {
|
||||
return PEAR::raiseError("Console_Getopt: Could not read cmd args (register_argc_argv=Off?)");
|
||||
}
|
||||
return $GLOBALS['HTTP_SERVER_VARS']['argv'];
|
||||
}
|
||||
return $_SERVER['argv'];
|
||||
}
|
||||
return $argv;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Vendored
+317
@@ -0,0 +1,317 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Crypt_Blowfish allows for encryption and decryption on the fly using
|
||||
* the Blowfish algorithm. Crypt_Blowfish does not require the mcrypt
|
||||
* PHP extension, it uses only PHP.
|
||||
* Crypt_Blowfish support encryption/decryption with or without a secret key.
|
||||
*
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.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 Encryption
|
||||
* @package Crypt_Blowfish
|
||||
* @author Matthew Fonda <mfonda@php.net>
|
||||
* @copyright 2005 Matthew Fonda
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: Blowfish.php,v 1.81 2005/05/30 18:40:36 mfonda Exp $
|
||||
* @link http://pear.php.net/package/Crypt_Blowfish
|
||||
*/
|
||||
|
||||
|
||||
require_once 'PEAR.php';
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Example usage:
|
||||
* $bf = new Crypt_Blowfish('some secret key!');
|
||||
* $encrypted = $bf->encrypt('this is some example plain text');
|
||||
* $plaintext = $bf->decrypt($encrypted);
|
||||
* echo "plain text: $plaintext";
|
||||
*
|
||||
*
|
||||
* @category Encryption
|
||||
* @package Crypt_Blowfish
|
||||
* @author Matthew Fonda <mfonda@php.net>
|
||||
* @copyright 2005 Matthew Fonda
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @link http://pear.php.net/package/Crypt_Blowfish
|
||||
* @version @package_version@
|
||||
* @access public
|
||||
*/
|
||||
class Crypt_Blowfish
|
||||
{
|
||||
/**
|
||||
* P-Array contains 18 32-bit subkeys
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_P = array();
|
||||
|
||||
|
||||
/**
|
||||
* Array of four S-Blocks each containing 256 32-bit entries
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_S = array();
|
||||
|
||||
/**
|
||||
* Mcrypt td resource
|
||||
*
|
||||
* @var resource
|
||||
* @access private
|
||||
*/
|
||||
var $_td = null;
|
||||
|
||||
/**
|
||||
* Initialization vector
|
||||
*
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $_iv = null;
|
||||
|
||||
|
||||
/**
|
||||
* Crypt_Blowfish Constructor
|
||||
* Initializes the Crypt_Blowfish object, and gives a sets
|
||||
* the secret key
|
||||
*
|
||||
* @param string $key
|
||||
* @access public
|
||||
*/
|
||||
function Crypt_Blowfish($key)
|
||||
{
|
||||
if (extension_loaded('mcrypt')) {
|
||||
$this->_td = mcrypt_module_open(MCRYPT_BLOWFISH, '', 'ecb', '');
|
||||
$this->_iv = mcrypt_create_iv(8, MCRYPT_RAND);
|
||||
}
|
||||
$this->setKey($key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated isReady method
|
||||
*
|
||||
* @return bool
|
||||
* @access public
|
||||
* @deprecated
|
||||
*/
|
||||
function isReady()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated init method - init is now a private
|
||||
* method and has been replaced with _init
|
||||
*
|
||||
* @return bool
|
||||
* @access public
|
||||
* @deprecated
|
||||
* @see Crypt_Blowfish::_init()
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
$this->_init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the Crypt_Blowfish object
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function _init()
|
||||
{
|
||||
$defaults = new Crypt_Blowfish_DefaultKey();
|
||||
$this->_P = $defaults->P;
|
||||
$this->_S = $defaults->S;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enciphers a single 64 bit block
|
||||
*
|
||||
* @param int &$Xl
|
||||
* @param int &$Xr
|
||||
* @access private
|
||||
*/
|
||||
function _encipher(&$Xl, &$Xr)
|
||||
{
|
||||
for ($i = 0; $i < 16; $i++) {
|
||||
$temp = $Xl ^ $this->_P[$i];
|
||||
$Xl = ((($this->_S[0][($temp>>24) & 255] +
|
||||
$this->_S[1][($temp>>16) & 255]) ^
|
||||
$this->_S[2][($temp>>8) & 255]) +
|
||||
$this->_S[3][$temp & 255]) ^ $Xr;
|
||||
$Xr = $temp;
|
||||
}
|
||||
$Xr = $Xl ^ $this->_P[16];
|
||||
$Xl = $temp ^ $this->_P[17];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deciphers a single 64 bit block
|
||||
*
|
||||
* @param int &$Xl
|
||||
* @param int &$Xr
|
||||
* @access private
|
||||
*/
|
||||
function _decipher(&$Xl, &$Xr)
|
||||
{
|
||||
for ($i = 17; $i > 1; $i--) {
|
||||
$temp = $Xl ^ $this->_P[$i];
|
||||
$Xl = ((($this->_S[0][($temp>>24) & 255] +
|
||||
$this->_S[1][($temp>>16) & 255]) ^
|
||||
$this->_S[2][($temp>>8) & 255]) +
|
||||
$this->_S[3][$temp & 255]) ^ $Xr;
|
||||
$Xr = $temp;
|
||||
}
|
||||
$Xr = $Xl ^ $this->_P[1];
|
||||
$Xl = $temp ^ $this->_P[0];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Encrypts a string
|
||||
*
|
||||
* @param string $plainText
|
||||
* @return string Returns cipher text on success, PEAR_Error on failure
|
||||
* @access public
|
||||
*/
|
||||
function encrypt($plainText)
|
||||
{
|
||||
if (!is_string($plainText)) {
|
||||
PEAR::raiseError('Plain text must be a string', 0, PEAR_ERROR_DIE);
|
||||
}
|
||||
|
||||
if (extension_loaded('mcrypt')) {
|
||||
return mcrypt_generic($this->_td, $plainText);
|
||||
}
|
||||
|
||||
$cipherText = '';
|
||||
$len = strlen($plainText);
|
||||
$plainText .= str_repeat(chr(0),(8 - ($len%8))%8);
|
||||
for ($i = 0; $i < $len; $i += 8) {
|
||||
list(,$Xl,$Xr) = unpack("N2",substr($plainText,$i,8));
|
||||
$this->_encipher($Xl, $Xr);
|
||||
$cipherText .= pack("N2", $Xl, $Xr);
|
||||
}
|
||||
return $cipherText;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Decrypts an encrypted string
|
||||
*
|
||||
* @param string $cipherText
|
||||
* @return string Returns plain text on success, PEAR_Error on failure
|
||||
* @access public
|
||||
*/
|
||||
function decrypt($cipherText)
|
||||
{
|
||||
if (!is_string($cipherText)) {
|
||||
PEAR::raiseError('Cipher text must be a string', 1, PEAR_ERROR_DIE);
|
||||
}
|
||||
|
||||
if (extension_loaded('mcrypt')) {
|
||||
return mdecrypt_generic($this->_td, $cipherText);
|
||||
}
|
||||
|
||||
$plainText = '';
|
||||
$len = strlen($cipherText);
|
||||
$cipherText .= str_repeat(chr(0),(8 - ($len%8))%8);
|
||||
for ($i = 0; $i < $len; $i += 8) {
|
||||
list(,$Xl,$Xr) = unpack("N2",substr($cipherText,$i,8));
|
||||
$this->_decipher($Xl, $Xr);
|
||||
$plainText .= pack("N2", $Xl, $Xr);
|
||||
}
|
||||
return $plainText;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the secret key
|
||||
* The key must be non-zero, and less than or equal to
|
||||
* 56 characters in length.
|
||||
*
|
||||
* @param string $key
|
||||
* @return bool Returns true on success, PEAR_Error on failure
|
||||
* @access public
|
||||
*/
|
||||
function setKey($key)
|
||||
{
|
||||
if (!is_string($key)) {
|
||||
PEAR::raiseError('Key must be a string', 2, PEAR_ERROR_DIE);
|
||||
}
|
||||
|
||||
$len = strlen($key);
|
||||
|
||||
if ($len > 56 || $len == 0) {
|
||||
PEAR::raiseError('Key must be less than 56 characters and non-zero. Supplied key length: ' . $len, 3, PEAR_ERROR_DIE);
|
||||
}
|
||||
|
||||
if (extension_loaded('mcrypt')) {
|
||||
mcrypt_generic_init($this->_td, $key, $this->_iv);
|
||||
return true;
|
||||
}
|
||||
|
||||
require_once 'Blowfish/DefaultKey.php';
|
||||
$this->_init();
|
||||
|
||||
$k = 0;
|
||||
$data = 0;
|
||||
$datal = 0;
|
||||
$datar = 0;
|
||||
|
||||
for ($i = 0; $i < 18; $i++) {
|
||||
$data = 0;
|
||||
for ($j = 4; $j > 0; $j--) {
|
||||
$data = $data << 8 | ord($key{$k});
|
||||
$k = ($k+1) % $len;
|
||||
}
|
||||
$this->_P[$i] ^= $data;
|
||||
}
|
||||
|
||||
for ($i = 0; $i <= 16; $i += 2) {
|
||||
$this->_encipher($datal, $datar);
|
||||
$this->_P[$i] = $datal;
|
||||
$this->_P[$i+1] = $datar;
|
||||
}
|
||||
for ($i = 0; $i < 256; $i += 2) {
|
||||
$this->_encipher($datal, $datar);
|
||||
$this->_S[0][$i] = $datal;
|
||||
$this->_S[0][$i+1] = $datar;
|
||||
}
|
||||
for ($i = 0; $i < 256; $i += 2) {
|
||||
$this->_encipher($datal, $datar);
|
||||
$this->_S[1][$i] = $datal;
|
||||
$this->_S[1][$i+1] = $datar;
|
||||
}
|
||||
for ($i = 0; $i < 256; $i += 2) {
|
||||
$this->_encipher($datal, $datar);
|
||||
$this->_S[2][$i] = $datal;
|
||||
$this->_S[2][$i+1] = $datar;
|
||||
}
|
||||
for ($i = 0; $i < 256; $i += 2) {
|
||||
$this->_encipher($datal, $datar);
|
||||
$this->_S[3][$i] = $datal;
|
||||
$this->_S[3][$i+1] = $datar;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
+327
@@ -0,0 +1,327 @@
|
||||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Crypt_Blowfish allows for encryption and decryption on the fly using
|
||||
* the Blowfish algorithm. Crypt_Blowfish does not require the mcrypt
|
||||
* PHP extension, it uses only PHP.
|
||||
* Crypt_Blowfish support encryption/decryption with or without a secret key.
|
||||
*
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* LICENSE: This source file is subject to version 3.0 of the PHP license
|
||||
* that is available through the world-wide-web at the following URI:
|
||||
* http://www.php.net/license/3_0.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 Encryption
|
||||
* @package Crypt_Blowfish
|
||||
* @author Matthew Fonda <mfonda@php.net>
|
||||
* @copyright 2005 Matthew Fonda
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @version CVS: $Id: DefaultKey.php,v 1.81 2005/05/30 18:40:37 mfonda Exp $
|
||||
* @link http://pear.php.net/package/Crypt_Blowfish
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class containing default key
|
||||
*
|
||||
* @category Encryption
|
||||
* @package Crypt_Blowfish
|
||||
* @author Matthew Fonda <mfonda@php.net>
|
||||
* @copyright 2005 Matthew Fonda
|
||||
* @license http://www.php.net/license/3_0.txt PHP License 3.0
|
||||
* @link http://pear.php.net/package/Crypt_Blowfish
|
||||
* @version @package_version@
|
||||
* @access public
|
||||
*/
|
||||
class Crypt_Blowfish_DefaultKey
|
||||
{
|
||||
var $P = array();
|
||||
|
||||
var $S = array();
|
||||
|
||||
function Crypt_Blowfish_DefaultKey()
|
||||
{
|
||||
$this->P = array(
|
||||
0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344,
|
||||
0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89,
|
||||
0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
|
||||
0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917,
|
||||
0x9216D5D9, 0x8979FB1B
|
||||
);
|
||||
|
||||
$this->S = array(
|
||||
array(
|
||||
0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7,
|
||||
0xB8E1AFED, 0x6A267E96, 0xBA7C9045, 0xF12C7F99,
|
||||
0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16,
|
||||
0x636920D8, 0x71574E69, 0xA458FEA3, 0xF4933D7E,
|
||||
0x0D95748F, 0x728EB658, 0x718BCD58, 0x82154AEE,
|
||||
0x7B54A41D, 0xC25A59B5, 0x9C30D539, 0x2AF26013,
|
||||
0xC5D1B023, 0x286085F0, 0xCA417918, 0xB8DB38EF,
|
||||
0x8E79DCB0, 0x603A180E, 0x6C9E0E8B, 0xB01E8A3E,
|
||||
0xD71577C1, 0xBD314B27, 0x78AF2FDA, 0x55605C60,
|
||||
0xE65525F3, 0xAA55AB94, 0x57489862, 0x63E81440,
|
||||
0x55CA396A, 0x2AAB10B6, 0xB4CC5C34, 0x1141E8CE,
|
||||
0xA15486AF, 0x7C72E993, 0xB3EE1411, 0x636FBC2A,
|
||||
0x2BA9C55D, 0x741831F6, 0xCE5C3E16, 0x9B87931E,
|
||||
0xAFD6BA33, 0x6C24CF5C, 0x7A325381, 0x28958677,
|
||||
0x3B8F4898, 0x6B4BB9AF, 0xC4BFE81B, 0x66282193,
|
||||
0x61D809CC, 0xFB21A991, 0x487CAC60, 0x5DEC8032,
|
||||
0xEF845D5D, 0xE98575B1, 0xDC262302, 0xEB651B88,
|
||||
0x23893E81, 0xD396ACC5, 0x0F6D6FF3, 0x83F44239,
|
||||
0x2E0B4482, 0xA4842004, 0x69C8F04A, 0x9E1F9B5E,
|
||||
0x21C66842, 0xF6E96C9A, 0x670C9C61, 0xABD388F0,
|
||||
0x6A51A0D2, 0xD8542F68, 0x960FA728, 0xAB5133A3,
|
||||
0x6EEF0B6C, 0x137A3BE4, 0xBA3BF050, 0x7EFB2A98,
|
||||
0xA1F1651D, 0x39AF0176, 0x66CA593E, 0x82430E88,
|
||||
0x8CEE8619, 0x456F9FB4, 0x7D84A5C3, 0x3B8B5EBE,
|
||||
0xE06F75D8, 0x85C12073, 0x401A449F, 0x56C16AA6,
|
||||
0x4ED3AA62, 0x363F7706, 0x1BFEDF72, 0x429B023D,
|
||||
0x37D0D724, 0xD00A1248, 0xDB0FEAD3, 0x49F1C09B,
|
||||
0x075372C9, 0x80991B7B, 0x25D479D8, 0xF6E8DEF7,
|
||||
0xE3FE501A, 0xB6794C3B, 0x976CE0BD, 0x04C006BA,
|
||||
0xC1A94FB6, 0x409F60C4, 0x5E5C9EC2, 0x196A2463,
|
||||
0x68FB6FAF, 0x3E6C53B5, 0x1339B2EB, 0x3B52EC6F,
|
||||
0x6DFC511F, 0x9B30952C, 0xCC814544, 0xAF5EBD09,
|
||||
0xBEE3D004, 0xDE334AFD, 0x660F2807, 0x192E4BB3,
|
||||
0xC0CBA857, 0x45C8740F, 0xD20B5F39, 0xB9D3FBDB,
|
||||
0x5579C0BD, 0x1A60320A, 0xD6A100C6, 0x402C7279,
|
||||
0x679F25FE, 0xFB1FA3CC, 0x8EA5E9F8, 0xDB3222F8,
|
||||
0x3C7516DF, 0xFD616B15, 0x2F501EC8, 0xAD0552AB,
|
||||
0x323DB5FA, 0xFD238760, 0x53317B48, 0x3E00DF82,
|
||||
0x9E5C57BB, 0xCA6F8CA0, 0x1A87562E, 0xDF1769DB,
|
||||
0xD542A8F6, 0x287EFFC3, 0xAC6732C6, 0x8C4F5573,
|
||||
0x695B27B0, 0xBBCA58C8, 0xE1FFA35D, 0xB8F011A0,
|
||||
0x10FA3D98, 0xFD2183B8, 0x4AFCB56C, 0x2DD1D35B,
|
||||
0x9A53E479, 0xB6F84565, 0xD28E49BC, 0x4BFB9790,
|
||||
0xE1DDF2DA, 0xA4CB7E33, 0x62FB1341, 0xCEE4C6E8,
|
||||
0xEF20CADA, 0x36774C01, 0xD07E9EFE, 0x2BF11FB4,
|
||||
0x95DBDA4D, 0xAE909198, 0xEAAD8E71, 0x6B93D5A0,
|
||||
0xD08ED1D0, 0xAFC725E0, 0x8E3C5B2F, 0x8E7594B7,
|
||||
0x8FF6E2FB, 0xF2122B64, 0x8888B812, 0x900DF01C,
|
||||
0x4FAD5EA0, 0x688FC31C, 0xD1CFF191, 0xB3A8C1AD,
|
||||
0x2F2F2218, 0xBE0E1777, 0xEA752DFE, 0x8B021FA1,
|
||||
0xE5A0CC0F, 0xB56F74E8, 0x18ACF3D6, 0xCE89E299,
|
||||
0xB4A84FE0, 0xFD13E0B7, 0x7CC43B81, 0xD2ADA8D9,
|
||||
0x165FA266, 0x80957705, 0x93CC7314, 0x211A1477,
|
||||
0xE6AD2065, 0x77B5FA86, 0xC75442F5, 0xFB9D35CF,
|
||||
0xEBCDAF0C, 0x7B3E89A0, 0xD6411BD3, 0xAE1E7E49,
|
||||
0x00250E2D, 0x2071B35E, 0x226800BB, 0x57B8E0AF,
|
||||
0x2464369B, 0xF009B91E, 0x5563911D, 0x59DFA6AA,
|
||||
0x78C14389, 0xD95A537F, 0x207D5BA2, 0x02E5B9C5,
|
||||
0x83260376, 0x6295CFA9, 0x11C81968, 0x4E734A41,
|
||||
0xB3472DCA, 0x7B14A94A, 0x1B510052, 0x9A532915,
|
||||
0xD60F573F, 0xBC9BC6E4, 0x2B60A476, 0x81E67400,
|
||||
0x08BA6FB5, 0x571BE91F, 0xF296EC6B, 0x2A0DD915,
|
||||
0xB6636521, 0xE7B9F9B6, 0xFF34052E, 0xC5855664,
|
||||
0x53B02D5D, 0xA99F8FA1, 0x08BA4799, 0x6E85076A
|
||||
),
|
||||
array(
|
||||
0x4B7A70E9, 0xB5B32944, 0xDB75092E, 0xC4192623,
|
||||
0xAD6EA6B0, 0x49A7DF7D, 0x9CEE60B8, 0x8FEDB266,
|
||||
0xECAA8C71, 0x699A17FF, 0x5664526C, 0xC2B19EE1,
|
||||
0x193602A5, 0x75094C29, 0xA0591340, 0xE4183A3E,
|
||||
0x3F54989A, 0x5B429D65, 0x6B8FE4D6, 0x99F73FD6,
|
||||
0xA1D29C07, 0xEFE830F5, 0x4D2D38E6, 0xF0255DC1,
|
||||
0x4CDD2086, 0x8470EB26, 0x6382E9C6, 0x021ECC5E,
|
||||
0x09686B3F, 0x3EBAEFC9, 0x3C971814, 0x6B6A70A1,
|
||||
0x687F3584, 0x52A0E286, 0xB79C5305, 0xAA500737,
|
||||
0x3E07841C, 0x7FDEAE5C, 0x8E7D44EC, 0x5716F2B8,
|
||||
0xB03ADA37, 0xF0500C0D, 0xF01C1F04, 0x0200B3FF,
|
||||
0xAE0CF51A, 0x3CB574B2, 0x25837A58, 0xDC0921BD,
|
||||
0xD19113F9, 0x7CA92FF6, 0x94324773, 0x22F54701,
|
||||
0x3AE5E581, 0x37C2DADC, 0xC8B57634, 0x9AF3DDA7,
|
||||
0xA9446146, 0x0FD0030E, 0xECC8C73E, 0xA4751E41,
|
||||
0xE238CD99, 0x3BEA0E2F, 0x3280BBA1, 0x183EB331,
|
||||
0x4E548B38, 0x4F6DB908, 0x6F420D03, 0xF60A04BF,
|
||||
0x2CB81290, 0x24977C79, 0x5679B072, 0xBCAF89AF,
|
||||
0xDE9A771F, 0xD9930810, 0xB38BAE12, 0xDCCF3F2E,
|
||||
0x5512721F, 0x2E6B7124, 0x501ADDE6, 0x9F84CD87,
|
||||
0x7A584718, 0x7408DA17, 0xBC9F9ABC, 0xE94B7D8C,
|
||||
0xEC7AEC3A, 0xDB851DFA, 0x63094366, 0xC464C3D2,
|
||||
0xEF1C1847, 0x3215D908, 0xDD433B37, 0x24C2BA16,
|
||||
0x12A14D43, 0x2A65C451, 0x50940002, 0x133AE4DD,
|
||||
0x71DFF89E, 0x10314E55, 0x81AC77D6, 0x5F11199B,
|
||||
0x043556F1, 0xD7A3C76B, 0x3C11183B, 0x5924A509,
|
||||
0xF28FE6ED, 0x97F1FBFA, 0x9EBABF2C, 0x1E153C6E,
|
||||
0x86E34570, 0xEAE96FB1, 0x860E5E0A, 0x5A3E2AB3,
|
||||
0x771FE71C, 0x4E3D06FA, 0x2965DCB9, 0x99E71D0F,
|
||||
0x803E89D6, 0x5266C825, 0x2E4CC978, 0x9C10B36A,
|
||||
0xC6150EBA, 0x94E2EA78, 0xA5FC3C53, 0x1E0A2DF4,
|
||||
0xF2F74EA7, 0x361D2B3D, 0x1939260F, 0x19C27960,
|
||||
0x5223A708, 0xF71312B6, 0xEBADFE6E, 0xEAC31F66,
|
||||
0xE3BC4595, 0xA67BC883, 0xB17F37D1, 0x018CFF28,
|
||||
0xC332DDEF, 0xBE6C5AA5, 0x65582185, 0x68AB9802,
|
||||
0xEECEA50F, 0xDB2F953B, 0x2AEF7DAD, 0x5B6E2F84,
|
||||
0x1521B628, 0x29076170, 0xECDD4775, 0x619F1510,
|
||||
0x13CCA830, 0xEB61BD96, 0x0334FE1E, 0xAA0363CF,
|
||||
0xB5735C90, 0x4C70A239, 0xD59E9E0B, 0xCBAADE14,
|
||||
0xEECC86BC, 0x60622CA7, 0x9CAB5CAB, 0xB2F3846E,
|
||||
0x648B1EAF, 0x19BDF0CA, 0xA02369B9, 0x655ABB50,
|
||||
0x40685A32, 0x3C2AB4B3, 0x319EE9D5, 0xC021B8F7,
|
||||
0x9B540B19, 0x875FA099, 0x95F7997E, 0x623D7DA8,
|
||||
0xF837889A, 0x97E32D77, 0x11ED935F, 0x16681281,
|
||||
0x0E358829, 0xC7E61FD6, 0x96DEDFA1, 0x7858BA99,
|
||||
0x57F584A5, 0x1B227263, 0x9B83C3FF, 0x1AC24696,
|
||||
0xCDB30AEB, 0x532E3054, 0x8FD948E4, 0x6DBC3128,
|
||||
0x58EBF2EF, 0x34C6FFEA, 0xFE28ED61, 0xEE7C3C73,
|
||||
0x5D4A14D9, 0xE864B7E3, 0x42105D14, 0x203E13E0,
|
||||
0x45EEE2B6, 0xA3AAABEA, 0xDB6C4F15, 0xFACB4FD0,
|
||||
0xC742F442, 0xEF6ABBB5, 0x654F3B1D, 0x41CD2105,
|
||||
0xD81E799E, 0x86854DC7, 0xE44B476A, 0x3D816250,
|
||||
0xCF62A1F2, 0x5B8D2646, 0xFC8883A0, 0xC1C7B6A3,
|
||||
0x7F1524C3, 0x69CB7492, 0x47848A0B, 0x5692B285,
|
||||
0x095BBF00, 0xAD19489D, 0x1462B174, 0x23820E00,
|
||||
0x58428D2A, 0x0C55F5EA, 0x1DADF43E, 0x233F7061,
|
||||
0x3372F092, 0x8D937E41, 0xD65FECF1, 0x6C223BDB,
|
||||
0x7CDE3759, 0xCBEE7460, 0x4085F2A7, 0xCE77326E,
|
||||
0xA6078084, 0x19F8509E, 0xE8EFD855, 0x61D99735,
|
||||
0xA969A7AA, 0xC50C06C2, 0x5A04ABFC, 0x800BCADC,
|
||||
0x9E447A2E, 0xC3453484, 0xFDD56705, 0x0E1E9EC9,
|
||||
0xDB73DBD3, 0x105588CD, 0x675FDA79, 0xE3674340,
|
||||
0xC5C43465, 0x713E38D8, 0x3D28F89E, 0xF16DFF20,
|
||||
0x153E21E7, 0x8FB03D4A, 0xE6E39F2B, 0xDB83ADF7
|
||||
),
|
||||
array(
|
||||
0xE93D5A68, 0x948140F7, 0xF64C261C, 0x94692934,
|
||||
0x411520F7, 0x7602D4F7, 0xBCF46B2E, 0xD4A20068,
|
||||
0xD4082471, 0x3320F46A, 0x43B7D4B7, 0x500061AF,
|
||||
0x1E39F62E, 0x97244546, 0x14214F74, 0xBF8B8840,
|
||||
0x4D95FC1D, 0x96B591AF, 0x70F4DDD3, 0x66A02F45,
|
||||
0xBFBC09EC, 0x03BD9785, 0x7FAC6DD0, 0x31CB8504,
|
||||
0x96EB27B3, 0x55FD3941, 0xDA2547E6, 0xABCA0A9A,
|
||||
0x28507825, 0x530429F4, 0x0A2C86DA, 0xE9B66DFB,
|
||||
0x68DC1462, 0xD7486900, 0x680EC0A4, 0x27A18DEE,
|
||||
0x4F3FFEA2, 0xE887AD8C, 0xB58CE006, 0x7AF4D6B6,
|
||||
0xAACE1E7C, 0xD3375FEC, 0xCE78A399, 0x406B2A42,
|
||||
0x20FE9E35, 0xD9F385B9, 0xEE39D7AB, 0x3B124E8B,
|
||||
0x1DC9FAF7, 0x4B6D1856, 0x26A36631, 0xEAE397B2,
|
||||
0x3A6EFA74, 0xDD5B4332, 0x6841E7F7, 0xCA7820FB,
|
||||
0xFB0AF54E, 0xD8FEB397, 0x454056AC, 0xBA489527,
|
||||
0x55533A3A, 0x20838D87, 0xFE6BA9B7, 0xD096954B,
|
||||
0x55A867BC, 0xA1159A58, 0xCCA92963, 0x99E1DB33,
|
||||
0xA62A4A56, 0x3F3125F9, 0x5EF47E1C, 0x9029317C,
|
||||
0xFDF8E802, 0x04272F70, 0x80BB155C, 0x05282CE3,
|
||||
0x95C11548, 0xE4C66D22, 0x48C1133F, 0xC70F86DC,
|
||||
0x07F9C9EE, 0x41041F0F, 0x404779A4, 0x5D886E17,
|
||||
0x325F51EB, 0xD59BC0D1, 0xF2BCC18F, 0x41113564,
|
||||
0x257B7834, 0x602A9C60, 0xDFF8E8A3, 0x1F636C1B,
|
||||
0x0E12B4C2, 0x02E1329E, 0xAF664FD1, 0xCAD18115,
|
||||
0x6B2395E0, 0x333E92E1, 0x3B240B62, 0xEEBEB922,
|
||||
0x85B2A20E, 0xE6BA0D99, 0xDE720C8C, 0x2DA2F728,
|
||||
0xD0127845, 0x95B794FD, 0x647D0862, 0xE7CCF5F0,
|
||||
0x5449A36F, 0x877D48FA, 0xC39DFD27, 0xF33E8D1E,
|
||||
0x0A476341, 0x992EFF74, 0x3A6F6EAB, 0xF4F8FD37,
|
||||
0xA812DC60, 0xA1EBDDF8, 0x991BE14C, 0xDB6E6B0D,
|
||||
0xC67B5510, 0x6D672C37, 0x2765D43B, 0xDCD0E804,
|
||||
0xF1290DC7, 0xCC00FFA3, 0xB5390F92, 0x690FED0B,
|
||||
0x667B9FFB, 0xCEDB7D9C, 0xA091CF0B, 0xD9155EA3,
|
||||
0xBB132F88, 0x515BAD24, 0x7B9479BF, 0x763BD6EB,
|
||||
0x37392EB3, 0xCC115979, 0x8026E297, 0xF42E312D,
|
||||
0x6842ADA7, 0xC66A2B3B, 0x12754CCC, 0x782EF11C,
|
||||
0x6A124237, 0xB79251E7, 0x06A1BBE6, 0x4BFB6350,
|
||||
0x1A6B1018, 0x11CAEDFA, 0x3D25BDD8, 0xE2E1C3C9,
|
||||
0x44421659, 0x0A121386, 0xD90CEC6E, 0xD5ABEA2A,
|
||||
0x64AF674E, 0xDA86A85F, 0xBEBFE988, 0x64E4C3FE,
|
||||
0x9DBC8057, 0xF0F7C086, 0x60787BF8, 0x6003604D,
|
||||
0xD1FD8346, 0xF6381FB0, 0x7745AE04, 0xD736FCCC,
|
||||
0x83426B33, 0xF01EAB71, 0xB0804187, 0x3C005E5F,
|
||||
0x77A057BE, 0xBDE8AE24, 0x55464299, 0xBF582E61,
|
||||
0x4E58F48F, 0xF2DDFDA2, 0xF474EF38, 0x8789BDC2,
|
||||
0x5366F9C3, 0xC8B38E74, 0xB475F255, 0x46FCD9B9,
|
||||
0x7AEB2661, 0x8B1DDF84, 0x846A0E79, 0x915F95E2,
|
||||
0x466E598E, 0x20B45770, 0x8CD55591, 0xC902DE4C,
|
||||
0xB90BACE1, 0xBB8205D0, 0x11A86248, 0x7574A99E,
|
||||
0xB77F19B6, 0xE0A9DC09, 0x662D09A1, 0xC4324633,
|
||||
0xE85A1F02, 0x09F0BE8C, 0x4A99A025, 0x1D6EFE10,
|
||||
0x1AB93D1D, 0x0BA5A4DF, 0xA186F20F, 0x2868F169,
|
||||
0xDCB7DA83, 0x573906FE, 0xA1E2CE9B, 0x4FCD7F52,
|
||||
0x50115E01, 0xA70683FA, 0xA002B5C4, 0x0DE6D027,
|
||||
0x9AF88C27, 0x773F8641, 0xC3604C06, 0x61A806B5,
|
||||
0xF0177A28, 0xC0F586E0, 0x006058AA, 0x30DC7D62,
|
||||
0x11E69ED7, 0x2338EA63, 0x53C2DD94, 0xC2C21634,
|
||||
0xBBCBEE56, 0x90BCB6DE, 0xEBFC7DA1, 0xCE591D76,
|
||||
0x6F05E409, 0x4B7C0188, 0x39720A3D, 0x7C927C24,
|
||||
0x86E3725F, 0x724D9DB9, 0x1AC15BB4, 0xD39EB8FC,
|
||||
0xED545578, 0x08FCA5B5, 0xD83D7CD3, 0x4DAD0FC4,
|
||||
0x1E50EF5E, 0xB161E6F8, 0xA28514D9, 0x6C51133C,
|
||||
0x6FD5C7E7, 0x56E14EC4, 0x362ABFCE, 0xDDC6C837,
|
||||
0xD79A3234, 0x92638212, 0x670EFA8E, 0x406000E0
|
||||
),
|
||||
array(
|
||||
0x3A39CE37, 0xD3FAF5CF, 0xABC27737, 0x5AC52D1B,
|
||||
0x5CB0679E, 0x4FA33742, 0xD3822740, 0x99BC9BBE,
|
||||
0xD5118E9D, 0xBF0F7315, 0xD62D1C7E, 0xC700C47B,
|
||||
0xB78C1B6B, 0x21A19045, 0xB26EB1BE, 0x6A366EB4,
|
||||
0x5748AB2F, 0xBC946E79, 0xC6A376D2, 0x6549C2C8,
|
||||
0x530FF8EE, 0x468DDE7D, 0xD5730A1D, 0x4CD04DC6,
|
||||
0x2939BBDB, 0xA9BA4650, 0xAC9526E8, 0xBE5EE304,
|
||||
0xA1FAD5F0, 0x6A2D519A, 0x63EF8CE2, 0x9A86EE22,
|
||||
0xC089C2B8, 0x43242EF6, 0xA51E03AA, 0x9CF2D0A4,
|
||||
0x83C061BA, 0x9BE96A4D, 0x8FE51550, 0xBA645BD6,
|
||||
0x2826A2F9, 0xA73A3AE1, 0x4BA99586, 0xEF5562E9,
|
||||
0xC72FEFD3, 0xF752F7DA, 0x3F046F69, 0x77FA0A59,
|
||||
0x80E4A915, 0x87B08601, 0x9B09E6AD, 0x3B3EE593,
|
||||
0xE990FD5A, 0x9E34D797, 0x2CF0B7D9, 0x022B8B51,
|
||||
0x96D5AC3A, 0x017DA67D, 0xD1CF3ED6, 0x7C7D2D28,
|
||||
0x1F9F25CF, 0xADF2B89B, 0x5AD6B472, 0x5A88F54C,
|
||||
0xE029AC71, 0xE019A5E6, 0x47B0ACFD, 0xED93FA9B,
|
||||
0xE8D3C48D, 0x283B57CC, 0xF8D56629, 0x79132E28,
|
||||
0x785F0191, 0xED756055, 0xF7960E44, 0xE3D35E8C,
|
||||
0x15056DD4, 0x88F46DBA, 0x03A16125, 0x0564F0BD,
|
||||
0xC3EB9E15, 0x3C9057A2, 0x97271AEC, 0xA93A072A,
|
||||
0x1B3F6D9B, 0x1E6321F5, 0xF59C66FB, 0x26DCF319,
|
||||
0x7533D928, 0xB155FDF5, 0x03563482, 0x8ABA3CBB,
|
||||
0x28517711, 0xC20AD9F8, 0xABCC5167, 0xCCAD925F,
|
||||
0x4DE81751, 0x3830DC8E, 0x379D5862, 0x9320F991,
|
||||
0xEA7A90C2, 0xFB3E7BCE, 0x5121CE64, 0x774FBE32,
|
||||
0xA8B6E37E, 0xC3293D46, 0x48DE5369, 0x6413E680,
|
||||
0xA2AE0810, 0xDD6DB224, 0x69852DFD, 0x09072166,
|
||||
0xB39A460A, 0x6445C0DD, 0x586CDECF, 0x1C20C8AE,
|
||||
0x5BBEF7DD, 0x1B588D40, 0xCCD2017F, 0x6BB4E3BB,
|
||||
0xDDA26A7E, 0x3A59FF45, 0x3E350A44, 0xBCB4CDD5,
|
||||
0x72EACEA8, 0xFA6484BB, 0x8D6612AE, 0xBF3C6F47,
|
||||
0xD29BE463, 0x542F5D9E, 0xAEC2771B, 0xF64E6370,
|
||||
0x740E0D8D, 0xE75B1357, 0xF8721671, 0xAF537D5D,
|
||||
0x4040CB08, 0x4EB4E2CC, 0x34D2466A, 0x0115AF84,
|
||||
0xE1B00428, 0x95983A1D, 0x06B89FB4, 0xCE6EA048,
|
||||
0x6F3F3B82, 0x3520AB82, 0x011A1D4B, 0x277227F8,
|
||||
0x611560B1, 0xE7933FDC, 0xBB3A792B, 0x344525BD,
|
||||
0xA08839E1, 0x51CE794B, 0x2F32C9B7, 0xA01FBAC9,
|
||||
0xE01CC87E, 0xBCC7D1F6, 0xCF0111C3, 0xA1E8AAC7,
|
||||
0x1A908749, 0xD44FBD9A, 0xD0DADECB, 0xD50ADA38,
|
||||
0x0339C32A, 0xC6913667, 0x8DF9317C, 0xE0B12B4F,
|
||||
0xF79E59B7, 0x43F5BB3A, 0xF2D519FF, 0x27D9459C,
|
||||
0xBF97222C, 0x15E6FC2A, 0x0F91FC71, 0x9B941525,
|
||||
0xFAE59361, 0xCEB69CEB, 0xC2A86459, 0x12BAA8D1,
|
||||
0xB6C1075E, 0xE3056A0C, 0x10D25065, 0xCB03A442,
|
||||
0xE0EC6E0E, 0x1698DB3B, 0x4C98A0BE, 0x3278E964,
|
||||
0x9F1F9532, 0xE0D392DF, 0xD3A0342B, 0x8971F21E,
|
||||
0x1B0A7441, 0x4BA3348C, 0xC5BE7120, 0xC37632D8,
|
||||
0xDF359F8D, 0x9B992F2E, 0xE60B6F47, 0x0FE3F11D,
|
||||
0xE54CDA54, 0x1EDAD891, 0xCE6279CF, 0xCD3E7E6F,
|
||||
0x1618B166, 0xFD2C1D05, 0x848FD2C5, 0xF6FB2299,
|
||||
0xF523F357, 0xA6327623, 0x93A83531, 0x56CCCD02,
|
||||
0xACF08162, 0x5A75EBB5, 0x6E163697, 0x88D273CC,
|
||||
0xDE966292, 0x81B949D0, 0x4C50901B, 0x71C65614,
|
||||
0xE6C6C7BD, 0x327A140A, 0x45E1D006, 0xC3F27B9A,
|
||||
0xC9AA53FD, 0x62A80F00, 0xBB25BFE2, 0x35BDD2F6,
|
||||
0x71126905, 0xB2040222, 0xB6CBCF7C, 0xCD769C2B,
|
||||
0x53113EC0, 0x1640E3D3, 0x38ABBD60, 0x2547ADF0,
|
||||
0xBA38209C, 0xF746CE76, 0x77AFA1C5, 0x20756060,
|
||||
0x85CBFE4E, 0x8AE88DD8, 0x7AAAF9B0, 0x4CF9AA7E,
|
||||
0x1948C25C, 0x02FB8A8C, 0x01C36AE4, 0xD6EBE1F9,
|
||||
0x90D4F869, 0xA65CDEA0, 0x3F09252D, 0xC208E69F,
|
||||
0xB74E6132, 0xCE77E25B, 0x578FDFE3, 0x3AC372E6
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
Vendored
+380
@@ -0,0 +1,380 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Dropbox API class
|
||||
*
|
||||
* @package Dropbox
|
||||
* @copyright Copyright (C) 2010 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/dropbox-php/wiki/License MIT
|
||||
*/
|
||||
class Dropbox_API {
|
||||
|
||||
/**
|
||||
* Sandbox root-path
|
||||
*/
|
||||
const ROOT_SANDBOX = 'sandbox';
|
||||
|
||||
/**
|
||||
* Dropbox root-path
|
||||
*/
|
||||
const ROOT_DROPBOX = 'dropbox';
|
||||
|
||||
/**
|
||||
* API URl
|
||||
*/
|
||||
protected $api_url = 'https://api.dropbox.com/1/';
|
||||
|
||||
/**
|
||||
* Content API URl
|
||||
*/
|
||||
protected $api_content_url = 'https://api-content.dropbox.com/1/';
|
||||
|
||||
/**
|
||||
* OAuth object
|
||||
*
|
||||
* @var Dropbox_OAuth
|
||||
*/
|
||||
protected $oauth;
|
||||
|
||||
/**
|
||||
* Default root-path, this will most likely be 'sandbox' or 'dropbox'
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $root;
|
||||
protected $useSSL;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Dropbox_OAuth Dropbox_Auth object
|
||||
* @param string $root default root path (sandbox or dropbox)
|
||||
*/
|
||||
public function __construct(Dropbox_OAuth $oauth, $root = self::ROOT_DROPBOX, $useSSL = true) {
|
||||
|
||||
$this->oauth = $oauth;
|
||||
$this->root = $root;
|
||||
$this->useSSL = $useSSL;
|
||||
if (!$this->useSSL)
|
||||
{
|
||||
throw new Dropbox_Exception('Dropbox REST API now requires that all requests use SSL');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information about the current dropbox account
|
||||
*
|
||||
* @return stdclass
|
||||
*/
|
||||
public function getAccountInfo() {
|
||||
|
||||
$data = $this->oauth->fetch($this->api_url . 'account/info');
|
||||
return json_decode($data['body'],true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a file's contents
|
||||
*
|
||||
* @param string $path path
|
||||
* @param string $root Use this to override the default root path (sandbox/dropbox)
|
||||
* @return string
|
||||
*/
|
||||
public function getFile($path = '', $root = null) {
|
||||
|
||||
if (is_null($root)) $root = $this->root;
|
||||
$path = str_replace(array('%2F','~'), array('/','%7E'), rawurlencode($path));
|
||||
$result = $this->oauth->fetch($this->api_content_url . 'files/' . $root . '/' . ltrim($path,'/'));
|
||||
return $result['body'];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Uploads a new file
|
||||
*
|
||||
* @param string $path Target path (including filename)
|
||||
* @param string $file Either a path to a file or a stream resource
|
||||
* @param string $root Use this to override the default root path (sandbox/dropbox)
|
||||
* @return bool
|
||||
*/
|
||||
public function putFile($path, $file, $root = null) {
|
||||
|
||||
$directory = dirname($path);
|
||||
$filename = basename($path);
|
||||
|
||||
if($directory==='.') $directory = '';
|
||||
$directory = str_replace(array('%2F','~'), array('/','%7E'), rawurlencode($directory));
|
||||
// $filename = str_replace('~', '%7E', rawurlencode($filename));
|
||||
if (is_null($root)) $root = $this->root;
|
||||
|
||||
if (is_string($file)) {
|
||||
|
||||
$file = fopen($file,'rb');
|
||||
|
||||
} elseif (!is_resource($file)) {
|
||||
throw new Dropbox_Exception('File must be a file-resource or a string');
|
||||
}
|
||||
$result=$this->multipartFetch($this->api_content_url . 'files/' .
|
||||
$root . '/' . trim($directory,'/'), $file, $filename);
|
||||
|
||||
if(!isset($result["httpStatus"]) || $result["httpStatus"] != 200)
|
||||
throw new Dropbox_Exception("Uploading file to Dropbox failed");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copies a file or directory from one location to another
|
||||
*
|
||||
* This method returns the file information of the newly created file.
|
||||
*
|
||||
* @param string $from source path
|
||||
* @param string $to destination path
|
||||
* @param string $root Use this to override the default root path (sandbox/dropbox)
|
||||
* @return stdclass
|
||||
*/
|
||||
public function copy($from, $to, $root = null) {
|
||||
|
||||
if (is_null($root)) $root = $this->root;
|
||||
$response = $this->oauth->fetch($this->api_url . 'fileops/copy', array('from_path' => $from, 'to_path' => $to, 'root' => $root), 'POST');
|
||||
|
||||
return json_decode($response['body'],true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new folder
|
||||
*
|
||||
* This method returns the information from the newly created directory
|
||||
*
|
||||
* @param string $path
|
||||
* @param string $root Use this to override the default root path (sandbox/dropbox)
|
||||
* @return stdclass
|
||||
*/
|
||||
public function createFolder($path, $root = null) {
|
||||
|
||||
if (is_null($root)) $root = $this->root;
|
||||
|
||||
// Making sure the path starts with a /
|
||||
// $path = '/' . ltrim($path,'/');
|
||||
|
||||
$response = $this->oauth->fetch($this->api_url . 'fileops/create_folder', array('path' => $path, 'root' => $root),'POST');
|
||||
return json_decode($response['body'],true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a file or folder.
|
||||
*
|
||||
* This method will return the metadata information from the deleted file or folder, if successful.
|
||||
*
|
||||
* @param string $path Path to new folder
|
||||
* @param string $root Use this to override the default root path (sandbox/dropbox)
|
||||
* @return array
|
||||
*/
|
||||
public function delete($path, $root = null) {
|
||||
|
||||
if (is_null($root)) $root = $this->root;
|
||||
$response = $this->oauth->fetch($this->api_url . 'fileops/delete', array('path' => $path, 'root' => $root), 'POST');
|
||||
return json_decode($response['body']);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves a file or directory to a new location
|
||||
*
|
||||
* This method returns the information from the newly created directory
|
||||
*
|
||||
* @param mixed $from Source path
|
||||
* @param mixed $to destination path
|
||||
* @param string $root Use this to override the default root path (sandbox/dropbox)
|
||||
* @return stdclass
|
||||
*/
|
||||
public function move($from, $to, $root = null) {
|
||||
|
||||
if (is_null($root)) $root = $this->root;
|
||||
$response = $this->oauth->fetch($this->api_url . 'fileops/move', array('from_path' => rawurldecode($from), 'to_path' => rawurldecode($to), 'root' => $root), 'POST');
|
||||
|
||||
return json_decode($response['body'],true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns file and directory information
|
||||
*
|
||||
* @param string $path Path to receive information from
|
||||
* @param bool $list When set to true, this method returns information from all files in a directory. When set to false it will only return infromation from the specified directory.
|
||||
* @param string $hash If a hash is supplied, this method simply returns true if nothing has changed since the last request. Good for caching.
|
||||
* @param int $fileLimit Maximum number of file-information to receive
|
||||
* @param string $root Use this to override the default root path (sandbox/dropbox)
|
||||
* @return array|true
|
||||
*/
|
||||
public function getMetaData($path, $list = true, $hash = null, $fileLimit = null, $root = null) {
|
||||
|
||||
if (is_null($root)) $root = $this->root;
|
||||
|
||||
$args = array(
|
||||
'list' => $list,
|
||||
);
|
||||
|
||||
if (!is_null($hash)) $args['hash'] = $hash;
|
||||
if (!is_null($fileLimit)) $args['file_limit'] = $fileLimit;
|
||||
|
||||
$path = str_replace(array('%2F','~'), array('/','%7E'), rawurlencode($path));
|
||||
$response = $this->oauth->fetch($this->api_url . 'metadata/' . $root . '/' . ltrim($path,'/'), $args);
|
||||
|
||||
/* 304 is not modified */
|
||||
if ($response['httpStatus']==304) {
|
||||
return true;
|
||||
} else {
|
||||
return json_decode($response['body'],true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A way of letting you keep up with changes to files and folders in a user's Dropbox. You can periodically call /delta to get a list of "delta entries", which are instructions on how to update your local state to match the server's state.
|
||||
*
|
||||
* This method returns the information from the newly created directory
|
||||
*
|
||||
* @param string $cursor A string that is used to keep track of your current state. On the next call pass in this value to return delta entries that have been recorded since the cursor was returned.
|
||||
* @return stdclass
|
||||
*/
|
||||
public function delta($cursor) {
|
||||
|
||||
$arg['cursor'] = $cursor;
|
||||
|
||||
$response = $this->oauth->fetch($this->api_url . 'delta', $arg, 'POST');
|
||||
return json_decode($response['body'],true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a thumbnail (as a string) for a file path.
|
||||
*
|
||||
* @param string $path Path to file
|
||||
* @param string $size small, medium or large
|
||||
* @param string $root Use this to override the default root path (sandbox/dropbox)
|
||||
* @return string
|
||||
*/
|
||||
public function getThumbnail($path, $size = 'small', $root = null) {
|
||||
|
||||
if (is_null($root)) $root = $this->root;
|
||||
$path = str_replace(array('%2F','~'), array('/','%7E'), rawurlencode($path));
|
||||
$response = $this->oauth->fetch($this->api_content_url . 'thumbnails/' . $root . '/' . ltrim($path,'/'),array('size' => $size));
|
||||
|
||||
return $response['body'];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is used to generate multipart POST requests for file upload
|
||||
*
|
||||
* @param string $uri
|
||||
* @param array $arguments
|
||||
* @return bool
|
||||
*/
|
||||
protected function multipartFetch($uri, $file, $filename) {
|
||||
|
||||
/* random string */
|
||||
$boundary = 'R50hrfBj5JYyfR3vF3wR96GPCC9Fd2q2pVMERvEaOE3D8LZTgLLbRpNwXek3';
|
||||
|
||||
$headers = array(
|
||||
'Content-Type' => 'multipart/form-data; boundary=' . $boundary,
|
||||
);
|
||||
|
||||
$body="--" . $boundary . "\r\n";
|
||||
$body.="Content-Disposition: form-data; name=file; filename=".rawurldecode($filename)."\r\n";
|
||||
$body.="Content-type: application/octet-stream\r\n";
|
||||
$body.="\r\n";
|
||||
$body.=stream_get_contents($file);
|
||||
$body.="\r\n";
|
||||
$body.="--" . $boundary . "--";
|
||||
|
||||
// Dropbox requires the filename to also be part of the regular arguments, so it becomes
|
||||
// part of the signature.
|
||||
$uri.='?file=' . $filename;
|
||||
|
||||
return $this->oauth->fetch($uri, $body, 'POST', $headers);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Search
|
||||
*
|
||||
* Returns metadata for all files and folders that match the search query.
|
||||
*
|
||||
* @added by: diszo.sasil
|
||||
*
|
||||
* @param string $query
|
||||
* @param string $root Use this to override the default root path (sandbox/dropbox)
|
||||
* @param string $path
|
||||
* @return array
|
||||
*/
|
||||
public function search($query = '', $root = null, $path = ''){
|
||||
if (is_null($root)) $root = $this->root;
|
||||
if(!empty($path)){
|
||||
$path = str_replace(array('%2F','~'), array('/','%7E'), rawurlencode($path));
|
||||
}
|
||||
$response = $this->oauth->fetch($this->api_url . 'search/' . $root . '/' . ltrim($path,'/'),array('query' => $query));
|
||||
return json_decode($response['body'],true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a shareable link to files or folders.
|
||||
*
|
||||
* Note: Links created by the /shares API call expire after thirty days.
|
||||
*
|
||||
* @param type $path
|
||||
* @param type $root
|
||||
* @return type
|
||||
*/
|
||||
public function share($path, $root = null) {
|
||||
if (is_null($root)) $root = $this->root;
|
||||
$path = str_replace(array('%2F','~'), array('/','%7E'), rawurlencode($path));
|
||||
$response = $this->oauth->fetch($this->api_url. 'shares/'. $root . '/' . ltrim($path, '/'), array(), 'POST');
|
||||
return json_decode($response['body'],true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a link directly to a file.
|
||||
* Similar to /shares. The difference is that this bypasses the Dropbox webserver, used to provide a preview of the file, so that you can effectively stream the contents of your media.
|
||||
*
|
||||
* Note: The /media link expires after four hours, allotting enough time to stream files, but not enough to leave a connection open indefinitely.
|
||||
*
|
||||
* @param type $path
|
||||
* @param type $root
|
||||
* @return type
|
||||
*/
|
||||
public function media($path, $root = null) {
|
||||
|
||||
if (is_null($root)) $root = $this->root;
|
||||
$path = str_replace(array('%2F','~'), array('/','%7E'), rawurlencode($path));
|
||||
$response = $this->oauth->fetch($this->api_url. 'media/'. $root . '/' . ltrim($path, '/'), array(), 'POST');
|
||||
return json_decode($response['body'],true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and returns a copy_ref to a file. This reference string can be used to copy that file to another user's Dropbox by passing it in as the from_copy_ref parameter on /fileops/copy.
|
||||
*
|
||||
* @param type $path
|
||||
* @param type $root
|
||||
* @return type
|
||||
*/
|
||||
public function copy_ref($path, $root = null) {
|
||||
|
||||
if (is_null($root)) $root = $this->root;
|
||||
$path = str_replace(array('%2F','~'), array('/','%7E'), rawurlencode($path));
|
||||
$response = $this->oauth->fetch($this->api_url. 'copy_ref/'. $root . '/' . ltrim($path, '/'));
|
||||
return json_decode($response['body'],true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Dropbox base exception
|
||||
*
|
||||
* @package Dropbox
|
||||
* @copyright Copyright (C) 2010 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/dropbox-php/wiki/License MIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base exception class
|
||||
*/
|
||||
class Dropbox_Exception extends Exception { }
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Dropbox Forbidden exception
|
||||
*
|
||||
* @package Dropbox
|
||||
* @copyright Copyright (C) 2010 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/dropbox-php/wiki/License MIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* This exception is thrown when we receive the 403 forbidden response
|
||||
*/
|
||||
class Dropbox_Exception_Forbidden extends Dropbox_Exception {
|
||||
|
||||
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Dropbox Not Found exception
|
||||
*
|
||||
* @package Dropbox
|
||||
* @copyright Copyright (C) 2010 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/dropbox-php/wiki/License MIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* This exception is thrown when a non-existant uri is accessed.
|
||||
*
|
||||
* Basically, this exception is used when we get back a 404.
|
||||
*/
|
||||
class Dropbox_Exception_NotFound extends Dropbox_Exception {
|
||||
|
||||
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Dropbox Over Quota exception
|
||||
*
|
||||
* @package Dropbox
|
||||
* @copyright Copyright (C) 2010 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/dropbox-php/wiki/License MIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* This exception is thrown when the operation required more space than the available quota.
|
||||
*
|
||||
* Basically, this exception is used when we get back a 507.
|
||||
*/
|
||||
class Dropbox_Exception_OverQuota extends Dropbox_Exception {
|
||||
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Dropbox RequestToken exception
|
||||
*
|
||||
* @package Dropbox
|
||||
* @copyright Copyright (C) 2010 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/dropbox-php/wiki/License MIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* This exception is thrown when an error occured during the request_token process.
|
||||
*/
|
||||
class Dropbox_Exception_RequestToken extends Dropbox_Exception {
|
||||
|
||||
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2010 Rooftop Solutions
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
Vendored
+151
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Dropbox OAuth
|
||||
*
|
||||
* @package Dropbox
|
||||
* @copyright Copyright (C) 2010 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/dropbox-php/wiki/License MIT
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* This class is an abstract OAuth class.
|
||||
*
|
||||
* It must be extended by classes who wish to provide OAuth functionality
|
||||
* using different libraries.
|
||||
*/
|
||||
abstract class Dropbox_OAuth {
|
||||
|
||||
/**
|
||||
* After a user has authorized access, dropbox can redirect the user back
|
||||
* to this url.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $authorizeCallbackUrl = null;
|
||||
|
||||
/**
|
||||
* Uri used to fetch request tokens
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const URI_REQUEST_TOKEN = 'https://api.dropbox.com/1/oauth/request_token';
|
||||
|
||||
/**
|
||||
* Uri used to redirect the user to for authorization.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const URI_AUTHORIZE = 'https://www.dropbox.com/1/oauth/authorize';
|
||||
|
||||
/**
|
||||
* Uri used to
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const URI_ACCESS_TOKEN = 'https://api.dropbox.com/1/oauth/access_token';
|
||||
|
||||
/**
|
||||
* An OAuth request token.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $oauth_token = null;
|
||||
|
||||
/**
|
||||
* OAuth token secret
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $oauth_token_secret = null;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $consumerKey
|
||||
* @param string $consumerSecret
|
||||
*/
|
||||
abstract public function __construct($consumerKey, $consumerSecret);
|
||||
|
||||
/**
|
||||
* Sets the request token and secret.
|
||||
*
|
||||
* The tokens can also be passed as an array into the first argument.
|
||||
* The array must have the elements token and token_secret.
|
||||
*
|
||||
* @param string|array $token
|
||||
* @param string $token_secret
|
||||
* @return void
|
||||
*/
|
||||
public function setToken($token, $token_secret = null) {
|
||||
|
||||
if (is_array($token)) {
|
||||
$this->oauth_token = $token['token'];
|
||||
$this->oauth_token_secret = $token['token_secret'];
|
||||
} else {
|
||||
$this->oauth_token = $token;
|
||||
$this->oauth_token_secret = $token_secret;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the oauth request tokens as an associative array.
|
||||
*
|
||||
* The array will contain the elements 'token' and 'token_secret'.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getToken() {
|
||||
|
||||
return array(
|
||||
'token' => $this->oauth_token,
|
||||
'token_secret' => $this->oauth_token_secret,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the authorization url
|
||||
*
|
||||
* @param string $callBack Specify a callback url to automatically redirect the user back
|
||||
* @return string
|
||||
*/
|
||||
public function getAuthorizeUrl($callBack = null) {
|
||||
|
||||
// Building the redirect uri
|
||||
$token = $this->getToken();
|
||||
$uri = self::URI_AUTHORIZE . '?oauth_token=' . $token['token'];
|
||||
if ($callBack) $uri.='&oauth_callback=' . $callBack;
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a secured oauth url and returns the response body.
|
||||
*
|
||||
* @param string $uri
|
||||
* @param mixed $arguments
|
||||
* @param string $method
|
||||
* @param array $httpHeaders
|
||||
* @return string
|
||||
*/
|
||||
public abstract function fetch($uri, $arguments = array(), $method = 'GET', $httpHeaders = array());
|
||||
|
||||
/**
|
||||
* Requests the OAuth request token.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
abstract public function getRequestToken();
|
||||
|
||||
/**
|
||||
* Requests the OAuth access tokens.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
abstract public function getAccessToken();
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* HTTP OAuth Consumer
|
||||
*
|
||||
* Adapted from halldirector's code in
|
||||
* http://code.google.com/p/dropbox-php/issues/detail?id=36#c5
|
||||
*
|
||||
* @package Dropbox
|
||||
* @copyright Copyright (C) 2011 Joe Constant / halldirector. All rights reserved.
|
||||
* @author Joe Constant / halldirector
|
||||
* @license http://code.google.com/p/dropbox-php/wiki/License MIT
|
||||
*/
|
||||
|
||||
require_once 'HTTP/OAuth.php';
|
||||
require_once 'HTTP/OAuth/Consumer.php';
|
||||
|
||||
/*
|
||||
* This class is to help work around aomw ssl issues.
|
||||
*/
|
||||
class Dropbox_OAuth_Consumer_Dropbox extends HTTP_OAuth_Consumer
|
||||
{
|
||||
public function getOAuthConsumerRequest()
|
||||
{
|
||||
if (!$this->consumerRequest instanceof HTTP_OAuth_Consumer_Request) {
|
||||
$this->consumerRequest = new HTTP_OAuth_Consumer_Request;
|
||||
}
|
||||
|
||||
// TODO: Change this and add in code to validate the SSL cert.
|
||||
// see https://github.com/bagder/curl/blob/master/lib/mk-ca-bundle.pl
|
||||
$this->consumerRequest->setConfig(array(
|
||||
'ssl_verify_peer' => false,
|
||||
'ssl_verify_host' => false
|
||||
));
|
||||
|
||||
return $this->consumerRequest;
|
||||
}
|
||||
}
|
||||
Vendored
+282
@@ -0,0 +1,282 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Dropbox OAuth
|
||||
*
|
||||
* @package Dropbox
|
||||
* @copyright Copyright (C) 2011 Daniel Huesken
|
||||
* @author Daniel Huesken (http://www.danielhuesken.de/)
|
||||
* @license MIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* This class is used to sign all requests to dropbox.
|
||||
*
|
||||
* This specific class uses WordPress WP_Http to authenticate.
|
||||
*/
|
||||
class Dropbox_OAuth_Curl extends Dropbox_OAuth {
|
||||
|
||||
/**
|
||||
*
|
||||
* @var string ConsumerKey
|
||||
*/
|
||||
protected $consumerKey = null;
|
||||
/**
|
||||
*
|
||||
* @var string ConsumerSecret
|
||||
*/
|
||||
protected $consumerSecret = null;
|
||||
/**
|
||||
*
|
||||
* @var string ProzessCallBack
|
||||
*/
|
||||
public $ProgressFunction = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $consumerKey
|
||||
* @param string $consumerSecret
|
||||
*/
|
||||
public function __construct($consumerKey, $consumerSecret) {
|
||||
if (!function_exists('curl_exec'))
|
||||
throw new Dropbox_Exception('The PHP curl functions not available!');
|
||||
|
||||
$this->consumerKey = $consumerKey;
|
||||
$this->consumerSecret = $consumerSecret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches a secured oauth url and returns the response body.
|
||||
*
|
||||
* @param string $uri
|
||||
* @param mixed $arguments
|
||||
* @param string $method
|
||||
* @param array $httpHeaders
|
||||
* @return string
|
||||
*/
|
||||
public function fetch($uri, $arguments = array(), $method = 'GET', $httpHeaders = array()) {
|
||||
|
||||
$uri=str_replace('http://', 'https://', $uri); // all https, upload makes problems if not
|
||||
if (is_string($arguments) and strtoupper($method) == 'POST') {
|
||||
preg_match("/\?file=(.*)$/i", $uri, $matches);
|
||||
if (isset($matches[1])) {
|
||||
$uri = str_replace($matches[0], "", $uri);
|
||||
$filename = $matches[1];
|
||||
$httpHeaders=array_merge($httpHeaders,$this->getOAuthHeader($uri, array("file" => $filename), $method));
|
||||
}
|
||||
} else {
|
||||
$httpHeaders=array_merge($httpHeaders,$this->getOAuthHeader($uri, $arguments, $method));
|
||||
}
|
||||
$ch = curl_init();
|
||||
if (strtoupper($method) == 'POST') {
|
||||
curl_setopt($ch, CURLOPT_URL, $uri);
|
||||
curl_setopt($ch, CURLOPT_POST, true);
|
||||
// if (is_array($arguments))
|
||||
// $arguments=http_build_query($arguments);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $arguments);
|
||||
// $httpHeaders['Content-Length']=strlen($arguments);
|
||||
} else {
|
||||
curl_setopt($ch, CURLOPT_URL, $uri.'?'.http_build_query($arguments));
|
||||
curl_setopt($ch, CURLOPT_POST, false);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 300);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
||||
// curl_setopt($ch, CURLOPT_CAINFO, "rootca");
|
||||
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
|
||||
//Build header
|
||||
$headers = array();
|
||||
foreach ($httpHeaders as $name => $value) {
|
||||
$headers[] = "{$name}: $value";
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
if (!ini_get('safe_mode') && !ini_get('open_basedir'))
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true );
|
||||
if (function_exists($this->ProgressFunction) and defined('CURLOPT_PROGRESSFUNCTION')) {
|
||||
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
|
||||
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, $this->ProgressFunction);
|
||||
curl_setopt($ch, CURLOPT_BUFFERSIZE, 512);
|
||||
}
|
||||
$response=curl_exec($ch);
|
||||
$errorno=curl_errno($ch);
|
||||
$error=curl_error($ch);
|
||||
$status=curl_getinfo($ch,CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
|
||||
|
||||
if (!empty($errorno))
|
||||
throw new Dropbox_Exception_NotFound('Curl error: ('.$errorno.') '.$error."\n");
|
||||
|
||||
if ($status>=300) {
|
||||
$body = json_decode($response,true);
|
||||
switch ($status) {
|
||||
// Not modified
|
||||
case 304 :
|
||||
return array(
|
||||
'httpStatus' => 304,
|
||||
'body' => null,
|
||||
);
|
||||
break;
|
||||
case 403 :
|
||||
throw new Dropbox_Exception_Forbidden('Forbidden.
|
||||
This could mean a bad OAuth request, or a file or folder already existing at the target location.
|
||||
' . $body["error"] . "\n");
|
||||
case 404 :
|
||||
throw new Dropbox_Exception_NotFound('Resource at uri: ' . $uri . ' could not be found. ' .
|
||||
$body["error"] . "\n");
|
||||
case 507 :
|
||||
throw new Dropbox_Exception_OverQuota('This dropbox is full. ' .
|
||||
$body["error"] . "\n");
|
||||
}
|
||||
if (!empty($body["error"]))
|
||||
throw new Dropbox_Exception_RequestToken('Error: ('.$status.') '.$body["error"]."\n");
|
||||
}
|
||||
|
||||
return array(
|
||||
'body' => $response,
|
||||
'httpStatus' => $status
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns named array with oauth parameters for further use
|
||||
* @return array Array with oauth_ parameters
|
||||
*/
|
||||
private function getOAuthBaseParams() {
|
||||
$params['oauth_version'] = '1.0';
|
||||
$params['oauth_signature_method'] = 'HMAC-SHA1';
|
||||
|
||||
$params['oauth_consumer_key'] = $this->consumerKey;
|
||||
$tokens = $this->getToken();
|
||||
if (isset($tokens['token']) && $tokens['token']) {
|
||||
$params['oauth_token'] = $tokens['token'];
|
||||
}
|
||||
$params['oauth_timestamp'] = time();
|
||||
$params['oauth_nonce'] = md5(microtime() . mt_rand());
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates valid Authorization header for OAuth, based on URI and Params
|
||||
*
|
||||
* @param string $uri
|
||||
* @param array $params
|
||||
* @param string $method GET or POST, standard is GET
|
||||
* @param array $oAuthParams optional, pass your own oauth_params here
|
||||
* @return array Array for request's headers section like
|
||||
* array('Authorization' => 'OAuth ...');
|
||||
*/
|
||||
private function getOAuthHeader($uri, $params, $method = 'GET', $oAuthParams = null) {
|
||||
$oAuthParams = $oAuthParams ? $oAuthParams : $this->getOAuthBaseParams();
|
||||
|
||||
// create baseString to encode for the sent parameters
|
||||
$baseString = $method . '&';
|
||||
$baseString .= $this->oauth_urlencode($uri) . "&";
|
||||
|
||||
// OAuth header does not include GET-Parameters
|
||||
$signatureParams = array_merge($params, $oAuthParams);
|
||||
|
||||
// sorting the parameters
|
||||
ksort($signatureParams);
|
||||
|
||||
$encodedParams = array();
|
||||
foreach ($signatureParams as $key => $value) {
|
||||
$encodedParams[] = $this->oauth_urlencode($key) . '=' . $this->oauth_urlencode($value);
|
||||
}
|
||||
|
||||
$baseString .= $this->oauth_urlencode(implode('&', $encodedParams));
|
||||
|
||||
// encode the signature
|
||||
$tokens = $this->getToken();
|
||||
$hash = $this->hash_hmac_sha1($this->consumerSecret.'&'.$tokens['token_secret'], $baseString);
|
||||
$signature = base64_encode($hash);
|
||||
|
||||
// add signature to oAuthParams
|
||||
$oAuthParams['oauth_signature'] = $signature;
|
||||
|
||||
$oAuthEncoded = array();
|
||||
foreach ($oAuthParams as $key => $value) {
|
||||
$oAuthEncoded[] = $key . '="' . $this->oauth_urlencode($value) . '"';
|
||||
}
|
||||
|
||||
return array('Authorization' => 'OAuth ' . implode(', ', $oAuthEncoded));
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests the OAuth request token.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getRequestToken() {
|
||||
$result = $this->fetch(self::URI_REQUEST_TOKEN, array(), 'POST');
|
||||
if ($result['httpStatus'] == "200") {
|
||||
$tokens = array();
|
||||
parse_str($result['body'], $tokens);
|
||||
$this->setToken($tokens['oauth_token'], $tokens['oauth_token_secret']);
|
||||
return $this->getToken();
|
||||
} else {
|
||||
throw new Dropbox_Exception_RequestToken('We were unable to fetch request tokens. This likely means that your consumer key and/or secret are incorrect.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests the OAuth access tokens.
|
||||
*
|
||||
* This method requires the 'unauthorized' request tokens
|
||||
* and, if successful will set the authorized request tokens.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getAccessToken() {
|
||||
$result = $this->fetch(self::URI_ACCESS_TOKEN, array(), 'POST');
|
||||
if ($result['httpStatus'] == "200") {
|
||||
$tokens = array();
|
||||
parse_str($result['body'], $tokens);
|
||||
$this->setToken($tokens['oauth_token'], $tokens['oauth_token_secret']);
|
||||
return $this->getToken();
|
||||
} else {
|
||||
throw new Dropbox_Exception_RequestToken('We were unable to fetch request tokens. This likely means that your consumer key and/or secret are incorrect.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to properly urlencode parameters.
|
||||
* See http://php.net/manual/en/function.oauth-urlencode.php
|
||||
*
|
||||
* @param string $string
|
||||
* @return string
|
||||
*/
|
||||
private function oauth_urlencode($string) {
|
||||
return str_replace('%E7', '~', rawurlencode($string));
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash function for hmac_sha1; uses native function if available.
|
||||
*
|
||||
* @param string $key
|
||||
* @param string $data
|
||||
* @return string
|
||||
*/
|
||||
private function hash_hmac_sha1($key, $data) {
|
||||
if (function_exists('hash_hmac') && in_array('sha1', hash_algos())) {
|
||||
return hash_hmac('sha1', $data, $key, true);
|
||||
} else {
|
||||
$blocksize = 64;
|
||||
$hashfunc = 'sha1';
|
||||
if (strlen($key) > $blocksize) {
|
||||
$key = pack('H*', $hashfunc($key));
|
||||
}
|
||||
|
||||
$key = str_pad($key, $blocksize, chr(0x00));
|
||||
$ipad = str_repeat(chr(0x36), $blocksize);
|
||||
$opad = str_repeat(chr(0x5c), $blocksize);
|
||||
$hash = pack('H*', $hashfunc(( $key ^ $opad ) . pack('H*', $hashfunc(($key ^ $ipad) . $data))));
|
||||
|
||||
return $hash;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
Dropbox-php
|
||||
===========
|
||||
|
||||
This PHP library allows you to easily integrate dropbox with PHP.
|
||||
|
||||
The following PHP extension is required:
|
||||
|
||||
* json
|
||||
|
||||
The library makes use of OAuth. At the moment you can use either of these libraries:
|
||||
|
||||
[PHP OAuth extension](http://pecl.php.net/package/oauth)
|
||||
[PEAR's HTTP_OAUTH package](http://pear.php.net/package/http_oauth)
|
||||
|
||||
The extension is recommended, but if you can't install php extensions you should go for the pear package.
|
||||
Installing
|
||||
----------
|
||||
|
||||
pear channel-discover pear.dropbox-php.com
|
||||
pear install dropbox-php/Dropbox-alpha
|
||||
|
||||
Documentation
|
||||
-------------
|
||||
Check out the [documentation](http://www.dropbox-php.com/docs).
|
||||
|
||||
Questions?
|
||||
----------
|
||||
|
||||
[Dropbox-php Mailing list](http://groups.google.com/group/dropbox-php)
|
||||
[Official Dropbox developer forum](http://forums.dropbox.com/forum.php?id=5)
|
||||
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* This file registers a new autoload function using spl_autoload_register.
|
||||
*
|
||||
* @package Dropbox
|
||||
* @copyright Copyright (C) 2010 Rooftop Solutions. All rights reserved.
|
||||
* @author Evert Pot (http://www.rooftopsolutions.nl/)
|
||||
* @license http://code.google.com/p/dropbox-php/wiki/License MIT
|
||||
*/
|
||||
|
||||
/**
|
||||
* Autoloader function
|
||||
*
|
||||
* @param $className string
|
||||
* @return void
|
||||
*/
|
||||
function Dropbox_autoload($className) {
|
||||
|
||||
if(strpos($className,'Dropbox_')===0) {
|
||||
|
||||
include dirname(__FILE__) . '/' . str_replace('_','/',substr($className,8)) . '.php';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
spl_autoload_register('Dropbox_autoload');
|
||||
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2007 Andy Smith
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
+751
@@ -0,0 +1,751 @@
|
||||
<?php
|
||||
// vim: foldmethod=marker
|
||||
|
||||
/* Generic exception class
|
||||
*/
|
||||
class OAuthException extends Exception {/*{{{*/
|
||||
// pass
|
||||
}/*}}}*/
|
||||
|
||||
class OAuthConsumer {/*{{{*/
|
||||
public $key;
|
||||
public $secret;
|
||||
|
||||
public function __construct($key, $secret, $callback_url=NULL) {/*{{{*/
|
||||
$this->key = $key;
|
||||
$this->secret = $secret;
|
||||
$this->callback_url = $callback_url;
|
||||
}/*}}}*/
|
||||
}/*}}}*/
|
||||
|
||||
class OAuthToken {/*{{{*/
|
||||
// access tokens and request tokens
|
||||
public $key;
|
||||
public $secret;
|
||||
|
||||
/**
|
||||
* key = the token
|
||||
* secret = the token secret
|
||||
*/
|
||||
function __construct($key, $secret) {/*{{{*/
|
||||
$this->key = $key;
|
||||
$this->secret = $secret;
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* generates the basic string serialization of a token that a server
|
||||
* would respond to request_token and access_token calls with
|
||||
*/
|
||||
function to_string() {/*{{{*/
|
||||
return "oauth_token=" . OAuthUtil::urlencodeRFC3986($this->key) .
|
||||
"&oauth_token_secret=" . OAuthUtil::urlencodeRFC3986($this->secret);
|
||||
}/*}}}*/
|
||||
|
||||
function __toString() {/*{{{*/
|
||||
return $this->to_string();
|
||||
}/*}}}*/
|
||||
}/*}}}*/
|
||||
|
||||
class OAuthSignatureMethod {/*{{{*/
|
||||
public function check_signature(&$request, $consumer, $token, $signature) {
|
||||
$built = $this->build_signature($request, $consumer, $token);
|
||||
return $built == $signature;
|
||||
}
|
||||
}/*}}}*/
|
||||
|
||||
class OAuthSignatureMethod_HMAC_SHA1 extends OAuthSignatureMethod {/*{{{*/
|
||||
function get_name() {/*{{{*/
|
||||
return "HMAC-SHA1";
|
||||
}/*}}}*/
|
||||
|
||||
public function build_signature($request, $consumer, $token, $privKey=NULL) {/*{{{*/
|
||||
$base_string = $request->get_signature_base_string();
|
||||
$request->base_string = $base_string;
|
||||
|
||||
$key_parts = array(
|
||||
$consumer->secret,
|
||||
($token) ? $token->secret : ""
|
||||
);
|
||||
|
||||
$key_parts = array_map(array('OAuthUtil','urlencodeRFC3986'), $key_parts);
|
||||
$key = implode('&', $key_parts);
|
||||
|
||||
return base64_encode( hash_hmac('sha1', $base_string, $key, true));
|
||||
}/*}}}*/
|
||||
}/*}}}*/
|
||||
|
||||
class OAuthSignatureMethod_RSA_SHA1 extends OAuthSignatureMethod {/*{{{*/
|
||||
public function get_name() {/*{{{*/
|
||||
return "RSA-SHA1";
|
||||
}/*}}}*/
|
||||
|
||||
protected function fetch_public_cert(&$request) {/*{{{*/
|
||||
// not implemented yet, ideas are:
|
||||
// (1) do a lookup in a table of trusted certs keyed off of consumer
|
||||
// (2) fetch via http using a url provided by the requester
|
||||
// (3) some sort of specific discovery code based on request
|
||||
//
|
||||
// either way should return a string representation of the certificate
|
||||
throw Exception("fetch_public_cert not implemented");
|
||||
}/*}}}*/
|
||||
|
||||
protected function fetch_private_cert($privKey) {//&$request) {/*{{{*/
|
||||
// not implemented yet, ideas are:
|
||||
// (1) do a lookup in a table of trusted certs keyed off of consumer
|
||||
//
|
||||
// either way should return a string representation of the certificate
|
||||
throw Exception("fetch_private_cert not implemented");
|
||||
}/*}}}*/
|
||||
|
||||
public function build_signature(&$request, $consumer, $token, $privKey) {/*{{{*/
|
||||
$base_string = $request->get_signature_base_string();
|
||||
|
||||
// Fetch the private key cert based on the request
|
||||
//$cert = $this->fetch_private_cert($consumer->privKey);
|
||||
|
||||
//Pull the private key ID from the certificate
|
||||
//$privatekeyid = openssl_get_privatekey($cert);
|
||||
|
||||
// hacked in
|
||||
if ($privKey == '') {
|
||||
$fp = fopen($GLOBALS['PRIV_KEY_FILE'], "r");
|
||||
$privKey = fread($fp, 8192);
|
||||
fclose($fp);
|
||||
}
|
||||
$privatekeyid = openssl_get_privatekey($privKey);
|
||||
|
||||
//Check the computer signature against the one passed in the query
|
||||
$ok = openssl_sign($base_string, $signature, $privatekeyid);
|
||||
|
||||
//Release the key resource
|
||||
openssl_free_key($privatekeyid);
|
||||
|
||||
return base64_encode($signature);
|
||||
} /*}}}*/
|
||||
|
||||
public function check_signature(&$request, $consumer, $token, $signature) {/*{{{*/
|
||||
$decoded_sig = base64_decode($signature);
|
||||
|
||||
$base_string = $request->get_signature_base_string();
|
||||
|
||||
// Fetch the public key cert based on the request
|
||||
$cert = $this->fetch_public_cert($request);
|
||||
|
||||
//Pull the public key ID from the certificate
|
||||
$publickeyid = openssl_get_publickey($cert);
|
||||
|
||||
//Check the computer signature against the one passed in the query
|
||||
$ok = openssl_verify($base_string, $decoded_sig, $publickeyid);
|
||||
|
||||
//Release the key resource
|
||||
openssl_free_key($publickeyid);
|
||||
|
||||
return $ok == 1;
|
||||
} /*}}}*/
|
||||
}/*}}}*/
|
||||
|
||||
class OAuthRequest {/*{{{*/
|
||||
private $parameters;
|
||||
private $http_method;
|
||||
private $http_url;
|
||||
// for debug purposes
|
||||
public $base_string;
|
||||
public static $version = '1.0';
|
||||
|
||||
function __construct($http_method, $http_url, $parameters=NULL) {/*{{{*/
|
||||
@$parameters or $parameters = array();
|
||||
$this->parameters = $parameters;
|
||||
$this->http_method = $http_method;
|
||||
$this->http_url = $http_url;
|
||||
}/*}}}*/
|
||||
|
||||
|
||||
/**
|
||||
* attempt to build up a request from what was passed to the server
|
||||
*/
|
||||
public static function from_request($http_method=NULL, $http_url=NULL, $parameters=NULL) {/*{{{*/
|
||||
$scheme = (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on") ? 'http' : 'https';
|
||||
@$http_url or $http_url = $scheme . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
|
||||
@$http_method or $http_method = $_SERVER['REQUEST_METHOD'];
|
||||
|
||||
$request_headers = OAuthRequest::get_headers();
|
||||
|
||||
// let the library user override things however they'd like, if they know
|
||||
// which parameters to use then go for it, for example XMLRPC might want to
|
||||
// do this
|
||||
if ($parameters) {
|
||||
$req = new OAuthRequest($http_method, $http_url, $parameters);
|
||||
}
|
||||
// next check for the auth header, we need to do some extra stuff
|
||||
// if that is the case, namely suck in the parameters from GET or POST
|
||||
// so that we can include them in the signature
|
||||
else if (@substr($request_headers['Authorization'], 0, 5) == "OAuth") {
|
||||
$header_parameters = OAuthRequest::split_header($request_headers['Authorization']);
|
||||
if ($http_method == "GET") {
|
||||
$req_parameters = $_GET;
|
||||
}
|
||||
else if ($http_method = "POST") {
|
||||
$req_parameters = $_POST;
|
||||
}
|
||||
$parameters = array_merge($header_parameters, $req_parameters);
|
||||
$req = new OAuthRequest($http_method, $http_url, $parameters);
|
||||
}
|
||||
else if ($http_method == "GET") {
|
||||
$req = new OAuthRequest($http_method, $http_url, $_GET);
|
||||
}
|
||||
else if ($http_method == "POST") {
|
||||
$req = new OAuthRequest($http_method, $http_url, $_POST);
|
||||
}
|
||||
return $req;
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* pretty much a helper function to set up the request
|
||||
*/
|
||||
public static function from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=NULL) {/*{{{*/
|
||||
@$parameters or $parameters = array();
|
||||
$defaults = array("oauth_version" => OAuthRequest::$version,
|
||||
"oauth_nonce" => OAuthRequest::generate_nonce(),
|
||||
"oauth_timestamp" => OAuthRequest::generate_timestamp(),
|
||||
"oauth_consumer_key" => $consumer->key);
|
||||
$parameters = array_merge($defaults, $parameters);
|
||||
|
||||
if ($token) {
|
||||
$parameters['oauth_token'] = $token->key;
|
||||
}
|
||||
|
||||
// oauth v1.0a
|
||||
/*if (isset($_REQUEST['oauth_verifier'])) {
|
||||
$parameters['oauth_verifier'] = $_REQUEST['oauth_verifier'];
|
||||
}*/
|
||||
|
||||
|
||||
return new OAuthRequest($http_method, $http_url, $parameters);
|
||||
}/*}}}*/
|
||||
|
||||
public function set_parameter($name, $value) {/*{{{*/
|
||||
$this->parameters[$name] = $value;
|
||||
}/*}}}*/
|
||||
|
||||
public function get_parameter($name) {/*{{{*/
|
||||
return $this->parameters[$name];
|
||||
}/*}}}*/
|
||||
|
||||
public function get_parameters() {/*{{{*/
|
||||
return $this->parameters;
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* Returns the normalized parameters of the request
|
||||
*
|
||||
* This will be all (except oauth_signature) parameters,
|
||||
* sorted first by key, and if duplicate keys, then by
|
||||
* value.
|
||||
*
|
||||
* The returned string will be all the key=value pairs
|
||||
* concated by &.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_signable_parameters() {/*{{{*/
|
||||
// Grab all parameters
|
||||
$params = $this->parameters;
|
||||
|
||||
// Remove oauth_signature if present
|
||||
if (isset($params['oauth_signature'])) {
|
||||
unset($params['oauth_signature']);
|
||||
}
|
||||
|
||||
// Urlencode both keys and values
|
||||
$keys = array_map(array('OAuthUtil', 'urlencodeRFC3986'), array_keys($params));
|
||||
$values = array_map(array('OAuthUtil', 'urlencodeRFC3986'), array_values($params));
|
||||
$params = array_combine($keys, $values);
|
||||
|
||||
// Sort by keys (natsort)
|
||||
uksort($params, 'strnatcmp');
|
||||
|
||||
if(isset($params['title']) && isset($params['title-exact'])) {
|
||||
$temp = $params['title-exact'];
|
||||
$title = $params['title'];
|
||||
|
||||
unset($params['title']);
|
||||
unset($params['title-exact']);
|
||||
|
||||
$params['title-exact'] = $temp;
|
||||
$params['title'] = $title;
|
||||
}
|
||||
|
||||
// Generate key=value pairs
|
||||
$pairs = array();
|
||||
foreach ($params as $key=>$value ) {
|
||||
if (is_array($value)) {
|
||||
// If the value is an array, it's because there are multiple
|
||||
// with the same key, sort them, then add all the pairs
|
||||
natsort($value);
|
||||
foreach ($value as $v2) {
|
||||
$pairs[] = $key . '=' . $v2;
|
||||
}
|
||||
} else {
|
||||
$pairs[] = $key . '=' . $value;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the pairs, concated with &
|
||||
return implode('&', $pairs);
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* Returns the base string of this request
|
||||
*
|
||||
* The base string defined as the method, the url
|
||||
* and the parameters (normalized), each urlencoded
|
||||
* and the concated with &.
|
||||
*/
|
||||
public function get_signature_base_string() {/*{{{*/
|
||||
$parts = array(
|
||||
$this->get_normalized_http_method(),
|
||||
$this->get_normalized_http_url(),
|
||||
$this->get_signable_parameters()
|
||||
);
|
||||
|
||||
$parts = array_map(array('OAuthUtil', 'urlencodeRFC3986'), $parts);
|
||||
|
||||
return implode('&', $parts);
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* just uppercases the http method
|
||||
*/
|
||||
public function get_normalized_http_method() {/*{{{*/
|
||||
return strtoupper($this->http_method);
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* parses the url and rebuilds it to be
|
||||
* scheme://host/path
|
||||
*/
|
||||
public function get_normalized_http_url() {
|
||||
$parts = parse_url($this->http_url);
|
||||
|
||||
$scheme = (isset($parts['scheme'])) ? $parts['scheme'] : 'http';
|
||||
$port = (isset($parts['port'])) ? $parts['port'] : (($scheme == 'https') ? '443' : '80');
|
||||
$host = (isset($parts['host'])) ? strtolower($parts['host']) : '';
|
||||
$path = (isset($parts['path'])) ? $parts['path'] : '';
|
||||
|
||||
if (($scheme == 'https' && $port != '443')
|
||||
|| ($scheme == 'http' && $port != '80')) {
|
||||
$host = "$host:$port";
|
||||
}
|
||||
return "$scheme://$host$path";
|
||||
}
|
||||
|
||||
/**
|
||||
* builds a url usable for a GET request
|
||||
*/
|
||||
public function to_url() {/*{{{*/
|
||||
$out = $this->get_normalized_http_url() . "?";
|
||||
$out .= $this->to_postdata();
|
||||
return $out;
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* builds the data one would send in a POST request
|
||||
*/
|
||||
public function to_postdata() {/*{{{*/
|
||||
$total = array();
|
||||
foreach ($this->parameters as $k => $v) {
|
||||
$total[] = OAuthUtil::urlencodeRFC3986($k) . "=" . OAuthUtil::urlencodeRFC3986($v);
|
||||
}
|
||||
$out = implode("&", $total);
|
||||
return $out;
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* builds the Authorization: header
|
||||
*/
|
||||
public function to_header() {/*{{{*/
|
||||
$out ='Authorization: OAuth ';
|
||||
$total = array();
|
||||
|
||||
/*
|
||||
$sig = $this->parameters['oauth_signature'];
|
||||
unset($this->parameters['oauth_signature']);
|
||||
uksort($this->parameters, 'strnatcmp');
|
||||
$this->parameters['oauth_signature'] = $sig;
|
||||
*/
|
||||
|
||||
foreach ($this->parameters as $k => $v) {
|
||||
if (substr($k, 0, 5) != "oauth") continue;
|
||||
$out .= OAuthUtil::urlencodeRFC3986($k) . '="' . OAuthUtil::urlencodeRFC3986($v) . '", ';
|
||||
}
|
||||
$out = substr_replace($out, '', strlen($out) - 2);
|
||||
|
||||
return $out;
|
||||
}/*}}}*/
|
||||
|
||||
public function __toString() {/*{{{*/
|
||||
return $this->to_url();
|
||||
}/*}}}*/
|
||||
|
||||
|
||||
public function sign_request($signature_method, $consumer, $token, $privKey=NULL) {/*{{{*/
|
||||
$this->set_parameter("oauth_signature_method", $signature_method->get_name());
|
||||
$signature = $this->build_signature($signature_method, $consumer, $token, $privKey);
|
||||
$this->set_parameter("oauth_signature", $signature);
|
||||
}/*}}}*/
|
||||
|
||||
public function build_signature($signature_method, $consumer, $token, $privKey=NULL) {/*{{{*/
|
||||
$signature = $signature_method->build_signature($this, $consumer, $token, $privKey);
|
||||
return $signature;
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* util function: current timestamp
|
||||
*/
|
||||
private static function generate_timestamp() {/*{{{*/
|
||||
return time();
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* util function: current nonce
|
||||
*/
|
||||
private static function generate_nonce() {/*{{{*/
|
||||
$mt = microtime();
|
||||
$rand = mt_rand();
|
||||
|
||||
return md5($mt . $rand); // md5s look nicer than numbers
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* util function for turning the Authorization: header into
|
||||
* parameters, has to do some unescaping
|
||||
*/
|
||||
private static function split_header($header) {/*{{{*/
|
||||
// this should be a regex
|
||||
// error cases: commas in parameter values
|
||||
$parts = explode(",", $header);
|
||||
$out = array();
|
||||
foreach ($parts as $param) {
|
||||
$param = ltrim($param);
|
||||
// skip the "realm" param, nobody ever uses it anyway
|
||||
if (substr($param, 0, 5) != "oauth") continue;
|
||||
|
||||
$param_parts = explode("=", $param);
|
||||
|
||||
// rawurldecode() used because urldecode() will turn a "+" in the
|
||||
// value into a space
|
||||
$out[$param_parts[0]] = rawurldecode(substr($param_parts[1], 1, -1));
|
||||
}
|
||||
return $out;
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* helper to try to sort out headers for people who aren't running apache
|
||||
*/
|
||||
private static function get_headers() {/*{{{*/
|
||||
if (function_exists('apache_request_headers')) {
|
||||
// we need this to get the actual Authorization: header
|
||||
// because apache tends to tell us it doesn't exist
|
||||
return apache_request_headers();
|
||||
}
|
||||
// otherwise we don't have apache and are just going to have to hope
|
||||
// that $_SERVER actually contains what we need
|
||||
$out = array();
|
||||
foreach ($_SERVER as $key => $value) {
|
||||
if (substr($key, 0, 5) == "HTTP_") {
|
||||
// this is chaos, basically it is just there to capitalize the first
|
||||
// letter of every word that is not an initial HTTP and strip HTTP
|
||||
// code from przemek
|
||||
$key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($key, 5)))));
|
||||
$out[$key] = $value;
|
||||
}
|
||||
}
|
||||
return $out;
|
||||
}/*}}}*/
|
||||
}/*}}}*/
|
||||
|
||||
class OAuthServer {/*{{{*/
|
||||
protected $timestamp_threshold = 300; // in seconds, five minutes
|
||||
protected $version = 1.0; // hi blaine
|
||||
protected $signature_methods = array();
|
||||
|
||||
protected $data_store;
|
||||
|
||||
function __construct($data_store) {/*{{{*/
|
||||
$this->data_store = $data_store;
|
||||
}/*}}}*/
|
||||
|
||||
public function add_signature_method($signature_method) {/*{{{*/
|
||||
$this->signature_methods[$signature_method->get_name()] =
|
||||
$signature_method;
|
||||
}/*}}}*/
|
||||
|
||||
// high level functions
|
||||
|
||||
/**
|
||||
* process a request_token request
|
||||
* returns the request token on success
|
||||
*/
|
||||
public function fetch_request_token(&$request) {/*{{{*/
|
||||
$this->get_version($request);
|
||||
|
||||
$consumer = $this->get_consumer($request);
|
||||
|
||||
// no token required for the initial token request
|
||||
$token = NULL;
|
||||
|
||||
$this->check_signature($request, $consumer, $token);
|
||||
|
||||
$new_token = $this->data_store->new_request_token($consumer);
|
||||
|
||||
return $new_token;
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* process an access_token request
|
||||
* returns the access token on success
|
||||
*/
|
||||
public function fetch_access_token(&$request) {/*{{{*/
|
||||
$this->get_version($request);
|
||||
|
||||
$consumer = $this->get_consumer($request);
|
||||
|
||||
// requires authorized request token
|
||||
$token = $this->get_token($request, $consumer, "request");
|
||||
|
||||
$this->check_signature($request, $consumer, $token);
|
||||
|
||||
$new_token = $this->data_store->new_access_token($token, $consumer);
|
||||
|
||||
return $new_token;
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* verify an api call, checks all the parameters
|
||||
*/
|
||||
public function verify_request(&$request) {/*{{{*/
|
||||
$this->get_version($request);
|
||||
$consumer = $this->get_consumer($request);
|
||||
$token = $this->get_token($request, $consumer, "access");
|
||||
$this->check_signature($request, $consumer, $token);
|
||||
return array($consumer, $token);
|
||||
}/*}}}*/
|
||||
|
||||
// Internals from here
|
||||
/**
|
||||
* version 1
|
||||
*/
|
||||
private function get_version(&$request) {/*{{{*/
|
||||
$version = $request->get_parameter("oauth_version");
|
||||
if (!$version) {
|
||||
$version = 1.0;
|
||||
}
|
||||
if ($version && $version != $this->version) {
|
||||
throw new OAuthException("OAuth version '$version' not supported");
|
||||
}
|
||||
return $version;
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* figure out the signature with some defaults
|
||||
*/
|
||||
private function get_signature_method(&$request) {/*{{{*/
|
||||
$signature_method =
|
||||
@$request->get_parameter("oauth_signature_method");
|
||||
if (!$signature_method) {
|
||||
$signature_method = "PLAINTEXT";
|
||||
}
|
||||
if (!in_array($signature_method,
|
||||
array_keys($this->signature_methods))) {
|
||||
throw new OAuthException(
|
||||
"Signature method '$signature_method' not supported try one of the following: " . implode(", ", array_keys($this->signature_methods))
|
||||
);
|
||||
}
|
||||
return $this->signature_methods[$signature_method];
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* try to find the consumer for the provided request's consumer key
|
||||
*/
|
||||
private function get_consumer(&$request) {/*{{{*/
|
||||
$consumer_key = @$request->get_parameter("oauth_consumer_key");
|
||||
if (!$consumer_key) {
|
||||
throw new OAuthException("Invalid consumer key");
|
||||
}
|
||||
|
||||
$consumer = $this->data_store->lookup_consumer($consumer_key);
|
||||
if (!$consumer) {
|
||||
throw new OAuthException("Invalid consumer");
|
||||
}
|
||||
|
||||
return $consumer;
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* try to find the token for the provided request's token key
|
||||
*/
|
||||
private function get_token(&$request, $consumer, $token_type="access") {/*{{{*/
|
||||
$token_field = @$request->get_parameter('oauth_token');
|
||||
$token = $this->data_store->lookup_token(
|
||||
$consumer, $token_type, $token_field
|
||||
);
|
||||
if (!$token) {
|
||||
throw new OAuthException("Invalid $token_type token: $token_field");
|
||||
}
|
||||
return $token;
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* all-in-one function to check the signature on a request
|
||||
* should guess the signature method appropriately
|
||||
*/
|
||||
private function check_signature(&$request, $consumer, $token) {/*{{{*/
|
||||
// this should probably be in a different method
|
||||
$timestamp = @$request->get_parameter('oauth_timestamp');
|
||||
$nonce = @$request->get_parameter('oauth_nonce');
|
||||
|
||||
$this->check_timestamp($timestamp);
|
||||
$this->check_nonce($consumer, $token, $nonce, $timestamp);
|
||||
|
||||
$signature_method = $this->get_signature_method($request);
|
||||
|
||||
$signature = $request->get_parameter('oauth_signature');
|
||||
$valid_sig = $signature_method->check_signature(
|
||||
$request,
|
||||
$consumer,
|
||||
$token,
|
||||
$signature
|
||||
);
|
||||
|
||||
if (!$valid_sig) {
|
||||
throw new OAuthException("Invalid signature");
|
||||
}
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* check that the timestamp is new enough
|
||||
*/
|
||||
private function check_timestamp($timestamp) {/*{{{*/
|
||||
// verify that timestamp is recentish
|
||||
$now = time();
|
||||
if ($now - $timestamp > $this->timestamp_threshold) {
|
||||
throw new OAuthException("Expired timestamp, yours $timestamp, ours $now");
|
||||
}
|
||||
}/*}}}*/
|
||||
|
||||
/**
|
||||
* check that the nonce is not repeated
|
||||
*/
|
||||
private function check_nonce($consumer, $token, $nonce, $timestamp) {/*{{{*/
|
||||
// verify that the nonce is uniqueish
|
||||
$found = $this->data_store->lookup_nonce($consumer, $token, $nonce, $timestamp);
|
||||
if ($found) {
|
||||
throw new OAuthException("Nonce already used: $nonce");
|
||||
}
|
||||
}/*}}}*/
|
||||
|
||||
|
||||
|
||||
}/*}}}*/
|
||||
|
||||
class OAuthDataStore {/*{{{*/
|
||||
function lookup_consumer($consumer_key) {/*{{{*/
|
||||
// implement me
|
||||
}/*}}}*/
|
||||
|
||||
function lookup_token($consumer, $token_type, $token) {/*{{{*/
|
||||
// implement me
|
||||
}/*}}}*/
|
||||
|
||||
function lookup_nonce($consumer, $token, $nonce, $timestamp) {/*{{{*/
|
||||
// implement me
|
||||
}/*}}}*/
|
||||
|
||||
function fetch_request_token($consumer) {/*{{{*/
|
||||
// return a new token attached to this consumer
|
||||
}/*}}}*/
|
||||
|
||||
function fetch_access_token($token, $consumer) {/*{{{*/
|
||||
// return a new access token attached to this consumer
|
||||
// for the user associated with this token if the request token
|
||||
// is authorized
|
||||
// should also invalidate the request token
|
||||
}/*}}}*/
|
||||
|
||||
}/*}}}*/
|
||||
|
||||
|
||||
/* A very naive dbm-based oauth storage
|
||||
*/
|
||||
class SimpleOAuthDataStore extends OAuthDataStore {/*{{{*/
|
||||
private $dbh;
|
||||
|
||||
function __construct($path = "oauth.gdbm") {/*{{{*/
|
||||
$this->dbh = dba_popen($path, 'c', 'gdbm');
|
||||
}/*}}}*/
|
||||
|
||||
function __destruct() {/*{{{*/
|
||||
dba_close($this->dbh);
|
||||
}/*}}}*/
|
||||
|
||||
function lookup_consumer($consumer_key) {/*{{{*/
|
||||
$rv = dba_fetch("consumer_$consumer_key", $this->dbh);
|
||||
if ($rv === FALSE) {
|
||||
return NULL;
|
||||
}
|
||||
$obj = unserialize($rv);
|
||||
if (!($obj instanceof OAuthConsumer)) {
|
||||
return NULL;
|
||||
}
|
||||
return $obj;
|
||||
}/*}}}*/
|
||||
|
||||
function lookup_token($consumer, $token_type, $token) {/*{{{*/
|
||||
$rv = dba_fetch("${token_type}_${token}", $this->dbh);
|
||||
if ($rv === FALSE) {
|
||||
return NULL;
|
||||
}
|
||||
$obj = unserialize($rv);
|
||||
if (!($obj instanceof OAuthToken)) {
|
||||
return NULL;
|
||||
}
|
||||
return $obj;
|
||||
}/*}}}*/
|
||||
|
||||
function lookup_nonce($consumer, $token, $nonce, $timestamp) {/*{{{*/
|
||||
return dba_exists("nonce_$nonce", $this->dbh);
|
||||
}/*}}}*/
|
||||
|
||||
function new_token($consumer, $type="request") {/*{{{*/
|
||||
$key = md5(time());
|
||||
$secret = time() + time();
|
||||
$token = new OAuthToken($key, md5(md5($secret)));
|
||||
if (!dba_insert("${type}_$key", serialize($token), $this->dbh)) {
|
||||
throw new OAuthException("doooom!");
|
||||
}
|
||||
return $token;
|
||||
}/*}}}*/
|
||||
|
||||
function new_request_token($consumer) {/*{{{*/
|
||||
return $this->new_token($consumer, "request");
|
||||
}/*}}}*/
|
||||
|
||||
function new_access_token($token, $consumer) {/*{{{*/
|
||||
|
||||
$token = $this->new_token($consumer, 'access');
|
||||
dba_delete("request_" . $token->key, $this->dbh);
|
||||
return $token;
|
||||
}/*}}}*/
|
||||
}/*}}}*/
|
||||
|
||||
class OAuthUtil {/*{{{*/
|
||||
public static function urlencodeRFC3986($string) {/*{{{*/
|
||||
return str_replace('%7E', '~', rawurlencode($string));
|
||||
}/*}}}*/
|
||||
|
||||
public static function urldecodeRFC3986($string) {/*{{{*/
|
||||
return rawurldecode($string);
|
||||
}/*}}}*/
|
||||
}/*}}}*/
|
||||
|
||||
?>
|
||||
+185
@@ -0,0 +1,185 @@
|
||||
<?php
|
||||
/* Copyright (c) 2009 Google Inc.
|
||||
*
|
||||
* 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
|
||||
*
|
||||
* http://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.
|
||||
*
|
||||
* Author: Eric Bidelman <e.bidelman@google.com>
|
||||
*/
|
||||
|
||||
$PRIV_KEY_FILE = '/path/to/your/rsa_private_key.pem';
|
||||
|
||||
// OAuth library - http://oauth.googlecode.com/svn/code/php/
|
||||
require_once('OAuth.php');
|
||||
|
||||
// Google's accepted signature methods
|
||||
$hmac_method = new OAuthSignatureMethod_HMAC_SHA1();
|
||||
$rsa_method = new OAuthSignatureMethod_RSA_SHA1();
|
||||
$SIG_METHODS = array($rsa_method->get_name() => $rsa_method,
|
||||
$hmac_method->get_name() => $hmac_method);
|
||||
|
||||
/**
|
||||
* Makes an HTTP request to the specified URL
|
||||
*
|
||||
* @param string $http_method The HTTP method (GET, POST, PUT, DELETE)
|
||||
* @param string $url Full URL of the resource to access
|
||||
* @param array $extraHeaders (optional) Additional headers to include in each
|
||||
* request. Elements are header/value pair strings ('Host: example.com')
|
||||
* @param string $postData (optional) POST/PUT request body
|
||||
* @param bool $returnResponseHeaders True if resp. headers should be returned.
|
||||
* @return string Response body from the server
|
||||
*/
|
||||
function send_signed_request($http_method, $url, $extraHeaders=null,
|
||||
$postData=null, $returnResponseHeaders=true) {
|
||||
$curl = curl_init($url);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($curl, CURLOPT_FAILONERROR, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
|
||||
// Return request headers in the reponse
|
||||
// curl_setopt($curl, CURLINFO_HEADER_OUT, true);
|
||||
|
||||
// Return response headers ni the response?
|
||||
if ($returnResponseHeaders) {
|
||||
curl_setopt($curl, CURLOPT_HEADER, true);
|
||||
}
|
||||
|
||||
$headers = array();
|
||||
//$headers[] = 'GData-Version: 2.0'; // use GData v2 by default
|
||||
if (is_array($extraHeaders)) {
|
||||
$headers = array_merge($headers, $extraHeaders);
|
||||
}
|
||||
|
||||
// Setup default curl options for each type of HTTP request.
|
||||
// This is also a great place to add additional headers for each request.
|
||||
switch($http_method) {
|
||||
case 'GET':
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
break;
|
||||
case 'POST':
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($curl, CURLOPT_POST, 1);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
break;
|
||||
case 'PUT':
|
||||
$headers[] = 'If-Match: *';
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $http_method);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
|
||||
break;
|
||||
case 'DELETE':
|
||||
$headers[] = 'If-Match: *';
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $http_method);
|
||||
break;
|
||||
default:
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
}
|
||||
|
||||
// Execute the request. If an error occures, fill the response body with it.
|
||||
$response = curl_exec($curl);
|
||||
if (!$response) {
|
||||
$response = curl_error($curl);
|
||||
}
|
||||
|
||||
// Add server's response headers to our response body
|
||||
$response = curl_getinfo($curl, CURLINFO_HEADER_OUT) . $response;
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes XML as a string and returns it nicely indented
|
||||
*
|
||||
* @param string $xml The xml to beautify
|
||||
* @param boolean $html_output True if returned XML should be escaped for HTML.
|
||||
* @return string The beautified xml
|
||||
*/
|
||||
function xml_pretty_printer($xml, $html_output=false) {
|
||||
$xml_obj = new SimpleXMLElement($xml);
|
||||
$level = 2;
|
||||
|
||||
// Get an array containing each XML element
|
||||
$xml = explode("\n", preg_replace('/>\s*</', ">\n<", $xml_obj->asXML()));
|
||||
|
||||
// Hold current indentation level
|
||||
$indent = 0;
|
||||
|
||||
$pretty = array();
|
||||
|
||||
// Shift off opening XML tag if present
|
||||
if (count($xml) && preg_match('/^<\?\s*xml/', $xml[0])) {
|
||||
$pretty[] = array_shift($xml);
|
||||
}
|
||||
|
||||
foreach ($xml as $el) {
|
||||
if (preg_match('/^<([\w])+[^>\/]*>$/U', $el)) {
|
||||
// opening tag, increase indent
|
||||
$pretty[] = str_repeat(' ', $indent) . $el;
|
||||
$indent += $level;
|
||||
} else {
|
||||
if (preg_match('/^<\/.+>$/', $el)) {
|
||||
$indent -= $level; // closing tag, decrease indent
|
||||
}
|
||||
if ($indent < 0) {
|
||||
$indent += $level;
|
||||
}
|
||||
$pretty[] = str_repeat(' ', $indent) . $el;
|
||||
}
|
||||
}
|
||||
|
||||
$xml = implode("\n", $pretty);
|
||||
return $html_output ? htmlentities($xml) : $xml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Joins key/value pairs by $inner_glue and each pair together by $outer_glue.
|
||||
*
|
||||
* Example: implode_assoc('=', '&', array('a' => 1, 'b' => 2)) === 'a=1&b=2'
|
||||
*
|
||||
* @param string $inner_glue What to implode each key/value pair with
|
||||
* @param string $outer_glue What to impode each key/value string subset with
|
||||
* @param array $array Associative array of query parameters
|
||||
* @return string Urlencoded string of query parameters
|
||||
*/
|
||||
function implode_assoc($inner_glue, $outer_glue, $array) {
|
||||
$output = array();
|
||||
foreach($array as $key => $item) {
|
||||
$output[] = $key . $inner_glue . urlencode($item);
|
||||
}
|
||||
return implode($outer_glue, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Explodes a string of key/value url parameters into an associative array.
|
||||
* This method performs the compliment operations of implode_assoc().
|
||||
*
|
||||
* Example: explode_assoc('=', '&', 'a=1&b=2') === array('a' => 1, 'b' => 2)
|
||||
*
|
||||
* @param string $inner_glue What each key/value pair is joined with
|
||||
* @param string $outer_glue What each set of key/value pairs is joined with.
|
||||
* @param array $array Associative array of query parameters
|
||||
* @return array Urlencoded string of query parameters
|
||||
*/
|
||||
function explode_assoc($inner_glue, $outer_glue, $params) {
|
||||
$tempArr = explode($outer_glue, $params);
|
||||
foreach($tempArr as $val) {
|
||||
$pos = strpos($val, $inner_glue);
|
||||
$key = substr($val, 0, $pos);
|
||||
$array2[$key] = substr($val, $pos + 1, strlen($val));
|
||||
}
|
||||
return $array2;
|
||||
}
|
||||
|
||||
?>
|
||||
Vendored
+4587
File diff suppressed because it is too large
Load Diff
Vendored
+183
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP versions 4 and 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1998-2006 Manuel Lemos, Tomas V.V.Cox, |
|
||||
// | Stig. S. Bakken, Lukas Smith |
|
||||
// | All rights reserved. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
|
||||
// | API as well as database abstraction for PHP applications. |
|
||||
// | This LICENSE is in the BSD license style. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | |
|
||||
// | Redistributions in binary form must reproduce the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer in the |
|
||||
// | documentation and/or other materials provided with the distribution. |
|
||||
// | |
|
||||
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
|
||||
// | Lukas Smith nor the names of his contributors may be used to endorse |
|
||||
// | or promote products derived from this software without specific prior|
|
||||
// | written permission. |
|
||||
// | |
|
||||
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
||||
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
||||
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
||||
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
|
||||
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
||||
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
||||
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
|
||||
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||||
// | POSSIBILITY OF SUCH DAMAGE. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Lukas Smith <smith@pooteeweet.org> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
|
||||
/**
|
||||
* @package MDB2
|
||||
* @category Database
|
||||
* @author Lukas Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Several methods to convert the MDB2 native timestamp format (ISO based)
|
||||
* to and from data structures that are convenient to worth with in side of php.
|
||||
* For more complex date arithmetic please take a look at the Date package in PEAR
|
||||
*
|
||||
* @package MDB2
|
||||
* @category Database
|
||||
* @author Lukas Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
class MDB2_Date
|
||||
{
|
||||
// {{{ mdbNow()
|
||||
|
||||
/**
|
||||
* return the current datetime
|
||||
*
|
||||
* @return string current datetime in the MDB2 format
|
||||
* @access public
|
||||
*/
|
||||
function mdbNow()
|
||||
{
|
||||
return date('Y-m-d H:i:s');
|
||||
}
|
||||
// }}}
|
||||
|
||||
// {{{ mdbToday()
|
||||
|
||||
/**
|
||||
* return the current date
|
||||
*
|
||||
* @return string current date in the MDB2 format
|
||||
* @access public
|
||||
*/
|
||||
function mdbToday()
|
||||
{
|
||||
return date('Y-m-d');
|
||||
}
|
||||
// }}}
|
||||
|
||||
// {{{ mdbTime()
|
||||
|
||||
/**
|
||||
* return the current time
|
||||
*
|
||||
* @return string current time in the MDB2 format
|
||||
* @access public
|
||||
*/
|
||||
function mdbTime()
|
||||
{
|
||||
return date('H:i:s');
|
||||
}
|
||||
// }}}
|
||||
|
||||
// {{{ date2Mdbstamp()
|
||||
|
||||
/**
|
||||
* convert a date into a MDB2 timestamp
|
||||
*
|
||||
* @param int hour of the date
|
||||
* @param int minute of the date
|
||||
* @param int second of the date
|
||||
* @param int month of the date
|
||||
* @param int day of the date
|
||||
* @param int year of the date
|
||||
*
|
||||
* @return string a valid MDB2 timestamp
|
||||
* @access public
|
||||
*/
|
||||
function date2Mdbstamp($hour = null, $minute = null, $second = null,
|
||||
$month = null, $day = null, $year = null)
|
||||
{
|
||||
return MDB2_Date::unix2Mdbstamp(mktime($hour, $minute, $second, $month, $day, $year, -1));
|
||||
}
|
||||
// }}}
|
||||
|
||||
// {{{ unix2Mdbstamp()
|
||||
|
||||
/**
|
||||
* convert a unix timestamp into a MDB2 timestamp
|
||||
*
|
||||
* @param int a valid unix timestamp
|
||||
*
|
||||
* @return string a valid MDB2 timestamp
|
||||
* @access public
|
||||
*/
|
||||
function unix2Mdbstamp($unix_timestamp)
|
||||
{
|
||||
return date('Y-m-d H:i:s', $unix_timestamp);
|
||||
}
|
||||
// }}}
|
||||
|
||||
// {{{ mdbstamp2Unix()
|
||||
|
||||
/**
|
||||
* convert a MDB2 timestamp into a unix timestamp
|
||||
*
|
||||
* @param int a valid MDB2 timestamp
|
||||
* @return string unix timestamp with the time stored in the MDB2 format
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function mdbstamp2Unix($mdb_timestamp)
|
||||
{
|
||||
$arr = MDB2_Date::mdbstamp2Date($mdb_timestamp);
|
||||
|
||||
return mktime($arr['hour'], $arr['minute'], $arr['second'], $arr['month'], $arr['day'], $arr['year'], -1);
|
||||
}
|
||||
// }}}
|
||||
|
||||
// {{{ mdbstamp2Date()
|
||||
|
||||
/**
|
||||
* convert a MDB2 timestamp into an array containing all
|
||||
* values necessary to pass to php's date() function
|
||||
*
|
||||
* @param int a valid MDB2 timestamp
|
||||
*
|
||||
* @return array with the time split
|
||||
* @access public
|
||||
*/
|
||||
function mdbstamp2Date($mdb_timestamp)
|
||||
{
|
||||
list($arr['year'], $arr['month'], $arr['day'], $arr['hour'], $arr['minute'], $arr['second']) =
|
||||
sscanf($mdb_timestamp, "%04u-%02u-%02u %02u:%02u:%02u");
|
||||
return $arr;
|
||||
}
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
+1842
File diff suppressed because it is too large
Load Diff
+602
@@ -0,0 +1,602 @@
|
||||
<?php
|
||||
// vim: set et ts=4 sw=4 fdm=marker:
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP versions 4 and 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1998-2008 Manuel Lemos, Tomas V.V.Cox, |
|
||||
// | Stig. S. Bakken, Lukas Smith |
|
||||
// | All rights reserved. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
|
||||
// | API as well as database abstraction for PHP applications. |
|
||||
// | This LICENSE is in the BSD license style. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | |
|
||||
// | Redistributions in binary form must reproduce the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer in the |
|
||||
// | documentation and/or other materials provided with the distribution. |
|
||||
// | |
|
||||
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
|
||||
// | Lukas Smith nor the names of his contributors may be used to endorse |
|
||||
// | or promote products derived from this software without specific prior|
|
||||
// | written permission. |
|
||||
// | |
|
||||
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
||||
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
||||
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
||||
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
|
||||
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
||||
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
||||
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
|
||||
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||||
// | POSSIBILITY OF SUCH DAMAGE. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Lukas Smith <smith@pooteeweet.org> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
|
||||
require_once 'MDB2/Driver/Datatype/Common.php';
|
||||
|
||||
/**
|
||||
* MDB2 MySQL driver
|
||||
*
|
||||
* @package MDB2
|
||||
* @category Database
|
||||
* @author Lukas Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
class MDB2_Driver_Datatype_mysql extends MDB2_Driver_Datatype_Common
|
||||
{
|
||||
// {{{ _getCharsetFieldDeclaration()
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to set the CHARACTER SET
|
||||
* of a field declaration to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* @param string $charset name of the charset
|
||||
* @return string DBMS specific SQL code portion needed to set the CHARACTER SET
|
||||
* of a field declaration.
|
||||
*/
|
||||
function _getCharsetFieldDeclaration($charset)
|
||||
{
|
||||
return 'CHARACTER SET '.$charset;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _getCollationFieldDeclaration()
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to set the COLLATION
|
||||
* of a field declaration to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* @param string $collation name of the collation
|
||||
* @return string DBMS specific SQL code portion needed to set the COLLATION
|
||||
* of a field declaration.
|
||||
*/
|
||||
function _getCollationFieldDeclaration($collation)
|
||||
{
|
||||
return 'COLLATE '.$collation;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getDeclaration()
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to declare
|
||||
* of the given type
|
||||
*
|
||||
* @param string $type type to which the value should be converted to
|
||||
* @param string $name name the field to be declared.
|
||||
* @param string $field definition of the field
|
||||
*
|
||||
* @return string DBMS-specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
* @access public
|
||||
*/
|
||||
function getDeclaration($type, $name, $field)
|
||||
{
|
||||
// MySQL DDL syntax forbids combining NOT NULL with DEFAULT NULL.
|
||||
// To get a default of NULL for NOT NULL columns, omit it.
|
||||
if ( isset($field['notnull'])
|
||||
&& !empty($field['notnull'])
|
||||
&& array_key_exists('default', $field) // do not use isset() here!
|
||||
&& null === $field['default']
|
||||
) {
|
||||
unset($field['default']);
|
||||
}
|
||||
return parent::getDeclaration($type, $name, $field);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getTypeDeclaration()
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to declare an text type
|
||||
* field to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* @param array $field associative array with the name of the properties
|
||||
* of the field being declared as array indexes. Currently, the types
|
||||
* of supported field properties are as follows:
|
||||
*
|
||||
* length
|
||||
* Integer value that determines the maximum length of the text
|
||||
* field. If this argument is missing the field should be
|
||||
* declared to have the longest length allowed by the DBMS.
|
||||
*
|
||||
* default
|
||||
* Text value to be used as default for this field.
|
||||
*
|
||||
* notnull
|
||||
* Boolean flag that indicates whether this field is constrained
|
||||
* to not be set to null.
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
* @access public
|
||||
*/
|
||||
function getTypeDeclaration($field)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
switch ($field['type']) {
|
||||
case 'text':
|
||||
if (empty($field['length']) && array_key_exists('default', $field)) {
|
||||
$field['length'] = $db->varchar_max_length;
|
||||
}
|
||||
$length = !empty($field['length']) ? $field['length'] : false;
|
||||
$fixed = !empty($field['fixed']) ? $field['fixed'] : false;
|
||||
return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR(255)')
|
||||
: ($length ? 'VARCHAR('.$length.')' : 'TEXT');
|
||||
case 'clob':
|
||||
if (!empty($field['length'])) {
|
||||
$length = $field['length'];
|
||||
if ($length <= 255) {
|
||||
return 'TINYTEXT';
|
||||
} elseif ($length <= 65532) {
|
||||
return 'TEXT';
|
||||
} elseif ($length <= 16777215) {
|
||||
return 'MEDIUMTEXT';
|
||||
}
|
||||
}
|
||||
return 'LONGTEXT';
|
||||
case 'blob':
|
||||
if (!empty($field['length'])) {
|
||||
$length = $field['length'];
|
||||
if ($length <= 255) {
|
||||
return 'TINYBLOB';
|
||||
} elseif ($length <= 65532) {
|
||||
return 'BLOB';
|
||||
} elseif ($length <= 16777215) {
|
||||
return 'MEDIUMBLOB';
|
||||
}
|
||||
}
|
||||
return 'LONGBLOB';
|
||||
case 'integer':
|
||||
if (!empty($field['length'])) {
|
||||
$length = $field['length'];
|
||||
if ($length <= 1) {
|
||||
return 'TINYINT';
|
||||
} elseif ($length == 2) {
|
||||
return 'SMALLINT';
|
||||
} elseif ($length == 3) {
|
||||
return 'MEDIUMINT';
|
||||
} elseif ($length == 4) {
|
||||
return 'INT';
|
||||
} elseif ($length > 4) {
|
||||
return 'BIGINT';
|
||||
}
|
||||
}
|
||||
return 'INT';
|
||||
case 'boolean':
|
||||
return 'TINYINT(1)';
|
||||
case 'date':
|
||||
return 'DATE';
|
||||
case 'time':
|
||||
return 'TIME';
|
||||
case 'timestamp':
|
||||
return 'DATETIME';
|
||||
case 'float':
|
||||
$l = '';
|
||||
if (!empty($field['length'])) {
|
||||
$l = '(' . $field['length'];
|
||||
if (!empty($field['scale'])) {
|
||||
$l .= ',' . $field['scale'];
|
||||
}
|
||||
$l .= ')';
|
||||
}
|
||||
return 'DOUBLE' . $l;
|
||||
case 'decimal':
|
||||
$length = !empty($field['length']) ? $field['length'] : 18;
|
||||
$scale = !empty($field['scale']) ? $field['scale'] : $db->options['decimal_places'];
|
||||
return 'DECIMAL('.$length.','.$scale.')';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _getIntegerDeclaration()
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to declare an integer type
|
||||
* field to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* @param string $name name the field to be declared.
|
||||
* @param string $field associative array with the name of the properties
|
||||
* of the field being declared as array indexes.
|
||||
* Currently, the types of supported field
|
||||
* properties are as follows:
|
||||
*
|
||||
* unsigned
|
||||
* Boolean flag that indicates whether the field
|
||||
* should be declared as unsigned integer if
|
||||
* possible.
|
||||
*
|
||||
* default
|
||||
* Integer value to be used as default for this
|
||||
* field.
|
||||
*
|
||||
* notnull
|
||||
* Boolean flag that indicates whether this field is
|
||||
* constrained to not be set to null.
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
* @access protected
|
||||
*/
|
||||
function _getIntegerDeclaration($name, $field)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$default = $autoinc = '';
|
||||
if (!empty($field['autoincrement'])) {
|
||||
$autoinc = ' AUTO_INCREMENT PRIMARY KEY';
|
||||
} elseif (array_key_exists('default', $field)) {
|
||||
if ($field['default'] === '') {
|
||||
$field['default'] = empty($field['notnull']) ? null : 0;
|
||||
}
|
||||
$default = ' DEFAULT '.$this->quote($field['default'], 'integer');
|
||||
}
|
||||
|
||||
$notnull = empty($field['notnull']) ? '' : ' NOT NULL';
|
||||
$unsigned = empty($field['unsigned']) ? '' : ' UNSIGNED';
|
||||
if (empty($default) && empty($notnull)) {
|
||||
$default = ' DEFAULT NULL';
|
||||
}
|
||||
$name = $db->quoteIdentifier($name, true);
|
||||
return $name.' '.$this->getTypeDeclaration($field).$unsigned.$default.$notnull.$autoinc;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _getFloatDeclaration()
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to declare an float type
|
||||
* field to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* @param string $name name the field to be declared.
|
||||
* @param string $field associative array with the name of the properties
|
||||
* of the field being declared as array indexes.
|
||||
* Currently, the types of supported field
|
||||
* properties are as follows:
|
||||
*
|
||||
* unsigned
|
||||
* Boolean flag that indicates whether the field
|
||||
* should be declared as unsigned float if
|
||||
* possible.
|
||||
*
|
||||
* default
|
||||
* float value to be used as default for this
|
||||
* field.
|
||||
*
|
||||
* notnull
|
||||
* Boolean flag that indicates whether this field is
|
||||
* constrained to not be set to null.
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
* @access protected
|
||||
*/
|
||||
function _getFloatDeclaration($name, $field)
|
||||
{
|
||||
// Since AUTO_INCREMENT can be used for integer or floating-point types,
|
||||
// reuse the INTEGER declaration
|
||||
// @see http://bugs.mysql.com/bug.php?id=31032
|
||||
return $this->_getIntegerDeclaration($name, $field);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _getDecimalDeclaration()
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to declare an decimal type
|
||||
* field to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* @param string $name name the field to be declared.
|
||||
* @param string $field associative array with the name of the properties
|
||||
* of the field being declared as array indexes.
|
||||
* Currently, the types of supported field
|
||||
* properties are as follows:
|
||||
*
|
||||
* unsigned
|
||||
* Boolean flag that indicates whether the field
|
||||
* should be declared as unsigned integer if
|
||||
* possible.
|
||||
*
|
||||
* default
|
||||
* Decimal value to be used as default for this
|
||||
* field.
|
||||
*
|
||||
* notnull
|
||||
* Boolean flag that indicates whether this field is
|
||||
* constrained to not be set to null.
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
* @access protected
|
||||
*/
|
||||
function _getDecimalDeclaration($name, $field)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$default = '';
|
||||
if (array_key_exists('default', $field)) {
|
||||
if ($field['default'] === '') {
|
||||
$field['default'] = empty($field['notnull']) ? null : 0;
|
||||
}
|
||||
$default = ' DEFAULT '.$this->quote($field['default'], 'integer');
|
||||
} elseif (empty($field['notnull'])) {
|
||||
$default = ' DEFAULT NULL';
|
||||
}
|
||||
|
||||
$notnull = empty($field['notnull']) ? '' : ' NOT NULL';
|
||||
$unsigned = empty($field['unsigned']) ? '' : ' UNSIGNED';
|
||||
$name = $db->quoteIdentifier($name, true);
|
||||
return $name.' '.$this->getTypeDeclaration($field).$unsigned.$default.$notnull;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ matchPattern()
|
||||
|
||||
/**
|
||||
* build a pattern matching string
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param array $pattern even keys are strings, odd are patterns (% and _)
|
||||
* @param string $operator optional pattern operator (LIKE, ILIKE and maybe others in the future)
|
||||
* @param string $field optional field name that is being matched against
|
||||
* (might be required when emulating ILIKE)
|
||||
*
|
||||
* @return string SQL pattern
|
||||
*/
|
||||
function matchPattern($pattern, $operator = null, $field = null)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$match = '';
|
||||
if (null !== $operator) {
|
||||
$field = (null === $field) ? '' : $field.' ';
|
||||
$operator = strtoupper($operator);
|
||||
switch ($operator) {
|
||||
// case insensitive
|
||||
case 'ILIKE':
|
||||
$match = $field.'LIKE ';
|
||||
break;
|
||||
case 'NOT ILIKE':
|
||||
$match = $field.'NOT LIKE ';
|
||||
break;
|
||||
// case sensitive
|
||||
case 'LIKE':
|
||||
$match = $field.'LIKE BINARY ';
|
||||
break;
|
||||
case 'NOT LIKE':
|
||||
$match = $field.'NOT LIKE BINARY ';
|
||||
break;
|
||||
default:
|
||||
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
|
||||
'not a supported operator type:'. $operator, __FUNCTION__);
|
||||
}
|
||||
}
|
||||
$match.= "'";
|
||||
foreach ($pattern as $key => $value) {
|
||||
if ($key % 2) {
|
||||
$match.= $value;
|
||||
} else {
|
||||
$match.= $db->escapePattern($db->escape($value));
|
||||
}
|
||||
}
|
||||
$match.= "'";
|
||||
$match.= $this->patternEscapeString();
|
||||
return $match;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _mapNativeDatatype()
|
||||
|
||||
/**
|
||||
* Maps a native array description of a field to a MDB2 datatype and length
|
||||
*
|
||||
* @param array $field native field description
|
||||
* @return array containing the various possible types, length, sign, fixed
|
||||
* @access public
|
||||
*/
|
||||
function _mapNativeDatatype($field)
|
||||
{
|
||||
$db_type = strtolower($field['type']);
|
||||
$db_type = strtok($db_type, '(), ');
|
||||
if ($db_type == 'national') {
|
||||
$db_type = strtok('(), ');
|
||||
}
|
||||
if (!empty($field['length'])) {
|
||||
$length = strtok($field['length'], ', ');
|
||||
$decimal = strtok(', ');
|
||||
} else {
|
||||
$length = strtok('(), ');
|
||||
$decimal = strtok('(), ');
|
||||
}
|
||||
$type = array();
|
||||
$unsigned = $fixed = null;
|
||||
switch ($db_type) {
|
||||
case 'tinyint':
|
||||
$type[] = 'integer';
|
||||
$type[] = 'boolean';
|
||||
if (preg_match('/^(is|has)/', $field['name'])) {
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
$unsigned = preg_match('/ unsigned/i', $field['type']);
|
||||
$length = 1;
|
||||
break;
|
||||
case 'smallint':
|
||||
$type[] = 'integer';
|
||||
$unsigned = preg_match('/ unsigned/i', $field['type']);
|
||||
$length = 2;
|
||||
break;
|
||||
case 'mediumint':
|
||||
$type[] = 'integer';
|
||||
$unsigned = preg_match('/ unsigned/i', $field['type']);
|
||||
$length = 3;
|
||||
break;
|
||||
case 'int':
|
||||
case 'integer':
|
||||
$type[] = 'integer';
|
||||
$unsigned = preg_match('/ unsigned/i', $field['type']);
|
||||
$length = 4;
|
||||
break;
|
||||
case 'bigint':
|
||||
$type[] = 'integer';
|
||||
$unsigned = preg_match('/ unsigned/i', $field['type']);
|
||||
$length = 8;
|
||||
break;
|
||||
case 'tinytext':
|
||||
case 'mediumtext':
|
||||
case 'longtext':
|
||||
case 'text':
|
||||
case 'varchar':
|
||||
$fixed = false;
|
||||
case 'string':
|
||||
case 'char':
|
||||
$type[] = 'text';
|
||||
if ($length == '1') {
|
||||
$type[] = 'boolean';
|
||||
if (preg_match('/^(is|has)/', $field['name'])) {
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
} elseif (strstr($db_type, 'text')) {
|
||||
$type[] = 'clob';
|
||||
if ($decimal == 'binary') {
|
||||
$type[] = 'blob';
|
||||
}
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
if ($fixed !== false) {
|
||||
$fixed = true;
|
||||
}
|
||||
break;
|
||||
case 'enum':
|
||||
$type[] = 'text';
|
||||
preg_match_all('/\'.+\'/U', $field['type'], $matches);
|
||||
$length = 0;
|
||||
$fixed = false;
|
||||
if (is_array($matches)) {
|
||||
foreach ($matches[0] as $value) {
|
||||
$length = max($length, strlen($value)-2);
|
||||
}
|
||||
if ($length == '1' && count($matches[0]) == 2) {
|
||||
$type[] = 'boolean';
|
||||
if (preg_match('/^(is|has)/', $field['name'])) {
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
}
|
||||
}
|
||||
$type[] = 'integer';
|
||||
case 'set':
|
||||
$fixed = false;
|
||||
$type[] = 'text';
|
||||
$type[] = 'integer';
|
||||
break;
|
||||
case 'date':
|
||||
$type[] = 'date';
|
||||
$length = null;
|
||||
break;
|
||||
case 'datetime':
|
||||
case 'timestamp':
|
||||
$type[] = 'timestamp';
|
||||
$length = null;
|
||||
break;
|
||||
case 'time':
|
||||
$type[] = 'time';
|
||||
$length = null;
|
||||
break;
|
||||
case 'float':
|
||||
case 'double':
|
||||
case 'real':
|
||||
$type[] = 'float';
|
||||
$unsigned = preg_match('/ unsigned/i', $field['type']);
|
||||
if ($decimal !== false) {
|
||||
$length = $length.','.$decimal;
|
||||
}
|
||||
break;
|
||||
case 'unknown':
|
||||
case 'decimal':
|
||||
case 'numeric':
|
||||
$type[] = 'decimal';
|
||||
$unsigned = preg_match('/ unsigned/i', $field['type']);
|
||||
if ($decimal !== false) {
|
||||
$length = $length.','.$decimal;
|
||||
}
|
||||
break;
|
||||
case 'tinyblob':
|
||||
case 'mediumblob':
|
||||
case 'longblob':
|
||||
case 'blob':
|
||||
$type[] = 'blob';
|
||||
$length = null;
|
||||
break;
|
||||
case 'binary':
|
||||
case 'varbinary':
|
||||
$type[] = 'blob';
|
||||
break;
|
||||
case 'year':
|
||||
$type[] = 'integer';
|
||||
$type[] = 'date';
|
||||
$length = null;
|
||||
break;
|
||||
default:
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
|
||||
'unknown database attribute type: '.$db_type, __FUNCTION__);
|
||||
}
|
||||
|
||||
if ((int)$length <= 0) {
|
||||
$length = null;
|
||||
}
|
||||
|
||||
return array($type, $length, $unsigned, $fixed);
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
+499
@@ -0,0 +1,499 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP versions 4 and 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1998-2007 Manuel Lemos, Tomas V.V.Cox, |
|
||||
// | Stig. S. Bakken, Lukas Smith |
|
||||
// | All rights reserved. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
|
||||
// | API as well as database abstraction for PHP applications. |
|
||||
// | This LICENSE is in the BSD license style. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | |
|
||||
// | Redistributions in binary form must reproduce the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer in the |
|
||||
// | documentation and/or other materials provided with the distribution. |
|
||||
// | |
|
||||
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
|
||||
// | Lukas Smith nor the names of his contributors may be used to endorse |
|
||||
// | or promote products derived from this software without specific prior|
|
||||
// | written permission. |
|
||||
// | |
|
||||
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
||||
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
||||
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
||||
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
|
||||
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
||||
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
||||
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
|
||||
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||||
// | POSSIBILITY OF SUCH DAMAGE. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Lukas Smith <smith@pooteeweet.org> |
|
||||
// +----------------------------------------------------------------------+
|
||||
|
||||
// $Id: oci8.php 295587 2010-02-28 17:16:38Z quipo $
|
||||
|
||||
require_once 'MDB2/Driver/Datatype/Common.php';
|
||||
|
||||
/**
|
||||
* MDB2 OCI8 driver
|
||||
*
|
||||
* @package MDB2
|
||||
* @category Database
|
||||
* @author Lukas Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
class MDB2_Driver_Datatype_oci8 extends MDB2_Driver_Datatype_Common
|
||||
{
|
||||
// {{{ _baseConvertResult()
|
||||
|
||||
/**
|
||||
* general type conversion method
|
||||
*
|
||||
* @param mixed $value refernce to a value to be converted
|
||||
* @param string $type specifies which type to convert to
|
||||
* @param boolean $rtrim [optional] when TRUE [default], apply rtrim() to text
|
||||
* @return object a MDB2 error on failure
|
||||
* @access protected
|
||||
*/
|
||||
function _baseConvertResult($value, $type, $rtrim = true)
|
||||
{
|
||||
if (null === $value) {
|
||||
return null;
|
||||
}
|
||||
switch ($type) {
|
||||
case 'text':
|
||||
if (is_object($value) && is_a($value, 'OCI-Lob')) {
|
||||
//LOB => fetch into variable
|
||||
$clob = $this->_baseConvertResult($value, 'clob', $rtrim);
|
||||
if (!PEAR::isError($clob) && is_resource($clob)) {
|
||||
$clob_value = '';
|
||||
while (!feof($clob)) {
|
||||
$clob_value .= fread($clob, 8192);
|
||||
}
|
||||
$this->destroyLOB($clob);
|
||||
}
|
||||
$value = $clob_value;
|
||||
}
|
||||
if ($rtrim) {
|
||||
$value = rtrim($value);
|
||||
}
|
||||
return $value;
|
||||
case 'date':
|
||||
return substr($value, 0, strlen('YYYY-MM-DD'));
|
||||
case 'time':
|
||||
return substr($value, strlen('YYYY-MM-DD '), strlen('HH:MI:SS'));
|
||||
}
|
||||
return parent::_baseConvertResult($value, $type, $rtrim);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getTypeDeclaration()
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to declare an text type
|
||||
* field to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* @param array $field associative array with the name of the properties
|
||||
* of the field being declared as array indexes. Currently, the types
|
||||
* of supported field properties are as follows:
|
||||
*
|
||||
* length
|
||||
* Integer value that determines the maximum length of the text
|
||||
* field. If this argument is missing the field should be
|
||||
* declared to have the longest length allowed by the DBMS.
|
||||
*
|
||||
* default
|
||||
* Text value to be used as default for this field.
|
||||
*
|
||||
* notnull
|
||||
* Boolean flag that indicates whether this field is constrained
|
||||
* to not be set to null.
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
* @access public
|
||||
*/
|
||||
function getTypeDeclaration($field)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
switch ($field['type']) {
|
||||
case 'text':
|
||||
$length = !empty($field['length'])
|
||||
? $field['length'] : $db->options['default_text_field_length'];
|
||||
$fixed = !empty($field['fixed']) ? $field['fixed'] : false;
|
||||
return $fixed ? 'CHAR('.$length.')' : 'VARCHAR2('.$length.')';
|
||||
case 'clob':
|
||||
return 'CLOB';
|
||||
case 'blob':
|
||||
return 'BLOB';
|
||||
case 'integer':
|
||||
if (!empty($field['length'])) {
|
||||
switch((int)$field['length']) {
|
||||
case 1: $digit = 3; break;
|
||||
case 2: $digit = 5; break;
|
||||
case 3: $digit = 8; break;
|
||||
case 4: $digit = 10; break;
|
||||
case 5: $digit = 13; break;
|
||||
case 6: $digit = 15; break;
|
||||
case 7: $digit = 17; break;
|
||||
case 8: $digit = 20; break;
|
||||
default: $digit = 10;
|
||||
}
|
||||
return 'NUMBER('.$digit.')';
|
||||
}
|
||||
return 'INT';
|
||||
case 'boolean':
|
||||
return 'NUMBER(1)';
|
||||
case 'date':
|
||||
case 'time':
|
||||
case 'timestamp':
|
||||
return 'DATE';
|
||||
case 'float':
|
||||
return 'NUMBER';
|
||||
case 'decimal':
|
||||
$scale = !empty($field['scale']) ? $field['scale'] : $db->options['decimal_places'];
|
||||
return 'NUMBER(*,'.$scale.')';
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _quoteCLOB()
|
||||
|
||||
/**
|
||||
* Convert a text value into a DBMS specific format that is suitable to
|
||||
* compose query statements.
|
||||
*
|
||||
* @param string $value text string value that is intended to be converted.
|
||||
* @param bool $quote determines if the value should be quoted and escaped
|
||||
* @param bool $escape_wildcards if to escape escape wildcards
|
||||
* @return string text string that represents the given argument value in
|
||||
* a DBMS specific format.
|
||||
* @access protected
|
||||
*/
|
||||
function _quoteCLOB($value, $quote, $escape_wildcards)
|
||||
{
|
||||
return 'EMPTY_CLOB()';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _quoteBLOB()
|
||||
|
||||
/**
|
||||
* Convert a text value into a DBMS specific format that is suitable to
|
||||
* compose query statements.
|
||||
*
|
||||
* @param string $value text string value that is intended to be converted.
|
||||
* @param bool $quote determines if the value should be quoted and escaped
|
||||
* @param bool $escape_wildcards if to escape escape wildcards
|
||||
* @return string text string that represents the given argument value in
|
||||
* a DBMS specific format.
|
||||
* @access protected
|
||||
*/
|
||||
function _quoteBLOB($value, $quote, $escape_wildcards)
|
||||
{
|
||||
return 'EMPTY_BLOB()';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _quoteDate()
|
||||
|
||||
/**
|
||||
* Convert a text value into a DBMS specific format that is suitable to
|
||||
* compose query statements.
|
||||
*
|
||||
* @param string $value text string value that is intended to be converted.
|
||||
* @param bool $quote determines if the value should be quoted and escaped
|
||||
* @param bool $escape_wildcards if to escape escape wildcards
|
||||
* @return string text string that represents the given argument value in
|
||||
* a DBMS specific format.
|
||||
* @access protected
|
||||
*/
|
||||
function _quoteDate($value, $quote, $escape_wildcards)
|
||||
{
|
||||
return $this->_quoteText("$value 00:00:00", $quote, $escape_wildcards);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _quoteTimestamp()
|
||||
|
||||
/**
|
||||
* Convert a text value into a DBMS specific format that is suitable to
|
||||
* compose query statements.
|
||||
*
|
||||
* @param string $value text string value that is intended to be converted.
|
||||
* @param bool $quote determines if the value should be quoted and escaped
|
||||
* @param bool $escape_wildcards if to escape escape wildcards
|
||||
* @return string text string that represents the given argument value in
|
||||
* a DBMS specific format.
|
||||
* @access protected
|
||||
*/
|
||||
//function _quoteTimestamp($value, $quote, $escape_wildcards)
|
||||
//{
|
||||
// return $this->_quoteText($value, $quote, $escape_wildcards);
|
||||
//}
|
||||
|
||||
// }}}
|
||||
// {{{ _quoteTime()
|
||||
|
||||
/**
|
||||
* Convert a text value into a DBMS specific format that is suitable to
|
||||
* compose query statements.
|
||||
*
|
||||
* @param string $value text string value that is intended to be converted.
|
||||
* @param bool $quote determines if the value should be quoted and escaped
|
||||
* @param bool $escape_wildcards if to escape escape wildcards
|
||||
* @return string text string that represents the given argument value in
|
||||
* a DBMS specific format.
|
||||
* @access protected
|
||||
*/
|
||||
function _quoteTime($value, $quote, $escape_wildcards)
|
||||
{
|
||||
return $this->_quoteText("0001-01-01 $value", $quote, $escape_wildcards);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ writeLOBToFile()
|
||||
|
||||
/**
|
||||
* retrieve LOB from the database
|
||||
*
|
||||
* @param array $lob array
|
||||
* @param string $file name of the file into which the LOb should be fetched
|
||||
* @return mixed MDB2_OK on success, a MDB2 error on failure
|
||||
* @access protected
|
||||
*/
|
||||
function writeLOBToFile($lob, $file)
|
||||
{
|
||||
if (preg_match('/^(\w+:\/\/)(.*)$/', $file, $match)) {
|
||||
if ($match[1] == 'file://') {
|
||||
$file = $match[2];
|
||||
}
|
||||
}
|
||||
$lob_data = stream_get_meta_data($lob);
|
||||
$lob_index = $lob_data['wrapper_data']->lob_index;
|
||||
$result = $this->lobs[$lob_index]['resource']->writetofile($file);
|
||||
$this->lobs[$lob_index]['resource']->seek(0);
|
||||
if (!$result) {
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
return $db->raiseError(null, null, null,
|
||||
'Unable to write LOB to file', __FUNCTION__);
|
||||
}
|
||||
return MDB2_OK;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _retrieveLOB()
|
||||
|
||||
/**
|
||||
* retrieve LOB from the database
|
||||
*
|
||||
* @param array $lob array
|
||||
* @return mixed MDB2_OK on success, a MDB2 error on failure
|
||||
* @access protected
|
||||
*/
|
||||
function _retrieveLOB(&$lob)
|
||||
{
|
||||
if (!is_object($lob['resource'])) {
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
|
||||
'attemped to retrieve LOB from non existing or NULL column', __FUNCTION__);
|
||||
}
|
||||
|
||||
if (!$lob['loaded']
|
||||
# && !method_exists($lob['resource'], 'read')
|
||||
) {
|
||||
$lob['value'] = $lob['resource']->load();
|
||||
$lob['resource']->seek(0);
|
||||
}
|
||||
$lob['loaded'] = true;
|
||||
return MDB2_OK;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _readLOB()
|
||||
|
||||
/**
|
||||
* Read data from large object input stream.
|
||||
*
|
||||
* @param array $lob array
|
||||
* @param blob $data reference to a variable that will hold data to be
|
||||
* read from the large object input stream
|
||||
* @param int $length integer value that indicates the largest ammount of
|
||||
* data to be read from the large object input stream.
|
||||
* @return mixed length on success, a MDB2 error on failure
|
||||
* @access protected
|
||||
*/
|
||||
function _readLOB($lob, $length)
|
||||
{
|
||||
if ($lob['loaded']) {
|
||||
return parent::_readLOB($lob, $length);
|
||||
}
|
||||
|
||||
if (!is_object($lob['resource'])) {
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
return $db->raiseError(MDB2_ERROR_NOT_FOUND, null, null,
|
||||
'attemped to retrieve LOB from non existing or NULL column', __FUNCTION__);
|
||||
}
|
||||
|
||||
$data = $lob['resource']->read($length);
|
||||
if (!is_string($data)) {
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
return $db->raiseError(null, null, null,
|
||||
'Unable to read LOB', __FUNCTION__);
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ patternEscapeString()
|
||||
|
||||
/**
|
||||
* build string to define escape pattern string
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
*
|
||||
* @return string define escape pattern
|
||||
*/
|
||||
function patternEscapeString()
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
return " ESCAPE '". $db->string_quoting['escape_pattern'] ."'";
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _mapNativeDatatype()
|
||||
|
||||
/**
|
||||
* Maps a native array description of a field to a MDB2 datatype and length
|
||||
*
|
||||
* @param array $field native field description
|
||||
* @return array containing the various possible types, length, sign, fixed
|
||||
* @access public
|
||||
*/
|
||||
function _mapNativeDatatype($field)
|
||||
{
|
||||
$db_type = strtolower($field['type']);
|
||||
$type = array();
|
||||
$length = $unsigned = $fixed = null;
|
||||
if (!empty($field['length'])) {
|
||||
$length = $field['length'];
|
||||
}
|
||||
switch ($db_type) {
|
||||
case 'integer':
|
||||
case 'pls_integer':
|
||||
case 'binary_integer':
|
||||
$type[] = 'integer';
|
||||
if ($length == '1') {
|
||||
$type[] = 'boolean';
|
||||
if (preg_match('/^(is|has)/', $field['name'])) {
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'varchar':
|
||||
case 'varchar2':
|
||||
case 'nvarchar2':
|
||||
$fixed = false;
|
||||
case 'char':
|
||||
case 'nchar':
|
||||
$type[] = 'text';
|
||||
if ($length == '1') {
|
||||
$type[] = 'boolean';
|
||||
if (preg_match('/^(is|has)/', $field['name'])) {
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
}
|
||||
if ($fixed !== false) {
|
||||
$fixed = true;
|
||||
}
|
||||
break;
|
||||
case 'date':
|
||||
case 'timestamp':
|
||||
$type[] = 'timestamp';
|
||||
$length = null;
|
||||
break;
|
||||
case 'float':
|
||||
$type[] = 'float';
|
||||
break;
|
||||
case 'number':
|
||||
if (!empty($field['scale'])) {
|
||||
$type[] = 'decimal';
|
||||
$length = $length.','.$field['scale'];
|
||||
} else {
|
||||
$type[] = 'integer';
|
||||
if ($length == '1') {
|
||||
$type[] = 'boolean';
|
||||
if (preg_match('/^(is|has)/', $field['name'])) {
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'long':
|
||||
$type[] = 'text';
|
||||
case 'clob':
|
||||
case 'nclob':
|
||||
$type[] = 'clob';
|
||||
break;
|
||||
case 'blob':
|
||||
case 'raw':
|
||||
case 'long raw':
|
||||
case 'bfile':
|
||||
$type[] = 'blob';
|
||||
$length = null;
|
||||
break;
|
||||
case 'rowid':
|
||||
case 'urowid':
|
||||
default:
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
|
||||
'unknown database attribute type: '.$db_type, __FUNCTION__);
|
||||
}
|
||||
|
||||
if ((int)$length <= 0) {
|
||||
$length = null;
|
||||
}
|
||||
|
||||
return array($type, $length, $unsigned, $fixed);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
+579
@@ -0,0 +1,579 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP versions 4 and 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1998-2007 Manuel Lemos, Tomas V.V.Cox, |
|
||||
// | Stig. S. Bakken, Lukas Smith |
|
||||
// | All rights reserved. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
|
||||
// | API as well as database abstraction for PHP applications. |
|
||||
// | This LICENSE is in the BSD license style. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | |
|
||||
// | Redistributions in binary form must reproduce the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer in the |
|
||||
// | documentation and/or other materials provided with the distribution. |
|
||||
// | |
|
||||
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
|
||||
// | Lukas Smith nor the names of his contributors may be used to endorse |
|
||||
// | or promote products derived from this software without specific prior|
|
||||
// | written permission. |
|
||||
// | |
|
||||
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
||||
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
||||
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
||||
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
|
||||
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
||||
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
||||
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
|
||||
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||||
// | POSSIBILITY OF SUCH DAMAGE. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Paul Cooper <pgc@ucecom.com> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
|
||||
require_once 'MDB2/Driver/Datatype/Common.php';
|
||||
|
||||
/**
|
||||
* MDB2 PostGreSQL driver
|
||||
*
|
||||
* @package MDB2
|
||||
* @category Database
|
||||
* @author Paul Cooper <pgc@ucecom.com>
|
||||
*/
|
||||
class MDB2_Driver_Datatype_pgsql extends MDB2_Driver_Datatype_Common
|
||||
{
|
||||
// {{{ _baseConvertResult()
|
||||
|
||||
/**
|
||||
* General type conversion method
|
||||
*
|
||||
* @param mixed $value refernce to a value to be converted
|
||||
* @param string $type specifies which type to convert to
|
||||
* @param boolean $rtrim [optional] when TRUE [default], apply rtrim() to text
|
||||
* @return object a MDB2 error on failure
|
||||
* @access protected
|
||||
*/
|
||||
function _baseConvertResult($value, $type, $rtrim = true)
|
||||
{
|
||||
if (null === $value) {
|
||||
return null;
|
||||
}
|
||||
switch ($type) {
|
||||
case 'boolean':
|
||||
return $value == 't';
|
||||
case 'float':
|
||||
return doubleval($value);
|
||||
case 'date':
|
||||
return $value;
|
||||
case 'time':
|
||||
return substr($value, 0, strlen('HH:MM:SS'));
|
||||
case 'timestamp':
|
||||
return substr($value, 0, strlen('YYYY-MM-DD HH:MM:SS'));
|
||||
case 'blob':
|
||||
$value = pg_unescape_bytea($value);
|
||||
return parent::_baseConvertResult($value, $type, $rtrim);
|
||||
}
|
||||
return parent::_baseConvertResult($value, $type, $rtrim);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getTypeDeclaration()
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to declare an text type
|
||||
* field to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* @param array $field associative array with the name of the properties
|
||||
* of the field being declared as array indexes. Currently, the types
|
||||
* of supported field properties are as follows:
|
||||
*
|
||||
* length
|
||||
* Integer value that determines the maximum length of the text
|
||||
* field. If this argument is missing the field should be
|
||||
* declared to have the longest length allowed by the DBMS.
|
||||
*
|
||||
* default
|
||||
* Text value to be used as default for this field.
|
||||
*
|
||||
* notnull
|
||||
* Boolean flag that indicates whether this field is constrained
|
||||
* to not be set to null.
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
* @access public
|
||||
*/
|
||||
function getTypeDeclaration($field)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
switch ($field['type']) {
|
||||
case 'text':
|
||||
$length = !empty($field['length']) ? $field['length'] : false;
|
||||
$fixed = !empty($field['fixed']) ? $field['fixed'] : false;
|
||||
return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$db->options['default_text_field_length'].')')
|
||||
: ($length ? 'VARCHAR('.$length.')' : 'TEXT');
|
||||
case 'clob':
|
||||
return 'TEXT';
|
||||
case 'blob':
|
||||
return 'BYTEA';
|
||||
case 'integer':
|
||||
if (!empty($field['autoincrement'])) {
|
||||
if (!empty($field['length'])) {
|
||||
$length = $field['length'];
|
||||
if ($length > 4) {
|
||||
return 'BIGSERIAL PRIMARY KEY';
|
||||
}
|
||||
}
|
||||
return 'SERIAL PRIMARY KEY';
|
||||
}
|
||||
if (!empty($field['length'])) {
|
||||
$length = $field['length'];
|
||||
if ($length <= 2) {
|
||||
return 'SMALLINT';
|
||||
} elseif ($length == 3 || $length == 4) {
|
||||
return 'INT';
|
||||
} elseif ($length > 4) {
|
||||
return 'BIGINT';
|
||||
}
|
||||
}
|
||||
return 'INT';
|
||||
case 'boolean':
|
||||
return 'BOOLEAN';
|
||||
case 'date':
|
||||
return 'DATE';
|
||||
case 'time':
|
||||
return 'TIME without time zone';
|
||||
case 'timestamp':
|
||||
return 'TIMESTAMP without time zone';
|
||||
case 'float':
|
||||
return 'FLOAT8';
|
||||
case 'decimal':
|
||||
$length = !empty($field['length']) ? $field['length'] : 18;
|
||||
$scale = !empty($field['scale']) ? $field['scale'] : $db->options['decimal_places'];
|
||||
return 'NUMERIC('.$length.','.$scale.')';
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _getIntegerDeclaration()
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to declare an integer type
|
||||
* field to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* @param string $name name the field to be declared.
|
||||
* @param array $field associative array with the name of the properties
|
||||
* of the field being declared as array indexes. Currently, the types
|
||||
* of supported field properties are as follows:
|
||||
*
|
||||
* unsigned
|
||||
* Boolean flag that indicates whether the field should be
|
||||
* declared as unsigned integer if possible.
|
||||
*
|
||||
* default
|
||||
* Integer value to be used as default for this field.
|
||||
*
|
||||
* notnull
|
||||
* Boolean flag that indicates whether this field is constrained
|
||||
* to not be set to null.
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
* @access protected
|
||||
*/
|
||||
function _getIntegerDeclaration($name, $field)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
if (!empty($field['unsigned'])) {
|
||||
$db->warnings[] = "unsigned integer field \"$name\" is being declared as signed integer";
|
||||
}
|
||||
if (!empty($field['autoincrement'])) {
|
||||
$name = $db->quoteIdentifier($name, true);
|
||||
return $name.' '.$this->getTypeDeclaration($field);
|
||||
}
|
||||
$default = '';
|
||||
if (array_key_exists('default', $field)) {
|
||||
if ($field['default'] === '') {
|
||||
$field['default'] = empty($field['notnull']) ? null : 0;
|
||||
}
|
||||
$default = ' DEFAULT '.$this->quote($field['default'], 'integer');
|
||||
}
|
||||
|
||||
$notnull = empty($field['notnull']) ? '' : ' NOT NULL';
|
||||
if (empty($default) && empty($notnull)) {
|
||||
$default = ' DEFAULT NULL';
|
||||
}
|
||||
$name = $db->quoteIdentifier($name, true);
|
||||
return $name.' '.$this->getTypeDeclaration($field).$default.$notnull;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _quoteCLOB()
|
||||
|
||||
/**
|
||||
* Convert a text value into a DBMS specific format that is suitable to
|
||||
* compose query statements.
|
||||
*
|
||||
* @param string $value text string value that is intended to be converted.
|
||||
* @param bool $quote determines if the value should be quoted and escaped
|
||||
* @param bool $escape_wildcards if to escape escape wildcards
|
||||
* @return string text string that represents the given argument value in
|
||||
* a DBMS specific format.
|
||||
* @access protected
|
||||
*/
|
||||
function _quoteCLOB($value, $quote, $escape_wildcards)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
if ($db->options['lob_allow_url_include']) {
|
||||
$value = $this->_readFile($value);
|
||||
if (PEAR::isError($value)) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
return $this->_quoteText($value, $quote, $escape_wildcards);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _quoteBLOB()
|
||||
|
||||
/**
|
||||
* Convert a text value into a DBMS specific format that is suitable to
|
||||
* compose query statements.
|
||||
*
|
||||
* @param string $value text string value that is intended to be converted.
|
||||
* @param bool $quote determines if the value should be quoted and escaped
|
||||
* @param bool $escape_wildcards if to escape escape wildcards
|
||||
* @return string text string that represents the given argument value in
|
||||
* a DBMS specific format.
|
||||
* @access protected
|
||||
*/
|
||||
function _quoteBLOB($value, $quote, $escape_wildcards)
|
||||
{
|
||||
if (!$quote) {
|
||||
return $value;
|
||||
}
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
if ($db->options['lob_allow_url_include']) {
|
||||
$value = $this->_readFile($value);
|
||||
if (PEAR::isError($value)) {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
if (version_compare(PHP_VERSION, '5.2.0RC6', '>=')) {
|
||||
$connection = $db->getConnection();
|
||||
if (PEAR::isError($connection)) {
|
||||
return $connection;
|
||||
}
|
||||
$value = @pg_escape_bytea($connection, $value);
|
||||
} else {
|
||||
$value = @pg_escape_bytea($value);
|
||||
}
|
||||
return "'".$value."'";
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _quoteBoolean()
|
||||
|
||||
/**
|
||||
* Convert a text value into a DBMS specific format that is suitable to
|
||||
* compose query statements.
|
||||
*
|
||||
* @param string $value text string value that is intended to be converted.
|
||||
* @param bool $quote determines if the value should be quoted and escaped
|
||||
* @param bool $escape_wildcards if to escape escape wildcards
|
||||
* @return string text string that represents the given argument value in
|
||||
* a DBMS specific format.
|
||||
* @access protected
|
||||
*/
|
||||
function _quoteBoolean($value, $quote, $escape_wildcards)
|
||||
{
|
||||
$value = $value ? 't' : 'f';
|
||||
if (!$quote) {
|
||||
return $value;
|
||||
}
|
||||
return "'".$value."'";
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ matchPattern()
|
||||
|
||||
/**
|
||||
* build a pattern matching string
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param array $pattern even keys are strings, odd are patterns (% and _)
|
||||
* @param string $operator optional pattern operator (LIKE, ILIKE and maybe others in the future)
|
||||
* @param string $field optional field name that is being matched against
|
||||
* (might be required when emulating ILIKE)
|
||||
*
|
||||
* @return string SQL pattern
|
||||
*/
|
||||
function matchPattern($pattern, $operator = null, $field = null)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$match = '';
|
||||
if (null !== $operator) {
|
||||
$field = (null === $field) ? '' : $field.' ';
|
||||
$operator = strtoupper($operator);
|
||||
switch ($operator) {
|
||||
// case insensitive
|
||||
case 'ILIKE':
|
||||
$match = $field.'ILIKE ';
|
||||
break;
|
||||
case 'NOT ILIKE':
|
||||
$match = $field.'NOT ILIKE ';
|
||||
break;
|
||||
// case sensitive
|
||||
case 'LIKE':
|
||||
$match = $field.'LIKE ';
|
||||
break;
|
||||
case 'NOT LIKE':
|
||||
$match = $field.'NOT LIKE ';
|
||||
break;
|
||||
default:
|
||||
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
|
||||
'not a supported operator type:'. $operator, __FUNCTION__);
|
||||
}
|
||||
}
|
||||
$match.= "'";
|
||||
foreach ($pattern as $key => $value) {
|
||||
if ($key % 2) {
|
||||
$match.= $value;
|
||||
} else {
|
||||
$match.= $db->escapePattern($db->escape($value));
|
||||
}
|
||||
}
|
||||
$match.= "'";
|
||||
$match.= $this->patternEscapeString();
|
||||
return $match;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ patternEscapeString()
|
||||
|
||||
/**
|
||||
* build string to define escape pattern string
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
*
|
||||
* @return string define escape pattern
|
||||
*/
|
||||
function patternEscapeString()
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
return ' ESCAPE '.$this->quote($db->string_quoting['escape_pattern']);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _mapNativeDatatype()
|
||||
|
||||
/**
|
||||
* Maps a native array description of a field to a MDB2 datatype and length
|
||||
*
|
||||
* @param array $field native field description
|
||||
* @return array containing the various possible types, length, sign, fixed
|
||||
* @access public
|
||||
*/
|
||||
function _mapNativeDatatype($field)
|
||||
{
|
||||
$db_type = strtolower($field['type']);
|
||||
$length = $field['length'];
|
||||
$type = array();
|
||||
$unsigned = $fixed = null;
|
||||
switch ($db_type) {
|
||||
case 'smallint':
|
||||
case 'int2':
|
||||
$type[] = 'integer';
|
||||
$unsigned = false;
|
||||
$length = 2;
|
||||
if ($length == '2') {
|
||||
$type[] = 'boolean';
|
||||
if (preg_match('/^(is|has)/', $field['name'])) {
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'int':
|
||||
case 'int4':
|
||||
case 'integer':
|
||||
case 'serial':
|
||||
case 'serial4':
|
||||
$type[] = 'integer';
|
||||
$unsigned = false;
|
||||
$length = 4;
|
||||
break;
|
||||
case 'bigint':
|
||||
case 'int8':
|
||||
case 'bigserial':
|
||||
case 'serial8':
|
||||
$type[] = 'integer';
|
||||
$unsigned = false;
|
||||
$length = 8;
|
||||
break;
|
||||
case 'bool':
|
||||
case 'boolean':
|
||||
$type[] = 'boolean';
|
||||
$length = null;
|
||||
break;
|
||||
case 'text':
|
||||
case 'varchar':
|
||||
$fixed = false;
|
||||
case 'unknown':
|
||||
case 'char':
|
||||
case 'bpchar':
|
||||
$type[] = 'text';
|
||||
if ($length == '1') {
|
||||
$type[] = 'boolean';
|
||||
if (preg_match('/^(is|has)/', $field['name'])) {
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
} elseif (strstr($db_type, 'text')) {
|
||||
$type[] = 'clob';
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
if ($fixed !== false) {
|
||||
$fixed = true;
|
||||
}
|
||||
break;
|
||||
case 'date':
|
||||
$type[] = 'date';
|
||||
$length = null;
|
||||
break;
|
||||
case 'datetime':
|
||||
case 'timestamp':
|
||||
case 'timestamptz':
|
||||
$type[] = 'timestamp';
|
||||
$length = null;
|
||||
break;
|
||||
case 'time':
|
||||
$type[] = 'time';
|
||||
$length = null;
|
||||
break;
|
||||
case 'float':
|
||||
case 'float4':
|
||||
case 'float8':
|
||||
case 'double':
|
||||
case 'real':
|
||||
$type[] = 'float';
|
||||
break;
|
||||
case 'decimal':
|
||||
case 'money':
|
||||
case 'numeric':
|
||||
$type[] = 'decimal';
|
||||
if (isset($field['scale'])) {
|
||||
$length = $length.','.$field['scale'];
|
||||
}
|
||||
break;
|
||||
case 'tinyblob':
|
||||
case 'mediumblob':
|
||||
case 'longblob':
|
||||
case 'blob':
|
||||
case 'bytea':
|
||||
$type[] = 'blob';
|
||||
$length = null;
|
||||
break;
|
||||
case 'oid':
|
||||
$type[] = 'blob';
|
||||
$type[] = 'clob';
|
||||
$length = null;
|
||||
break;
|
||||
case 'year':
|
||||
$type[] = 'integer';
|
||||
$type[] = 'date';
|
||||
$length = null;
|
||||
break;
|
||||
default:
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
|
||||
'unknown database attribute type: '.$db_type, __FUNCTION__);
|
||||
}
|
||||
|
||||
if ((int)$length <= 0) {
|
||||
$length = null;
|
||||
}
|
||||
|
||||
return array($type, $length, $unsigned, $fixed);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ mapPrepareDatatype()
|
||||
|
||||
/**
|
||||
* Maps an mdb2 datatype to native prepare type
|
||||
*
|
||||
* @param string $type
|
||||
* @return string
|
||||
* @access public
|
||||
*/
|
||||
function mapPrepareDatatype($type)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
if (!empty($db->options['datatype_map'][$type])) {
|
||||
$type = $db->options['datatype_map'][$type];
|
||||
if (!empty($db->options['datatype_map_callback'][$type])) {
|
||||
$parameter = array('type' => $type);
|
||||
return call_user_func_array($db->options['datatype_map_callback'][$type], array(&$db, __FUNCTION__, $parameter));
|
||||
}
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'integer':
|
||||
return 'int';
|
||||
case 'boolean':
|
||||
return 'bool';
|
||||
case 'decimal':
|
||||
case 'float':
|
||||
return 'numeric';
|
||||
case 'clob':
|
||||
return 'text';
|
||||
case 'blob':
|
||||
return 'bytea';
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return $type;
|
||||
}
|
||||
// }}}
|
||||
}
|
||||
?>
|
||||
+418
@@ -0,0 +1,418 @@
|
||||
<?php
|
||||
// vim: set et ts=4 sw=4 fdm=marker:
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP versions 4 and 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1998-2007 Manuel Lemos, Tomas V.V.Cox, |
|
||||
// | Stig. S. Bakken, Lukas Smith |
|
||||
// | All rights reserved. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
|
||||
// | API as well as database abstraction for PHP applications. |
|
||||
// | This LICENSE is in the BSD license style. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | |
|
||||
// | Redistributions in binary form must reproduce the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer in the |
|
||||
// | documentation and/or other materials provided with the distribution. |
|
||||
// | |
|
||||
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
|
||||
// | Lukas Smith nor the names of his contributors may be used to endorse |
|
||||
// | or promote products derived from this software without specific prior|
|
||||
// | written permission. |
|
||||
// | |
|
||||
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
||||
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
||||
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
||||
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
|
||||
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
||||
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
||||
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
|
||||
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||||
// | POSSIBILITY OF SUCH DAMAGE. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Lukas Smith <smith@pooteeweet.org> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
|
||||
require_once 'MDB2/Driver/Datatype/Common.php';
|
||||
|
||||
/**
|
||||
* MDB2 SQLite driver
|
||||
*
|
||||
* @package MDB2
|
||||
* @category Database
|
||||
* @author Lukas Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
class MDB2_Driver_Datatype_sqlite extends MDB2_Driver_Datatype_Common
|
||||
{
|
||||
// {{{ _getCollationFieldDeclaration()
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to set the COLLATION
|
||||
* of a field declaration to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* @param string $collation name of the collation
|
||||
*
|
||||
* @return string DBMS specific SQL code portion needed to set the COLLATION
|
||||
* of a field declaration.
|
||||
*/
|
||||
function _getCollationFieldDeclaration($collation)
|
||||
{
|
||||
return 'COLLATE '.$collation;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ getTypeDeclaration()
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to declare an text type
|
||||
* field to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* @param array $field associative array with the name of the properties
|
||||
* of the field being declared as array indexes. Currently, the types
|
||||
* of supported field properties are as follows:
|
||||
*
|
||||
* length
|
||||
* Integer value that determines the maximum length of the text
|
||||
* field. If this argument is missing the field should be
|
||||
* declared to have the longest length allowed by the DBMS.
|
||||
*
|
||||
* default
|
||||
* Text value to be used as default for this field.
|
||||
*
|
||||
* notnull
|
||||
* Boolean flag that indicates whether this field is constrained
|
||||
* to not be set to null.
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
* @access public
|
||||
*/
|
||||
function getTypeDeclaration($field)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
switch ($field['type']) {
|
||||
case 'text':
|
||||
$length = !empty($field['length'])
|
||||
? $field['length'] : false;
|
||||
$fixed = !empty($field['fixed']) ? $field['fixed'] : false;
|
||||
return $fixed ? ($length ? 'CHAR('.$length.')' : 'CHAR('.$db->options['default_text_field_length'].')')
|
||||
: ($length ? 'VARCHAR('.$length.')' : 'TEXT');
|
||||
case 'clob':
|
||||
if (!empty($field['length'])) {
|
||||
$length = $field['length'];
|
||||
if ($length <= 255) {
|
||||
return 'TINYTEXT';
|
||||
} elseif ($length <= 65532) {
|
||||
return 'TEXT';
|
||||
} elseif ($length <= 16777215) {
|
||||
return 'MEDIUMTEXT';
|
||||
}
|
||||
}
|
||||
return 'LONGTEXT';
|
||||
case 'blob':
|
||||
if (!empty($field['length'])) {
|
||||
$length = $field['length'];
|
||||
if ($length <= 255) {
|
||||
return 'TINYBLOB';
|
||||
} elseif ($length <= 65532) {
|
||||
return 'BLOB';
|
||||
} elseif ($length <= 16777215) {
|
||||
return 'MEDIUMBLOB';
|
||||
}
|
||||
}
|
||||
return 'LONGBLOB';
|
||||
case 'integer':
|
||||
if (!empty($field['length'])) {
|
||||
$length = $field['length'];
|
||||
if ($length <= 2) {
|
||||
return 'SMALLINT';
|
||||
} elseif ($length == 3 || $length == 4) {
|
||||
return 'INTEGER';
|
||||
} elseif ($length > 4) {
|
||||
return 'BIGINT';
|
||||
}
|
||||
}
|
||||
return 'INTEGER';
|
||||
case 'boolean':
|
||||
return 'BOOLEAN';
|
||||
case 'date':
|
||||
return 'DATE';
|
||||
case 'time':
|
||||
return 'TIME';
|
||||
case 'timestamp':
|
||||
return 'DATETIME';
|
||||
case 'float':
|
||||
return 'DOUBLE'.($db->options['fixed_float'] ? '('.
|
||||
($db->options['fixed_float']+2).','.$db->options['fixed_float'].')' : '');
|
||||
case 'decimal':
|
||||
$length = !empty($field['length']) ? $field['length'] : 18;
|
||||
$scale = !empty($field['scale']) ? $field['scale'] : $db->options['decimal_places'];
|
||||
return 'DECIMAL('.$length.','.$scale.')';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _getIntegerDeclaration()
|
||||
|
||||
/**
|
||||
* Obtain DBMS specific SQL code portion needed to declare an integer type
|
||||
* field to be used in statements like CREATE TABLE.
|
||||
*
|
||||
* @param string $name name the field to be declared.
|
||||
* @param string $field associative array with the name of the properties
|
||||
* of the field being declared as array indexes.
|
||||
* Currently, the types of supported field
|
||||
* properties are as follows:
|
||||
*
|
||||
* unsigned
|
||||
* Boolean flag that indicates whether the field
|
||||
* should be declared as unsigned integer if
|
||||
* possible.
|
||||
*
|
||||
* default
|
||||
* Integer value to be used as default for this
|
||||
* field.
|
||||
*
|
||||
* notnull
|
||||
* Boolean flag that indicates whether this field is
|
||||
* constrained to not be set to null.
|
||||
* @return string DBMS specific SQL code portion that should be used to
|
||||
* declare the specified field.
|
||||
* @access protected
|
||||
*/
|
||||
function _getIntegerDeclaration($name, $field)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$default = $autoinc = '';
|
||||
if (!empty($field['autoincrement'])) {
|
||||
$autoinc = ' PRIMARY KEY';
|
||||
} elseif (array_key_exists('default', $field)) {
|
||||
if ($field['default'] === '') {
|
||||
$field['default'] = empty($field['notnull']) ? null : 0;
|
||||
}
|
||||
$default = ' DEFAULT '.$this->quote($field['default'], 'integer');
|
||||
}
|
||||
|
||||
$notnull = empty($field['notnull']) ? '' : ' NOT NULL';
|
||||
$unsigned = empty($field['unsigned']) ? '' : ' UNSIGNED';
|
||||
if (empty($default) && empty($notnull)) {
|
||||
$default = ' DEFAULT NULL';
|
||||
}
|
||||
$name = $db->quoteIdentifier($name, true);
|
||||
return $name.' '.$this->getTypeDeclaration($field).$unsigned.$default.$notnull.$autoinc;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ matchPattern()
|
||||
|
||||
/**
|
||||
* build a pattern matching string
|
||||
*
|
||||
* @access public
|
||||
*
|
||||
* @param array $pattern even keys are strings, odd are patterns (% and _)
|
||||
* @param string $operator optional pattern operator (LIKE, ILIKE and maybe others in the future)
|
||||
* @param string $field optional field name that is being matched against
|
||||
* (might be required when emulating ILIKE)
|
||||
*
|
||||
* @return string SQL pattern
|
||||
*/
|
||||
function matchPattern($pattern, $operator = null, $field = null)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$match = '';
|
||||
if (null !== $operator) {
|
||||
$field = (null === $field) ? '' : $field.' ';
|
||||
$operator = strtoupper($operator);
|
||||
switch ($operator) {
|
||||
// case insensitive
|
||||
case 'ILIKE':
|
||||
$match = $field.'LIKE ';
|
||||
break;
|
||||
case 'NOT ILIKE':
|
||||
$match = $field.'NOT LIKE ';
|
||||
break;
|
||||
// case sensitive
|
||||
case 'LIKE':
|
||||
$match = $field.'LIKE ';
|
||||
break;
|
||||
case 'NOT LIKE':
|
||||
$match = $field.'NOT LIKE ';
|
||||
break;
|
||||
default:
|
||||
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
|
||||
'not a supported operator type:'. $operator, __FUNCTION__);
|
||||
}
|
||||
}
|
||||
$match.= "'";
|
||||
foreach ($pattern as $key => $value) {
|
||||
if ($key % 2) {
|
||||
$match.= $value;
|
||||
} else {
|
||||
$match.= $db->escapePattern($db->escape($value));
|
||||
}
|
||||
}
|
||||
$match.= "'";
|
||||
$match.= $this->patternEscapeString();
|
||||
return $match;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ _mapNativeDatatype()
|
||||
|
||||
/**
|
||||
* Maps a native array description of a field to a MDB2 datatype and length
|
||||
*
|
||||
* @param array $field native field description
|
||||
* @return array containing the various possible types, length, sign, fixed
|
||||
* @access public
|
||||
*/
|
||||
function _mapNativeDatatype($field)
|
||||
{
|
||||
$db_type = strtolower($field['type']);
|
||||
$length = !empty($field['length']) ? $field['length'] : null;
|
||||
$unsigned = !empty($field['unsigned']) ? $field['unsigned'] : null;
|
||||
$fixed = null;
|
||||
$type = array();
|
||||
switch ($db_type) {
|
||||
case 'boolean':
|
||||
$type[] = 'boolean';
|
||||
break;
|
||||
case 'tinyint':
|
||||
$type[] = 'integer';
|
||||
$type[] = 'boolean';
|
||||
if (preg_match('/^(is|has)/', $field['name'])) {
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
$unsigned = preg_match('/ unsigned/i', $field['type']);
|
||||
$length = 1;
|
||||
break;
|
||||
case 'smallint':
|
||||
$type[] = 'integer';
|
||||
$unsigned = preg_match('/ unsigned/i', $field['type']);
|
||||
$length = 2;
|
||||
break;
|
||||
case 'mediumint':
|
||||
$type[] = 'integer';
|
||||
$unsigned = preg_match('/ unsigned/i', $field['type']);
|
||||
$length = 3;
|
||||
break;
|
||||
case 'int':
|
||||
case 'integer':
|
||||
case 'serial':
|
||||
$type[] = 'integer';
|
||||
$unsigned = preg_match('/ unsigned/i', $field['type']);
|
||||
$length = 4;
|
||||
break;
|
||||
case 'bigint':
|
||||
case 'bigserial':
|
||||
$type[] = 'integer';
|
||||
$unsigned = preg_match('/ unsigned/i', $field['type']);
|
||||
$length = 8;
|
||||
break;
|
||||
case 'clob':
|
||||
$type[] = 'clob';
|
||||
$fixed = false;
|
||||
break;
|
||||
case 'tinytext':
|
||||
case 'mediumtext':
|
||||
case 'longtext':
|
||||
case 'text':
|
||||
case 'varchar':
|
||||
case 'varchar2':
|
||||
$fixed = false;
|
||||
case 'char':
|
||||
$type[] = 'text';
|
||||
if ($length == '1') {
|
||||
$type[] = 'boolean';
|
||||
if (preg_match('/^(is|has)/', $field['name'])) {
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
} elseif (strstr($db_type, 'text')) {
|
||||
$type[] = 'clob';
|
||||
$type = array_reverse($type);
|
||||
}
|
||||
if ($fixed !== false) {
|
||||
$fixed = true;
|
||||
}
|
||||
break;
|
||||
case 'date':
|
||||
$type[] = 'date';
|
||||
$length = null;
|
||||
break;
|
||||
case 'datetime':
|
||||
case 'timestamp':
|
||||
$type[] = 'timestamp';
|
||||
$length = null;
|
||||
break;
|
||||
case 'time':
|
||||
$type[] = 'time';
|
||||
$length = null;
|
||||
break;
|
||||
case 'float':
|
||||
case 'double':
|
||||
case 'real':
|
||||
$type[] = 'float';
|
||||
break;
|
||||
case 'decimal':
|
||||
case 'numeric':
|
||||
$type[] = 'decimal';
|
||||
$length = $length.','.$field['decimal'];
|
||||
break;
|
||||
case 'tinyblob':
|
||||
case 'mediumblob':
|
||||
case 'longblob':
|
||||
case 'blob':
|
||||
$type[] = 'blob';
|
||||
$length = null;
|
||||
break;
|
||||
case 'year':
|
||||
$type[] = 'integer';
|
||||
$type[] = 'date';
|
||||
$length = null;
|
||||
break;
|
||||
default:
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
return $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
|
||||
'unknown database attribute type: '.$db_type, __FUNCTION__);
|
||||
}
|
||||
|
||||
if ((int)$length <= 0) {
|
||||
$length = null;
|
||||
}
|
||||
|
||||
return array($type, $length, $unsigned, $fixed);
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
|
||||
?>
|
||||
+293
@@ -0,0 +1,293 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP versions 4 and 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1998-2006 Manuel Lemos, Tomas V.V.Cox, |
|
||||
// | Stig. S. Bakken, Lukas Smith |
|
||||
// | All rights reserved. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
|
||||
// | API as well as database abstraction for PHP applications. |
|
||||
// | This LICENSE is in the BSD license style. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | |
|
||||
// | Redistributions in binary form must reproduce the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer in the |
|
||||
// | documentation and/or other materials provided with the distribution. |
|
||||
// | |
|
||||
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
|
||||
// | Lukas Smith nor the names of his contributors may be used to endorse |
|
||||
// | or promote products derived from this software without specific prior|
|
||||
// | written permission. |
|
||||
// | |
|
||||
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
||||
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
||||
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
||||
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
|
||||
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
||||
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
||||
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
|
||||
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||||
// | POSSIBILITY OF SUCH DAMAGE. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Lukas Smith <smith@pooteeweet.org> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
|
||||
/**
|
||||
* @package MDB2
|
||||
* @category Database
|
||||
* @author Lukas Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base class for the function modules that is extended by each MDB2 driver
|
||||
*
|
||||
* To load this module in the MDB2 object:
|
||||
* $mdb->loadModule('Function');
|
||||
*
|
||||
* @package MDB2
|
||||
* @category Database
|
||||
* @author Lukas Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
class MDB2_Driver_Function_Common extends MDB2_Module_Common
|
||||
{
|
||||
// {{{ executeStoredProc()
|
||||
|
||||
/**
|
||||
* Execute a stored procedure and return any results
|
||||
*
|
||||
* @param string $name string that identifies the function to execute
|
||||
* @param mixed $params array that contains the paramaters to pass the stored proc
|
||||
* @param mixed $types array that contains the types of the columns in
|
||||
* the result set
|
||||
* @param mixed $result_class string which specifies which result class to use
|
||||
* @param mixed $result_wrap_class string which specifies which class to wrap results in
|
||||
*
|
||||
* @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure
|
||||
* @access public
|
||||
*/
|
||||
function executeStoredProc($name, $params = null, $types = null, $result_class = true, $result_wrap_class = false)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$error = $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
|
||||
'method not implemented', __FUNCTION__);
|
||||
return $error;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ functionTable()
|
||||
|
||||
/**
|
||||
* return string for internal table used when calling only a function
|
||||
*
|
||||
* @return string for internal table used when calling only a function
|
||||
* @access public
|
||||
*/
|
||||
function functionTable()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ now()
|
||||
|
||||
/**
|
||||
* Return string to call a variable with the current timestamp inside an SQL statement
|
||||
* There are three special variables for current date and time:
|
||||
* - CURRENT_TIMESTAMP (date and time, TIMESTAMP type)
|
||||
* - CURRENT_DATE (date, DATE type)
|
||||
* - CURRENT_TIME (time, TIME type)
|
||||
*
|
||||
* @param string $type 'timestamp' | 'time' | 'date'
|
||||
*
|
||||
* @return string to call a variable with the current timestamp
|
||||
* @access public
|
||||
*/
|
||||
function now($type = 'timestamp')
|
||||
{
|
||||
switch ($type) {
|
||||
case 'time':
|
||||
return 'CURRENT_TIME';
|
||||
case 'date':
|
||||
return 'CURRENT_DATE';
|
||||
case 'timestamp':
|
||||
default:
|
||||
return 'CURRENT_TIMESTAMP';
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ unixtimestamp()
|
||||
|
||||
/**
|
||||
* return string to call a function to get the unix timestamp from a iso timestamp
|
||||
*
|
||||
* @param string $expression
|
||||
*
|
||||
* @return string to call a variable with the timestamp
|
||||
* @access public
|
||||
*/
|
||||
function unixtimestamp($expression)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$error = $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
|
||||
'method not implemented', __FUNCTION__);
|
||||
return $error;
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ substring()
|
||||
|
||||
/**
|
||||
* return string to call a function to get a substring inside an SQL statement
|
||||
*
|
||||
* @return string to call a function to get a substring
|
||||
* @access public
|
||||
*/
|
||||
function substring($value, $position = 1, $length = null)
|
||||
{
|
||||
if (null !== $length) {
|
||||
return "SUBSTRING($value FROM $position FOR $length)";
|
||||
}
|
||||
return "SUBSTRING($value FROM $position)";
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ replace()
|
||||
|
||||
/**
|
||||
* return string to call a function to get replace inside an SQL statement.
|
||||
*
|
||||
* @return string to call a function to get a replace
|
||||
* @access public
|
||||
*/
|
||||
function replace($str, $from_str, $to_str)
|
||||
{
|
||||
return "REPLACE($str, $from_str , $to_str)";
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ concat()
|
||||
|
||||
/**
|
||||
* Returns string to concatenate two or more string parameters
|
||||
*
|
||||
* @param string $value1
|
||||
* @param string $value2
|
||||
* @param string $values...
|
||||
*
|
||||
* @return string to concatenate two strings
|
||||
* @access public
|
||||
*/
|
||||
function concat($value1, $value2)
|
||||
{
|
||||
$args = func_get_args();
|
||||
return "(".implode(' || ', $args).")";
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ random()
|
||||
|
||||
/**
|
||||
* return string to call a function to get random value inside an SQL statement
|
||||
*
|
||||
* @return return string to generate float between 0 and 1
|
||||
* @access public
|
||||
*/
|
||||
function random()
|
||||
{
|
||||
return 'RAND()';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ lower()
|
||||
|
||||
/**
|
||||
* return string to call a function to lower the case of an expression
|
||||
*
|
||||
* @param string $expression
|
||||
*
|
||||
* @return return string to lower case of an expression
|
||||
* @access public
|
||||
*/
|
||||
function lower($expression)
|
||||
{
|
||||
return "LOWER($expression)";
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ upper()
|
||||
|
||||
/**
|
||||
* return string to call a function to upper the case of an expression
|
||||
*
|
||||
* @param string $expression
|
||||
*
|
||||
* @return return string to upper case of an expression
|
||||
* @access public
|
||||
*/
|
||||
function upper($expression)
|
||||
{
|
||||
return "UPPER($expression)";
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ length()
|
||||
|
||||
/**
|
||||
* return string to call a function to get the length of a string expression
|
||||
*
|
||||
* @param string $expression
|
||||
*
|
||||
* @return return string to get the string expression length
|
||||
* @access public
|
||||
*/
|
||||
function length($expression)
|
||||
{
|
||||
return "LENGTH($expression)";
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ guid()
|
||||
|
||||
/**
|
||||
* Returns global unique identifier
|
||||
*
|
||||
* @return string to get global unique identifier
|
||||
* @access public
|
||||
*/
|
||||
function guid()
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$error = $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
|
||||
'method not implemented', __FUNCTION__);
|
||||
return $error;
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
?>
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP versions 4 and 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1998-2008 Manuel Lemos, Tomas V.V.Cox, |
|
||||
// | Stig. S. Bakken, Lukas Smith |
|
||||
// | All rights reserved. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
|
||||
// | API as well as database abstraction for PHP applications. |
|
||||
// | This LICENSE is in the BSD license style. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | |
|
||||
// | Redistributions in binary form must reproduce the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer in the |
|
||||
// | documentation and/or other materials provided with the distribution. |
|
||||
// | |
|
||||
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
|
||||
// | Lukas Smith nor the names of his contributors may be used to endorse |
|
||||
// | or promote products derived from this software without specific prior|
|
||||
// | written permission. |
|
||||
// | |
|
||||
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
||||
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
||||
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
||||
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
|
||||
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
||||
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
||||
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
|
||||
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||||
// | POSSIBILITY OF SUCH DAMAGE. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Lukas Smith <smith@pooteeweet.org> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
|
||||
require_once 'MDB2/Driver/Function/Common.php';
|
||||
|
||||
/**
|
||||
* MDB2 MySQL driver for the function modules
|
||||
*
|
||||
* @package MDB2
|
||||
* @category Database
|
||||
* @author Lukas Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
class MDB2_Driver_Function_mysql extends MDB2_Driver_Function_Common
|
||||
{
|
||||
// }}}
|
||||
// {{{ executeStoredProc()
|
||||
|
||||
/**
|
||||
* Execute a stored procedure and return any results
|
||||
*
|
||||
* @param string $name string that identifies the function to execute
|
||||
* @param mixed $params array that contains the paramaters to pass the stored proc
|
||||
* @param mixed $types array that contains the types of the columns in
|
||||
* the result set
|
||||
* @param mixed $result_class string which specifies which result class to use
|
||||
* @param mixed $result_wrap_class string which specifies which class to wrap results in
|
||||
* @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure
|
||||
* @access public
|
||||
*/
|
||||
function executeStoredProc($name, $params = null, $types = null, $result_class = true, $result_wrap_class = false)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$query = 'CALL '.$name;
|
||||
$query .= $params ? '('.implode(', ', $params).')' : '()';
|
||||
return $db->query($query, $types, $result_class, $result_wrap_class);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ unixtimestamp()
|
||||
|
||||
/**
|
||||
* return string to call a function to get the unix timestamp from a iso timestamp
|
||||
*
|
||||
* @param string $expression
|
||||
*
|
||||
* @return string to call a variable with the timestamp
|
||||
* @access public
|
||||
*/
|
||||
function unixtimestamp($expression)
|
||||
{
|
||||
return 'UNIX_TIMESTAMP('. $expression.')';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ concat()
|
||||
|
||||
/**
|
||||
* Returns string to concatenate two or more string parameters
|
||||
*
|
||||
* @param string $value1
|
||||
* @param string $value2
|
||||
* @param string $values...
|
||||
* @return string to concatenate two strings
|
||||
* @access public
|
||||
**/
|
||||
function concat($value1, $value2)
|
||||
{
|
||||
$args = func_get_args();
|
||||
return "CONCAT(".implode(', ', $args).")";
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ guid()
|
||||
|
||||
/**
|
||||
* Returns global unique identifier
|
||||
*
|
||||
* @return string to get global unique identifier
|
||||
* @access public
|
||||
*/
|
||||
function guid()
|
||||
{
|
||||
return 'UUID()';
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
?>
|
||||
+187
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP versions 4 and 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1998-2008 Manuel Lemos, Tomas V.V.Cox, |
|
||||
// | Stig. S. Bakken, Lukas Smith |
|
||||
// | All rights reserved. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
|
||||
// | API as well as database abstraction for PHP applications. |
|
||||
// | This LICENSE is in the BSD license style. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | |
|
||||
// | Redistributions in binary form must reproduce the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer in the |
|
||||
// | documentation and/or other materials provided with the distribution. |
|
||||
// | |
|
||||
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
|
||||
// | Lukas Smith nor the names of his contributors may be used to endorse |
|
||||
// | or promote products derived from this software without specific prior|
|
||||
// | written permission. |
|
||||
// | |
|
||||
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
||||
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
||||
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
||||
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
|
||||
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
||||
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
||||
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
|
||||
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||||
// | POSSIBILITY OF SUCH DAMAGE. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Lukas Smith <smith@pooteeweet.org> |
|
||||
// +----------------------------------------------------------------------+
|
||||
|
||||
// $Id: oci8.php 295587 2010-02-28 17:16:38Z quipo $
|
||||
|
||||
require_once 'MDB2/Driver/Function/Common.php';
|
||||
|
||||
/**
|
||||
* MDB2 oci8 driver for the function modules
|
||||
*
|
||||
* @package MDB2
|
||||
* @category Database
|
||||
* @author Lukas Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
class MDB2_Driver_Function_oci8 extends MDB2_Driver_Function_Common
|
||||
{
|
||||
// {{{ executeStoredProc()
|
||||
|
||||
/**
|
||||
* Execute a stored procedure and return any results
|
||||
*
|
||||
* @param string $name string that identifies the function to execute
|
||||
* @param mixed $params array that contains the paramaters to pass the stored proc
|
||||
* @param mixed $types array that contains the types of the columns in
|
||||
* the result set
|
||||
* @param mixed $result_class string which specifies which result class to use
|
||||
* @param mixed $result_wrap_class string which specifies which class to wrap results in
|
||||
* @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure
|
||||
* @access public
|
||||
*/
|
||||
function executeStoredProc($name, $params = null, $types = null, $result_class = true, $result_wrap_class = false)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$query = 'EXEC '.$name;
|
||||
$query .= $params ? '('.implode(', ', $params).')' : '()';
|
||||
return $db->query($query, $types, $result_class, $result_wrap_class);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ functionTable()
|
||||
|
||||
/**
|
||||
* return string for internal table used when calling only a function
|
||||
*
|
||||
* @return string for internal table used when calling only a function
|
||||
* @access public
|
||||
*/
|
||||
function functionTable()
|
||||
{
|
||||
return ' FROM dual';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ now()
|
||||
|
||||
/**
|
||||
* Return string to call a variable with the current timestamp inside an SQL statement
|
||||
* There are three special variables for current date and time:
|
||||
* - CURRENT_TIMESTAMP (date and time, TIMESTAMP type)
|
||||
* - CURRENT_DATE (date, DATE type)
|
||||
* - CURRENT_TIME (time, TIME type)
|
||||
*
|
||||
* @return string to call a variable with the current timestamp
|
||||
* @access public
|
||||
*/
|
||||
function now($type = 'timestamp')
|
||||
{
|
||||
switch ($type) {
|
||||
case 'date':
|
||||
case 'time':
|
||||
case 'timestamp':
|
||||
default:
|
||||
return 'TO_CHAR(CURRENT_TIMESTAMP, \'YYYY-MM-DD HH24:MI:SS\')';
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ unixtimestamp()
|
||||
|
||||
/**
|
||||
* return string to call a function to get the unix timestamp from a iso timestamp
|
||||
*
|
||||
* @param string $expression
|
||||
*
|
||||
* @return string to call a variable with the timestamp
|
||||
* @access public
|
||||
*/
|
||||
function unixtimestamp($expression)
|
||||
{
|
||||
$utc_offset = 'CAST(SYS_EXTRACT_UTC(SYSTIMESTAMP) AS DATE) - CAST(SYSTIMESTAMP AS DATE)';
|
||||
$epoch_date = 'to_date(\'19700101\', \'YYYYMMDD\')';
|
||||
return '(CAST('.$expression.' AS DATE) - '.$epoch_date.' + '.$utc_offset.') * 86400 seconds';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ substring()
|
||||
|
||||
/**
|
||||
* return string to call a function to get a substring inside an SQL statement
|
||||
*
|
||||
* @return string to call a function to get a substring
|
||||
* @access public
|
||||
*/
|
||||
function substring($value, $position = 1, $length = null)
|
||||
{
|
||||
if (null !== $length) {
|
||||
return "SUBSTR($value, $position, $length)";
|
||||
}
|
||||
return "SUBSTR($value, $position)";
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ random()
|
||||
|
||||
/**
|
||||
* return string to call a function to get random value inside an SQL statement
|
||||
*
|
||||
* @return return string to generate float between 0 and 1
|
||||
* @access public
|
||||
*/
|
||||
function random()
|
||||
{
|
||||
return 'dbms_random.value';
|
||||
}
|
||||
|
||||
// }}}}
|
||||
// {{{ guid()
|
||||
|
||||
/**
|
||||
* Returns global unique identifier
|
||||
*
|
||||
* @return string to get global unique identifier
|
||||
* @access public
|
||||
*/
|
||||
function guid()
|
||||
{
|
||||
return 'SYS_GUID()';
|
||||
}
|
||||
|
||||
// }}}}
|
||||
}
|
||||
?>
|
||||
+132
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP versions 4 and 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1998-2008 Manuel Lemos, Tomas V.V.Cox, |
|
||||
// | Stig. S. Bakken, Lukas Smith |
|
||||
// | All rights reserved. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
|
||||
// | API as well as database abstraction for PHP applications. |
|
||||
// | This LICENSE is in the BSD license style. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | |
|
||||
// | Redistributions in binary form must reproduce the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer in the |
|
||||
// | documentation and/or other materials provided with the distribution. |
|
||||
// | |
|
||||
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
|
||||
// | Lukas Smith nor the names of his contributors may be used to endorse |
|
||||
// | or promote products derived from this software without specific prior|
|
||||
// | written permission. |
|
||||
// | |
|
||||
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
||||
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
||||
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
||||
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
|
||||
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
||||
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
||||
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
|
||||
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||||
// | POSSIBILITY OF SUCH DAMAGE. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Paul Cooper <pgc@ucecom.com> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
|
||||
require_once 'MDB2/Driver/Function/Common.php';
|
||||
|
||||
/**
|
||||
* MDB2 MySQL driver for the function modules
|
||||
*
|
||||
* @package MDB2
|
||||
* @category Database
|
||||
* @author Lukas Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
class MDB2_Driver_Function_pgsql extends MDB2_Driver_Function_Common
|
||||
{
|
||||
// {{{ executeStoredProc()
|
||||
|
||||
/**
|
||||
* Execute a stored procedure and return any results
|
||||
*
|
||||
* @param string $name string that identifies the function to execute
|
||||
* @param mixed $params array that contains the paramaters to pass the stored proc
|
||||
* @param mixed $types array that contains the types of the columns in
|
||||
* the result set
|
||||
* @param mixed $result_class string which specifies which result class to use
|
||||
* @param mixed $result_wrap_class string which specifies which class to wrap results in
|
||||
* @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure
|
||||
* @access public
|
||||
*/
|
||||
function executeStoredProc($name, $params = null, $types = null, $result_class = true, $result_wrap_class = false)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$query = 'SELECT * FROM '.$name;
|
||||
$query .= $params ? '('.implode(', ', $params).')' : '()';
|
||||
return $db->query($query, $types, $result_class, $result_wrap_class);
|
||||
}
|
||||
// }}}
|
||||
// {{{ unixtimestamp()
|
||||
|
||||
/**
|
||||
* return string to call a function to get the unix timestamp from a iso timestamp
|
||||
*
|
||||
* @param string $expression
|
||||
*
|
||||
* @return string to call a variable with the timestamp
|
||||
* @access public
|
||||
*/
|
||||
function unixtimestamp($expression)
|
||||
{
|
||||
return 'EXTRACT(EPOCH FROM DATE_TRUNC(\'seconds\', CAST ((' . $expression . ') AS TIMESTAMP)))';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ substring()
|
||||
|
||||
/**
|
||||
* return string to call a function to get a substring inside an SQL statement
|
||||
*
|
||||
* @return string to call a function to get a substring
|
||||
* @access public
|
||||
*/
|
||||
function substring($value, $position = 1, $length = null)
|
||||
{
|
||||
if (null !== $length) {
|
||||
return "SUBSTRING(CAST($value AS VARCHAR) FROM $position FOR $length)";
|
||||
}
|
||||
return "SUBSTRING(CAST($value AS VARCHAR) FROM $position)";
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ random()
|
||||
|
||||
/**
|
||||
* return string to call a function to get random value inside an SQL statement
|
||||
*
|
||||
* @return return string to generate float between 0 and 1
|
||||
* @access public
|
||||
*/
|
||||
function random()
|
||||
{
|
||||
return 'RANDOM()';
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
?>
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP versions 4 and 5 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1998-2008 Manuel Lemos, Tomas V.V.Cox, |
|
||||
// | Stig. S. Bakken, Lukas Smith |
|
||||
// | All rights reserved. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | MDB2 is a merge of PEAR DB and Metabases that provides a unified DB |
|
||||
// | API as well as database abstraction for PHP applications. |
|
||||
// | This LICENSE is in the BSD license style. |
|
||||
// | |
|
||||
// | Redistribution and use in source and binary forms, with or without |
|
||||
// | modification, are permitted provided that the following conditions |
|
||||
// | are met: |
|
||||
// | |
|
||||
// | Redistributions of source code must retain the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer. |
|
||||
// | |
|
||||
// | Redistributions in binary form must reproduce the above copyright |
|
||||
// | notice, this list of conditions and the following disclaimer in the |
|
||||
// | documentation and/or other materials provided with the distribution. |
|
||||
// | |
|
||||
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
|
||||
// | Lukas Smith nor the names of his contributors may be used to endorse |
|
||||
// | or promote products derived from this software without specific prior|
|
||||
// | written permission. |
|
||||
// | |
|
||||
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
||||
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
||||
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
||||
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
||||
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
||||
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
||||
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
|
||||
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
||||
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
||||
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
|
||||
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
||||
// | POSSIBILITY OF SUCH DAMAGE. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Author: Lukas Smith <smith@pooteeweet.org> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
|
||||
require_once 'MDB2/Driver/Function/Common.php';
|
||||
|
||||
/**
|
||||
* MDB2 SQLite driver for the function modules
|
||||
*
|
||||
* @package MDB2
|
||||
* @category Database
|
||||
* @author Lukas Smith <smith@pooteeweet.org>
|
||||
*/
|
||||
class MDB2_Driver_Function_sqlite extends MDB2_Driver_Function_Common
|
||||
{
|
||||
// {{{ constructor
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct($db_index)
|
||||
{
|
||||
parent::__construct($db_index);
|
||||
// create all sorts of UDFs
|
||||
}
|
||||
|
||||
// {{{ now()
|
||||
|
||||
/**
|
||||
* Return string to call a variable with the current timestamp inside an SQL statement
|
||||
* There are three special variables for current date and time.
|
||||
*
|
||||
* @return string to call a variable with the current timestamp
|
||||
* @access public
|
||||
*/
|
||||
function now($type = 'timestamp')
|
||||
{
|
||||
switch ($type) {
|
||||
case 'time':
|
||||
return 'time(\'now\')';
|
||||
case 'date':
|
||||
return 'date(\'now\')';
|
||||
case 'timestamp':
|
||||
default:
|
||||
return 'datetime(\'now\')';
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ unixtimestamp()
|
||||
|
||||
/**
|
||||
* return string to call a function to get the unix timestamp from a iso timestamp
|
||||
*
|
||||
* @param string $expression
|
||||
*
|
||||
* @return string to call a variable with the timestamp
|
||||
* @access public
|
||||
*/
|
||||
function unixtimestamp($expression)
|
||||
{
|
||||
return 'strftime("%s",'. $expression.', "utc")';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ substring()
|
||||
|
||||
/**
|
||||
* return string to call a function to get a substring inside an SQL statement
|
||||
*
|
||||
* @return string to call a function to get a substring
|
||||
* @access public
|
||||
*/
|
||||
function substring($value, $position = 1, $length = null)
|
||||
{
|
||||
if (null !== $length) {
|
||||
return "substr($value, $position, $length)";
|
||||
}
|
||||
return "substr($value, $position, length($value))";
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ random()
|
||||
|
||||
/**
|
||||
* return string to call a function to get random value inside an SQL statement
|
||||
*
|
||||
* @return return string to generate float between 0 and 1
|
||||
* @access public
|
||||
*/
|
||||
function random()
|
||||
{
|
||||
return '((RANDOM()+2147483648)/4294967296)';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ replace()
|
||||
|
||||
/**
|
||||
* return string to call a function to get a replacement inside an SQL statement.
|
||||
*
|
||||
* @return string to call a function to get a replace
|
||||
* @access public
|
||||
*/
|
||||
function replace($str, $from_str, $to_str)
|
||||
{
|
||||
$db = $this->getDBInstance();
|
||||
if (PEAR::isError($db)) {
|
||||
return $db;
|
||||
}
|
||||
|
||||
$error = $db->raiseError(MDB2_ERROR_UNSUPPORTED, null, null,
|
||||
'method not implemented', __FUNCTION__);
|
||||
return $error;
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
?>
|
||||
+1038
File diff suppressed because it is too large
Load Diff
+1471
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user