/** * Show marker group index * * @return void */ protected function _index() { /* Online User Location */ \IPS\Session::i()->setLocation(\IPS\Http\Url::internal('app=membermap&module=markers&controller=groups', 'front', 'markers'), array(), 'loc_membermap_browsing_groups'); \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('membermap_marker_groups'); \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('markers')->index(); }
/** * ... * * @return void */ protected function manage() { \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__membermap_membermap_settings'); \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('jquery/jquery-ui.js', 'membermap', 'interface')); \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('admin_membermap.js', 'membermap', 'admin')); \IPS\Output::i()->cssFiles = array_merge(\IPS\Output::i()->cssFiles, \IPS\Theme::i()->css('jquery-ui.css', 'membermap', 'global')); \IPS\Output::i()->jsVars['membermap_mapquestAPI'] = \IPS\membermap\Application::getApiKeys('mapquest'); $form = new \IPS\Helpers\Form(); $form->addHeader('api_settings'); $form->add(new \IPS\Helpers\Form\Text('membermap_mapQuestAPI', \IPS\Settings::i()->membermap_mapQuestAPI, TRUE, array(), NULL, NULL, NULL, 'membermap_mapQuestAPI')); if (!empty(\IPS\Settings::i()->membermap_mapQuestAPI)) { $form->attributes['data-controller'] = 'membermap.admin.membermap.settings'; $form->attributes['id'] = 'membermap_form_settings'; $form->addHeader('map_settings'); $form->add(new \IPS\Helpers\Form\YesNo('membermap_groupByMemberGroup', \IPS\Settings::i()->membermap_groupByMemberGroup)); $form->add(new \IPS\Helpers\Form\YesNo('membermap_enable_clustering', \IPS\Settings::i()->membermap_enable_clustering)); $form->add(new \IPS\Helpers\Form\Text('membermap_bbox_location', \IPS\Settings::i()->membermap_bbox_location, FALSE, array(), NULL, NULL, NULL, 'membermap_bbox_location')); $form->add(new \IPS\Helpers\Form\Number('membermap_bbox_zoom', intval(\IPS\Settings::i()->membermap_bbox_zoom), FALSE, array('min' => 1, 'max' => 18))); $form->hiddenValues['membermap_bbox'] = \IPS\Settings::i()->membermap_bbox; $form->addHeader('membermap_autoUpdate'); $profileFields = array('' => ' -- ' . \IPS\Member::loggedIn()->language()->addToStack('membermap_profileLocationField') . ' -- '); foreach (\IPS\core\ProfileFields\Field::fields(array(), \IPS\core\ProfileFields\Field::PROFILE) as $group => $fields) { foreach ($fields as $id => $field) { $profileFields['core_pfieldgroups_' . $group][$id] = $field->name; } } $form->add(new \IPS\Helpers\Form\YesNo('membermap_monitorLocationField', \IPS\Settings::i()->membermap_monitorLocationField, FALSE, array('togglesOn' => array('membermap_profileLocationField', 'membermap_monitorLocationField_groupPerm', 'membermap_syncLocationField')))); $form->add(new \IPS\Helpers\Form\Select('membermap_profileLocationField', \IPS\Settings::i()->membermap_profileLocationField ? intval(\IPS\Settings::i()->membermap_profileLocationField) : NULL, FALSE, array('options' => $profileFields), NULL, NULL, NULL, 'membermap_profileLocationField')); $form->add(new \IPS\Helpers\Form\Select('membermap_monitorLocationField_groupPerm', \IPS\Settings::i()->membermap_monitorLocationField_groupPerm != '' ? \IPS\Settings::i()->membermap_monitorLocationField_groupPerm === '*' ? '*' : explode(",", \IPS\Settings::i()->membermap_monitorLocationField_groupPerm) : '*', FALSE, array('options' => \IPS\Member\Group::groups(), 'multiple' => TRUE, 'parse' => 'normal', 'unlimited' => '*', 'unlimitedLang' => 'all'), NULL, NULL, NULL, 'membermap_monitorLocationField_groupPerm')); $form->add(new \IPS\Helpers\Form\YesNo('membermap_syncLocationField', \IPS\Settings::i()->membermap_syncLocationField, FALSE, array(), NULL, NULL, NULL, 'membermap_syncLocationField')); } if ($values = $form->values(TRUE)) { $values['membermap_bbox'] = \IPS\Request::i()->membermap_bbox; if (empty($values['membermap_bbox_location'])) { $values['membermap_bbox'] = ""; } \IPS\DB::i()->update('core_tasks', array('enabled' => isset($values['membermap_syncLocationField']) and $values['membermap_syncLocationField'] ? 1 : 0), array('`key`=?', 'locationSync')); $form->saveAsSettings($values); \IPS\Session::i()->log('acplogs__membermap_settings'); \IPS\Output::i()->redirect(\IPS\Http\Url::internal("app=membermap&module=membermap&controller=settings"), 'saved'); } \IPS\Output::i()->output = $form; }
/** * Authenticate * * @param string $url The URL for the login page * @param \IPS\Member $member If we want to integrate this login method with an existing member, provide the member object * @return \IPS\Member * @throws \IPS\Login\Exception */ public function authenticate( $url, $member=NULL ) { $url = $url->setQueryString( 'loginProcess', 'vk' ); try { /* CSRF Check */ if ( \IPS\Request::i()->state !== \IPS\Session::i()->csrfKey ) { throw new \IPS\Login\Exception( 'CSRF_FAIL', \IPS\Login\Exception::INTERNAL_ERROR ); } if(isset(\IPS\Request::i()->error) || !isset(\IPS\Request::i()->code)) { throw new \IPS\Login\Exception( 'generic_error', \IPS\Login\Exception::INTERNAL_ERROR ); } /* Get a token */ try { $response = \IPS\Http\Url::external( "https://oauth.vk.com/access_token" )->setQueryString( array( 'client_id' => $this->settings['app_id'], 'redirect_uri' => (string) \IPS\Http\Url::internal( 'applications/core/interface/vk/auth.php', 'none' ), 'client_secret' => $this->settings['app_secret'], 'code' => \IPS\Request::i()->code ) )->request()->Get()->decodeJson(); if(isset($response['error'])) { throw new \IPS\Login\Exception( 'generic_error', \IPS\Login\Exception::INTERNAL_ERROR ); } } catch( \RuntimeException $e ) { throw new \IPS\Login\Exception( 'generic_error', \IPS\Login\Exception::INTERNAL_ERROR ); } /* Get the user data */ $userData = \IPS\Http\Url::external( "https://api.vk.com/method/getProfiles?uid={$response['user_id']}&access_token={$response['access_token']}&fields=first_name,last_name,screen_name,bdate,nickname" )->request()->get()->decodeJson(); $userData = $userData['response'][0]; /* Find or create member */ $newMember = FALSE; if ( $member === NULL ) { $member = \IPS\Member::load( $response['user_id'], 'vk_id' ); if ( !$member->member_id ) { if(isset($response['email'])) { $existingEmail = \IPS\Member::load( $response['email'], 'email' ); if ( $existingEmail->member_id ) { $exception = new \IPS\Login\Exception( 'generic_error', \IPS\Login\Exception::MERGE_SOCIAL_ACCOUNT ); $exception->handler = 'vk'; $exception->member = $existingEmail; $exception->details = array($response['access_token'], $response['user_id']); throw $exception; } } $member = new \IPS\Member; if ( \IPS\Settings::i()->reg_auth_type == 'admin' or \IPS\Settings::i()->reg_auth_type == 'admin_user' ) { $member->members_bitoptions['validating'] = TRUE; } $member->member_group_id = \IPS\Settings::i()->member_group; $member->email = isset($response['email'])?$response['email']:''; $member->name = $userData['nickname']; if ( empty($member->name) AND $this->settings['real_name'] ) { $name = $userData['first_name'] . ' ' . $userData['last_name']; $existingUsername = \IPS\Member::load( $name, 'name' ); if ( !$existingUsername->member_id ) { $member->name = $name; } } $member->profilesync = json_encode( array( 'vk' => array( 'photo' => TRUE, 'status' => '' ) ) ); $newMember = TRUE; } } /* Update details */ $member->vk_id = $response['user_id']; $member->vk_token = $response['access_token']; $member->save(); /* Sync */ if ( $newMember ) { if ( \IPS\Settings::i()->reg_auth_type == 'admin_user' ) { \IPS\Db::i()->update( 'core_validating', array( 'user_verified' => 1 ), array( 'member_id=?', $member->member_id ) ); } $sync = new \IPS\core\ProfileSync\VK( $member ); $sync->sync(); } /* Return */ return $member; } catch ( \IPS\Http\Request\Exception $e ) { throw new \IPS\Login\Exception( 'generic_error', \IPS\Login\Exception::INTERNAL_ERROR ); } }
/** * @brief Payline Gateway * @author <a href='http://skinod.com.com'>Skinod</a> * @copyright (c) 2015 Skinod.com */ require_once '../../../../init.php'; \IPS\Session\Front::i(); try { $transaction = \IPS\nexus\Transaction::load(\IPS\Request::i()->nexusTransactionId); if ($transaction->status !== \IPS\nexus\Transaction::STATUS_PENDING) { throw new \OutofRangeException(); } } catch (\OutOfRangeException $e) { \IPS\Output::i()->redirect(\IPS\Http\Url::internal("app=nexus&module=payments&controller=checkout&do=transaction&id=&t=" . \IPS\Request::i()->nexusTransactionId, 'front', 'nexus_checkout', \IPS\Settings::i()->nexus_https)); } try { $result = $transaction->method->api(array('trans_id' => \IPS\Request::i()->trans_id, 'id_get' => \IPS\Request::i()->id_get), TRUE); if ($result === 1) { $transaction->gw_id = \IPS\Request::i()->trans_id . '_' . \IPS\Request::i()->id_get; $transaction->save(); $transaction->checkFraudRulesAndCapture(NULL); $transaction->sendNotification(); \IPS\Session::i()->setMember($transaction->invoice->member); // This is in case the checkout was a guest, meaning checkFraudRulesAndCapture() may have just created an account. There is no security issue as we have just verified they were just bounced back from Payline \IPS\Output::i()->redirect($transaction->url()); } throw new \OutofRangeException(); } catch (\Exception $e) { \IPS\Output::i()->redirect($transaction->invoice->checkoutUrl()->setQueryString(array('_step' => 'checkout_pay', 'err' => $transaction->member->language()->get('gateway_err')))); }
/** * Delete a marker * * @return void */ protected function delete() { \IPS\Session::i()->csrfCheck(); if (!\IPS\Member::loggedIn()->member_id or !intval(\IPS\Request::i()->member_id)) { \IPS\Output::i()->error('no_permission', '2MM3/4', 403, ''); } /* Get the marker */ $existing = \IPS\membermap\Map::i()->getMarkerByMember(intval(\IPS\Request::i()->member_id), FALSE); if (isset($existing)) { $is_supmod = \IPS\Member::loggedIn()->modPermission() ?: 0; if ($is_supmod or $existing->mapped('author') == \IPS\Member::loggedIn()->member_id and $existing->canDelete()) { $existing->delete(); \IPS\Output::i()->json('OK'); } } /* Fall back to a generic error */ \IPS\Output::i()->error('no_permission', '2MM3/5', 403, ''); }