Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21278

Unable to Post to Web Page Using Internet Transfer Control

$
0
0
This is my first post as I just joined today. I'm trying to create a program that will check the online connection status of a Skype adapter that is plugged into my network. The Skype adapter allows a regular telephone to connect through my router allowing incoming and outgoing calls using Skype. It works flawlessly most of the time but as with most network appliances it sometimes hiccups and loses connection to Skype or worse to the router.

I'm using VB6 on XP and the code I have so far uses the Internet Transfer Control to connect to my router's ARP page and looks for a match to the known MAC address of the Skype adapter to find the current IP in use by the device. That code works just fine. By the way, I have been unable to ping the hostname of the device directly so I can't get the IP that way.

The problem I'm having is in posting the required Skype name and password to the adapter's log in web page. I do not really have a good understanding of Visual Basic, HTML or Javascript (which the web page contains) so please forgive my ignorance as I'm sure I'm not seeing the obvious. The INET EXECUTE I use with the POST operation does not generate any kind of error but when I try to open the next URL into a variable after doing so I just see the original URL's generic web page code with no indication that anything processed at all. I have scoured the web for about a week now and know there are other methods besides INET for getting this to work but my main goal seems so simple I would think that INET would work.

I am so close at this point because if I can get the log on to work then I know the device has a good connection on my network and then all I need to do is view a different page on the device which shows the Skype connection status.

I have included what Firefox shows as the HTML source for the logon page as well as the snippet of code I'm trying to use to post the logon. Again, please excuse my ignorance if there is something obvious I am doing wrong. Could it have something to do with the uft-8 charset or the use of frames? Please feel free to point me to some existing code examples that may give me clue or just tell me if it is a simple solution.

HTML source -
Code:

<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>Login</title>
    <link rel="stylesheet" href="css/screen.css?v=1.0">
    <link rel="shortcut icon" href="images/favicon.png">
</head>

<body id="login">
<iframe id="log_in" width="0" height="0" frameborder=0></iframe>
<input type="hidden" id="defaultaccount" value="1">
    <div id="wrapper">

        <div id="content">
           
                <img src="images/connect-me-logo.png" class="connect-logo">
                <h1>Login</h1>
<p>Administration area is password protected to secure your private information from unauthorized access. Please login with your Skype credentials used during the first setup of <strong>FREETALK&reg; Connect&bull;Me</strong>.</p>
                <div class="notice" id="status_login" style="display:none">Please login again to authenticate your username and password.</div><!--Please ... password.-->
                <div class="error" id="status_check" style="display:none">Error: Username or password incorrect.</div><!--Error: ... incorrect.-->
                <form action="login.php" method="post">
                    <dl>
                        <dt><label for="skype-name">Skype Name</label></dt><!--Skype Name-->
                        <dd>
                            <input type="text" id="skype-name" maxlength="32" onkeydown="if (event.keyCode==13) login();">
                            <p class="note"><a href="https://login.skype.com/account/login-form?intcmp=sign-in&return_url=https://secure.skype.com/account/login">FORGOT YOUR SKYPE NAME?</a></p><!--Forgot ... name?-->
                        </dd>
                    </dl>
                    <dl>
                        <dt><label for="password">Password</label></dt><!--Password-->
                        <dd>
                            <input type="password" id="password" maxlength="20" onkeydown="if (event.keyCode==13) login();">
                            <p class="note"><a href="https://login.skype.com/account/login-form?intcmp=sign-in&return_url=https://secure.skype.com/account/login">FORGOT YOUR PASSWORD?</a></p><!--Forgot ... password?-->
                        </dd>
                    </dl>
                   
                    <dl>
                        <img src="images/loading.gif" class="loading" id="status_wait" alt="Loading..." style="display:none">
                        <dd><input type="button" class="button" id="encrypt" value="Login" onclick="login();"></dd>
                    </dl>
                </form>
        </div>
    </div>

    <div id="footer">
        <div class="version">
            <strong>FREETALK&reg; Connect&bull;Me</strong><!--FREETALKⓇ Connect∙Me-->
            <br>
            Software Version: 1.0.9.0<!--Software Version: 0.0.00-xx-->
        </div>
        <div class="logo">FREETALK</div>
    </div>

    <script src="js/jquery.min.js?v=1.6.1"></script>
    <script src="js/head.min.js?v=0.96"></script>
    <script src="js/scripts.js?v=1.0"></script>
</body>

</html>

<SCRIPT language=JavaScript>

function error(value)
{
    if (value==1) window.location = "../administration/home.php";
    else
    {
        document.getElementById('status_wait').style.display = "none";
        document.getElementById('status_check').style.display = "";
        document.getElementById("password").value = "";
        $('form').find('dl:first').addClass('error');
        $('form').find('dl:nth-child(2)').addClass('error');
    }
}

function cipher(value)
{
    var ciphertext = '';

    for (index=0; index<value.length; index++)
    {
        if (index<(value.length-1)) ciphertext = ciphertext + (value.charCodeAt(index) ^ keycipher.charCodeAt(index)) + ',';
        else ciphertext = ciphertext + (value.charCodeAt(index) ^ keycipher.charCodeAt(index));
    }
    return ciphertext;
}

function login()
{
    var skype = document.getElementById("skype-name").value;
    var pass = document.getElementById("password").value;
    var error = 0;

    if (skype=="" || pass=="") error = 1;
    for (i = 0; i<skype.length; i++)
    {
        skypechar = skype.toUpperCase().charCodeAt(i);
        if (i==0) if (skypechar<65 || skypechar>90) error = 1;
        if (i>0) if (skypechar<44 || skypechar==47 || (skypechar>57 && skypechar<65) ||
            (skypechar>90 && skypechar!=95)) error = 1;
    }
    if (error==0)
    {       
        document.getElementById('status_wait').style.display = "";
        pass = cipher(pass);
        document.getElementById("log_in").src = "wizard/0-detection.php?id=6&name=" + skype + "&pass=" + pass;
        document.getElementById('status_check').style.display = "none";
        $('form').find('dl:first').removeClass('error');
        $('form').find('dl:nth-child(2)').removeClass('error');
    }
    else
    {
        document.getElementById('status_check').style.display = "";
        $('form').find('dl:first').addClass('error');
        $('form').find('dl:nth-child(2)').addClass('error');
    }
}

if (document.getElementById("defaultaccount").value!=1)
    document.getElementById("status_login").style.display = "";

</script>

VB6 snippet -
Code:

' *** Code up to this point works fine and allows me to retrieve the IP address for the Skype adapter in the next line

              CnctMeIP = Mid(pgstrg, IPstart, IPend - IPstart + 1)
 
              Inet1.Cancel

' *** Here's where I set up the variables to pass to the web page - maybe the web page doesn't allow for receiving these?
' *** Do I need to create my own variation of the web page to plug in the variables?

              strOptions = "skype-name=first.midwest.properties&password=ch00law00d"

              Inet1.Execute "http://" & CnctMeIP & "/login.php", "POST", strOptions & vbCr, _
                "Content-Type: application/x-www-form-urlencoded" & vbCr

              While Inet1.StillExecuting
                DoEvents
              Wend

              Inet1.URL = "http://" & CnctMeIP & "/administration/system-settings.php"

              pgstrg = Inet1.OpenURL

              While Inet1.StillExecuting
                DoEvents
              Wend

              For x = 1 To Len(pgstrg) Step 1024
                MsgBox Mid(pgstrg, x, 1024)
              Next x
 
' *** The message boxes just display what seems to be the code for the original login.php without any variable values plugged in

Thanks for any help...

Viewing all articles
Browse latest Browse all 21278

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>