/** * 로그인 컨트롤러. */ public function doLogin($userid) { Input::merge(array('userid' => $userid)); array_map('trim', Input::only('userid', 'userpw')); // 유효성 검사 rule $rules = array('userid' => Member::CONSTRAINT_USERID, 'userpw' => Member::CONSTRAINT_USERPW); $validator = Validator::make(Input::all(), $rules); if ($validator->fails()) { } $member = Member::where(['userid' => Input::get('userid')])->where(['userpw' => Input::get('userpw')])->first(); if (isset($member) && $member->getKey() >= 0) { // 토큰이 있다면 삭제. if ($member->token()) { $member->token()->delete(); } // 새로운 토큰 발급. $memberToken = new Membertoken(); $memberToken->token = Membertoken::getNewToken(); $memberToken->memberSeq = $member->getKey(); $memberToken->expiretime = Membertoken::getNewExpire(); $memberToken->save(); return Utils::result($memberToken->token); } else { return Utils::result(Utils::CANNOT_LOGIN, true); } }
public function testOpenIdUserAssociation() { $username = '******'; $password = '******'; $member = Member::where('Email', '=', $username)->firstOrFail(); $this->assertTrue($member->checkPassword($password)); }
public function postAjaxLogin() { try { if (!isset($_POST)) { throw new Exception('Request error'); } $id = \Input::get('id', false); $passwd = \Input::get('password', false); if (!$id || !$password) { throw new Exception('Parameter error'); } $m = \Member::where('uid', '=', md5($id))->where('social', '=', 'rebeauty')->get(); if ($m == null) { throw new Exception('Not founded'); } if (!\Hash::check($passwd, $m->password)) { throw new Exception('帳號或密碼錯誤'); } // register user into Auth that is a global variable \Auth::login($m); return \Redirect::route('frontend.index'); } catch (Exception $e) { return Response::json(array('status' => 'error', 'message' => $e->getMessage(), '_token' => csrf_token())); } }
public function search() { $keyword = Input::get('keyword'); // REDIRECT BACK TO HOMEPAGE IF EMPTY if (empty($keyword)) { return Redirect::to('/'); } $this->data['members'] = Member::where('last_name', 'LIKE', "%{$keyword}%")->orWhere('first_name', 'LIKE', "%{$keyword}%")->orWhere('number', 'LIKE', "%{$keyword}%")->orderBy('last_name')->get(); return $this->layout->content = View::make('members_search', $this->data); }
static function currentUserProfile() { if (Auth::check()) { $id = Auth::user()->id; $member = Member::where('user_id', '=', $id)->first()->id; $profileUrl = action('ProfileController@getProfile', array('id' => $member)); return $profileUrl; } else { return false; } }
/** * Run the migrations. * * @return void */ public function up() { //get all users $users = User::all(); // and update new field external_identifier with member id foreach ($users as $user) { $email = $user->external_id; $member = Member::where('Email', '=', $email)->first(); if (!is_null($member)) { $user->external_identifier = $member->ID; $user->save(); } } }
public function setUsername($username) { $this->fail = false; $this->member = Member::where('MemberEmail', $username)->get(); $this->petugas = Petugas::where('PetugasUsername', $username)->get(); if ($this->member->count() == 0 && $this->petugas->count() == 0) { $this->fail = true; } else { if ($this->member->count() == 1) { $this->type = "member"; } elseif ($this->petugas->count() == 1) { $this->type = "petugas"; } } }
static function currentUsername() { if (Auth::check()) { $id = Auth::user()->id; if ($member = Member::where('user_id', '=', $id)->first()) { if (!empty($member->name)) { return $member->name; } else { return Auth::user()->username; } } else { return 'Unknown'; } } else { return 'Unknown'; } }
public function getVklogin() { $code = Input::get('code'); //OAuth::setHttpClient('CurlClient'); $vk = OAuth::consumer('Vkontakte', 'http://localhost/study_barter/public/users/vklogin'); //var_dump($code); if (!empty($code)) { $token = $vk->requestAccessToken($code); $result = json_decode($vk->request('users.get?lang=ru&fields=photo_100,photo_200'), true); $result = $result['response'][0]; //echo "<pre>"; //var_dump($result); //echo "</pre>"; //die(); if ($user = User::where('vk_id', '=', $result['uid'])->first()) { //die(var_dump($result)); $member = Member::where('user_id', '=', $user->id)->first(); $member->name = $result['first_name']; $member->surname = $result['last_name']; $member->avatar_url = $result['photo_100']; $member->avatar_url_big = $result['photo_200']; $member->save(); Auth::login($user); return Redirect::to('/'); } else { $user = new User(); $user->vk_id = $result['uid']; $user->is_active = 1; $user->save(); $member = new Member(); $member->user_id = $user->id; $member->name = $result['first_name']; $member->surname = $result['last_name']; $member->avatar_url = $result['photo_100']; $member->avatar_url_big = $result['photo_200']; $member->save(); Auth::login($user); Log::info("User [{$result['first_name']}] successfully logged in."); return Redirect::to('/'); } } else { $url = $vk->getAuthorizationUri(); return Redirect::to((string) $url); } }
/** * Display the specified resource. * * @param int $itemId * @param string $key * @return Response */ public function show($itemId, $key) { // $retVal = array('status' => 'ERR', 'msg' => 'Invalid Session'); try { $user = \Member::where('session_key', '=', $key)->exists(); if (!$user) { return Response::json($retVal); } $comment = \Comments::where('itemid', '=', $itemId)->get(); if ($comment->count() > 0) { $retVal = array('status' => 'OK', 'comments' => $comment->toArray()); } else { $retVal = array('status' => 'ERR', 'msg' => 'beyond your imagination :)'); } return Response::json($retVal); } catch (ModelNotFoundException $e) { } }
public static function DeadLineFinished() { date_default_timezone_set(config::$timezone); $today = date("Y-m-d"); $orders = Order::where('to', '<', $today)->where('status', '=', 1)->orderBy('id', 'desc')->get(); $info = array(); $x = 0; foreach ($orders as $order) { $single = array(); $single['email'] = User::where('details_id', '=', $order->member->id)->where('user_level', '=', 'member')->get()->first()->email; $single['movie name'] = Movie::where("id", '=', $order->movie_id)->get()->first()->name; $single['first name'] = Member::where("id", '=', $order->member_id)->get()->first()->first_name; $single['last name'] = Member::where("id", '=', $order->member_id)->get()->first()->last_name; $info[$x++] = $single; } foreach ($info as $member) { Mail::send('emails.deadlinefinishedorder', array('first_name' => $member['first name'], 'last_name' => $member['last name'], 'movie' => $member['movie name']), function ($message) use($member) { $message->to($member['email'], $member['first name'])->subject('DVD Rental Notification'); }); } return "Email has been successfully sent."; }
public function team($id) { //add security to avoid stealing of information $user = Auth::user(); Excel::create('roster', function ($excel) use($id) { $excel->sheet('Sheetname', function ($sheet) use($id) { $event = Team::find($id); $team = array(); if ($event->children->count() > 0) { foreach ($event->children as $e) { foreach ($e->members as $member) { $team[] = $member; } } } else { $team = Member::where('team_id', '=', $id)->with('team')->get(); } $sheet->setOrientation('landscape'); $sheet->loadView('export.lacrosse.roster', ['members' => $team]); }); })->download('xlsx'); }
/** * Display a listing of the resource. * GET /player * * @return Response */ public function index() { $user = Auth::user(); $title = 'League Together - Club'; $players = $user->players; $invites = []; //get player from follower foreach ($players as $player) { $member = Member::where('player_id', '=', $player->id)->where('accepted_on', '=', null)->where('declined_on', '=', null)->get(); $participant = Participant::where('player_id', '=', $player->id)->where('accepted_on', '=', null)->where('declined_on', '=', null)->get(); if ($member) { foreach ($member as $data) { $invites[] = $data; } } if ($participant) { foreach ($participant as $data) { $invites[] = $data; } } } return View::make('app.account.player.index')->with('page_title', $title)->with('players', $user->players)->with('invites', $invites)->withUser($user); }
public function feedGet($page = 0, $key = null) { $limit = 20; $offset = $page == 1 ? 0 : ($page - 1) * $limit; $retVal = array('status' => 'ERR', 'msg' => 'Invalid Session'); try { $user = \Member::where('sessionKey', '=', $key)->exists(); if (!$user) { return Response::json($retVal); } //$media = \Media::where('status','approved') //->where('createdDate','>', new DateTime() ) $media = \Media::orderBy('createdDate', 'desc')->take($limit)->get(); if ($media->count() > 0 && $user) { //print_r($media); $fmedia = $this->flattenMedia($media); $retVal = $fmedia; } else { $retVal = array('status' => 'ERR', 'msg' => 'beyond your imagination :)'); } return Response::json($retVal); } catch (ModelNotFoundException $e) { } //return Response::json($retVal); }
public static function idMemberTable() { $membership_id = AppHelper::findMemberId(); $id_member_table = Member::where('membership_id', '=', $membership_id)->get(); foreach ($id_member_table as $id) { $id = $id['id']; } $id = Member::find($id); return $id->id; }
foreach ($members as $m) { $m->roleId = Prefs::getRoleId('Merchant'); $m->save(); } }); Route::get('impcat', function () { $slugs = array('Others' => 'others', 'Music Instruments' => 'music-instruments', 'Electronics' => 'electronics', 'Motorcycle Accessories' => 'motorcycle-accessories', 'Homes and Gardens' => 'homes-and-gardens', 'Pet Supplies' => 'pet-supplies', 'Food & Health' => 'food-health', 'Health & Beauty' => 'health-beauty', 'Watch & Jewelry watch-jewelry', 'Collectibles' => 'collectibles', 'Food & Health' => 'food-health', 'Fashion & Accessories' => 'fashion-accessories', 'Books & Magazines' => 'books-magazines', 'Toys & Games' => 'toys-games', 'Infants & Children' => 'infants-children', 'Sporting Goods' => 'sporting-goods'); $csvfile = public_path() . '/storage/import/jex_shops2.csv'; $imp = array(); Excel::load($csvfile, function ($reader) use(&$imp) { $imp = $reader->toArray(); })->get(); print_r($imp); $count = 0; foreach ($imp as $s) { $m = Member::where('id', strval($s['id']))->first(); if ($m) { $count++; $m->shopcategory = $s['shopcategory']; $m->shopcategoryLink = $slugs[trim($s['shopcategory'])]; $m->status = 'active'; $m->save(); print_r($m); } } print $count . "\r\n"; }); Route::get('regeneratepic/{obj?}', function ($obj = null) { set_time_limit(0); if (is_null($obj)) { $product = new Product();
<?php define('_MEXEC', 'OK'); require_once $_SERVER['DOCUMENT_ROOT'] . "/config/app.php"; $info_bag = ['first_name' => isset($_POST['first_name']) ? $_POST['first_name'] : '', 'last_name' => isset($_POST['last_name']) ? $_POST['last_name'] : '', 'email' => isset($_POST['email']) ? $_POST['email'] : '', 'password' => isset($_POST['password']) ? $_POST['password'] : '']; //returns the real ip address of a user (really?) $ip = new IP(); $ip = $ip->realIP(); $member = new Member(); $prevNoob = $member->where('email', '=', $info_bag['email'])->first(); if ($prevNoob) { $prevNoob->first_name = $info_bag['first_name']; $prevNoob->last_name = $info_bag['last_name']; $prevNoob->email = $info_bag['email']; $prevNoob->password = hash('sha512', $info_bag['password']); $prevNoob->ip_address = $ip; $prevNoob->registered_date = date('Y-m-d'); $prevNoob->status = 0; $prevNoob->has_hotels = 1; $prevNoob->save(); $nId = $prevNoob->id; } else { $member->first_name = $info_bag['first_name']; $member->last_name = $info_bag['last_name']; $member->email = $info_bag['email']; $member->password = hash('sha512', $info_bag['password']); $member->ip_address = $ip; $member->registered_date = date('Y-m-d'); $member->status = 0; $member->has_hotels = 1; $member->save();
public function download_tag() { $r1 = Input::has('r1') ? Input::get('r1') : 'Mr Sam Sample'; $r2 = Input::has('r2') ? Input::get('r2') : 'Sample Street'; $r3 = Input::has('r3') ? Input::get('r3') : 'Sampletown VIC 3000'; $r4 = Input::has('r4') ? Input::get('r4') : 'phone +61 414 141 414'; if ($user = Auth::user()) { $member = Member::where('user_id', '=', $user->id)->first(); $r1 = $member->firstname . ' ' . $member->lastname; $r2 = $member->address; $r3 = $member->suburb . ' ' . $member->state . ' ' . $member->postcode; $r4 = 'phone ' . $member->phone; } $pdf = new FPDI('L'); $pdf->setPrintHeader(false); $pdf->setPrintFooter(false); $pdf->AddPage(); $pdf->setSourceFile(realpath(dirname(__FILE__)) . '/../../public/assets/pdf/luggage_tags.pdf'); $pdf->SetTextColor(0, 0, 0); $tplIdx = $pdf->importPage(1); $pdf->useTemplate($tplIdx); $pdf->SetFont('museosansrounded1000'); $pdf->SetXY(121, 40); $pdf->Write(20, $r1); $pdf->SetXY(121, 45); $pdf->Write(20, $r2); $pdf->SetXY(121, 50); $pdf->Write(20, $r3); $pdf->SetXY(121, 55); $pdf->Write(20, $r4); $pdf->Output('luggage-tag.pdf'); }
public function saveCard() { $user = Auth::user(); // If not logged in, return failure if (!isset($user)) { return Response::json(array('success' => false))->setCallback(Input::get('callback')); } $member = Member::where('user_id', '=', $user->id)->first(); $member->member_type = Input::get('member_type'); $member->save(); return Response::json(array('success' => true))->setCallback(Input::get('callback')); }
public function edit() { if (!Auth::user()) { return Redirect::to('/login'); } // Get interest and destination choice data $data = array('interests' => Interests::all()->sortBy('orderIndex'), 'interests_categories' => InterestsCategories::all()->sortBy('orderIndex'), 'destinations' => Destinations::where('publish', '=', 1)->get()->sortBy('orderIndex'), 'member_cards' => Member::getCards(), 'member' => Member::where('user_id', '=', Auth::user()->id)->first(), 'user' => Auth::user()); // populate members destinations into easily emutable array $data['members_destinations'] = array(); $m_dest = MembersDestinations::where('current_id', '=', $data['member']->id)->get(); foreach ($m_dest as $dest) { $data['members_destinations'][] = $dest->destination_id; } // populate members interests into easily emutable array $data['members_interests'] = array(); $m_int = MembersInterests::where('current_id', '=', $data['member']->id)->get(); foreach ($m_int as $int) { $data['members_interests'][] = $int->interest_id; } // Convert object to array so it can be chunked for signup list $tmpdest = array(); foreach ($data['destinations'] as $dest) { $tmpdest[] = $dest; } $data['destinations_chunks'] = array_chunk($tmpdest, ceil(count($data['destinations']) / 3)); // Push view to content $this->layout->content = View::make('pages.edit', $data); }
public function doAnnouncement($id) { global $club, $messageData, $messageSubject, $team, $sms, $user, $recipientMobile, $recipientEmail; $user = Auth::user(); // $club = $user->Clubs()->FirstOrFail(); // $team = Team::where("id", "=",$id)->where("club_id",'=',$club->id)->FirstOrFail(); $team = Team::find($id); $club = $team->club; $members = Member::where('team_id', '=', $team->id)->get(); $messageData = Input::get('message'); $messageSubject = Input::get('subject'); $sms = substr($messageData, 0, 140) . " {$club->name} - Do not reply"; $uuid = Uuid::generate(); //get list of recepients $recipientUser = array(); $recipientPlayer = array(); $recipientContact = array(); $recipientEmail = array(); $recipientMobile = array(); //do selection for children events if ($team->children->count() > 0) { foreach ($team->children as $e) { foreach ($e->members as $member) { //only members that accepted joined if ($member->accepted_user) { $user = User::find($member->accepted_user); $player = Player::find($member->player_id); $recipientUser[] = array('name' => $user->profile->firstname . " " . $user->profile->lastname, 'email' => $user->email, 'mobile' => $user->profile->mobile); foreach ($player->contacts as $contact) { $recipientContact[] = array('name' => $contact->firstname . " " . $contact->lastname, 'email' => $contact->email, 'mobile' => $contact->mobile); } //allow players with email and mobile if ($player->mobile && $player->email) { $recipientPlayer[] = array('name' => $player->firstname . " " . $player->lastname, 'email' => $player->email, 'mobile' => $player->mobile); } } } } } else { foreach ($members as $member) { //only members that accepted joined if ($member->accepted_user) { $user = User::find($member->accepted_user); $player = Player::find($member->player_id); $recipientUser[] = array('name' => $user->profile->firstname . " " . $user->profile->lastname, 'email' => $user->email, 'mobile' => $user->profile->mobile); foreach ($player->contacts as $contact) { $recipientContact[] = array('name' => $contact->firstname . " " . $contact->lastname, 'email' => $contact->email, 'mobile' => $contact->mobile); } //allow players with email and mobile if ($player->mobile && $player->email) { $recipientPlayer[] = array('name' => $player->firstname . " " . $player->lastname, 'email' => $player->email, 'mobile' => $player->mobile); } } } } //send default function function sendmessage($destination) { global $club, $messageData, $messageSubject, $team, $sms, $user, $recipientMobile, $recipientEmail; foreach ($destination as $recipient) { //send email notification of acceptance queue $data = array('club' => $club, 'messageOriginal' => $messageData, 'subject' => $messageSubject, 'team' => $team); Mail::later(3, 'emails.announcement.default', $data, function ($message) use($recipient, $club, $messageSubject) { $message->to($recipient['email'], $recipient['name'])->subject("{$messageSubject} | " . $club->name); }); $recipientEmail[] = array('name' => $recipient['name'], 'email' => $recipient['email']); if (Input::get('sms')) { $recipientMobile[] = array('name' => $recipient['name'], 'mobile' => $recipient['mobile']); //queue sms Queue::push(function ($job) use($recipient, $sms) { Twilio::message($recipient['mobile'], $sms); $job->delete(); }); } } } // send to user sendmessage($recipientUser); //send to player if (Input::get('players')) { sendmessage($recipientPlayer); } //send to contacts if (Input::get('family')) { sendmessage($recipientContact); } //save message to database $announcement = new Announcement(); $announcement->id = $uuid; $announcement->subject = $messageSubject; $announcement->message = $messageData; $announcement->sms = $sms; $announcement->to_email = serialize($recipientEmail); $announcement->to_sms = serialize($recipientMobile); $announcement->team_id = $team->id; $announcement->club_id = $club->id; $announcement->user_id = $user->id; $status = $announcement->save(); return array('success' => true, 'email' => $recipientEmail, 'mobile' => $recipientMobile); }
public function postSynclegacy() { set_time_limit(0); $mymerchant = Merchant::where('group_id', 4)->get(); $count = 0; foreach ($mymerchant->toArray() as $m) { $member = Member::where('legacyId', $m['id'])->first(); if ($member) { } else { $member = new Member(); } foreach ($m as $k => $v) { $member->{$k} = $v; } if (!isset($member->status)) { $member->status = 'inactive'; } if (!isset($member->url)) { $member->url = ''; } $member->legacyId = new MongoInt32($m['id']); $member->roleId = Prefs::getRoleId('Merchant'); $member->unset('id'); $member->save(); $count++; } return Response::json(array('result' => 'OK', 'count' => $count)); }
/** * @brief 라즈베리파이에서 측정된 30초 윈도우 받아서 가공 * @details 30초 윈도우 데이터를 외부 C 프로그램으로 분류하고 결과를 DB에 저장하고 MQTT 전송 * @param bluetoothaddr (String) * @param rawdata (String) * @return Util */ public function userRawDataReceiver() { $validRule = ['bluetoothaddr' => array('required', 'regex:/^[0-9a-zA-Z]{2}:[0-9a-zA-Z]{2}:[0-9a-zA-Z]{2}:[0-9a-zA-Z]{2}:[0-9a-zA-Z]{2}:[0-9a-zA-Z]{2}$/')]; $bluetoothaddr = array_map('trim', Input::only('bluetoothaddr')); $validator = Validator::make($bluetoothaddr, $validRule); $rawdata = Input::get('rawdata'); $noiseFile = Input::file('noisefile'); $noisePeak = Input::get('noisepeak'); if (!isset($noisePeak)) { $noisePeak = NULL; } if ($validator->fails()) { return Utils::result(Utils::CANNOT_PASS_VALIDATOR, true); } // 블루투스로 유저 조회 $member = Member::where('bluetoothaddr', $bluetoothaddr)->first(); if (!isset($member)) { return Utils::result(Utils::CANNOT_FIND_MEMBER); } //--------------------------- // RAW 데이터 처리 //--------------------------- $_startConvertData = microtime(true); $arrayRawData = explode(',', $rawdata); if (count($arrayRawData) == 0) { return Utils::result(Utils::CANNOT_PASS_VALIDATOR, true); } $arrayVoltageData = $this->matlabExec->convertRawData($arrayRawData); // RAW 데이터를 Voltage 데이터로 변환. // voltage 파일 저장 $saveResult = $this->matlabExec->saveRawData($arrayVoltageData); if ($saveResult === FALSE) { return Utils::result(Utils::CANNOT_PASS_VALIDATOR . " FAIL TO SAVE", true); } $_endConvertData = microtime(true); // MATLAB 필터 $_startClassify = microtime(true); // 실행시간 측정 $sleepStep = $this->matlabExec->execNeutralNetFilter(); //--------------------------------------------------------- // noise 파일 업로드 부분 //--------------------------------------------------------- $uploadFileName = NULL; if (isset($noiseFile)) { $extension = $noiseFile->getClientOriginalExtension(); $originalFileName = $noiseFile->getClientOriginalName(); $uploadFileName = sprintf("%s_%d.%s", md5(time()), time(), $extension); // 업로드 시작 $noiseFile->move(public_path() . '/upload/', $uploadFileName); } //--------------------------------------------------------- // AvgSleep & SleepRecord 업데이트 //--------------------------------------------------------- $lastRegIdx = $this->avgSleepRepo->getLastRegIdx($member); $lastRegTime = $this->avgSleepRepo->getLastRegTime($member, $lastRegIdx); // 가장 마지막 시간 가져옴 $currentTime = time(); $currentDate = date('Y-m-d H:i:s', $currentTime); if (abs($currentTime - strtotime($lastRegTime)) > 3600) { /* 현재시간과 마지막 묶음 시간차이가 1시간 이상이면 다른 묶음으로 처리 */ $lastRegIdx += 1; $this->avgSleepRepo->addAvgSleep($member, $lastRegIdx); } $this->sleepRecordRepo->addSleepRecord($member, $lastRegIdx, $sleepStep, $currentDate, $uploadFileName, $noisePeak); // 수면 단계 업데이트 if (in_array($sleepStep, [1, 2, 3, 4])) { $this->avgSleepRepo->increaseTotalRecord($member, $lastRegIdx); if (in_array($sleepStep, [3, 4])) { $this->avgSleepRepo->increaseDeepRecord($member, $lastRegIdx); } } // MQTT 전송부분 $topic = $member->userid . '/sleepStep'; $message = sprintf("%d", $sleepStep); $mqtt = new MQTT("laravel.ssm.n-pure.net", 1883, "NeuroskyMQTTPUSH"); //Change client name to something unique if ($mqtt->connect()) { $mqtt->publish($topic, $message, 0); $mqtt->close(); } $_endClassify = microtime(true); // 측정끝 $output = new stdClass(); $output->sleepStep = (int) $sleepStep; $output->elapsedConvertFile = $_endConvertData - $_startConvertData; $output->elapsedClassification = $_endClassify - $_startClassify; $output->elapsedTime = $output->elapsedConvertFile + $output->elapsedClassification; // RAW 데이터 삭제 $this->matlabExec->removeRawData(); return Utils::result($output); }