Ejemplo n.º 1
0
 /**
  * ...
  *
  * @return	void
  */
 protected function manage()
 {
     $defaultMaps = \IPS\membermap\Application::getEnabledMaps();
     \IPS\Output::i()->jsVars['membermap_defaultMaps'] = $defaultMaps;
     \IPS\Output::i()->sidebar['actions']['preview'] = array('icon' => 'eye', 'link' => \IPS\Http\Url::external('https://leaflet-extras.github.io/leaflet-providers/preview/index.html'), 'title' => 'membermap_mapmanager_preview', 'target' => '_blank');
     \IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__membermap_membermap_mapmanager');
     \IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate('mapmanager')->wrapper();
 }
Ejemplo n.º 2
0
 /**
  * Authorize
  *
  * @param	\IPS\nexus\Transaction					$transaction	Transaction
  * @param	array|\IPS\nexus\Customer\CreditCard	$values			Values from form OR a stored card object if this gateway supports them
  * @param	\IPS\nexus\Fraud\MaxMind\Request|NULL	$maxMind		*If* MaxMind is enabled, the request object will be passed here so gateway can additional data before request is made	
  * @return	\IPS\DateTime|NULL		Auth is valid until or NULL to indicate auth is good forever
  * @throws	\LogicException			Message will be displayed to user
  */
 public function auth(\IPS\nexus\Transaction $transaction, $values, \IPS\nexus\Fraud\MaxMind\Request $maxMind = NULL)
 {
     $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();
 }
Ejemplo n.º 3
0
 /**
  * Authorize
  *
  * @param	\IPS\nexus\Transaction					$transaction	Transaction
  * @param	array|\IPS\nexus\Customer\CreditCard	$values			Values from form OR a stored card object if this gateway supports them
  * @param	\IPS\nexus\Fraud\MaxMind\Request|NULL	$maxMind		*If* MaxMind is enabled, the request object will be passed here so gateway can additional data before request is made	
  * @return	\IPS\DateTime|NULL		Auth is valid until or NULL to indicate auth is good forever
  * @throws	\LogicException			Message will be displayed to user
  */
 public function auth(\IPS\nexus\Transaction $transaction, $values, \IPS\nexus\Fraud\MaxMind\Request $maxMind = NULL)
 {
     $transaction->save();
     $data = array('Amount' => $transaction->amount->amount / 10, 'Description' => $transaction->invoice->title, 'Email' => $transaction->member->email, 'Mobile' => $transaction->member->cm_phone, 'CallbackURL' => (string) \IPS\Settings::i()->base_url . 'applications/nexus/interface/gateways/zarinpal.php?nexusTransactionId=' . $transaction->id);
     $res = $this->api($data);
     if ($res['Status'] == 100) {
         $settings = json_decode($this->settings, TRUE);
         \IPS\Output::i()->redirect(\IPS\Http\Url::external('https://www.zarinpal.com/pg/StartPay/' . $res['Authority'] . '' . ($settings['zarin_gate'] ? '/ZarinGate' : '')));
     }
     throw new \RuntimeException();
 }
 /**
  * Get photo
  *
  * @return	\IPS\Http\Url|null
  */
 public function photo()
 {
     $user = $this->userData();
     if ($user !== NULL && isset($user['avatarfull'])) {
         try {
             return \IPS\Http\Url::external($user['avatarfull'])->import('core_Profile');
         } catch (\IPS\Http\Request\Exception $e) {
             // Fall through to return NULL below
         }
     }
     return NULL;
 }
Ejemplo n.º 5
0
	/**
	 * Link Account
	 *
	 * @param	\IPS\Member	$member		The member
	 * @param	mixed		$details	Details as they were passed to the exception thrown in authenticate()
	 * @return	void
	 */
	public static function link( \IPS\Member $member, $details )
	{
		try {
			$userData = \IPS\Http\Url::external( "https://api.vk.com/method/getProfiles?uid={$details[1]}&access_token={$details[0]}&fields=first_name,last_name,screen_name,bdate,nickname" )->request()->get()->decodeJson();
			$userData = $userData['response'][0];
			$member->vk_id = $details[1];
			$member->vk_token = $details[0];
			$member->save();
		}catch(\Exception $e) {}
	}
Ejemplo n.º 6
0
 /**
  * Geocode, get lat/lng by location
  *
  * @param 	string 	Location
  * @return 	array 	Lat/lng/formatted address
  */
 public function getLatLng($location)
 {
     static $locCache = array();
     $locKey = md5($location);
     if (isset($locCache['cache-' . $locKey])) {
         return $locCache['cache-' . $locKey];
     }
     $apiKey = \IPS\membermap\Application::getApiKeys('mapquest');
     if ($apiKey) {
         try {
             $data = \IPS\Http\Url::external("https://open.mapquestapi.com/nominatim/v1/search.php?key={$apiKey}&format=json&limit=1&q=" . urlencode($location))->request(15)->get()->decodeJson();
             if (is_array($data) and count($data)) {
                 $locCache['cache-' . $locKey] = array('lat' => $data[0]['lat'], 'lng' => $data[0]['lon'], 'location' => $data[0]['display_name']);
                 return $locCache['cache-' . $locKey];
             } else {
                 /* No result for this */
                 $locCache['cache-' . $locKey] = false;
             }
         } catch (\RuntimeException $e) {
             \IPS\Log::log($e, 'membermap');
             return false;
         }
     }
     return false;
 }
 /**
  * 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;
 }
Ejemplo n.º 8
0
	/**
	 * Get name
	 *
	 * @return	string
	 */
	public function name()
	{
		try
		{
			$response = \IPS\Http\Url::external( "https://api.vk.com/method/getProfiles?uid={$this->member->vk_id}&access_token={$this->member->vk_token}" )->request()->get()->decodeJson();

			if ( isset( $response["response"] ) && isset($response['response'][0]) )
			{
				return $response['response'][0]['first_name'] . ' ' . $response['response'][0]['last_name'];
			}
		}
		catch ( \IPS\Http\Request\Exception $e )
		{
			return NULL;
		}
	}
Ejemplo n.º 9
0
 /**
  * Verifies a usernames existence on YouTube
  *
  * @note This will return false if no channels are found, even if the username does exist
  * @param $username The YouTube username
  * @return bool
  * @throws InvalidAPIKey
  * @throws NoAPIKey
  */
 public function verifyUsername($username)
 {
     $api_key = $this->hasApiKey();
     // Yup, lets get to it and build our URL
     $url = \IPS\Http\Url::external('https://www.googleapis.com/youtube/v3/channels')->setQueryString('key', $api_key)->setQueryString('forUsername', $username)->setQueryString('part', 'id');
     // Init our curl
     $curl = new \IPS\Http\Request\Curl($url);
     // Get our response
     $response = $curl->get();
     // Close the curl just cause I'm tidy like that.
     unset($curl);
     // If false, username not found OR has no channels
     if (!$this->parseResponse($response)) {
         return FALSE;
     }
     return TRUE;
 }
Ejemplo n.º 10
0
 /**
  * Send API Request
  *
  * @param	array	$data	The data to send
  * @return	array
  */
 public function api($data, $verify = FALSE)
 {
     $data['api'] = json_decode($this->settings)->api;
     return intval((string) \IPS\Http\Url::external($verify ? self::PAYLINE_CHECK_URL : self::PAYLINE_SEND_URL)->request()->post($data));
 }
Ejemplo n.º 11
0
 /**
 * ACP Settings Form
 *
 * @param    string $url URL to redirect user to after successful submission
 *
 * @return    array    List of settings to save - settings will be stored to core_login_handlers.login_settings DB
 *                     field
 * @code
     return array( 'savekey'    => new \IPS\Helpers\Form\[Type]( ... ), ... );
 * @endcode
 */
 public function acpForm()
 {
     \IPS\Output::i()->sidebar['actions'] = array('help' => array('title' => 'help', 'icon' => 'question-circle', 'link' => \IPS\Http\Url::external('http://forums.vatsim.net/viewtopic.php?f=134&t=65133'), 'target' => '_blank', 'class' => ''));
     return array('sso_base' => new \IPS\Helpers\Form\Text('login_vatsim_sso_base', isset($this->settings['sso_base']) ? $this->settings['sso_base'] : '', TRUE), 'sso_key' => new \IPS\Helpers\Form\Text('login_vatsim_sso_key', isset($this->settings['sso_key']) ? $this->settings['sso_key'] : '', TRUE), 'sso_secret' => new \IPS\Helpers\Form\Password('login_vatsim_sso_secret', isset($this->settings['sso_secret']) ? $this->settings['sso_secret'] : '', TRUE), 'sso_rsa_key' => new \IPS\Helpers\Form\TextArea('login_vatsim_sso_rsa_key', isset($this->settings['sso_rsa_key']) ? $this->settings['sso_rsa_key'] : '', TRUE));
 }