Example #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);
 }
 public function run()
 {
     DB::table('users')->delete();
     users::create(['id' => 1, 'name' => 'Alex', 'email' => '*****@*****.**', 'password' => bcrypt('123456'), 'isStudent' => 0, 'isCompany' => 1]);
     DB::table('resume')->delete();
     App\resume::create(['studentID' => 1, 'about' => 'hi :)', 'evaluation' => 'good at java']);
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     // $this->call(UserTableSeeder::class);
     user::create(['username' => 'puah', 'email' => '*****@*****.**']);
     user::create(['username' => 'yan', 'email' => '*****@*****.**', 'user_role' => 'admin']);
     product::create(['productname' => 'clothyan', 'product_price' => '50.00', 'quantity' => '10', 'product_desc' => 'this is good cloth']);
     product::create(['productname' => 'clothyan2', 'product_price' => '52.00', 'quantity' => '12']);
     Model::reguard();
 }
Example #4
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;
 }
Example #5
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');
     }
 }
 public function modeltest()
 {
     // Funció patranya per veure com buscar un registre, modificar-lo i gravar-lo a la BD
     //$user= new App\User;  // Si volguessim crear un de nou en comptes de modificar ;)
     $user = App\User::find(1);
     // Si no especifiquem res estem buscant per defecte per camp 'id'
     $name = $user->first_name;
     $changedname = $name . 'P';
     $user->first_name = $changedname;
     if ($user->save()) {
         $aNousValors = App\user::all()->toArray();
         return 'User name Marc updated OK!<br><br>' . print_r($aNousValors, 1);
     }
 }
 public function index()
 {
     $oauth = $_POST['inputOAuth'];
     $login = $_POST['inputLogin'];
     $name = $_POST['inputName'];
     $gender = $_POST['optGender'];
     $address = $_POST['inputAddress'];
     $email = $_POST['inputEmail'];
     $user = new App\user();
     $user->name = $name;
     $user->gender = $gender;
     $user->address = $address;
     $user->email = $email;
     $user->oauthID = $oauth;
     $user->loginType = $login;
     $saved = $user->save();
     if ($saved) {
         return view('Registration.registration_done');
     } else {
         // return redirect('/');
         return 'fail';
     }
 }
Example #8
0
 public function regispost(InputUserRequest $request)
 {
     $input = $request->all();
     $password = bcrypt($request->input('password'));
     $input['password'] = $password;
     $register = user::create($input);
     if ($register) {
         Session::flash('message', 'Data Berhasil Masuk');
         Session::flash('alert-class', 'alert-success alert-dismissable');
         return redirect()->route('regis-user');
     } else {
         Session::flash('message', 'Data Gagal Masuk Masuk');
         Session::flash('alert-class', 'alert-danger alert-dismissable');
         return redirect()->route('regis-user');
     }
 }
Example #9
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();
 }
Example #10
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);
 }
 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');
         }
     }
 }
Example #12
0
 public function index()
 {
     $user = Auth::user();
     if (!empty($user)) {
         echo $user->name;
     }
     /**
      * 9/14 現在是透過再次find(`user`)取得user資料,要找其他方式做Join關聯查詢 
      * 9/21 觀看全部文章,僅可編輯自己文章
      */
     $m_article = article::all();
     $articles = array();
     foreach ($m_article as $k => $v) {
         $articles[$k]['id'] = $v->id;
         $articles[$k]['name'] = $v->name;
         $articles[$k]['content'] = $v->content;
         $articles[$k]['updated_at'] = $v->updated_at;
         $articles[$k]['user_id'] = $v->user_id;
         $articles[$k]['user_mail'] = user::find($v->user_id)['account'];
     }
     return view('Mars.article.index')->withArticles($articles)->withTitle(self::$title)->withFun(self::$fun)->withUser($user);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     \App\user::destroy($id);
     session::flash('message', 'Usuario Eliminado Correctamente');
     return Redirect::to('/usuario');
 }
Example #14
0
 public function addPatient(AddPatientByStaffRequest $request)
 {
     $user = new user($request->all());
     $user->userType = 'patient';
     $user->save();
     patient::createNewPatient($user->userId, $request->all());
     return redirect('/');
 }
 public function settings(Request $request)
 {
     if (!Session::has('username')) {
         return redirect('/');
     }
     $opass = "";
     $passmatch = "";
     $passlen = "";
     if ($request['op'] && $request['np'] && $request['cp']) {
         if (strlen($request['np']) >= 6 && strlen($request['cp']) >= 6) {
             if ($request['np'] == $request['cp']) {
                 $password = Session::get('user')->hashed_password;
                 if (Hash::check($request['op'], $password)) {
                     $user = user::whereUsername(Session::get('username'))->first();
                     $user->hashed_password = Hash::make($request['np']);
                     $user->save();
                     $newuser = user::whereUsername(Session::get('username'))->first();
                     Session::put('user', $newuser);
                 } else {
                     $opass = "******";
                 }
             } else {
                 $passmatch = "The passwords donot match";
             }
         } else {
             $passlen = "The length of newpassword should be more than 5";
         }
     }
     $register = "";
     if ($request['registerno']) {
         $count = user::whereUsername($request['registerno'])->count();
         if ($count == 0) {
             $user = user::whereUsername(Session::get('username'))->first();
             $user->username = $request['registerno'];
             $user->save();
             Session::put('username', $request['registerno']);
             $newuser = user::whereUsername(Session::get('username'))->first();
             Session::put('user', $newuser);
         } else {
             $register = "The Username already exists.";
         }
     }
     if ($request['file']) {
         $timestamp = strtotime(Carbon\Carbon::now());
         $user = user::whereUsername(Session::get('username'))->first();
         $id = $user->id;
         $dps = $user->dpstamp;
         $user->dpstamp = $timestamp;
         $user->save();
         $newuser = user::whereUsername(Session::get('username'))->first();
         Session::put('user', $newuser);
         File::delete("../../images/profile/" . $id . "_" . $dps . ".jpg");
         $imgurl = Session::get('user')->id . '_' . $timestamp . '.jpg';
         $request['file']->move("../../images/profile", $imgurl);
     }
     $error = array('register' => $register, 'opass' => $opass, 'passmatch' => $passmatch, 'passlen' => $passlen);
     if ($opass == "" && $register == "" && $passlen == "" && $passmatch == "") {
         return redirect('settings');
     }
     return View::make('settings')->withInput($request)->with('errors', $error);
 }
Example #16
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     session_start();
     $loguser = $_SESSION['user_id'];
     $data = ['modified_by' => $loguser, 'deleted' => '1'];
     App\user::find($id)->update($data);
 }
 /**
  *
  * Get POST Requsets and Handle them
  * 
  * 
  * @return Json Response
  *
  */
 public function inputs()
 {
     $user = Session::get('user');
     if (Request::get('task') == "loadtableopendtickets") {
         $x = Request::get('skip');
         return $this->loadTableOpenedTickets($x);
     } elseif (Request::get('task') == "loadtableAvailabletickets") {
         $x = Request::get('skip');
         return $this->loadTableAvailableTickets($x);
     } elseif (Request::get('task') == "loadtableclosedtickets") {
         $x = Request::get('skip');
         return $this->loadTableClosedTickets($x);
     } elseif (Request::get('task') == "closeTicket") {
         $ids = Request::get('tickets');
         return $this->closeTickets($ids);
     } elseif (Request::get('task') == "openTicket") {
         $ids = Request::get('tickets');
         return $this->openTickets($ids);
     } elseif (Request::get('task') == "viewTicket") {
         $ids = Request::get('ticket');
         if (!is_null($ids)) {
             $ticketOwner;
             $ticket = tickets::find($ids);
             if (is_null($ticket)) {
                 abort(404);
             } else {
                 $ticketOwner = user::find($ticket->userid);
             }
             $ticketsMessages = tickets_messages::where('ticket_id', $ticket->id)->orderBy('id', 'asc')->get();
             return view('admin.reply')->with('user', $user)->with('messages', $ticketsMessages)->with('ticket', $ticket)->with('ticket_owner', $ticketOwner);
         } else {
             abort(404);
         }
     } elseif (Request::get('task') == "replyTickets") {
         $message = Request::get('text');
         $ticketId = Request::get('ticket_id');
         return $this->replyTickets($message, $ticketId);
     }
     return response()->json(['message' => 'Invalid Request', 'code' => 'error']);
     //return 1;
 }
Example #18
0
 public static function getReceiver($message)
 {
     $user = user::Where('id', $message->to_user_id)->first();
     return $user;
 }
 /**
  * BlockControl.
  *
  * Block or unblock the user out off the system.
  * Preventing them to login into the system.
  *
  * @param int $status, The status code. 1 = Block | 0 = Unblock.
  * @param int $id      ,     The id off the user.
  */
 public function blockControl($status, $id)
 {
     if (!Auth::user()->is('admin') || Auth::user()->is('developer') || Auth::user()->is('moderator')) {
         return Redirect::route('trips.index', ['selector' => 'all']);
     }
     $user = user::find($id);
     $user->status = $status;
     $user->save();
     $sessionQuery = Sessions::where('user_id', $id)->get();
     if (count($sessionQuery) == 1 && $status == 1) {
         Sessions::where('user_id', $id)->delete();
     }
     // Set flash message data.
     // Displayed when u block a user
     if ($status == 0) {
         // unblock
         $message = 'U hebt een gebruiker terug geactiveerd';
     } elseif ($status == 1) {
         // block
         $message = 'U hebt een gebruiker geblokkeerd';
     } else {
         // unknown
         $message = 'wij konden niet uitmaken welke handeling u wou uitvoeren.';
     }
     session()->flash('flash_title', 'Success!');
     session()->flash('flash_message', $message);
     session()->flash('flash_message_important', '');
     return Redirect::back();
 }
 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();
     }
 }
 /**
  * Take All JSON Post Requset and process them
  *  Tasks
  *	 1. 
  *
  * @return Response, Views
  **/
 public function inputs()
 {
     if (Request::get('task') == "checkEmail") {
         $email = Request::get('email');
         return $this->checkEmail($email);
     } elseif (Request::get('task') == "checkPhone") {
         $phone = "";
         $phone = Request::get('phone');
         return $this->checkPhone($phone);
     } elseif (Request::get('task') == "submit") {
         /**
          *
          * Handled the main Registraion form submission
          *
          */
         $phone = Request::get('txtPhone');
         $email = Request::get('txtEmail');
         $password = Request::get('txtPassword');
         $nic = Request::get('txtNIC');
         if (is_null($phone) || is_null($email) || is_null($password)) {
             return view('registration')->with('email', $email)->with('phone', $phone)->with('nic', $nic);
         }
         $phoneVerify = json_decode($this->checkPhone($phone)->getContent(), true);
         $emailVerify = json_decode($this->checkEmail($email)->getContent(), true);
         if ($phoneVerify['code'] == "error" || $emailVerify['code'] == "error") {
             return view('registration')->with('email', $email)->with('phone', $phone)->with('nic', $nic);
         }
         $inputs = Input::all();
         $rules = ['g-recaptcha-response' => 'required|captcha'];
         $messages = ['g-recaptcha-response.required' => 'You Must Fill the Captcha', 'g-recaptcha-response.captcha' => 'Captcha Error'];
         $validator = Validator::make($inputs, $rules, $messages);
         if ($validator->fails()) {
             $errors = $validator->messages();
             return view('registration')->with('email', $email)->with('phone', $phone)->with('nic', $nic)->with('captcha', 'Captcha Erro');
         }
         $newUser = new user();
         $newUser->email = $email;
         if (!is_null($nic)) {
             $newUser->nic = $nic;
         }
         $newUser->password = md5($password);
         $phone = "+94" . $phone;
         $newUser->tp = $phone;
         $newUser->level = "1";
         $newUser->active = 1;
         $newUser->verified = 0;
         $newUser->save();
         try {
             Mail::send('mailtemplate/sociallogin', ['name' => $newUser->name, 'pass' => $password], function ($m) use($newUser) {
                 $m->from('*****@*****.**', 'Native Physician');
                 $m->to($newUser->email, $newUser->name)->subject('New Password!');
             });
         } catch (Exception $e) {
             //echo 'Message: ' .$e->getMessage();
         }
         Session::put('loginMsg', 'user_created');
         return Redirect::to('login');
     }
 }
Example #22
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');
     }
 }
Example #23
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'));
 }
 public static function url_hook($uri)
 {
     return substr($uri, 0, 8) == '/backend' && user::current()->is_signed_in() ? 10 : 0;
 }
 /**
  *
  * Change the role of the users
  * @param Stringlist $id user ids
  * @param String $role the role
  * @return Json Response
  *
  */
 private function changeRole($ids, $role)
 {
     $level = 1;
     if ($role == "User") {
         $level = 1;
     } elseif ($role == "Doctor") {
         $level = 2;
     } elseif ($role == "Admin") {
         $level = 10;
     } elseif ($role == "Moderator") {
         $level = 5;
     }
     if (!is_null($ids)) {
         foreach ($ids as &$value) {
             $user = user::find($value);
             $user->level = $level;
             $user->save();
         }
     } else {
         return response()->json(['message' => 'hacker', 'code' => 'error']);
     }
     return response()->json(['code' => 'success', 'task' => 'changeRole']);
 }
 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("/");
     }
 }
Example #27
0
 function myplaceorder(Request $request)
 {
     if ($request['place'] == 1) {
         $order_address = new order_address();
         $order_address->type = "himself";
         $order_address->name = $request['name'];
         $order_address->phone = (string) $request['Contact Number'];
         $order_address->pincode = $request['postalcode'];
         $order_address->address = $request['address'];
         $order_address->message = $request['Personalized'];
         $order_address->order_id = $request['productid'];
         $order_address->save();
         $token = $request['productid'];
         $order_token = new product_token();
         $order_token->u_id = Session::get('uid');
         $order_token->order_id = $token;
         $return_key = md5($token . rand());
         $order_token->order_token = $return_key;
         $order_token->save();
         $api = new Instamojo('b0702bd721ad77f700aa98e4b5a8832a', 'aec9d4a72e40263ea010f35beae47f96');
         try {
             $response = $api->linkCreate(array('title' => 'Gags By Mail', 'description' => 'Create a new Link easily', 'base_price' => Session::get('price', 0), 'currency' => 'INR', 'redirect_url' => 'http://.' . $_SERVER['HTTP_HOST'] . './sucess/' . $return_key));
             $user = user::find(Session::get('uid'));
             //dd($user);
             return redirect($response['url'] . "?data_name=" . $user->name . "&data_email=" . $user->email . "&data_readonly=data_name&data_readonly=data_email");
         } catch (Exception $e) {
             print 'Error: ' . $e->getMessage();
         }
     } elseif ($request['place'] == 2) {
         $victimorder = new order_address();
         $victimorder->type = "victim";
         $victimorder->name = $request['name1'];
         $victimorder->address = $request['address1'];
         $victimorder->city = $request['city1'];
         $victimorder->pincode = $request['pincode1'];
         $victimorder->phone = $request['po1'];
         $victimorder->message = $request['message1'];
         $victimorder->order_id = $request['productid'];
         $victimorder->save();
         $token = $request['productid'];
         $order_token = new product_token();
         $order_token->u_id = Session::get('uid');
         $order_token->order_id = $token;
         $return_key = md5($token . rand());
         $order_token->order_token = $return_key;
         $order_token->save();
         $api = new Instamojo('b0702bd721ad77f700aa98e4b5a8832a', 'aec9d4a72e40263ea010f35beae47f96');
         try {
             $response = $api->linkCreate(array('title' => 'Gags By Mail', 'description' => 'Create a new Link easily', 'base_price' => Session::get('price', 0), 'currency' => 'INR', 'redirect_url' => 'http://' . $_SERVER['HTTP_HOST'] . '/sucess/' . $return_key));
             $user = user::find(Session::get('uid'));
             //dd($user);
             return redirect($response['url'] . "?data_name=" . $user->name . "&data_email=" . $user->email . "&data_readonly=data_name&data_readonly=data_email");
         } catch (Exception $e) {
             print 'Error: ' . $e->getMessage();
         }
     } else {
         echo "f**k u mother f****r";
     }
     /*
     
       $api = new Instamojo('b0702bd721ad77f700aa98e4b5a8832a', 'aec9d4a72e40263ea010f35beae47f96');
             try {
           $response = $api->linkCreate(array(
               'title'=>'Gags By Mail',
               'description'=>'Create a new Link easily',
               'base_price'=>Session::get('price',0),
               'currency'=>'INR',
               'redirect_url'=>'http://localhost:8000/sucess/'.$return_key
               ));
         $user=user::find(Session::get('uid'));
         //dd($user);
     
           return redirect($response['url']."?data_name=".$user->name."&data_email=".$user->email."&data_readonly=data_name&data_readonly=data_email");
       }
       catch (Exception $e) {
           print('Error: ' . $e->getMessage());
       }*/
 }
 public function index()
 {
     $users = user::all();
     $name = "Sumanth";
     return View('card', compact('users'));
 }
Example #29
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);
 }