Exemplo n.º 1
0
 /**
  * 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();
 }
Exemplo n.º 2
0
 /**
  * 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');
     });
 }
Exemplo n.º 3
0
 /**
  * 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;
 }
Exemplo n.º 4
0
 /**
  * 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();
 }
Exemplo n.º 5
0
 /**
  * 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');
 }
Exemplo n.º 6
0
 /**
  * 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;
 }
Exemplo n.º 7
0
 /**
  * ...
  *
  * @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;
 }
Exemplo n.º 8
0
 /**
  * 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')));
 }
Exemplo n.º 9
0
 /**
  * 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;
 }
Exemplo n.º 10
0
<?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'))));
Exemplo n.º 11
0
 /**
  * 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('&lt;?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;
 }
Exemplo n.º 12
0
 /**
  * Get Link
  *
  * @return	\IPS\Http\Url
  */
 public function link()
 {
     return \IPS\Http\Url::internal("app=membermap&module=membermap&controller=showmap", 'front', 'membermap');
 }
Exemplo n.º 13
0
 /**
  * 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);
 }
Exemplo n.º 14
0
 /**
  * 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');
     });
 }
Exemplo n.º 15
0
 public function import()
 {
     $id = isset(\IPS\Request::i()->id) ? intval(\IPS\Request::i()->id) : 0;
     /* Build form */
     $form = new \IPS\Helpers\Form(NULL, 'import');
     if (isset(\IPS\Request::i()->id)) {
         $group = \IPS\membermap\Markers\Groups::load(intval(\IPS\Request::i()->id));
         if ($group->type == 'member') {
             \IPS\Output::i()->error('generic_error', '1MM4/1', 403, '');
         }
     }
     $form->add(new \IPS\Helpers\Form\Upload('import_upload', NULL, TRUE, array('allowedFileTypes' => array('kml'), 'temporary' => TRUE)));
     $form->add(new \IPS\Helpers\Form\YesNo('import_creategroups', FALSE, FALSE, array('togglesOff' => array('import_group'))));
     $form->add(new \IPS\Helpers\Form\Node('import_group', $id ?: 0, FALSE, array('class' => '\\IPS\\membermap\\Markers\\Groups', 'permissionCheck' => 'add', 'subnodes' => false, 'where' => array('group_type != ?', 'member')), NULL, NULL, NULL, 'import_group'));
     if ($values = $form->values()) {
         try {
             $xml = \IPS\Xml\SimpleXML::loadFile($values['import_upload']);
         } catch (\InvalidArgumentException $e) {
             $form->error = \IPS\Member::loggedIn()->language()->addToStack('xml_upload_invalid');
             \IPS\Output::i()->output = $form;
             return;
         }
         /* No group selected, and don't create groups?! */
         if ($values['import_creategroups'] == FALSE and !$values['import_group']) {
             $form->error = \IPS\Member::loggedIn()->language()->addToStack('membermap_error_no_id_no_create');
             \IPS\Output::i()->output = $form;
             return;
         }
         $markers = array();
         $groupOrder = NULL;
         $imported = 0;
         foreach ($xml->Document->Folder as $folder) {
             if (!isset($folder->Placemark)) {
                 continue;
             }
             $folderName = (string) $folder->name;
             foreach ($folder->Placemark as $placemark) {
                 if (!isset($placemark->Point->coordinates)) {
                     continue;
                 }
                 list($lon, $lat, $elev) = explode(',', $placemark->Point->coordinates);
                 $markers[] = array('marker_name' => (string) $placemark->name, 'marker_name_seo' => \IPS\Http\Url::seoTitle((string) $placemark->name), 'marker_description' => (string) $placemark->description, 'marker_lat' => $lat, 'marker_lon' => $lon, 'marker_member_id' => \IPS\Member::loggedIn()->member_id, 'marker_added' => time(), 'marker_open' => 1, 'marker_parent_id' => isset($values['import_group']) ? $values['import_group']->id : NULL);
             }
             /* Create a new group per "folder" */
             if ($values['import_creategroups'] == TRUE and count($markers) > 0) {
                 if ($groupOrder === NULL) {
                     $groupOrder = \IPS\Db::i()->select(array("MAX( `group_position` ) as position"), 'membermap_markers_groups')->first();
                 }
                 $groupOrder = $groupOrder + 1;
                 $group = new \IPS\membermap\Markers\Groups();
                 $group->name = $folderName;
                 $group->name_seo = \IPS\Http\Url::seoTitle($folderName);
                 $group->type = 'custom';
                 $group->pin_colour = '#FFFFFF';
                 $group->pin_bg_colour = 'red';
                 $group->pin_icon = 'fa-globe';
                 $group->position = $groupOrder;
                 $group->save();
                 \IPS\Lang::saveCustom('membermap', "membermap_marker_group_{$group->id}", trim($folderName));
                 \IPS\Lang::saveCustom('membermap', "membermap_marker_group_{$group->id}_JS", trim($folderName), 1);
                 // Add group id to all elements of the array
                 array_walk($markers, function (&$v, $k) use($group) {
                     $v['marker_parent_id'] = $group->id;
                 });
                 // Insert
                 \IPS\Db::i()->insert('membermap_markers', $markers);
                 $group->setLastComment();
                 $group->save();
                 // Set default permissions
                 $perms = $group->permissions();
                 \IPS\Db::i()->update('core_permission_index', array('perm_view' => '*', 'perm_2' => '*', 'perm_3' => \IPS\Settings::i()->admin_group, 'perm_4' => \IPS\Settings::i()->admin_group), array('perm_id=?', $perms['perm_id']));
                 // Reset
                 $imported += count($markers);
                 $markers = array();
             }
         }
         /* If we still got markers here, it's all pushed to one group, probably */
         if (is_array($markers) and count($markers) > 0) {
             \IPS\Db::i()->insert('membermap_markers', $markers);
             $group = $values['import_group'];
             $group->setLastComment();
             $group->save();
             $imported += count($markers);
         }
         \IPS\membermap\Map::i()->invalidateJsonCache();
         $message = \IPS\Member::loggedIn()->language()->addToStack('membermap_import_thumbup', FALSE, array('sprintf' => array($imported)));
         \IPS\Output::i()->redirect(\IPS\Http\Url::internal("app=membermap&module=membermap&controller=markers"), $message);
     }
     /* Display */
     \IPS\Output::i()->output = $form;
 }
Exemplo n.º 16
0
<?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] ) );
}
Exemplo n.º 17
0
 /**
  * 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'))));
 }
Exemplo n.º 18
0
 /**
  * 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)
 {
     if ($member !== null) {
         return $member;
     }
     try {
         // Let's do the VATSIM SSO Stuff
         require_once "VatsimSSO/OAuth.php";
         require_once "VatsimSSO/SSO.class.php";
         $ssoRequest = new \IPS\Login\VatsimSSO\SSO($this->settings["sso_base"], $this->settings["sso_key"], $this->settings["sso_secret"], "RSA", $this->settings["sso_rsa_key"]);
         $ssoReturn = \IPS\Http\Url::internal("login/?loginProcess=vatsim&return=true", "none");
         // Deal with the return!
         if (isset($_GET['return'])) {
             // Cancelled
             if (isset($_GET['oauth_cancel'])) {
                 \IPS\Output::i()->error('login_vatsim_cancelled', 'vs1001', 408, '');
                 return;
             }
             // Fine?
             if (isset($_GET['oauth_verifier'])) {
                 if (isset($_SESSION['sso_session_oauth']) && isset($_SESSION['sso_session_oauth']["key"]) && isset($_SESSION['sso_session_oauth']["secret"])) {
                     if (@$_GET['oauth_token'] != $_SESSION['sso_session_oauth']["key"]) {
                         throw new \IPS\Login\Exception('generic_error', \IPS\Login\Exception::INTERNAL_ERROR);
                     }
                     if (@(!isset($_GET['oauth_verifier']))) {
                         throw new \IPS\Login\Exception('generic_error', \IPS\Login\Exception::INTERNAL_ERROR);
                     }
                     // Get the user details!
                     $member = $ssoRequest->checkLogin($_SESSION['sso_session_oauth']["key"], $_SESSION['sso_session_oauth']["secret"], @$_GET['oauth_verifier']);
                     if (!$member) {
                         throw new \IPS\Login\Exception('generic_error', \IPS\Login\Exception::INTERNAL_ERROR);
                     }
                     $ssoMember = $member->user;
                     // HOUSTON, WE have the data!
                     if ($ssoMember && isset($ssoMember->id)) {
                         /* Try to find member */
                         $member = \IPS\Login\VatsimMember::load($ssoMember->id, 'vatsim_cid');
                         /* If we don't have one, create one */
                         if (!$member->member_id) {
                             /* Create member */
                             $member = new \IPS\Login\VatsimMember();
                             $member->member_group_id = \IPS\Settings::i()->member_group;
                         }
                         // We have one! Let's update.
                         $member->vatsim_cid = $ssoMember->id;
                         $member->name = $ssoMember->name_first . " " . $ssoMember->name_last;
                         $member->email = isset($ssoMember->email) ? $ssoMember->email : NULL;
                         $member->save();
                         return $member;
                     }
                     // We shouldn't get here.
                     throw new \IPS\Login\Exception('generic_error', \IPS\Login\Exception::INTERNAL_ERROR);
                 }
             }
         }
         // Let's deal with the token request and send them packing for a bit.
         $token = $ssoRequest->requestToken($ssoReturn, false, false);
         if ($token) {
             $_SESSION['sso_session_oauth'] = ["key" => (string) $token->token->oauth_token, "secret" => (string) $token->token->oauth_token_secret];
             $ssoRequest->sendToVatsim();
             return;
         }
         // We should never get here
         throw new \IPS\Login\Exception('generic_error', \IPS\Login\Exception::INTERNAL_ERROR);
     } catch (\IPS\Http\Request\Exception $e) {
         throw new \IPS\Login\Exception('generic_error', \IPS\Login\Exception::INTERNAL_ERROR);
     }
 }
<?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));
}
 /**
  * Get Form
  *
  * @param    string $url The URL for the login page
  * @param    bool   $ucp Is UCP? (as opposed to login form)
  *
  * @return    string
  */
 public function loginForm($url, $ucp = false)
 {
     return \IPS\Theme::i()->getTemplate('plugins', 'core', 'global')->steam((string) \IPS\Http\Url::external('https://steamcommunity.com/openid/login')->setQueryString(array('openid.ns' => 'http://specs.openid.net/auth/2.0', 'openid.mode' => 'checkid_setup', 'openid.return_to' => (string) \IPS\Http\Url::internal('applications/core/interface/steam/auth.php', 'none'), 'openid.realm' => (string) \IPS\Http\Url::internal('', 'none'), 'openid.identity' => 'http://specs.openid.net/auth/2.0/identifier_select', 'openid.claimed_id' => 'http://specs.openid.net/auth/2.0/identifier_select', 'openid.assoc_handle' => $ucp ? 'ucp' : \IPS\Dispatcher::i()->controllerLocation)));
 }
Exemplo n.º 21
0
 /**
  * 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) {
         /* If we have a custom author defined, we need to save the ID manually for json encoding */
         if (!empty($values['author']) and $values['author'] instanceof \IPS\Member) {
             $values['author'] = $values['author']->member_id;
         }
         $values['total'] = mt_rand($values['comment_range']['start'], $values['comment_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);
     /* <sarcasm>Serialization is fun</sarcasm> @TODO: Clean this up */
     if (!empty($values['author']) and is_int($values['author'])) {
         $values['author'] = \IPS\Member::load($values['author']);
     }
     if (!empty($values['item_url']) and is_array($values['item_url'])) {
         $values['item_url'] = \IPS\Http\Url::createFromArray($values['item_url']['data']);
     }
     /* Generate the MultipleRedirect page */
     $perGo = isset($values['per_go']) ? (int) $values['per_go'] : 25;
     $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;
         }
         /* Load our content item container */
         $itemClass = $self::$itemClass;
         $item = $itemClass::loadFromUrl($values['item_url']);
         $count = 0;
         $limit = $values['total'] - $doneSoFar;
         $generated = array();
         while ($count < $limit and count($generated) < $perGo) {
             ++$count;
             $generated[] = $self->generateSingle($item, $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, $values, $extension) {
         \IPS\Output::i()->redirect(\IPS\Http\Url::internal("app=faker&module=generator&controller={$self::$_controller}&extApp={$self::$app}&extension={$extension}"), 'completed');
     });
 }
Exemplo n.º 22
0
	/**
	 * 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 );
   		}
	}
Exemplo n.º 23
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(''));