Linux ip-172-31-33-47 5.4.0-1045-aws #47~18.04.1-Ubuntu SMP Tue Apr 13 15:58:14 UTC 2021 x86_64
Apache/2.4.29 (Ubuntu)
: 172.31.33.47 | : 18.119.126.168
Cant Read [ /etc/named.conf ]
7.4.20
www-data
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
var /
www /
html /
stage /
app /
Http /
Controllers /
API /
[ HOME SHELL ]
Name
Size
Permission
Action
FoodController.php
6.27
KB
-rw-rw-r--
NewPlaceController.php
9.01
KB
-rw-rw-r--
PlaceController.php
31.89
KB
-rw-rw-r--
ReviewsController.php
5.32
KB
-rw-rw-r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : NewPlaceController.php
<?php namespace App\Http\Controllers\API; use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Auth; use App\Http\Controllers\Controller; use App\Place; use App\Foods; use App\Food; use App\Jobs\ProcessImage; use App\Jobs\ProcessReviewImage; use Illuminate\Support\Facades\Validator; use stdClass; class PlaceController extends Controller { /** * Get Place details * * @param string $slug Place slug **/ public function show(string $slug) { $db = DB::getMongoDB(); // return response()->json(['hey' => $db]); $place = $db->places->aggregate([['$match' => ['slug' => $slug]], ['$project' => [ '_id' => 0, 'name' => 1, 'address' => 1, 'phones' => 1, 'coords' => '$location.coordinates', 'opening' => 1, 'closing' => 1, 'delivery' => 1, 'image' => 1, 'slug' => 1, 'type' => 1, 'avg_rate' => 1, 'category' => 1 ]]] )->toArray()[0]; if($place) { $place['food'] = $db->fooding->aggregate([['$match' => ['place_slug' => $slug]], [ '$project' => [ '_id' => ['$toString' => '$_id'], 'name' => 1, 'description' => 1, 'category' => 1, 'price' => 1, 'avg_rate' => 1 ]] ])->toArray(); }else { abort(404, 'Place not found'); } return response()->json(['food' => true, 'place' => $place]); } public function findPlace(Request $request) { $perPage = 15; $params = $query = $request->query(); $user = $request->user(); // sleep(1); // Extract search params $longitude = $latitude = $rad = $page = $category = $food = $address = $parking = $seating = $delivery = $distance = $t = ""; extract($params); $page = $page ?: 1; $next = $other = false; $db = DB::getMongoDB(); // $tok = $db->search->findOne(['token' => $t]); // if(!$tok) return response()->json(['data' => [], 'next' => $next, 'query' => $food]); // else { // // var_dump($tok);die; // if (new \DateTime($tok['created']) < (new \DateTime('10 minute ago'))) { // $db->search->deleteOne(['token' => $t]); // return response()->json(['data' => [], 'next' => $next, 'query' => $food]); // } // } // Start pipeline build $pipeline = []; $projection = ['$project' => [ '_id' => 0, 'name' => 1, 'phones' => 1, 'address' => 1, 'coords' => '$location.coordinates', 'slug' => 1, 'image' => ['$arrayElemAt' => ['$image', 0]], 'food' => $food ? 1 : [], 'delivery' => 1, 'distance' => 1, 'avg_rate' => 1 ]]; if($user) { $projection['$project']['liked'] = ['$in' => [(string) $user->_id, '$likes']]; }else { $projection['$project']['liked'] = ['$in' => [1, '$likes']]; } if ($food) { $foodParts = explode(" and ", $food); $a = $foodParts[0]; $foodPipeline = [ '$or' => [ ['name' => [ '$regex' => "$a", '$options' => 'i'] ], ['description' => [ '$regex' => "$a", '$options' => 'i'] ] ] ]; $lookupPipeline = ['$lookup' => [ 'from' => 'fooding', 'let' => ['id' => '$slug'], 'pipeline' => [ ['$match' => array_merge(['$expr' => ['$eq' => ['$place_slug', '$$id']]], $foodPipeline)], ['$limit' => 3] ], 'as' => 'food' ]]; } if ($longitude && strtolower(trim($address)) != 'lagos') { $pipeline[] = $this->findByLocation([floatval($longitude), floatval($latitude)], $distance); $pipeline[] = ['$match' => ['enabled' => true]]; }else { $search = 'Popular'; if (intval($page) !== 1) { return response()->json(['data' => [], 'next' => false, 'message' => 'enter location']); } if (!$food) { $places = $db->places->aggregate([ ['$match' => ['popular' => true]], ['$sample' => ['size' => 30]], $projection ])->toArray(); }else { // $pipeline[] = ['$match' => ['popular' => true]]; $pipeline[] = ['$match' => ['enabled' => true]]; $pipeline[] = $lookupPipeline; $pipeline[] = ['$match' => ['food' => ['$ne' => []]]]; $pipeline[] = ['$sample' => ['size' => 30]]; $pipeline[] = $projection; $places = $db->places->aggregate($pipeline)->toArray(); // $next = count($places) >= $perPage; $search = $food; } return response()->json(['data' => $places, 'next' => $next, 'query' => $search, 'location' => 'none']); } // Log query $query['user'] = $request->user(); $query['created'] = (new \DateTime('now'))->format('d-m-Y H:i:s'); $db->logs->insertOne($query); // list($st, $en) = explode(" ", $food); // $lookupPipeline = $food ? ['$or' => [['$text' => ['$search' => "$food"]], ['description' => ['$regex' => "$food", '$options' => 'i']]]] : []; // if(!$food && $category){ // $pipeline[] = ['$match' => ['type' => $category]]; // }elseif($category && $food){ // $pipeline[] = ['$match' => ['type' => $category, 'food' => ['$ne' => []]]]; // }else { // $pipeline[] = ['$match' => ['food' => ['$ne' => []]]]; // } if ($food) { $pipeline[] = $lookupPipeline; $pipeline[] = ['$match' => ['food' => ['$ne' => []]]]; } if($delivery) { $pipeline[] = ['$match' => ['delivery' => ['$exists' => true, '$ne' => []]]]; } if($page){ $skip = (intval($page)-1)*$perPage; $pipeline[] = [ '$skip' => $skip ]; $pipeline[] = [ '$limit' => $perPage ]; } $pipeline[] = $projection; $others = false; $search_result = $db->places->aggregate($pipeline)->toArray(); // var_dump(count($search_result));die; if(count($search_result) >= $perPage) { // if result is more than one page long $next = true; }else { $next = false; if($page == 1 && $longitude && $food && count($search_result) == 0) { // if no results with food specified, search by location only $other = true; $search_result = $db->places->aggregate([ $this->findByLocation([floatval($longitude), floatval($latitude)], $distance), $projection, [ '$limit' => $perPage ] ])->toArray(); } elseif ($page == 1 && $longitude && $food) { // var_dump($search_result);die; // if result count is less than a page long, find other nearby places without specified food $slugs = array_column($search_result, 'slug'); $others = $db->places->aggregate([ $this->findByLocation([floatval($longitude), floatval($latitude)], $distance), [ '$match' => ['slug' => ['$nin' => $slugs ]] ], $projection, [ '$limit' => $perPage ] ])->toArray(); } $db->search->deleteOne(['token' => $t]); } return response()->json(['data' => $search_result, 'next' => $next, 'query' => $food, 'other' => $other, 'others' => $others]); } /** * find places by location only * * @param array $coords coordinates * @return array **/ private function findByLocation(array $coords, $distance) { return ['$geoNear' => [ 'near' => [ 'type' => 'Point', 'coordinates' => $coords, ], 'maxDistance' => intval($distance) ?: 5000, 'spherical' => true, 'distanceField' => 'distance' ]]; } }
Close