Skip to content

Commit

Permalink
m
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-tharwat committed Mar 1, 2022
1 parent 638221d commit 91d7706
Show file tree
Hide file tree
Showing 17 changed files with 1,403 additions and 1,472 deletions.
4 changes: 2 additions & 2 deletions app/Helpers/MainHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class MainHelper {
protected static $colorGap = 20;
protected static $generated = array();

public function notify_user(
public static function notify_user(
$options=[]
){
$options = array_merge([
Expand All @@ -34,7 +34,7 @@ public function notify_user(
}
}

public function make_error_report(
public static function make_error_report(
$options=[]
){
$options = array_merge([
Expand Down
57 changes: 30 additions & 27 deletions app/Helpers/UserSystemInfoHelper.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
namespace App\Helpers;

use Stevebauman\Location\Facades\Location;

class UserSystemInfoHelper
{
Expand All @@ -16,7 +16,7 @@ class UserSystemInfoHelper
public function get_country_from_ip($ip)
{
try{
$location = \Location::get($ip);
$location = Location::get($ip);
$country=$this->countries[$location->countryCode];
return [
'country'=>$country,
Expand All @@ -31,31 +31,34 @@ public function get_country_from_ip($ip)
}


private static function get_user_agent(){
return $_SERVER['HTTP_USER_AGENT'];
public static function get_user_agent(){

return request()->header('User-Agent');
}

public static function get_ip(){

$ipaddress = '';
if (isset($_SERVER['HTTP_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_X_FORWARDED']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_FORWARDED']))
$ipaddress = $_SERVER['HTTP_FORWARDED'];
else if(isset($_SERVER['REMOTE_ADDR']))
$ipaddress = $_SERVER['REMOTE_ADDR'];
else if(request()->ip()!=null)
$ipaddress = request()->ip();
else
$ipaddress = 'UNKNOWN';
return $ipaddress;

$ipaddress = '';
if(isset($_SERVER["HTTP_CF_CONNECTING_IP"]))
$ipaddress=$_SERVER["HTTP_CF_CONNECTING_IP"];
else if(isset($_SERVER['REMOTE_ADDR']))
$ipaddress=$_SERVER['REMOTE_ADDR'];
else if(isset($_SERVER['HTTP_CLIENT_IP']))
$ipaddress = $_SERVER['HTTP_CLIENT_IP'];
else if(isset($_SERVER['HTTP_X_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_X_FORWARDED']))
$ipaddress = $_SERVER['HTTP_X_FORWARDED'];
else if(isset($_SERVER['HTTP_FORWARDED_FOR']))
$ipaddress = $_SERVER['HTTP_FORWARDED_FOR'];
else if(isset($_SERVER['HTTP_FORWARDED']))
$ipaddress = $_SERVER['HTTP_FORWARDED'];
else if(isset($_SERVER['REMOTE_ADDR']))
$ipaddress = $_SERVER['REMOTE_ADDR'];
else if(request()->ip()!=null)
$ipaddress = request()->ip();
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}


Expand Down Expand Up @@ -131,15 +134,15 @@ public static function get_device(){
$tablet_browser = 0;
$mobile_browser = 0;

if(preg_match('/(tablet|ipad|playbook)|(android(?!.*(mobi|opera mini)))/i', strtolower($_SERVER['HTTP_USER_AGENT']))){
if(preg_match('/(tablet|ipad|playbook)|(android(?!.*(mobi|opera mini)))/i', strtolower(request()->header('User-Agent')))){
$tablet_browser++;
}

if(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android|iemobile)/i', strtolower($_SERVER['HTTP_USER_AGENT']))){
if(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|android|iemobile)/i', strtolower(request()->header('User-Agent')))){
$mobile_browser++;
}

if((strpos(strtolower($_SERVER['HTTP_ACCEPT']),
if((isset($_SERVER['HTTP_ACCEPT'])&&strpos(strtolower($_SERVER['HTTP_ACCEPT']),
'application/vnd.wap.xhtml+xml')> 0) or
((isset($_SERVER['HTTP_X_WAP_PROFILE']) or
isset($_SERVER['HTTP_PROFILE'])))){
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/ArticleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function store(Request $request)
]);
$article->update(['main_image'=>$file['filename']]);
}
notify()->success('تم إضافة المقال بنجاح','عملية ناجحة');
flash()->success('تم إضافة المقال بنجاح','عملية ناجحة');
return redirect()->route('admin.articles.index');
}

Expand Down Expand Up @@ -153,7 +153,7 @@ public function update(Request $request, Article $article)
]);
$article->update(['main_image'=>$file['filename']]);
}
notify()->success('تم تحديث المقال بنجاح','عملية ناجحة');
flash()->success('تم تحديث المقال بنجاح','عملية ناجحة');
return redirect()->route('admin.articles.index');
}

Expand All @@ -167,7 +167,7 @@ public function destroy(Article $article)
{
if(!auth()->user()->has_access_to('delete',$article))abort(403);
$article->delete();
notify()->success('تم حذف المقال بنجاح','عملية ناجحة');
flash()->success('تم حذف المقال بنجاح','عملية ناجحة');
return redirect()->route('admin.articles.index');
}
}
6 changes: 3 additions & 3 deletions app/Http/Controllers/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function store(Request $request)
]);
$category->update(['image'=>$file['filename']]);
}
notify()->success('تم إضافة القسم بنجاح','عملية ناجحة');
flash()->success('تم إضافة القسم بنجاح','عملية ناجحة');
return redirect()->route('admin.categories.index');
}

Expand Down Expand Up @@ -146,7 +146,7 @@ public function update(Request $request, Category $category)
]);
$category->update(['image'=>$file['filename']]);
}
notify()->success('تم تحديث القسم بنجاح','عملية ناجحة');
flash()->success('تم تحديث القسم بنجاح','عملية ناجحة');
return redirect()->route('admin.categories.index');
}

Expand All @@ -160,7 +160,7 @@ public function destroy(Category $category)
{
if(!auth()->user()->has_access_to('delete',$category))abort(403);
$category->delete();
notify()->success('تم حذف القسم بنجاح','عملية ناجحة');
flash()->success('تم حذف القسم بنجاح','عملية ناجحة');
return redirect()->route('admin.categories.index');
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/ContactController.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public function update(Request $request, Contact $contact)
public function destroy(Contact $contact)
{
$contact->delete();
notify()->success('تم حذف طلب التواصل بنجاح','عملية ناجحة');
flash()->success('تم حذف طلب التواصل بنجاح','عملية ناجحة');
return redirect()->route('admin.contacts.index');
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/FrontController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function contact_post(Request $request)
'phone'=>$request->phone,
'message'=>"قادم من : ".urldecode(url()->previous())."\n\nالرسالة : ".$request->message
]);
notify()->success('تم استلام رسالتك بنجاح وسنتواصل معك في أقرب وقت');
flash()->success('تم استلام رسالتك بنجاح وسنتواصل معك في أقرب وقت');
//\Session::flash('message', __("Your Message Has Been Send Successfully And We Will Contact You Soon !"));
return redirect()->back();
}
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/ProfileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function update_password(Request $request){
auth()->user()->update([
'password'=>Hash::make($request->password)
]);
notify()->success('تم تغيير كلمة المرور بنجاح','عملية ناجحة');
flash()->success('تم تغيير كلمة المرور بنجاح','عملية ناجحة');
return redirect()->back();
}else{
notify()->error('كلمة المرور الحالية التي أدخلتها غير صحيحة','عملية غير ناجحة');
Expand All @@ -104,7 +104,7 @@ public function update_email(Request $request){
auth()->user()->update([
'email'=>$request->email
]);
notify()->success('تمت عملية تغيير البريد الالكتروني بنجاح','عملية ناجحة');
flash()->success('تمت عملية تغيير البريد الالكتروني بنجاح','عملية ناجحة');
return redirect()->back();
}

Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/RedirectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function store(Request $request)
'new_url'=>$request->new_url,
'code'=>$request->code,
]);
notify()->success('تم إضافة التحويل بنجاح','عملية ناجحة');
flash()->success('تم إضافة التحويل بنجاح','عملية ناجحة');
return redirect()->route('admin.redirections.index');
}

Expand Down Expand Up @@ -99,7 +99,7 @@ public function update(Request $request, Redirection $redirection)
'new_url'=>$request->new_url,
'code'=>$request->code,
]);
notify()->success('تم تحديث التحويل بنجاح','عملية ناجحة');
flash()->success('تم تحديث التحويل بنجاح','عملية ناجحة');
return redirect()->route('admin.redirections.index');
}

Expand All @@ -113,7 +113,7 @@ public function destroy(Redirection $redirection)
{
if(!auth()->user()->has_access_to('delete',$redirection))abort(403);
$redirection->delete();
notify()->success('تم حذف التحويل بنجاح','عملية ناجحة');
flash()->success('تم حذف التحويل بنجاح','عملية ناجحة');
return redirect()->route('admin.redirections.index');
}
}
2 changes: 1 addition & 1 deletion app/Http/Controllers/SettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function update(Request $request)
])['filename'];
\App\Models\Setting::query()->update(['website_cover'=>$file]);
}
notify()->success('تم تحديث الإعدادات بنجاح','عملية ناجحة');
flash()->success('تم تحديث الإعدادات بنجاح','عملية ناجحة');
return redirect()->back();

}
Expand Down
6 changes: 3 additions & 3 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function store(Request $request)
$user->update(['avatar'=>$file['filename']]);
}

notify()->success('تم إضافة المستخدم بنجاح','عملية ناجحة');
flash()->success('تم إضافة المستخدم بنجاح','عملية ناجحة');
return redirect()->route('admin.users.index');


Expand Down Expand Up @@ -165,7 +165,7 @@ public function update(Request $request, User $user)
$user->update(['avatar'=>$file['filename']]);
}

notify()->success('تم تحديث المستخدم بنجاح','عملية ناجحة');
flash()->success('تم تحديث المستخدم بنجاح','عملية ناجحة');
return redirect()->route('admin.users.index');
}

Expand All @@ -179,7 +179,7 @@ public function destroy(User $user)
{
if(!auth()->user()->has_access_to('delete',$user))abort(403);
$user->delete();
notify()->success('تم حذف المستخدم بنجاح','عملية ناجحة');
flash()->success('تم حذف المستخدم بنجاح','عملية ناجحة');
return redirect()->route('admin.users.index');
}
}
9 changes: 7 additions & 2 deletions app/Http/Middleware/TrustProxies.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Middleware;

use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Middleware\TrustProxies as Middleware;
use Illuminate\Http\Request;

class TrustProxies extends Middleware
Expand All @@ -19,5 +19,10 @@ class TrustProxies extends Middleware
*
* @var int
*/
protected $headers = Request::HEADER_X_FORWARDED_ALL;
protected $headers =
Request::HEADER_X_FORWARDED_FOR |
Request::HEADER_X_FORWARDED_HOST |
Request::HEADER_X_FORWARDED_PORT |
Request::HEADER_X_FORWARDED_PROTO |
Request::HEADER_X_FORWARDED_AWS_ELB;
}
5 changes: 5 additions & 0 deletions app/Providers/AppServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,10 @@ public function boot()
$settings = \App\Models\Setting::first();
View::share('settings', $settings);
}
\Spatie\Flash\Flash::levels([
'success' => 'alert-success',
'warning' => 'alert-warning',
'error' => 'alert-error',
]);
}
}
11 changes: 5 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,25 @@
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
"php": "^7.3|^8.0",
"fideloper/proxy": "^4.4",
"php": "^8.0.2",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^7.0.1",
"intervention/image": "^2.7",
"laravel/framework": "^8.65",
"laravel/framework": "^9.2",
"laravel/sanctum": "^2.11",
"laravel/tinker": "^2.5",
"laravel/ui": "^3.3",
"livewire/livewire": "^2.7",
"mckenziearts/laravel-notify": "^2.2",
"nesbot/carbon": "^2.54",
"spatie/laravel-flash": "^1.9",
"stevebauman/location": "^6.2"
},
"require-dev": {
"facade/ignition": "^2.5",
"spatie/laravel-ignition": "^1.0",
"fakerphp/faker": "^1.9.1",
"laravel/sail": "^1.0.1",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^5.10",
"nunomaduro/collision": "^6.1",
"phpunit/phpunit": "^9.5.10"
},
"autoload": {
Expand Down
Loading

0 comments on commit 91d7706

Please sign in to comment.