public function setOnlineStatus() { $status = \Input::get('status'); if (\Auth::check()) { \Auth::user()->updateStatus($status, true); } }
public function add() { if (!\Config::get('game-create-allowed')) { return \Redirect::to(\URL::previous()); } $message = null; if ($val = \Input::get('val')) { $validator = \Validator::make($val, ['title' => 'required|predefined|validalpha|min:3']); if (!$validator->fails()) { $game = $this->gameRepository->add($val); if ($game) { //send to game list if (\Config::get('game-create-allowed') and !\Auth::user()->isAdmin()) { $message = "<strong>Thanks for adding game:</strong> One of our administrator will now inspect your game and confirm very soon"; } else { return \Redirect::to($game->present()->url()); } } else { $message = trans('game.error'); } } else { $message = $validator->messages()->first(); } } return $this->preRender($this->theme->section('game.add', ['message' => $message, 'categories' => $this->categoryRepository->listAll()]), $this->setTitle(trans('game.add-games'))); }
public function index() { $message = null; if ($val = \Input::get('val')) { $this->inviteRepository->inviteMember($val); $message = trans('invite.success'); } return $this->render('invite.send', ['user' => \Auth::user(), 'message' => $message], ['title' => $this->setTitle(trans('invite.invite-friends'))]); }
public function remove($userid, $touserid, $way) { if ($userid != \Auth::user()->id and $touserid != \Auth::user()->id) { return 0; } if ($this->connectionRepository->remove($userid, $touserid, $way)) { return 1; } return 0; }
public function index() { if (!$this->exists()) { return $this->profileNotFound(); } if (\Auth::check() and $this->blockUserRepository->hasBlock(\Auth::user()->id, $this->profileUser->id)) { return \Redirect::route('user-home'); } echo $this->render('profile.index', [], ['title' => $this->setTitle()]); }
public function handleProviderCallback($provider) { try { $user = Socialite::driver($provider)->user(); } catch (\Exception $e) { return redirect('/faurgs/auth/' . $provider); } $authUser = $this->findOrCreateUser($user); \Auth::login($authUser, true); return redirect('/faurgs/unidades'); }
public function process() { usleep(2000000); $results = ['status' => 'login']; if (!\Auth::check()) { return json_encode($results); } $this->realTimeRepository->setType('update'); $results['status'] = true; $results['lastaccess'] = $this->realTimeRepository->getLastAccess(\Auth::user()->id); $messageUserId = \Input::get('messageuserid'); $postType = \Input::get('postType'); $currentTime = date('Y-m-d H:i:s', time()); $lastaccess = \Input::get('lastaccess'); $continue = true; $results['lastaccess'] = $this->realTimeRepository->getLastAccess(\Auth::user()->id); if ($this->realTimeRepository->has(\Auth::user()->id, 'notification', $lastaccess)) { $results['notifications'] = $this->notificationRepository->count(); $this->realTimeRepository->remove(\Auth::user()->id, 'notification'); $continue = false; } if ($this->realTimeRepository->has(\Auth::user()->id, 'friend-request', $lastaccess)) { $results['requests'] = $this->connectionRepository->countFriendRequest(); $this->realTimeRepository->remove(\Auth::user()->id, 'friend-request'); $continue = false; } if ($this->realTimeRepository->has(\Auth::user()->id, 'message', $lastaccess)) { if ($messageUserId) { $lastime = \Input::get('messagelastcheck'); if ($lastime) { $messages = $this->messageRepository->getList($messageUserId, 10, 0, $lastime); $results['messages'] = (string) $this->theme->section('messages.paginate', ['messages' => $messages]); } } $this->realTimeRepository->remove(\Auth::user()->id, 'message'); $continue = false; } clearstatcache(storage_path('realtime/')); $results['messagelastcheck'] = $currentTime; $results['postlastcheck'] = $currentTime; $results['onlines'] = $this->userRepository->countFriendsOnline(); $results['unreadmessage'] = $this->messageRepository->countNew(); if ($postType) { $lastime = \Input::get('postlastcheck'); if ($lastime) { $results['posts'] = (string) $this->theme->section('post.paginate', ['posts' => $this->postRepository->lists($postType, 0, \Input::get('postUserid'), $lastime)]); } } return json_encode($results); }
/** * Dashboard index page */ public static function index($finish = false) { if ($finish) { \Auth::showWizard('finish'); } else { if (\Auth::showWizard()) { \Router::redirect('accounts/permissions'); } } $templateData = array('template' => 'dashboard/content', 'title' => 'Migrate - Dashboard', 'bodyId' => 'dashboard', 'styles' => array('dashboard.css'), 'scripts' => array(), 'queue' => TasksModel::listingFor(array('user_id' => $_SESSION['current']['username']['id'], 'user_affected_id' => $_SESSION['current']['username']['id']), 4), 'services' => ServicesModel::forUser(array('id' => $_SESSION['current']['username']['id'], 'limit' => 4)), 'usernames' => $_SESSION['usernames'], 'intro' => (bool) IntroModel::first(array('page' => 'dashboard', 'group' => $_SESSION['current']['username']['group']))); if (!$templateData['intro']) { IntroModel::create(array('page' => 'dashboard', 'group' => $_SESSION['current']['username']['group']))->save(); } \Render::layout('template', $templateData); }
public function retrievePassword() { $hash = \Input::get('hash'); if (empty($hash)) { return \Redirect::to('/'); } if ($user = $this->user->findByHash(['code' => $hash], false)) { $message = null; if ($val = \Input::get('val')) { $validator = \Validator::make($val, ['password' => 'required|confirmed']); if ($validator->fails()) { $message = $validator->messages()->first(); } else { $this->user->changePassword($val, $user); \Auth::login($user); return \Redirect::route('user-home'); } } return $this->theme->view('user.login.change-password', ['user' => $user, 'message' => $message])->render(); } }
public function cropCover() { $top = \Input::get('top'); $image = $this->photo->cropImage(base_path(\Auth::getUser()->original_cover), 'cover/', 0, abs($top), 1000, 300, false); $image = str_replace('%d', 'original', $image->result()); if (!empty($image)) { /** * Update user profile cover */ $user = \Auth::user(); if ($user->cover and $user->cover != $user->original_cover) { \Image::delete($user->cover); } $this->userRepository->updateCover($image); return json_encode(['status' => 'success', 'url' => \Image::url($image)]); } else { return json_encode(['status' => 'error', 'message' => 'Error things']); } }
/** * Unlink account * * @param int $key Account session key */ public static function unlink($key = 0) { // Revoke Token \Rest::get('https://accounts.google.com/o/oauth2/revoke', array('token' => $_SESSION['usernames'][$key]['credentials']['access_token'])); // Remove Data UsersModel::remove($_SESSION['usernames'][$key]['username']['id']); if (isset($_SESSION['usernames'][$key])) { $toRemove = $_SESSION['usernames'][$key]; unset($_SESSION['usernames'][$key]); if (isset($_SESSION['wizard']['source']) && $_SESSION['wizard']['source']['username']['id'] == $toRemove['username']['id']) { $_SESSION['wizard']['source'] = \Auth::userBeside($_SESSION['wizard']['destination']); } if (isset($_SESSION['wizard']['destination']) && $_SESSION['wizard']['destination']['username']['id'] == $toRemove['username']['id']) { $_SESSION['wizard']['destination'] = \Auth::userBeside($_SESSION['sync']['source']); } if ($_SESSION['current']['username']['id'] == $key && count($_SESSION['usernames'])) { end($_SESSION['usernames']); $_SESSION['current'] = current($_SESSION['usernames']); } } if (!count($_SESSION['usernames'])) { \Auth::logout(); } \Util::notice(array('type' => 'success', 'text' => 'The account has been successfully removed and its API tokens revoked.')); \Router::redirect('accounts'); }
/** * Listing accounts */ public static function index($selectedService = 0) { \Auth::showWizard('finish'); $templateData = array('template' => 'backup/content', 'title' => 'Migrate - Backup', 'bodyId' => 'backup', 'styles' => array('backup.css'), 'scripts' => array('common/wizard.js', 'backup.js'), 'services' => $_SESSION['current']['services']); \Render::layout('template', $templateData); }
public function mention() { return $this->render('discover.mention', ['posts' => $this->postRepository->search(\Auth::user()->present()->atName()), 'username' => \Auth::user()->present()->atName()], ['title' => $this->setTitle(trans('discover.@mention'))]); }
/** * @return \Illuminate\Http\RedirectResponse */ public function getLogout() { \Auth::logout(); return \Redirect::action('home.index'); }
public static function add($taskId = 0, $revert = false) { $taskId = (int) $taskId; if ($taskId) { $start = microtime(true); $task = TasksModel::details($taskId); // Settings $settings = array('initialStatus' => TasksModel::STATUS_SCHEDULED, 'startStatus' => TasksModel::STATUS_PROGRESS, 'finishStatus' => TasksModel::STATUS_FINISHED, 'source' => true, 'sourceBackup' => true, 'destination' => true, 'destinationBackup' => true, 'action' => true, 'actionType' => TasksModel::TYPE_BACKUP); if ($task && $task['services']) { switch ($task['type']) { case TasksModel::TYPE_BACKUP: $settings['destination'] = false; $settings['action'] = false; break; case TasksModel::TYPE_MIGRATE: case TasksModel::TYPE_SYNC: case TasksModel::TYPE_MOVE: $settings['actionType'] = $task['type']; if ($revert) { $settings['initialStatus'] = TasksModel::STATUS_FINISHED; $settings['startStatus'] = TasksModel::STATUS_REVERTING; $settings['finishStatus'] = TasksModel::STATUS_REVERTED; $settings['sourceBackup'] = false; $settings['destinationBackup'] = false; $settings['actionType'] = TasksModel::TYPE_REVERT; } break; case TasksModel::TYPE_SHARE: $settings['destination'] = false; $settings['action'] = false; break; case TasksModel::TYPE_CLEAN: $settings['destination'] = false; $settings['actionType'] = TasksModel::TYPE_CLEAN; if ($revert) { $settings['initialStatus'] = TasksModel::STATUS_FINISHED; $settings['startStatus'] = TasksModel::STATUS_REVERTING; $settings['finishStatus'] = TasksModel::STATUS_REVERTED; $settings['sourceBackup'] = false; $settings['destinationBackup'] = false; $settings['actionType'] = TasksModel::TYPE_REVERT; } break; } if ($task['status'] == $settings['initialStatus']) { // Start the task $dbTask = TasksModel::first($taskId); $dbTask->started_at = date(DATE_TIME); $dbTask->status = $settings['startStatus']; $dbTask->save(); $source = array(); if ($settings['source']) { $source = UsersModel::profile($task['user_id']); $source['credentials'] = \Auth::oAuthRefreshToken($source, 'updateSession', 'force'); } $destination = array(); if ($settings['destination']) { $destination = UsersModel::profile($task['user_affected_id']); $destination['credentials'] = \Auth::oAuthRefreshToken($destination, 'updateSession', 'force'); } // Call services foreach ($task['services'] as $service) { $stats = array(); // Save source data if ($settings['source'] && $settings['sourceBackup']) { $stats = call_user_func_array(array('app\\libraries\\' . $service['library'], 'backup'), array($source, 0, $taskId)); } // Save destination data if ($settings['destination'] && $settings['destinationBackup']) { $stats = call_user_func_array(array('app\\libraries\\' . $service['library'], 'backup'), array($destination, 0, $taskId)); } // Copy source to destination if ($settings['action'] && $settings['actionType']) { $stats = call_user_func_array(array('app\\libraries\\' . $service['library'], $settings['actionType']), array($source, $destination, $taskId, false)); } // Update task service $taskService = TasksServicesModel::first(array('task_id' => $task['id'], 'service_id' => $service['id'])); if ($settings['actionType'] != TasksModel::TYPE_REVERT) { $taskService->stats = json_encode($stats); $taskService->save(); } } // Finish Task $dbTask->finished_at = date(DATE_TIME, time()); $dbTask->duration = microtime(true) - $start; $dbTask->status = $settings['finishStatus']; $dbTask->save(); } } } }
public function onAuthSuccess($client) { $attributes = $client->getUserAttributes(); /** @var Auth $auth */ $auth = Auth::find()->where(['source' => $client->getId(), 'source_id' => $attributes['id']])->one(); if (Yii::$app->user->isGuest) { if ($auth) { // login $user = $auth->user; Yii::$app->user->login($user); } else { // signup if (isset($attributes['email']) && isset($attributes['username']) && User::find()->where(['email' => $attributes['email']])->exists()) { Yii::$app->getSession()->setFlash('error', [Yii::t('app', "User with the same email as in {client} account already exists but isn't linked to it. Login using email first to link it.", ['client' => $client->getTitle()])]); } else { $password = Yii::$app->security->generateRandomString(6); $user = new User(['username' => $attributes['login'], 'email' => $attributes['email'], 'password' => $password]); $user->generateAuthKey(); $user->generatePasswordResetToken(); $transaction = $user->getDb()->beginTransaction(); /* if ($user->save()) { $auth = new Auth([ 'user_id' => $user->id, 'source' => $client->getId(), 'source_id' => (string)$attributes['id'], ]); if ($auth->save()) { $transaction->commit(); Yii::$app->user->login($user); } else { print_r($auth->getErrors()); } } else { print_r($user->getErrors()); } */ } } } else { // user already logged in if (!$auth) { // add auth provider $auth = new Auth(['user_id' => Yii::$app->user->id, 'source' => $client->getId(), 'source_id' => $attributes['id']]); $auth->save(); } } }
public function complete($username) { $user = $this->userRepository->findByUsername($username); if (!$user) { return \Redirect::to('/'); } $username = false; $email = false; $message = false; if ($this->socialauthRepository->userIsOk($user)) { return \Redirect::to('/'); } if ($val = \Input::get('val')) { $completed = $this->socialauthRepository->complete($val, $user); if ($completed) { \Auth::login($user); return \Redirect::route('user-home'); } else { $message = "Failed again, please try with different values"; } } if (preg_match('#existed-#', $user->username)) { $username = str_replace('existed-', '', $user->username); } if (preg_match('#existed-#', $user->email_address) or empty($user->email_address)) { $email = str_replace('existed-', '', $user->email_address); $user->email_address = $email; } return $this->theme->view('socialauth.complete', ['user' => $user, 'username' => $username, 'email' => $email, 'message' => $message])->render(); }
public function delete() { $userid = \Input::get('userid'); $userid = empty($userid) ? \Auth::user()->id : $userid; $delete = $this->userRepository->delete($userid); return \Redirect::to(\URL::previous()); }
public function index() { $data = Xcrud::get_instance()->table('inti_online_meeting_rooms')->columns('room_name,description,created_at')->fields('room_name,description')->label('room_name', 'Judul Rapat')->label('description', 'Deskripsi')->label('created_at', 'Tanggal Dibuat')->column_pattern('room_name', '<a href="https://rtc.intifadah.net/{slug}" class="xcrud-action" ><b color="red">{room_name}</a></b>')->pass_var('creator', \Auth::user()->id)->pass_var('created_at', date('Y-m-d H:i:s'))->before_insert('save_online_meeting', app_path() . '/config/function.php')->where("creator = '" . \Auth::user()->id . "'")->unset_title()->unset_limitlist()->unset_view()->unset_csv()->limit(10); return $this->render('webrtc.meeting.manage', ['data' => $data], ['title' => $this->setTitle(trans('global.about'))]); }
public static function data() { $service = ServicesModel::first($_SESSION['clean']['service'])->toArray(); if (!isset($_SESSION['clean']['data']) || empty($_SESSION['clean']['data'])) { \Auth::oAuthRefreshToken($_SESSION['current'], 'updateSession', 'force'); $_SESSION['clean']['data'] = call_user_func_array(array('app\\libraries\\' . $service['library'], 'share'), array($_SESSION['current'])); } $data = $_SESSION['clean']['data']; echo \Render::view('clean/data', array('data' => $data, 'selectedData' => $_SESSION['clean']['selectedData']), 'return'); }
public function point($slug) { if (!$this->exists()) { return $this->notFound(); } $community = $this->communityRepostory->get($slug); if ($this->community->present()->isAdmin()) { $data = Xcrud::get_instance()->table('inti_community_points')->columns('workprogram_id,member_id,point,date,description')->fields('workprogram_id,member_id,point,date,description')->relation('member_id', 'inti_view_community_members', 'user_id', 'fullname', 'community_id = ' . $community->id, 'fullname', true)->relation('workprogram_id', 'inti_community_workprogram', 'id', 'program_name', 'community_id = ' . $community->id)->column_name('workprogram_id', 'Nama Program')->column_name('member_id', 'Anggota')->column_name('date', 'Tanggal')->column_name('description', 'Keterangan')->label('workprogram_id', 'Nama Program')->label('member_id', 'Anggota')->label('date', 'Tanggal')->label('description', 'Keterangan')->pass_var('community_id', $community->id)->where("inti_community_points.community_id = '" . $community->id . "'")->unset_title()->unset_limitlist()->unset_view()->sum('point')->unset_csv()->limit(10); } else { $data = Xcrud::get_instance()->table('inti_community_points')->columns('workprogram_id,member_id,point,date,description')->fields('workprogram_id,member_id,point,date,description')->relation('member_id', 'inti_view_community_members', 'user_id', 'fullname', 'community_id = ' . $community->id, 'fullname', true)->relation('workprogram_id', 'inti_community_workprogram', 'id', 'program_name', 'community_id = ' . $community->id)->column_name('workprogram_id', 'Nama Program')->column_name('member_id', 'Anggota')->column_name('date', 'Tanggal')->column_name('description', 'Keterangan')->label('workprogram_id', 'Nama Program')->label('member_id', 'Anggota')->label('date', 'Tanggal')->label('description', 'Keterangan')->pass_var('community_id', $community->id)->where("inti_community_points.community_id = '" . $community->id . "'")->where("inti_community_points.member_id like '%" . \Auth::user()->id . "%'")->unset_title()->unset_limitlist()->unset_view()->sum('point')->unset_edit()->unset_remove()->unset_add()->unset_csv()->limit(10); } return $this->render('community.page.manage', ['data' => $data, 'header' => 'Daftar Poin Anggota (SSKM)'], ['title' => $this->setTitle(trans('global.about'))]); }
public static function _setUsers($source = -1, $destination = -1) { // First access if (!isset($_SESSION['wizard']['source']) || is_null($_SESSION['wizard']['source']) || !$_SESSION['wizard']['source'] || !isset($_SESSION['wizard']['destination']) || is_null($_SESSION['wizard']['destination']) || !$_SESSION['wizard']['destination']) { $_SESSION['wizard']['source'] = $_SESSION['current']; $_SESSION['wizard']['destination'] = \Auth::userBeside($_SESSION['current']['username']['id']); } // Selected source and destination if ($source !== -1 && $destination !== -1) { if ($source == $destination) { if ($_SESSION['wizard']['source']['username']['id'] == $source) { $_SESSION['wizard']['source'] = \Auth::userBeside($source); $_SESSION['wizard']['destination'] = $_SESSION['usernames'][$destination]; } else { $_SESSION['wizard']['source'] = $_SESSION['usernames'][$source]; $_SESSION['wizard']['destination'] = \Auth::userBeside($source); } } else { $_SESSION['wizard']['source'] = $_SESSION['usernames'][$source]; $_SESSION['wizard']['destination'] = $_SESSION['usernames'][$destination]; } $_SESSION['current'] = $_SESSION['wizard']['source']; \Router::redirect('migrate'); } }