예제 #1
0
 public function search(Request $request)
 {
     if (!Auth::check()) {
         // Only for logged-in users.
         return redirect("/home");
     }
     $query = $request->input("q");
     $terms = implode(" ", explode(" ", trim($query)));
     if (isset($query) && strlen($terms) > 1) {
         $terms = explode(" ", $terms);
         $special = array("+", "-", "*", "(", ")", "<", ">");
         foreach ($terms as &$term) {
             $first = substr($term, 0, 1);
             $last = substr($term, -1);
             if (in_array($last, $special)) {
                 $term = substr($term, 0, -1);
             }
             $term = str_replace($special, "", $term);
             if ($first == '"' && $last == '"') {
                 $term = "+" . substr($term, 1, -1);
             } else {
                 $term = $term . "*";
             }
         }
         $terms = implode(" ", $terms);
         $sprites = Sprite::whereRaw("MATCH(title,description,colors) AGAINST(? IN BOOLEAN MODE)", [$terms])->orderBy("created_at", "desc")->get();
         return view("home", ["sprites" => $sprites, "query" => $query]);
     } else {
         return redirect("home");
     }
 }
예제 #2
0
 public function showProfile($userid)
 {
     $user = User::where("alphaid", "=", $userid);
     if (!$user->exists()) {
         abort(404);
     }
     $user = $user->first();
     $favorites = Mark::where("username", "=", $user->alphaid)->orderBy("created_at", "desc")->get();
     $uploads = Sprite::where("username", "=", $user->alphaid)->orderBy("created_at", "desc")->get();
     return view("user/show", ["username" => $user->username, "name" => $user->name, "about" => $user->about, "favorites" => $favorites, "uploads" => $uploads, "creation" => $user->created_at, "modification" => $user->updated_at]);
 }
예제 #3
0
 public function remove($spriteid, Request $request)
 {
     if ($request->input("t") == csrf_token()) {
         $sprite = Sprite::where("alphaid", "=", $spriteid);
         if (!$sprite->exists()) {
             abort(404);
         }
         $sprite = $sprite->first();
         if (!($sprite->username == Auth::user()->alphaid || str_contains(Auth::user()->rights, "delete_anything "))) {
             abort(403);
         }
         unlink(public_path() . "/sprites/full/" . $spriteid . ".png");
         unlink(public_path() . "/sprites/small/" . $spriteid . ".png");
         $favorites = Mark::where("alphaid", "=", $spriteid);
         foreach ($favorites as $favorite) {
             $favorite->delete();
         }
         $sprite->delete();
     } else {
         abort(403);
     }
     return redirect("");
 }
예제 #4
0
	</a>
@endforeach
</div>
<main>
@else
<p class="empty"><em>Nothing here</em></p>
@endif

@if ($username != Auth::user()->username && false)
<h3>Favorites ({{ count($favorites) }})</h3>
@if (count($favorites) > 0)
</main>
<div class="grid">
@foreach ($favorites as $favorite)
	<?php 
$sprite = \App\Sprite::where("alphaid", "=", $favorite->alphaid)->first();
?>
	<a class="item @if ($sprite->width/$sprite->height > 1.5) double @endif" href="{{ url("/sprite/".$sprite->alphaid) }}">
		<img src="{{ url("/sprites/small/".$sprite->alphaid.".png") }}"
		     data-original="{{ url("/sprites/full/".$sprite->alphaid.".png") }}"
		     width="{{ $sprite->width }}" height="{{ $sprite->height }}"
		     class="checker" />
		<div>{{ \App\Sprite::where("alphaid", "=", $sprite->alphaid)->first()->title }}</div><i> </i>
	</a>
@endforeach
</div>
<main>
@else
<p class="empty"><em>Nothing here</em></p>
@endif
@endif