示例#1
0
 /**
  * Show edit form
  * 
  * @return void
  */
 protected function edit()
 {
     if (!$this->marker->canEdit() and !\IPS\Request::i()->form_submitted) {
         \IPS\Output::i()->error('edit_no_perm_err', '2MM1/2', 403, '');
     }
     $form = $this->marker->buildEditForm();
     if ($values = $form->values()) {
         if ($this->marker->canEdit()) {
             $this->marker->processForm($values);
             /* Old custom markers did not store the author ID, update them now to the current member */
             if ($this->marker->member_id == 0) {
                 $this->marker->member_id = \IPS\Member::loggedIn()->member_id;
             }
             $this->marker->updated = time();
             $this->marker->save();
             $this->marker->processAfterEdit($values);
             \IPS\Output::i()->redirect($this->marker->url());
         } else {
             $form->error = \IPS\Member::loggedIn()->language()->addToStack('edit_no_perm_err');
         }
     }
     /* Display */
     \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('membermap_edit_a_marker');
     \IPS\Output::i()->sidebar['enabled'] = FALSE;
     \IPS\Output::i()->breadcrumb[] = array(NULL, \IPS\Member::loggedIn()->language()->addToStack('membermap_edit_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')));
 }
示例#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');
     });
 }
示例#3
0
 /**
  * Custom title for this step
  *
  * @return string
  */
 public function step1CustomTitle()
 {
     $limit = isset(\IPS\Request::i()->extra) ? \IPS\Request::i()->extra : 0;
     if (!isset($_SESSION['_step1Count'])) {
         $_SESSION['_step1Count'] = \IPS\Db::i()->select('COUNT(*)', 'membermap_members')->first();
     }
     return "Updating member markers (Upgraded so far: " . ($limit > $_SESSION['_step1Count'] ? $_SESSION['_step1Count'] : $limit) . ' out of ' . $_SESSION['_step1Count'] . ')';
 }
示例#4
0
 /**
  * ...
  *
  * @return	void
  */
 protected function manage()
 {
     if (isset(\IPS\Request::i()->id)) {
         try {
             $this->_group(\IPS\membermap\Markers\Groups::loadAndCheckPerms(\IPS\Request::i()->id, 'view'));
         } catch (\OutOfRangeException $e) {
             \IPS\Output::i()->error('node_error', '2MM2/1', 404, '');
         }
     } else {
         $this->_index();
     }
 }
示例#5
0
 /**
  * Process Pingback
  *
  * @return    void
  */
 protected function manage()
 {
     try {
         $transaction = \IPS\nexus\Transaction::load(\IPS\Request::i()->id);
     } catch (\OutOfRangeException $e) {
         die('Transaction invalid!');
     }
     try {
         $response = $transaction->method->handlerPingback($transaction);
         die($response);
     } catch (\Exception $e) {
         die($e->getMessage());
     }
 }
示例#6
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;
 }
示例#7
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');
 }
示例#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')));
 }
示例#9
0
 /**
  * Get request extension data
  *
  * @return  array   Extension object, app name, extension name
  */
 protected function extData()
 {
     /* Return pre-generated extension data if we have it */
     if ($this->extData) {
         return $this->extData;
     }
     /* Make sure our extension app and extension name have been defined */
     if (!($extApp = \IPS\Request::i()->extApp) or !($extension = \IPS\Request::i()->extension)) {
         \IPS\Output::i()->error('generic_error', '3FAKE108/1', 400);
         return array();
     }
     /* Try and fetch the requested extension or display a generic 404 error if we can't find it */
     try {
         $extensions = \IPS\faker\Faker::allExtensions(constant('\\IPS\\faker\\Faker::' . mb_strtoupper(static::$controller)));
         $ext = $extensions[\IPS\Request::i()->extApp . '_' . \IPS\Request::i()->extension];
     } catch (\Whoops\Exception\ErrorException $e) {
         \IPS\Output::i()->error('node_error', '2FAKE108/2', 404);
         return array();
     }
     return $this->extData = array($ext, $extApp, $extension, static::$controller);
 }
示例#10
0
/**
 * @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'))));
}
示例#11
0
 /**
  * Build a generator form for this node
  *
  * @param   \IPS\faker\Decorators\Form  $form
  * @return  void
  */
 public function buildGenerateForm(&$form)
 {
     $form->add(new \IPS\Helpers\Form\YesNo('description', FALSE));
     $form->add(new \IPS\Helpers\Form\NumberRange('node_range', array('start' => 3, 'end' => 5), TRUE, array('start' => array('min' => 1))));
     $form->add(new \IPS\Helpers\Form\Radio('forum_type', 'normal', TRUE, array('options' => array('normal' => 'forum_type_normal', 'qa' => 'forum_type_qa'), 'toggles' => array('normal' => array('forum_password_on', 'forum_ipseo_priority', 'forum_viglink', 'forum_min_posts_view', 'forum_can_view_others', 'forum_permission_showtopic', 'forum_permission_custom_error', "form_new_header_permissions", "form_new_tab_forum_display", "form_new_tab_posting_settings", "form_new_header_forum_display_topic", 'forum_preview_posts', 'forum_icon'), 'qa' => array('forum_password_on', 'forum_ipseo_priority', 'forum_viglink', 'forum_min_posts_view', 'forum_can_view_others_qa', 'forum_permission_showtopic_qa', 'forum_permission_custom_error', "form_new_header_permissions", "form_new_tab_forum_display", "form_new_tab_posting_settings", "form_new_header_forum_display_question", 'forum_can_view_others_qa', 'bw_enable_answers_member', 'forum_qa_rate_questions', 'forum_qa_rate_answers', 'forum_preview_posts_qa', 'forum_icon'), 'redirect' => array('forum_password_on', 'forum_redirect_url', 'forum_redirect_hits')))));
     $form->add(new \IPS\Helpers\Form\Node('parent_ids', NULL, FALSE, array('class' => '\\IPS\\forums\\Forum', 'multiple' => TRUE, 'disabled' => array(), 'zeroVal' => 'node_no_parentf', 'permissionCheck' => function ($node) {
         return !isset(\IPS\Request::i()->id) or $node->id != \IPS\Request::i()->id and !$node->isChildOf($node::load(\IPS\Request::i()->id));
     }), function ($val) {
         if (!$val and \IPS\Request::i()->forum_type !== 'category') {
             throw new \DomainException('faker_parent_id_error');
         }
     }));
     // $form->add( new \IPS\Helpers\Form\YesNo( 'icon', FALSE ) ); @TODO
     $form->add(new \IPS\Helpers\Form\YesNo('password_on', FALSE, FALSE, array('togglesOn' => array('password', 'password_override')), NULL, NULL, NULL, 'password_on'));
     $form->add(new \IPS\Helpers\Form\Password('password', NULL, FALSE, array(), NULL, NULL, NULL, 'password'));
     /* Defaults */
     $hiddenValues = array('forum_ipseo_priority' => '0.1', 'forum_min_posts_view' => 0, 'forum_can_view_others' => TRUE, 'forum_can_view_others_qa' => TRUE, 'forum_permission_showtopic' => TRUE, 'forum_permission_showtopic_qa' => TRUE, 'forum_sort_key' => 'last_post', 'forum_show_rules' => 0, 'forum_preview_posts' => FALSE, 'forum_preview_posts_qa' => FALSE, 'forum_inc_postcount' => TRUE, 'forum_allow_poll' => TRUE, 'forum_min_posts_post' => TRUE, 'bw_disable_tagging' => FALSE, 'bw_disable_prefixes' => FALSE);
     $form->hiddenValues = array_merge($form->hiddenValues, $hiddenValues);
 }
 /**
  * Execute Version Query
  *
  * @return  void
  */
 protected function executeVersionQuery()
 {
     $version = \IPS\Request::i()->version == 'install' ? 'install' : intval(\IPS\Request::i()->version);
     $json = $this->_getQueries($version);
     $query = $json[intval(\IPS\Request::i()->query)];
     $db = \IPS\Db::i();
     call_user_func_array(array($db, $query['method']), $query['params']);
 }
示例#13
0
/**
 * @brief		Jahanpay 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()->order_id);
    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()->order_id, 'front', 'nexus_checkout', \IPS\Settings::i()->nexus_https));
}
try {
    $res = $transaction->method->api(array('amount' => $transaction->amount->amount / 10, 'au' => \IPS\Request::i()->au), TRUE);
    if (!empty($res) and $res == 1) {
        $transaction->gw_id = \IPS\Request::i()->au;
        $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 Jahanpay
        \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'))));
}
示例#14
0
 /**
  * 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, '');
 }
示例#15
0
 public static function create($item, $comment, $first = FALSE, $guestName = NULL, $incrementPostCount = NULL, $member = NULL, \IPS\DateTime $time = NULL)
 {
     $topic = $item;
     if ($member === NULL) {
         $member = \IPS\Member::loggedIn();
     }
     if (isset($_POST['topic_title'])) {
         $comment = $_POST['topic_title'] . "\n" . $comment;
     }
     $access_key = \IPS\Settings::i()->access_key;
     if (isset($member) && !$member->isAdmin() && $member->member_posts <= 10 && \IPS\Settings::i()->moderate_new == 1) {
         require_once dirname($_SERVER['SCRIPT_FILENAME']) . "/uploads/cleantalk.class.php";
         require_once dirname($_SERVER['SCRIPT_FILENAME']) . "/uploads/JSON.php";
         session_name('cleantalksession');
         if (!isset($_SESSION)) {
             session_start();
         }
         if (array_key_exists('formtime', $_SESSION)) {
             $submit_time = time() - (int) $_SESSION['formtime'];
         } else {
             $submit_time = NULL;
         }
         $_SESSION['formtime'] = time();
         $post_info = '';
         $lang = \IPS\Lang::getEnabledLanguages();
         $locale = $lang[\IPS\Lang::defaultLanguage()]->short;
         if (function_exists('json_encode')) {
             $arr = array('cms_lang' => $locale, 'REFFERRER' => $_SERVER['HTTP_REFERER'], 'USER_AGENT' => $_SERVER['HTTP_USER_AGENT']);
             $post_info = json_encode($arr);
         }
         if ($post_info === FALSE) {
             $post_info = '';
         }
         $ct_url = 'http://moderate.cleantalk.ru';
         $config_work_url = $ct_url;
         $config_ttl = 43200;
         $config_changed = 1349162987;
         $config_key = $access_key;
         $ct = new \Cleantalk();
         $ct->work_url = $config_work_url;
         $ct->server_url = $ct_url;
         $ct->server_ttl = $config_ttl;
         $ct->server_changed = $config_changed;
         $sender_email = filter_var($member->email, FILTER_SANITIZE_EMAIL);
         $sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
         $ct_request = new \CleantalkRequest();
         $ct_request->auth_key = $config_key;
         if (isset($_POST['guest_name'])) {
             $ct_request->sender_nickname = $_POST['guest_name'];
         } else {
             $ct_request->sender_nickname = $member->name;
         }
         $ct_request->sender_ip = $sender_ip;
         $ct_request->sender_email = $sender_email;
         $ct_request->sender_info = $post_info;
         $ct_request->agent = 'ipboard4-18';
         $js_keys = array();
         for ($i = -5; $i <= 1; $i++) {
             $js_keys[] = md5(\IPS\Settings::i()->access_key . '+' . \IPS\Settings::i()->email_in . date("Ymd", time() + 86400 * $i));
         }
         $ct_request->js_on = in_array($_COOKIE['ct_checkjs'], $js_keys) ? 1 : 0;
         $ct_request->submit_time = $submit_time;
         $ct_request->message = $comment;
         $ct_result = $ct->isAllowMessage($ct_request);
         if (isset($ct_result->errno) && $ct_result->errno > 0) {
             //sendErrorMessage("CleanTalk has some problems, errno is ".$ct_result->errno.", errstr is '".$ct_result->errstr."'")
         }
         if ($ct_result->allow == 1) {
             // Not spammer.
             //call_user_func_array( 'parent::save', func_get_args() );
             return call_user_func_array('parent::create', func_get_args());
         } else {
             if (isset($_POST['topic_title'])) {
                 $topic->delete();
             }
             if (\IPS\Request::i()->isAjax()) {
                 $result = array("type" => "error", "message" => $ct_result->comment);
                 $result = json_encode($result);
                 \IPS\Output::i()->sendOutput($result, 200, "application/json");
             } else {
                 \IPS\Output::i()->sidebar['enabled'] = FALSE;
                 \IPS\Output::i()->sendOutput(\IPS\Theme::i()->getTemplate('global', 'core')->globalTemplate("Forbidden", \IPS\Theme::i()->getTemplate('global', 'core')->error("Forbidden", $ct_result->comment, 1, ""), array('app' => \IPS\Dispatcher::i()->application ? \IPS\Dispatcher::i()->application->directory : NULL, 'module' => \IPS\Dispatcher::i()->module ? \IPS\Dispatcher::i()->module->key : NULL, 'controller' => \IPS\Dispatcher::i()->controller)), 200, 'text/html', array(), FALSE, FALSE);
             }
             die;
             return call_user_func_array('parent::create', func_get_args());
         }
     }
     return call_user_func_array('parent::create', func_get_args());
 }
<?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));
}
示例#17
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');
     });
 }
示例#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 )
	{
		$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 );
   		}
	}
示例#19
0
 /**
  * Rewrite cache file
  * 
  * @return	array	Parsed list of markers
  */
 public function recacheJsonFile()
 {
     /* The upgrader kept firing this off whenever a group/marker was saved. */
     if (isset(\IPS\Request::i()->controller) and \IPS\Request::i()->controller == 'applications') {
         return;
     }
     $totalMarkers = 0;
     $memberMarkers = array();
     $customMarkers = array();
     try {
         $totalMarkers = \IPS\Db::i()->select('COUNT(*)', 'membermap_markers')->first();
     } catch (\Exception $ex) {
     }
     /* Trigger the queue if the marker count is too large to do in one go. */
     /* We'll hardcode the cap at 4000 now, that consumes roughly 50MB */
     /* We'll also see if we have enough memory available to do it */
     $currentMemUsage = memory_get_usage(TRUE);
     $memoryLimit = intval(ini_get('memory_limit'));
     $useQueue = false;
     if ($memoryLimit > 0) {
         $howMuchAreWeGoingToUse = $totalMarkers * 0.02;
         /* ~0.02MB pr marker */
         $howMuchAreWeGoingToUse += 10;
         /* Plus a bit to be safe */
         $howMuchDoWeHaveLeft = $memoryLimit - ceil($currentMemUsage / 1024 / 1024);
         if ($howMuchDoWeHaveLeft < $howMuchAreWeGoingToUse) {
             $useQueue = true;
         }
     }
     if ($totalMarkers > 4000) {
         $useQueue = true;
     }
     if ($useQueue or defined('MEMBERMAP_FORCE_QUEUE') and MEMBERMAP_FORCE_QUEUE) {
         \IPS\Task::queue('membermap', 'RebuildCache', array('class' => '\\IPS\\membermap\\Map'), 1, array('class'));
         return;
     }
     $selectColumns = array('mm.*', 'mg.*', 'm.member_id', 'm.name', 'm.members_seo_name', 'm.member_group_id', 'm.pp_photo_type', 'm.pp_main_photo', 'm.pp_thumb_photo');
     if (\IPS\Settings::i()->allow_gravatars) {
         $selectColumns[] = 'm.pp_gravatar';
         $selectColumns[] = 'm.email';
         $selectColumns[] = 'm.members_bitoptions';
     }
     /* Remember to update the queue too */
     $_markers = \IPS\Db::i()->select(implode(',', $selectColumns), array('membermap_markers', 'mm'), array('marker_open=1'), 'mg.group_position ASC, mm.marker_id DESC')->join(array('membermap_markers_groups', 'mg'), 'mm.marker_parent_id=mg.group_id')->join(array('core_members', 'm'), 'mm.marker_member_id=m.member_id');
     foreach ($_markers as $marker) {
         if ($marker['group_type'] == 'member') {
             $memberMarkers[] = $marker;
         } else {
             $customMarkers[] = $marker;
         }
     }
     $markers = $this->formatMemberMarkers($memberMarkers);
     $custMarkers = $this->formatCustomMarkers($customMarkers);
     $markers = array_merge($markers, $custMarkers);
     $markers = array_chunk($markers, 500);
     $this->deleteCacheFiles();
     $fileCount = 0;
     foreach ($markers as $chunk) {
         touch(\IPS\ROOT_PATH . '/datastore/membermap_cache/membermap-' . $fileCount . '.json');
         chmod(\IPS\ROOT_PATH . '/datastore/membermap_cache/membermap-' . $fileCount . '.json', \IPS\IPS_FILE_PERMISSION);
         \file_put_contents(\IPS\ROOT_PATH . '/datastore/membermap_cache/membermap-' . $fileCount . '.json', json_encode(array('markers' => $chunk, 'memUsage' => (memory_get_usage(TRUE) - $currentMemUsage) / 1024 . 'kB')));
         $fileCount++;
     }
     /* Store the timestamp of the cache to force the browser to purge its local storage */
     \IPS\Data\Store::i()->membermap_cacheTime = time();
 }
示例#20
0
$key = md5(md5(\IPS\Settings::i()->sql_user . \IPS\Settings::i()->sql_pass) . \IPS\Settings::i()->board_start);
$login_type = 'email';
/* Alowed IP addresses, uncomment for more security  */
// $ip_address = array('x.x.x.x'); // EDIT THIS LINE!!
/* -~-~-~-~-~-~ Stop Editing -~-~-~-~-~-~ */
if (isset($ip_address) and in_array($_SERVER['REMOTE_ADDR'], $ip_address) !== TRUE) {
    \IPS\Output::i()->json(array('status' => 'FAILD', 'msg' => 'BAD_IP_ADDR'));
}
if (!\IPS\Request::i()->do || !\IPS\Request::i()->id || !\IPS\Request::i()->key || !\IPS\Login::compareHashes(\IPS\Request::i()->key, md5($key . \IPS\Request::i()->id))) {
    \IPS\Output::i()->json(array('status' => 'FAILD', 'msg' => 'BAD_KEY'));
}
$member = \IPS\Member::load(\IPS\Request::i()->id, $login_type);
if (!$member->member_id) {
    \IPS\Output::i()->json(array('status' => 'FAILD', 'msg' => 'ACCOUNT_NOT_FOUND'));
}
switch (\IPS\Request::i()->do) {
    case 'get_salt':
        \IPS\Output::i()->json(array('status' => 'SUCCESS', 'pass_salt' => $member->members_pass_salt));
        break;
    case 'login':
        if (\IPS\Login::compareHashes($member->members_pass_hash, \IPS\Request::i()->password) === TRUE) {
            \IPS\Output::i()->json(array('status' => 'SUCCESS', 'connect_status' => $member->members_bitoptions['validating'] ? 'VALIDATING' : 'SUCCESS', 'email' => $member->email, 'name' => $member->name, 'connect_id' => $member->member_id));
        }
        break;
    case 'field':
        $fields = $member->profileFields();
        if (isset($fields['core_pfieldgroups_' . \IPS\Request::i()->fgroup]) and isset($fields['core_pfieldgroups_' . \IPS\Request::i()->fgroup]['core_pfield_' . \IPS\Request::i()->fid])) {
            \IPS\Output::i()->json(array('status' => 'SUCCESS', 'field_value' => $fields['core_pfieldgroups_' . \IPS\Request::i()->fgroup]['core_pfield_' . \IPS\Request::i()->fid]));
        }
        break;
}
示例#21
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;
 }
示例#22
0
/**
 * @brief		Zarinpal 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 {
    $res = $transaction->method->api(array('Amount' => $transaction->amount->amount / 10, 'Authority' => \IPS\Request::i()->Authority), TRUE);
    if ($res['Status'] == 100) {
        $transaction->gw_id = $res['RefID'];
        $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 Zarinpal
        \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'))));
}
示例#23
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');
     });
 }
示例#24
0
 /**
  * [ActiveRecord] Save Changed Columns
  *
  * @return	void
  * @note	We have to be careful when upgrading in case we are coming from an older version
  */
 public function save()
 {
     $new = $this->_new;
     $enabled = \IPS\Settings::i()->plugin_enabled;
     $access_key = \IPS\Settings::i()->access_key;
     if ($enabled == 1 && $new) {
         require_once dirname($_SERVER['SCRIPT_FILENAME']) . "/uploads/cleantalk.class.php";
         require_once dirname($_SERVER['SCRIPT_FILENAME']) . "/uploads/JSON.php";
         session_name('cleantalksession');
         if (!isset($_SESSION)) {
             session_start();
         }
         if (array_key_exists('formtime', $_SESSION)) {
             $submit_time = time() - (int) $_SESSION['formtime'];
         } else {
             $submit_time = NULL;
         }
         $_SESSION['formtime'] = time();
         $post_info = '';
         $lang = \IPS\Lang::getEnabledLanguages();
         $locale = $lang[\IPS\Lang::defaultLanguage()]->short;
         if (function_exists('json_encode')) {
             $arr = array('cms_lang' => $locale, 'REFFERRER' => $_SERVER['HTTP_REFERER'], 'USER_AGENT' => $_SERVER['HTTP_USER_AGENT']);
             $post_info = json_encode($arr);
         }
         if ($post_info === FALSE) {
             $post_info = '';
         }
         $ct_url = 'http://moderate.cleantalk.ru';
         $config_work_url = $ct_url;
         $config_ttl = 43200;
         $config_changed = 1349162987;
         $config_key = $access_key;
         $ct = new \Cleantalk();
         $ct->work_url = $config_work_url;
         $ct->server_url = $ct_url;
         $ct->server_ttl = $config_ttl;
         $ct->server_changed = $config_changed;
         $sender_email = filter_var($_POST['email_address'], FILTER_SANITIZE_EMAIL);
         $sender_ip = $ct->ct_session_ip($_SERVER['REMOTE_ADDR']);
         $ct_request = new \CleantalkRequest();
         $ct_request->auth_key = $config_key;
         $ct_request->sender_nickname = $_POST['username'];
         $ct_request->sender_ip = $sender_ip;
         $ct_request->sender_email = $sender_email;
         $ct_request->sender_info = $post_info;
         $ct_request->agent = 'ipboard4-18';
         //$ct_request->js_on = $_COOKIE['ct_checkjs'] == md5(\IPS\Settings::i()->access_key . '+' . \IPS\Settings::i()->email_in) ? 1 : 0;
         $ct_request->js_on = in_array($_COOKIE['ct_checkjs'], self::getCheckJSArray()) ? 1 : 0;
         $ct_request->submit_time = $submit_time;
         $ct_result = $ct->isAllowUser($ct_request);
         if (isset($ct_result->errno) && $ct_result->errno > 0) {
             //sendErrorMessage("CleanTalk has some problems, errno is ".$ct_result->errno.", errstr is '".$ct_result->errstr."'")
         }
         if ($ct_result->allow == 1) {
             // Not spammer.
             call_user_func_array('parent::save', func_get_args());
         } else {
             // Spammer - display message and exit.
             if (\IPS\Request::i()->isAjax()) {
                 $err_str = '<span style="color:#ab1f39;">' . $ct_result->comment . '</span><script>setTimeout("history.back()", 5000);</script>';
                 print $err_str;
             } else {
                 \IPS\Output::i()->sidebar['enabled'] = FALSE;
                 \IPS\Output::i()->sendOutput(\IPS\Theme::i()->getTemplate('global', 'core')->globalTemplate("Forbidden", \IPS\Theme::i()->getTemplate('global', 'core')->error("Forbidden", $ct_result->comment, 1, ""), array('app' => \IPS\Dispatcher::i()->application ? \IPS\Dispatcher::i()->application->directory : NULL, 'module' => \IPS\Dispatcher::i()->module ? \IPS\Dispatcher::i()->module->key : NULL, 'controller' => \IPS\Dispatcher::i()->controller)), 200, 'text/html', array(), FALSE, FALSE);
             }
             die;
         }
     }
     return call_user_func_array('parent::save', func_get_args());
 }
示例#25
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] ) );
}
示例#26
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(''));
示例#27
0
 /**
  * Member account has been updated
  *
  * @param	$member		\IPS\Member	Member updating profile
  * @param	$changes	array		The changes
  * @return	void
  */
 public function onProfileUpdate($member, $changes)
 {
     /* An endless loop is formed when \Item::createItem() is saving \Member, which then fire this membersync, which then calls \Item::createItem, and so on, and so on */
     static $wereDoneHere = false;
     if ($wereDoneHere) {
         return;
     }
     $wereDoneHere = true;
     if (isset($changes['name'])) {
         $existingMarker = \IPS\membermap\Map::i()->getMarkerByMember($member->member_id, FALSE, FALSE);
         if ($existingMarker instanceof \IPS\membermap\Markers\Markers) {
             $existingMarker->name = $member->name;
             $existingMarker->updated = time();
             $existingMarker->save();
         }
     }
     if (count($changes) and \IPS\Settings::i()->membermap_monitorLocationField and !$member->members_bitoptions['bw_is_spammer']) {
         if (\IPS\Settings::i()->membermap_monitorLocationField_groupPerm === '*' or \IPS\Member::loggedIn()->inGroup(explode(',', \IPS\Settings::i()->membermap_monitorLocationField_groupPerm))) {
             if (isset($changes['field_' . \IPS\Settings::i()->membermap_profileLocationField]) and !empty($changes['field_' . \IPS\Settings::i()->membermap_profileLocationField])) {
                 try {
                     $lat = $lng = $location = NULL;
                     $fieldValue = $changes['field_' . \IPS\Settings::i()->membermap_profileLocationField];
                     /* If it's an array, it might be from an address field, which already have the lat/lng data */
                     if (is_array(json_decode($fieldValue, TRUE))) {
                         $addressData = json_decode($fieldValue, TRUE);
                         if (is_float($addressData['lat']) and is_float($addressData['long'])) {
                             $lat = floatval($addressData['lat']);
                             $lng = floatval($addressData['long']);
                         }
                         $addressData['addressLines'][] = $addressData['city'];
                         if (count($addressData['addressLines'])) {
                             $location = implode(', ', $addressData['addressLines']);
                         }
                     } else {
                         /* Remove HTML, newlines, tab, etc, etc */
                         $fieldValue = preg_replace("/[\\x00-\\x20]|\\xc2|\\xa0+/", ' ', strip_tags($fieldValue));
                         $fieldValue = trim(preg_replace("/\\s\\s+/", ' ', $fieldValue));
                         /* To my understanding we're not allowed to use \IPS\Geolocation, as that uses Google API, and we're not showing the info on a Google Map. */
                         $nominatim = \IPS\membermap\Map::i()->getLatLng($fieldValue);
                         if (is_array($nominatim) and count($nominatim)) {
                             $lat = $nominatim['lat'];
                             $lng = $nominatim['lng'];
                             $location = $nominatim['location'];
                         }
                     }
                     if ($lat and $lng) {
                         $existingMarker = \IPS\membermap\Map::i()->getMarkerByMember($member->member_id, FALSE);
                         if ($existingMarker instanceof \IPS\membermap\Markers\Markers) {
                             $marker = $existingMarker;
                             $marker->updated = time();
                         } else {
                             $groupId = \IPS\membermap\Map::i()->getMemberGroupId();
                             $marker = \IPS\membermap\Markers\Markers::createItem($member, \IPS\Request::i()->ipAddress(), new \IPS\DateTime(), \IPS\membermap\Markers\Groups::load($groupId));
                         }
                         $marker->name = $member->name;
                         $marker->lat = $lat;
                         $marker->lon = $lng;
                         $marker->location = $location ?: $fieldValue;
                         /* Save and add to search index */
                         $marker->save();
                         \IPS\Content\Search\Index::i()->index($marker);
                     }
                 } catch (\Exception $e) {
                     /* Something went wrong. Such as the input field being an editor */
                     \IPS\Log::log($e, 'membermap');
                     return false;
                 }
             }
         }
     }
 }
 /**
  * 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;
 }