/** * @return mixed * @throws NoAPIKey */ public function hasApiKey() { // Has an API key been supplied? if (($api_key = \IPS\Settings::i()->vizionyoutube_api_key) === NULL) { throw new NoAPIKey('NO_API_KEY'); } return $api_key; }
/** * Authorize * * @param \IPS\nexus\Transaction $transaction Transaction * @param array|\IPS\nexus\Customer\CreditCard $values Values from form OR a stored card object if this gateway supports them * @param \IPS\nexus\Fraud\MaxMind\Request|NULL $maxMind *If* MaxMind is enabled, the request object will be passed here so gateway can additional data before request is made * @return \IPS\DateTime|NULL Auth is valid until or NULL to indicate auth is good forever * @throws \LogicException Message will be displayed to user */ public function auth(\IPS\nexus\Transaction $transaction, $values, \IPS\nexus\Fraud\MaxMind\Request $maxMind = NULL) { $transaction->save(); $data = array('amount' => $transaction->amount->amount, 'redirect' => urlencode((string) \IPS\Settings::i()->base_url . 'applications/nexus/interface/gateways/payline.php?nexusTransactionId=' . $transaction->id)); $result = $this->api($data); if ($result > 0) { \IPS\Output::i()->redirect(\IPS\Http\Url::external("http://payline.ir/payment/gateway-{$result}")); } throw new \RuntimeException(); }
/** * Authorize * * @param \IPS\nexus\Transaction $transaction Transaction * @param array|\IPS\nexus\Customer\CreditCard $values Values from form OR a stored card object if this gateway supports them * @param \IPS\nexus\Fraud\MaxMind\Request|NULL $maxMind *If* MaxMind is enabled, the request object will be passed here so gateway can additional data before request is made * @return \IPS\DateTime|NULL Auth is valid until or NULL to indicate auth is good forever * @throws \LogicException Message will be displayed to user */ public function auth(\IPS\nexus\Transaction $transaction, $values, \IPS\nexus\Fraud\MaxMind\Request $maxMind = NULL) { $transaction->save(); $data = array('amount' => $transaction->amount->amount / 10, 'msg' => urlencode($transaction->invoice->title), 'orderId' => $transaction->id, 'callbackUrl' => (string) \IPS\Settings::i()->base_url . 'applications/nexus/interface/gateways/jahanpay.php'); $res = $this->api($data); if (!empty($res)) { \IPS\Output::i()->redirect(\IPS\Http\Url::external('http://www.jahanpay.com/pay_invoice/' . $res)); } throw new \RuntimeException(); }
/** * Get an array of enabled maps * @return array List of maps */ public static function getEnabledMaps() { $defaultMaps = static::$defaultMaps; if (\IPS\Settings::i()->membermap_activemaps) { $maps = json_decode(\IPS\Settings::i()->membermap_activemaps, true); if (is_array($maps)) { $defaultMaps = $maps; } } return $defaultMaps; }
public function sfw_die() { $key = \IPS\Settings::i()->access_key; $sfw_die_page = file_get_contents(dirname(__FILE__) . "/sfw_die_page.html"); $sfw_die_page = str_replace("{REMOTE_ADDRESS}", $this->blocked_ip, $sfw_die_page); $sfw_die_page = str_replace("{REQUEST_URI}", $_SERVER['REQUEST_URI'], $sfw_die_page); $sfw_die_page = str_replace("{SFW_COOKIE}", md5($this->blocked_ip . $key), $sfw_die_page); @header('HTTP/1.0 403 Forbidden'); print $sfw_die_page; die; }
/** * Authorize * * @param \IPS\nexus\Transaction $transaction Transaction * @param array|\IPS\nexus\Customer\CreditCard $values Values from form OR a stored card object if this gateway supports them * @param \IPS\nexus\Fraud\MaxMind\Request|NULL $maxMind *If* MaxMind is enabled, the request object will be passed here so gateway can additional data before request is made * @return \IPS\DateTime|NULL Auth is valid until or NULL to indicate auth is good forever * @throws \LogicException Message will be displayed to user */ public function auth(\IPS\nexus\Transaction $transaction, $values, \IPS\nexus\Fraud\MaxMind\Request $maxMind = NULL) { $transaction->save(); $data = array('Amount' => $transaction->amount->amount / 10, 'Description' => $transaction->invoice->title, 'Email' => $transaction->member->email, 'Mobile' => $transaction->member->cm_phone, 'CallbackURL' => (string) \IPS\Settings::i()->base_url . 'applications/nexus/interface/gateways/zarinpal.php?nexusTransactionId=' . $transaction->id); $res = $this->api($data); if ($res['Status'] == 100) { $settings = json_decode($this->settings, TRUE); \IPS\Output::i()->redirect(\IPS\Http\Url::external('https://www.zarinpal.com/pg/StartPay/' . $res['Authority'] . '' . ($settings['zarin_gate'] ? '/ZarinGate' : ''))); } throw new \RuntimeException(); }
/** * Show the map * * @return void */ protected function manage() { $markers = array(); /* Rebuild JSON cache if needed */ if (!\IPS\membermap\Map::i()->checkForCache()) { /* We clicked the tools menu item to force a rebuild */ if (\IPS\Request::i()->isAjax()) { \IPS\Output::i()->redirect(\IPS\Http\Url::internal('app=membermap&module=membermap&controller=showmap', NULL, 'membermap')); } } $cacheTime = isset(\IPS\Data\Store::i()->membermap_cacheTime) ? \IPS\Data\Store::i()->membermap_cacheTime : 0; $getByUser = intval(\IPS\Request::i()->member_id); if (\IPS\Request::i()->filter == 'getByUser' and $getByUser) { $markers = \IPS\membermap\Map::i()->getMarkerByMember($getByUser); } /* Get enabled maps */ $defaultMaps = \IPS\membermap\Application::getEnabledMaps(); /* Add/edit marker permissions */ $groupId = \IPS\membermap\Map::i()->getMemberGroupId(); $existing = \IPS\membermap\Map::i()->getMarkerByMember(\IPS\Member::loggedIn()->member_id, FALSE); $canAdd = \IPS\membermap\Markers\Groups::load($groupId)->can('add'); $canEdit = $existing ? $existing->canEdit() : false; $canDelete = $existing ? $existing->canDelete() : false; /* Load JS and CSS */ \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('leaflet/leaflet-src.js', 'membermap', 'interface')); \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('leaflet/plugins/Control.FullScreen.js', 'membermap', 'interface')); \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('leaflet/plugins/Control.Loading.js', 'membermap', 'interface')); \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('leaflet/plugins/leaflet-providers.js', 'membermap', 'interface')); \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('leaflet/plugins/leaflet.awesome-markers.js', 'membermap', 'interface')); \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('leaflet/plugins/leaflet.contextmenu-src.js', 'membermap', 'interface')); \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('leaflet/plugins/leaflet.markercluster-src.js', 'membermap', 'interface')); \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('leaflet/plugins/subgroup.js', 'membermap', 'interface')); \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_main.js', 'membermap', 'front')); \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('jquery/jquery-ui.js', 'membermap', 'interface')); \IPS\Output::i()->cssFiles = array_merge(\IPS\Output::i()->cssFiles, \IPS\Theme::i()->css('membermap.css', 'membermap')); \IPS\Output::i()->cssFiles = array_merge(\IPS\Output::i()->cssFiles, \IPS\Theme::i()->css('leaflet.css', 'membermap', 'global')); \IPS\Output::i()->cssFiles = array_merge(\IPS\Output::i()->cssFiles, \IPS\Theme::i()->css('jquery-ui.css', 'membermap', 'global')); \IPS\Output::i()->cssFiles = array_merge(\IPS\Output::i()->cssFiles, \IPS\Theme::i()->css('plugins.combined.css', 'membermap')); \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('__app_membermap'); \IPS\Output::i()->sidebar['enabled'] = FALSE; /* Update session location */ \IPS\Session::i()->setLocation(\IPS\Http\Url::internal('app=membermap&module=membermap&controller=showmap', 'front', 'membermap'), array(), 'loc_membermap_viewing_membermap'); /* Things we need to know in the Javascript */ \IPS\Output::i()->jsVars = array_merge(\IPS\Output::i()->jsVars, array('is_supmod' => \IPS\Member::loggedIn()->modPermission() ?: 0, 'member_id' => \IPS\Member::loggedIn()->member_id ?: 0, 'membermap_canAdd' => $canAdd ?: 0, 'membermap_canEdit' => $canEdit ?: 0, 'membermap_canDelete' => $canDelete ?: 0, 'membermap_cacheTime' => $cacheTime, 'membermap_bbox' => json_decode(\IPS\Settings::i()->membermap_bbox), 'membermap_bbox_zoom' => intval(\IPS\Settings::i()->membermap_bbox_zoom), 'membermap_defaultMaps' => $defaultMaps, 'membermap_mapquestAPI' => \IPS\membermap\Application::getApiKeys('mapquest'), 'membermap_enable_clustering' => \IPS\Settings::i()->membermap_enable_clustering == 1 ? 1 : 0, 'membermap_groupByMemberGroup' => \IPS\Settings::i()->membermap_groupByMemberGroup == 1 ? 1 : 0)); \IPS\Output::i()->endBodyCode .= <<<EOF \t\t<script type='text/javascript'> \t\t\tips.membermap.initMap(); \t\t</script> EOF; \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('map')->showMap($markers, $cacheTime, $canAdd, $canEdit); }
/** * ... * * @return array If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops) */ public function step1() { /* Remove MapQuest.OSM, as it's no longer "free" */ $maps = json_decode(\IPS\Settings::i()->membermap_activemaps, true); if (is_array($maps)) { $osm = array_search('MapQuestOpen.OSM', $maps['basemaps']); if ($osm !== FALSE) { $maps['basemaps'][$osm] = 'OpenStreetMap.France'; $maps['basemaps'] = array_unique($maps['basemaps'], SORT_REGULAR); \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); } } return TRUE; }
public function getTitle($title) { if (\IPS\Settings::i()->cleantalk_sfw == 1) { $is_sfw_check = true; $ip = $this->CleantalkGetIP(); $ip = array_unique($ip); $key = \IPS\Settings::i()->access_key; for ($i = 0; $i < sizeof($ip); $i++) { if (isset($_COOKIE['ct_sfw_pass_key']) && $_COOKIE['ct_sfw_pass_key'] == md5($ip[$i] . $key)) { $is_sfw_check = false; if (isset($_COOKIE['ct_sfw_passed'])) { @setcookie('ct_sfw_passed', '0', 1, "/"); } } } if ($is_sfw_check) { include_once dirname(__FILE__) . "/uploads/cleantalk-sfw.class.php"; $sfw = new \CleanTalkSFW(); $sfw->cleantalk_get_real_ip(); $sfw->check_ip(); if ($sfw->result) { $sfw->sfw_die(); } } } if (session_id() == '') { session_start(); } $show_link = \IPS\Settings::i()->show_link; $html = ' <script type="text/javascript"> function ctSetCookie(c_name, value, def_value) { document.cookie = c_name + "=" + escape(value.replace(/^def_value$/, value)) + "; path=/"; } ctSetCookie("%s", "%s", "%s"); </script> '; $ct_checkjs_key = md5(\IPS\Settings::i()->access_key . '+' . \IPS\Settings::i()->email_in . date("Ymd", time())); $html = sprintf($html, "ct_checkjs", $ct_checkjs_key, 0); if ($show_link == 1) { $html .= "<div id='cleantalk_footer_link' style='width:100%;text-align:center;'><a href='https://cleantalk.org/ips-cs-4-anti-spam-plugin'>IPS spam</a> blocked by CleanTalk.</div>"; } $this->endBodyCode .= $html; return $title; }
/** * Update default maps * @return void */ public function update() { $maps = \IPS\Request::i()->maps; if (!isset($maps['basemaps'])) { /* You can't have a map with no basemap. Defaulting to OpenStreetMap.France */ $maps['basemaps'] = array('OpenStreetMap.France'); } if (!isset($maps['overlays'])) { $maps['overlays'] = array(); } \IPS\Settings::i()->membermap_activemaps = json_encode($maps); \IPS\Db::i()->update('core_sys_conf_settings', array('conf_value' => \IPS\Settings::i()->membermap_activemaps), array('conf_key=?', 'membermap_activemaps')); unset(\IPS\Data\Store::i()->settings); if (\IPS\Request::i()->isAjax()) { \IPS\Output::i()->output = 1; return; } \IPS\Output::i()->redirect(\IPS\Http\Url::internal("app=membermap&module=membermap&controller=mapmanager"), 'saved'); }
/** * ... * * @return void */ protected function manage() { \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__membermap_membermap_settings'); \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('jquery/jquery-ui.js', 'membermap', 'interface')); \IPS\Output::i()->jsFiles = array_merge(\IPS\Output::i()->jsFiles, \IPS\Output::i()->js('admin_membermap.js', 'membermap', 'admin')); \IPS\Output::i()->cssFiles = array_merge(\IPS\Output::i()->cssFiles, \IPS\Theme::i()->css('jquery-ui.css', 'membermap', 'global')); \IPS\Output::i()->jsVars['membermap_mapquestAPI'] = \IPS\membermap\Application::getApiKeys('mapquest'); $form = new \IPS\Helpers\Form(); $form->addHeader('api_settings'); $form->add(new \IPS\Helpers\Form\Text('membermap_mapQuestAPI', \IPS\Settings::i()->membermap_mapQuestAPI, TRUE, array(), NULL, NULL, NULL, 'membermap_mapQuestAPI')); if (!empty(\IPS\Settings::i()->membermap_mapQuestAPI)) { $form->attributes['data-controller'] = 'membermap.admin.membermap.settings'; $form->attributes['id'] = 'membermap_form_settings'; $form->addHeader('map_settings'); $form->add(new \IPS\Helpers\Form\YesNo('membermap_groupByMemberGroup', \IPS\Settings::i()->membermap_groupByMemberGroup)); $form->add(new \IPS\Helpers\Form\YesNo('membermap_enable_clustering', \IPS\Settings::i()->membermap_enable_clustering)); $form->add(new \IPS\Helpers\Form\Text('membermap_bbox_location', \IPS\Settings::i()->membermap_bbox_location, FALSE, array(), NULL, NULL, NULL, 'membermap_bbox_location')); $form->add(new \IPS\Helpers\Form\Number('membermap_bbox_zoom', intval(\IPS\Settings::i()->membermap_bbox_zoom), FALSE, array('min' => 1, 'max' => 18))); $form->hiddenValues['membermap_bbox'] = \IPS\Settings::i()->membermap_bbox; $form->addHeader('membermap_autoUpdate'); $profileFields = array('' => ' -- ' . \IPS\Member::loggedIn()->language()->addToStack('membermap_profileLocationField') . ' -- '); foreach (\IPS\core\ProfileFields\Field::fields(array(), \IPS\core\ProfileFields\Field::PROFILE) as $group => $fields) { foreach ($fields as $id => $field) { $profileFields['core_pfieldgroups_' . $group][$id] = $field->name; } } $form->add(new \IPS\Helpers\Form\YesNo('membermap_monitorLocationField', \IPS\Settings::i()->membermap_monitorLocationField, FALSE, array('togglesOn' => array('membermap_profileLocationField', 'membermap_monitorLocationField_groupPerm', 'membermap_syncLocationField')))); $form->add(new \IPS\Helpers\Form\Select('membermap_profileLocationField', \IPS\Settings::i()->membermap_profileLocationField ? intval(\IPS\Settings::i()->membermap_profileLocationField) : NULL, FALSE, array('options' => $profileFields), NULL, NULL, NULL, 'membermap_profileLocationField')); $form->add(new \IPS\Helpers\Form\Select('membermap_monitorLocationField_groupPerm', \IPS\Settings::i()->membermap_monitorLocationField_groupPerm != '' ? \IPS\Settings::i()->membermap_monitorLocationField_groupPerm === '*' ? '*' : explode(",", \IPS\Settings::i()->membermap_monitorLocationField_groupPerm) : '*', FALSE, array('options' => \IPS\Member\Group::groups(), 'multiple' => TRUE, 'parse' => 'normal', 'unlimited' => '*', 'unlimitedLang' => 'all'), NULL, NULL, NULL, 'membermap_monitorLocationField_groupPerm')); $form->add(new \IPS\Helpers\Form\YesNo('membermap_syncLocationField', \IPS\Settings::i()->membermap_syncLocationField, FALSE, array(), NULL, NULL, NULL, 'membermap_syncLocationField')); } if ($values = $form->values(TRUE)) { $values['membermap_bbox'] = \IPS\Request::i()->membermap_bbox; if (empty($values['membermap_bbox_location'])) { $values['membermap_bbox'] = ""; } \IPS\DB::i()->update('core_tasks', array('enabled' => isset($values['membermap_syncLocationField']) and $values['membermap_syncLocationField'] ? 1 : 0), array('`key`=?', 'locationSync')); $form->saveAsSettings($values); \IPS\Session::i()->log('acplogs__membermap_settings'); \IPS\Output::i()->redirect(\IPS\Http\Url::internal("app=membermap&module=membermap&controller=settings"), 'saved'); } \IPS\Output::i()->output = $form; }
/** * Run Background Task * * @param mixed $data Data as it was passed to \IPS\Task::queue() * @param int $offset Offset * @return int|null New offset or NULL if complete * @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete */ public function run($data, $offset) { $currentMemUsage = memory_get_usage(TRUE); /* Wipe out the old files on the first run */ if ($offset === 0) { \IPS\membermap\Map::i()->deleteCacheFiles(); } $count = 0; $memberMarkers = array(); $customMarkers = array(); $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 membermap\Map too */ $_markers = \IPS\Db::i()->select(implode(',', $selectColumns), array('membermap_markers', 'mm'), array('marker_open=1'), 'mg.group_position ASC, mm.marker_id DESC', array($offset, $this->perCycle))->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) { $count++; if ($marker['group_type'] == 'member') { $memberMarkers[] = $marker; } else { $customMarkers[] = $marker; } } if ($count > 0) { $markers = \IPS\membermap\Map::i()->formatMemberMarkers($memberMarkers); $custMarkers = \IPS\membermap\Map::i()->formatCustomMarkers($customMarkers); $markers = array_merge($markers, $custMarkers); $fileNumber = $offset / $this->perCycle; touch(\IPS\ROOT_PATH . '/datastore/membermap_cache/membermap-' . $fileNumber . '.json'); chmod(\IPS\ROOT_PATH . '/datastore/membermap_cache/membermap-' . $fileNumber . '.json', \IPS\IPS_FILE_PERMISSION); \file_put_contents(\IPS\ROOT_PATH . '/datastore/membermap_cache/membermap-' . $fileNumber . '.json', json_encode(array('markers' => $markers, 'memUsage' => (memory_get_usage(TRUE) - $currentMemUsage) / 1024 . 'kB', 'fromQueue' => 1))); /* Store the timestamp of the cache to force the browser to purge its local storage */ \IPS\Data\Store::i()->membermap_cacheTime = time(); } if (!$count) { throw new \IPS\Task\Queue\OutOfRangeException(); } return $offset + $count; }
public static function hookData() { $last_check = intval(\IPS\Settings::i()->cleantalk_last_check); $last_status = intval(\IPS\Settings::i()->cleantalk_last_status); $api_key = \IPS\Settings::i()->access_key; $result = ''; $html = ''; if (time() - $last_check > 86400 && $api_key != 0 && $api_key != '') { $data = array(); $data['auth_key'] = $api_key; $data['method_name'] = 'notice_validate_key'; if (!function_exists('sendRawRequest')) { require_once dirname($_SERVER['SCRIPT_FILENAME']) . "/../uploads/cleantalk.class.php"; require_once dirname($_SERVER['SCRIPT_FILENAME']) . "/../uploads/JSON.php"; } $result = sendRawRequest('https://api.cleantalk.org', $data); $result = json_decode(trim($result)); if (isset($result->valid)) { $new_status = intval($result->valid); \IPS\Settings::i()->cleantalk_last_status = $new_status; } else { $new_status = 0; } if ($new_status == 1 && $last_status == 0) { \IPS\Settings::i()->cleantalk_show_banner = 1; } \IPS\Settings::i()->cleantalk_last_check = time(); } if (isset($_COOKIE['cleantalk_close_banner'])) { \IPS\Settings::i()->cleantalk_show_banner = 0; } $show_banner = intval(\IPS\Settings::i()->cleantalk_show_banner); if ($show_banner == 1) { $html = "<div style='width:99%;background: #90EE90; padding:10px;border: 2px dashed green;margin:3px;font-size:16px;text-align:center;' id='cleantalk_banner'>Like antispam by CleanTalk? <a href='https://community.invisionpower.com/files/file/7706-anti-spam-ips4/' target='_blank'>Leave a review!</a><div style='float:right;margin-top:-5px;margin-right:-5px;'><a href=# style='text-decoration:none;font-size:14px;font-weight:600;' onclick='jQuery(\"#cleantalk_banner\").hide(\"slow\");document.cookie=\"cleantalk_close_banner = 1;\"'>X</a></div></div>"; } return array_merge_recursive(array('globalTemplate' => array(0 => array('selector' => '#acpPageHeader', 'type' => 'add_after', 'content' => $html))), parent::hookData()); }
/** * 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(); }
$values = $form->values(); $ct = new \Cleantalk(); $ct->work_url = 'http://moderate.cleantalk.ru'; $ct->server_url = 'http://moderate.cleantalk.ru'; $ct->server_ttl = 43200; $ct_request = new \CleantalkRequest(); $ct_request->auth_key = $values['access_key']; $ct_request->sender_nickname = 'CleanTalk'; $ct_request->sender_ip = $_SERVER['REMOTE_ADDR']; $ct_request->sender_email = '*****@*****.**'; $ct_request->agent = 'ipboard4-18'; $ct_request->js_on = 1; $ct_request->message = 'This message is a test to check the connection to the CleanTalk servers.'; $ct_result = $ct->isAllowMessage($ct_request); $form->saveAsSettings(); if (\IPS\Settings::i()->cleantalk_sfw == 1) { $sql = "DROP TABLE IF EXISTS `cleantalk_sfw`"; $result = IPS\Db::i()->query($sql); $sql = "CREATE TABLE IF NOT EXISTS `cleantalk_sfw` (\n`network` int(11) unsigned NOT NULL,\n`mask` int(11) unsigned NOT NULL,\nINDEX ( `network` , `mask` )\n) ENGINE = MYISAM "; $result = IPS\Db::i()->query($sql); $data = array('auth_key' => $values['access_key'], 'method_name' => '2s_blacklists_db'); $result = sendRawRequest('https://api.cleantalk.org/2.1', $data, false); $result = json_decode($result, true); if (isset($result['data'])) { $result = $result['data']; $query = "INSERT INTO `cleantalk_sfw` VALUES "; for ($i = 0; $i < sizeof($result); $i++) { if ($i == sizeof($result) - 1) { $query .= "(" . $result[$i][0] . "," . $result[$i][1] . ")"; } else { $query .= "(" . $result[$i][0] . "," . $result[$i][1] . "), ";
/** * @param \IPS\nexus\Invoice $invoice */ private function registerMember(\IPS\nexus\Invoice &$invoice) { // Create the member account if this was a guest if (!$invoice->member->member_id and $invoice->guest_data) { $profileFields = $invoice->guest_data['profileFields']; $memberToSave = new \IPS\nexus\Customer(); foreach ($invoice->guest_data['member'] as $k => $v) { $memberToSave->_data[$k] = $v; $memberToSave->changed[$k] = $v; } $memberToSave->save(); $invoice->member = $memberToSave; $invoice->guest_data = NULL; $invoice->save(); // If we've entered an address during checkout, save it if ($invoice->billaddress !== NULL) { $billing = new \IPS\nexus\Customer\Address(); $billing->member = $invoice->member; $billing->address = $invoice->billaddress; $billing->primary_billing = 1; $billing->save(); } if ($this->shipaddress !== NULL) { $shipping = new \IPS\nexus\Customer\Address(); $shipping->member = $invoice->member; $shipping->address = $invoice->shipaddress; $shipping->primary_shipping = 1; $shipping->save(); } $profileFields['member_id'] = $memberToSave->member_id; \IPS\Db::i()->replace('core_pfields_content', $profileFields); // Notify the incoming mail address if (\IPS\Settings::i()->new_reg_notify) { \IPS\Email::buildFromTemplate('core', 'registration_notify', array($memberToSave, $profileFields))->send(\IPS\Settings::i()->email_in); } // Update associated transactions \IPS\Db::i()->update('nexus_transactions', array('t_member' => $invoice->member->member_id), array('t_invoice=? AND t_member=0', $invoice->id)); } }
<?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'))));
//<?php $form->add(new \IPS\Helpers\Form\YesNo('querybox_enable_execute_query', !is_null(\IPS\Settings::i()->querybox_enable_execute_query) ? \IPS\Settings::i()->querybox_enable_execute_query : TRUE)); $form->add(new \IPS\Helpers\Form\YesNo('querybox_enable_versions_query_templates', !is_null(\IPS\Settings::i()->querybox_enable_versions_query_templates) ? \IPS\Settings::i()->querybox_enable_versions_query_templates : TRUE)); $form->add(new \IPS\Helpers\Form\YesNo('querybox_enable_versions_query_execute', !is_null(\IPS\Settings::i()->querybox_enable_versions_query_execute) ? \IPS\Settings::i()->querybox_enable_versions_query_execute : TRUE)); if ($values = $form->values()) { $form->saveAsSettings(); return TRUE; } return $form;
/** * Get the queries rows for a version * * @param int $long Version ID * @return array */ public function _getQueriesRows($long) { $enabled = \IPS\Settings::i()->querybox_enable_versions_query_execute; if (!is_null($enabled) and !$enabled) { return call_user_func_array('parent::_getQueriesRows', func_get_args()); } $queries = $this->_getQueries($long); $order = 1; $rows = array(); foreach ($queries as $qid => $data) { $params = array(); if (isset($data['params']) and is_array($data['params'])) { foreach ($data['params'] as $v) { $params[] = var_export($v, TRUE); } } $rows["{$long}.{$qid}"] = \IPS\Theme::i()->getTemplate('trees', 'core')->row($this->url, "{$long}.{$qid}", str_replace('<?php', '', highlight_string("<?php \\IPS\\Db::i()->{$data['method']}( " . implode(', ', $params) . " )", TRUE)), FALSE, array('execute' => array('icon' => 'play-circle', 'title' => 'versions_query_execute', 'link' => \IPS\Http\Url::internal("app=core&module=applications&controller=developer&appKey={$this->application->directory}&do=executeVersionQuery&version={$long}&query={$qid}"), 'data' => array('confirm' => '')), 'delete' => array('icon' => 'times-circle', 'title' => 'delete', 'link' => \IPS\Http\Url::internal("app=core&module=applications&controller=developer&appKey={$this->application->directory}&do=deleteVersionQuery&version={$long}&query={$qid}"), 'data' => array('delete' => ''))), NULL, NULL, $order, FALSE, NULL, NULL, NULL, TRUE); $order++; } return $rows; }
/** * 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); } }
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()); }
/** * [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()); }
/** * 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 ); } }
<?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> */ $_SERVER['SCRIPT_FILENAME'] = __FILE__; $path = ''; require_once $path . 'init.php'; \IPS\Session\Front::i(); $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':
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; }
//<?php $form->add(new \IPS\Helpers\Form\Text('plugin_example_setting', \IPS\Settings::i()->plugin_example_setting)); if ($values = $form->values()) { $form->saveAsSettings(); return TRUE; } return $form;
/** * Authenticate * * @param string $url The URL for the login page * @param \IPS\Member $member If we want to integrate this login method with an existing member, provide the * member object * * @return \IPS\Member * @throws \IPS\Login\Exception */ public function authenticate($url, $member = null) { try { $steamId = $this->validate(); if (!$steamId) { throw new \IPS\Login\Exception('generic_error', \IPS\Login\Exception::INTERNAL_ERROR); } /* If an api key is provided, attempt to load the user from steam */ $response = null; $userData = null; if ($this->settings['api_key']) { try { $response = \IPS\Http\Url::external("http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key={$this->settings['api_key']}&steamids={$steamId}")->request()->get()->decodeJson(); if ($response) { // Get the first player $userData = $response['response']['players'][0]; } } catch (\IPS\Http\Request\Exception $e) { throw new \IPS\Login\Exception('generic_error', \IPS\Login\Exception::INTERNAL_ERROR, $e); } } /* Find member */ $newMember = false; if ($member === null) { try { $memberData = \IPS\Db::i()->select('*', 'core_members', array('steamid=?', $steamId))->first(); $member = \IPS\Member::constructFromData($memberData); } catch (\UnderflowException $e) { $member = \IPS\Member::load(null); } if (!$member->member_id) { if ($this->settings['api_key']) { try { $gameslist = \IPS\Http\Url::external("http://api.steampowered.com/IPlayerService/GetOwnedGames/v0001/?key={$this->settings['api_key']}&steamid={$steamId}")->request()->get()->decodeJson(); $hasgmod = false; if (!isset($gameslist) or !isset($gameslist['response']) or !isset($gameslist['response']['games'])) { throw new \IPS\Login\Exception('Your Steam account is private and we can\'t tell if you own Garry\'s Mod. Please change your game library to public!', \IPS\Login\Exception::NO_ACCOUNT, $e); } foreach ($gameslist['response']['games'] as $game) { if ($game['appid'] == 4000) { $hasgmod = true; } } if (!$hasgmod) { throw new \IPS\Login\Exception('Your Steam account must own Garry\'s Mod to login.', \IPS\Login\Exception::NO_ACCOUNT, $e); } } catch (\IPS\Http\Request\Exception $e) { throw new \IPS\Login\Exception('generic_error', \IPS\Login\Exception::INTERNAL_ERROR, $e); } } $member = new \IPS\Member(); $member->member_group_id = \IPS\Settings::i()->member_group; if (\IPS\Settings::i()->reg_auth_type == 'admin' or \IPS\Settings::i()->reg_auth_type == 'admin_user') { $member->members_bitoptions['validating'] = true; } if (isset($userData)) { if ($this->settings['use_steam_name']) { $existingUsername = \IPS\Member::load($userData['personaname'], 'name'); if (!$existingUsername->member_id) { $member->name = $userData['personaname']; } } $member->profilesync = json_encode(array(static::$loginKey => array('photo' => true, 'cover' => false, 'status' => ''))); } $newMember = true; } } /* Create member */ $member->steamid = $steamId; $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\Steam($member); $sync->sync(); } /* Return */ return $member; } catch (\IPS\Http\Request\Exception $e) { throw new \IPS\Login\Exception('generic_error', \IPS\Login\Exception::INTERNAL_ERROR); } }
/** * Filling the gaps in marker groups * * @return array If returns TRUE, upgrader will proceed to next step. If it returns any other value, it will set this as the value of the 'extra' GET parameter and rerun this step (useful for loops) */ public function step2() { $order = 2; foreach (\IPS\Db::i()->select('*', 'membermap_markers_groups') as $group) { $group = \IPS\membermap\Markers\Groups::constructFromData($group); \IPS\Lang::saveCustom('membermap', "membermap_marker_group_{$group->id}", trim($group->name)); \IPS\Lang::saveCustom('membermap', "membermap_marker_group_{$group->id}_JS", trim($group->name), 1); $group->name_seo = \IPS\Http\Url::seoTitle(trim($group->name)); if ($group->type == 'custom') { $group->position = $order; $group->moderate = 1; $order++; } try { $latestMarker = \IPS\Db::i()->select('*', 'membermap_markers', array('marker_open=? and marker_parent_id=?', 1, $group->id), 'marker_updated DESC, marker_added DESC', array(0, 1))->first(); $group->last_marker_id = $latestMarker['marker_id']; $group->last_marker_date = $latestMarker['marker_added']; } catch (\UnderflowException $e) { $group->last_marker_id = 0; $group->last_marker_date = 0; } $group->save(); /* Reset 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'])); } return TRUE; }
/** * 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; } } } } }
/** * Build a generator form for this comment * * @param \IPS\faker\Decorators\Form $form * @return void */ public function buildGenerateForm(&$form) { $groups = \IPS\Member\Group::groups(); $groupOpts = array(); foreach ($groups as $group) { $groupOpts[$group->g_id] = $group->name; } $form->langPrefix = 'core_members_faker_activerecords'; $form->add(new \IPS\Helpers\Form\NumberRange('record_range', array('start' => 3, 'end' => 5), TRUE, array('start' => array('min' => 1)))); $form->add(new \IPS\Helpers\Form\Select('member_group', \IPS\Settings::i()->member_group, true, array('options' => $groupOpts))); $form->add(new \IPS\Helpers\Form\YesNo('profile_photo', true)); $form->add(new \IPS\Helpers\Form\YesNo('password')); }