id; $littlelink_name = Auth::user()->littlelink_name; $userinfo = User::find($userId); $links = Link::where('user_id', $userId)->select('link')->count(); $clicks = Link::where('user_id', $userId)->sum('click_number'); $topLinks = Link::where('user_id', $userId)->orderby('click_number', 'desc') ->whereNotNull('link')->where('link', '<>', '') ->take(5)->get(); $pageStats = [ 'visitors' => [ 'all' => visits('App\Models\User', $littlelink_name)->count(), 'day' => visits('App\Models\User', $littlelink_name)->period('day')->count(), 'week' => visits('App\Models\User', $littlelink_name)->period('week')->count(), 'month' => visits('App\Models\User', $littlelink_name)->period('month')->count(), 'year' => visits('App\Models\User', $littlelink_name)->period('year')->count(), ], 'os' => visits('App\Models\User', $littlelink_name)->operatingSystems(), 'referers' => visits('App\Models\User', $littlelink_name)->refs(), 'countries' => visits('App\Models\User', $littlelink_name)->countries(), ]; return view('studio/index', ['greeting' => $userinfo->name, 'toplinks' => $topLinks, 'links' => $links, 'clicks' => $clicks, 'pageStats' => $pageStats]); } //Show littlelink page. example => http://127.0.0.1:8000/+admin public function littlelink(request $request) { if(isset($request->useif)){ $littlelink_name = User::select('littlelink_name')->where('id', $request->littlelink)->value('littlelink_name'); $id = $request->littlelink; } else { $littlelink_name = $request->littlelink; $id = User::select('id')->where('littlelink_name', $littlelink_name)->value('id'); } if (empty($id)) { return abort(404); } $userinfo = User::select('id', 'name', 'littlelink_name', 'littlelink_description', 'theme', 'role', 'block')->where('id', $id)->first(); $information = User::select('name', 'littlelink_name', 'littlelink_description', 'theme')->where('id', $id)->get(); if ($userinfo->block == 'yes') { return abort(404); } $links = DB::table('links')->join('buttons', 'buttons.id', '=', 'links.button_id')->select('links.link', 'links.id', 'links.button_id', 'links.title', 'links.custom_css', 'links.custom_icon', 'buttons.name')->where('user_id', $id)->orderBy('up_link', 'asc')->orderBy('order', 'asc')->get(); return view('linkstack.linkstack', ['userinfo' => $userinfo, 'information' => $information, 'links' => $links, 'littlelink_name' => $littlelink_name]); } //Show littlelink page as home page if set in config public function littlelinkhome(request $request) { $littlelink_name = env('HOME_URL'); $id = User::select('id')->where('littlelink_name', $littlelink_name)->value('id'); if (empty($id)) { return abort(404); } $userinfo = User::select('id', 'name', 'littlelink_name', 'littlelink_description', 'theme', 'role', 'block')->where('id', $id)->first(); $information = User::select('name', 'littlelink_name', 'littlelink_description', 'theme')->where('id', $id)->get(); $links = DB::table('links')->join('buttons', 'buttons.id', '=', 'links.button_id')->select('links.link', 'links.id', 'links.button_id', 'links.title', 'links.custom_css', 'links.custom_icon', 'buttons.name')->where('user_id', $id)->orderBy('up_link', 'asc')->orderBy('order', 'asc')->get(); return view('linkstack.linkstack', ['userinfo' => $userinfo, 'information' => $information, 'links' => $links, 'littlelink_name' => $littlelink_name]); } //Redirect to user page public function userRedirect(request $request) { $id = $request->id; $user = User::select('littlelink_name')->where('id', $id)->value('littlelink_name'); if (empty($id)) { return abort(404); } if (empty($user)) { return abort(404); } return redirect(url('@'.$user)); } //Show add/update form public function AddUpdateLink($id = 0) { $linkData = $id ? Link::find($id) : new Link(['typename' => 'link', 'id' => '0']); $data = [ 'LinkTypes' => LinkType::get(), 'LinkData' => $linkData, 'LinkID' => $id, 'linkTypeID' => "1", 'title' => "Predefined Site", ]; if (Route::currentRouteName() != 'showButtons' && $link = DB::table('links')->where('id', $id)->first()) { $bidToLinkTypeId = [ 1 => "2", 2 => "2", 42 => "3", 43 => "4", 93 => "5", 6 => "6", 7 => "6", 44 => "7", 96 => "8", ]; $data['linkTypeID'] = $bidToLinkTypeId[$link->button_id] ?? "1"; $data['title'] = LinkType::where('id', $data['linkTypeID'])->value('title'); } $data['SelectedLinkType'] = $data['LinkTypes']->firstWhere('typename', $linkData['typename']); return view('studio/edit-link', $data); } //Save add link public function saveLink(Request $request) { $request->validate([ 'link' => 'sometimes|exturl', ]); $linkType = LinkType::find($request->linktype_id); $LinkTitle = ($request->link_text ?? $request->link_title) ?? $request->title; $LinkURL = $request->link_url ?? $request->link; $OrigLink = Link::find($request->linkid); $customParams = []; foreach ($request->all() as $key => $param) { if (str_starts_with($key, "_") || in_array($key, ['linktype_id', 'linktype_title', 'link_text', 'link_url'])) continue; $customParams[$key] = $param; } $userId = Auth::user()->id; $button = Button::where('name', $request->button)->first(); if ($button && empty($LinkTitle)) $LinkTitle = $button->alt; if ($linkType->typename == 'video' && empty($LinkTitle)) { $embed = OEmbed::get($LinkURL); if ($embed) $LinkTitle = $embed->data()['title']; } $message = (ucwords($button?->name) ?? ucwords($linkType->typename)) . " has been "; $linkData = [ 'link' => $LinkURL, 'title' => $LinkTitle, 'user_id' => $userId, 'button_id' => $button?->id ]; if ($linkType->typename == "link" && $customParams['GetSiteIcon'] == "1") { $linkData['button_id'] = "2"; } elseif ($linkType->typename == "link") { $linkData['button_id'] = "1"; } elseif ($linkType->typename == "spacer") { $linkData['title'] = $customParams['height'] ?? null; $linkData['button_id'] = "43"; } elseif ($linkType->typename == "heading") { $linkData['button_id'] = "42"; } elseif ($linkType->typename == "text") { $sanitizedText = $request->text; $sanitizedText = strip_tags($sanitizedText, '