Skip to content

Commit

Permalink
users
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-tharwat committed Nov 15, 2021
1 parent 2bdd1f1 commit d645631
Show file tree
Hide file tree
Showing 38 changed files with 1,213 additions and 2,213 deletions.
167 changes: 167 additions & 0 deletions app/Helpers/UserSystemInfoHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<?php

/**
*
*/
namespace App\Helpers;
class UserSystemInfoHelper
{
private static function get_user_agent(){
return $_SERVER['HTTP_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
$ipaddress = 'UNKNOWN';
return $ipaddress;

}

public static function get_os(){

$user_agent = self::get_user_agent();
$os_platform = "Unknown OS Platform";
$os_array = array(
'/windows nt 10/i' => 'Windows 10',
'/windows nt 6.3/i' => 'Windows 8.1',
'/windows nt 6.2/i' => 'Windows 8',
'/windows nt 6.1/i' => 'Windows 7',
'/windows nt 6.0/i' => 'Windows Vista',
'/windows nt 5.2/i' => 'Windows Server 2003/XP x64',
'/windows nt 5.1/i' => 'Windows XP',
'/windows xp/i' => 'Windows XP',
'/windows nt 5.0/i' => 'Windows 2000',
'/windows me/i' => 'Windows ME',
'/win98/i' => 'Windows 98',
'/win95/i' => 'Windows 95',
'/win16/i' => 'Windows 3.11',
'/macintosh|mac os x/i' => 'Mac OS X',
'/mac_powerpc/i' => 'Mac OS 9',
'/linux/i' => 'Linux',
'/ubuntu/i' => 'Ubuntu',
'/iphone/i' => 'iPhone',
'/ipod/i' => 'iPod',
'/ipad/i' => 'iPad',
'/android/i' => 'Android',
'/blackberry/i' => 'BlackBerry',
'/webos/i' => 'Mobile',
);

foreach ($os_array as $regex => $value){
if(preg_match($regex, $user_agent)){
$os_platform = $value;
}
}
return $os_platform;
}

public static function get_browsers(){

$user_agent= self::get_user_agent();

$browser = "Unknown Browser";

$browser_array = array(
'/msie/i' => 'Internet Explorer',
'/Trident/i' => 'Internet Explorer',
'/firefox/i' => 'Firefox',
'/safari/i' => 'Safari',
'/chrome/i' => 'Chrome',
'/edge/i' => 'Edge',
'/opera/i' => 'Opera',
'/netscape/' => 'Netscape',
'/maxthon/i' => 'Maxthon',
'/knoqueror/i' => 'Konqueror',
'/ubrowser/i' => 'UC Browser',
'/mobile/i' => 'Safari Browser',
);

foreach($browser_array as $regex => $value){
if(preg_match($regex, $user_agent)){
$browser = $value;
}
}
return $browser;
}

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']))){
$tablet_browser++;
}

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

if((strpos(strtolower($_SERVER['HTTP_ACCEPT']),
'application/vnd.wap.xhtml+xml')> 0) or
((isset($_SERVER['HTTP_X_WAP_PROFILE']) or
isset($_SERVER['HTTP_PROFILE'])))){
$mobile_browser++;
}

$mobile_ua = strtolower(substr(self::get_user_agent(), 0, 4));
$mobile_agents = array(
'w3c','acs-','alav','alca','amoi','audi','avan','benq','bird','blac','blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno',
'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-','maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-',

'newt','noki','palm','pana','pant','phil','play','port','prox','qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar',

'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-','tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp',
'wapr','webc','winw','winw','xda','xda-');

if(in_array($mobile_ua,$mobile_agents)){
$mobile_browser++;
}

if(strpos(strtolower(self::get_user_agent()),'opera mini') > 0){
$mobile_browser++;

//Check for tables on opera mini alternative headers

$stock_ua =
strtolower(isset($_SERVER['HTTP_X_OPERAMINI_PHONE_UA'])?
$_SERVER['HTTP_X_OPERAMINI_PHONE_UA']:
(isset($_SERVER['HTTP_DEVICE_STOCK_UA'])?
$_SERVER['HTTP_DEVICE_STOCK_UA']:''));

if(preg_match('/(tablet|ipad|playbook)|(android(?!.*mobile))/i', $stock_ua)){
$tablet_browser++;
}
}

if($tablet_browser > 0){
//do something for tablet devices

return 'Tablet';
}
else if($mobile_browser > 0){
//do something for mobile devices

return 'Mobile';
}
else{
//do something for everything else
return 'Computer';
}

}
}
19 changes: 2 additions & 17 deletions app/Http/Controllers/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,9 @@ class AdminController extends Controller
{
public function index(Request $request)
{
$data=[];
if(auth()->user()->power=="ADMIN")
$data= $this->admin_attributes($request);

return view('admin.index',compact('data'));

}
public function admin_attributes(Request $request){
return [
"path"=>app('rinvex.statistics.path')->orderBy('count','DESC')->get(),
"geoip"=>app('rinvex.statistics.geoip')->orderBy('count','DESC')->get(),
"route"=>app('rinvex.statistics.route')->orderBy('count','DESC')->get(),
"agent"=>app('rinvex.statistics.agent')->orderBy('count','DESC')->get(),
"device"=>app('rinvex.statistics.device')->orderBy('count','DESC')->get(),
"request"=>app('rinvex.statistics.request')->get(),
"platform"=>app('rinvex.statistics.platform')->orderBy('count','DESC')->get()
];
return view('admin.index');
}



}
34 changes: 18 additions & 16 deletions app/Http/Controllers/HelperController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,70 +52,72 @@ public function upload_file(Request $request)
]);
}
public function robots(){
return "Sitemap: ".env('APP_URL')."/sitemap.xml\nUser-agent: *";
$settings = \App\Models\Setting::firstOrFail();
return response($settings->robots_txt)->header('Content-Type', 'text/plain');
}
public function manifest(){
$settings = \App\Models\Setting::firstOrFail();
$manifest = [
"name" => env('APP_NAME'),
"short_name" => env('APP_NAME'),
"name" => $settings->website_name,
"short_name" => $settings->website_name,
"start_url" => env('APP_URL'),
"display" => "standalone",
"theme_color" => "#243c6d",
"background_color" => "#1565c0",
"theme_color" => $settings->main_color ,
"background_color" => $settings->main_color ,
"orientation" => "portrait",
"icons" => [
[
"src" => asset('/images/default/logo.png'),
"src" => $settings->website_logo(),
"sizes" => "36x36",
"type" => "image/png",
],
[
"src" => asset('/images/default/logo.png'),
"src" => $settings->website_logo(),
"sizes" => "48x48",
"type" => "image/png",
],
[
"src" => asset('/images/default/logo.png'),
"src" => $settings->website_logo(),
"sizes" => "60x60",
"type" => "image/png",
],
[
"src" => asset('/images/default/logo.png'),
"src" => $settings->website_logo(),
"sizes" => "72x72",
"type" => "image/png",
],
[
"src" => asset('/images/default/logo.png'),
"src" => $settings->website_logo(),
"sizes" => "76x76",
"type" => "image/png",
],
[
"src" => asset('/images/default/logo.png'),
"src" => $settings->website_logo(),
"sizes" => "96x96",
"type" => "image/png",
],
[
"src" => asset('/images/default/logo.png'),
"src" => $settings->website_logo(),
"sizes" => "120x120",
"type" => "image/png",
],
[
"src" => asset('/images/default/logo.png'),
"src" => $settings->website_logo(),
"sizes" => "152x152",
"type" => "image/png",
],
[
"src" => asset('/images/default/logo.png'),
"src" => $settings->website_logo(),
"sizes" => "180x180",
"type" => "image/png",
],
[
"src" => asset('/images/default/logo.png'),
"src" => $settings->website_logo(),
"sizes" => "192x192",
"type" => "image/png",
],
[
"src" => asset('/images/default/logo.png'),
"src" => $settings->website_logo(),
"sizes" => "512x512",
"type" => "image/png",
],
Expand Down
97 changes: 96 additions & 1 deletion app/Http/Controllers/SettingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,103 @@ public function index()

public function update(Request $request)
{
\App\Models\Setting::query()->update([
'website_name'=>$request->website_name,
'address'=>$request->address,
'website_bio'=>$request->website_bio,
'contact_email'=>$request->contact_email,
'main_color'=>$request->main_color,
'hover_color'=>$request->hover_color,
'phone'=>$request->phone,
'phone2'=>$request->phone2,
'whatsapp_phone'=>$request->whatsapp_phone,
'facebook_link'=>$request->facebook_link,
'twitter_link'=>$request->twitter_link,
'instagram_link'=>$request->instagram_link,
'youtube_link'=>$request->youtube_link,
'telegram_link'=>$request->telegram_link,
'whatsapp_link'=>$request->whatsapp_link,
'tiktok_link'=>$request->tiktok_link,
'nafezly_link'=>$request->nafezly_link,
'linkedin_link'=>$request->linkedin_link,
'github_link'=>$request->github_link,
'another_link1'=>$request->another_link1,
'another_link2'=>$request->another_link2,
'another_link3'=>$request->another_link3,
'privacy_page'=>$request->privacy_page,
'terms_page'=>$request->terms_page,
'about_page'=>$request->about_page,
'contact_page'=>$request->contact_page,
'header_code'=>$request->header_code,
'footer_code'=>$request->footer_code,
'robots_txt'=>$request->robots_txt,
]);

if($request->hasFile('website_logo')){
$file = $this->store_file([
'source'=>$request->website_logo,
'validation'=>"image",
'path_to_save'=>'/uploads/website/',
'type'=>'IMAGE',
'user_id'=>\Auth::user()->id,
'resize'=>null,
'small_path'=>'small/',
'visibility'=>'PUBLIC',
'file_system_type'=>env('FILESYSTEM_DRIVER','local'),
'compress'=>'auto'
])['filename'];
\App\Models\Setting::query()->update(['website_logo'=>$file]);
}
if($request->hasFile('website_wide_logo')){
$file = $this->store_file([
'source'=>$request->website_wide_logo,
'validation'=>"image",
'path_to_save'=>'/uploads/website/',
'type'=>'IMAGE',
'user_id'=>\Auth::user()->id,
'resize'=>null,
'small_path'=>'small/',
'visibility'=>'PUBLIC',
'file_system_type'=>env('FILESYSTEM_DRIVER','local'),
'compress'=>'auto'
])['filename'];
\App\Models\Setting::query()->update(['website_wide_logo'=>$file]);
}
if($request->hasFile('website_icon')){
$file = $this->store_file([
'source'=>$request->website_icon,
'validation'=>"image",
'path_to_save'=>'/uploads/website/',
'type'=>'IMAGE',
'user_id'=>\Auth::user()->id,
'resize'=>[500,1000],
'small_path'=>'small/',
'visibility'=>'PUBLIC',
'file_system_type'=>env('FILESYSTEM_DRIVER','local'),
'compress'=>'auto'
])['filename'];
\App\Models\Setting::query()->update(['website_icon'=>$file]);
}


if($request->hasFile('website_cover')){
$file = $this->store_file([
'source'=>$request->website_cover,
'validation'=>"image",
'path_to_save'=>'/uploads/website/',
'type'=>'IMAGE',
'user_id'=>\Auth::user()->id,
'resize'=>[500,1000],
'small_path'=>'small/',
'visibility'=>'PUBLIC',
'file_system_type'=>env('FILESYSTEM_DRIVER','local'),
'compress'=>'auto'
])['filename'];
\App\Models\Setting::query()->update(['website_cover'=>$file]);
}
notify()->success('تم تحديث الإعدادات بنجاح','عملية ناجحة');
return redirect()->back();

dd($request->all());
}

}
Loading

0 comments on commit d645631

Please sign in to comment.