Exemplo n.º 1
0
 /**
  * Get Config
  *
  *
  */
 public static function getConfig()
 {
     if (empty(self::$config)) {
         $params = self::_getParams();
         $config = array();
         //providers
         $config['providers'] = array();
         foreach (self::$providers as $provider) {
             $config['providers'][$provider] = array();
             $lowerName = strtolower($provider);
             $config['providers'][$provider]['enabled'] = (int) $params->get('enable_' . $lowerName, 0);
             if ($config['providers'][$provider]['enabled'] === 1) {
                 //parse to boolean
                 $config['providers'][$provider]['enabled'] = true;
                 $secret = $params->get('appsecret_' . $lowerName, 0);
                 if (isset($secret)) {
                     $config['providers'][$provider]['keys'] = array('id' => null, 'secret' => null);
                     $config['providers'][$provider]['keys']['id'] = $params->get('appid_' . $lowerName, 0);
                     $config['providers'][$provider]['keys']['key'] = $params->get('appkey_' . $lowerName, 0);
                     $config['providers'][$provider]['keys']['secret'] = $params->get('appsecret_' . $lowerName, 0);
                     //Specific parameters
                     //for google
                     if ($provider == 'Google') {
                         /*
                                                 $config['providers'][$provider]['access_type'] = 'online';
                                                 $config['providers'][$provider]['approval_prompt'] = 'force';
                         */
                     }
                 }
             }
         }
         //base path
         //$config['base_url']    = JUri::base().'index.php?option=com_hs_users&task=authentications.endpoint';
         $config['base_url'] = JRoute::_('index.php?option=com_hs_users&task=authentications.endpoint', false, -1);
         //debug
         //
         $debug = (int) $params->get('debug', 0);
         if ($debug === 1) {
             $config['debug_mode'] = true;
             $config['debug_file'] = JPATH_SITE . $params->get('debug_file');
         } else {
             $config['debug_mode'] = false;
         }
         self::$config = $config;
     }
     if ($_SERVER['HTTPS'] === "on" && strpos($config["base_url"], 'http://') === 0) {
         if ($config['debug_mode']) {
             file_put_contents($config['debug_file'], '$SERVER["HTTP"] = "on", so why is $config["base_url"] set to http' . "\n\n", FILE_APPEND);
             file_put_contents($config['debug_file'], 'Replace http:// with https:// in ' . $config['base_url'] . "\n\n", FILE_APPEND);
         }
         //this is really anoying to me.
         //
         $config['base_url'] = str_replace('http://', 'https://', $config['base_url']);
     }
     return self::$config;
 }
Exemplo n.º 2
0
 /**
  * Get Config
  * 
  * 
  */
 static function getConfig()
 {
     if (empty(self::$config)) {
         $params = self::_getParams();
         $config = array();
         //providers
         $config['providers'] = array();
         foreach (self::$providers as $provider) {
             $config['providers'][$provider] = array();
             $lowerName = strtolower($provider);
             $config['providers'][$provider]['enabled'] = (int) $params->get('enable_' . $lowerName, 0);
             if ($config['providers'][$provider]['enabled'] === 1) {
                 //parse to boolean
                 $config['providers'][$provider]['enabled'] = true;
                 $secret = $params->get('appsecret_' . $lowerName, 0);
                 if (isset($secret)) {
                     $config['providers'][$provider]['keys'] = array('id' => null, 'secret' => null);
                     $config['providers'][$provider]['keys']['id'] = $params->get('appid_' . $lowerName, 0);
                     $config['providers'][$provider]['keys']['key'] = $params->get('appkey_' . $lowerName, 0);
                     $config['providers'][$provider]['keys']['secret'] = $params->get('appsecret_' . $lowerName, 0);
                     //Specific parameters
                     //for google
                     if ($provider == 'Google') {
                         /*
                         $config['providers'][$provider]['access_type'] = 'online';
                         $config['providers'][$provider]['approval_prompt'] = 'force';
                         */
                     }
                 }
             }
         }
         //base path
         //$config['base_url']	= JUri::base().'index.php?option=com_hs_users&task=authentications.endpoint';
         $config['base_url'] = JRoute::_('index.php?option=com_hs_users&task=authentications.endpoint', false, -1);
         //debug
         $debug = (int) $params->get('debug', 0);
         if ($debug === 1) {
             $config['debug_mode'] = true;
             $config['debug_file'] = JPATH_SITE . $params->get('debug_file');
         } else {
             $config['debug_mode'] = false;
         }
         self::$config = $config;
     }
     return self::$config;
 }