Added page to report user profiles

Sends notification with report to admin email set in env with SMTP server.
This commit is contained in:
Julian Prieber 2023-11-17 17:05:50 +01:00
parent 63d2892159
commit 404aa7549c
6 changed files with 350 additions and 0 deletions

View File

@ -11,6 +11,8 @@ use Illuminate\Support\Facades\Response;
use JeroenDesloovere\VCard\VCard; use JeroenDesloovere\VCard\VCard;
use Illuminate\Validation\Rule; use Illuminate\Validation\Rule;
use Illuminate\Support\Facades\Validator; use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Mail;
use App\Mail\ReportSubmissionMail;
use Auth; use Auth;
use DB; use DB;
@ -1160,6 +1162,20 @@ class UserController extends Controller
} }
// Hanle reports
function report(Request $request)
{
$formData = $request->all();
try {
Mail::to(env('ADMIN_EMAIL'))->send(new ReportSubmissionMail($formData));
return redirect('report')->with('success', __('messages.report_success'));
} catch (\Exception $e) {
return redirect()->back()->with('error', __('messages.report_error'));
}
}
//Edit/save page icons //Edit/save page icons
public function editIcons(request $request) public function editIcons(request $request)
{ {

View File

@ -0,0 +1,28 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;
class ReportSubmissionMail extends Mailable
{
use Queueable, SerializesModels;
public $formData;
public function __construct($formData)
{
$this->formData = $formData;
}
public function build()
{
return $this->view('layouts.send-report')
->subject(__('messages.report_mail_admin_subject'));
}
}

View File

@ -1039,6 +1039,53 @@ return [
'footer.Contact' => 'Contact', 'footer.Contact' => 'Contact',
/*
|--------------------------------------------------------------------------
| Report Page
|--------------------------------------------------------------------------
|
*/
'report_violation' => 'Report a Violation',
'url_label' => 'URL of the site you are reporting',
'report_type_label' => 'Type of report',
'hate_speech' => 'Hate Speech or Harassment',
'violence_threats' => 'Violence or Threats',
'illegal_activities' => 'Illegal Activities',
'copyright_infringement' => 'Copyright Infringement',
'misinformation_fake_news' => 'Misinformation or Fake News',
'identity_theft' => 'Identity Theft',
'drug_related_content' => 'Drug-related Content',
'weapons_harmful_objects' => 'Weapons or Harmful Objects',
'child_exploitation' => 'Child Exploitation',
'fraud_scams' => 'Fraud or Scams',
'privacy_violation' => 'Privacy Violation',
'impersonation' => 'Impersonation',
'other_specify' => 'Other (Specify)',
'additional_comments_label' => 'Additional comments',
'submit_button' => 'Submit',
'report_mail_admin_subject' => 'Profile Report',
'report_mail_admin_report' => 'A Profile has been reported',
'report_mail_reported_profile' => 'Reported Profile',
'report_mail_reported_url' => 'Reported URL',
'report_mail_type' => 'Type',
'report_mail_message' => 'Message',
'report_mail_report_submitted_by' => 'Report submitted by',
'report_mail_reported_by' => 'Reported by',
'report_mail_profile' => 'Profile',
'report_mail_button_profile' => 'View on Users Page',
'report_mail_button_delete' => 'Delete Reported User',
'report_error' => 'Profile could not be reported',
'report_success' => 'Profile has been reported successfully',
#=============================================================================# #=============================================================================#
# Laravel internal translations # # Laravel internal translations #
#=============================================================================# #=============================================================================#

View File

@ -0,0 +1,76 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
margin: 0;
padding: 20px;
}
.container {
max-width: 600px;
margin: 0 auto;
}
h2 {
color: #333;
}
.report-details {
margin-bottom: 20px;
}
.user-details {
margin-top: 20px;
}
.button-container {
text-align: center;
margin-top: 20px;
}
.button {
display: inline-block;
padding: 10px 20px;
background-color: #3498db;
color: #fff!important;
text-decoration: none;
border-radius: 5px;
}
.button.view {
background-color: #2ecc71;
}
</style>
</head>
<body>
<div class="container">
<h2>{{ __('messages.report_mail_admin_report') }}</h2>
<div class="report-details">
<h3>{{ __('messages.report_mail_reported_profile') }}</h3>
<strong>{{ __('messages.report_mail_reported_url') }}:</strong> <span>{{ $formData['url'] }}</span><br>
<strong>{{ __('messages.report_mail_type') }}:</strong> <span>{{ $formData['report-type'] }}</span><br>
<strong>{{ __('messages.report_mail_message') }}:</strong> <span>{{ $formData['message'] }}</span>
</div>
@if(auth()->check())
<div class="user-details">
<h3>{{ __('messages.report_mail_report_submitted_by') }}</h3>
<strong>{{ __('messages.report_mail_reported_by') }}:</strong> <span>{{ auth()->user()->email }}</span><br>
<strong>{{ __('messages.report_mail_profile') }}:</strong> <span>{{ url('u') . "/" . auth()->user()->id }}</span>
</div>
@endif
<div class="button-container">
<a href="{{url('admin/users')."?table[search]=".$formData['name']}}" class="button view">{{ __('messages.report_mail_button_profile') }}</a>
<a href="{{url('admin/delete-user')."/".$formData['id']}}" class="button" style="margin-left: 10px;">{{ __('messages.report_mail_button_delete') }}</a>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,180 @@
<!doctype html>
@include('layouts.lang')
<head>
<meta charset="utf-8">
@php $GLOBALS['themeName'] = config('advanced-config.home_theme'); @endphp
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
@if(env('CUSTOM_META_TAGS') == 'true' and config('advanced-config.title') != '')
<title>{{ config('advanced-config.title') }}</title>
@else
<title>{{ config('app.name') }}</title>
@endif
<!-- Favicon -->
@if(file_exists(base_path("assets/linkstack/images/").findFile('favicon')))
<link rel="icon" type="image/png" href="{{ asset('assets/linkstack/images/'.findFile('favicon')) }}">
@else
<link rel="icon" type="image/svg+xml" href="{{ asset('assets/linkstack/images/logo.svg') }}">
@endif
<script src="{{asset('assets/js/detect-dark-mode.js')}}"></script>
<!-- Library / Plugin Css Build -->
<link rel="stylesheet" href="{{asset('assets/css/core/libs.min.css')}}" />
<!-- Aos Animation Css -->
<link rel="stylesheet" href="{{asset('assets/vendor/aos/dist/aos.css')}}" />
@include('layouts.fonts')
<!-- Hope Ui Design System Css -->
<link rel="stylesheet" href="{{asset('assets/css/hope-ui.min.css?v=2.0.0')}}" />
<!-- Custom Css -->
<link rel="stylesheet" href="{{asset('assets/css/custom.min.css?v=2.0.0')}}" />
<!-- Dark Css -->
<link rel="stylesheet" href="{{asset('assets/css/dark.min.css')}}" />
<!-- Customizer Css -->
@if(file_exists(base_path("assets/dashboard-themes/dashboard.css")))
<link rel="stylesheet" href="{{asset('assets/dashboard-themes/dashboard.css')}}" />
@else
<link rel="stylesheet" href="{{asset('assets/css/customizer.min.css')}}" />
@endif
<!-- RTL Css -->
<link rel="stylesheet" href="{{asset('assets/css/rtl.min.css')}}" />
</head>
@php
if ($_SERVER['QUERY_STRING'] != '') {
try {
$id = $_SERVER['QUERY_STRING'];
$user = \App\Models\User::where('id', $id)->first();
$name = $user->littlelink_name;
if ($name != null)$url = url('') . '/@' . $name;
} catch (\Exception $e) {}
}
@endphp
<body>
<div class="container-fluid">
<div class="align-items-center justify-content-center d-flex min-vh-100">
<div class="col-10 col-sm-8 col-md-6 col-lg-5">
<div class="card shadow-lg card--bg-gray card--customized align-self-center">
<div class="card-body">
<h1 class="card-title">{{ __('messages.report_violation') }}</h1>
@if(session('success'))
<div class="alert alert-left alert-success alert-dismissible fade show mb-3" role="alert">
<span> {{ __('messages.report_success') }}</span>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
@endif
@if(session('error'))
<div class="alert alert-right alert-warning alert-dismissible fade show mb-3" role="alert">
<span> {{ __('messages.report_error') }}</span>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
@endif
<form action="{{ url('report') }}" enctype="multipart/form-data" method="post">
@csrf
<input type="hidden" name="id" value="{{$id ?? null}}">
<input type="hidden" name="name" value="{{$name ?? null}}">
<div class="mb-2 control-wrapper">
<div class="label-container">
<label for="url" class="form-label">{{ __('messages.url_label') }}*</label>
</div>
<input type="url" class="form-control" id="url" name="url" value="{{ $url ?? null }}">
<div class="display-msg"></div>
</div>
<div class="mb-2 control-wrapper">
<div class="label-container">
<label for="report-type" class="form-label">{{ __('messages.report_type_label') }}*</label>
</div>
<select id="report-type" class="form-control" name="report-type" required>
<option></option>
<option value="{{ __('messages.hate_speech') }}">{{ __('messages.hate_speech') }}</option>
<option value="{{ __('messages.violence_threats') }}">{{ __('messages.violence_threats') }}</option>
<option value="{{ __('messages.illegal_activities') }}">{{ __('messages.illegal_activities') }}</option>
<option value="{{ __('messages.copyright_infringement') }}">{{ __('messages.copyright_infringement') }}</option>
<option value="{{ __('messages.misinformation_fake_news') }}">{{ __('messages.misinformation_fake_news') }}</option>
<option value="{{ __('messages.identity_theft') }}">{{ __('messages.identity_theft') }}</option>
<option value="{{ __('messages.drug_related_content') }}">{{ __('messages.drug_related_content') }}</option>
<option value="{{ __('messages.weapons_harmful_objects') }}">{{ __('messages.weapons_harmful_objects') }}</option>
<option value="{{ __('messages.child_exploitation') }}">{{ __('messages.child_exploitation') }}</option>
<option value="{{ __('messages.fraud_scams') }}">{{ __('messages.fraud_scams') }}</option>
<option value="{{ __('messages.privacy_violation') }}">{{ __('messages.privacy_violation') }}</option>
<option value="{{ __('messages.impersonation') }}">{{ __('messages.impersonation') }}</option>
<option value="{{ __('messages.other_specify') }}">{{ __('messages.other_specify') }}</option>
</select>
<div class="display-msg"></div>
</div>
<div class="mb-4 control-wrapper">
<div class="label-container">
<label for="message" class="form-label">{{ __('messages.additional_comments_label') }}</label>
</div>
<textarea class="form-control" id="message" name="message" rows="3"></textarea>
<div class="display-msg"></div>
</div>
<button type="submit" class="btn btn-primary">{{ __('messages.submit_button') }}</button>
</form>
</div>
</div>
</div>
</div>
</div>
</body>
<!-- Footer Section End -->
<!-- Library Bundle Script -->
<script src="{{asset('assets/js/core/libs.min.js')}}"></script>
<!-- External Library Bundle Script -->
<script src="{{asset('assets/js/core/external.min.js')}}"></script>
<!-- Widgetchart Script -->
<script src="{{asset('assets/js/charts/widgetcharts.js')}}"></script>
<!-- mapchart Script -->
<script src="{{asset('assets/js/charts/vectore-chart.js')}}"></script>
<script src="{{asset('assets/js/charts/dashboard.js')}}" ></script>
<!-- fslightbox Script -->
<script src="{{asset('assets/js/plugins/fslightbox.js')}}"></script>
<!-- Settings Script -->
<script src="{{asset('assets/js/plugins/setting.js')}}"></script>
<!-- Slider-tab Script -->
<script src="{{asset('assets/js/plugins/slider-tabs.js')}}"></script>
<!-- Form Wizard Script -->
<script src="{{asset('assets/js/plugins/form-wizard.js')}}"></script>
<!-- AOS Animation Plugin-->
<script src="{{asset('assets/vendor/aos/dist/aos.js')}}"></script>
<!-- App Script -->
<script src="{{asset('assets/js/hope-ui.js')}}" defer></script>
<!-- Flatpickr Script -->
<script src="{{asset('assets/vendor/flatpickr/dist/flatpickr.min.js')}}"></script>
<script src="{{asset('assets/js/plugins/flatpickr.js')}}" defer></script>
<script src="{{asset('assets/js/plugins/prism.mini.js')}}"></script>
</html>

View File

@ -96,6 +96,9 @@ Route::get('/theme/@{littlelink}', [UserController::class, 'theme'])->name('them
Route::get('/vcard/{id?}', [UserController::class, 'vcard'])->name('vcard'); Route::get('/vcard/{id?}', [UserController::class, 'vcard'])->name('vcard');
Route::get('/u/{id?}', [UserController::class, 'userRedirect'])->name('userRedirect'); Route::get('/u/{id?}', [UserController::class, 'userRedirect'])->name('userRedirect');
Route::get('/report', function () {return view('report');});
Route::post('/report', [UserController::class, 'report'])->name('report');
Route::get('/demo-page', [App\Http\Controllers\HomeController::class, 'demo'])->name('demo'); Route::get('/demo-page', [App\Http\Controllers\HomeController::class, 'demo'])->name('demo');
} }