コード例 #1
0
ファイル: curl.php プロジェクト: acculitx/fleetmatrixsite
 function run($form, $actiondata)
 {
     $mainframe =& JFactory::getApplication();
     $params = new JParameter($actiondata->params);
     if (function_exists('curl_init')) {
         $form->debug['curl'][] = "CURL OK : the CURL function was found on this server.";
     } else {
         $form->debug['curl'][] = "CURL problem : the CURL function was not found on this server.";
         return;
     }
     if (!empty($actiondata->content1)) {
         $list = explode("\n", trim($actiondata->content1));
         $curl_values = array();
         foreach ($list as $item) {
             $fields_data = explode("=", $item);
             $curl_values[$fields_data[0]] = $form->data[trim($fields_data[1])];
         }
     }
     $query = JURI::buildQuery($curl_values);
     $form->debug['curl'][] = '$curl_values: ' . print_r($query, true);
     $form->debug['curl'][] = 'curl_target_url: ' . $params->get('target_url');
     $ch = curl_init($params->get('target_url'));
     curl_setopt($ch, CURLOPT_HEADER, $params->get('header_in_response', 0));
     // set to 0 to eliminate header info from response
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     // Returns response data instead of TRUE(1)
     curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
     // use HTTP POST to send form data
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     $response = curl_exec($ch);
     //execute post and get results
     curl_close($ch);
     //add the response in the form data array
     $form->data['curl'] = $response;
 }
コード例 #2
0
    static function getReturnURL($params, $type)
	{
		$app	= JFactory::getApplication();
		$router = $app->getRouter();
		$url = null;
		if ($itemid =  $params->get($type))
		{
			$db		= JFactory::getDbo();
			$query	= $db->getQuery(true);

			$query->select($db->nameQuote('link'));
			$query->from($db->nameQuote('#__menu'));
			$query->where($db->nameQuote('published') . '=1');
			$query->where($db->nameQuote('id') . '=' . $db->quote($itemid));

			$db->setQuery($query);
			if ($link = $db->loadResult()) {
				if ($router->getMode() == JROUTER_MODE_SEF) {
					$url = 'index.php?Itemid='.$itemid;
				}
				else {
					$url = $link.'&Itemid='.$itemid;
				}
			}
		}
		if (!$url)
		{
			// stay on the same page
			$uri = clone JFactory::getURI();
			$vars = $router->parse($uri);
			unset($vars['lang']);
			if ($router->getMode() == JROUTER_MODE_SEF)
			{
				if (isset($vars['Itemid']))
				{
					$itemid = $vars['Itemid'];
					$menu = $app->getMenu();
					$item = $menu->getItem($itemid);
					unset($vars['Itemid']);
					if (isset($item) && $vars == $item->query) {
						$url = 'index.php?Itemid='.$itemid;
					}
					else {
						$url = 'index.php?'.JURI::buildQuery($vars).'&Itemid='.$itemid;
					}
				}
				else
				{
					$url = 'index.php?'.JURI::buildQuery($vars);
				}
			}
			else
			{
				$url = 'index.php?'.JURI::buildQuery($vars);
			}
		}

		return base64_encode($url);
	}
コード例 #3
0
 function &_createURI($url)
 {
     // Create full URL if we are only appending variables to it
     if (substr($url, 0, 1) == '&') {
         $vars = array();
         parse_str($url, $vars);
         $vars = array_merge($this->getVars(), $vars);
         foreach ($vars as $key => $var) {
             if ($var == "") {
                 unset($vars[$key]);
             }
         }
         $url = 'index.php?' . JURI::buildQuery($vars);
     }
     // Security - only allow one question mark in URL
     $pos = strpos($url, '?');
     if ($pos !== false) {
         $url = substr($url, 0, $pos + 1) . str_replace('?', '%3F', substr($url, $pos + 1));
     }
     // Decompose link into url component parts
     $uri = new JURI($url);
     return $uri;
 }
コード例 #4
0
 /**
  * Sets the type of the menu item currently being editted.
  *
  * @return	void
  * @since	1.6
  */
 function setType()
 {
     // Initialise variables.
     $app = JFactory::getApplication();
     // Get the posted values from the request.
     $data = array();
     $data['type'] = json_decode(base64_decode(JRequest::getVar('params', '')));
     $data['menutype'] = JRequest::getVar('menutype', '');
     // Get the type.
     $type = $data['type'];
     $title = isset($type->title) ? $type->title : null;
     $recordId = isset($type->id) ? $type->id : 0;
     if ($title != 'alias' && $title != 'separator' && $title != 'url') {
         $title = 'component';
     }
     $app->setUserState('com_menus.edit.item.type', $title);
     if ($title == 'component') {
         if (isset($type->request)) {
             $component = JComponentHelper::getComponent($type->request->option);
             $data['component_id'] = $component->id;
             $app->setUserState('com_menus.edit.item.link', 'index.php?' . JURI::buildQuery((array) $type->request));
         }
     } else {
         if ($title == 'alias') {
             $app->setUserState('com_menus.edit.item.link', 'index.php?Itemid=');
         }
     }
     unset($data['request']);
     $data['type'] = $title;
     if (JRequest::getCmd('fieldtype') == 'type') {
         $data['link'] = $app->getUserState('com_menus.edit.item.link');
     }
     //Save the data in the session.
     $app->setUserState('com_menus.edit.item.data', $data);
     $this->type = $type;
     $this->setRedirect(JRoute::_('index.php?option=com_menus&&view=item&layout=edit' . $this->getRedirectToItemAppend($recordId), false));
 }
コード例 #5
0
ファイル: openid.php プロジェクト: kwizera05/police
 /**
  * This method should handle any authentication and report back to the subject
  *
  * @access	public
  * @param   array 	$credentials Array holding the user credentials
  * @param 	array   $options     Array of extra options (return, entry_url)
  * @param	object	$response	Authentication response object
  * @return	boolean
  * @since 1.5
  */
 function onAuthenticate($credentials, $options, &$response)
 {
     $mainframe =& JFactory::getApplication();
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         define('Auth_OpenID_RAND_SOURCE', null);
     } else {
         $f = @fopen('/dev/urandom', 'r');
         if ($f !== false) {
             define('Auth_OpenID_RAND_SOURCE', '/dev/urandom');
             fclose($f);
         } else {
             $f = @fopen('/dev/random', 'r');
             if ($f !== false) {
                 define('Auth_OpenID_RAND_SOURCE', '/dev/urandom');
                 fclose($f);
             } else {
                 define('Auth_OpenID_RAND_SOURCE', null);
             }
         }
     }
     jimport('openid.consumer');
     jimport('joomla.filesystem.folder');
     // Access the session data
     $session =& JFactory::getSession();
     // Create and/or start using the data store
     $store_path = JPATH_ROOT . '/tmp/_joomla_openid_store';
     if (!JFolder::exists($store_path) && !JFolder::create($store_path)) {
         $response->type = JAUTHENTICATE_STATUS_FAILURE;
         $response->error_message = "Could not create the FileStore directory '{$store_path}'. " . " Please check the effective permissions.";
         return false;
     }
     // Create store object
     $store = new Auth_OpenID_FileStore($store_path);
     // Create a consumer object
     $consumer = new Auth_OpenID_Consumer($store);
     if (!isset($_SESSION['_openid_consumer_last_token'])) {
         // Begin the OpenID authentication process.
         if (!($auth_request = $consumer->begin($credentials['username']))) {
             $response->type = JAUTHENTICATE_STATUS_FAILURE;
             $response->error_message = 'Authentication error : could not connect to the openid server';
             return false;
         }
         $sreg_request = Auth_OpenID_SRegRequest::build(array('email'), array('fullname', 'language', 'timezone'));
         if ($sreg_request) {
             $auth_request->addExtension($sreg_request);
         }
         $policy_uris = array();
         if ($this->params->get('phishing-resistant', 0)) {
             $policy_uris[] = 'http://schemas.openid.net/pape/policies/2007/06/phishing-resistant';
         }
         if ($this->params->get('multi-factor', 0)) {
             $policy_uris[] = 'http://schemas.openid.net/pape/policies/2007/06/multi-factor';
         }
         if ($this->params->get('multi-factor-physical', 0)) {
             $policy_uris[] = 'http://schemas.openid.net/pape/policies/2007/06/multi-factor-physical';
         }
         $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
         if ($pape_request) {
             $auth_request->addExtension($pape_request);
         }
         //Create the entry url
         $entry_url = isset($options['entry_url']) ? $options['entry_url'] : JURI::base();
         $entry_url = JURI::getInstance($entry_url);
         unset($options['entry_url']);
         //We don't need this anymore
         //Create the url query information
         $options['return'] = isset($options['return']) ? base64_encode($options['return']) : base64_encode(JURI::base());
         $options[JUtility::getToken()] = 1;
         $process_url = sprintf($entry_url->toString() . "?option=com_user&task=login&username=%s", $credentials['username']);
         $process_url .= '&' . JURI::buildQuery($options);
         $session->set('return_url', $process_url);
         $trust_url = $entry_url->toString(array('path', 'host', 'port', 'scheme'));
         $session->set('trust_url', $trust_url);
         // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
         // form to send a POST request to the server.
         if ($auth_request->shouldSendRedirect()) {
             $redirect_url = $auth_request->redirectURL($trust_url, $process_url);
             // If the redirect URL can't be built, display an error
             // message.
             if (Auth_OpenID::isFailure($redirect_url)) {
                 displayError("Could not redirect to server: " . $redirect_url->message);
             } else {
                 // Send redirect.
                 $mainframe->redirect($redirect_url);
                 return false;
             }
         } else {
             // Generate form markup and render it.
             $form_id = 'openid_message';
             $form_html = $auth_request->htmlMarkup($trust_url, $process_url, false, array('id' => $form_id));
             // Display an error if the form markup couldn't be generated;
             // otherwise, render the HTML.
             if (Auth_OpenID::isFailure($form_html)) {
                 //displayError("Could not redirect to server: " . $form_html->message);
             } else {
                 JResponse::setBody($form_html);
                 echo JResponse::toString($mainframe->getCfg('gzip'));
                 $mainframe->close();
                 return false;
             }
         }
     }
     $result = $consumer->complete($session->get('return_url'));
     switch ($result->status) {
         case Auth_OpenID_SUCCESS:
             $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($result);
             $sreg = $sreg_resp->contents();
             $usermode = $this->params->get('usermode', 2);
             /* in the following code, we deal with the transition from the old openid version to the new openid version
                In the old version, the username was always taken straight from the login form.  In the new version, we get a
                username back from the openid provider.  This is necessary for a number of reasons.  First, providers such as
                yahoo.com allow you to enter only the provider name in the username field (i.e. yahoo.com or flickr.com).  Taking
                this as the username would obviously cause problems because everybody who had an id from yahoo.com would have username
                yahoo.com.  Second, it is necessary because with the old way, we rely on the user entering the id the same every time.
                This is bad because if the user enters the http:// one time and not the second time, they end up as two different users.
                There are two possible settings here - the first setting, is to always use the new way, which is to get the username from
                the provider after authentication.  The second setting is to check if the username exists that we got from the provider.  If it
                doesn't, then we check if the entered username exists.  If it does, then we update the database with the username from the provider
                and continue happily along with the new username.
                We had talked about a third option, which would be to always used the old way, but that seems insecure in the case of somebody using
                a yahoo.com ID.
             */
             if ($usermode && $usermode == 1) {
                 $response->username = $result->getDisplayIdentifier();
             } else {
                 // first, check if the provider provided username exists in the database
                 $db =& JFactory::getDBO();
                 $query = 'SELECT username FROM #__users' . ' WHERE username='******' AND password=\'\'';
                 $db->setQuery($query);
                 $dbresult = $db->loadObject();
                 if ($dbresult) {
                     // if so, we set our username value to the provided value
                     $response->username = $result->getDisplayIdentifier();
                 } else {
                     // if it doesn't, we check if the username from the from exists in the database
                     $query = 'SELECT username FROM #__users' . ' WHERE username='******'username']) . ' AND password=\'\'';
                     $db->setQuery($query);
                     $dbresult = $db->loadObject();
                     if ($dbresult) {
                         // if it does, we update the database
                         $query = 'UPDATE #__users SET username='******' WHERE username='******'username']);
                         $db->setQuery($query);
                         $db->query();
                         if (!$db->query()) {
                             $response->status = JAUTHENTICATE_STATUS_FAILURE;
                             $response->error_message = $db->getErrorMsg();
                             //break out of the switch if we hit an error with our query
                             break;
                         }
                     }
                     $response->username = $result->getDisplayIdentifier();
                     // we return the username provided by the openid provider
                 }
             }
             $response->status = JAUTHENTICATE_STATUS_SUCCESS;
             $response->error_message = '';
             if (!isset($sreg['email'])) {
                 $response->email = str_replace(array('http://', 'https://'), '', $response->username);
                 $response->email = str_replace('/', '-', $response->email);
                 $response->email .= '@openid.';
             } else {
                 $response->email = $sreg['email'];
             }
             $response->fullname = isset($sreg['fullname']) ? $sreg['fullname'] : $response->username;
             $response->language = isset($sreg['language']) ? $sreg['language'] : '';
             $response->timezone = isset($sreg['timezone']) ? $sreg['timezone'] : '';
             break;
         case Auth_OpenID_CANCEL:
             $response->status = JAUTHENTICATE_STATUS_CANCEL;
             $response->error_message = 'Authentication cancelled';
             break;
         case Auth_OpenID_FAILURE:
             $response->status = JAUTHENTICATE_STATUS_FAILURE;
             $response->error_message = 'Authentication failed';
             break;
     }
 }
コード例 #6
0
ファイル: helper.php プロジェクト: kosmosby/medicine-prof
	public static function getList(&$params)
	{
		$lang = JFactory::getLanguage();
		$languages	= JLanguageHelper::getLanguages();
		$app		= JFactory::getApplication();

        //use to remove default language code in url
        $lang_codes 	= JLanguageHelper::getLanguages('lang_code');
        $default_lang = JComponentHelper::getParams('com_languages')->get('site', 'en-GB');
        $default_sef 	= $lang_codes[$default_lang]->sef;

        $sefToolsEnabled = modFaLangHelper::sefToolEnabled();


        $menu = $app->getMenu();
        $active = $menu->getActive();
        $uri = JURI::getInstance();


        // Get menu home items
        $homes = array();

        foreach ($menu->getMenu() as $item)
        {
            if ($item->home)
            {
                $homes[$item->language] = $item;
            }
        }


        if (FALANG_J30) {
            //since 3.2
            if (version_compare(JVERSION, '3.2', 'ge')) {
                $assoc =  JLanguageAssociations::isEnabled();
            } else {
                $assoc = isset($app->item_associations) ? (boolean) $app->item_associations : false;
            }
        } else {
            $assoc = (boolean) $app->get('menu_associations', true);
        }


		if ($assoc) {
			if ($active) {
				$associations = MenusHelper::getAssociations($active->id);
			}
		}
   		foreach($languages as $i => &$language) {
			// Do not display language without frontend UI
			if (!JLanguage::exists($language->lang_code)) {
				unset($languages[$i]);
			}
            if (FALANG_J30) {
                $language_filter = JLanguageMultilang::isEnabled();
            } else {
                $language_filter = $app->getLanguageFilter();
            }



            //set language active before language filter use for sh404 notice
            $language->active =  $language->lang_code == $lang->getTag();

            //since v1.4 change in 1.5 , ex rsform preview don't have active
            if (isset($active)){
                $language->display = ($active->language == '*' || $language->active)?true:false;
            } else {
                $language->display = true;
            }


            if ($language_filter) {
                if (isset($associations[$language->lang_code]) && $menu->getItem($associations[$language->lang_code])) {
                    $language->display = true;
                    $itemid = $associations[$language->lang_code];
                    if ($app->getCfg('sef')=='1') {
                        $language->link = JRoute::_('index.php?lang='.$language->sef.'&Itemid='.$itemid);
                    }
                    else {
                        $language->link = 'index.php?lang='.$language->sef.'&Itemid='.$itemid;
                    }
                }
                else {
                    //sef case
                    if ($app->getCfg('sef')=='1') {

                        //sefToolsEnabled
                        if ($sefToolsEnabled) {
                            $itemid = isset($homes[$language->lang_code]) ? $homes[$language->lang_code]->id : $homes['*']->id;
                            $language->link = JRoute::_('index.php?lang='.$language->sef.'&Itemid='.$itemid);
                            continue;
                        }


                         //$uri->setVar('lang',$language->sef);
                         $router = JApplication::getRouter();
                         $tmpuri = clone($uri);

                         $router->parse($tmpuri);

                         $vars = $router->getVars();
                         //workaround to fix index language
                         $vars['lang'] = $language->sef;

                        //case of category article
                        if (!empty($vars['view']) && $vars['view'] == 'article' && !empty($vars['option']) && $vars['option'] == 'com_content') {

                            if (FALANG_J30){
                                JModelLegacy::addIncludePath(JPATH_SITE.'/components/com_content/models', 'ContentModel');
                                $model = JModelLegacy::getInstance('Article', 'ContentModel', array('ignore_request'=>true));
                                $appParams = JFactory::getApplication()->getParams();
                            } else {
                                JModel::addIncludePath(JPATH_SITE.'/components/com_content/models', 'ContentModel');
                                $model =& JModel::getInstance('Article', 'ContentModel', array('ignore_request'=>true));
                                $appParams = JFactory::getApplication()->getParams();
                            }


                            $model->setState('params', $appParams);

                            //in sef some link have this url
                            //index.php/component/content/article?id=39
                            //id is not in vars but in $tmpuri
                            if (empty($vars['id'])) {
                                $tmpid = $tmpuri->getVar('id');
                                if (!empty($tmpid)) {
                                    $vars['id'] = $tmpuri->getVar('id');
                                } else {
                                    continue;
                                }
                            }

                            $item = $model->getItem($vars['id']);

                            //get alias of content item without the id , so i don't have the translation
                            $db = JFactory::getDbo();
                            $query = $db->getQuery(true);
                            $query->select('alias')->from('#__content')->where('id = ' . (int) $item->id);
                            $db->setQuery($query);
                            $alias = $db->loadResult();

                            $vars['id'] = $item->id.':'.$alias;
                            $vars['catid'] =$item->catid.':'.$item->category_alias;
                        }

                        //new version 1.5
                        //case for k2 item alias write twice
                        if (isset($vars['option']) && $vars['option'] == 'com_k2'){
                            if ($vars['task'] == $vars['id']){
                                unset($vars['id']);
                            }
                        }
                        $url = 'index.php?'.JURI::buildQuery($vars);
                        $language->link = JRoute::_($url);

                        //TODO check performance 3 queries by languages -1
                        /**
                         * Replace the slug from the language switch with correctly translated slug.
                         * $language->lang_code language de la boucle (icone lien)
                         * $lang->getTag() => language en cours sur le site
                         * $default_lang langue par default du site
                         */
                        if($lang->getTag() != $language->lang_code && !empty($vars['Itemid']))
                        {
                            $fManager = FalangManager::getInstance();
                            $id_lang = $fManager->getLanguageID($language->lang_code);
                            $db = JFactory::getDbo();
                            // get translated path if exist
                            $query = $db->getQuery(true);
                            $query->select('fc.value')
                                ->from('#__falang_content fc')
                                ->where('fc.reference_id = '.(int)$vars['Itemid'])
                                ->where('fc.language_id = '.(int) $id_lang )
                                ->where('fc.reference_field = \'path\'')
                                ->where('fc.reference_table = \'menu\'');
                            $db->setQuery($query);
                            $translatedPath = $db->loadResult();

                            // $translatedPath not exist if not translated or site default language
                            // don't pass id to the query , so no translation given by falang
                            $query = $db->getQuery(true);
                            $query->select('m.path')
                                ->from('#__menu m')
                                ->where('m.id = '.(int)$vars['Itemid']);
                            $db->setQuery($query);
                            $originalPath = $db->loadResult();

                            $pathInUse = null;
                            //si on est sur une page traduite on doit récupérer la traduction du path en cours
                            if ($default_lang != $lang->getTag() ) {
                                $id_lang = $fManager->getLanguageID($lang->getTag());
                                // get translated path if exist
                                $query = $db->getQuery(true);
                                $query->select('fc.value')
                                    ->from('#__falang_content fc')
                                    ->where('fc.reference_id = '.(int)$vars['Itemid'])
                                    ->where('fc.language_id = '.(int) $id_lang )
                                    ->where('fc.reference_field = \'path\'')
                                    ->where('fc.reference_table = \'menu\'');
                                $db->setQuery($query);
                                $pathInUse = $db->loadResult();

                            }

                            if (!isset($translatedPath)) {
                                $translatedPath = $originalPath;
                            }

                            // not exist if not translated or site default language
                            if (!isset($pathInUse)) {
                                $pathInUse = $originalPath ;
                            }

                            //make replacement in the url

                            //si language de boucle et language site
                            if($language->lang_code == $default_lang) {
                                if (isset($pathInUse) && isset($originalPath)){
                                    $language->link = str_replace($pathInUse, $originalPath, $language->link);
                                }
                            } else {
                                if (isset($pathInUse) && isset($translatedPath)){
                                    $language->link = str_replace($pathInUse, $translatedPath, $language->link);
                                }
                            }

                        }
                    }
                    //default case
             else {
                        //we can't remove default language in the link
                        $uri->setVar('lang',$language->sef);
                        $language->link = 'index.php?'.$uri->getQuery();
                    }
                }
            }
            else {
                $language->link = 'index.php';
            }

		}
		return $languages;
	}
コード例 #7
0
function openid($credentials, $options)
{
    $mainframe =& JFactory::getApplication();
    $provider = $credentials[PROVIDER];
    $db = JFactory::getDBO();
    $selectProvider = 'select p.id, p.discovery_url, p.prefix, p.suffix, p.use_email from #__providers p where p.name = "' . $provider . '"';
    $db->setQuery($selectProvider);
    $dbprovider = $db->loadObject();
    $prefix = trim($dbprovider->prefix);
    $suffix = trim($dbprovider->suffix);
    //$discovery = trim($dbprovider->discovery_url);
    //    $discovery = ($dbprovider->discovery_url == null) ? null : trim($dbprovider->discovery_url);
    $discovery = $dbprovider->discovery_url;
    $username = trim($credentials['username']);
    $beginning = substr($username, 0, strlen($prefix));
    $ending = substr($username, strlen($username) - strlen($suffix));
    if ($beginning != $prefix) {
        $username = $prefix . $username;
    }
    if ($ending != $suffix) {
        $username = $username . $suffix;
    }
    //$discovery_url = ($discovery) ? $discovery : $credentials['username'];
    $discovery_url = $discovery ? $discovery : $username;
    $username = $discovery ? '' : $username;
    ################################################
    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
        define('Auth_OpenID_RAND_SOURCE', null);
    } else {
        $f = @fopen('/dev/urandom', 'r');
        if ($f !== false) {
            define('Auth_OpenID_RAND_SOURCE', '/dev/urandom');
            fclose($f);
        } else {
            $f = @fopen('/dev/random', 'r');
            if ($f !== false) {
                define('Auth_OpenID_RAND_SOURCE', '/dev/urandom');
                fclose($f);
            } else {
                define('Auth_OpenID_RAND_SOURCE', null);
            }
        }
    }
    jimport('openid.consumer');
    jimport('joomla.filesystem.folder');
    // Access the session data
    $session =& JFactory::getSession();
    $info = array();
    // Create and/or start using the data store
    $store_path = JPATH_ROOT . '/tmp/_joomla_openid_store';
    if (!JFolder::exists($store_path) && !JFolder::create($store_path)) {
        $info[STATUS] = Auth_FAILURE;
        //$response->type = JAUTHENTICATE_STATUS_FAILURE;
        //$response->error_message = "Could not create the FileStore directory '$store_path'. " . " Please check the effective permissions.";
        return false;
    }
    // Create store object
    $store = new Auth_OpenID_FileStore($store_path);
    // Create a consumer object
    $consumer = new Auth_OpenID_Consumer($store);
    if (!isset($_SESSION['_openid_consumer_last_token'])) {
        // Begin the OpenID authentication process.
        if (!($auth_request = $consumer->begin($discovery_url))) {
            $info[STATUS] = Auth_FAILURE;
            //$response->type = JAUTHENTICATE_STATUS_FAILURE;
            //$response->error_message = 'Authentication error : could not connect to the openid server';
            return $info;
        }
        // if ($auth_request->endpoint->usesExtension(Auth_OpenID_AX_NS_URI)) {
        $ax_request = new Auth_OpenID_AX_FetchRequest();
        $ax_request->add(Auth_OpenID_AX_AttrInfo::make('http://axschema.org/contact/email', 1, true));
        //         }
        $sreg_request = Auth_OpenID_SRegRequest::build(array('email'));
        if ($ax_request) {
            $auth_request->addExtension($ax_request);
            $auth_request->addExtension($sreg_request);
        }
        //        $policy_uris = array();
        //        if ($this->params->get( 'phishing-resistant', 0)) {
        //            $policy_uris[] = 'http://schemas.openid.net/pape/policies/2007/06/phishing-resistant';
        //        }
        //
        //        if ($this->params->get( 'multi-factor', 0)) {
        //            $policy_uris[] = 'http://schemas.openid.net/pape/policies/2007/06/multi-factor';
        //        }
        //
        //        if ($this->params->get( 'multi-factor-physical', 0)) {
        //            $policy_uris[] = 'http://schemas.openid.net/pape/policies/2007/06/multi-factor-physical';
        //        }
        //
        //        $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
        //        if ($pape_request) {
        //            $auth_request->addExtension($pape_request);
        //        }
        //Create the entry url
        $entry_url = isset($options['entry_url']) ? $options['entry_url'] : JURI::base();
        $entry_url = JURI::getInstance($entry_url);
        unset($options['entry_url']);
        //We don't need this anymore
        //Create the url query information
        $options['return'] = isset($options['return']) ? base64_encode($options['return']) : base64_encode(JURI::base());
        $options[JUtility::getToken()] = 1;
        $process_url = sprintf($entry_url->toString() . "?option=com_user&task=login&provider=%s", $provider);
        $process_url = isset($username) && $username ? sprintf("%s&username=%s", $process_url, urlencode($username)) : $process_url;
        $process_url .= '&' . JURI::buildQuery($options);
        $session->set('return_url', $process_url);
        $trust_url = $entry_url->toString(array('path', 'host', 'port', 'scheme'));
        $session->set('trust_url', $trust_url);
        // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
        // form to send a POST request to the server.
        if ($auth_request->shouldSendRedirect()) {
            $redirect_url = $auth_request->redirectURL($trust_url, $process_url);
            // If the redirect URL can't be built, display an error
            // message.
            if (Auth_OpenID::isFailure($redirect_url)) {
                displayError("Could not redirect to server: " . $redirect_url->message);
            } else {
                // Send redirect.
                $mainframe->redirect($redirect_url);
                return false;
            }
        } else {
            // Generate form markup and render it.
            $form_id = 'openid_message';
            $form_html = $auth_request->htmlMarkup($trust_url, $process_url, false, array('id' => $form_id));
            // Display an error if the form markup couldn't be generated;
            // otherwise, render the HTML.
            if (Auth_OpenID::isFailure($form_html)) {
                //displayError("Could not redirect to server: " . $form_html->message);
            } else {
                JResponse::setBody($form_html);
                echo JResponse::toString($mainframe->getCfg('gzip'));
                $mainframe->close();
                return false;
            }
        }
    }
    $result = $consumer->complete($session->get('return_url'));
    // estandarizo el formato de salida de los datos necesarios
    $info[EXTERNAL_ID] = $result->getDisplayIdentifier();
    switch ($result->status) {
        case Auth_OpenID_SUCCESS:
            $info[STATUS] = Auth_SUCCESS;
            $ax_resp = Auth_OpenID_AX_FetchResponse::fromSuccessResponse($result);
            if ($ax_resp) {
                $email = $ax_resp->getSingle('http://axschema.org/contact/email');
                if ($email && !is_a($email, 'Auth_OpenID_AX_Error')) {
                    $info[EMAIL] = $email;
                }
            }
            $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($result);
            if (!isset($info[EMAIL]) && $sreg_resp) {
                $sreg = $sreg_resp->contents();
                if (isset($sreg['email'])) {
                    $info[EMAIL] = $sreg['email'];
                }
            }
            $info[EMAIL] = isset($info[EMAIL]) ? $info[EMAIL] : $info[EXTERNAL_ID];
            $info[LABEL] = $dbprovider->use_email ? $info[EMAIL] : $info[EXTERNAL_ID];
            break;
        case Auth_OpenID_CANCEL:
            $info[STATUS] = Auth_CANCEL;
            break;
        case Auth_OpenID_FAILURE:
            $info[STATUS] = Auth_FAILURE;
            break;
    }
    return $info;
}
コード例 #8
0
ファイル: cf_redirect.php プロジェクト: kaantunc/MYK-BOR
 /**
  * The function that will be executed when the form is submitted
  *
  */
 function onsubmit($option, $params, $row)
 {
     global $mainframe;
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_chronocontact' . DS . 'helpers' . DS . 'plugin.php';
     $helper = new ChronoContactHelperPlugin();
     $doc =& JFactory::getDocument();
     $doc->addStyleDeclaration("div.debug {border:1px solid red; padding:3px; margin-bottom:3px;}");
     $mainframe->enqueuemessage('$_POST: ' . print_r($_POST, true));
     $messages = array();
     /*********do the before onsubmit code**********/
     if (!empty($row->extra4)) {
         eval("?>" . $row->extra4);
     }
     $url_values = array();
     /// add main fields
     if (trim($row->extra2)) {
         $extras2 = explode("\n", $row->extra2);
         foreach ($extras2 as $extra2) {
             $values = array();
             $values = explode("=", $extra2);
             if ($values[1]) {
                 $v = urlencode(trim($values[1]));
                 $url_values[$v] = JRequest::getVar(trim($values[0]), '', 'post', 'string', '');
             }
         }
     }
     if (trim($row->extra1)) {
         $extras = explode("\n", $row->extra1);
         foreach ($extras as $extra) {
             // Note: accept only the first parameter pair on each line
             $values = explode("=", $extra, 2);
             if (isset($values[1])) {
                 $url_values[$values[0]] = trim($values[1]);
             }
         }
     }
     $query = JURI::buildQuery($url_values);
     $uri = $params->get('target_url') . '?' . $query;
     $parts['query'] = $query;
     $parts['scheme'] = 'http';
     $parts['host'] = 'bobjanes.com';
     //$parts['host'] = $params->get('target_url');
     //$uri = JURI::toString($parts);
     $MyForm =& CFChronoForm::getInstance();
     $MyForm->formrow->redirecturl = $uri;
     $messages[] = '<b>cf_redirect debug info</b>';
     $messages[] = '$url: ' . print_r($uri, true);
     $messages[] = '$_POST: ' . print_r($_POST, true);
     /*
      * Build query into url and set CF redirect url
      */
     $helper->showCFDebugMessage('Redirect URL set');
     if ($params->get('debugging')) {
         $helper->showPluginDebugMessages($messages);
     }
 }
コード例 #9
0
 public static function getReturnURL()
 {
     $app = JFactory::getApplication();
     $router = $app->getRouter();
     $lr_settings = self::sociallogin_getsettings();
     $check_rewrite = $app->getCfg('sef_rewrite');
     $url = null;
     if ($itemid = $lr_settings['setredirct']) {
         $db = JFactory::getDbo();
         if ($router->getMode() == JROUTER_MODE_SEF) {
             $query = "SELECT path FROM #__menu WHERE id = " . $itemid;
             $db->setQuery($query);
             $url = $db->loadResult();
             if ($check_rewrite == '0' and !empty($url)) {
                 $url = 'index.php/' . $url;
             }
         } else {
             $query = "SELECT link FROM #__menu WHERE id = " . $itemid;
             $db->setQuery($query);
             $url = $db->loadResult();
         }
     }
     if (!$url) {
         // stay on the same page
         $uri = clone JFactory::getURI();
         $vars = $router->parse($uri);
         unset($vars['lang']);
         if ($router->getMode() == JROUTER_MODE_SEF) {
             if (isset($vars['Itemid'])) {
                 $itemid = $vars['Itemid'];
                 $menu = $app->getMenu();
                 $item = $menu->getItem($itemid);
                 unset($vars['Itemid']);
                 if (isset($item) && $vars == $item->query) {
                     $query = "SELECT path FROM #__menu WHERE id = '" . $itemid . "' AND home = 1";
                     $db->setQuery($query);
                     $home_url = $db->loadResult();
                     if ($home_url) {
                         $url = 'index.php';
                     } else {
                         $query = "SELECT path FROM #__menu WHERE id = " . $itemid;
                         $db->setQuery($query);
                         $url = $db->loadResult();
                     }
                 } else {
                     // get article url path
                     $articlePath =& JFactory::getURI()->getPath();
                     $url = $articlePath;
                 }
             } else {
                 $articlePath =& JFactory::getURI()->getPath();
                 $url = $articlePath;
             }
         } else {
             $url = 'index.php?' . JURI::buildQuery($vars);
         }
     }
     return $url;
 }
コード例 #10
0
ファイル: cf_CURL.php プロジェクト: kaantunc/MYK-BOR
 /**
  * The function that will be executed when the form is submitted
  *
  */
 function onsubmit($option, $params, $row)
 {
     global $mainframe;
     if (!function_exists('curl_init')) {
         $mainframe->enqueuemessage("CURL problem : the CURL function was not found on this server.<br />\n            Sorry, but the CURL plugin cannot be used on this site as it is currently set up.", 'error');
         return;
     }
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_chronocontact' . DS . 'helpers' . DS . 'plugin.php';
     $helper = new ChronoContactHelperPlugin();
     $doc =& JFactory::getDocument();
     $doc->addStyleDeclaration("div.debug {border:1px solid red; padding:3px; margin-bottom:3px;}");
     $messages = array();
     /*********do the before onsubmit code**********/
     if (!empty($row->extra4)) {
         eval("?>" . $row->extra4);
     }
     $curl_values = array();
     /// add main fields
     if (trim($row->extra2)) {
         $extras2 = explode("\n", $row->extra2);
         foreach ($extras2 as $extra2) {
             $values = array();
             $values = explode("=", $extra2);
             if ($values[1]) {
                 $v = urlencode(trim($values[1]));
                 $curl_values[$v] = JRequest::getVar(trim($values[0]), '', 'post', 'string', '');
             }
         }
     }
     if (trim($row->extra1)) {
         $extras = explode("\n", $row->extra1);
         foreach ($extras as $extra) {
             // Note: accept only the first parameter pair on each line
             $values = explode("=", $extra, 2);
             $curl_values[$values[0]] = trim($values[1]);
         }
     }
     $query = JURI::buildQuery($curl_values);
     $messages[] = '<b>cf_CURL debug info</b>';
     $messages[] = '$curl_values: ' . print_r($query, true);
     $messages[] = '$params->target_url: ' . print_r($params->get('target_url'), true);
     $ch = curl_init($params->get('target_url'));
     $messages[] = '$ch: ' . print_r($ch, true);
     curl_setopt($ch, CURLOPT_HEADER, $params->get('header_in_response'));
     // set to 0 to eliminate header info from response
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     // Returns response data instead of TRUE(1)
     curl_setopt($ch, CURLOPT_POSTFIELDS, $query);
     // use HTTP POST to send form data
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     $response = curl_exec($ch);
     //execute post and get results
     curl_close($ch);
     $messages[] = 'CURL response: ' . print_r($response, true);
     $helper->showCFDebugMessage('CURL transaction executed');
     /*********do the after onsubmit code**********/
     if (!empty($row->extra5)) {
         eval("?>" . $row->extra5);
     }
     if ($params->get('debugging')) {
         $helper->showPluginDebugMessages($messages);
     }
 }
コード例 #11
0
 /**
  * Build internal URL - indepedent of SEF function
  *
  * @param object $uri
  * @return string
  */
 private function buildInternalUrl($uri)
 {
     // Clone JURI object to avoid an error because of the method -parse- in the next step
     $uri_clone = clone $uri;
     // Reference to JRouter object
     $route = JSite::getRouter();
     // Get the internal route
     $url_internal_array = $route->parse($uri_clone);
     // Move Itemid at the end
     if (array_key_exists('Itemid', $url_internal_array)) {
         $itemid = $url_internal_array['Itemid'];
         unset($url_internal_array['Itemid']);
         $url_internal_array['Itemid'] = $itemid;
     }
     // Move lang at the end
     if (array_key_exists('lang', $url_internal_array)) {
         $lang = $url_internal_array['lang'];
         unset($url_internal_array['lang']);
         $url_internal_array['lang'] = $lang;
     }
     $url_internal = JURI::base() . 'index.php?' . JURI::buildQuery($url_internal_array);
     return $url_internal;
 }
コード例 #12
0
ファイル: route.php プロジェクト: julienV/Joomla-Tracks
 /**
  * build url
  *
  * @param   array  $parts  parts
  *
  * @return string
  */
 protected static function buildUrl($parts)
 {
     if ($item = self::_findItem($parts)) {
         $parts['Itemid'] = $item->id;
     }
     return 'index.php?' . JURI::buildQuery($parts);
 }
コード例 #13
0
 protected static function buildUrl($parts)
 {
     if ($item = self::_findItem($parts)) {
         $parts['Itemid'] = $item->id;
     } else {
         $params = JComponentHelper::getParams('com_redevent');
         if ($params->get('default_itemid')) {
             $parts['Itemid'] = intval($params->get('default_itemid'));
         }
     }
     return 'index.php?' . JURI::buildQuery($parts);
 }
コード例 #14
0
ファイル: router.php プロジェクト: Fellah/govnobaki
 /**
  * Create a uri based on a full or partial url string
  *
  * @access	protected
  * @return  JURI  A JURI object
  */
 function &_createURI($url)
 {
     // Create full URL if we are only appending variables to it
     if (substr($url, 0, 1) == '&') {
         $vars = array();
         parse_str($url, $vars);
         $vars = array_merge($this->getVars(), $vars);
         foreach ($vars as $key => $var) {
             if ($var == "") {
                 unset($vars[$key]);
             }
         }
         $url = 'index.php?' . JURI::buildQuery($vars);
     }
     // Decompose link into url component parts
     $uri = new JURI($url);
     return $uri;
 }
コード例 #15
0
                } else {
                    ?>
 people<?php 
                }
                ?>
 did this</p>
						<?php 
            }
            if (SWG_EventsController::canRecordAttendance()) {
                ?>
							<p>
								<a class="attendance" href="<?php 
                echo JURI::current();
                ?>
?<?php 
                echo JURI::buildQuery(array("task" => "attendance.attend", "evttype" => $event->getType(), "evtid" => $event->id, "set" => (int) (!$attended)));
                ?>
"
									><img src="/images/icons/<?php 
                if ($attended) {
                    ?>
tick<?php 
                } else {
                    ?>
tickbox<?php 
                }
                ?>
.png" width="19" height="16" /
								></a>
								You did this
							</p>
 /**
  * Method to get the field input markup.
  *
  * @return    string    The field input markup.
  * @since       1.2.0
  */
 protected function getInput()
 {
     // Initialise variables
     $value = '';
     $html = array();
     $size = !empty($this->size) ? ' size="' . $this->size . '"' : '';
     $class = !empty($this->class) ? ' class="' . $this->class . '"' : 'class="inputbox"';
     $recordId = (int) $this->form->getValue('id', 0);
     $typeExtension = 'extension';
     if ($extension = FieldsandfiltersFactory::getExtensions()->getExtensionsPivot('content_type_id', true)->get($this->value)) {
         // Load Extensions Helper
         KextensionsLanguage::load('plg_' . $extension->type . '_' . $extension->name, JPATH_ADMINISTRATOR);
         $extensionForm = $extension->forms->get($typeExtension, new JObject());
         if (isset($extensionForm->group->title)) {
             $value = JText::_($extensionForm->title) . ' [' . JText::_($extensionForm->group->title) . ']';
         } elseif (isset($extensionForm->title)) {
             $value = JText::_($extensionForm->title);
         }
     }
     // Load the javascript and css
     JHtml::_('behavior.framework');
     JHtml::_('behavior.modal');
     $query = array('option' => 'com_fieldsandfilters', 'view' => 'plugins', 'tmpl' => 'component', 'layout' => 'extensions', 'recordId' => $recordId);
     $link = JRoute::_('index.php?' . JURI::buildQuery($query));
     if (FieldsandfiltersFactory::isVersion()) {
         $html[] = '<span class="input-append">';
         $html[] = '	<input type="text" readonly="readonly" disabled="disabled" value="' . $value . '"' . $size . $class . ' />';
         $html[] = '	<a class="btn btn-primary" onclick="SqueezeBox.fromElement(this, {handler:\'iframe\', size: {x: 600, y: 450}, url:\'' . $link . '\'})">';
         $html[] = '		<i class="icon-list icon-white"></i>';
         $html[] = JText::_('JSELECT');
         $html[] = '	</a>';
         $html[] = '</span>';
         $html[] = '<input class="input-small" type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />';
     } else {
         $html[] = '<input type="text" readonly="readonly" disabled="disabled" value="' . $value . '"' . $size . $class . ' />';
         $html[] = '<input type="button" value="' . JText::_('JSELECT') . '" onclick="SqueezeBox.fromElement(this, {handler:\'iframe\', size: {x: 600, y: 450}, url:\'' . $link . '\'})" />';
         $html[] = '<input type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" />';
     }
     return implode("\n", $html);
 }
コード例 #17
0
ファイル: JURITest.php プロジェクト: nguyen1986vn/atj25
 public function testBuildQuery()
 {
     $params = array('field' => array('price' => array('from' => 5, 'to' => 10), 'name' => 'foo'), 'v' => 45);
     $expected = 'field[price][from]=5&field[price][to]=10&field[name]=foo&v=45';
     $this->assertEquals($expected, JURI::buildQuery($params));
 }
コード例 #18
0
ファイル: router.php プロジェクト: knigherrant/decopatio
 public static function url($options = array())
 {
     // Set option as com_easysocial by default
     if (!isset($options['option'])) {
         $options['option'] = SOCIAL_COMPONENT_NAME;
     }
     // Remove external
     $external = false;
     if (isset($options['external'])) {
         $external = $options['external'];
         unset($options['external']);
     }
     // Remove sef
     $sef = false;
     if (isset($options['sef'])) {
         $sef = $options['sef'];
         unset($options['sef']);
     }
     // Remove tokenize
     $tokenize = false;
     if (isset($options['tokenize'])) {
         $tokenize = $options['tokenize'];
         unset($options['tokenize']);
     }
     // Remove ssl
     $ssl = false;
     if (isset($options['ssl'])) {
         $ssl = $options['ssl'];
         unset($options['ssl']);
     }
     // Remove xhtml
     $xhtml = false;
     if (isset($options['xhtml'])) {
         $xhtml = $options['xhtml'];
         unset($options['xhtml']);
     }
     $base = 'index.php?' . JURI::buildQuery($options);
     return FRoute::_($base, $xhtml, array(), $ssl, $tokenize, $external, '', '', $sef);
 }
コード例 #19
0
ファイル: route.php プロジェクト: vstorm83/propertease
 static function _fullURL($router, $url)
 {
     //$surl = $url;
     $vars = array();
     if (strpos($url, '&amp;') !== false) {
         $url = str_replace('&amp;', '&', $url);
     }
     parse_str($url, $vars);
     $rvars = $router->getVars();
     if (!is_array($rvars) || count($rvars) == 0) {
         $vars = array_merge($_GET, $vars);
     } else {
         $vars = array_merge($rvars, $vars);
     }
     foreach ($vars as $key => $var) {
         if ($var == "") {
             unset($vars[$key]);
         }
     }
     $url = 'index.php?' . JURI::buildQuery($vars);
     //echo "URL <b>$surl</b> --> <b>$url</b><br />";
     return $url;
 }
コード例 #20
0
 function setMenu()
 {
     $app =& JFactory::getApplication();
     $type = json_decode('{"id":0,"title":"COM_RSFORM_MENU_FORM","request":{"option":"com_rsform","view":"rsform"}}');
     $title = 'component';
     $app->setUserState('com_menus.edit.item.type', $title);
     $component = JComponentHelper::getComponent($type->request->option);
     $data['component_id'] = $component->id;
     $params['option'] = 'com_rsform';
     $params['view'] = 'rsform';
     $params['formId'] = JRequest::getInt('formId');
     $app->setUserState('com_menus.edit.item.link', 'index.php?' . JURI::buildQuery($params));
     $data['type'] = $title;
     $data['formId'] = JRequest::getInt('formId');
     $app->setUserState('com_menus.edit.item.data', $data);
     $this->setRedirect(JRoute::_('index.php?option=com_menus&view=item&layout=edit', false));
 }
コード例 #21
0
 public static function nextLastPages($url, $text, $maxentries, $limitstart = 0, $limit = 10)
 {
     $latestlimitstart = 0;
     if (intval($limitstart - $limit) > 0) {
         $latestlimitstart = intval($limitstart - $limit);
     }
     $nextlimitstart = 0;
     if ($limitstart + $limit < $maxentries) {
         $nextlimitstart = $limitstart + $limit;
     }
     $lastlimitstart = $maxentries - $maxentries % $limit;
     if ($maxentries % $limit == 0) {
         $lastlimitstart = $maxentries - $maxentries % $limit - $limit;
     }
     echo '<center>';
     echo '<table style="width: 50%; align: center;" cellspacing="0" cellpadding="0" border="0">';
     echo '<tr>';
     echo '<td style="width: 10%; text-align: left;" nowrap="nowrap">';
     if ($limitstart > 0) {
         $query = JURI::buildQuery(array("limit" => $limit, "limitstart" => 0));
         echo JHTML::link($url . $query, '&lt;&lt;&lt;');
         echo '&nbsp;&nbsp;&nbsp';
         $query = JURI::buildQuery(array("limit" => $limit, "limitstart" => $latestlimitstart));
         echo JHTML::link($url . $query, '&lt;&lt;');
         echo '&nbsp;&nbsp;&nbsp;';
     }
     echo '</td>';
     echo '<td style="text-align: center;" nowrap="nowrap">';
     $players_to = $maxentries;
     if ($limitstart + $limit < $maxentries) {
         $players_to = $limitstart + $limit;
     }
     echo sprintf($text, $maxentries, $limitstart + 1 . ' - ' . $players_to);
     echo '</td>';
     echo '<td style="width: 10%; text-align: right;" nowrap="nowrap">';
     if ($nextlimitstart > 0) {
         echo '&nbsp;&nbsp;&nbsp;';
         $query = JURI::buildQuery(array("limit" => $limit, "limitstart" => $nextlimitstart));
         echo JHTML::link($url . $query, '&gt;&gt;');
         echo '&nbsp;&nbsp;&nbsp';
         $query = JURI::buildQuery(array("limit" => $limit, "limitstart" => $lastlimitstart));
         echo JHTML::link($url . $query, '&gt;&gt;&gt;');
     }
     echo '</td>';
     echo '</tr>';
     echo '</table>';
     echo '</center>';
 }
コード例 #22
0
ファイル: uri.php プロジェクト: RangerWalt/ecci
 /**
  * Build a query from a array (reverse of the PHP parse_str())
  *
  * @access	public
  * @return	string The resulting query string
  * @since	1.5
  * @see	parse_str()
  */
 function buildQuery($params, $akey = null)
 {
     if (!is_array($params) || count($params) == 0) {
         return false;
     }
     $out = array();
     //reset in case we are looping
     if (!isset($akey) && !count($out)) {
         unset($out);
         $out = array();
     }
     foreach ($params as $key => $val) {
         if (is_array($val)) {
             $out[] = JURI::buildQuery($val, $key);
             continue;
         }
         $thekey = !$akey ? $key : $akey . '[' . $key . ']';
         $out[] = $thekey . "=" . urlencode($val);
     }
     return implode("&", $out);
 }
コード例 #23
0
ファイル: item.php プロジェクト: interfaceslivres/ccmd-ufpb
 /**
  * Sets the type of the menu item currently being edited.
  *
  * @return  void
  *
  * @since   1.6
  */
 public function setType()
 {
     $app = JFactory::getApplication();
     // Get the posted values from the request.
     $data = $this->input->post->get('jform', array(), 'array');
     $recordId = $this->input->getInt('id');
     // Get the type.
     $type = $data['type'];
     $type = json_decode(base64_decode($type));
     $title = isset($type->title) ? $type->title : null;
     $recordId = isset($type->id) ? $type->id : 0;
     $specialTypes = array('alias', 'separator', 'url', 'heading');
     if (!in_array($title, $specialTypes)) {
         $title = 'component';
     }
     $app->setUserState('com_menus.edit.item.type', $title);
     if ($title == 'component') {
         if (isset($type->request)) {
             $component = JComponentHelper::getComponent($type->request->option);
             $data['component_id'] = $component->id;
             $app->setUserState('com_menus.edit.item.link', 'index.php?' . JURI::buildQuery((array) $type->request));
         }
     } elseif ($title == 'alias') {
         $app->setUserState('com_menus.edit.item.link', 'index.php?Itemid=');
     }
     unset($data['request']);
     $data['type'] = $title;
     if ($this->input->get('fieldtype') == 'type') {
         $data['link'] = $app->getUserState('com_menus.edit.item.link');
     }
     //Save the data in the session.
     $app->setUserState('com_menus.edit.item.data', $data);
     $this->type = $type;
     $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId), false));
 }
コード例 #24
0
ファイル: modalcontentitem.php プロジェクト: gruz/MenuAry
    /**
     * Method to get the field input markup.
     *
     * @return  string	The field input markup.
     * @since   1.6
     */
    function getInput()
    {
        // Load the modal behavior script.
        JHtml::_('behavior.modal', 'a.modal');
        // Build the script.
        $script = array();
        $script[] = '	function jSelectContentitem_' . $this->id . '(id, title, catid, object) {';
        $script[] = '
		if (document.id("' . $this->id . '_id").value.trim() == \'\') {
				document.id("' . $this->id . '_id").value = id;
		} else {
			var currentValues = document.id("' . $this->id . '_id").value.split(\',\');
			if (currentValues.contains(id)) {
				return true;
			}
			document.id("' . $this->id . '_id").value = document.id("' . $this->id . '_id").value+\',\'+id
		}
							';
        //$script[] = '		document.id("'.$this->id.'_id").value = id;';
        //$script[] = '		document.id("'.$this->id.'_name").value = id;';
        $script[] = '		SqueezeBox.close();';
        $script[] = '	}';
        // Add the script to the document head.
        JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
        // Setup variables for display.
        $html = array();
        if (is_array($this->value)) {
            foreach ($this->value as $k => $v) {
                if (empty($v) || $v === "") {
                    unset($this->value[$k]);
                }
            }
            $value = implode(',', $this->value);
        } else {
            if (0 == (int) $this->value || empty($this->value)) {
                $value = '';
            } else {
                $value = $this->value;
            }
        }
        // class='required' for client side validation
        $class = '';
        if ($this->required) {
            $class = ' class="required modal-value"';
        }
        // The current user display field.
        $html[] = '<span class="input-append">';
        $html[] = '<input type="text" id="' . $this->id . '_id"' . $class . ' name="' . $this->name . '" value="' . $value . '" />';
        $context_or_contenttype = (string) $this->element['context_or_contenttype'];
        //~ dumpMessage('ModalItem');
        //~ dump ($context_or_contenttype,'$context_or_contenttype');
        $link = array();
        if ($context_or_contenttype != 'context') {
            $extension = (string) $this->element['extension'];
            $category = JTable::getInstance('contenttype');
            $category->load($extension);
            $extension = $category->type_alias;
            //~ dump ($extension,'extension');
            $component = explode('.', $extension);
            $component = $component[0];
            $view = explode('.', $extension, 2);
            $view = end($view);
            if (empty($component)) {
                $component = 'com_content';
            }
            if (empty($view)) {
                $view = 'article';
            }
            switch ($component) {
                case '':
                case 'com_banners':
                case 'com_tags':
                case 'com_users':
                    break;
                case 'com_k2':
                    break;
                default:
                    $link['layout'] = 'modal';
                    $link['tmpl'] = 'component';
                    $link['function'] = 'jSelectContentitem_' . $this->id;
                    if ($view == 'category') {
                        $link['option'] = 'com_categories';
                        $link['extension'] = $component;
                    } else {
                        $link['option'] = $component;
                        $link['view'] = $view . 's';
                    }
                    break;
            }
        }
        if (!empty($link)) {
            $link = 'index.php?' . JURI::buildQuery($link);
            //$link	= 'index.php?option=com_content&amp;view=articles&amp;layout=modal&amp;tmpl=component&amp;function=jSelectContentitem_'.$this->id;
            if (isset($this->element['language'])) {
                $link .= '&amp;forcedLanguage=' . $this->element['language'];
            }
            $html[] = '<a class="modal btn" title="' . JText::_('COM_CONTENT_CHANGE_ARTICLE') . '"  href="' . $link . '&amp;' . JSession::getFormToken() . '=1" rel="{handler: \'iframe\', size: {x: 800, y: 450}}"><i class="icon-file"></i> ' . JText::_('JSELECT') . '</a>';
        }
        $html[] = '</span>';
        //~ $html[] = $link;
        return implode("\n", $html);
    }
コード例 #25
0
 public static function buildQuery($parts)
 {
     if ($item = JoomleagueHelperRoute::_findItem($parts)) {
         $parts['Itemid'] = $item->id;
     } else {
         $params = JComponentHelper::getParams('com_joomleague');
         if ($params->get('default_itemid')) {
             $parts['Itemid'] = intval($params->get('default_itemid'));
         }
     }
     return JURI::buildQuery($parts);
 }
コード例 #26
0
ファイル: openid.php プロジェクト: esumerfd/ssol_joomla
 /**
  * This method should handle any authentication and report back to the subject
  *
  * @access	public
  * @param   array 	$credentials Array holding the user credentials
  * @param 	array   $options     Array of extra options (return, entry_url)
  * @param	object	$response	Authentication response object
  * @return	boolean
  * @since 1.5
  */
 function onAuthenticate($credentials, $options, &$response)
 {
     global $mainframe;
     if (!defined('Auth_OpenID_RAND_SOURCE')) {
         define("Auth_OpenID_RAND_SOURCE", null);
     }
     require_once JPATH_LIBRARIES . DS . 'openid' . DS . 'consumer.php';
     jimport('joomla.filesystem.folder');
     // Access the session data
     $session =& JFactory::getSession();
     // Need to check for bcmath or gmp - if not, use the dumb mode.
     // TODO: Should dump an error to debug saying we are dumb
     global $_Auth_OpenID_math_extensions;
     $ext = Auth_OpenID_detectMathLibrary($_Auth_OpenID_math_extensions);
     if (!isset($ext['extension']) || !isset($ext['class'])) {
         define("Auth_OpenID_NO_MATH_SUPPORT", true);
     }
     // Create and/or start using the data store
     $store_path = JPATH_ROOT . '/tmp/_joomla_openid_store';
     if (!JFolder::exists($store_path) && !JFolder::create($store_path)) {
         $response->type = JAUTHENTICATE_STATUS_FAILURE;
         $response->error_message = "Could not create the FileStore directory '{$store_path}'. " . " Please check the effective permissions.";
         return false;
     }
     // Create store object
     $store = new Auth_OpenID_FileStore($store_path);
     // Create a consumer object
     $consumer = new Auth_OpenID_Consumer($store);
     if (!isset($_SESSION['_openid_consumer_last_token'])) {
         // Begin the OpenID authentication process.
         if (!($request = $consumer->begin($credentials['username']))) {
             $response->type = JAUTHENTICATE_STATUS_FAILURE;
             $response->error_message = 'Authentication error : could not connect to the openid server';
             return false;
         }
         // Request simple registration information
         $request->addExtensionArg('sreg', 'required', 'email');
         $request->addExtensionArg('sreg', 'optional', 'fullname, language, timezone');
         //Create the entry url
         $entry_url = isset($options['entry_url']) ? $options['entry_url'] : JURI::base();
         $entry_url = JURI::getInstance($entry_url);
         unset($options['entry_url']);
         //We don't need this anymore
         //Create the url query information
         $options['return'] = isset($options['return']) ? base64_encode($options['return']) : base64_encode(JURI::base());
         $options[JUtility::getToken()] = 1;
         $process_url = sprintf($entry_url->toString() . "&username=%s", $credentials['username']);
         $process_url .= '&' . JURI::buildQuery($options);
         $trust_url = $entry_url->toString(array('path', 'host', 'port', 'scheme'));
         $redirect_url = $request->redirectURL($trust_url, $process_url);
         $session->set('trust_url', $trust_url);
         // Redirect the user to the OpenID server for authentication.  Store
         // the token for this authentication so we can verify the response.
         $mainframe->redirect($redirect_url);
         return false;
     }
     $result = $consumer->complete(JRequest::get('get'));
     switch ($result->status) {
         case Auth_OpenID_SUCCESS:
             $sreg = $result->extensionResponse('sreg');
             $response->status = JAUTHENTICATE_STATUS_SUCCESS;
             $response->error_message = '';
             $response->email = isset($sreg['email']) ? $sreg['email'] : "";
             $response->fullname = isset($sreg['fullname']) ? $sreg['fullname'] : "";
             $response->language = isset($sreg['language']) ? $sreg['language'] : "";
             $response->timezone = isset($sreg['timezone']) ? $sreg['timezone'] : "";
             break;
         case Auth_OpenID_CANCEL:
             $response->status = JAUTHENTICATE_STATUS_CANCEL;
             $response->error_message = 'Authentication cancelled';
             break;
         case Auth_OpenID_FAILURE:
             $response->status = JAUTHENTICATE_STATUS_FAILURE;
             $response->error_message = 'Authentication failed';
             break;
     }
 }
コード例 #27
0
ファイル: router.php プロジェクト: Simarpreet05/joomla
 /**
  * Create a uri based on a full or partial url string
  *
  * @param   string   $url  The URI
  *
  * @return  A JURI object
  *
  * @since   11.1
  */
 protected function _createURI($url)
 {
     // Create full URL if we are only appending variables to it
     if (substr($url, 0, 1) == '&') {
         $vars = array();
         if (strpos($url, '&amp;') !== false) {
             $url = str_replace('&amp;', '&', $url);
         }
         parse_str($url, $vars);
         $vars = array_merge($this->getVars(), $vars);
         foreach ($vars as $key => $var) {
             if ($var == "") {
                 unset($vars[$key]);
             }
         }
         $url = 'index.php?' . JURI::buildQuery($vars);
     }
     // Decompose link into url component parts
     return new JURI($url);
 }
コード例 #28
0
ファイル: openid.php プロジェクト: BGCX261/zonales-svn-to-git
 /**
  * This method should handle any authentication and report back to the subject
  *
  * @access	public
  * @param   array 	$credentials Array holding the user credentials
  * @param 	array   $options     Array of extra options (return, entry_url)
  * @param	object	$response	Authentication response object
  * @return	boolean
  * @since 1.5
  */
 function onAuthenticate($credentials, $options, &$response)
 {
     $mainframe =& JFactory::getApplication();
     ###########
     $db =& JFactory::getDBO();
     $this->logme($db, 'en el plugin openid');
     ################################################
     ## modificacion para que acepte gmail y yahoo ##
     ################################################
     ## asignar valor a $provider!!!!!!
     $provider = isset($credentials['provider']) && $credentials['provider'] != null ? $credentials['provider'] : 'OpenID';
     $selectProvider = 'select p.id, p.discovery_url, p.prefix, p.suffix from #__providers p where p.name = "' . $provider . '"';
     $db->setQuery($selectProvider);
     $dbprovider = $db->loadObject();
     $beginning = substr($credentials['username'], 0, strlen($dbprovider->prefix));
     $ending = substr($credentials['username'], strlen($credentials['username']) - strlen($dbprovider->suffix));
     if ($beginning != $dbprovider->prefix) {
         $credentials['username'] = $dbprovider->prefix . $credentials['username'];
     }
     if ($ending != $dbprovider->suffix) {
         $credentials['username'] = $credentials['username'] . $dbprovider->suffix;
     }
     $discovery_url = isset($dbprovider->discovery_url) ? $dbprovider->discovery_url : $credentials['username'];
     ################################################
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         define('Auth_OpenID_RAND_SOURCE', null);
     } else {
         $f = @fopen('/dev/urandom', 'r');
         if ($f !== false) {
             define('Auth_OpenID_RAND_SOURCE', '/dev/urandom');
             fclose($f);
         } else {
             $f = @fopen('/dev/random', 'r');
             if ($f !== false) {
                 define('Auth_OpenID_RAND_SOURCE', '/dev/urandom');
                 fclose($f);
             } else {
                 define('Auth_OpenID_RAND_SOURCE', null);
             }
         }
     }
     jimport('openid.consumer');
     jimport('joomla.filesystem.folder');
     // Access the session data
     $session =& JFactory::getSession();
     // Create and/or start using the data store
     $store_path = JPATH_ROOT . '/tmp/_joomla_openid_store';
     if (!JFolder::exists($store_path) && !JFolder::create($store_path)) {
         $response->type = JAUTHENTICATE_STATUS_FAILURE;
         $response->error_message = "Could not create the FileStore directory '{$store_path}'. " . " Please check the effective permissions.";
         return false;
     }
     // Create store object
     $store = new Auth_OpenID_FileStore($store_path);
     // Create a consumer object
     $consumer = new Auth_OpenID_Consumer($store);
     if (!isset($_SESSION['_openid_consumer_last_token'])) {
         $this->logme($db, 'se va a iniciar el proceso');
         // Begin the OpenID authentication process.
         if (!($auth_request = $consumer->begin($discovery_url))) {
             $this->logme($db, 'no se pudo iniciar el proceso');
             $response->type = JAUTHENTICATE_STATUS_FAILURE;
             $response->error_message = 'Authentication error : could not connect to the openid server';
             return false;
         }
         $this->logme($db, 'continuamos');
         # armamos la peticion la informacion asociada al usuario
         //            $sreg_request = Auth_OpenID_SRegRequest::build(
         //                array ('email'),
         //                array ('fullname','language','timezone')
         //            );
         //
         //            if ($sreg_request) {
         //                $auth_request->addExtension($sreg_request);
         //            }
         $policy_uris = array();
         if ($this->params->get('phishing-resistant', 0)) {
             $policy_uris[] = 'http://schemas.openid.net/pape/policies/2007/06/phishing-resistant';
         }
         if ($this->params->get('multi-factor', 0)) {
             $policy_uris[] = 'http://schemas.openid.net/pape/policies/2007/06/multi-factor';
         }
         if ($this->params->get('multi-factor-physical', 0)) {
             $policy_uris[] = 'http://schemas.openid.net/pape/policies/2007/06/multi-factor-physical';
         }
         $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
         if ($pape_request) {
             $auth_request->addExtension($pape_request);
         }
         //Create the entry url
         $entry_url = isset($options['entry_url']) ? $options['entry_url'] : JURI::base();
         $entry_url = JURI::getInstance($entry_url);
         unset($options['entry_url']);
         //We don't need this anymore
         //Create the url query information
         $options['return'] = isset($options['return']) ? base64_encode($options['return']) : base64_encode(JURI::base());
         $options[JUtility::getToken()] = 1;
         $process_url = sprintf($entry_url->toString() . "?option=com_user&task=login&provider=%s", $provider);
         $process_url = isset($credentials['username']) && $credentials['username'] != '' ? sprintf("%s&username=%s", $process_url, $credentials['username']) : $process_url;
         $process_url .= '&' . JURI::buildQuery($options);
         $this->logme($db, 'la url de retorno es: ' . $process_url);
         $session->set('return_url', $process_url);
         $trust_url = $entry_url->toString(array('path', 'host', 'port', 'scheme'));
         $session->set('trust_url', $trust_url);
         $this->logme($db, 'tomando decisiones');
         // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
         // form to send a POST request to the server.
         if ($auth_request->shouldSendRedirect()) {
             $redirect_url = $auth_request->redirectURL($trust_url, $process_url);
             // If the redirect URL can't be built, display an error
             // message.
             if (Auth_OpenID::isFailure($redirect_url)) {
                 displayError("Could not redirect to server: " . $redirect_url->message);
             } else {
                 // Send redirect.
                 $mainframe->redirect($redirect_url);
                 return false;
             }
         } else {
             // Generate form markup and render it.
             $form_id = 'openid_message';
             $form_html = $auth_request->htmlMarkup($trust_url, $process_url, false, array('id' => $form_id));
             // Display an error if the form markup couldn't be generated;
             // otherwise, render the HTML.
             if (Auth_OpenID::isFailure($form_html)) {
                 //displayError("Could not redirect to server: " . $form_html->message);
             } else {
                 JResponse::setBody($form_html);
                 echo JResponse::toString($mainframe->getCfg('gzip'));
                 $mainframe->close();
                 return false;
             }
         }
     }
     $this->logme($db, 'voy a finalizar el proceso');
     $result = $consumer->complete($session->get('return_url'));
     $this->logme($db, 'se va a iniciar la interpretacion de los resultados');
     switch ($result->status) {
         case Auth_OpenID_SUCCESS:
             $usermode = $this->params->get('usermode', 2);
             $response->status = JAUTHENTICATE_STATUS_SUCCESS;
             $response->error_message = '';
             $session->set('externalidentifier', $result->getDisplayIdentifier());
             /* in the following code, we deal with the transition from the old openid version to the new openid version
                In the old version, the username was always taken straight from the login form.  In the new version, we get a
                username back from the openid provider.  This is necessary for a number of reasons.  First, providers such as
                yahoo.com allow you to enter only the provider name in the username field (i.e. yahoo.com or flickr.com).  Taking
                this as the username would obviously cause problems because everybody who had an id from yahoo.com would have username
                yahoo.com.  Second, it is necessary because with the old way, we rely on the user entering the id the same every time.
                This is bad because if the user enters the http:// one time and not the second time, they end up as two different users.
                There are two possible settings here - the first setting, is to always use the new way, which is to get the username from
                the provider after authentication.  The second setting is to check if the username exists that we got from the provider.  If it
                doesn't, then we check if the entered username exists.  If it does, then we update the database with the username from the provider
                and continue happily along with the new username.
                We had talked about a third option, which would be to always used the old way, but that seems insecure in the case of somebody using
                a yahoo.com ID.
             */
             if ($usermode && $usermode == 1) {
                 $response->username = $result->getDisplayIdentifier();
             } else {
                 $query = 'SELECT u.username, a.block as aliasblocked, u.block as userblocked' . ' FROM #__alias a, #__providers p, #__users u' . ' WHERE a.name=' . $db->Quote($result->getDisplayIdentifier()) . ' AND a.provider_id = p.id' . ' AND u.id = a.user_id' . ' AND p.name = ' . $db->Quote($provider);
                 $db->setQuery($query);
                 $dbresult = $db->loadObject();
                 $this->logme($db, 'realizo la consulta en busca del alias');
                 if ($dbresult) {
                     // if so, we set our username value to the provided value
                     $response->username = $dbresult->username;
                     $this->logme($db, 'el alias fue encontrado :D');
                     // si el alias o el usuario se encuentran bloqueados
                     // el acceso es cancelado
                     if ($dbresult->aliasblocked || $dbresult->userblocked) {
                         $response->status = JAUTHENTICATE_STATUS_FAILURE;
                         $response->error_message = 'The identifier is Blocked';
                         return false;
                     }
                 } else {
                     // si el alias no existe
                     $this->logme($db, 'el alias no existe :(');
                     $session->set('authenticationonprogress', 'true');
                     if ($credentials['userid'] == 0) {
                         $user =& JFactory::getUser();
                         if ($user->guest) {
                             $mainframe->redirect('index.php?option=com_user&view=userstatusrequest&externalid=' . $result->getDisplayIdentifier() . '&providerid=' . $dbprovider->id);
                         } else {
                             $token = JUtility::getToken();
                             $mainframe->redirect('index.php?option=com_user&task=aliasregister&externalid=' . urlencode($result->getDisplayIdentifier()) . '&providerid=' . $dbprovider->id . '&' . $token . '=1');
                         }
                     }
                 }
             }
             break;
         case Auth_OpenID_CANCEL:
             $response->status = JAUTHENTICATE_STATUS_CANCEL;
             $response->error_message = 'Authentication cancelled';
             break;
         case Auth_OpenID_FAILURE:
             $response->status = JAUTHENTICATE_STATUS_FAILURE;
             $response->error_message = 'Authentication failed';
             break;
     }
 }