Skip to content

Commit 404aa75

Browse files
committed
Added page to report user profiles
Sends notification with report to admin email set in env with SMTP server.
1 parent 63d2892 commit 404aa75

File tree

6 files changed

+350
-0
lines changed

6 files changed

+350
-0
lines changed

app/Http/Controllers/UserController.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use JeroenDesloovere\VCard\VCard;
1212
use Illuminate\Validation\Rule;
1313
use Illuminate\Support\Facades\Validator;
14+
use Illuminate\Support\Facades\Mail;
15+
use App\Mail\ReportSubmissionMail;
1416

1517
use Auth;
1618
use DB;
@@ -1160,6 +1162,20 @@ public function importData(Request $request)
11601162
}
11611163

11621164

1165+
// Hanle reports
1166+
function report(Request $request)
1167+
{
1168+
$formData = $request->all();
1169+
1170+
try {
1171+
Mail::to(env('ADMIN_EMAIL'))->send(new ReportSubmissionMail($formData));
1172+
1173+
return redirect('report')->with('success', __('messages.report_success'));
1174+
} catch (\Exception $e) {
1175+
return redirect()->back()->with('error', __('messages.report_error'));
1176+
}
1177+
}
1178+
11631179
//Edit/save page icons
11641180
public function editIcons(request $request)
11651181
{

app/Mail/ReportSubmissionMail.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace App\Mail;
4+
5+
use Illuminate\Bus\Queueable;
6+
use Illuminate\Contracts\Queue\ShouldQueue;
7+
use Illuminate\Mail\Mailable;
8+
use Illuminate\Mail\Mailables\Content;
9+
use Illuminate\Mail\Mailables\Envelope;
10+
use Illuminate\Queue\SerializesModels;
11+
12+
class ReportSubmissionMail extends Mailable
13+
{
14+
use Queueable, SerializesModels;
15+
16+
public $formData;
17+
18+
public function __construct($formData)
19+
{
20+
$this->formData = $formData;
21+
}
22+
23+
public function build()
24+
{
25+
return $this->view('layouts.send-report')
26+
->subject(__('messages.report_mail_admin_subject'));
27+
}
28+
}

resources/lang/en/messages.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1039,6 +1039,53 @@
10391039
'footer.Contact' => 'Contact',
10401040

10411041

1042+
/*
1043+
|--------------------------------------------------------------------------
1044+
| Report Page
1045+
|--------------------------------------------------------------------------
1046+
|
1047+
*/
1048+
1049+
'report_violation' => 'Report a Violation',
1050+
'url_label' => 'URL of the site you are reporting',
1051+
'report_type_label' => 'Type of report',
1052+
'hate_speech' => 'Hate Speech or Harassment',
1053+
'violence_threats' => 'Violence or Threats',
1054+
'illegal_activities' => 'Illegal Activities',
1055+
'copyright_infringement' => 'Copyright Infringement',
1056+
'misinformation_fake_news' => 'Misinformation or Fake News',
1057+
'identity_theft' => 'Identity Theft',
1058+
'drug_related_content' => 'Drug-related Content',
1059+
'weapons_harmful_objects' => 'Weapons or Harmful Objects',
1060+
'child_exploitation' => 'Child Exploitation',
1061+
'fraud_scams' => 'Fraud or Scams',
1062+
'privacy_violation' => 'Privacy Violation',
1063+
'impersonation' => 'Impersonation',
1064+
'other_specify' => 'Other (Specify)',
1065+
'additional_comments_label' => 'Additional comments',
1066+
'submit_button' => 'Submit',
1067+
1068+
1069+
'report_mail_admin_subject' => 'Profile Report',
1070+
'report_mail_admin_report' => 'A Profile has been reported',
1071+
1072+
'report_mail_reported_profile' => 'Reported Profile',
1073+
'report_mail_reported_url' => 'Reported URL',
1074+
'report_mail_type' => 'Type',
1075+
'report_mail_message' => 'Message',
1076+
1077+
'report_mail_report_submitted_by' => 'Report submitted by',
1078+
'report_mail_reported_by' => 'Reported by',
1079+
'report_mail_profile' => 'Profile',
1080+
1081+
'report_mail_button_profile' => 'View on Users Page',
1082+
'report_mail_button_delete' => 'Delete Reported User',
1083+
1084+
1085+
'report_error' => 'Profile could not be reported',
1086+
'report_success' => 'Profile has been reported successfully',
1087+
1088+
10421089
#=============================================================================#
10431090
# Laravel internal translations #
10441091
#=============================================================================#
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<style>
8+
body {
9+
font-family: Arial, sans-serif;
10+
line-height: 1.6;
11+
margin: 0;
12+
padding: 20px;
13+
}
14+
15+
.container {
16+
max-width: 600px;
17+
margin: 0 auto;
18+
}
19+
20+
h2 {
21+
color: #333;
22+
}
23+
24+
.report-details {
25+
margin-bottom: 20px;
26+
}
27+
28+
.user-details {
29+
margin-top: 20px;
30+
}
31+
32+
.button-container {
33+
text-align: center;
34+
margin-top: 20px;
35+
}
36+
37+
.button {
38+
display: inline-block;
39+
padding: 10px 20px;
40+
background-color: #3498db;
41+
color: #fff!important;
42+
text-decoration: none;
43+
border-radius: 5px;
44+
}
45+
46+
.button.view {
47+
background-color: #2ecc71;
48+
}
49+
</style>
50+
</head>
51+
<body>
52+
<div class="container">
53+
<h2>{{ __('messages.report_mail_admin_report') }}</h2>
54+
55+
<div class="report-details">
56+
<h3>{{ __('messages.report_mail_reported_profile') }}</h3>
57+
<strong>{{ __('messages.report_mail_reported_url') }}:</strong> <span>{{ $formData['url'] }}</span><br>
58+
<strong>{{ __('messages.report_mail_type') }}:</strong> <span>{{ $formData['report-type'] }}</span><br>
59+
<strong>{{ __('messages.report_mail_message') }}:</strong> <span>{{ $formData['message'] }}</span>
60+
</div>
61+
62+
@if(auth()->check())
63+
<div class="user-details">
64+
<h3>{{ __('messages.report_mail_report_submitted_by') }}</h3>
65+
<strong>{{ __('messages.report_mail_reported_by') }}:</strong> <span>{{ auth()->user()->email }}</span><br>
66+
<strong>{{ __('messages.report_mail_profile') }}:</strong> <span>{{ url('u') . "/" . auth()->user()->id }}</span>
67+
</div>
68+
@endif
69+
70+
<div class="button-container">
71+
<a href="{{url('admin/users')."?table[search]=".$formData['name']}}" class="button view">{{ __('messages.report_mail_button_profile') }}</a>
72+
<a href="{{url('admin/delete-user')."/".$formData['id']}}" class="button" style="margin-left: 10px;">{{ __('messages.report_mail_button_delete') }}</a>
73+
</div>
74+
</div>
75+
</body>
76+
</html>

resources/views/report.blade.php

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
2+
3+
4+
<!doctype html>
5+
@include('layouts.lang')
6+
<head>
7+
<meta charset="utf-8">
8+
@php $GLOBALS['themeName'] = config('advanced-config.home_theme'); @endphp
9+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
10+
@if(env('CUSTOM_META_TAGS') == 'true' and config('advanced-config.title') != '')
11+
<title>{{ config('advanced-config.title') }}</title>
12+
@else
13+
<title>{{ config('app.name') }}</title>
14+
@endif
15+
16+
<!-- Favicon -->
17+
@if(file_exists(base_path("assets/linkstack/images/").findFile('favicon')))
18+
<link rel="icon" type="image/png" href="{{ asset('assets/linkstack/images/'.findFile('favicon')) }}">
19+
@else
20+
<link rel="icon" type="image/svg+xml" href="{{ asset('assets/linkstack/images/logo.svg') }}">
21+
@endif
22+
23+
<script src="{{asset('assets/js/detect-dark-mode.js')}}"></script>
24+
25+
<!-- Library / Plugin Css Build -->
26+
<link rel="stylesheet" href="{{asset('assets/css/core/libs.min.css')}}" />
27+
28+
<!-- Aos Animation Css -->
29+
<link rel="stylesheet" href="{{asset('assets/vendor/aos/dist/aos.css')}}" />
30+
31+
@include('layouts.fonts')
32+
33+
<!-- Hope Ui Design System Css -->
34+
<link rel="stylesheet" href="{{asset('assets/css/hope-ui.min.css?v=2.0.0')}}" />
35+
36+
<!-- Custom Css -->
37+
<link rel="stylesheet" href="{{asset('assets/css/custom.min.css?v=2.0.0')}}" />
38+
39+
<!-- Dark Css -->
40+
<link rel="stylesheet" href="{{asset('assets/css/dark.min.css')}}" />
41+
42+
<!-- Customizer Css -->
43+
@if(file_exists(base_path("assets/dashboard-themes/dashboard.css")))
44+
<link rel="stylesheet" href="{{asset('assets/dashboard-themes/dashboard.css')}}" />
45+
@else
46+
<link rel="stylesheet" href="{{asset('assets/css/customizer.min.css')}}" />
47+
@endif
48+
49+
<!-- RTL Css -->
50+
<link rel="stylesheet" href="{{asset('assets/css/rtl.min.css')}}" />
51+
52+
53+
</head>
54+
55+
@php
56+
57+
if ($_SERVER['QUERY_STRING'] != '') {
58+
59+
try {
60+
61+
$id = $_SERVER['QUERY_STRING'];
62+
$user = \App\Models\User::where('id', $id)->first();
63+
$name = $user->littlelink_name;
64+
if ($name != null)$url = url('') . '/@' . $name;
65+
66+
} catch (\Exception $e) {}
67+
68+
}
69+
70+
@endphp
71+
72+
<body>
73+
<div class="container-fluid">
74+
<div class="align-items-center justify-content-center d-flex min-vh-100">
75+
<div class="col-10 col-sm-8 col-md-6 col-lg-5">
76+
<div class="card shadow-lg card--bg-gray card--customized align-self-center">
77+
<div class="card-body">
78+
<h1 class="card-title">{{ __('messages.report_violation') }}</h1>
79+
80+
@if(session('success'))
81+
<div class="alert alert-left alert-success alert-dismissible fade show mb-3" role="alert">
82+
<span> {{ __('messages.report_success') }}</span>
83+
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="Close"></button>
84+
</div>
85+
@endif
86+
87+
@if(session('error'))
88+
<div class="alert alert-right alert-warning alert-dismissible fade show mb-3" role="alert">
89+
<span> {{ __('messages.report_error') }}</span>
90+
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="alert" aria-label="Close"></button>
91+
</div>
92+
@endif
93+
94+
<form action="{{ url('report') }}" enctype="multipart/form-data" method="post">
95+
@csrf
96+
<input type="hidden" name="id" value="{{$id ?? null}}">
97+
<input type="hidden" name="name" value="{{$name ?? null}}">
98+
<div class="mb-2 control-wrapper">
99+
<div class="label-container">
100+
<label for="url" class="form-label">{{ __('messages.url_label') }}*</label>
101+
</div>
102+
<input type="url" class="form-control" id="url" name="url" value="{{ $url ?? null }}">
103+
<div class="display-msg"></div>
104+
</div>
105+
<div class="mb-2 control-wrapper">
106+
<div class="label-container">
107+
<label for="report-type" class="form-label">{{ __('messages.report_type_label') }}*</label>
108+
</div>
109+
<select id="report-type" class="form-control" name="report-type" required>
110+
<option></option>
111+
<option value="{{ __('messages.hate_speech') }}">{{ __('messages.hate_speech') }}</option>
112+
<option value="{{ __('messages.violence_threats') }}">{{ __('messages.violence_threats') }}</option>
113+
<option value="{{ __('messages.illegal_activities') }}">{{ __('messages.illegal_activities') }}</option>
114+
<option value="{{ __('messages.copyright_infringement') }}">{{ __('messages.copyright_infringement') }}</option>
115+
<option value="{{ __('messages.misinformation_fake_news') }}">{{ __('messages.misinformation_fake_news') }}</option>
116+
<option value="{{ __('messages.identity_theft') }}">{{ __('messages.identity_theft') }}</option>
117+
<option value="{{ __('messages.drug_related_content') }}">{{ __('messages.drug_related_content') }}</option>
118+
<option value="{{ __('messages.weapons_harmful_objects') }}">{{ __('messages.weapons_harmful_objects') }}</option>
119+
<option value="{{ __('messages.child_exploitation') }}">{{ __('messages.child_exploitation') }}</option>
120+
<option value="{{ __('messages.fraud_scams') }}">{{ __('messages.fraud_scams') }}</option>
121+
<option value="{{ __('messages.privacy_violation') }}">{{ __('messages.privacy_violation') }}</option>
122+
<option value="{{ __('messages.impersonation') }}">{{ __('messages.impersonation') }}</option>
123+
<option value="{{ __('messages.other_specify') }}">{{ __('messages.other_specify') }}</option>
124+
</select>
125+
<div class="display-msg"></div>
126+
</div>
127+
<div class="mb-4 control-wrapper">
128+
<div class="label-container">
129+
<label for="message" class="form-label">{{ __('messages.additional_comments_label') }}</label>
130+
</div>
131+
<textarea class="form-control" id="message" name="message" rows="3"></textarea>
132+
<div class="display-msg"></div>
133+
</div>
134+
<button type="submit" class="btn btn-primary">{{ __('messages.submit_button') }}</button>
135+
</form>
136+
</div>
137+
</div>
138+
</div>
139+
</div>
140+
</div>
141+
</body>
142+
<!-- Footer Section End -->
143+
144+
<!-- Library Bundle Script -->
145+
<script src="{{asset('assets/js/core/libs.min.js')}}"></script>
146+
147+
<!-- External Library Bundle Script -->
148+
<script src="{{asset('assets/js/core/external.min.js')}}"></script>
149+
150+
<!-- Widgetchart Script -->
151+
<script src="{{asset('assets/js/charts/widgetcharts.js')}}"></script>
152+
153+
<!-- mapchart Script -->
154+
<script src="{{asset('assets/js/charts/vectore-chart.js')}}"></script>
155+
<script src="{{asset('assets/js/charts/dashboard.js')}}" ></script>
156+
157+
<!-- fslightbox Script -->
158+
<script src="{{asset('assets/js/plugins/fslightbox.js')}}"></script>
159+
160+
<!-- Settings Script -->
161+
<script src="{{asset('assets/js/plugins/setting.js')}}"></script>
162+
163+
<!-- Slider-tab Script -->
164+
<script src="{{asset('assets/js/plugins/slider-tabs.js')}}"></script>
165+
166+
<!-- Form Wizard Script -->
167+
<script src="{{asset('assets/js/plugins/form-wizard.js')}}"></script>
168+
169+
<!-- AOS Animation Plugin-->
170+
<script src="{{asset('assets/vendor/aos/dist/aos.js')}}"></script>
171+
172+
<!-- App Script -->
173+
<script src="{{asset('assets/js/hope-ui.js')}}" defer></script>
174+
175+
<!-- Flatpickr Script -->
176+
<script src="{{asset('assets/vendor/flatpickr/dist/flatpickr.min.js')}}"></script>
177+
<script src="{{asset('assets/js/plugins/flatpickr.js')}}" defer></script>
178+
179+
<script src="{{asset('assets/js/plugins/prism.mini.js')}}"></script>
180+
</html>

routes/web.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@
9696
Route::get('/vcard/{id?}', [UserController::class, 'vcard'])->name('vcard');
9797
Route::get('/u/{id?}', [UserController::class, 'userRedirect'])->name('userRedirect');
9898

99+
Route::get('/report', function () {return view('report');});
100+
Route::post('/report', [UserController::class, 'report'])->name('report');
101+
99102
Route::get('/demo-page', [App\Http\Controllers\HomeController::class, 'demo'])->name('demo');
100103

101104
}

0 commit comments

Comments
 (0)