Esempio n. 1
0
 public function ajaxSearch(Request $request, $keyword)
 {
     if ($request->ajax() && $request->isMethod('GET') && trim($keyword) !== '') {
         $stores = Store::where('name', 'LIKE', "%{$keyword}%")->take(10)->get(['slug', 'name']);
         $products = Product::where('name', 'LIKE', "%{$keyword}%")->take(10)->get(['id', 'name']);
         $users = User::where('first_name', 'LIKE', "%{$keyword}%")->orWhere('last_name', 'LIKE', "%{$keyword}%")->orWhere('user_name', 'LIKE', "%{$keyword}%")->take(10)->get(['user_name', 'first_name', 'last_name']);
         return pong(1, ['data' => ['stores' => $stores, 'products' => $products, 'users' => $users]]);
     }
 }
Esempio n. 2
0
 /**
  * Change the profile's status: publish or unpublish
  * 
  * @param Request $request
  * 
  * @return AJAX 
  */
 public function publishProfile(Request $request)
 {
     if ($request->ajax() && $request->isMethod('POST')) {
         $userProfile = user()->userProfile;
         $publish_request = $request->get('publish_state') === 'true' ? true : false;
         if (is_null($userProfile)) {
             $userProfile = new UserProfile();
             $userProfile->user_id = user()->id;
         }
         $userProfile->publish = $publish_request;
         $userProfile->save();
         return pong(['publish' => $userProfile->publish]);
     }
 }
 /**
  * @todo Save location by session
  *
  * @param \Illuminate\Http\Request $request
  * @param int                      $id City id
  *
  * @return \Illuminate\Http\JsonResponse
  */
 public function ajaxSelectLocation(Request $request, $id)
 {
     //Only accept ajax request
     if ($request->ajax()) {
         $id = (int) $id;
         if (City::find($id) !== null) {
             //Start session if it wasn't started
             if (!$request->session()->isStarted()) {
                 $request->session()->start();
             }
             $request->session()->put(_const('SESSION_LOCATION'), $id);
             return pong(1, _t('saved_info'));
         }
     }
 }
Esempio n. 4
0
 public function refresh(Request $request)
 {
     if ($request->ajax() && $request->isMethod('POST')) {
         $response = [];
         $productQuantity = (int) $request->get('product_quantity');
         $slug = $request->get('slug');
         $store = store($slug, true);
         if ($store === null) {
             return pong(0, _t('not_found'), 404);
         }
         if ($store->products->count() > $productQuantity) {
             dd($store->ptoducts);
         }
     }
 }
 public function ajaxCommentProduct(Request $request, $product_id)
 {
     // Only accept ajax request with post method
     if ($request->ajax() && $request->isMethod('POST')) {
         $commentText = $request->get('comment_text');
         $product = product($product_id);
         if (is_null($product)) {
             return pong(0, _t('not_found'), 404);
         }
         try {
             $comment = new Comment();
             $comment->product_id = $product_id;
             $comment->user_id = user()->id;
             $comment->text = $commentText;
             $comment->create_time = time();
             if ($comment->save()) {
                 $product->total_comment = $product->total_comment + 1;
                 $product->save();
             }
         } catch (Exception $ex) {
             return pong(0, _t('opp'), 500);
         }
         return pong(1, ['data' => ['id' => $comment->id, 'text' => $commentText, 'user' => ['id' => user()->id, 'username' => user()->user_name], 'product' => ['id' => $product_id, 'count_comment' => $product->total_comment]]]);
     }
 }
Esempio n. 6
0
 public function ajaxCheckStoreSlugUnique(Request $request)
 {
     if ($request->ajax() && $request->isMethod('POST')) {
         $slug = str_slug($request->get('slug'));
         $stores = Store::where('id', '!=', store()->id)->where('slug', $slug)->get();
         return pong(1, ['data' => ['stores' => ['count' => $stores->count(), 'message' => _t('store_slug_unique')]]]);
     }
 }
Esempio n. 7
0
    }
}
/* ======================
Conneciton aufbauen
====================== */
$fp = fsockopen("irc.de.quakenet.org", 6667, $errno, $errstr, 30);
if (!$fp) {
    die("{$errstr} ({$errno})\n\n");
}
tellIRC("USER {$NICK} {$NICK} {$NICK} :{$NICK}");
tellIRC("NICK {$NICK} {$IDENT}");
/* ======================
Auslesen
====================== */
$firstPING = 0;
while (!feof($fp) && !$eof) {
    $msg = str_replace("\n", "", str_replace("\r", "", fgets($fp, 2048)));
    if (strtoupper(substr($msg, 0, 4)) == 'PING') {
        $firstPING++;
        $pID = substr($msg, 6);
        //test
        $mess1 = 'AA';
        pong($pID, $mess1);
    } else {
        if (substr($msg, -8) == 'c4m quit') {
            tellIRC("QUIT :Visit www.meine-homepage.de");
        }
    }
    echo $msg, '<br />';
}
fclose($fp);
 public function ajaxSaveStoreInfo(Request $request)
 {
     //Only accept AJAX request
     if ($request->ajax() && $request->isMethod('POST')) {
         $store = $this->store;
         $user = user();
         if ($user->has_store) {
             $store = store();
         }
         $rules = $store->getRules();
         $messages = $store->getMessages();
         $validator = Validator::make($request->all(), $rules, $messages);
         if ($validator->fails()) {
             return pong(0, $validator->messages(), 403);
         }
         try {
             $store->user_id = $user->id;
             $store->name = $request->get('name');
             $store->category_id = $request->get('category_id');
             $store->street = $request->get('street');
             $store->city_id = $request->get('city_id');
             $store->district_id = $request->get('district_id');
             $store->ward_id = $request->get('ward_id');
             $store->phone_number = $request->get('phone_number');
             if ($store->save()) {
                 $user->has_store = true;
                 $user->update();
                 $productPath = config('front.product_path') . $store->id;
                 $oldmask = umask(0);
                 if (!file_exists($productPath)) {
                     mkdir($productPath, 0777);
                     umask($oldmask);
                 }
             }
         } catch (Exception $ex) {
             $validator->errors()->add('name', _t('opp'));
             return pong(0, $validator->messages(), 500);
         }
         return pong(1, _t('saved_info'));
     }
 }
Esempio n. 9
0
 /**
  * Return a new JSON response from the application.
  *
  * @param  string|array  $data
  * @param  int           $status
  * @param  int           $options
  *
  * @return \Illuminate\Http\JsonResponse
  */
 function file_pong($messages, $status = 'OK', $status_code = 200, array $headers = ['Content-Type' => 'text/html'], $options = 0)
 {
     return pong($messages, $status, $status_code, $headers, $options);
 }