Add initial Plenario live polling app
CakePHP 5.4 app for live polls: create via email without login, manage via secret admin link, join via code. Includes slide types (choice, wordcloud, open, scale, content), presenter mode, CSV export, captcha, throttling, tests and Gitea CI/deploy workflow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
eb319f8c1e
120 files changed
+15572
No files matched your search
@@ -0,0 +1,38 @@
|
||||
# Plenario environment configuration
|
||||
# Copy to config/.env (not committed) or set these as real environment variables.
|
||||
# Real environment variables take precedence over this file.
|
||||
|
||||
# --- Core -------------------------------------------------------------------
|
||||
DEBUG=false
|
||||
# Absolute URL used in e-mails, MUST be set in production
|
||||
APP_FULL_BASE_URL=https://plenario.example.org
|
||||
# Generate with: php -r "echo bin2hex(random_bytes(32));"
|
||||
SECURITY_SALT=change-me-to-a-long-random-string
|
||||
APP_DEFAULT_LOCALE=de_DE
|
||||
|
||||
# --- Database ---------------------------------------------------------------
|
||||
# Empty = SQLite file data/plenario.sqlite
|
||||
# DATABASE_URL=mysql://user:password@localhost/plenario?encoding=utf8mb4
|
||||
# DATABASE_URL=postgres://user:password@localhost/plenario
|
||||
|
||||
# --- Mail -------------------------------------------------------------------
|
||||
# Empty = .eml files in tmp/mails/ (development only!)
|
||||
# EMAIL_TRANSPORT_DEFAULT_URL=smtp://user:password@mail.example.org:587?tls=true
|
||||
MAIL_FROM=noreply@plenario.example.org
|
||||
MAIL_FROM_NAME=Plenario
|
||||
|
||||
# --- Captcha ----------------------------------------------------------------
|
||||
# none | math | recaptcha
|
||||
CAPTCHA_TYPE=math
|
||||
# Only for CAPTCHA_TYPE=recaptcha (reCAPTCHA v2 checkbox, https://www.google.com/recaptcha/admin)
|
||||
RECAPTCHA_SITE_KEY=
|
||||
RECAPTCHA_SECRET_KEY=
|
||||
|
||||
# --- Behaviour --------------------------------------------------------------
|
||||
# Show the admin link right after creation (development only, never in production)
|
||||
SHOW_ADMIN_LINK_AFTER_CREATE=false
|
||||
# Max. polls / recovery mails per IP and hour (0 = unlimited)
|
||||
THROTTLE_CREATE_PER_HOUR=10
|
||||
THROTTLE_RECOVER_PER_HOUR=5
|
||||
# How often presenter and participant pages poll for updates (ms)
|
||||
POLL_INTERVAL_MS=2000
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Migrations\BaseMigration;
|
||||
|
||||
/**
|
||||
* Initial Plenario schema.
|
||||
*
|
||||
* polls - one "presentation" created via e-mail, managed through a secret admin link
|
||||
* slides - questions / content slides of a poll, ordered by `position`
|
||||
* slide_options - answer options for choice slides
|
||||
* responses - participant answers (one row per selected option / entered text / value)
|
||||
*/
|
||||
class CreateInitialSchema extends BaseMigration
|
||||
{
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function change(): void
|
||||
{
|
||||
$this->table('polls')
|
||||
->addColumn('title', 'string', ['limit' => 200, 'null' => false])
|
||||
->addColumn('email', 'string', ['limit' => 255, 'null' => false])
|
||||
// sha256 of the secret admin token; the token itself is only sent by mail
|
||||
->addColumn('admin_token_hash', 'string', ['limit' => 64, 'null' => false])
|
||||
// token encrypted with Security.salt so the recovery mail can resend the same link
|
||||
->addColumn('admin_token_encrypted', 'text', ['null' => false])
|
||||
// short public code participants use to join, e.g. "K7P2QX"
|
||||
->addColumn('join_code', 'string', ['limit' => 12, 'null' => false])
|
||||
->addColumn('current_slide_id', 'integer', ['null' => true, 'default' => null])
|
||||
->addColumn('is_active', 'boolean', ['null' => false, 'default' => true])
|
||||
->addColumn('show_results_to_participants', 'boolean', ['null' => false, 'default' => true])
|
||||
->addColumn('last_admin_access', 'datetime', ['null' => true, 'default' => null])
|
||||
->addColumn('created', 'datetime', ['null' => false])
|
||||
->addColumn('modified', 'datetime', ['null' => false])
|
||||
->addIndex(['admin_token_hash'], ['unique' => true])
|
||||
->addIndex(['join_code'], ['unique' => true])
|
||||
->addIndex(['email'])
|
||||
->create();
|
||||
|
||||
$this->table('slides')
|
||||
->addColumn('poll_id', 'integer', ['null' => false])
|
||||
// choice | wordcloud | open | scale | content
|
||||
->addColumn('type', 'string', ['limit' => 20, 'null' => false])
|
||||
->addColumn('question', 'string', ['limit' => 500, 'null' => false])
|
||||
->addColumn('description', 'text', ['null' => true, 'default' => null])
|
||||
->addColumn('position', 'integer', ['null' => false, 'default' => 0])
|
||||
// JSON encoded type specific settings (multiple, scale_min, scale_max, ...)
|
||||
->addColumn('settings', 'text', ['null' => true, 'default' => null])
|
||||
->addColumn('is_voting_open', 'boolean', ['null' => false, 'default' => true])
|
||||
->addColumn('created', 'datetime', ['null' => false])
|
||||
->addColumn('modified', 'datetime', ['null' => false])
|
||||
->addIndex(['poll_id', 'position'])
|
||||
->addForeignKey('poll_id', 'polls', 'id', ['delete' => 'CASCADE', 'update' => 'NO_ACTION'])
|
||||
->create();
|
||||
|
||||
$this->table('slide_options')
|
||||
->addColumn('slide_id', 'integer', ['null' => false])
|
||||
->addColumn('label', 'string', ['limit' => 255, 'null' => false])
|
||||
->addColumn('position', 'integer', ['null' => false, 'default' => 0])
|
||||
->addIndex(['slide_id', 'position'])
|
||||
->addForeignKey('slide_id', 'slides', 'id', ['delete' => 'CASCADE', 'update' => 'NO_ACTION'])
|
||||
->create();
|
||||
|
||||
$this->table('responses')
|
||||
->addColumn('slide_id', 'integer', ['null' => false])
|
||||
// sha256 of the participant cookie id - anonymous, only used to prevent double voting
|
||||
->addColumn('participant_hash', 'string', ['limit' => 64, 'null' => false])
|
||||
->addColumn('slide_option_id', 'integer', ['null' => true, 'default' => null])
|
||||
->addColumn('text_value', 'string', ['limit' => 500, 'null' => true, 'default' => null])
|
||||
->addColumn('numeric_value', 'integer', ['null' => true, 'default' => null])
|
||||
->addColumn('created', 'datetime', ['null' => false])
|
||||
->addIndex(['slide_id', 'participant_hash'])
|
||||
->addIndex(['slide_option_id'])
|
||||
->addForeignKey('slide_id', 'slides', 'id', ['delete' => 'CASCADE', 'update' => 'NO_ACTION'])
|
||||
->addForeignKey('slide_option_id', 'slide_options', 'id', ['delete' => 'CASCADE', 'update' => 'NO_ACTION'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
+509
@@ -0,0 +1,509 @@
|
||||
<?php
|
||||
|
||||
use Cake\Cache\Engine\FileEngine;
|
||||
use Cake\Database\Connection;
|
||||
use Cake\Database\Driver\Sqlite;
|
||||
use Cake\Log\Engine\FileLog;
|
||||
use Cake\Mailer\Transport\MailTransport;
|
||||
use function Cake\Core\env;
|
||||
|
||||
return [
|
||||
/*
|
||||
* Plenario application settings.
|
||||
*
|
||||
* Every value can be overridden in config/app_local.php or via environment
|
||||
* variables (see config/.env.example).
|
||||
*
|
||||
* - captcha.type: 'none' | 'math' | 'recaptcha'
|
||||
* - captcha.recaptcha: Google reCAPTCHA v2 ("I'm not a robot") keys.
|
||||
* - showAdminLinkAfterCreate: show the admin link directly on the
|
||||
* confirmation page (useful for local development without mail server).
|
||||
* Defaults to the debug flag. NEVER enable this in production, otherwise
|
||||
* the e-mail confirmation is pointless.
|
||||
* - throttle: max. number of polls / recovery mails per IP and hour.
|
||||
* - pollIntervalMs: how often presenter / participant pages poll for state.
|
||||
*/
|
||||
'Plenario' => [
|
||||
'captcha' => [
|
||||
'type' => env('CAPTCHA_TYPE', 'math'),
|
||||
'recaptcha' => [
|
||||
'siteKey' => env('RECAPTCHA_SITE_KEY', ''),
|
||||
'secretKey' => env('RECAPTCHA_SECRET_KEY', ''),
|
||||
],
|
||||
],
|
||||
'showAdminLinkAfterCreate' => filter_var(
|
||||
env('SHOW_ADMIN_LINK_AFTER_CREATE', env('DEBUG', false)),
|
||||
FILTER_VALIDATE_BOOLEAN,
|
||||
),
|
||||
'throttle' => [
|
||||
'createPerHour' => (int)env('THROTTLE_CREATE_PER_HOUR', 10),
|
||||
'recoverPerHour' => (int)env('THROTTLE_RECOVER_PER_HOUR', 5),
|
||||
],
|
||||
'pollIntervalMs' => (int)env('POLL_INTERVAL_MS', 2000),
|
||||
],
|
||||
|
||||
/*
|
||||
* Debug Level:
|
||||
*
|
||||
* Production Mode:
|
||||
* false: No error messages, errors, or warnings shown.
|
||||
*
|
||||
* Development Mode:
|
||||
* true: Errors and warnings shown.
|
||||
*/
|
||||
'debug' => filter_var(env('DEBUG', false), FILTER_VALIDATE_BOOLEAN),
|
||||
|
||||
/*
|
||||
* Configure basic information about the application.
|
||||
*
|
||||
* - namespace - The namespace to find app classes under.
|
||||
* - defaultLocale - The default locale for translation, formatting currencies and numbers, date and time.
|
||||
* - encoding - The encoding used for HTML + database connections.
|
||||
* - base - The base directory the app resides in. If false this
|
||||
* will be auto-detected.
|
||||
* - dir - Name of app directory.
|
||||
* - webroot - The webroot directory.
|
||||
* - wwwRoot - The file path to webroot.
|
||||
* - baseUrl - To configure CakePHP to *not* use mod_rewrite and to
|
||||
* use CakePHP pretty URLs, remove these .htaccess
|
||||
* files:
|
||||
* /.htaccess
|
||||
* /webroot/.htaccess
|
||||
* And uncomment the baseUrl key below.
|
||||
* - fullBaseUrl - SECURITY: A base URL to use for absolute links.
|
||||
* IMPORTANT: This MUST be set in production to prevent Host Header Injection attacks
|
||||
* that can compromise password reset and other security-critical features.
|
||||
* Set this via APP_FULL_BASE_URL environment variable or directly in config.
|
||||
* Example: 'https://example.com'
|
||||
* When not set, the application will throw an exception in production mode.
|
||||
* - imageBaseUrl - Web path to the public images/ directory under webroot.
|
||||
* - cssBaseUrl - Web path to the public css/ directory under webroot.
|
||||
* - jsBaseUrl - Web path to the public js/ directory under webroot.
|
||||
* - paths - Configure paths for non class-based resources. Supports the
|
||||
* `plugins`, `templates`, `locales` subkeys, which allow the definition of
|
||||
* paths for plugins, view templates and locale files respectively.
|
||||
*/
|
||||
'App' => [
|
||||
'namespace' => 'App',
|
||||
'encoding' => env('APP_ENCODING', 'UTF-8'),
|
||||
'defaultLocale' => env('APP_DEFAULT_LOCALE', 'de_DE'),
|
||||
'defaultTimezone' => env('APP_DEFAULT_TIMEZONE', 'UTC'),
|
||||
'base' => false,
|
||||
'dir' => 'src',
|
||||
'webroot' => 'webroot',
|
||||
'wwwRoot' => WWW_ROOT,
|
||||
//'baseUrl' => env('SCRIPT_NAME'),
|
||||
'fullBaseUrl' => env('APP_FULL_BASE_URL', false),
|
||||
'imageBaseUrl' => 'img/',
|
||||
'cssBaseUrl' => 'css/',
|
||||
'jsBaseUrl' => 'js/',
|
||||
'paths' => [
|
||||
'plugins' => [ROOT . DS . 'plugins' . DS],
|
||||
'templates' => [ROOT . DS . 'templates' . DS],
|
||||
'locales' => [RESOURCES . 'locales' . DS],
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
* Security and encryption configuration
|
||||
*
|
||||
* - salt - A random string used in security hashing methods.
|
||||
* The salt value is also used as the encryption key.
|
||||
* You should treat it as extremely sensitive data.
|
||||
*/
|
||||
'Security' => [
|
||||
'salt' => env('SECURITY_SALT'),
|
||||
],
|
||||
|
||||
/*
|
||||
* Apply timestamps with the last modified time to static assets (js, css, images).
|
||||
* Will append a querystring parameter containing the time the file was modified.
|
||||
* This is useful for busting browser caches.
|
||||
*
|
||||
* Set to true to apply timestamps when debug is true. Set to 'force' to always
|
||||
* enable timestamping regardless of debug value.
|
||||
*/
|
||||
'Asset' => [
|
||||
//'timestamp' => true,
|
||||
// 'cacheTime' => '+1 year'
|
||||
],
|
||||
|
||||
/*
|
||||
* Configure the cache adapters.
|
||||
*/
|
||||
'Cache' => [
|
||||
'default' => [
|
||||
'className' => FileEngine::class,
|
||||
'path' => CACHE,
|
||||
'url' => env('CACHE_DEFAULT_URL', null),
|
||||
],
|
||||
|
||||
/*
|
||||
* Rate limiting of poll creation / recovery mails (App\Service\ThrottleService).
|
||||
*/
|
||||
'throttle' => [
|
||||
'className' => FileEngine::class,
|
||||
'prefix' => 'plenario_',
|
||||
'path' => CACHE . 'throttle' . DS,
|
||||
'duration' => '+1 hour',
|
||||
'url' => env('CACHE_THROTTLE_URL', null),
|
||||
],
|
||||
|
||||
/*
|
||||
* Configure the cache used for general framework caching.
|
||||
* Translation cache files are stored with this configuration.
|
||||
* Duration will be set to '+2 minutes' in bootstrap.php when debug = true
|
||||
* If you set 'className' => 'Null' core cache will be disabled.
|
||||
*/
|
||||
'_cake_translations_' => [
|
||||
'className' => FileEngine::class,
|
||||
'prefix' => 'myapp_cake_translations_',
|
||||
'path' => CACHE . 'persistent' . DS,
|
||||
'serialize' => true,
|
||||
'duration' => '+1 years',
|
||||
'url' => env('CACHE_CAKECORE_URL', null),
|
||||
],
|
||||
|
||||
/*
|
||||
* Configure the cache for model and datasource caches. This cache
|
||||
* configuration is used to store schema descriptions, and table listings
|
||||
* in connections.
|
||||
* Duration will be set to '+2 minutes' in bootstrap.php when debug = true
|
||||
*/
|
||||
'_cake_model_' => [
|
||||
'className' => FileEngine::class,
|
||||
'prefix' => 'myapp_cake_model_',
|
||||
'path' => CACHE . 'models' . DS,
|
||||
'serialize' => true,
|
||||
'duration' => '+1 years',
|
||||
'url' => env('CACHE_CAKEMODEL_URL', null),
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
* Configure the Error and Exception handlers used by your application.
|
||||
*
|
||||
* By default errors are displayed using Debugger, when debug is true and logged
|
||||
* by Cake\Log\Log when debug is false.
|
||||
*
|
||||
* In CLI environments exceptions will be printed to stderr with a backtrace.
|
||||
* In web environments an HTML page will be displayed for the exception.
|
||||
* With debug true, framework errors like Missing Controller will be displayed.
|
||||
* When debug is false, framework errors will be coerced into generic HTTP errors.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `errorLevel` - int - The level of errors you are interested in capturing.
|
||||
* - `trace` - boolean - Whether backtraces should be included in
|
||||
* logged errors/exceptions.
|
||||
* - `log` - boolean - Whether you want exceptions logged.
|
||||
* - `exceptionRenderer` - string - The class responsible for rendering uncaught exceptions.
|
||||
* The chosen class will be used for both CLI and web environments. If you want different
|
||||
* classes used in CLI and web environments you'll need to write that conditional logic as well.
|
||||
* The conventional location for custom renderers is in `src/Error`. Your exception renderer needs to
|
||||
* implement the `render()` method and return either a string or Http\Response.
|
||||
* `errorRenderer` - string - The class responsible for rendering PHP errors. The selected
|
||||
* class will be used for both web and CLI contexts. If you want different classes for each environment
|
||||
* you'll need to write that conditional logic as well. Error renderers need to
|
||||
* to implement the `Cake\Error\ErrorRendererInterface`.
|
||||
* - `skipLog` - array - List of exceptions to skip for logging. Exceptions that
|
||||
* extend one of the listed exceptions will also be skipped for logging.
|
||||
* E.g.:
|
||||
* `'skipLog' => ['Cake\Http\Exception\NotFoundException', 'Cake\Http\Exception\UnauthorizedException']`
|
||||
* - `extraFatalErrorMemory` - int - The number of megabytes to increase the memory limit by
|
||||
* when a fatal error is encountered. This allows
|
||||
* breathing room to complete logging or error handling.
|
||||
* - `ignoredDeprecationPaths` - array - A list of glob-compatible file paths that deprecations
|
||||
* should be ignored in. Use this to ignore deprecations for plugins or parts of
|
||||
* your application that still emits deprecations.
|
||||
* - `traceFormat` - when logging errors, List of `'array'`, `'points'`, `'shortPoints'`, defaults to `shortPoints`.
|
||||
*/
|
||||
'Error' => [
|
||||
'errorLevel' => E_ALL,
|
||||
'skipLog' => [],
|
||||
'log' => true,
|
||||
'trace' => true,
|
||||
'ignoredDeprecationPaths' => [],
|
||||
'traceFormat' => null,
|
||||
],
|
||||
|
||||
/*
|
||||
* Debugger configuration
|
||||
*
|
||||
* Define development error values for Cake\Error\Debugger
|
||||
*
|
||||
* - `editor` Set the editor URL format you want to use.
|
||||
* By default atom, emacs, macvim, phpstorm, sublime, textmate, and vscode are
|
||||
* available. You can add additional editor link formats using
|
||||
* `Debugger::addEditor()` during your application bootstrap.
|
||||
* - `editorBasePath` - The base path to your project for editor integration.
|
||||
* Used to generate file links in stack traces.
|
||||
* - `outputMask` A mapping of `key` to `replacement` values that
|
||||
* `Debugger` should replace in dumped data and logs generated by `Debugger`.
|
||||
*/
|
||||
'Debugger' => [
|
||||
'editor' => 'phpstorm',
|
||||
],
|
||||
|
||||
/*
|
||||
* Email configuration.
|
||||
*
|
||||
* By defining transports separately from delivery profiles you can easily
|
||||
* re-use transport configuration across multiple profiles.
|
||||
*
|
||||
* You can specify multiple configurations for production, development and
|
||||
* testing.
|
||||
*
|
||||
* Each transport needs a `className`. Valid options are as follows:
|
||||
*
|
||||
* Mail - Send using PHP mail function
|
||||
* Smtp - Send using SMTP
|
||||
* Debug - Do not send the email, just return the result
|
||||
*
|
||||
* You can add custom transports (or override existing transports) by adding the
|
||||
* appropriate file to src/Mailer/Transport. Transports should be named
|
||||
* 'YourTransport.php', where 'Your' is the name of the transport.
|
||||
*/
|
||||
'EmailTransport' => [
|
||||
'default' => [
|
||||
'className' => MailTransport::class,
|
||||
/*
|
||||
* The keys host, port, timeout, username, password, client and tls
|
||||
* are used in SMTP transports
|
||||
*/
|
||||
'host' => 'localhost',
|
||||
'port' => 25,
|
||||
'timeout' => 30,
|
||||
/*
|
||||
* It is recommended to set these options through your environment or app_local.php
|
||||
*/
|
||||
//'username' => null,
|
||||
//'password' => null,
|
||||
'client' => null,
|
||||
'tls' => false,
|
||||
'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
* Email delivery profiles
|
||||
*
|
||||
* Delivery profiles allow you to predefine various properties about email
|
||||
* messages from your application and give the settings a name. This saves
|
||||
* duplication across your application and makes maintenance and development
|
||||
* easier. Each profile accepts a number of keys. See `Cake\Mailer\Mailer`
|
||||
* for more information.
|
||||
*/
|
||||
'Email' => [
|
||||
'default' => [
|
||||
'transport' => 'default',
|
||||
'from' => [env('MAIL_FROM', 'noreply@localhost') => env('MAIL_FROM_NAME', 'Plenario')],
|
||||
/*
|
||||
* Will by default be set to config value of App.encoding, if that exists otherwise to UTF-8.
|
||||
*/
|
||||
//'charset' => 'utf-8',
|
||||
//'headerCharset' => 'utf-8',
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
* Connection information used by the ORM to connect
|
||||
* to your application's datastores.
|
||||
*
|
||||
* ### Notes
|
||||
* - Drivers include Mysql Postgres Sqlite Sqlserver
|
||||
* See vendor\cakephp\cakephp\src\Database\Driver for the complete list
|
||||
* - Do not use periods in database name - it may lead to errors.
|
||||
* See https://github.com/cakephp/cakephp/issues/6471 for details.
|
||||
* - 'encoding' is recommended to be set to full UTF-8 4-Byte support.
|
||||
* E.g set it to 'utf8mb4' in MariaDB and MySQL and 'utf8' for any
|
||||
* other RDBMS.
|
||||
*/
|
||||
'Datasources' => [
|
||||
/*
|
||||
* These configurations should contain permanent settings used
|
||||
* by all environments.
|
||||
*
|
||||
* The values in app_local.php will override any values set here
|
||||
* and should be used for local and per-environment configurations.
|
||||
*
|
||||
* Environment variable-based configurations can be loaded here or
|
||||
* in app_local.php depending on the application's needs.
|
||||
*/
|
||||
'default' => [
|
||||
'className' => Connection::class,
|
||||
'driver' => Sqlite::class,
|
||||
'persistent' => false,
|
||||
'timezone' => 'UTC',
|
||||
|
||||
/*
|
||||
* For MariaDB/MySQL the internal default changed from utf8 to utf8mb4, aka full utf-8 support
|
||||
*/
|
||||
'encoding' => 'utf8',
|
||||
|
||||
/*
|
||||
* If your MySQL server is configured with `skip-character-set-client-handshake`
|
||||
* then you MUST use the `flags` config to set your charset encoding.
|
||||
* For e.g. `'flags' => [\PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8mb4']`
|
||||
*/
|
||||
'flags' => [],
|
||||
'cacheMetadata' => true,
|
||||
'log' => false,
|
||||
|
||||
/*
|
||||
* Set identifier quoting to true if you are using reserved words or
|
||||
* special characters in your table or column names. Enabling this
|
||||
* setting will result in queries built using the Query Builder having
|
||||
* identifiers quoted when creating SQL. It should be noted that this
|
||||
* decreases performance because each query needs to be traversed and
|
||||
* manipulated before being executed.
|
||||
*/
|
||||
'quoteIdentifiers' => false,
|
||||
|
||||
/*
|
||||
* During development, if using MySQL < 5.6, uncommenting the
|
||||
* following line could boost the speed at which schema metadata is
|
||||
* fetched from the database. It can also be set directly with the
|
||||
* mysql configuration directive 'innodb_stats_on_metadata = 0'
|
||||
* which is the recommended value in production environments
|
||||
*/
|
||||
//'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
|
||||
],
|
||||
|
||||
/*
|
||||
* The test connection is used during the test suite.
|
||||
*/
|
||||
'test' => [
|
||||
'className' => Connection::class,
|
||||
'driver' => Sqlite::class,
|
||||
'persistent' => false,
|
||||
'timezone' => 'UTC',
|
||||
'encoding' => 'utf8',
|
||||
'flags' => [],
|
||||
'cacheMetadata' => true,
|
||||
'quoteIdentifiers' => false,
|
||||
'log' => false,
|
||||
//'init' => ['SET GLOBAL innodb_stats_on_metadata = 0'],
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
* Configures logging options
|
||||
*/
|
||||
'Log' => [
|
||||
'debug' => [
|
||||
'className' => FileLog::class,
|
||||
'path' => LOGS,
|
||||
'file' => 'debug',
|
||||
'url' => env('LOG_DEBUG_URL', null),
|
||||
'scopes' => null,
|
||||
'levels' => ['notice', 'info', 'debug'],
|
||||
],
|
||||
'error' => [
|
||||
'className' => FileLog::class,
|
||||
'path' => LOGS,
|
||||
'file' => 'error',
|
||||
'url' => env('LOG_ERROR_URL', null),
|
||||
'scopes' => null,
|
||||
'levels' => ['warning', 'error', 'critical', 'alert', 'emergency'],
|
||||
],
|
||||
// To enable this dedicated query log, you need to set your datasource's log flag to true
|
||||
'queries' => [
|
||||
'className' => FileLog::class,
|
||||
'path' => LOGS,
|
||||
'file' => 'queries',
|
||||
'url' => env('LOG_QUERIES_URL', null),
|
||||
'scopes' => ['cake.database.queries'],
|
||||
],
|
||||
],
|
||||
|
||||
/*
|
||||
* Session configuration.
|
||||
*
|
||||
* Contains an array of settings to use for session configuration. The
|
||||
* `defaults` key is used to define a default preset to use for sessions, any
|
||||
* settings declared here will override the settings of the default config.
|
||||
*
|
||||
* ## Options
|
||||
*
|
||||
* - `cookie` - The name of the cookie to use. Defaults to value set for `session.name` php.ini config.
|
||||
* Avoid using `.` in cookie names, as PHP will drop sessions from cookies with `.` in the name.
|
||||
* - `cookiePath` - The url path for which session cookie is set. Maps to the
|
||||
* `session.cookie_path` php.ini config. Defaults to base path of app.
|
||||
* - `timeout` - The time in minutes a session can be 'idle'. If no request is received in
|
||||
* this duration, the session will be expired and rotated. Pass 0 to disable idle timeout checks.
|
||||
* - `defaults` - The default configuration set to use as a basis for your session.
|
||||
* There are four built-in options: php, cake, cache, database.
|
||||
* - `handler` - Can be used to enable a custom session handler. Expects an
|
||||
* array with at least the `engine` key, being the name of the Session engine
|
||||
* class to use for managing the session. CakePHP bundles the `CacheSession`
|
||||
* and `DatabaseSession` engines.
|
||||
* - `ini` - An associative array of additional 'session.*` ini values to set.
|
||||
*
|
||||
* Within the `ini` key, you will likely want to define:
|
||||
*
|
||||
* - `session.cookie_lifetime` - The number of seconds that cookies are valid for. This
|
||||
* should be longer than `Session.timeout`.
|
||||
* - `session.gc_maxlifetime` - The number of seconds after which a session is considered 'garbage'
|
||||
* that can be deleted by PHP's session cleanup behavior. This value should be greater than both
|
||||
* `Sesssion.timeout` and `session.cookie_lifetime`.
|
||||
*
|
||||
* The built-in `defaults` options are:
|
||||
*
|
||||
* - 'php' - Uses settings defined in your php.ini.
|
||||
* - 'cake' - Saves session files in CakePHP's /tmp directory.
|
||||
* - 'database' - Uses CakePHP's database sessions.
|
||||
* - 'cache' - Use the Cache class to save sessions.
|
||||
*
|
||||
* To define a custom session handler, save it at src/Http/Session/<name>.php.
|
||||
* Make sure the class implements PHP's `SessionHandlerInterface` and set
|
||||
* Session.handler to <name>
|
||||
*
|
||||
* To use database sessions, load the SQL file located at config/schema/sessions.sql
|
||||
*/
|
||||
'Session' => [
|
||||
'defaults' => 'php',
|
||||
],
|
||||
|
||||
/**
|
||||
* DebugKit configuration.
|
||||
*
|
||||
* Contains an array of configurations to apply to the DebugKit plugin, if loaded.
|
||||
* Documentation: https://book.cakephp.org/debugkit/5/en/index.html#configuration
|
||||
*
|
||||
* ## Options
|
||||
*
|
||||
* - `panels` - Enable or disable panels. The key is the panel name, and the value is true to enable,
|
||||
* or false to disable.
|
||||
* - `includeSchemaReflection` - Set to true to enable logging of schema reflection queries. Disabled by default.
|
||||
* - `safeTld` - Set an array of whitelisted TLDs for local development.
|
||||
* - `forceEnable` - Force DebugKit to display. Careful with this, it is usually safer to simply whitelist
|
||||
* your local TLDs.
|
||||
* - `ignorePathsPattern` - Regex pattern (including delimiter) to ignore paths.
|
||||
* DebugKit won’t save data for request URLs that match this regex.
|
||||
* - `ignoreAuthorization` - Set to true to ignore Cake Authorization plugin for DebugKit requests.
|
||||
* Disabled by default.
|
||||
* - `maxDepth` - Defines how many levels of nested data should be shown in general for debug output.
|
||||
* Default is 5. WARNING: Increasing the max depth level can lead to an out of memory error.
|
||||
* - `variablesPanelMaxDepth` - Defines how many levels of nested data should be shown in the variables tab.
|
||||
* Default is 5. WARNING: Increasing the max depth level can lead to an out of memory error.
|
||||
*/
|
||||
'DebugKit' => [
|
||||
'forceEnable' => filter_var(env('DEBUG_KIT_FORCE_ENABLE', false), FILTER_VALIDATE_BOOLEAN),
|
||||
'safeTld' => env('DEBUG_KIT_SAFE_TLD', null),
|
||||
'ignoreAuthorization' => env('DEBUG_KIT_IGNORE_AUTHORIZATION', false),
|
||||
],
|
||||
|
||||
/**
|
||||
* TestSuite configuration.
|
||||
*
|
||||
* ## Options
|
||||
*
|
||||
* - `errorLevel` - Defaults to `E_ALL`. Can be set to `false` to disable overwrite error level.
|
||||
* - `fixtureStrategy` - Defaults to TruncateStrategy. Can be set to any class implementing FixtureStrategyInterface.
|
||||
*/
|
||||
'TestSuite' => [
|
||||
'errorLevel' => null,
|
||||
'fixtureStrategy' => null,
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
/*
|
||||
* Local configuration overrides for Plenario.
|
||||
*
|
||||
* Copy this file to config/app_local.php (done automatically by
|
||||
* `composer install`) and adjust it. app_local.php is NOT committed.
|
||||
*
|
||||
* Every value can alternatively be provided via environment variables.
|
||||
*/
|
||||
|
||||
use Cake\Database\Driver\Sqlite;
|
||||
use function Cake\Core\env;
|
||||
|
||||
return [
|
||||
'debug' => filter_var(env('DEBUG', true), FILTER_VALIDATE_BOOLEAN),
|
||||
|
||||
'App' => [
|
||||
// Absolute base URL used for links in e-mails, e.g. https://plenario.example.org
|
||||
'fullBaseUrl' => env('APP_FULL_BASE_URL', 'http://localhost:8765'),
|
||||
],
|
||||
|
||||
'Security' => [
|
||||
'salt' => env('SECURITY_SALT', '__SALT__'),
|
||||
],
|
||||
|
||||
'Plenario' => [
|
||||
'captcha' => [
|
||||
// 'none' | 'math' | 'recaptcha'
|
||||
'type' => env('CAPTCHA_TYPE', 'math'),
|
||||
'recaptcha' => [
|
||||
'siteKey' => env('RECAPTCHA_SITE_KEY', ''),
|
||||
'secretKey' => env('RECAPTCHA_SECRET_KEY', ''),
|
||||
],
|
||||
],
|
||||
// Shows the admin link on the confirmation page. Development only!
|
||||
'showAdminLinkAfterCreate' => filter_var(env('SHOW_ADMIN_LINK_AFTER_CREATE', env('DEBUG', true)), FILTER_VALIDATE_BOOLEAN),
|
||||
],
|
||||
|
||||
'Datasources' => [
|
||||
/*
|
||||
* Default: SQLite file in data/. For MySQL/MariaDB/PostgreSQL set
|
||||
* DATABASE_URL, e.g.
|
||||
* mysql://user:pass@localhost/plenario?encoding=utf8mb4
|
||||
*/
|
||||
'default' => [
|
||||
'driver' => Sqlite::class,
|
||||
'database' => ROOT . DS . 'data' . DS . 'plenario.sqlite',
|
||||
'url' => env('DATABASE_URL', null),
|
||||
],
|
||||
'test' => [
|
||||
'driver' => Sqlite::class,
|
||||
'database' => ROOT . DS . 'tmp' . DS . 'tests.sqlite',
|
||||
'url' => env('DATABASE_TEST_URL', null),
|
||||
],
|
||||
],
|
||||
|
||||
'EmailTransport' => [
|
||||
/*
|
||||
* Local default: mails are written as .eml files to tmp/mails/.
|
||||
* For production use SMTP, e.g.
|
||||
* EMAIL_TRANSPORT_DEFAULT_URL=smtp://user:pass@mail.example.org:587?tls=true
|
||||
*/
|
||||
'default' => [
|
||||
'className' => \App\Mailer\Transport\FileTransport::class,
|
||||
'url' => env('EMAIL_TRANSPORT_DEFAULT_URL', null),
|
||||
],
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,239 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @since 0.10.8
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is loaded by your src/Application.php bootstrap method.
|
||||
* Feel free to extend/extract parts of the bootstrap process into your own files
|
||||
* to suit your needs/preferences.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Configure paths required to find CakePHP + general filepath constants
|
||||
*/
|
||||
require __DIR__ . DIRECTORY_SEPARATOR . 'paths.php';
|
||||
|
||||
/*
|
||||
* Bootstrap CakePHP
|
||||
* Currently all this does is initialize the router (without loading your routes)
|
||||
*/
|
||||
require CORE_PATH . 'config' . DS . 'bootstrap.php';
|
||||
|
||||
use Cake\Cache\Cache;
|
||||
use Cake\Core\Configure;
|
||||
use Cake\Core\Configure\Engine\PhpConfig;
|
||||
use Cake\Datasource\ConnectionManager;
|
||||
use Cake\Error\ErrorTrap;
|
||||
use Cake\Error\ExceptionTrap;
|
||||
use Cake\Http\ServerRequest;
|
||||
use Cake\Log\Log;
|
||||
use Cake\Mailer\Mailer;
|
||||
use Cake\Mailer\TransportFactory;
|
||||
use Cake\Routing\Router;
|
||||
use Cake\Utility\Security;
|
||||
use Detection\MobileDetect;
|
||||
use function Cake\Core\env;
|
||||
|
||||
/*
|
||||
* Load global functions for collections, translations, debugging etc.
|
||||
*/
|
||||
require CAKE . 'functions.php';
|
||||
|
||||
/*
|
||||
* See https://github.com/josegonzalez/php-dotenv for API details.
|
||||
*
|
||||
* Uncomment block of code below if you want to use `.env` file during development.
|
||||
* You should copy `config/.env.example` to `config/.env` and set/modify the
|
||||
* variables as required.
|
||||
*
|
||||
* The purpose of the .env file is to emulate the presence of the environment
|
||||
* variables like they would be present in production.
|
||||
*
|
||||
* If you use .env files, be careful to not commit them to source control to avoid
|
||||
* security risks. See https://github.com/josegonzalez/php-dotenv#general-security-information
|
||||
* for more information for recommended practices.
|
||||
*/
|
||||
// Plenario: config/.env is optional. Real environment variables always win.
|
||||
if (file_exists(CONFIG . '.env')) {
|
||||
$dotenv = new \josegonzalez\Dotenv\Loader([CONFIG . '.env']);
|
||||
$dotenv->parse()
|
||||
->skipExisting()
|
||||
->putenv()
|
||||
->toEnv()
|
||||
->toServer();
|
||||
}
|
||||
|
||||
/*
|
||||
* Initializes default Config store and loads the main configuration file (app.php)
|
||||
*
|
||||
* CakePHP contains 2 configuration files after project creation:
|
||||
* - `config/app.php` for the default application configuration.
|
||||
* - `config/app_local.php` for environment specific configuration.
|
||||
*/
|
||||
try {
|
||||
Configure::config('default', new PhpConfig());
|
||||
Configure::load('app', 'default', false);
|
||||
} catch (Exception $e) {
|
||||
exit($e->getMessage() . "\n");
|
||||
}
|
||||
|
||||
/*
|
||||
* Load an environment local configuration file to provide overrides to your configuration.
|
||||
* Notice: For security reasons app_local.php **should not** be included in your git repo.
|
||||
*/
|
||||
if (file_exists(CONFIG . 'app_local.php')) {
|
||||
Configure::load('app_local', 'default');
|
||||
}
|
||||
|
||||
/*
|
||||
* When debug = true the metadata cache should only last for a short time.
|
||||
*/
|
||||
if (Configure::read('debug')) {
|
||||
Configure::write('Cache._cake_model_.duration', '+1 minute');
|
||||
Configure::write('Cache._cake_translations_.duration', '+1 minute');
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the default server timezone. Using UTC makes time calculations / conversions easier.
|
||||
* Check https://php.net/manual/en/timezones.php for list of valid timezone strings.
|
||||
*/
|
||||
date_default_timezone_set(Configure::read('App.defaultTimezone'));
|
||||
|
||||
/*
|
||||
* Configure the mbstring extension to use the correct encoding.
|
||||
*/
|
||||
mb_internal_encoding(Configure::read('App.encoding'));
|
||||
|
||||
/*
|
||||
* Set the default locale. This controls how dates, number and currency is
|
||||
* formatted and sets the default language to use for translations.
|
||||
*/
|
||||
ini_set('intl.default_locale', Configure::read('App.defaultLocale'));
|
||||
|
||||
/*
|
||||
* Register application error and exception handlers.
|
||||
*/
|
||||
(new ErrorTrap(Configure::read('Error')))->register();
|
||||
(new ExceptionTrap(Configure::read('Error')))->register();
|
||||
|
||||
/*
|
||||
* CLI/Command specific configuration.
|
||||
*/
|
||||
if (PHP_SAPI === 'cli') {
|
||||
// Set the fullBaseUrl to allow URLs to be generated in commands.
|
||||
// This is useful when sending email from commands.
|
||||
// Configure::write('App.fullBaseUrl', php_uname('n'));
|
||||
|
||||
// Set logs to different files so they don't have permission conflicts.
|
||||
if (Configure::check('Log.debug')) {
|
||||
Configure::write('Log.debug.file', 'cli-debug');
|
||||
}
|
||||
if (Configure::check('Log.error')) {
|
||||
Configure::write('Log.error.file', 'cli-error');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the full base URL for the application.
|
||||
*
|
||||
* SECURITY: In production, App.fullBaseUrl MUST be explicitly configured to prevent
|
||||
* Host Header Injection attacks. The HostHeaderMiddleware enforces this requirement
|
||||
* and validates incoming Host headers against the configured value.
|
||||
*
|
||||
* Set APP_FULL_BASE_URL in your environment variables or configure App.fullBaseUrl
|
||||
* in config/app.php or config/app_local.php
|
||||
*
|
||||
* Example: APP_FULL_BASE_URL=https://example.com
|
||||
*/
|
||||
$fullBaseUrl = Configure::read('App.fullBaseUrl');
|
||||
if (!$fullBaseUrl) {
|
||||
$httpHost = env('HTTP_HOST');
|
||||
|
||||
/*
|
||||
* Development mode fallback: Use HTTP_HOST for convenience.
|
||||
* WARNING: This is ONLY safe in development. In production, the
|
||||
* HostHeaderMiddleware will reject requests when fullBaseUrl is not configured.
|
||||
*/
|
||||
if ($httpHost) {
|
||||
$s = null;
|
||||
if (env('HTTPS') || env('HTTP_X_FORWARDED_PROTO') === 'https') {
|
||||
$s = 's';
|
||||
}
|
||||
$fullBaseUrl = 'http' . $s . '://' . $httpHost;
|
||||
}
|
||||
unset($httpHost, $s);
|
||||
}
|
||||
if ($fullBaseUrl) {
|
||||
Router::fullBaseUrl($fullBaseUrl);
|
||||
}
|
||||
unset($fullBaseUrl);
|
||||
|
||||
/*
|
||||
* Apply the loaded configuration settings to their respective systems.
|
||||
* This will also remove the loaded config data from memory.
|
||||
*/
|
||||
Cache::setConfig(Configure::consume('Cache'));
|
||||
ConnectionManager::setConfig(Configure::consume('Datasources'));
|
||||
TransportFactory::setConfig(Configure::consume('EmailTransport'));
|
||||
Mailer::setConfig(Configure::consume('Email'));
|
||||
Log::setConfig(Configure::consume('Log'));
|
||||
Security::setSalt(Configure::consume('Security.salt'));
|
||||
|
||||
/*
|
||||
* Setup detectors for mobile and tablet.
|
||||
* If you don't use these checks you can safely remove this code
|
||||
* and the mobiledetect package from composer.json.
|
||||
*/
|
||||
ServerRequest::addDetector('mobile', function ($request) {
|
||||
$detector = new MobileDetect();
|
||||
|
||||
return $detector->isMobile();
|
||||
});
|
||||
ServerRequest::addDetector('tablet', function ($request) {
|
||||
$detector = new MobileDetect();
|
||||
|
||||
return $detector->isTablet();
|
||||
});
|
||||
|
||||
/*
|
||||
* You can enable default locale format parsing by adding calls
|
||||
* to `useLocaleParser()`. This enables the automatic conversion of
|
||||
* locale specific date formats when processing request data. For details see
|
||||
* @link https://book.cakephp.org/5/en/core-libraries/internationalization-and-localization.html#parsing-localized-datetime-data
|
||||
*/
|
||||
// \Cake\Database\TypeFactory::build('time')->useLocaleParser();
|
||||
// \Cake\Database\TypeFactory::build('date')->useLocaleParser();
|
||||
// \Cake\Database\TypeFactory::build('datetime')->useLocaleParser();
|
||||
// \Cake\Database\TypeFactory::build('timestamp')->useLocaleParser();
|
||||
// \Cake\Database\TypeFactory::build('datetimefractional')->useLocaleParser();
|
||||
// \Cake\Database\TypeFactory::build('timestampfractional')->useLocaleParser();
|
||||
// \Cake\Database\TypeFactory::build('datetimetimezone')->useLocaleParser();
|
||||
// \Cake\Database\TypeFactory::build('timestamptimezone')->useLocaleParser();
|
||||
|
||||
/*
|
||||
* Custom Inflector rules, can be set to correctly pluralize or singularize
|
||||
* table, model, controller names or whatever other string is passed to the
|
||||
* inflection functions.
|
||||
*/
|
||||
// \Cake\Utility\Inflector::rules('plural', ['/^(inflect)or$/i' => '\1ables']);
|
||||
// \Cake\Utility\Inflector::rules('irregular', ['red' => 'redlings']);
|
||||
// \Cake\Utility\Inflector::rules('uninflected', ['dontinflectme']);
|
||||
|
||||
// set a custom date and time format
|
||||
// see https://book.cakephp.org/5/en/core-libraries/time.html#setting-the-default-locale-and-format-string
|
||||
// and https://unicode-org.github.io/icu/userguide/format_parse/datetime/#datetime-format-syntax
|
||||
// \Cake\I18n\Date::setToStringFormat('dd.MM.yyyy');
|
||||
// \Cake\I18n\Time::setToStringFormat('dd.MM.yyyy HH:mm');
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @since 3.0.0
|
||||
* @license MIT License (https://opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
/*
|
||||
* Use the DS to separate the directories in other defines
|
||||
*/
|
||||
if (!defined('DS')) {
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
/*
|
||||
* These definitions should only be edited if you have cake installed in
|
||||
* a directory layout other than the way it is distributed.
|
||||
* When using custom settings be sure to use the DS and do not add a trailing DS.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The full path to the directory which holds "src", WITHOUT a trailing DS.
|
||||
*/
|
||||
define('ROOT', dirname(__DIR__));
|
||||
|
||||
/*
|
||||
* The actual directory name for the application directory. Normally
|
||||
* named 'src'.
|
||||
*/
|
||||
define('APP_DIR', 'src');
|
||||
|
||||
/*
|
||||
* Path to the application's directory.
|
||||
*/
|
||||
define('APP', ROOT . DS . APP_DIR . DS);
|
||||
|
||||
/*
|
||||
* Path to the config directory.
|
||||
*/
|
||||
define('CONFIG', ROOT . DS . 'config' . DS);
|
||||
|
||||
/*
|
||||
* File path to the webroot directory.
|
||||
*
|
||||
* To derive your webroot from your webserver change this to:
|
||||
*
|
||||
* `define('WWW_ROOT', rtrim($_SERVER['DOCUMENT_ROOT'], DS) . DS);`
|
||||
*/
|
||||
define('WWW_ROOT', ROOT . DS . 'webroot' . DS);
|
||||
|
||||
/*
|
||||
* Path to the tests directory.
|
||||
*/
|
||||
define('TESTS', ROOT . DS . 'tests' . DS);
|
||||
|
||||
/*
|
||||
* Path to the temporary files directory.
|
||||
*/
|
||||
define('TMP', ROOT . DS . 'tmp' . DS);
|
||||
|
||||
/*
|
||||
* Path to the logs directory.
|
||||
*/
|
||||
define('LOGS', ROOT . DS . 'logs' . DS);
|
||||
|
||||
/*
|
||||
* Path to the cache files directory. It can be shared between hosts in a multi-server setup.
|
||||
*/
|
||||
define('CACHE', TMP . 'cache' . DS);
|
||||
|
||||
/*
|
||||
* Path to the resources directory.
|
||||
*/
|
||||
define('RESOURCES', ROOT . DS . 'resources' . DS);
|
||||
|
||||
/*
|
||||
* The absolute path to the "cake" directory, WITHOUT a trailing DS.
|
||||
*
|
||||
* CakePHP should always be installed with composer, so look there.
|
||||
*/
|
||||
define('CAKE_CORE_INCLUDE_PATH', ROOT . DS . 'vendor' . DS . 'cakephp' . DS . 'cakephp');
|
||||
|
||||
/*
|
||||
* Path to the cake directory.
|
||||
*/
|
||||
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH . DS);
|
||||
define('CAKE', CORE_PATH . 'src' . DS);
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Plugin configuration.
|
||||
*
|
||||
* In this file, you configure which plugins are loaded in the different states your app can be.
|
||||
* It's loaded via the `parent::bootstrap();` call inside your `Application::bootstrap()` method.
|
||||
* For more information see https://book.cakephp.org/5/en/plugins.html#loading-plugins-via-configuration-array
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
* @link https://cakephp.org CakePHP(tm) Project
|
||||
* @since 5.0.0
|
||||
* @license https://opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
/*
|
||||
* List of plugins to load in the form `PluginName` => `[configuration options]`.
|
||||
*
|
||||
* Available options:
|
||||
* - onlyDebug: Load the plugin only in debug mode. Default false.
|
||||
* - onlyCli: Load the plugin only in CLI mode. Default false.
|
||||
* - optional: Do not throw an exception if the plugin is not found. Default false.
|
||||
*/
|
||||
return [
|
||||
'DebugKit' => ['onlyDebug' => true],
|
||||
'Bake' => ['onlyCli' => true, 'optional' => true],
|
||||
'Migrations' => ['onlyCli' => true],
|
||||
|
||||
// Additional plugins here
|
||||
];
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* Plenario routes.
|
||||
*
|
||||
* Public: / start page (create poll, join by code)
|
||||
* /recover re-send admin links by e-mail
|
||||
* /p/{code} participant view
|
||||
* Admin: /admin/{token}/... everything behind the secret admin token
|
||||
*
|
||||
* All routes are named so templates build URLs via ['_name' => ...].
|
||||
* There are intentionally NO fallback routes.
|
||||
*/
|
||||
|
||||
use Cake\Routing\Route\DashedRoute;
|
||||
use Cake\Routing\RouteBuilder;
|
||||
|
||||
return function (RouteBuilder $routes): void {
|
||||
$routes->setRouteClass(DashedRoute::class);
|
||||
|
||||
$routes->scope('/', function (RouteBuilder $builder): void {
|
||||
// --- public -------------------------------------------------------
|
||||
$builder->connect('/', 'Home::index', ['_name' => 'home']);
|
||||
$builder->connect('/create', 'Home::create', ['_name' => 'create'])->setMethods(['POST']);
|
||||
$builder->connect('/created', 'Home::created', ['_name' => 'created']);
|
||||
$builder->connect('/join', 'Home::join', ['_name' => 'join']);
|
||||
$builder->connect('/recover', 'Home::recover', ['_name' => 'recover']);
|
||||
|
||||
// --- participants -------------------------------------------------
|
||||
$builder->connect('/p', 'Home::join', ['_name' => 'join:short']);
|
||||
$builder->connect('/p/{code}', 'Participate::view', ['_name' => 'participate'])
|
||||
->setPatterns(['code' => '[A-Za-z0-9-]{4,16}'])
|
||||
->setPass(['code']);
|
||||
$builder->connect('/p/{code}/state', 'Participate::state', ['_name' => 'participate:state'])
|
||||
->setPatterns(['code' => '[A-Za-z0-9-]{4,16}'])
|
||||
->setPass(['code']);
|
||||
$builder->connect('/p/{code}/vote', 'Participate::vote', ['_name' => 'participate:vote'])
|
||||
->setPatterns(['code' => '[A-Za-z0-9-]{4,16}'])
|
||||
->setPass(['code'])
|
||||
->setMethods(['POST']);
|
||||
|
||||
// --- admin (secret token) -----------------------------------------
|
||||
$builder->scope('/admin/{token}', function (RouteBuilder $admin): void {
|
||||
$token = ['token' => '[A-Za-z0-9_-]{20,64}', 'id' => '\d+'];
|
||||
|
||||
$admin->connect('/', 'Admin::index', ['_name' => 'admin'])->setPatterns($token);
|
||||
$admin->connect('/settings', 'Admin::settings', ['_name' => 'admin:settings'])
|
||||
->setPatterns($token)->setMethods(['POST']);
|
||||
$admin->connect('/rotate-token', 'Admin::rotateToken', ['_name' => 'admin:rotate'])
|
||||
->setPatterns($token)->setMethods(['POST']);
|
||||
$admin->connect('/delete', 'Admin::delete', ['_name' => 'admin:delete'])
|
||||
->setPatterns($token)->setMethods(['POST']);
|
||||
$admin->connect('/present', 'Admin::present', ['_name' => 'admin:present'])->setPatterns($token);
|
||||
$admin->connect('/state', 'Admin::state', ['_name' => 'admin:state'])->setPatterns($token);
|
||||
$admin->connect('/control', 'Admin::control', ['_name' => 'admin:control'])
|
||||
->setPatterns($token)->setMethods(['POST']);
|
||||
$admin->connect('/qr.svg', 'Admin::qr', ['_name' => 'admin:qr'])->setPatterns($token);
|
||||
$admin->connect('/export.csv', 'Admin::export', ['_name' => 'admin:export'])->setPatterns($token);
|
||||
|
||||
$admin->connect('/slides/add', 'Slides::add', ['_name' => 'slides:add'])->setPatterns($token);
|
||||
$admin->connect('/slides/{id}/edit', 'Slides::edit', ['_name' => 'slides:edit'])
|
||||
->setPatterns($token)->setPass(['id']);
|
||||
$admin->connect('/slides/{id}/delete', 'Slides::delete', ['_name' => 'slides:delete'])
|
||||
->setPatterns($token)->setPass(['id'])->setMethods(['POST']);
|
||||
$admin->connect('/slides/{id}/move/{direction}', 'Slides::move', ['_name' => 'slides:move'])
|
||||
->setPatterns($token + ['direction' => 'up|down'])->setPass(['id', 'direction'])->setMethods(['POST']);
|
||||
$admin->connect('/slides/{id}/reset', 'Slides::reset', ['_name' => 'slides:reset'])
|
||||
->setPatterns($token)->setPass(['id'])->setMethods(['POST']);
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
# Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
#
|
||||
# Licensed under The MIT License
|
||||
# For full copyright and license information, please see the LICENSE.txt
|
||||
# Redistributions of files must retain the above copyright notice.
|
||||
# MIT License (https://opensource.org/licenses/mit-license.php)
|
||||
|
||||
CREATE TABLE i18n (
|
||||
id int NOT NULL auto_increment,
|
||||
locale varchar(6) NOT NULL,
|
||||
model varchar(255) NOT NULL,
|
||||
foreign_key int(10) NOT NULL,
|
||||
field varchar(255) NOT NULL,
|
||||
content text,
|
||||
PRIMARY KEY (id),
|
||||
UNIQUE INDEX I18N_LOCALE_FIELD(locale, model, foreign_key, field),
|
||||
INDEX I18N_FIELD(model, foreign_key, field)
|
||||
);
|
||||
@@ -0,0 +1,15 @@
|
||||
# Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
||||
#
|
||||
# Licensed under The MIT License
|
||||
# For full copyright and license information, please see the LICENSE.txt
|
||||
# Redistributions of files must retain the above copyright notice.
|
||||
# MIT License (https://opensource.org/licenses/mit-license.php)
|
||||
|
||||
CREATE TABLE `sessions` (
|
||||
`id` char(40) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
||||
`created` datetime DEFAULT CURRENT_TIMESTAMP, -- optional, requires MySQL 5.6.5+
|
||||
`modified` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, -- optional, requires MySQL 5.6.5+
|
||||
`data` blob DEFAULT NULL, -- for PostgreSQL use bytea instead of blob
|
||||
`expires` int(10) unsigned DEFAULT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
Reference in new issue
Block a user