TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
 
 
LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
Old 04-06-2008, 09:03 PM   #1 (permalink)
The Prestige
Upcoming Programmer Inquisitive 
 
Tanax's Avatar
 
Join Date: Sep 2007
Location: Sweden, Stockholm
Posts: 1,080
Thanks: 115
Tanax is on a distinguished road
Default Stream problem

Hi!

I'm currently developing a script for a community for WoW-fans.
The problem is that they only want people who currently have an active account OR an account at all.

So I have to make a script that runs a check from the real wow-site and tries to login with the values provided by the user that is trying to register on the community.

However, this script is not supposed to store any values, since that is very illegal(phishing), and it's only supposed to run in the background when the user register.

So, what's the problem?
Well, I get this error:

Quote:
Warning: file_get_contents(https://www.wow-europe.com/login/log...m%2Faccount%2F) [function.file-get-contents]: failed to open stream: Invalid argument in C:\wamp\www\script.php on line 60
Invalid Account
This is the code:
php Code:
/**
||||||||||||||||||||||||||||||||||||||||||
|||| @author Tanax
|||| @copyright 2008
||||||||||||||||||||||||||||||||||||||||||
**/

   
/** --------------------------------------->
 ** Configuration
 **/

 
    // Names of the fields on the remote website.
    $field1_name_remote = 'username';
    $field2_name_remote = 'password';
    $submit_remote = 'Login';
   
    // Names of the fields on the local website.
    $field1_name_local = 'acc';
    $field2_name_local = 'pass';
   
    // String to search for on the logged remote page.
    $find = 'Account Type:';
   
    // The url to the account login-page on the remote website.
    $url = 'https://www.wow-europe.com/login/login?service=https%3A%2F%2Fwww.wow-europe.com%2Faccount%2F';
   
   
/** --------------------------------------->
 ** Don't touch!
 **/

    
    // Get the values from the input on local website.
    $field1_value_local = $_POST[$field1_name_local];
    $field2_value_local = $_POST[$field2_name_local];
   
    // Set up the data.
    $data = array(
        $field1_name_remote => $field1_value_local,
        $field2_name_remote => $field2_value_local,
        'submit' => $submit_remote
    );
   
    // Take away htmlspecialchars and build a query from the data.
    $query = htmlspecialchars_decode(http_build_query($data));
    // Create the stream and try to login with the query.
    $stream = stream_context_create(array(
       
        'http' => array(
           
            'method' => 'POST',
            'header'=> "Content-type: application/x-www-form-urlencoded\r\n" . "Content-Length: " . strlen($query) . "\r\n",
            'content' => $query
           
        )
       
    ));
    // Get the content from the page.
    $content = file_get_contents($url, false, $stream);
   
    // Search for the string.
    $search = strpos($content, $find);

    if($search === false){

        echo 'Invalid Account';

    }

    else {

        echo 'Valid Account';

    }

I'm only using the echo there to try the script, this will most likely to be converted to a function and then instead of echo 'valid account' it will return true, and return false on invalid account.

Also, if it's to any help, this is the form:
html Code:
<form action="script.php" method="POST">
Account name:<br />
<input type="text" name="acc" /><br /><br />

Password:<br />
<input type="text" name="pass" /><br /><br />

<input type="submit" name="submit" value="Login">
</form>
__________________

Last edited by Tanax : 03-09-2009 at 08:29 PM.
Tanax is offline  
Reply With Quote
 



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 08:30 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design