LinkStack/resources/views/components/finishing.blade.php

261 lines
13 KiB
PHP
Raw Normal View History

2023-02-03 16:27:22 +01:00
<?php
2022-12-01 20:31:29 +01:00
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Migrations\Migrator;
2022-12-01 20:31:29 +01:00
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
2023-02-03 16:27:22 +01:00
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\File;
use Database\Seeders\ButtonSeeder;
use App\Models\Page;
2022-06-30 10:39:40 +02:00
//run before finishing:
if(EnvEditor::keyExists('JOIN_BETA')){ /* Do nothing if key already exists */
} else { EnvEditor::addKey('JOIN_BETA', 'false');} // Adds key to .env file
if(EnvEditor::keyExists('SKIP_UPDATE_BACKUP')){ /* Do nothing if key already exists */
} else { EnvEditor::addKey('SKIP_UPDATE_BACKUP', 'false');} // Adds key to .env file
if(EnvEditor::keyExists('CUSTOM_META_TAGS')){ /* Do nothing if key already exists */
} else {EnvEditor::addKey('CUSTOM_META_TAGS', 'false');}
2022-08-08 14:23:58 +02:00
if(EnvEditor::keyExists('MAINTENANCE_MODE')){ /* Do nothing if key already exists */
} else {EnvEditor::addKey('MAINTENANCE_MODE', 'false');}
if(EnvEditor::keyExists('ALLOW_CUSTOM_CODE_IN_THEMES')){ /* Do nothing if key already exists */
} else {EnvEditor::addKey('ALLOW_CUSTOM_CODE_IN_THEMES', 'true');}
if(EnvEditor::keyExists('ENABLE_THEME_UPDATER')){ /* Do nothing if key already exists */
} else {EnvEditor::addKey('ENABLE_THEME_UPDATER', 'true');}
if(EnvEditor::keyExists('ENABLE_SOCIAL_LOGIN')){ /* Do nothing if key already exists */
} else {EnvEditor::addKey('ENABLE_SOCIAL_LOGIN', 'false');}
2022-11-09 09:50:39 +01:00
if(EnvEditor::keyExists('USE_THEME_PREVIEW_IFRAME')){ /* Do nothing if key already exists */
2022-11-15 15:01:51 +01:00
} else {EnvEditor::addKey('USE_THEME_PREVIEW_IFRAME', 'true');}
2022-11-09 09:50:39 +01:00
2022-11-20 22:07:37 +01:00
if(EnvEditor::keyExists('FORCE_ROUTE_HTTPS')){ /* Do nothing if key already exists */
} else {EnvEditor::addKey('FORCE_ROUTE_HTTPS', 'false');}
2023-02-13 14:20:14 +01:00
if(EnvEditor::keyExists('HIDE_VERIFICATION_CHECKMARK')){ /* Do nothing if key already exists */
} else {EnvEditor::addKey('HIDE_VERIFICATION_CHECKMARK', 'false');}
if(EnvEditor::keyExists('ALLOW_CUSTOM_BACKGROUNDS')){ /* Do nothing if key already exists */
} else {EnvEditor::addKey('ALLOW_CUSTOM_BACKGROUNDS', 'true');}
if(EnvEditor::keyExists('ALLOW_USER_IMPORT')){ /* Do nothing if key already exists */
} else {EnvEditor::addKey('ALLOW_USER_IMPORT', 'true');}
if(EnvEditor::keyExists('ALLOW_USER_EXPORT')){ /* Do nothing if key already exists */
} else {EnvEditor::addKey('ALLOW_USER_EXPORT', 'true');}
if(EnvEditor::keyExists('SUPPORTED_DOMAINS')){ /* Do nothing if key already exists */
} else {EnvEditor::addKey('SUPPORTED_DOMAINS', '');}
if(EnvEditor::keyExists('MANUAL_USER_VERIFICATION')){ /* Do nothing if key already exists */
} else {EnvEditor::addKey('MANUAL_USER_VERIFICATION', 'false');}
2023-05-10 19:41:19 +02:00
if(EnvEditor::keyExists('DISPLAY_CREDIT_FOOTER')){ /* Do nothing if key already exists */
} else {EnvEditor::addKey('DISPLAY_CREDIT_FOOTER', 'true');}
2023-06-11 19:05:36 +02:00
if(EnvEditor::keyExists('LOCALE')){ /* Do nothing if key already exists */
} else {EnvEditor::addKey('LOCALE', 'en');}
2023-05-10 15:23:58 +02:00
if(EnvEditor::keyExists('ADMIN_EMAIL')){} else
2023-05-10 15:33:00 +02:00
{if(Auth::user()->id == 1){EnvEditor::addKey('ADMIN_EMAIL', App\Models\User::find(1)->email);}
2023-05-10 15:23:58 +02:00
else{EnvEditor::addKey('ADMIN_EMAIL', '');}}
2023-05-04 18:32:44 +02:00
if(env('APP_NAME') == 'LittleLink Custom' or env('APP_NAME') == 'LittleLink') {
EnvEditor::editKey('APP_NAME', 'LinkStack');
}
if (EnvEditor::keyExists('ALLOW_REGISTRATION')) { /* Do nothing if key already exists */
} else {
$pagedb = DB::table('pages')->select('register')->first();
if ($pagedb->register) {
EnvEditor::addKey('ALLOW_REGISTRATION', 'true');
} else {
EnvEditor::addKey('ALLOW_REGISTRATION', 'false');
}
try {
DB::table('pages')->update(['register' => null]);
} catch (Exception $e) {}
}
2023-01-09 18:25:08 +01:00
2023-05-05 14:47:16 +02:00
try {
$file = base_path('storage/RSTAC');
if (file_exists($file)) {
copy(base_path('storage/templates/advanced-config.php'), base_path('config/advanced-config.php'));
unlink($file);
}
} catch (Exception $e) {}
2023-06-19 14:05:54 +02:00
try {
$vendorLangPath = resource_path('lang/vendor');
if (File::exists($vendorLangPath)) {
File::deleteDirectory($vendorLangPath);
}
} catch (Exception $e) {}
2023-01-09 18:25:08 +01:00
// Footer page customization
if(EnvEditor::keyExists('DISPLAY_FOOTER_HOME')){} else {EnvEditor::addKey('DISPLAY_FOOTER_HOME', 'true');}
if(EnvEditor::keyExists('DISPLAY_FOOTER_TERMS')){} else {EnvEditor::addKey('DISPLAY_FOOTER_TERMS', 'true');}
if(EnvEditor::keyExists('DISPLAY_FOOTER_PRIVACY')){} else {EnvEditor::addKey('DISPLAY_FOOTER_PRIVACY', 'true');}
if(EnvEditor::keyExists('DISPLAY_FOOTER_CONTACT')){} else {EnvEditor::addKey('DISPLAY_FOOTER_CONTACT', 'true');}
if(EnvEditor::keyExists('TITLE_FOOTER_HOME')){} else {EnvEditor::addKey('TITLE_FOOTER_HOME', 'Home');}
if(EnvEditor::keyExists('TITLE_FOOTER_TERMS')){} else {EnvEditor::addKey('TITLE_FOOTER_TERMS', 'Terms');}
if(EnvEditor::keyExists('TITLE_FOOTER_PRIVACY')){} else {EnvEditor::addKey('TITLE_FOOTER_PRIVACY', 'Privacy');}
if(EnvEditor::keyExists('TITLE_FOOTER_CONTACT')){} else {EnvEditor::addKey('TITLE_FOOTER_CONTACT', 'Contact');}
if(EnvEditor::keyExists('HOME_FOOTER_LINK')){} else {EnvEditor::addKey('HOME_FOOTER_LINK', '');}
2022-06-30 10:39:40 +02:00
if(EnvEditor::keyExists('FORCE_HTTPS')){ /* Do nothing if key already exists */
} else {EnvEditor::addKey('FORCE_HTTPS', 'false');}
2022-11-09 20:29:26 +01:00
$data['page'] = Page::select('contact')->first();
2023-05-01 13:48:13 +02:00
if (strpos($data['page']->contact, 'info@littlelink-custom.com') !== false or strpos($data['page']->contact, 'LittleLink Custom') !== false) {
2022-11-09 20:29:26 +01:00
$contact = '
2023-04-27 16:53:59 +02:00
<p><strong><a href="https://linkstack.org/">LinkStack</a></strong> is a free, open source&nbsp;link&nbsp;sharing platform. We depend on community feedback to steadily improve this project.</p>
2022-11-09 20:29:26 +01:00
<p><strong>Feel free to send us your feedback!</strong></p>
<ul>
2023-04-27 19:45:12 +02:00
<li>Join our <a href="https://discord.linkstack.org/">community Discord</a></li>
2023-04-27 17:06:40 +02:00
<li>Join the <a href="https://github.com/linkstackorg/linkstack/discussions">discussion forum</a></li>
<li>Request a feature and add it to the <a href="https://github.com/linkstackorg/linkstack/discussions/49">to-do list</a></li>
2023-05-01 13:48:13 +02:00
<li>Write us an <a href="mailto:info@linkstack.org?subject=Inquiry%20about%20LinkStack">email</a></li>
2022-11-09 20:29:26 +01:00
</ul>
2023-04-27 17:06:40 +02:00
<p>If you&#39;re having any trouble or encountered a bug, feel free to <a href="https://github.com/linkstackorg/linkstack/issues">open an issue on GitHub</a>.</p>
2022-11-09 20:29:26 +01:00
<p>&nbsp;</p>
';
Page::first()->update(['contact' => $contact]);
2022-11-09 20:37:29 +01:00
}
2022-11-09 20:29:26 +01:00
2023-05-04 15:41:54 +02:00
$data['page'] = Page::select('home_message')->first();
if (strpos($data['page']->home_message, 'LittleLink Custom') !== false) {
$home_message = '
<p>Take control of your online presence with&nbsp;<a href="https://linkstack.org/"><strong>LinkStack</strong></a> the privacy-focused, open-source <strong>link management platform</strong>. Create a customizable profile page to manage <strong>all your important links in one convenient location</strong> and give your audience a seamless browsing experience.</p>
';
Page::first()->update(['home_message' => $home_message]);
}
2022-07-07 22:57:40 +02:00
/* Updates button database entries */
Schema::disableForeignKeyConstraints();
try {
$migrator = app('migrator');
$migrator->run(database_path('migrations'), ['--force' => true]);
} catch (exception $e) {}
try {DB::table('buttons')->delete();} catch (exception $e) {}
try {DB::table('buttons')->truncate();} catch (exception $e) {}
try {
$seeder = new ButtonSeeder();
$seeder->run();
} catch (exception $e) {}
2022-07-07 22:57:40 +02:00
Schema::enableForeignKeyConstraints();
2022-12-06 20:27:01 +01:00
try {
2022-12-01 20:31:29 +01:00
DB::table('link_types')->updateOrInsert([
'typename' => 'text',
'title' => 'Text',
'icon' => 'bi bi-fonts',
'description' => 'Add static text to your page that is not clickable.',
'params' => '[{
"tag": "textarea",
"id": "static-text",
"for": "static_text",
"label": "Text",
"name": "static_text",
"class": "form-control"
}
]'
]);
DB::table('link_types')->updateOrInsert([
'typename' => 'email',
'title' => 'E-Mail address',
'icon' => 'bi bi-envelope-fill',
'description' => 'Add an email that opens a system dialog to compose a new email.'
]);
DB::table('link_types')->updateOrInsert([
'typename' => 'telephone',
'title' => 'Telephone number',
'icon' => 'bi bi-telephone-fill',
'description' => 'Add a telephone number that opens a system dialog to initiate a phone call.'
]);
2023-03-27 19:04:41 +02:00
DB::table('link_types')->updateOrInsert([
'typename' => 'vcard',
'title' => 'Vcard',
'icon' => 'bi bi-person-square',
'description' => 'Create or upload an electronic business card.'
]);
2022-12-06 20:27:01 +01:00
} catch (exception $e) {}
2022-12-01 20:31:29 +01:00
2023-05-01 12:37:56 +02:00
// Moves all previous images to the new path
2023-05-03 18:44:50 +02:00
try{if (is_dir(base_path('assets/img'))) {
2023-05-01 12:37:56 +02:00
$files = File::files(base_path('img'));
foreach ($files as $file) {
$filename = $file->getFilename();
$destination = base_path('assets/img/' . $filename);
if (!File::exists($destination)) {
if (!$file->isDir()) {
File::move($file, $destination);}}}}
2023-05-03 18:44:50 +02:00
}catch(exception $e) {}
try{if (is_dir(base_path('assets/img/background-img'))) {
2023-05-01 12:37:56 +02:00
$files = File::files(base_path('img/background-img'));
foreach ($files as $file) {
$filename = $file->getFilename();
$destination = base_path('assets/img/background-img/' . $filename);
if (!File::exists($destination)) {
if (!$file->isDir()) {
File::move($file, $destination);}}}}
2023-05-03 18:44:50 +02:00
}catch(exception $e) {}
try{if (is_dir(base_path('littlelink/images'))) {
2023-05-01 12:37:56 +02:00
$files = File::files(base_path('littlelink/images'));
foreach ($files as $file) {
$filename = $file->getFilename();
$destination = base_path('assets/linkstack/images/' . $filename);
if (!File::exists($destination)) {
if (!$file->isDir()) {
File::move($file, $destination);}}}}
2023-05-03 18:44:50 +02:00
}catch(exception $e) {}
try{if (is_dir(base_path('littlelink/images'))) {
2023-05-01 12:37:56 +02:00
$files = File::files(base_path('littlelink/images'));
foreach ($files as $file) {
$filename = $file->getFilename();
$destination = base_path('assets/linkstack/images/' . $filename);
if (!File::exists($destination)) {
if (!$file->isDir()) {
File::move($file, $destination);}}}}
2023-05-03 18:44:50 +02:00
}catch(exception $e) {}
try{if (is_dir(base_path('studio/favicon/icons'))) {
2023-05-01 12:37:56 +02:00
$files = File::files(base_path('studio/favicon/icons'));
foreach ($files as $file) {
$filename = $file->getFilename();
$destination = base_path('assets/favicon/icons/' . $filename);
if (!File::exists($destination)) {
if (!$file->isDir()) {
File::move($file, $destination);}}}}
2023-05-03 18:44:50 +02:00
}catch(exception $e) {}
2023-05-01 12:37:56 +02:00
2023-02-03 16:27:22 +01:00
// Changes saved profile images from littlelink_name to IDs.
// This runs every time the updater runs.
// Not sure if this will cause any issues.
// If it works, I won't touch it.
try {
$users = DB::table('users')->get();
foreach ($users as $user) {
$oldName = $user->littlelink_name . '.png';
$newName = $user->id . '.png';
2023-05-03 18:35:32 +02:00
$oldPath = base_path('assets/img/' . $oldName);
$newPath = base_path('assets/img/' . $newName);
2023-02-03 16:27:22 +01:00
if (File::exists($oldPath)) {
File::move($oldPath, $newPath);
}}} catch (exception $e) {}
2022-06-30 10:39:40 +02:00
?>