Example #1
1
 /**
  *
  * Ajax render to store in session
  */
 public function ajaxGetRender()
 {
     /** load libraries for the system rener **/
     JSNFactory::localimport('libraries.joomlashine.mode.rawmode');
     JSNFactory::localimport('libraries.joomlashine.menu.menuitems');
     /** get url **/
     $render_url = JRequest::getVar('render_url', '');
     $urlRender = base64_decode($render_url);
     $session = JSession::getInstance('files', array('name' => 'jsnpoweradmin'));
     if ($render_url == '') {
         $urlRender = JSNDatabase::getDefaultPage()->link;
     }
     $currUri = new JURI($urlRender);
     if (!$currUri->hasVar('Itemid')) {
         $currUri->setVar('Itemid', JSNDatabase::getDefaultPage()->id);
     }
     $urlString = $currUri->toString();
     $session->set('rawmode_render_url', base64_encode($urlString));
     $parts = JString::parse_url($urlString);
     if (!empty($parts['query'])) {
         parse_str($parts['query'], $params);
     } else {
         $params = array();
     }
     $jsntemplate = JSNFactory::getTemplate();
     $jsnrawmode = JSNRawmode::getInstance($params);
     $jsnrawmode->setParam('positions', $jsntemplate->loadXMLPositions());
     $jsnrawmode->renderAll();
     $session = JSession::getInstance('files', array('name' => 'jsnajaxgetrender'));
     $session->set('component', $jsnrawmode->getHTML('component'));
     $session->set('jsondata', $jsnrawmode->getScript('positions', 'JSON'));
     jexit('success');
 }
Example #2
0
	public function testHasVar() {
		$this->object->parse('http://*****:*****@www.example.com:80/path/file.html?var=value#fragment');

		$this->assertThat(
			$this->object->hasVar('somevar'),
			$this->equalTo(false)
		);

		$this->assertThat(
			$this->object->hasVar('var'),
			$this->equalTo(true)
		);
	}
 /**
  * Display function
  */
 public function display($tpl = null)
 {
     if (function_exists('error_reporting')) {
         error_reporting(E_ALL & ~E_WARNING & ~E_NOTICE & ~E_STRICT);
     }
     /** load libraries for the system rener **/
     JSNFactory::localimport('libraries.joomlashine.mode.rawmode');
     JSNFactory::localimport('libraries.joomlashine.menu.menuitems');
     /** Assignment variables **/
     $jsntemplate = JSNFactory::getTemplate();
     $jsnmenuitems = JSNMenuitems::getInstance();
     /** get url **/
     $render_url = JRequest::getVar('render_url', '');
     $session = JSession::getInstance('files', array('name' => 'jsnpoweradmin'));
     if ($render_url == '' && $session->get('rawmode_render_url')) {
         $render_url = $session->get('rawmode_render_url');
     }
     $urlRender = base64_decode($render_url);
     if ($render_url == '') {
         $urlRender = JSNDatabase::getDefaultPage()->link;
     }
     $currUri = new JURI($urlRender);
     if (!$currUri->hasVar('Itemid')) {
         $currUri->setVar('Itemid', JSNDatabase::getDefaultPage()->id);
     }
     $urlString = $currUri->toString();
     $session->set('rawmode_render_url', base64_encode($urlString));
     $parts = JString::parse_url($urlString);
     if (!empty($parts['query'])) {
         parse_str($parts['query'], $params);
     } else {
         $params = array();
     }
     $jsnrawmode = JSNRawmode::getInstance($params);
     $jsnrawmode->setParam('positions', $jsntemplate->loadXMLPositions());
     $jsnrawmode->renderAll();
     $this->assign('component', $jsnrawmode->getHTML('component'));
     $this->assign('modules', $jsnrawmode->getHTML('positions'));
     $this->assign('jsnmenuitems', $jsnmenuitems);
     $this->assign('urlRender', $urlRender);
     /** add toolbar buttons **/
     $this->addToolBar();
     /** add scripts and css **/
     //$this->addMedia( $currUri->getVar('Itemid'), $urlString, array());//$jsnrawmode->getScript('positions', 'Array'));
     $this->addMedia($currUri->getVar('Itemid'), $urlString, $jsnrawmode->getScript('positions', 'Array'));
     return parent::display();
 }
Example #4
0
 static function _($url, $xhtml = false, $ssl = null, $d = false)
 {
     // skip any external urls
     if (strpos($url, "option") !== false && strpos($url, "option=com_fss") === false) {
         return JRoute::_($url, $xhtml, $ssl);
     }
     global $FSSRoute_debug;
     global $FSSRoute_menus;
     global $FSSRoute_access;
     self::$d = $d;
     // get any menu items for fss
     FSS_Helper::GetRouteMenus();
     // Get the router
     $router = JFactory::getApplication()->getRouter();
     // if the url dont start with index.php, we need to add the exisitng url to what we want
     if (substr($url, 0, 9) != "index.php") {
         //echo "Making FUll URL: $url<br>";
         $url = self::_fullURL($router, $url);
         //echo "Resut : $url<br>";
     }
     $uri = new JURI($url);
     // work out is we are in an Itemid already, if so, set it as the best match
     if ($uri->hasVar('Itemid')) {
         $bestmatch = $uri->getVar('Itemid');
     } else {
         $bestmatch = '';
     }
     $bestcount = 0;
     $uriquery = $uri->toString(array('query'));
     $urivars = FSSRoute::SplitURL($uriquery);
     $sourcevars = FSSRoute::SplitURL($url);
     // check through the menu item for the current url, and add any items to the new url that are missing
     if ($bestmatch && array_key_exists($bestmatch, $FSSRoute_menus)) {
         foreach ($FSSRoute_menus[$bestmatch] as $key => $value) {
             if (!array_key_exists($key, $urivars) && !array_key_exists($key, $sourcevars)) {
                 $urivars[$key] = $value;
             }
         }
     }
     $current_access = 0;
     if (array_key_exists(FSS_Input::getInt('Itemid'), $FSSRoute_access)) {
         $current_access = $FSSRoute_access[FSS_Input::getInt('Itemid')];
     }
     if ($d) {
         echo "Incoming Link : {$url}<br>";
         echo "Cur Item ID : " . FSS_Input::getInt('Itemid') . "<br>";
         //print_p($FSSRoute_menus);
     }
     foreach ($FSSRoute_menus as $id => $vars) {
         if ($d) {
             echo "{$id} => <Br>";
             print_p($vars);
         }
         // need to check if the access level is the same
         if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) {
             if ($d) {
                 echo "No Access<br>";
             }
             continue;
         }
         $count = FSSRoute::MatchVars($urivars, $vars);
         if (FSS_Input::getInt('Itemid') == $id && $count > 0) {
             if ($d) {
                 echo "Current ItemId: increase count<br>";
             }
             $count++;
         }
         if ($d) {
             echo "Count: {$count}<br>";
         }
         if ($count > $bestcount) {
             if ($d) {
                 echo "New best match - {$id}<br>";
             }
             $bestcount = $count;
             $bestmatch = $id;
         }
     }
     if ($bestcount == 0 && array_key_exists('view', $sourcevars) && substr($sourcevars['view'], 0, 6) == "admin_") {
         foreach ($FSSRoute_menus as $id => $item) {
             // need to check if the access level is the same
             if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) {
                 continue;
             }
             if ($item['view'] == "admin") {
                 $bestcount = 1;
                 $bestmatch = $id;
             }
         }
     }
     // no match found, try to fallback on the main support menu id
     if ($bestcount == 0) {
         foreach ($FSSRoute_menus as $id => $item) {
             // need to check if the access level is the same
             if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) {
                 continue;
             }
             if ($item['view'] == "main") {
                 $bestcount = 1;
                 $bestmatch = $id;
             }
         }
     }
     if ($bestcount == 0) {
         // still no match found, use any fss menu
         if (count($FSSRoute_menus) > 0) {
             foreach ($FSSRoute_menus as $id => $item) {
                 // need to check if the access level is the same
                 if ($current_access && array_key_exists($id, $FSSRoute_access) && $FSSRoute_access[$id] != $current_access) {
                     continue;
                 }
                 $bestcount = 1;
                 $bestmatch = $id;
                 break;
             }
         }
     }
     if ($d) {
         echo "Best Found : {$bestcount}, {$bestmatch}<br>";
     }
     // sticky menu items
     if (FSS_Settings::get('sticky_menus_type')) {
         $cur_item_id = FSS_Input::GetInt("Itemid");
         if ($cur_item_id > 0) {
             $sticky_ids = explode(";", FSS_Settings::get('sticky_menus'));
             if (FSS_Settings::get('sticky_menus_type') == 1 && in_array($cur_item_id, $sticky_ids) || FSS_Settings::get('sticky_menus_type') == 2 && !in_array($cur_item_id, $sticky_ids)) {
                 $bestcount = 0;
                 $uri->setVar('Itemid', $cur_item_id);
             }
         }
     }
     if ($bestcount > 0) {
         $uri->setVar('Itemid', $bestmatch);
         // we need to remove parameters that are in the main url as well as the sub one
         // wait till 2.2 for this change as it may break stuff
     }
     if ($d) {
         echo "Using : " . $uri->toString(array('path', 'query', 'fragment')) . "<br>";
     }
     return JRoute::_($uri->toString(array('path', 'query', 'fragment')), $xhtml, $ssl);
 }
 /**
  * Using CURL get page source.
  *
  * @param   string  $url  Link to get content
  *
  * @return  string
  */
 protected static function curlResponse($url)
 {
     $options = array(CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_USERAGENT => "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13", CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => 120, CURLOPT_TIMEOUT => 120, CURLOPT_MAXREDIRS => 10, CURLOPT_SSL_VERIFYPEER => false);
     $ch = curl_init($url);
     curl_setopt_array($ch, $options);
     $contents = curl_exec($ch);
     $err = curl_errno($ch);
     $errmsg = curl_error($ch);
     $header = curl_getinfo($ch);
     curl_close($ch);
     if ($err > 0) {
         exit('cUrl error number: ' . $err);
     }
     $response = new stdClass();
     $response->contents = $contents;
     $response->redirect_url = $header['redirect_url'];
     if ($response->redirect_url != self::$_renderUrl and trim($response->redirect_url) != '') {
         $old_uri = new JURI(self::$_renderUrl);
         $redirect_uri = new JURI($response->redirect_url);
         if ($old_uri->hasVar('tp') and !$redirect_uri->hasVar('tp')) {
             $redirect_uri->setVar('tp', 1);
         }
         if ($old_uri->hasVar('jsntpl_position') and !$redirect_uri->hasVar('jsntpl_position')) {
             $redirect_uri->setVar('jsntpl_position', 1);
         }
         if ($old_uri->hasVar('secret_key') and !$redirect_uri->hasVar('secret_key')) {
             $config = JFactory::getConfig();
             $secret = $config->get('secret');
             $redirect_uri->setVar('secret_key', md5($secret));
         }
         if ($old_uri->hasVar('Itemid') and !$redirect_uri->hasVar('Itemid')) {
             $redirect_uri->setVar('Itemid', $old_uri->getVar('Itemid'));
         }
         // Save redirect url
         self::$_renderUrl = $redirect_uri->toString();
         $response = self::curlResponse(self::$_renderUrl);
     }
     return $response;
 }
Example #6
0
 /**
  * Set URL for get front-end content. Correct URL
  *
  * @param   string  $url  Link
  *
  * @return  void
  */
 public function setRenderUrl($url = '')
 {
     $uri = new JURI($url);
     if ($uri->getScheme() == '') {
         $scheme = 'http';
         if (@$_SERVER['HTTPS']) {
             $scheme = 'https';
         }
         $uri->setScheme($scheme);
     }
     @(list($host, $port) = explode(':', $_SERVER['HTTP_HOST']));
     if ($uri->getHost() == '') {
         $uri->setHost($host);
     }
     if ($uri->getPort() == '') {
         $uri->setPort($port);
     }
     if (JString::strtolower($uri->getHost()) != JString::strtolower($host)) {
         $this->_isExternal = true;
     } else {
         if (!$uri->hasVar('poweradmin')) {
             $uri->setVar('poweradmin', '1');
         }
         if ($uri->hasVar('Itemid') and $uri->getVar('Itemid') == '') {
             $uri->delVar('Itemid');
         }
         $this->_renderUrl = $uri->toString();
     }
 }