id; $littlelink_name = Auth::user()->littlelink_name; $links = Link::where('user_id', $userId)->select('link')->count(); $clicks = Link::where('user_id', $userId)->sum('click_number'); $userNumber = User::count(); $siteLinks = Link::count(); $siteClicks = Link::sum('click_number'); return view('panel/index', ['littlelink_name' => $littlelink_name, 'links' => $links, 'clicks' => $clicks, 'siteLinks' => $siteLinks, 'siteClicks' => $siteClicks, 'userNumber' => $userNumber]); } //Get users by type public function users(request $request) { $usersType = $request->type; switch($usersType){ case 'all': $data['users'] = User::select('id', 'name', 'littlelink_name', 'role', 'block', 'email_verified_at')->get(); return view('panel/users', $data); break; case 'user': $data['users'] = User::where('role', 'user')->select('id', 'name', 'littlelink_name', 'role', 'block', 'email_verified_at')->get(); return view('panel/users', $data); break; case 'vip': $data['users'] = User::where('role', 'vip')->select('id', 'name', 'littlelink_name', 'role', 'block', 'email_verified_at')->get(); return view('panel/users', $data); break; case 'admin': $data['users'] = User::where('role', 'admin')->select('id', 'name', 'littlelink_name', 'role', 'block', 'email_verified_at')->get(); return view('panel/users', $data); break; } } //Search user by name public function searchUser(request $request) { $name = $request->name; $data['users'] = User::where('name', $name)->select('id', 'name', 'role', 'block')->get(); return view('panel/users', $data); } //Block user and delete their links public function blockUser(request $request) { $id = $request->id; $status = $request->block; if($status == 'yes'){ $block = 'no'; }elseif($status == 'no'){ $block = 'yes'; } User::where('id', $id)->update(['block' => $block]); Link::where('user_id', $id)->delete(); return redirect('panel/users/all'); } //Verify or un-verify users emails public function verifyUser(request $request) { $id = $request->id; $status = $request->verify; if($status == '-'){ $verify = '0000-00-00 00:00:00'; }else{ $verify = NULL; } User::where('id', $id)->update(['email_verified_at' => $verify]); return redirect('panel/users/all'); } //Show user to edit public function showUser(request $request) { $id = $request->id; $data['user'] = User::where('id', $id)->get(); return view('panel/edit-user', $data); } //Show link, click number, up link in links page public function showLinksUser(request $request) { $id = $request->id; $data['user'] = User::where('id', $id)->get(); $data['links'] = Link::select('id', 'link', 'title', 'order', 'click_number', 'up_link', 'links.button_id')->where('user_id', $id)->orderBy('up_link', 'asc')->orderBy('order', 'asc')->paginate(10); return view('panel/links', $data); } //Delete link public function deleteLinkUser(request $request) { $linkId = $request->id; Link::where('id', $linkId)->delete(); return back(); } //Save user edit public function editUser(request $request) { $request->validate([ 'name' => '', 'email' => '', 'password' => '', 'littlelink_name' => '', ]); $id = $request->id; $name = $request->name; $email = $request->email; $password = Hash::make($request->password); $profilePhoto = $request->file('image'); $littlelink_name = $request->littlelink_name; $littlelink_description = $request->littlelink_description; $role = $request->role; if($request->password == '' ) { User::where('id', $id)->update(['name' => $name, 'email' => $email, 'littlelink_name' => $littlelink_name, 'littlelink_description' => $littlelink_description, 'role' => $role]); } else { User::where('id', $id)->update(['name' => $name, 'email' => $email, 'password' => $password, 'littlelink_name' => $littlelink_name, 'littlelink_description' => $littlelink_description, 'role' => $role]); } if(!empty($profilePhoto)){ $profilePhoto->move(base_path('/img'), $littlelink_name . ".png"); } return back(); } //Show site pages to edit public function showSitePage() { $data['pages'] = Page::select('terms', 'privacy', 'contact', 'register')->get(); return view('panel/pages', $data); } //Save site pages public function editSitePage(request $request) { $terms = $request->terms; $privacy = $request->privacy; $contact = $request->contact; $register = $request->register; Page::first()->update(['terms' => $terms, 'privacy' => $privacy, 'contact' => $contact, 'register' => $register]); return back(); } //Show home message for edit public function showSite() { $message = Page::select('home_message')->first(); return view('panel/site', $message); } //Save home message and logo public function editSite(request $request) { $message = $request->message; $logo = $request->file('image'); Page::first()->update(['home_message' => $message]); if(!empty($logo)){ $logo->move(base_path('/littlelink/images/'), "avatar.png"); } return back(); } //View any of the pages: contact, terms, privacy public function pages(request $request) { $name = $request->name; try { $data['page'] = Page::select($name)->first(); } catch (Exception $e) { return abort(404); } return view('pages', ['data' => $data, 'name' => $name]); } //Statistics of the number of clicks and links public function phpinfo() { return view('panel/phpinfo'); } //Shows config file editor page public function showFileEditor(request $request) { return view('/panel/config'); } //Saves advanced config public function editAC(request $request) { $AdvancedConfig = $request->AdvancedConfig; file_put_contents('config/advanced-config.php', $AdvancedConfig); return view('/panel/config'); } //Saves .env config public function editENV(request $request) { $AdvancedConfig = $request->AdvancedConfig; file_put_contents('.env', $AdvancedConfig); return view('/panel/config'); } //Shows config file editor page public function showBackups(request $request) { return view('/panel/backups'); } //Delete custom theme public function deleteTheme(request $request) { $del = $request->deltheme; if (empty($del)) { echo ''; } else { $folderName = base_path() . '/themes/' . $del; function removeFolder($folderName) { if (is_dir($folderName)) $folderHandle = opendir($folderName); if (!$folderHandle) return false; while($file = readdir($folderHandle)) { if ($file != "." && $file != "..") { if (!is_dir($folderName."/".$file)) unlink($folderName."/".$file); else removeFolder($folderName.'/'.$file); } } closedir($folderHandle); rmdir($folderName); } removeFolder($folderName); return Redirect('/panel/theme'); }} //Shows config file editor page public function showThemes(request $request) { return view('/panel/theme'); } }