/** * 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(); }
/** * Bulk process generations * * @param array|null $values Form submission values * @return \IPS\Helpers\MultipleRedirect */ public function generateBulk($values = NULL) { $self = $this; $vCookie = static::$app . '_faker_' . static::$_controller . '_generator_values'; /* If this is a form submission, store our values now */ if ($values) { $values['total'] = mt_rand($values['record_range']['start'], $values['record_range']['end']); unset(\IPS\Request::i()->cookie[$vCookie]); \IPS\Request::i()->setCookie($vCookie, json_encode($values)); } $values = $values ?: json_decode(\IPS\Request::i()->cookie[$vCookie], true); $perGo = isset($values['per_go']) ? (int) $values['per_go'] : 25; /* Generate the MultipleRedirect page */ $reflect = new \ReflectionClass($this); $extension = $reflect->getShortName(); $processUrl = \IPS\Http\Url::internal("app=faker&module=generator&controller={$self::$_controller}&extApp={$self::$app}&extension={$extension}&do=process"); return new \IPS\Helpers\MultipleRedirect($processUrl, function ($doneSoFar) use($self, $perGo, $values, $vCookie) { /* Have we processed everything? */ if ($doneSoFar >= $values['total']) { return NULL; } $count = 0; $generated = array(); while ($count < $values['total'] and count($generated) < $perGo) { ++$count; $generated[] = $self->generateSingle($values); } $doneSoFar += $perGo; /* Update our session cookies and proceed to the next chunk */ \IPS\Request::i()->setCookie($vCookie, json_encode($values)); return array($doneSoFar, end($generated), 100 * $doneSoFar / $values['total']); }, function () use($self, $extension) { \IPS\Output::i()->redirect(\IPS\Http\Url::internal("app=faker&module=generator&controller={$self::$_controller}&extApp={$self::$app}&extension={$extension}"), 'completed'); }); }
/** * Authorize * * @param \IPS\nexus\Transaction $transaction Transaction * @param array|\IPS\nexus\Customer\CreditCard $values Values from form OR a stored card object if this gateway supports them * @param \IPS\nexus\Fraud\MaxMind\Request|NULL $maxMind *If* MaxMind is enabled, the request object will be passed here so gateway can additional data before request is made * @return \IPS\DateTime|NULL Auth is valid until or NULL to indicate auth is good forever * @throws \LogicException Message will be displayed to user */ public function auth(\IPS\nexus\Transaction $transaction, $values, \IPS\nexus\Fraud\MaxMind\Request $maxMind = NULL) { $transaction->save(); $data = array('amount' => $transaction->amount->amount / 10, 'msg' => urlencode($transaction->invoice->title), 'orderId' => $transaction->id, 'callbackUrl' => (string) \IPS\Settings::i()->base_url . 'applications/nexus/interface/gateways/jahanpay.php'); $res = $this->api($data); if (!empty($res)) { \IPS\Output::i()->redirect(\IPS\Http\Url::external('http://www.jahanpay.com/pay_invoice/' . $res)); } throw new \RuntimeException(); }
/** * Authorize * * @param \IPS\nexus\Transaction $transaction Transaction * @param array|\IPS\nexus\Customer\CreditCard $values Values from form OR a stored card object if this gateway supports them * @param \IPS\nexus\Fraud\MaxMind\Request|NULL $maxMind *If* MaxMind is enabled, the request object will be passed here so gateway can additional data before request is made * @return \IPS\DateTime|NULL Auth is valid until or NULL to indicate auth is good forever * @throws \LogicException Message will be displayed to user */ public function auth(\IPS\nexus\Transaction $transaction, $values, \IPS\nexus\Fraud\MaxMind\Request $maxMind = NULL) { $transaction->save(); $data = array('Amount' => $transaction->amount->amount / 10, 'Description' => $transaction->invoice->title, 'Email' => $transaction->member->email, 'Mobile' => $transaction->member->cm_phone, 'CallbackURL' => (string) \IPS\Settings::i()->base_url . 'applications/nexus/interface/gateways/zarinpal.php?nexusTransactionId=' . $transaction->id); $res = $this->api($data); if ($res['Status'] == 100) { $settings = json_decode($this->settings, TRUE); \IPS\Output::i()->redirect(\IPS\Http\Url::external('https://www.zarinpal.com/pg/StartPay/' . $res['Authority'] . '' . ($settings['zarin_gate'] ? '/ZarinGate' : ''))); } throw new \RuntimeException(); }
/** * Get photo * * @return \IPS\Http\Url|null */ public function photo() { $user = $this->userData(); if ($user !== NULL && isset($user['avatarfull'])) { try { return \IPS\Http\Url::external($user['avatarfull'])->import('core_Profile'); } catch (\IPS\Http\Request\Exception $e) { // Fall through to return NULL below } } return NULL; }
/** * Display the content generation form * * @return void */ protected function manage() { $form = new \IPS\faker\Decorators\Form('form', 'faker_purge'); $form->langPrefix = 'faker_purge'; $form->add(new \IPS\Helpers\Form\CheckboxSet('content_types', 0, true, array('options' => $this->getContentTypes()))); if ($values = $form->values()) { $this->_purgeContent($values); \IPS\Output::i()->redirect(\IPS\Http\Url::internal('app=faker&module=tools&controller=purge'), 'faker_purge_success'); return; } \IPS\Output::i()->output = $form; return; }
/** * Execute * * @return void */ public function execute() { try { $this->marker = \IPS\membermap\Markers\Markers::loadAndCheckPerms(\IPS\Request::i()->id); } catch (\OutOfRangeException $e) { \IPS\Output::i()->error('node_error', '2MM1/1', 404, ''); } \IPS\Output::i()->breadcrumb[] = array(\IPS\Http\Url::internal('app=membermap&module=membermap&controller=showmap', 'front', 'membermap'), \IPS\Member::loggedIn()->language()->addToStack('module__membermap_membermap')); \IPS\Output::i()->breadcrumb = array_reverse(\IPS\Output::i()->breadcrumb); \IPS\Output::i()->breadcrumb[] = array($this->marker->container()->url(), $this->marker->container()->_title); \IPS\Output::i()->breadcrumb[] = array('', $this->marker->_title); /* Load JS */ \IPS\membermap\Application::getJsForMarkerForm(); parent::execute(); }
/** * Update default maps * @return void */ public function update() { $maps = \IPS\Request::i()->maps; if (!isset($maps['basemaps'])) { /* You can't have a map with no basemap. Defaulting to OpenStreetMap.France */ $maps['basemaps'] = array('OpenStreetMap.France'); } if (!isset($maps['overlays'])) { $maps['overlays'] = array(); } \IPS\Settings::i()->membermap_activemaps = json_encode($maps); \IPS\Db::i()->update('core_sys_conf_settings', array('conf_value' => \IPS\Settings::i()->membermap_activemaps), array('conf_key=?', 'membermap_activemaps')); unset(\IPS\Data\Store::i()->settings); if (\IPS\Request::i()->isAjax()) { \IPS\Output::i()->output = 1; return; } \IPS\Output::i()->redirect(\IPS\Http\Url::internal("app=membermap&module=membermap&controller=mapmanager"), 'saved'); }
/** * ... * * @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; }
/** * Display the generator form * * @return void */ protected function manage() { list($ext, $extApp, $extension, $controller) = $this->extData(); /* Build the generator form */ $form = new \IPS\faker\Decorators\Form('form', 'faker_form_generate', \IPS\Http\Url::internal("app=faker&module=generator&controller={$controller}&extApp={$extApp}&extension={$extension}")); $form->langPrefix = "{$extApp}_faker_{$controller}"; $ext->buildGenerateForm($form); /* Cycle field */ $cycle = new \IPS\Helpers\Form\Number('per_go', $ext::$cycleDefault, TRUE, array('min' => 1)); $cycle->label = \IPS\Member::loggedIn()->language()->addToStack('faker_perGo'); $form->add($cycle); if ($values = $form->values()) { \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('faker_generator_title', true, array('sprintf' => \IPS\Member::loggedIn()->language()->addToStack("menu__faker_{$extApp}_{$extension}"))); \IPS\Output::i()->output = (string) $ext->generateBulk($values); return; } \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack($ext::$title); \IPS\Output::i()->output = $form; }
/** * Submit Event * * @return void */ protected function manage() { $group = NULL; if (isset(\IPS\Request::i()->group)) { try { $group = \IPS\membermap\Markers\Groups::loadAndCheckPerms(\IPS\Request::i()->group); \IPS\Output::i()->breadcrumb[] = array(\IPS\Http\Url::internal('app=membermap&module=groups&controller=groups&id=' . $group->_id, 'front', 'markers_group', $group->name_seo), $group->_title); } catch (\OutOfRangeException $e) { } } $form = \IPS\membermap\Markers\Markers::create($group); if (\IPS\membermap\Markers\Markers::moderateNewItems(\IPS\Member::loggedIn())) { $form = \IPS\Theme::i()->getTemplate('forms', 'core')->modQueueMessage(\IPS\Member::loggedIn()->warnings(5, NULL, 'mq'), \IPS\Member::loggedIn()->mod_posts) . $form; } /* Display */ \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('membermap_submit_a_marker'); \IPS\Output::i()->sidebar['enabled'] = FALSE; \IPS\Output::i()->breadcrumb[] = array(NULL, \IPS\Member::loggedIn()->language()->addToStack('membermap_submit_a_marker')); \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('submit')->submitPage($form->customTemplate(array(call_user_func_array(array(\IPS\Theme::i(), 'getTemplate'), array('submit', 'membermap')), 'submitForm'))); }
/** * Authorize * * @param \IPS\nexus\Transaction $transaction Transaction * @param array|\IPS\nexus\Customer\CreditCard $values Values from form OR a stored card object if this gateway supports them * @param \IPS\nexus\Fraud\MaxMind\Request|NULL $maxMind *If* MaxMind is enabled, the request object will be passed here so gateway can additional data before request is made * @return \IPS\DateTime|NULL Auth is valid until or NULL to indicate auth is good forever * @throws \LogicException Message will be displayed to user */ public function auth(\IPS\nexus\Transaction $transaction, $values, \IPS\nexus\Fraud\MaxMind\Request $maxMind = NULL) { // Change order status to Waiting // Notice: When change status to PENDING, the site appears some errors about the template // Call to undefined method IPS\Theme\class_nexus_admin_transactions::pend() $transaction->status = \IPS\nexus\Transaction::STATUS_WAITING; $extra = $transaction->extra; $extra['history'][] = array('s' => \IPS\nexus\Transaction::STATUS_WAITING); $transaction->extra = $extra; $transaction->save(); // In case: When a guest checks out they will be prompted to create an account, // The account will not be created until payment has been authorised // So, we create a new account to get member_id before create the widget // After checkout, the customer needs re-login to check order status $this->registerMember($transaction->invoice); $settings = $this->getSettings(); self::initPaymentwall($settings['project_key'], $settings['secret_key']); $widget = new \Paymentwall_Widget($transaction->invoice->member->member_id ? $transaction->invoice->member->member_id : $_SERVER['REMOTE_ADDR'], $settings['widget_code'], array(new \Paymentwall_Product($transaction->invoice->id, (string) $transaction->amount->amount, $transaction->currency, 'Invoice #' . $transaction->invoice->id, \Paymentwall_Product::TYPE_FIXED)), array_merge(array('test_mode' => (int) $settings['test_mode'], 'success_url' => trim($settings['success_url']) != '' ? trim($settings['success_url']) : (string) \IPS\Http\Url::internal('app=nexus&module=clients&controller=invoices&id=' . $transaction->invoice->id, 'front', 'clientsinvoice', array(), \IPS\Settings::i()->nexus_https), 'id' => $transaction->id, 'integration_module' => 'ipboard', 'email' => $transaction->invoice->member->email), $this->prepareUserProfileData($transaction))); echo $widget->getHtmlCode(array('width' => '100%', 'height' => '600px')); die; }
<?php /** * @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'))));
/** * Get the queries rows for a version * * @param int $long Version ID * @return array */ public function _getQueriesRows($long) { $enabled = \IPS\Settings::i()->querybox_enable_versions_query_execute; if (!is_null($enabled) and !$enabled) { return call_user_func_array('parent::_getQueriesRows', func_get_args()); } $queries = $this->_getQueries($long); $order = 1; $rows = array(); foreach ($queries as $qid => $data) { $params = array(); if (isset($data['params']) and is_array($data['params'])) { foreach ($data['params'] as $v) { $params[] = var_export($v, TRUE); } } $rows["{$long}.{$qid}"] = \IPS\Theme::i()->getTemplate('trees', 'core')->row($this->url, "{$long}.{$qid}", str_replace('<?php', '', highlight_string("<?php \\IPS\\Db::i()->{$data['method']}( " . implode(', ', $params) . " )", TRUE)), FALSE, array('execute' => array('icon' => 'play-circle', 'title' => 'versions_query_execute', 'link' => \IPS\Http\Url::internal("app=core&module=applications&controller=developer&appKey={$this->application->directory}&do=executeVersionQuery&version={$long}&query={$qid}"), 'data' => array('confirm' => '')), 'delete' => array('icon' => 'times-circle', 'title' => 'delete', 'link' => \IPS\Http\Url::internal("app=core&module=applications&controller=developer&appKey={$this->application->directory}&do=deleteVersionQuery&version={$long}&query={$qid}"), 'data' => array('delete' => ''))), NULL, NULL, $order, FALSE, NULL, NULL, NULL, TRUE); $order++; } return $rows; }
/** * Get Link * * @return \IPS\Http\Url */ public function link() { return \IPS\Http\Url::internal("app=membermap&module=membermap&controller=showmap", 'front', 'membermap'); }
/** * Loads add/update location form * * @return void */ protected function add() { if (!\IPS\Member::loggedIn()->member_id) { \IPS\Output::i()->error('no_permission', '2MM3/1', 403, ''); } /* Get the members location, if it exists */ $existing = \IPS\membermap\Map::i()->getMarkerByMember(\IPS\Member::loggedIn()->member_id, FALSE); $groupId = \IPS\membermap\Map::i()->getMemberGroupId(); /* Check permissions */ if ($existing) { if (!$existing->canEdit()) { \IPS\Output::i()->error('membermap_error_cantEdit', '2MM3/2', 403, ''); } } else { if (!\IPS\membermap\Markers\Groups::load($groupId)->can('add')) { \IPS\Output::i()->error('membermap_error_cantAdd', '2MM3/3', 403, ''); } } /* HTML5 GeoLocation form */ $geoLocForm = new \IPS\Helpers\Form('membermap_form_geoLocation', NULL, NULL, array('id' => 'membermap_form_geoLocation')); $geoLocForm->class = 'ipsForm_vertical ipsType_center'; $geoLocForm->addHeader('membermap_current_location'); $geoLocForm->addHtml('<li class="ipsType_center"><i class="fa fa-fw fa-4x fa-location-arrow"></i></li>'); $geoLocForm->addHtml('<li class="ipsType_center">' . \IPS\Member::loggedIn()->language()->addToStack('membermap_geolocation_desc') . '</li>'); $geoLocForm->addButton('membermap_current_location', 'button', NULL, 'ipsButton ipsButton_primary', array('id' => 'membermap_currentLocation')); $form = new \IPS\Helpers\Form('membermap_form_location', NULL, NULL, array('id' => 'membermap_form_location')); $form->class = 'ipsForm_vertical ipsType_center'; $form->addHeader('membermap_form_location'); $form->add(new \IPS\Helpers\Form\Text('membermap_location', '', FALSE, array('placeholder' => \IPS\Member::loggedIn()->language()->addToStack('membermap_form_placeholder')), NULL, NULL, NULL, 'membermap_location')); $form->addButton('save', 'submit', NULL, 'ipsPos_center ipsButton ipsButton_primary', array('id' => 'membermap_locationSubmit')); $form->hiddenValues['lat'] = \IPS\Request::i()->lat; $form->hiddenValues['lng'] = \IPS\Request::i()->lng; if ($values = $form->values()) { try { /* Create marker */ if ($existing instanceof \IPS\membermap\Markers\Markers) { $marker = $existing; $marker->updated = time(); } else { $marker = \IPS\membermap\Markers\Markers::createItem(\IPS\Member::loggedIn(), \IPS\Request::i()->ipAddress(), new \IPS\DateTime(), \IPS\membermap\Markers\Groups::load($groupId)); $marker->member_id = \IPS\Member::loggedIn()->member_id; } if (isset($values['membermap_location']) and !empty($values['membermap_location'])) { $marker->location = $values['membermap_location']; } $marker->name = \IPS\Member::loggedIn()->name; $marker->lat = $values['lat']; $marker->lon = $values['lng']; $marker->save(); /* Add to search index */ \IPS\Content\Search\Index::i()->index($marker); /* Content approval is requred, redirect the member to the marker page, where this is made clear */ if ($marker->hidden()) { \IPS\Output::i()->redirect($marker->url()); } else { \IPS\Output::i()->redirect(\IPS\Http\Url::internal('app=membermap&module=membermap&controller=showmap&dropBrowserCache=1&goHome=1', 'front', 'membermap')); } return; } catch (\Exception $e) { $form->error = \IPS\Member::loggedIn()->language()->addToStack('membermap_' . $e->getMessage()); \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('map')->addLocation($geoLocForm, $form); return; } } \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack(!$existing ? 'membermap_button_addLocation' : 'membermap_button_editLocation'); \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('map')->addLocation($geoLocForm, $form); }
/** * Build a generator form for this content item * * @param \IPS\faker\Decorators\Form $form * @return void */ public function buildGenerateForm(&$form) { $form->add(new \IPS\Helpers\Form\Node('nodes', null, true, array('url' => \IPS\Http\Url::internal('app=forums&module=forums&controller=forums&do=createMenu'), 'class' => static::$nodeClass, 'multiple' => true))); $form->add(new \IPS\Helpers\Form\Select('author_type', 'random_fake', true, array('options' => array('random_fake' => 'faker_random_fake', 'guest' => 'guest'), 'unlimited' => '-1', 'unlimitedLang' => "faker_custom_author", 'unlimitedToggles' => array('faker_custom_author')))); $form->add(new \IPS\Helpers\Form\Member('author', null, false, array(), null, null, null, 'faker_custom_author')); $form->add(new \IPS\Helpers\Form\NumberRange('item_range', array('start' => 3, 'end' => 5), true, array('start' => array('min' => 1)))); $form->add(new \IPS\Helpers\Form\YesNo('add_comments', 0, false, array('togglesOn' => array('faker_comment_range')))); $form->add(new \IPS\Helpers\Form\NumberRange('comment_range', array('start' => 3, 'end' => 5), false, array('start' => array('min' => 1)), null, null, null, 'faker_comment_range')); $form->add(new \IPS\Helpers\Form\YesNo('add_tags', 0)); $form->add(new \IPS\Helpers\Form\CheckboxSet('after_posting', array(), false, array('options' => array('lock' => 'lock', 'pin' => 'pin', 'hide' => 'hide', 'feature' => 'feature')))); }
/** * Send API Request * * @param array $data The data to send * @return array */ public function api($data, $verify = FALSE) { $data['api'] = json_decode($this->settings)->api; return intval((string) \IPS\Http\Url::external($verify ? self::PAYLINE_CHECK_URL : self::PAYLINE_SEND_URL)->request()->post($data)); }
/** * ACP Settings Form * * @param string $url URL to redirect user to after successful submission * * @return array List of settings to save - settings will be stored to core_login_handlers.login_settings DB * field * @code return array( 'savekey' => new \IPS\Helpers\Form\[Type]( ... ), ... ); * @endcode */ public function acpForm() { \IPS\Output::i()->sidebar['actions'] = array('help' => array('title' => 'help', 'icon' => 'question-circle', 'link' => \IPS\Http\Url::external('http://forums.vatsim.net/viewtopic.php?f=134&t=65133'), 'target' => '_blank', 'class' => '')); return array('sso_base' => new \IPS\Helpers\Form\Text('login_vatsim_sso_base', isset($this->settings['sso_base']) ? $this->settings['sso_base'] : '', TRUE), 'sso_key' => new \IPS\Helpers\Form\Text('login_vatsim_sso_key', isset($this->settings['sso_key']) ? $this->settings['sso_key'] : '', TRUE), 'sso_secret' => new \IPS\Helpers\Form\Password('login_vatsim_sso_secret', isset($this->settings['sso_secret']) ? $this->settings['sso_secret'] : '', TRUE), 'sso_rsa_key' => new \IPS\Helpers\Form\TextArea('login_vatsim_sso_rsa_key', isset($this->settings['sso_rsa_key']) ? $this->settings['sso_rsa_key'] : '', TRUE)); }
/** * Geocode, get lat/lng by location * * @param string Location * @return array Lat/lng/formatted address */ public function getLatLng($location) { static $locCache = array(); $locKey = md5($location); if (isset($locCache['cache-' . $locKey])) { return $locCache['cache-' . $locKey]; } $apiKey = \IPS\membermap\Application::getApiKeys('mapquest'); if ($apiKey) { try { $data = \IPS\Http\Url::external("https://open.mapquestapi.com/nominatim/v1/search.php?key={$apiKey}&format=json&limit=1&q=" . urlencode($location))->request(15)->get()->decodeJson(); if (is_array($data) and count($data)) { $locCache['cache-' . $locKey] = array('lat' => $data[0]['lat'], 'lng' => $data[0]['lon'], 'location' => $data[0]['display_name']); return $locCache['cache-' . $locKey]; } else { /* No result for this */ $locCache['cache-' . $locKey] = false; } } catch (\RuntimeException $e) { \IPS\Log::log($e, 'membermap'); return false; } } return false; }
/** * Updating markers without a seo name * * @return array If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops) */ public function step3() { foreach (\IPS\Db::i()->select('*', 'membermap_markers', 'marker_name_seo = "" OR marker_name_seo IS NULL') as $marker) { $seoName = \IPS\Http\Url::seoTitle(trim($marker['marker_name'])); \IPS\Db::i()->update('membermap_markers', array('marker_name_seo' => $seoName), 'marker_id=' . $marker['marker_id']); } return TRUE; }
/** * [Node] Format form values from add/edit form for save * * @param array $values Values from the form * @return array */ public function formatFormValues($values) { if (!$this->id) { $this->save(); } if (isset($values['group_name'])) { \IPS\Lang::saveCustom('membermap', "membermap_marker_group_{$this->id}", $values['group_name']); \IPS\Lang::saveCustom('membermap', "membermap_marker_group_{$this->id}_JS", $values['group_name'], 1); $this->name_seo = \IPS\Http\Url::seoTitle($values['group_name'][\IPS\Lang::defaultLanguage()]); unset($values['group_name']); } foreach (array('group_pin_icon', 'group_pin_colour', 'group_pin_bg_colour') as $val) { if (isset($values[$val])) { $key = str_replace('group_', '', $val); $values[$key] = $values[$val]; unset($values[$val]); } } return $values; }
/** * Get name * * @return string */ public function name() { try { $response = \IPS\Http\Url::external( "https://api.vk.com/method/getProfiles?uid={$this->member->vk_id}&access_token={$this->member->vk_token}" )->request()->get()->decodeJson(); if ( isset( $response["response"] ) && isset($response['response'][0]) ) { return $response['response'][0]['first_name'] . ' ' . $response['response'][0]['last_name']; } } catch ( \IPS\Http\Request\Exception $e ) { return NULL; } }
/** * Verifies a usernames existence on YouTube * * @note This will return false if no channels are found, even if the username does exist * @param $username The YouTube username * @return bool * @throws InvalidAPIKey * @throws NoAPIKey */ public function verifyUsername($username) { $api_key = $this->hasApiKey(); // Yup, lets get to it and build our URL $url = \IPS\Http\Url::external('https://www.googleapis.com/youtube/v3/channels')->setQueryString('key', $api_key)->setQueryString('forUsername', $username)->setQueryString('part', 'id'); // Init our curl $curl = new \IPS\Http\Request\Curl($url); // Get our response $response = $curl->get(); // Close the curl just cause I'm tidy like that. unset($curl); // If false, username not found OR has no channels if (!$this->parseResponse($response)) { return FALSE; } return TRUE; }
<?php require_once str_replace('applications/core/interface/steam/auth.php', '', str_replace('\\', '/', __FILE__)) . 'init.php'; $openidParams = array(); foreach (array_keys($_GET) as $key) { if (strpos($key, 'openid_') === 0) { $openidParams[$key] = $_GET[$key]; } } $params = http_build_query($openidParams); if (\IPS\Request::i()->openid_invalidate_handle == 'ucp') { \IPS\Output::i()->redirect(\IPS\Http\Url::internal("app=core&module=system&controller=settings&area=profilesync&service=Steam&loginProcess=steam&" . $params, 'front', 'settings_Steam')); } else { \IPS\Output::i()->redirect(\IPS\Http\Url::internal("app=core&module=system&controller=login&loginProcess=steam&" . $params, \IPS\Request::i()->openid_invalidate_handle)); }
/** * Bulk process generations * * @param array|null $values Form submission values * @return \IPS\Helpers\MultipleRedirect */ public function generateBulk($values = NULL) { $self = $this; $vCookie = static::$app . '_faker_' . static::$_controller . '_generator_values'; $mCookie = static::$app . '_faker_' . static::$_controller . '_generator_map'; /* If this is a form submission, store our values now */ if ($values) { unset(\IPS\Request::i()->cookie[$vCookie]); unset(\IPS\Request::i()->cookie[$mCookie]); \IPS\Request::i()->setCookie($vCookie, json_encode($values)); } $values = $values ?: json_decode(\IPS\Request::i()->cookie[$vCookie], true); $perGo = isset($values['per_go']) ? (int) $values['per_go'] : 25; /** * How many items should we generate for each node? * We calculate this information beforehand so we can track our progress in MultipleRedirect */ $nodeMap = isset(\IPS\Request::i()->cookie[$mCookie]) ? json_decode(\IPS\Request::i()->cookie[$mCookie], true) : NULL; if (!$nodeMap) { $nodeMap = array('total' => 0, 'nodes' => array()); foreach ($values['nodes'] as $id => $node) { $nodeMap['nodes'][$id] = mt_rand($values['item_range']['start'], $values['item_range']['end']); } $nodeMap['total'] = array_sum($nodeMap['nodes']); \IPS\Request::i()->setCookie($mCookie, json_encode($nodeMap)); } $total = $nodeMap['total']; /* Generate the MultipleRedirect page */ $reflect = new \ReflectionClass($this); $extension = $reflect->getShortName(); $processUrl = \IPS\Http\Url::internal("app=faker&module=generator&controller={$self::$_controller}&extApp={$self::$app}&extension={$extension}&do=process"); return new \IPS\Helpers\MultipleRedirect($processUrl, function ($doneSoFar) use($self, $perGo, $values, $total, $nodeMap, $vCookie, $mCookie) { /* Have we processed everything? */ if (!array_sum($nodeMap['nodes'])) { return NULL; } /* Process our nodes */ $generated = array(); foreach ($nodeMap['nodes'] as $node => &$limit) { /* Have we reached our per go limit? */ if (count($generated) >= $perGo) { break; } /* Load our node container */ $nodeClass = $self::$nodeClass; $_node = $nodeClass::load($node); /* Process up to $perGo items from this node */ $count = 0; $_limit = $limit; while ($count < $_limit and count($generated) < $perGo) { ++$count; --$limit; $generated[] = $self->generateSingle($_node, $values); } /* If we've cleared out this node, remove it from our map and proceed to the next one */ if (!$nodeMap['nodes'][$node]) { unset($nodeMap['nodes'][$node]); } } $doneSoFar += $perGo; /* Update our session cookies and proceed to the next chunk */ \IPS\Request::i()->setCookie($vCookie, json_encode($values)); \IPS\Request::i()->setCookie($mCookie, json_encode($nodeMap)); return array($doneSoFar, end($generated), 100 * $doneSoFar / $total); }, function () use($self, $extension) { \IPS\Output::i()->redirect(\IPS\Http\Url::internal("app=faker&module=generator&controller={$self::$_controller}&extApp={$self::$app}&extension={$extension}"), 'completed'); }); }
<?php /** * @brief VK Login Handler Redirect URI Handler * @author <a href='http://www.skinod.com'>Skinod</a> * @copyright (c) 2015 skinod.com */ require_once str_replace( 'applications/core/interface/vk/auth.php', '', str_replace( '\\', '/', __FILE__ ) ) . 'init.php'; $state = explode( '-', \IPS\Request::i()->state ); if ( $state[0] == 'ucp' ) { \IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=system&controller=settings&area=profilesync&service=VK&loginProcess=VK&state={$state[1]}&code=" . urlencode( \IPS\Request::i()->code ), 'front', 'settings_VK' ) ); } else { \IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=core&module=system&controller=login&loginProcess=VK&state={$state[1]}&code=" . urlencode( \IPS\Request::i()->code ), $state[0] ) ); }
<?php /** * @author Sijad aka Mr.Wosi * @link <a href='http://skinod.com'>Skinod.com</a> * @copyright 2015 <a href='http://skinod.com'>Skinod.com</a> */ /** * Path to your IP.Board directory with a trailing / */ $_SERVER['SCRIPT_FILENAME'] = __FILE__; $path = ''; require_once $path . 'init.php'; \IPS\Session\Front::i(); if (\IPS\Member::loggedIn()->member_id) { \IPS\Member::loggedIn()->skin = (int) \IPS\Request::i()->id; \IPS\Member::loggedIn()->save(); } else { \IPS\Request::i()->setCookie('theme', (int) \IPS\Request::i()->id); } /* Make sure VSE cookie is killed */ if (isset(\IPS\Request::i()->cookie['vseThemeId'])) { \IPS\Request::i()->setCookie('vseThemeId', 0); } \IPS\Output::i()->redirect(\IPS\Http\Url::internal(''));
/** * Link Account * * @param \IPS\Member $member The member * @param mixed $details Details as they were passed to the exception thrown in authenticate() * @return void */ public static function link( \IPS\Member $member, $details ) { try { $userData = \IPS\Http\Url::external( "https://api.vk.com/method/getProfiles?uid={$details[1]}&access_token={$details[0]}&fields=first_name,last_name,screen_name,bdate,nickname" )->request()->get()->decodeJson(); $userData = $userData['response'][0]; $member->vk_id = $details[1]; $member->vk_token = $details[0]; $member->save(); }catch(\Exception $e) {} }
/** * This will validate the incoming Steam OpenID request * * @package Steam Community API * @copyright (c) 2010 ichimonai.com * @license http://opensource.org/licenses/mit-license.php The MIT License * * @return int|bool */ private function validate() { $params = array('openid.signed' => \IPS\Request::i()->openid_signed, 'openid.sig' => str_replace(' ', '+', \IPS\Request::i()->openid_sig), 'openid.ns' => 'http://specs.openid.net/auth/2.0'); // Get all the params that were sent back and resend them for validation $signed = explode(',', \IPS\Request::i()->openid_signed); foreach ($signed as $item) { $val = \IPS\Request::i()->{'openid_' . str_replace('.', '_', $item)}; $params['openid.' . $item] = get_magic_quotes_gpc() ? stripslashes($val) : $val; } // Finally, add the all important mode. $params['openid.mode'] = 'check_authentication'; // Validate whether it's true and if we have a good ID preg_match("#^http://steamcommunity.com/openid/id/([0-9]{17,25})#", $_GET['openid_claimed_id'], $matches); $steamID64 = is_numeric($matches[1]) ? $matches[1] : 0; $response = (string) \IPS\Http\Url::external('https://steamcommunity.com/openid/login')->request()->post($params); $values = array(); foreach (explode("\n", $response) as $value) { $data = explode(":", $value); $key = $data[0]; unset($data[0]); $values[$key] = implode(':', $data); } // Return our final value return $values['is_valid'] === 'true' ? $steamID64 : false; }