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) { if ($id !== 0) { $linkData = Link::find($id); } elseif ($id == 0) { $linkData = new Link(['typename' => 'link', 'id'=>'0']); } else { $linkData = new Link(['typename' => 'link', 'id'=>'0']); } $data['LinkTypes'] = LinkType::get(); $data['LinkData'] = $linkData; $data['LinkID'] = $id; $data['linkTypeID'] = "1"; $data['title'] = "Predefined Site"; if (Route::currentRouteName() != 'showButtons') { $links = DB::table('links')->where('id', $id)->first(); $bid = $links->button_id; if($bid == 1 or $bid == 2){ $data['linkTypeID'] = "2"; } elseif ($bid == 42) { $data['linkTypeID'] = "3"; } elseif ($bid == 43) { $data['linkTypeID'] = "4"; } elseif ($bid == 93) { $data['linkTypeID'] = "5"; } elseif ($bid == 6 or $bid == 7) { $data['linkTypeID'] = "6"; } elseif ($bid == 44) { $data['linkTypeID'] = "7"; } elseif ($bid == 96) { $data['linkTypeID'] = "8"; } else { $data['linkTypeID'] = "1"; } $data['title'] = LinkType::where('id', $data['linkTypeID'])->value('title'); } foreach ($data['LinkTypes']->toArray() as $key => $val) { if ($val['typename'] === $linkData['typename']) { $data['SelectedLinkType'] = $val; break; } } 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) { //echo $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 "; if ($OrigLink) { //EDITING EXISTING $isCustomWebsite = $customParams['GetSiteIcon'] ?? null; $SpacerHeight = $customParams['height'] ?? null; if($linkType->typename == "link" and $isCustomWebsite == "1"){ $OrigLink->update([ 'link' => $LinkURL, 'title' => $LinkTitle, 'button_id' => "2", ]); }elseif($linkType->typename == "link"){ $OrigLink->update([ 'link' => $LinkURL, 'title' => $LinkTitle, 'button_id' => "1", ]); }elseif($linkType->typename == "spacer"){ $OrigLink->update([ 'link' => $LinkURL, 'title' => $customParams['height'] ?? null, 'button_id' => "43", ]); }elseif($linkType->typename == "heading"){ $OrigLink->update([ 'link' => $LinkURL, 'title' => $LinkTitle, 'button_id' => "42", ]); }elseif($linkType->typename == "text"){ $sanitizedText = $request->text; $sanitizedText = strip_tags($sanitizedText, '