Exemplo n.º 1
1
 public function index()
 {
     $user_data = $this->getUserInfo();
     $post_data = array();
     $user_model = App\user::where('user_id', $_SESSION['usrID'])->first();
     $post_model = $user_model->posts;
     $count = 0;
     foreach ($post_model as $post) {
         $count++;
         $post_info = array('post_id' => $post->post_id, 'content' => $post->content, 'created_time' => $post->created_time, 'page_id' => $post->page_id, 'page_name' => $post->page->page_name);
         $post_data[] = $post_info;
     }
     $data = $user_data;
     $data['post'] = $post_data;
     $data['total'] = $count;
     return view('history.history', $data);
 }
Exemplo n.º 2
0
 public function viewMyProfilePatient(Request $request)
 {
     $userId = Auth::user()->userId;
     $user = user::where('userId', $userId)->first();
     $address = $user->patient->addressDetail();
     return view('patient.patientProfile')->with('user', $user)->with('address', $address);
 }
Exemplo n.º 3
0
 private function getTotalComment($user_id)
 {
     $user = App\user::where('user_id', $user_id)->first();
     $posts = $user->posts;
     $total_comment = 0;
     foreach ($posts as $post) {
         $total_comment += DB::table('comment')->where('post_id', $post->post_id)->count('comment_id');
     }
     return $total_comment;
 }
Exemplo n.º 4
0
 public function index()
 {
     $user_data = $this->getUserInfo();
     $user_model = App\user::where('user_id', $user_data['user_id'])->first();
     if ($user_model->user_profilePic2 == '') {
         $session = $this->getSession();
         $request = new FacebookRequest($session, 'GET', '/me?fields=picture.height(200)');
         $response = $request->execute();
         $graphObject = $response->getGraphObject();
         $userPicObj = $graphObject->getProperty('picture')->asArray();
         $user_model->user_profilePic2 = $userPicObj['url'];
         $user_model->save();
     }
     $user_data['bigPic'] = $user_model->user_profilePic2;
     return view('profile', $user_data);
 }
Exemplo n.º 5
0
 public static function deleteStaff($staffId)
 {
     $user = user::where('userId', $staffId)->first();
     if ($user->userType == 'doctor') {
         $doctor = doctor::where('userId', $staffId)->first();
         $doctor->delete();
     } else {
         if ($user->userType == 'staff') {
             $staff = staff::where('userId', $staffId)->first();
             $staff->delete();
         }
     }
     $hospitalStaff = hospitalStaff::where('userId', $staffId)->first();
     $hospitalStaff->delete();
     $user->delete();
 }
Exemplo n.º 6
0
 public function login_check(Request $request)
 {
     /**
      * 9/25 取得account = 登入者的資料並且status  = open
      */
     $this->validate($request, ['account' => 'required|max:32', 'password' => 'required']);
     $account = Input::get('account');
     $password = Input::get('password');
     $dir = Crypt::decrypt(Input::get('dir'));
     $status = 'open';
     if (Auth::attempt(['account' => $account, 'password' => $password, 'status' => $status])) {
         $user = Auth::user();
         $m_user = new user();
         $parms = array('lastloginip' => $_SERVER['REMOTE_ADDR']);
         $m_user->where('id', $user->id)->update($parms);
         return Redirect::to($dir);
     } else {
         return Redirect::to('/user/login');
     }
 }
Exemplo n.º 7
0
 public function updateprofile(Request $request)
 {
     $post = $request->all();
     $validator = user::validateUpdateData($post);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator->errors());
     } else {
         $currentpassword = \Auth::user()->password;
         if (\Hash::check($post['password'], $currentpassword)) {
             unset($post['_token'], $post['password']);
             $result = user::where('id', $post['id'])->update($post);
             if ($result > 0) {
                 Session::flash('message', 'profile successfully updated');
             }
             return redirect('/');
         } else {
             return redirect()->back()->withErrors('Wrong Password');
         }
     }
 }
 public function index()
 {
     $user_data = "";
     // if(Session::has('login_type')){
     // 	$_SESSION['login_type'] = Session::get('login_type');
     // }
     if (isset($_SESSION['login_type'])) {
         if ($_SESSION['login_type'] == "facebook") {
             $fb = new Facebook\Facebook(['app_id' => Config::get('facebook.appid'), 'app_secret' => Config::get('facebook.secret'), 'default_graph_version' => 'v2.2']);
             $helper = $fb->getRedirectLoginHelper();
             if (!isset($_SESSION['fb_access_token'])) {
                 try {
                     $accessToken = $helper->getAccessToken();
                 } catch (Facebook\Exceptions\FacebookResponseException $e) {
                     // When Graph returns an error
                     echo 'Graph returned an error: ' . $e->getMessage();
                     exit;
                 } catch (Facebook\Exceptions\FacebookSDKException $e) {
                     // When validation fails or other local issues
                     echo 'Facebook SDK returned an error: ' . $e->getMessage();
                     exit;
                 }
                 if (!isset($accessToken)) {
                     if ($helper->getError()) {
                         header('HTTP/1.0 401 Unauthorized');
                         echo "Error: " . $helper->getError() . "\n";
                         echo "Error Code: " . $helper->getErrorCode() . "\n";
                         echo "Error Reason: " . $helper->getErrorReason() . "\n";
                         echo "Error Description: " . $helper->getErrorDescription() . "\n";
                     } else {
                         header('HTTP/1.0 400 Bad Request');
                         echo 'Bad request';
                     }
                     exit;
                 }
                 $oAuth2Client = $fb->getOAuth2Client();
                 $tokenMetadata = $oAuth2Client->debugToken($accessToken);
                 $tokenMetadata->validateAppId(Config::get('facebook.appid'));
                 $tokenMetadata->validateExpiration();
                 if (!$accessToken->isLongLived()) {
                     // Exchanges a short-lived access token for a long-lived one
                     try {
                         $accessToken = $oAuth2Client->getLongLivedAccessToken($accessToken);
                     } catch (Facebook\Exceptions\FacebookSDKException $e) {
                         echo "<p>Error getting long-lived access token: " . $helper->getMessage() . "</p>\n\n";
                         exit;
                     }
                 }
                 $_SESSION['fb_access_token'] = (string) $accessToken;
             }
             try {
                 // Returns a `Facebook\FacebookResponse` object
                 $response = $fb->get('/me?fields=id,name,last_name', $_SESSION['fb_access_token']);
             } catch (Facebook\Exceptions\FacebookResponseException $e) {
                 echo 'Graph returned an error: ' . $e->getMessage();
                 exit;
             } catch (Facebook\Exceptions\FacebookSDKException $e) {
                 echo 'Facebook SDK returned an error: ' . $e->getMessage();
                 exit;
             }
             $user = $response->getGraphNode();
             $user_data = array('type' => $_SESSION['login_type'], 'Name' => $user->getField('name'), 'ID' => $user->getField('id'));
         } else {
             if ($_SESSION['login_type'] == "google") {
                 $user_data = array('type' => $_SESSION['login_type'], 'Name' => $_SESSION['name'], 'ID' => $_SESSION['id']);
             } else {
                 if (isset($_REQUEST['oauth_verifier'])) {
                     if (!isset($_SESSION['access_token'])) {
                         $request_token = [];
                         $request_token['oauth_token'] = $_SESSION['oauth_token'];
                         $request_token['oauth_token_secret'] = $_SESSION['oauth_token_secret'];
                         $connection = new TwitterOAuth(Config::get('twitter.appid'), Config::get('twitter.secret'), $request_token['oauth_token'], $request_token['oauth_token_secret']);
                         $access_token = $connection->oauth("oauth/access_token", array("oauth_verifier" => $_REQUEST['oauth_verifier']));
                         $_SESSION['access_token'] = $access_token;
                     }
                 }
                 $access_token = $_SESSION['access_token'];
                 $connection = new TwitterOAuth(Config::get('twitter.appid'), Config::get('twitter.secret'), $access_token['oauth_token'], $access_token['oauth_token_secret']);
                 $user = $connection->get("account/verify_credentials");
                 $user_data = array('type' => $_SESSION['login_type'], 'Name' => $user->screen_name, 'ID' => $user->id);
             }
         }
         $user = App\user::where('oauthID', $user_data['ID'])->first();
         if (is_null($user)) {
             return view('Registration.registration', $user_data);
         }
         $_SESSION['user_id'] = $user_data['ID'];
         return view('home', $user_data);
     } else {
         return redirect("/");
     }
 }
Exemplo n.º 9
0
 function registerdb(Request $request)
 {
     $user = new user();
     if ($user->where('email', $request['mail'])->count()) {
         return view('register', ['error' => 1]);
     } else {
         $user->name = $request['name'];
         $user->email = $request['mail'];
         $user->password = md5($request['password']);
         $user->save();
         Session::put('loginfo', 0);
         Session::put('uid', user::where('email', $request['mail'])->first()->id);
         return redirect('/');
     }
 }
Exemplo n.º 10
0
 /**
  *
  * show the available slots for spefic doctor
  * @return view
  */
 public function show($id)
 {
     $doctor = null;
     $userRequested = null;
     $doctor = Doctor::where('id', $id)->first();
     if (!is_null($doctor)) {
         $userRequested = user::where('email', '=', $doctor->email)->first();
         if (!is_null($userRequested)) {
             $timeSlots = Timeslots::where('doctor_id', '=', $doctor->id)->first();
             if (!is_null($timeSlots) && $doctor->available == 1) {
                 //getting the time period
                 $period = explode(".", $timeSlots->period);
                 if (count($period) != 2) {
                     return view('user.appointmetns.place')->with('user', Session::get('user'))->with('userReq', $userRequested)->with('doctor', $doctor);
                 }
                 $periodMinutes = $period[1];
                 $periodHours = $period[0];
                 $periodMinutes = $periodMinutes + $periodHours * 60;
                 // end of the processing the time format initialiation
                 $dt = Carbon::now('Asia/Colombo');
                 $dt->second = 0;
                 //$dt = Carbon::parse('2012-9-6 23:26:11.123789');
                 $dayCount = 0;
                 $dt->addDays(2);
                 $timetable = array();
                 $timevals = array();
                 while ($dayCount < 7) {
                     $day = array();
                     if ($dt->dayOfWeek == 1) {
                         //echo "monday<br>";
                         $day = $this->stringDateToArray($timeSlots->monday);
                     } elseif ($dt->dayOfWeek == 2) {
                         $day = $this->stringDateToArray($timeSlots->tuesday);
                         //echo "tuesday<br>";
                     } elseif ($dt->dayOfWeek == 3) {
                         $day = $this->stringDateToArray($timeSlots->wednesday);
                         //echo "wedensday<br>";
                     } elseif ($dt->dayOfWeek == 4) {
                         $day = $this->stringDateToArray($timeSlots->thursday);
                         //echo "Thursday<br>";
                     } elseif ($dt->dayOfWeek == 5) {
                         $day = $this->stringDateToArray($timeSlots->friday);
                         //echo "Friday<br>";
                     } elseif ($dt->dayOfWeek == 6) {
                         $day = $this->stringDateToArray($timeSlots->saturday);
                         //echo "Saturday<br>";
                     } elseif ($dt->dayOfWeek == 0) {
                         $day = $this->stringDateToArray($timeSlots->sunday);
                         //echo "Sunday<br>";
                     }
                     if (count($day) != 4) {
                         $dt->addDay();
                         $dayCount++;
                         continue;
                     }
                     $cancelTimeDb = cancelSlots::where('did', '=', $doctor->id)->where('slotdate', '=', $dt->toDateString())->first();
                     $tempCancel = $this->stringDateToArray("0.00-0.00");
                     if (!is_null($cancelTimeDb)) {
                         $tempCancel = $this->stringDateToArray($cancelTimeDb->time);
                         if (count($tempCancel) != 4) {
                             $tempCancel = $this->stringDateToArray("0.00-0.00");
                         }
                     }
                     $key = $dt->toDateString();
                     $returnArray = array();
                     $returnArray = $this->timeCal($day, $tempCancel, $periodMinutes, $dt, $doctor->id);
                     //$timetable[$key]=$this->timeCal($day,$tempCancel,$periodMinutes,$dt,$doctor->id);
                     $timetable[$key] = $returnArray['times'];
                     $timevals[$key] = $returnArray['vals'];
                     $dt->addDay();
                     $dayCount++;
                 }
                 Session::put('requestedDoctor', $doctor->id);
                 Session::put('timeval', $timevals);
                 return view('user.appointmetns.place')->with('user', Session::get('user'))->with('userReq', $userRequested)->with('doctor', $doctor)->with('timetable', $timetable)->with('timevals', $timevals);
             } else {
                 return view('user.appointmetns.place')->with('user', Session::get('user'))->with('userReq', $userRequested)->with('doctor', $doctor);
             }
             return view('user.appointmetns.place')->with('user', Session::get('user'))->with('userReq', $userRequested)->with('doctor', $doctor);
         }
     }
     return view('user.appointmetns.place')->with('user', Session::get('user'));
 }
Exemplo n.º 11
0
 public function comment($page_id, $post_id)
 {
     $data = array();
     $user_data = $this->getUserInfo();
     $post_data = array();
     $comment_data = array();
     $sentiment_data = array();
     $num_sent_data = array();
     $user_model = App\user::where('user_id', $user_data['user_id'])->first();
     $page_model = App\page::where('page_id', $page_id)->first();
     if (is_null($page_model)) {
         // if page data is not found in database
         $page_model = new App\page();
         $graphObject = $this->getPage($page_id);
         $pageName = $graphObject->getProperty('name');
         $page_model->page_id = $page_id;
         $page_model->page_name = $pageName;
         $page_model->save();
         $post_model = new App\post();
         $graphObject = $this->getPost($post_id);
         if (null !== $graphObject->getProperty('message')) {
             $postMsg = $graphObject->getProperty('message');
         } else {
             $postMsg = $graphObject->getProperty('story');
         }
         $postTime = $graphObject->getProperty('created_time');
         $post_model->post_id = $post_id;
         $post_model->content = $postMsg;
         $post_model->created_time = $postTime;
         $page_model = App\page::where('page_id', $page_id)->first();
         $page_model->posts()->save($post_model);
         $comment_data = $this->getComment($post_id);
         $sentiment_data = $this->sentiment($comment_data);
         $post_model = App\post::where('post_id', $post_id)->first();
         $count = 0;
         foreach ($comment_data as $comment) {
             $comment_model = new App\comment();
             $comment_model->comment = $comment['comment'];
             $comment_model->commenter = $comment['commenter'];
             $comment_model->commenter_id = $comment['commenter_id'];
             $comment_model->comment_datetime = $comment['comment_datetime'];
             $post_model->comments()->save($comment_model);
             $sentiment_model = new App\commentSentiment();
             $sentiment_model->joy = $sentiment_data[$count]['joy'];
             $sentiment_model->sadness = $sentiment_data[$count]['sadness'];
             $sentiment_model->trust = $sentiment_data[$count]['trust'];
             $sentiment_model->disgust = $sentiment_data[$count]['disgust'];
             $sentiment_model->fear = $sentiment_data[$count]['fear'];
             $sentiment_model->anger = $sentiment_data[$count]['anger'];
             $sentiment_model->surprise = $sentiment_data[$count]['surprise'];
             $sentiment_model->anticipation = $sentiment_data[$count]['anticipation'];
             $sentiment_model->result = $sentiment_data[$count]['result'];
             $comment_model->sentiment()->save($sentiment_model);
             $count++;
         }
     } else {
         //if page data is already been saved in database
         $post_model = $page_model->posts()->where('post_id', $post_id)->first();
         if (is_null($post_model)) {
             $post_model = new App\post();
             $graphObject = $this->getPost($post_id);
             $postMsg = $graphObject->getProperty('message');
             $postTime = $graphObject->getProperty('created_time');
             $post_model->post_id = $post_id;
             $post_model->content = $postMsg;
             $post_model->created_time = $postTime;
             $page_model->posts()->save($post_model);
             $post_model = $page_model->posts()->where('post_id', $post_id)->first();
             $comment_data = $this->getComment($post_id);
             $sentiment_data = $this->sentiment($comment_data);
             $count = 0;
             foreach ($comment_data as $comment) {
                 $comment_model = new App\comment();
                 $comment_model->comment = $comment['comment'];
                 $comment_model->commenter = $comment['commenter'];
                 $comment_model->commenter_id = $comment['commenter_id'];
                 $comment_model->comment_datetime = $comment['comment_datetime'];
                 $post_model->comments()->save($comment_model);
                 $sentiment_model = new App\commentSentiment();
                 $sentiment_model->joy = $sentiment_data[$count]['joy'];
                 $sentiment_model->sadness = $sentiment_data[$count]['sadness'];
                 $sentiment_model->trust = $sentiment_data[$count]['trust'];
                 $sentiment_model->disgust = $sentiment_data[$count]['disgust'];
                 $sentiment_model->fear = $sentiment_data[$count]['fear'];
                 $sentiment_model->anger = $sentiment_data[$count]['anger'];
                 $sentiment_model->surprise = $sentiment_data[$count]['surprise'];
                 $sentiment_model->anticipation = $sentiment_data[$count]['anticipation'];
                 $sentiment_model->result = $sentiment_data[$count]['result'];
                 $comment_model->sentiment()->save($sentiment_model);
                 $count++;
             }
         } else {
             $comment_data = $post_model->comments->toArray();
             foreach ($comment_data as $comment) {
                 $sentiment_data[] = App\comment::where('comment_id', $comment['comment_id'])->first()->sentiment->toArray();
             }
         }
     }
     $post_data['post_id'] = $post_model->post_id;
     $post_data['post_content'] = $post_model->content;
     $post_data['post_time'] = $post_model->created_time;
     $pivot_model = App\post_user::where(['user_id' => $user_data['user_id'], 'post_id' => $post_id])->first();
     if (is_null($pivot_model)) {
         $user_model = App\user::where('user_id', $user_data['user_id'])->first();
         $user_model->posts()->attach($post_id);
     }
     $data = $user_data;
     $data['post'] = $post_data;
     $data['comments'] = $comment_data;
     $data['sentiment'] = $sentiment_data;
     $num_sent_data = $this->count_sentiment($sentiment_data);
     $data['num_sentiment'] = $num_sent_data;
     return view('post.comments', $data);
 }
Exemplo n.º 12
0
 /**
  *
  * Search the users according to the type
  * @param String $searchstring what to search
  * @param Integer $tasktype what type of search
  * @return Json Response
  *
  */
 private function search($searchString, $tasktype)
 {
     $user = null;
     $max = 30;
     if ($tasktype == 1) {
         $user = user::where('active', '1')->where('verified', '=', 1)->where('email', 'LIKE', "%{$searchString}%")->skip(0)->take($max)->get();
         $count = user::where('active', '1')->where('verified', '=', 1)->where('email', 'LIKE', "%{$searchString}%")->count();
         if ($count > $max) {
             $count = $max;
         }
         return response()->json(['users' => $user, 'code' => 'success', 'task' => 'loadtableRegisterd', 'total' => $count, 'skips' => $max]);
     } else {
         if ($tasktype == 2) {
             $user = user::where('active', '0')->where('verified', '=', 1)->where('email', 'LIKE', "%{$searchString}%")->skip(0)->take($this->resultCount)->get();
             $count = user::where('active', '0')->where('verified', '=', 1)->where('email', 'LIKE', "%{$searchString}%")->count();
             if ($count > $max) {
                 $count = $max;
             }
             return response()->json(['users' => $user, 'code' => 'success', 'task' => 'loadtableBlocked', 'total' => $count, 'skips' => $max]);
         } else {
             $user = user::where('verified', '=', 0)->where('email', 'LIKE', "%{$searchString}%")->skip(0)->take($this->resultCount)->get();
             $count = user::where('verified', '=', 0)->where('email', 'LIKE', "%{$searchString}%")->count();
             if ($count > $max) {
                 $count = $max;
             }
             return response()->json(['users' => $user, 'code' => 'success', 'task' => 'loadtablePending', 'total' => $count, 'skips' => $max]);
         }
     }
 }
Exemplo n.º 13
0
 /**
  *
  * Take the response from the Google Auth and process it
  *
  **/
 public function gauth()
 {
     $user = user::where('id', Session::get('userid'))->first();
     if (!is_null($user)) {
         return Redirect::to('home');
     }
     session_start();
     if (isset($_SESSION['OAuth_email'])) {
         /**
          *
          * Checking for the sessions variables that is proceced in the FB and Google authentication php
          * files
          *
          **/
         $userEmail = $_SESSION['OAuth_email'];
         $user = user::where('email', $userEmail)->first();
         if (is_null($user)) {
             $newUser = new user();
             $newUser->email = $userEmail;
             $pass = Str::random(10);
             $newUser->password = md5($pass);
             if (isset($_SESSION['OAuth_name'])) {
                 $newUser->name = $_SESSION['OAuth_name'];
             } else {
                 $newUser->name = "User";
             }
             $newUser->level = "1";
             $newUser->active = 1;
             $newUser->verified = 0;
             if ($newUser->save()) {
                 try {
                     Mail::send('mailtemplate/sociallogin', ['name' => $newUser->name, 'pass' => $pass], function ($m) use($newUser) {
                         $m->from('*****@*****.**', 'Native Physician');
                         $m->to($newUser->email, $newUser->name)->subject('New Password!');
                     });
                 } catch (Exception $e) {
                     //echo 'Message: ' .$e->getMessage();
                 }
                 //return "Check the Email Settings or your internet connection";
             } else {
                 return "Check the Email Settings or your internet connection";
             }
             Session::put('userid', $newUser->id);
             Session::put('user', $newUser);
             return Redirect::to('profile');
         } else {
             if ($user->active == 0) {
                 Session::flush();
                 unset($_SESSION['access_token']);
                 unset($_SESSION['OAuth_email']);
                 unset($_SESSION['OAuth_name']);
                 return Redirect::to('login');
             }
             Session::put('userid', $user->id);
             Session::put('user', $user);
             if ($user->level >= 2) {
                 $doctor = Doctor::where('email', '=', $user->email)->first();
                 if (!is_null($doctor)) {
                     Session::put('doctor', $doctor);
                 }
             }
             if (is_null(Session::get('url'))) {
                 return Redirect::to('home');
             } else {
                 return Redirect::to(Session::get('url'));
             }
         }
     } else {
         Session::flush();
         unset($_SESSION['access_token']);
         unset($_SESSION['OAuth_email']);
         unset($_SESSION['OAuth_name']);
         session_regenerate_id();
         return Redirect::to('login');
     }
 }
Exemplo n.º 14
0
 /**
  *	This function will verify the phone number for the new Registration
  *	@param string $phone phone
  *	@return Json Response
  */
 private function checkPhone($phone)
 {
     if (!is_null($phone)) {
         if ($this->regex($phone, "TP")) {
             $phone = "+94" . $phone;
             $checkUser = user::where('tp', $phone)->count();
             if ($checkUser == 0) {
                 return response()->json(['message' => 'Ok', 'code' => 'success', 'task' => 'checkPhone']);
             } else {
                 return response()->json(['message' => 'Phone Number already Registerd', 'code' => 'error', 'task' => 'checkPhone']);
             }
         }
     }
     return response()->json(['message' => 'Phone Number Verification failed', 'code' => 'error', 'task' => 'checkPhone']);
 }
 public function update_user($par = array())
 {
     $user = $this->getAll();
     if ($par['z'] >= 70) {
         $log = array('username' => $user->username, 'kd_materi' => $par['kd_materi'], 'kd_belajar' => 'N', 'skor' => $par['z'], 'status' => 1);
         user_log::create($log);
         $ambil = user::where('username', $user->username)->first();
         $rek = $ambil->rekomendasi_materi + 1;
         user::where('username', $user->username)->update(['rekomendasi_materi' => $rek]);
         soal_temp::where('username', $user->username)->delete();
     } else {
         user_log::where('username', $user->username)->where('kd_materi', $par['kd_materi'])->delete();
     }
 }