Style sheet does not load when accessing via ssh tunnel

A place for users and developers of the Xataface to discuss and receive support.

Style sheet does not load when accessing via ssh tunnel

Postby rleyba » Thu Aug 18, 2011 7:27 am

Hi Steve,

Just need some help to allow some kind of hostfile substitution in the index.php file of my application (or in whatever file needs to be modified) so that we can put in a path name instead of the IP address. In our setup, the xataface site is behind a firewall and we need to do a local ssh tunnel through this firewall so we can get to the site.

Example: We need to access the site via http://127.1.8.10/xataface-1.2.6/ChangeOrder/index.php although the site itself has the address 192.168.1.17. What happens then is when we access the site externally, the resulting generated html page contains a mix of the "referred URL"....127.1.8.10 and the "true" site ip address of 192.168.1.17 causing the site to not load properly (specifically, the CSS and other javascript links and the/images directory). See my attached show page source (excerpt only).

I was wondering if there is a way to play with the index.php file (or any initialization file) so that I can use the refferred IP....127.1.8.10 instead of the true IP (192.168.1.17) in this case?

Thanks very much.

this is the index.php file

Code: Select all
<?php
/**
* File: index.php
* Description:
* -------------
*
* This is an entry file for this Dataface Application.  To use your application
* simply point your web browser to this file.
*/
$time = microtime(true);
        // use the timer to time how long it takes to generate a page
require_once '/var/www/html/xataface-1.2.6/dataface-public-api.php';
        // include the initialization file
df_init(__FILE__, 'http://192.168.1.17/xataface-1.2.6');
        // initialize the site

$app =& Dataface_Application::getInstance();
        // get an application instance and perform initialization
$app->display();
        // display the application


$time = microtime(true) - $time;
echo "<p>Execution Time: $time</p>";




An excerpt of the page source looks like this:


Code: Select all
   
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
   <head>
               
         <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
      <title>CHG000000027733 - Dataface Application</title>
      <link rel="stylesheet" type="text/css" href="http://192.168.1.17/xataface-1.2.6/plone.css"/>      <!-- Stylesheets go here -->      
            <!-- Common Plone ECMAScripts -->
   
      <!-- Pull-down ECMAScript menu, only active if logged in -->
      
      <script type="text/javascript"
            src="http://192.168.1.17/xataface-1.2.6/plone_menu.js">
      </script>

   
      <!-- Define dynamic server-side variables for javascripts in this one  -->
      <script type="text/javascript"
            src="http://192.168.1.17/xataface-1.2.6/plone_javascript_variables.js.php">
      </script>
      <script type="text/javascript" language="javascript"><!--
      DATAFACE_URL = 'http://192.168.1.17/xataface-1.2.6';
      DATAFACE_SITE_URL = '/xataface-1.2.6/ChangeOrder';
      DATAFACE_SITE_HREF = '/xataface-1.2.6/ChangeOrder/index.php';
      
      //--></script>
   
      <script type="text/javascript"
            src="http://192.168.1.17/xataface-1.2.6/plone_javascripts.js">
      </script>
            
                                  
       <script type="text/javascript" src="http://192.168.1.17/xataface-1.2.6/js/jquery.packed.js"></script>
       <script type="text/javascript"><!--

          if ( typeof(Xataface) == 'undefined' ) Xataface = {};
          if ( typeof(Xataface.blocks) == 'undefined' ) Xataface.blocks = {};
          if ( typeof(Xataface.blocks.collapsible_sidebar) ) Xataface.blocks.collapsible_sidebar = {};
          Xataface.blocks.collapsible_sidebar.toggleCallback = function(){
             // this : dom element
             jQuery(this).toggleClass('Dataface_collapsible_sidebar-closed');
             jQuery(this).toggleClass('closed');
             var img = jQuery(this).prev().find('img').get(0);
             if ( img.src == 'http://192.168.1.17/xataface-1.2.6/images/treeExpanded.gif' ) img.src = 'http://192.168.1.17/xataface-1.2.6/images/treeCollapsed.gif';
             else img.src = 'http://192.168.1.17/xataface-1.2.6/images/treeExpanded.gif';
             
             if ( jQuery(this).hasClass('closed') ){
                var collapseCallback = this.parentNode.getAttribute('oncollapse');
                
               this.parentNode.oncollapse = function(){eval(collapseCallback);};
               this.parentNode.oncollapse();   
             } else {
                var expandCallback = this.parentNode.getAttribute('onexpand');
               this.parentNode.onexpand = function(){ eval(expandCallback);};
               this.parentNode.onexpand();
             }
          
          };
          jQuery(document).ready(function($){
             var handles = jQuery('.expansion-handle');
             for ( var i=0; i<handles.length; i++ ){
                jQuery(handles[i]).click(function(){
                   jQuery(this).parent().next().slideToggle("slow", Xataface.blocks.collapsible_sidebar.toggleCallback);
                });
             }
             
          });
       
       //-->
      </script>

       
       
                  <!-- custom javascripts can go in slot "custom_javascripts" -->
            
            <!-- Place any other items in the head of the document by filling the "head_slot" slot -->
                  
   

   </head>
   <body onload="bodyOnload()" >

      <link rel="alternate" href="http://127.1.8.10/xataface-1.2.6/ChangeOrder/index.php?-table=ChangeRecord&-action=feed&-cursor=0&-skip=0&-limit=30&-mode=list&-recordid=ChangeRecord%3FChangeNumber%3DCHG000000027733"
          title="RSS 1.0" type="application/rss+xml" />

   
   <!-- Replace the entire HTML Body with the "html_body" slot -->
   <div id="top-section">
      
             <div id="site_logo">

             <img src="http://192.168.1.17/xataface-1.2.6/images/logo-small.jpg" alt="Dataface Web Application   
* Framework"/>
rleyba
 
Posts: 53
Joined: Sat Dec 04, 2010 3:50 pm

Re: Style sheet does not load when accessing via ssh tunnel

Postby shannah » Thu Aug 18, 2011 9:51 am

What I usually do in cases like this is to take a look at the $_SERVER array and modify values appropriately at the beginning of the index.php file.

E.g.
do a print_r($_SERVER); just to see what the values are. Then change the ones that are wrong.
e.g.
$_SERVER['HTTP_HOST'] = '192.168.1.10';
...
etc..

-Steve
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

Re: Style sheet does not load when accessing via ssh tunnel

Postby rleyba » Fri Aug 19, 2011 5:36 pm

Thanks Steve, I shall try this out.

In the meantime, can I request your help in my other forum inquiry? --> viewtopic.php?f=4&t=6208
rleyba
 
Posts: 53
Joined: Sat Dec 04, 2010 3:50 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 20 guests

Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved