diff --git a/.platform.app.yaml b/.platform.app.yaml new file mode 100644 index 000000000..ef147c1c2 --- /dev/null +++ b/.platform.app.yaml @@ -0,0 +1,101 @@ +# This file describes an application. You can have multiple applications +# in the same project. + +# The name of this app. Must be unique within a project. +name: restyaboard + +# The runtime the application uses. +type: 'php:7.2' + +# The relationships of the application with services or other applications. +# The left-hand side is the name of the relationship as it will be exposed +# to the application in the PLATFORM_RELATIONSHIPS variable. The right-hand +# side is in the form `:`. +relationships: + database: 'pgsql96:postgresql' + # platform sql -p 52l75zyfpy2t6 --relationship database < sql/restyaboard_with_empty_data.sql + +variables: + php: + # Turn display errors off when you're ready to launch. + display_errors: On + upload_max_filesize: 50M + post_max_size: 50M + max_execution_time: 200 + max_input_time: 200 + memory_limit: 256M + +# The configuration of app when it is exposed to the web. +web: + locations: + '/': + # The public directory of the app, relative to its root. + root: '' + # The front-controller script to send non-static requests to. + passthru: '/client/index.html' + allow: true + rules: + ^/client/img/([a-zA-Z_]*)/([a-zA-Z_]*)/([a-zA-Z0-9_\.]*)$: + passthru: '/server/php/image.php?size=$1&model=$2&filename=$3' + ^/ical/([0-9]*)/([0-9]*)/([a-zA-Z0-9]*).ics$: + passthru: '/server/php/ical.php?id=$1&user_id=$2&hash=$2' + ^/download/([0-9]*)/([a-zA-Z0-9_\.]*)$: + passthru: '/server/php/download.php?id=$1&hash=$2' + ^/oauth_callback/([a-zA-Z0-9_\.]*)/([a-zA-Z0-9_\.]*)$: + passthru: '/server/php/oauth_callback.php?plugin=$1&code=$2' + ^/oauth/authorize$: + passthru: '/server/php/authorize.php' + ^/api/(.*)$: + passthru: '/server/php/R/r.php?_url=$1' + ^/(css|js|img|font|apps|locales)/(.*)$: + passthru: '/client/$1/$2' + ^/favicon.ico$: + passthru: '/client/favicon.ico' + ^/manifest.json$: + passthru: '/client/manifest.json' + ^/apple-touch-icon(.*)$: + passthru: '/client/apple-touch-icon$1' + +runtime: + extensions: + - pgsql + - pdo_pgsql + - curl + - gd + - imap + - json + - ldap + - mbstring + +# The size of the persistent disk of the application (in MB). +disk: 2048 + + +# The mounts that will be performed when the package is deployed. +mounts: + '/client/img/micro_thumb': 'shared:files/client/img/micro_thumb' + '/client/img/small_thumb': 'shared:files/client/img/small_thumb' + '/client/img/normal_thumb': 'shared:files/client/img/normal_thumb' + '/client/img/medium_thumb': 'shared:files/client/img/medium_thumb' + '/client/img/large_thumb': 'shared:files/client/img/large_thumb' + '/client/img/extra_large_thumb': 'shared:files/client/img/extra_large_thumb' + '/client/img/original': 'shared:files/client/img/original' + '/tmp': 'shared:files/tmp' + '/tmp/cache': 'shared:files/tmp/cache' + '/media': 'shared:files/media' + +# Restyaboard crons +crons: + main: + spec: '*/5 * * * *' + cmd: 'cd server/php/shell; ./main.sh' + +# Deploy hook, access to services & done once (per cluster, not per node), only mounts are writable at this point +# Note: Http traffic is paused while this is running, so for prod code this should finish as fast as possible, < 30s +hooks: + deploy: | + set -e + # Mainly relevant for eZ Platform demo usage, for own setup adapt this or remove and rely on migrations. + if [ ! -f /tmp/.sql.installed ]; then + php server/php/platformsh_install.php + fi \ No newline at end of file diff --git a/.platform/routes.yaml b/.platform/routes.yaml new file mode 100644 index 000000000..3011a1e59 --- /dev/null +++ b/.platform/routes.yaml @@ -0,0 +1,11 @@ +# The routes of the project. +# +# Each route describes how an incoming URL is going +# to be processed by Platform.sh. + +"http://{default}/": + type: upstream + upstream: "restyaboard:http" +"http://www.{default}/": + type: redirect + to: "https://{default}/" \ No newline at end of file diff --git a/.platform/services.yaml b/.platform/services.yaml new file mode 100644 index 000000000..ec865aee6 --- /dev/null +++ b/.platform/services.yaml @@ -0,0 +1,8 @@ +# The services of the project. +# +# Each service listed will be deployed +# to power your Platform.sh project. + +pgsql96: + type: postgresql:9.6 + disk: 2048 diff --git a/client/img/default-admin-user.png b/client/img/default-admin-user.png new file mode 100755 index 000000000..e3a72b00e Binary files /dev/null and b/client/img/default-admin-user.png differ diff --git a/server/php/config.inc.php b/server/php/config.inc.php index 0193d52aa..651d38d55 100644 --- a/server/php/config.inc.php +++ b/server/php/config.inc.php @@ -41,11 +41,25 @@ define('OAUTH_CLIENTID', '7742632501382313'); define('OAUTH_CLIENT_SECRET', '4g7C4l1Y2b0S6a7L8c1E7B3K0e'); } -define('R_DB_HOST', 'localhost'); -define('R_DB_USER', 'restya'); -define('R_DB_PASSWORD', 'hjVl2!rGd'); -define('R_DB_NAME', 'restyaboard'); -define('R_DB_PORT', 5432); +if (getenv('PLATFORM_RELATIONSHIPS')) { + $relationships = json_decode(base64_decode(getenv('PLATFORM_RELATIONSHIPS')), true); + if (!empty($relationships['database'])) { + foreach ($relationships['database'] as $endpoint) { + define('R_DB_HOST', $endpoint['host']); + define('R_DB_USER', $endpoint['username']); + define('R_DB_PASSWORD', $endpoint['password']); + define('R_DB_NAME', $endpoint['path']); + define('R_DB_PORT', $endpoint['port']); + break; + } + } + } else { + define('R_DB_HOST', 'localhost'); + define('R_DB_USER', 'restya'); + define('R_DB_PASSWORD', 'hjVl2!rGd'); + define('R_DB_NAME', 'restyaboard'); + define('R_DB_PORT', 5432); + } define('SECURITYSALT', 'e9a556134534545ab47c6c81c14f06c0b8sdfsdf'); define('SITE_LICENSE_KEY', 'REPLACE YOUR LICENCE HERE'); if (!defined('STDIN') && !file_exists(SITE_URL_FOR_SHELL) && !empty($_server_domain_url)) { @@ -85,4 +99,4 @@ 'large_thumb' => '202x151' ) ); -$aspect['CardAttachment']['large_thumb'] = 1; +$aspect['CardAttachment']['large_thumb'] = 1; \ No newline at end of file diff --git a/server/php/image.php b/server/php/image.php index a27a206c0..ee6456b2e 100644 --- a/server/php/image.php +++ b/server/php/image.php @@ -66,7 +66,12 @@ function preserveImageTransparency($fileExt, $sourceImg, &$targetImg) $row = pg_fetch_assoc($s_result); $fullPath = $row['path']; } - $fullPath = MEDIA_PATH . DS . $fullPath; + //Todo default image + if(explode('/',$fullPath)[0] == 'client' && explode('/',$fullPath)[1] == 'img'){ + $fullPath = APP_PATH. DS .$fullPath; + }else{ + $fullPath = MEDIA_PATH . DS . $fullPath; + } $is_aspect = false; if (!empty($aspect[$model][$size])) { $is_aspect = true; @@ -185,4 +190,4 @@ function preserveImageTransparency($fileExt, $sourceImg, &$targetImg) header('Location:' . $_SERVER['REQUEST_URI'] . '?chrome-3xx-fix'); } else { header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404); -} +} \ No newline at end of file diff --git a/server/php/platformsh_install.php b/server/php/platformsh_install.php new file mode 100644 index 000000000..b42494bc9 --- /dev/null +++ b/server/php/platformsh_install.php @@ -0,0 +1,23 @@ + /tmp/.sql.installed'); +exec('mkdir -p /tmp/pgpass'); +exec('chmod -R go-rwx /tmp/pgpass'); +$relationships = json_decode(base64_decode(getenv('PLATFORM_RELATIONSHIPS')), true); +if (!empty($relationships['database'])) { + foreach ($relationships['database'] as $endpoint) { + define('R_DB_HOST', $endpoint['host']); + define('R_DB_USER', $endpoint['username']); + define('R_DB_PASSWORD', $endpoint['password']); + define('R_DB_NAME', $endpoint['path']); + define('R_DB_PORT', $endpoint['port']); + break; + } + } + +exec('echo "'.R_DB_HOST.':'.R_DB_PORT.':'.R_DB_NAME.':'.R_DB_USER.':'.R_DB_PASSWORD.'" > /tmp/pgpass/.pgpass'); +exec('chmod 0600 /tmp/pgpass/.pgpass'); +putenv('PGPASSFILE=/tmp/pgpass/.pgpass'); +exec('psql --host='.R_DB_HOST. ' --port='.R_DB_PORT.' --dbname='.R_DB_NAME.' --username='.R_DB_USER.' --no-password --file=' . $current_dir . '/../../sql/restyaboard_with_empty_data.sql'); +exec('rm -rf /tmp/pgpass'); \ No newline at end of file diff --git a/sql/restyaboard_with_empty_data.sql b/sql/restyaboard_with_empty_data.sql index 1732000f4..8bb27f7a6 100644 --- a/sql/restyaboard_with_empty_data.sql +++ b/sql/restyaboard_with_empty_data.sql @@ -5472,7 +5472,7 @@ COPY public.user_logins (id, created, modified, user_id, ip_id, user_agent, is_l -- COPY public.users (id, created, modified, role_id, username, email, password, full_name, initials, about_me, profile_picture_path, notification_frequency, is_allow_desktop_notification, is_active, is_email_confirmed, created_organization_count, created_board_count, joined_organization_count, list_count, joined_card_count, created_card_count, joined_board_count, checklist_count, checklist_item_completed_count, checklist_item_count, activity_count, card_voter_count, last_activity_id, last_login_date, last_login_ip_id, ip_id, login_type_id, is_productivity_beats, user_login_count, is_ldap, is_send_newsletter, last_email_notified_activity_id, owner_board_count, member_board_count, owner_organization_count, member_organization_count, language, timezone, default_desktop_notification, is_list_notifications_enabled, is_card_notifications_enabled, is_card_members_notifications_enabled, is_card_labels_notifications_enabled, is_card_checklists_notifications_enabled, is_card_attachments_notifications_enabled, is_intro_video_skipped, is_invite_from_board, is_two_factor_authentication_enabled, two_factor_authentication_hash) FROM stdin; -1 2014-06-03 12:40:41.189 2015-04-02 16:26:03.939 1 admin board@restya.com $2y$12$QiJW6TjPKzDZPAuoWEex9OjPHQF33YzfkdC09FhasgPO.MjZ5btKe New Admin PA Added About Me media/User/1/default-admin-user.png \N f t t 0 0 0 0 0 0 0 0 0 0 0 0 2 2015-06-06 10:53:34.46 1 \N 2 t 2 f 2 0 0 0 0 0 \N Europe/Andorra t t t t t t t f f f \N +1 2014-06-03 12:40:41.189 2015-04-02 16:26:03.939 1 admin board@restya.com $2y$12$QiJW6TjPKzDZPAuoWEex9OjPHQF33YzfkdC09FhasgPO.MjZ5btKe New Admin PA Added About Me client/img/default-admin-user.png \N f t t 0 0 0 0 0 0 0 0 0 0 0 0 2 2015-06-06 10:53:34.46 1 \N 2 t 2 f 2 0 0 0 0 0 \N Europe/Andorra t t t t t t t f f f \N 2 2014-07-05 11:46:40.804 2014-07-05 11:46:40.804 2 user board+user@restya.com $2y$12$QiJW6TjPKzDZPAuoWEex9OjPHQF33YzfkdC09FhasgPO.MjZ5btKe User U \N \N \N f t t 0 0 0 0 0 0 0 0 0 0 0 0 0 2018-10-29 18:23:04.746305 2 \N 2 f 1 f 0 0 0 0 0 0 \N Asia/Calcutta f f f f f f f f f f \N \.