Esempio n. 1
0
 function __construct($lang = null)
 {
     if ($lang) {
         $this->setLang($lang);
     }
     return $this->lang = Session::get('lang', $this->default);
 }
Esempio n. 2
0
File: Admin.php Progetto: vizo/Core
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $locale = config('app.locale');
     $adminLocale = config('typicms.admin_locale');
     $locales = config('translatable.locales');
     // If locale is present in app.locales…
     if (in_array(Input::get('locale'), $locales)) {
         // …store locale in session
         Session::put('locale', Input::get('locale'));
     }
     // Set app.locale
     config(['app.locale' => Session::get('locale', $locale)]);
     // Set Translator locale to typicms.admin_locale config
     Lang::setLocale($adminLocale);
     $localesForJS = [];
     foreach ($locales as $key => $locale) {
         $localesForJS[] = ['short' => $locale, 'long' => trans('global.languages.' . $locale)];
     }
     // Set Locales to JS.
     JavaScript::put(['_token' => csrf_token(), 'encrypted_token' => Crypt::encrypt(csrf_token()), 'adminLocale' => $adminLocale, 'locales' => $localesForJS, 'locale' => config('app.locale')]);
     // set curent user preferences to Config
     if ($request->user()) {
         $prefs = $request->user()->preferences;
         config(['typicms.user' => $prefs]);
     }
     return $next($request);
 }
Esempio n. 3
0
 public function incrementReadCounter($link, $slug)
 {
     if (Session::get('last_read_article') !== $slug) {
         $link->increment('read_counter');
         Session::put('last_read_article', $slug);
     }
 }
Esempio n. 4
0
 public function __construct(array $attributes = [])
 {
     parent::__construct($attributes);
     $this->websiteId = Session::get('website_id');
     $this->defaultWebsiteId = Session::get('default_website_id');
     $this->isDefaultWebsite = Session::get('is_default_website');
 }
Esempio n. 5
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string  $l
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     //Session::flush();
     if (!Session::has('locale')) {
         /**
          * Get the browser local code and lang code.
          */
         $localCode = $request->getPreferredLanguage();
         $localLang = substr($localCode, 0, 2);
         if (in_array($localLang, $this->lang)) {
             Session::set('locale', $localLang);
         } else {
             Session::set('locale', Config::get('app.locale'));
         }
     }
     /**
      * Set the local config.
      */
     App::setLocale(Session::get('locale'));
     Config::set('app.locale', Session::get('locale'));
     /**
      * Share variables in view.
      */
     if (Config::get('app.locale') == 'fr') {
         View::share(['lang' => 'fr', 'langreverse' => 'en']);
     } else {
         View::share(['lang' => 'en', 'langreverse' => 'fr']);
     }
     return $next($request);
 }
Esempio n. 6
0
 public function messages()
 {
     if ($this->hasMessages()) {
         $this->messages = Session::get('messages');
         return View::make(Platform::getPackageName() . '::page/messages')->with('items', $this->messages)->render();
     }
 }
 /**
  * @return mixed
  */
 public function pubpriv()
 {
     /**
      * Verify CSRF token.
      */
     if ($_POST['_token'] !== Session::token()) {
         return Response::json(array('error' => true));
     }
     /**
      * Session validation
      */
     $session = Session::get('uber_profile');
     if (!isset($session) || $session['utid'] !== $_POST['utid']) {
         return Response::json(array('error' => true));
     }
     /**
      * Find Uber row and change public/private status.
      */
     $uber = Uber::where('utid', $_POST['utid'])->first();
     $status = $_POST['status'] == 1 ? false : true;
     $uber->public = $status;
     $uber->save();
     /**
      * Respond with json success data.
      */
     return Response::json(array('success' => true, 'dump' => $uber->public));
 }
 function getAttendance($member = '')
 {
     $input = Input::all();
     if ($member == null or $member == '') {
         $memberId = Session::get('memberId');
     } else {
         $memberId = $member;
     }
     if (array_key_exists('date', $input)) {
         $year = date("Y", strtotime($input['date']));
         $startDate = $year . '-01-01';
         $endDate = $startDate . '12-31';
     } else {
         $year = date("Y");
         $startDate = $year . '-01-01';
         $endDate = $year . '-12-31';
     }
     $month = array_key_exists('month', $input) ? $input['month'] : date('F');
     $month = Month::ForMonth($month)->first();
     if (!empty($month)) {
         $attendance = $month->attendances()->DateBetween($startDate, $endDate)->ForMember($memberId)->get();
         $attendances = $this->AverageMonthAttendance($attendance, $month, $year);
         return $attendances;
     } else {
         return Redirect::to('/auth/dashboard')->withFlashMessage('No Attendnce for the month');
     }
 }
Esempio n. 9
0
 /**
  * Show the form for creating a new resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function create()
 {
     if (Session::has('user_instagram_info')) {
         $userInfo = Session::get('user_instagram_info');
         return view('dashboard.customerRegister', ['userInfo' => $userInfo]);
     }
 }
Esempio n. 10
0
 /**
  * Returns session data
  *
  * @static
  * @param  string  $key
  * @return array
  */
 public static function get($key)
 {
     if (!isset(static::$cache[$key])) {
         static::$cache[$key] = parent::get($key);
     }
     return static::$cache[$key];
 }
Esempio n. 11
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Session::get('Email') != 'astral') {
         return redirect('/adminC');
     }
     return $next($request);
 }
Esempio n. 12
0
 public function isAuthorSession()
 {
     if (Session::get('ROLE.Author')) {
         return true;
     }
     return false;
 }
 public function addMedicalRecordCreate()
 {
     $validator = Validator::make(Input::all(), array('HN' => 'min:8|hn_exist|have_appointment_with_me|already_addmedicalrecord'), array('HN.min' => 'ท่านกรอก HN ของผู้ป่วยไม่ครบ', 'HN.hn_exist' => 'HN ที่ท่านกรอกไม่ตรงกับผู้ป่วยใดของโรงพยาบาล', 'HN.have_appointment_with_me' => 'ผู้ป่วยคนนี้ไม่ได้นัดกับท่านไว้ในช่วงเวลานี้', 'HN.already_addmedicalrecord' => 'ท่านได้ทำการบันทึกการรักษาผู้ป่วยคนนี้ไปแล้ว'));
     if ($validator->passes()) {
         $n = Input::get('ICD10');
         $diseases = DB::table('ICD10_Disease')->get();
         $i = 0;
         foreach ($diseases as $disease) {
             if ($i++ == $n) {
                 $ICD10 = $disease->ICD10;
                 break;
             }
         }
         date_default_timezone_set('Asia/Bangkok');
         $date = date("Y-m-d", time());
         $time = date("H:i:s", time());
         $morning = 1;
         if ((int) date("H", time()) < 12) {
             $morning = 0;
         }
         DB::table('appointments')->where('HN', Input::get('HN'))->where('appointmentDate', $date)->where('morning', $morning)->update(array('addMedicalRecordTime' => $time));
         $addMedicalRecord = new MedicalRecord();
         $addMedicalRecord->HN = Input::get('HN');
         $addMedicalRecord->doctorEmpID = Session::get('username');
         date_default_timezone_set('Asia/Bangkok');
         $addMedicalRecord->date = $date;
         $addMedicalRecord->time = $time;
         $addMedicalRecord->symptom = Input::get('symptom');
         $addMedicalRecord->ICD10 = $ICD10;
         $addMedicalRecord->save();
         return Redirect::to('doctor/addMedicalRecord')->with('flash_notice', 'ดำเนินการบันทึกการรักษาสำเร็จ');
     } else {
         return Redirect::to('doctor/addMedicalRecord')->withErrors($validator)->withInput();
     }
 }
Esempio n. 14
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!Session::get('has_access')) {
         return redirect('/auth');
     }
     return $next($request);
 }
 public function isLoggedIn()
 {
     if (Session::has('token')) {
         $this->client->setAccessToken(Session::get('token'));
     }
     return $this->client->getAccessToken();
 }
Esempio n. 16
0
 /**
  * Create an activity log entry.
  *
  * @param  mixed
  * @return boolean
  */
 public static function log($data = array())
 {
     if (is_object($data)) {
         $data = (array) $data;
     }
     if (is_string($data)) {
         $data = array('action' => $data);
     }
     $user = Auth::user();
     $activity = new static();
     $activity->user_id = isset($user->id) ? $user->id : 0;
     $activity->content_id = isset($data['contentID']) ? $data['contentID'] : 0;
     $activity->content_type = isset($data['contentType']) ? $data['contentType'] : "";
     $activity->action = isset($data['action']) ? $data['action'] : "";
     $activity->description = isset($data['description']) ? $data['description'] : "";
     $activity->details = isset($data['details']) ? $data['details'] : "";
     //set action and allow "updated" boolean to replace activity text "Added" or "Created" with "Updated"
     if (isset($data['updated'])) {
         if ($data['updated']) {
             $activity->description = str_replace('Added', 'Updated', str_replace('Created', 'Updated', $activity->description));
             $activity->action = "Updated";
         } else {
             $activity->action = "Created";
         }
     }
     if (isset($data['deleted']) && $data['deleted']) {
         $activity->action = "Deleted";
     }
     //set developer flag
     $activity->developer = !is_null(Session::get('developer')) ? true : false;
     $activity->ip_address = Request::getClientIp();
     $activity->user_agent = $_SERVER['HTTP_USER_AGENT'];
     $activity->save();
     return true;
 }
Esempio n. 17
0
 public function editarCarrinho($id, $qtd)
 {
     $cart = Session::get('cart');
     $arr = $cart->all();
     $arr[$id]['qtd'] = $qtd;
     return $arr;
 }
Esempio n. 18
0
 public function __construct($method, array $fields = [], array $options = [], $url = null, $assoc = false)
 {
     if ($url) {
         $this->url = $url;
     }
     $this->url .= $method;
     $this->ch = curl_init($this->url);
     if (!$this->ch) {
         throw new Exception('Curl initialisation failed!');
     }
     $this->defaultFields['access_token'] = Session::get('vk_token');
     $options[CURLOPT_POSTFIELDS] = http_build_query(array_replace($this->defaultFields, $fields));
     $this->options = array_replace($this->defaults, $options);
     if (!curl_setopt_array($this->ch, $this->options)) {
         throw new Exception('Curl options setting failed!');
     }
     $this->results = json_decode(curl_exec($this->ch), $assoc);
     if (!$this->results) {
         throw new Exception('Curl exec failed');
     }
     if (isset($this->results->error)) {
         throw new Exception($this->results->error->error_code . ': ' . $this->results->error->error_msg, $this->results->error->error_code);
     }
     curl_close($this->ch);
 }
 public function place(Order $orderModel, OrderItem $orderItem, CheckoutService $checkoutService, Factory $factory)
 {
     if (!Session::has('cart')) {
         return false;
     }
     $cart = Session::get('cart');
     if ($cart->getTotal() > 0) {
         $order = $orderModel->create(['user_id' => Auth::user()->id, 'total' => $cart->getTotal()]);
         // Criação da classe de checkout para integração com o pagseguro
         //$checkout = $checkoutService->createCheckoutBuilder();
         foreach ($cart->all() as $k => $item) {
             $order->items()->create(['product_id' => $k, 'price' => $item['price'], 'qtd' => $item['qtd']]);
             //$checkout->addItem(new Item($k, $item['name'], number_format($item['price'], 2, '.', ''), $item['qtd']));
         }
         $cart->clear();
         event(new CheckoutEvent(Auth::user(), $order));
         // Na verdade esse lugar não é exatamente o melhor lugar para se colocar o redirecionamento para
         // o pagseguro, porém por hora irá servir;
         //$response = $checkoutService->checkout($checkout->getCheckout());
         //return view('store.checkout', compact('order'));
         return view('store.checkout', ['order' => $order, 'cart' => 'vazio']);
         //return redirect($response->getRedirectionUrl());
     }
     return $factory->make('store.checkout', ['cart' => 'empty']);
     //return view('store.checkout', ['cart' => 'empty']);
 }
 public function markAcceptance($policyCode, $userUid)
 {
     // get inputs
     //
     $policy = Policy::where('policy_code', '=', $policyCode)->first();
     $user = User::getIndex($userUid);
     $acceptFlag = Input::has('accept_flag');
     // check inputs
     //
     if (!$user || !$policy || !$acceptFlag) {
         return Response::make('Invalid input.', 404);
     }
     // check privileges
     //
     if (!$user->isAdmin() && $user->user_uid != Session::get('user_uid')) {
         return Response::make('Insufficient privileges to mark policy acceptance.', 401);
     }
     // get or create new user policy
     //
     $userPolicy = UserPolicy::where('user_uid', '=', $userUid)->where('policy_code', '=', $policyCode)->first();
     if (!$userPolicy) {
         $userPolicy = new UserPolicy(array('user_policy_uid' => GUID::create(), 'user_uid' => $userUid, 'policy_code' => $policyCode));
     }
     $userPolicy->accept_flag = $acceptFlag;
     $userPolicy->save();
     return $userPolicy;
 }
Esempio n. 21
0
 public function viewShipping($orderId = 0)
 {
     $data = [];
     $data['user_id'] = Session::get('uid');
     $data['id'] = $orderId;
     $data['delivery'] = 1;
     $order = PhoneOrder::where($data)->first();
     if ($order) {
         $reqData = [];
         $reqData['type'] = $order->expresses->type;
         $reqData['postid'] = $order->shipping_code;
         $expData = PHPCurl::get('http://www.kuaidi100.com/query', $reqData);
         if ($expData) {
             $res = json_decode($expData, true);
             if ($res['status'] == 200) {
                 $renData = [];
                 $renData['expresses'] = $res['data'];
                 return view('home.my.order.viewShipping')->with($renData);
             } else {
                 flash($res['message']);
                 return redirect()->back();
             }
         }
     }
     flash('亲~服务器繁忙请稍后再试');
     return redirect()->back();
 }
Esempio n. 22
0
 public function destroy($id)
 {
     $cartData = Session::get('cart');
     unset($cartData[$id]);
     Session::put('cart', $cartData);
     return redirect()->back();
 }
Esempio n. 23
0
 public function postLogin()
 {
     $username = Input::get('username', null);
     $password = Input::get('password', null);
     if ($username and $password) {
         $userInfo = PhoneUser::where(['username' => $username])->first();
         if ($userInfo->username == $username) {
             if ($userInfo->password == md5($password)) {
                 Session::set('uid', $userInfo->id);
                 Session::set('username', $userInfo->username);
                 if (VerifyUser::shipping(Session::get('uid'))) {
                     return redirect(CallBack::get());
                 } else {
                     return redirect('my/shipping/create');
                 }
             } else {
                 flash('亲,密码错了哦~请重试');
                 return redirect()->back();
             }
         } else {
             flash('亲,账户不存在~请重试');
             return redirect()->back();
         }
     } else {
         flash('亲,用户名或密码不能为空~请重试');
         return redirect()->back();
     }
 }
Esempio n. 24
0
 public function postReceive()
 {
     $code = Input::get('code');
     if ($code) {
         $coupon = AdminCoupon::where(['coupon_code' => $code])->first();
         if ($coupon) {
             $data = [];
             $data['coupon_id'] = $coupon->id;
             $data['user_id'] = Session::get('uid');
             $data['is_used'] = 0;
             $isCoupon = PhoneUserToCoupon::where($data)->first();
             if ($isCoupon) {
                 flash('亲,您已经领取过这个红包啦~');
                 return redirect()->back();
             }
             $couponToUser = new PhoneUserToCoupon();
             $couponToUser->coupon_id = $coupon->id;
             $couponToUser->user_id = Session::get('uid');
             if ($couponToUser->save()) {
                 $coupon->used += 1;
                 $coupon->save();
                 return redirect("coupon/success/{$coupon->coupon_price}");
             } else {
                 flash('亲~现在服务器压力山大~请稍后再试');
                 return redirect()->back();
             }
         } else {
             flash('亲~兑换码不对呦~请重试');
             return redirect()->back();
         }
     } else {
         flash('亲~兑换码不能为空哦~请重试');
         return redirect()->back();
     }
 }
Esempio n. 25
0
 /**
  * @return Cart
  */
 private function getCart()
 {
     if (Session::get('cart')) {
         return Session::get('cart');
     }
     return $this->cart;
 }
Esempio n. 26
0
 /**
  * @return mixed
  */
 public function showNews()
 {
     $slug = Request::segment(2);
     $news_title = "Not active";
     $news_text = "Either this news item is not active, or it does not exist";
     $active = 1;
     $news_id = 0;
     $results = DB::table('news')->where('slug', '=', $slug)->get();
     foreach ($results as $result) {
         $active = $result->active;
         if ($active > 0 || Auth::check() && Auth::user()->hasRole('news')) {
             if (Session::get('lang') == null || Session::get('lang') == "en") {
                 $news_title = $result->title;
                 $news_text = $result->news_text;
                 $news_id = $result->id;
             } else {
                 $news_title = $result->title_fr;
                 $news_text = $result->news_text_fr;
                 $news_id = $result->id;
             }
             $news_image = $result->image;
             $news_date = $result->news_date;
         }
     }
     return View::make('public.news')->with('news_title', $news_title)->with('news_text', $news_text)->with('page_content', $news_text)->with('active', $active)->with('news_id', $news_id)->with('news_date', $news_date)->with('news_image', $news_image)->with('menu', $this->menu)->with('page_category_id', 0)->with('page_title', $news_title);
 }
Esempio n. 27
0
 public function getBasked(Products $products, Slider $slider, Delivery $delivery)
 {
     if (Session::get('product')) {
         $this->data['delivery'] = $delivery->getDeliveryActive();
         $productsBasked = Session::get('product');
         $this->data['countProducts'] = collect($productsBasked);
         $productsId = '';
         $k = 0;
         foreach ($productsBasked as $id) {
             if ($k == 0) {
                 $productsId = $id['id'];
                 $k++;
             } else {
                 $productsId = $productsId . ' ,' . $id['id'];
             }
         }
         $this->data['bascedProducts'] = collect($products->getBascedProducts($productsId));
     } else {
         $this->data['bascedErrr'] = 'Корзина пуста';
     }
     $this->data['slides'] = $slider->getActive();
     $this->data['products'] = $products->getActive();
     if (\Auth::user()) {
         $this->data['name'] = \Auth::user()->name;
         $this->data['address'] = \Auth::user()->address;
         $this->data['email'] = \Auth::user()->email;
         $this->data['number'] = \Auth::user()->number;
     }
     return view('pages.cart', $this->data);
 }
Esempio n. 28
0
 /**
  * @param Request $request
  * @param Closure $next
  */
 public function handle($request, Closure $next)
 {
     Lang::setFallback(self::getDefault());
     $setLocale = Session::get('setLocale');
     //flash data
     if (Config::get('app.locale_use_cookie')) {
         if ($setLocale) {
             Session::set('locale', $setLocale);
         }
         if (Session::has('locale')) {
             App::setLocale(Session::get('locale'));
         } else {
             self::autoDetect();
         }
     } else {
         if (Config::get('app.locale_use_url')) {
             if ($setLocale) {
                 self::setLocaleURLSegment($setLocale);
             } else {
                 $lang = self::getLocaleFromURL();
                 if ($lang) {
                     App::setLocale($lang);
                 } else {
                     if ($request->segment(1) != 'locale') {
                         //ignore set-locale URL
                         self::autoDetect();
                         self::setLocaleURLSegment(self::get());
                     }
                 }
             }
         }
     }
     View::share('lang', self::get());
 }
Esempio n. 29
0
 public function index()
 {
     if (!Session::has('cart')) {
         Session::set('cart', $this->cart);
     }
     return view('store.cart', ['cart' => Session::get('cart')]);
 }
Esempio n. 30
-1
 public function postSendsms(Request $request)
 {
     $mobile = Input::get('mobile');
     if (!preg_match("/1[3458]{1}\\d{9}\$/", $mobile)) {
         // if(!preg_match("/^13\d{9}$|^14\d{9}$|^15\d{9}$|^17\d{9}$|^18\d{9}$/",$mobile)){
         //手机号码格式不对
         return parent::returnJson(1, "手机号码格式不对" . $mobile);
     }
     $data = DB::select("select * from members where lifestatus=1 and mobile =" . $mobile);
     if (sizeof($data) > 0) {
         return parent::returnJson(1, "手机号已注册");
     }
     $checkCode = parent::get_code(6, 1);
     Session::put("m" . $mobile, $checkCode);
     $checkCode = Session::get("m" . $mobile);
     Log::error("sendsms:session:" . $checkCode);
     $msg = "尊敬的用户:" . $checkCode . "是您本次的短信验证码,5分钟内有效.";
     // Input::get('msg');
     $curl = new cURL();
     $serverUrl = "http://cf.lmobile.cn/submitdata/Service.asmx/g_Submit";
     $response = $curl->get($serverUrl . "?sname=dlrmcf58&spwd=ZRB2aP8K&scorpid=&sprdid=1012818&sdst=" . $mobile . "&smsg=" . rawurlencode($msg . "【投贷宝】"));
     $xml = simplexml_load_string($response);
     echo json_encode($xml);
     //$xml->State;
     //  <CSubmitState xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/">
     //   <State>0</State>
     //   <MsgID>1512191953407413801</MsgID>
     //   <MsgState>提交成功</MsgState>
     //   <Reserve>0</Reserve>
     // </CSubmitState>
     // <State>1023</State>
     //  <MsgID>0</MsgID>
     //  <MsgState>无效计费条数,号码不规则,过滤[1:186019249011,]</MsgState>
     //  <Reserve>0</Reserve>
 }