We help IT Professionals succeed at work.

Complicated Transparent remote access site mashup

331 Views
Last Modified: 2010-04-16
Hello,

I have a webpage that will provide remote access to people using a service from a website called SkyFex. The client visits the webpage https://skyfex.com/client/ and is given a 6-digit number. They provide this to a helper who then remotely connects to the client. I want to provide this transparently through my site, so they see no skyfex branding (not concerned with the ethics at the moment, will solve that later.)

Here is the process I am currently using:
Open index.php with a blank iframe
index.php makes a background AJAX call to skyfex.php
skyfex.php uses a php curl proxy through godaddy.com's server (my hosted server) to open the page https://skyfex.com/client/ and sends bogus useragent information so the page will think the webserver is actually a browser(IE7).
the response page is sent back and stored in a variable
the variable to written to a php file named skyfexsession.php
change iframe src on index.php to skyfexsession.php, and find the div innerHTML which contains the 6-digit number and throw an alert with the number

I get the information back fine, but when you try to connect to that remote access on skyfex's site it does not work (error "client id not found"). I am assuming there is a problem with the php being ran from the page i am trying to receive from skyfex, or cookies, or something, I cannot be sure. Is there anyone brave enough to try to tackle this issue? Here is the code across the pages:

//////////////////      index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<iframe src="about:blank" style="visibility:hidden; position:absolute;height:500;width:250px" id="skyfexframe" name="skyfexframe"></iframe>
<script type="text/javascript">
function getothersite() {
    if (window.XMLHttpRequest) {
        http = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
        http = new ActiveXObject("Microsoft.XMLHTTP");
    }
        http.open("GET", 'skyfex.php', true);
        http.onreadystatechange = getxmlvalidate;
        http.send(null);
}
function getxmlvalidate() {
    if (http.readyState == 4) {
         myframe = document.getElementById('skyfexframe');
        myframe.src = "skyfexsession.php";
         setTimeout("getnumber()", 5000);
    }
}
function getnumber() {
            alert(window.frames['skyfexframe'].document.getElementById('client_id').innerHTML);
}
window.onload = getothersite;
</script>
</body>
</html>



////////////////////////     skyfex.php
<?
session_start();
$FULLURL = "https://skyfex.com/client/";
$useragent = 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt ($ch, CURLOPT_PROXY,"http://proxy.shr.secureserver.net:3128");
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_URL, $FULLURL);
curl_setopt ($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close ($ch);
$result = str_replace('CODEBASE = "/download/SkyFexClient.cab#Version=1,0,2,106"','CODEBASE = "http://skyfex.com/download/SkyFexClient.cab#Version=1,0,2,106"',$result);
$phpfilename = "skyfexsession.php";
$phpfilehandle = fopen($phpfilename, 'w') or die("can't write file");
fwrite($phpfilehandle, $result);
fclose($phpfilehandle);
exit();
?>


///////////// example of what is written to skyfexsession.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
   <Title>SkyFex Remote Assistant Client</title>
   <link rel="stylesheet" href="https://skyfex.com/styles.css" type="text/css">
   <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
   <script language="javascript" type="text/javascript" src="https://skyfex.com/js/strings.js"></script>
   <script language="javascript" type="text/javascript" src="https://skyfex.com/js/client.js"></script>
      <script language="javascript" type="text/javascript">
            bDebug = 0;
      </script>
      <script for="skyClient" event="ActiveXMessage(id_message, text_message)" language="javascript" type="text/javascript">
      ActiveXMessage(id_message, text_message);
      </script>
      <script for="skyClient" event="ActiveXResize(left,top,right,bottom)" language="javascript" type="text/javascript">
    ActiveXResize(left,top,right,bottom);
    </script>
   <script language="javascript" type="text/javascript">
   function GetUrl()
      {
            var a = document.URL;
            var i = a.length;
            for(i=0;a.charAt(i)!= '/' ;i++);
            for(i++;a.charAt(i)!= '/' ;i++);
            for(i++;a.charAt(i)!= '/' ;i++);
            var it = "";
            var j;
            for(j = 0;j <= i;j++)
            {
                  it += a.charAt(j);
            };
            //it += "c.xsl"
            //it = it.replace("https","http");
            return it;
      }
      </script>
</head>
<body id="client" onactivate="Initialize();" onbeforeunload="ConfirmExit();">
<!-- ********** noscript browser********** -->
<noscript>
    <DIV id="pnlNoJavaScript" style="BORDER-RIGHT: #f3cb6a 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #f3cb6a 1px solid; PADDING-LEFT: 5px; PADDING-BOTTOM: 5px; BORDER-LEFT: #f3cb6a 1px solid; WIDTH: 472px; PADDING-TOP: 5px; BORDER-BOTTOM: #f3cb6a 1px solid; POSITION: relative; HEIGHT: 316px; BACKGROUND-COLOR: #fff4c3"
        align="left" ms_positioning="FlowLayout">
        <P>
            Your browser is not allowed to start JavaScript.&nbsp;Please
            allow&nbsp;JavaScript to run&nbsp;SkyFex Remote Assistant.<BR>
            <STRONG>
                <BR>
                Windows 2003 Server</STRONG> users:<BR>
            If ActiveX is not started this means you have High security level for Internet.
            To start SkyFex Remote Assistant please add <A href="https://skyfex.com/client/">skyfex.com</A>
            to&nbsp;the Trusted Sites zone:</P>
        <UL>
            <LI>
            Open Tools-&gt;Internet Options...-&gt;Security
            <LI>
            Select 'Trusted sites' icon
            <LI>
            Click on the 'Sites...' button
            <LI>
            Click on the 'Add' button
            <LI>
            Click on the 'Close' button
            <LI>
            Click OK
            <LI>
                <STRONG>Reload</STRONG> this page</LI></UL>
    </DIV>
</noscript>
<!-- ********** pnlSP2Instructions ********** -->
<DIV id="pnlSP2Instructions" style="  DISPLAY: none; WIDTH: 472px;   POSITION: relative; HEIGHT: 382px; " ms_positioning="GridLayout">
    <DIV         ms_positioning="FlowLayout" align="center">
    <STRONG>To start SkyFex Remote
            Assistant&nbsp;please follow these steps:</STRONG></DIV>
    <DIV >
    <IMG  alt="" src="https://skyfex.com/img/InstallDialog3_client_pro.gif">
    </DIV>
</DIV>
<!-- ********** pnlInstructions ********** -->
<DIV id="pnlInstructions" style="  DISPLAY: none; WIDTH: 500px;   POSITION: relative; HEIGHT: 382px;" ms_positioning="GridLayout">
      <DIV         ms_positioning="FlowLayout" align="center">
      <STRONG>To start&nbsp;SkyFex Remote Assistant click on the 'Yes' button&nbsp;in this window.</STRONG>
      </DIV>
      <DIV >
    <IMG  alt="" src="https://skyfex.com/img/InstallDialog2.gif">
    </DIV>
</DIV>
<!-- ********** cookie ********** -->
<DIV id="box_cookie" style="display:none;BORDER-RIGHT: #f3cb6a 1px solid; BORDER-TOP: #f3cb6a 1px solid; BORDER-LEFT: #f3cb6a 1px solid; WIDTH: 620px; BORDER-BOTTOM: #f3cb6a 1px solid; POSITION: relative; HEIGHT: 120px; BACKGROUND-COLOR: #fff4c3">
    <span id="lbHeader" class="Header2" style="width:616px;"><strong>Cookies Disabled.</strong></span><BR>
    <BR>
    <span id="lbMessage" style="height:72px;width:609px;"><p align=left style="MARGIN-LEFT: 10px">
Your browser currently has cookies disabled. We apologize for the inconvenience, but you will need to enable cookies before you can
<a href="https://skyfex.com/client/"><strong>join assistance session</strong></a>.
To help you make the change, below are instructions for enabling cookies:<BR><BR>
<strong>Microsoft Internet Explorer 6.0+</strong><BR>
Select "Internet Options" from the Tools menu.<BR>
Click on the "Privacy" tab.<BR>
Click the "Default" button (or manually slide the bar down to "Medium") under "Settings".<BR>
Click "OK".<BR>
<BR>
<strong>Microsoft Internet Explorer 5.x</strong><BR>
Select "Internet Options" from the Tools menu.<BR>
Click on the "Security" tab.<BR>
Click the "Custom Level" button.<BR>
Scroll down to the "Cookies" section.<BR>
To enable:<BR>
Set "Allow cookies that are stored on your computer" to "Enable".<BR>
Set "Allow per-session cookies" to "Enable".<BR>
Click "OK".<BR><BR>
</p>
</span>
</DIV>
<div id="source_body" style="display:none">
<!-- ********** header layout ********** -->
<div id="head_out"><div id="head_in">
      <table width="100%">
      <tr>
      <td align="left">
            <img src="https://skyfex.com/img/skyfex.gif" width="163" height="37" alt="SKYFEX" title="SKYFEX" id="logo">
      </td>
      <td width="100%">
      </td>
      <td >
            <div id="SupportVista" style="display:none;">
                  <a href="http://skyfex.com/client/main.html" target="_blank">Support Vista</a>
            </div>
      </td>
      <td >
            <a href="http://skyfex.com" target="_blank">SkyFex&nbsp;web&nbsp;site</a>&nbsp;&nbsp;&nbsp;
      </td>
      <td >
            <a href="http://skyfex.com/help.php" target="_blank">Help</a>&nbsp;&nbsp;&nbsp;
      </td>
      <td >
      <INPUT type="button" id="mail_button" name="mail_button" value="Submit Log" onClick="b_mail();" style="display:none;">
      </td>
      <td width="5px" align="right">&nbsp;</td>
      <td >
            <input type="button" class="button" id="exit_button" name="exit_button" value="Exit" onClick="exit();" >
      </td>
      <td width="5px" align="right">&nbsp;</td>
      </tr>
   </table>
</div>
</div>
      <div class="box" id="msg_limit" style="padding-top:5px; padding-bottom:5px; padding-right:5px; display:none;text-align:right;">
      <table>
      <tr>
            <td>
            <INPUT type="button" id="file_button" name="file_button" value="Send File" onClick="b_file();" style=" WIDTH: 100px;">
            </td>
            <td width="5px"></td>
            <td>
            <INPUT type="button" id="chat_button" name="chat_button" value="Start Chat" onClick="b_chat();" style=" WIDTH: 100px;">
            </td>
      </tr>
      </table>
    </div>
<!-- ********** messages layout ********** -->
<div class="box" id="msg_generic" style="display:none">
   <h2 id="message_title">SkyFex Remote Assistant.</h2>
   <div id="message_text">
      <p>No activity has been detected in the last 5 minutes. You have been disconnected from SkyFex server. To join session again please click</p>
      <a href="https://skyfex.com/client/"><strong>Get Assistance</strong></a>.
   </div>
</div>
<!-- ********** client_id layout ********** -->
<div class="msg_client_id">
    <div id="msg_client_id" style="display:none">
        <div class="client_id">
            <div id="client_id">
362 951
            </div>
        </div>
        <big>Client ID:</big>
    </div>
      <div class="box" >
            <table cellpadding="10" cellspacing="10">
            <tr><td align="center">
            <div id="enterid_status"  style="display:block"></div>
            <div id="debug_status" style="display:block"></div>
            </td></tr>
            </table>
      </div>
</div>
</div>
<BR>
<script language="javascript" type="text/javascript">
        SaveParam("362951","69.57.144.11","skyfex.com",GetUrl());
</script>
<div style="display:none">
http://skyfex.com/download/
</div>
<!-- <div id="activexclient" >-->
<OBJECT ID="skyClient" CLASSID="CLSID:F84E0B64-1E86-4640-8094-5B38CEB28C1E" height="1" width="1" CODEBASE = "/download/SkyFexClient.cab#Version=1,0,2,106">
<PARAM name="activex_enable" value=0>
</OBJECT>
<!-- </div>-->
<script language="javascript" type="text/javascript">
        //activateObject();
</script>
<!-- mummy -->
</body>
</html>
Comment
Watch Question

Can you actually make the AJAX call from your client? Looks like you're hitting the AJAX cross-domain security wall. You might have to do all of your "AJAX" in an iframe.
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.