diff options
| author | Austin Gillmann <alucard@cuntflaps.me> | 2017-01-04 02:12:58 +0100 |
|---|---|---|
| committer | Austin Gillmann <alucard@cuntflaps.me> | 2017-01-04 02:12:58 +0100 |
| commit | b4fc2f892b877fe0cfb90063248d720bf87b49c8 (patch) | |
| tree | bc549baf7bbfcc1fb5af576a41fbce4439d3d1f4 /static/php/includes | |
| parent | 2a57c9e78f3b23c9251adfd8773681fe695fe76d (diff) | |
Merge php submodule into pomf, delete expiry.
Diffstat (limited to 'static/php/includes')
| -rw-r--r-- | static/php/includes/database.inc.php | 30 | ||||
| -rw-r--r-- | static/php/includes/settings.inc.php | 118 |
2 files changed, 148 insertions, 0 deletions
diff --git a/static/php/includes/database.inc.php b/static/php/includes/database.inc.php new file mode 100644 index 0000000..7a1d4f9 --- /dev/null +++ b/static/php/includes/database.inc.php @@ -0,0 +1,30 @@ +<?php + +/** + * Prepares a PDO connection between Pomf and a database server. + * + * @copyright Copyright (c) 2013 Peter Lejeck <peter.lejeck@gmail.com> + * + * 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. + */ + +require_once 'settings.inc.php'; + +/* NOTE: we don't have to unref the PDO because we're not long-running */ +$db = new PDO(POMF_DB_CONN, POMF_DB_USER, POMF_DB_PASS); diff --git a/static/php/includes/settings.inc.php b/static/php/includes/settings.inc.php new file mode 100644 index 0000000..c0767cf --- /dev/null +++ b/static/php/includes/settings.inc.php @@ -0,0 +1,118 @@ +<?php + +/** + * User configurable settings for Pomf. + * + * @copyright Copyright (c) 2013, 2014 Peter Lejeck <peter.lejeck@gmail.com> + * @copyright Copyright (c) 2015 cenci0 <alchimist94@gmail.com> + * @copyright Copyright (c) 2015, 2016 the Pantsu.cat developers + * <hostmaster@pantsu.cat> + * + * 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. + */ + +/** + * PDO connection socket + * + * Database connection to use for communication. Currently, MySQL is the only + * DSN prefix supported. + * + * @see http://php.net/manual/en/ref.pdo-mysql.connection.php PHP manual for + * PDO_MYSQL DSN. + * @param string POMF_DB_CONN DSN:host|unix_socket=hostname|path;dbname=database + */ +define('POMF_DB_CONN', 'mysql:unix_socket=/var/run/mysqld/mysqld.sock;dbname=pomf'); + +/** + * PDO database login credentials + */ + +/** @param string POMF_DB_NAME Database username */ +define('POMF_DB_USER', 'pomf'); +/** @param string POMF_DB_PASS Database password */ +define('POMF_DB_PASS', ''); + +/** + * File system location where to store uploaded files + * + * @param string Path to directory with trailing delimiter + */ +define('POMF_FILES_ROOT', '/mnt/pantsu/http/files/'); + +/** + * Maximum number of iterations while generating a new filename + * + * Pomf uses an algorithm to generate random filenames. Sometimes a file may + * exist under a randomly generated filename, so we count tries and keep trying. + * If this value is exceeded, we give up trying to generate a new filename. + * + * @param int POMF_FILES_RETRIES Number of attempts to retry + */ +define('POMF_FILES_RETRIES', 15); + +/** + * The length of generated filename (without file extension) + * + * @param int POMF_FILES_LENGTH Number of random alphabetical ASCII characters + * to use + */ +define('POMF_FILES_LENGTH', 6); + +/** + * URI to prepend to links for uploaded files + * + * @param string POMF_URL URI with trailing delimiter + */ +define('POMF_URL', 'https://i.pantsu.cat/'); + +/** + * URI for filename generation + * + * @param string characters to be used in generateName() + */ +define('ID_CHARSET', 'abcdefghijklmnopqrstuvwxyz'); + + +/** + * Filtered mime types + * @param string[] $FILTER_MIME allowed/blocked mime types + */ +$FILTER_MIME = array(); +/** + * Filter mode: whitelist (true) or blacklist (false) + * @param bool $FILTER_MODE mime type filter mode + */ +$FILTER_MODE = false; +/** + * Double dot file extensions + * + * Pomf keeps the last file extension for the uploaded file. In other words, an + * uploaded file with `.tar.gz` extension will be given a random filename which + * ends in `.gz` unless configured here to ignore discards for `.tar.gz`. + * + * @param string[] $doubledots Array of double dot file extensions strings + * without the first prefixing dot + */ +$doubledots = array_map('strrev', array( + 'tar.gz', + 'tar.bz', + 'tar.bz2', + 'tar.xz', + 'user.js', +)); |
