TCP reading from webpage

BlitzPlus Forums/BlitzPlus Beginners Area/TCP reading from webpage

Nike(Posted 2009) [#1]
Hi! I am trying to make a e-mailer. I need some helping getting the usernames and passwords. Here is all of my code so far...
main=CreateWindow("Login",400,300,400,150,0)  
CreateLabel("Username",0,0,70,20,main,0) 
CreateLabel("Password",0,25,70,20,main,0) 
CreateLabel(\"@...)
username=CreateTextField(80,0,100,20,main) ;create textfield in that window 
pass=CreateTextField(80,25,200,20,main) ;create textfield in that window 
ok=CreateButton("Login",0,50,80,29,main) ;create button 
menu=WindowMenu(main) 
file=CreateMenu("File",0,menu) ; main menu 
CreateMenu "Register",1,file ; child menu 
CreateMenu "",0,file ; Use an empty string to generate separator bars 
CreateMenu "New account",3,file ; another child menu 
UpdateWindowMenu main



Repeat 
If WaitEvent()=$803 Then Exit 
If ID=$1001 Then 
EID=EventData() ; Event data contains the menu ID specified when creating the menu items 
Select EID 
Case 1 

Case 3 

End Select
EndIf 
Forever 

I need it so that when you hit the login button, it checks my website for the username and password, and if they are together, it logs in. The usernames and passwords are in a txt file in the format:
"Username"
"Password"
"Username"
"Password"
and so on. like if my username was bob@...
and my password was obb it would look like this:

bob@...
obb

How could i get it to check?


Sauer(Posted 2009) [#2]
You will probably need some kind of database running on your server to check this. This means you need another program running on your server that can read and write the text file, then send the information to their program.

Blitz probably isn't your best tool for this, but PHP and SQL would be the good.

The other option is to have your program connect to a server written in BlitzPlus on your machine. The only problem with this is that you'd have to have the computer and your server constantly on, or else they wouldn't be able to connect.

If you have a spare computer connected to the internet, you're all set, because it usually isn't a good idea to leave your main computer on constantly... but it is possible.


Nike(Posted 2009) [#3]
ok thanks, I will probolly have to keep my computer on with the server until I can figure out PHP or SQL. Think I can set up a server on my iPhone?


Nike(Posted 2009) [#4]
Ok i can't figure out SQL and the download wont work. Is there another way to get a server and still, is there any way to get a server on my iPhone?


xlsior(Posted 2009) [#5]
ok thanks, I will probolly have to keep my computer on with the server until I can figure out PHP or SQL. Think I can set up a server on my iPhone?


Who knows -- but one major downside that you'll run into is that the iphone can only run one app at a time, so even if you somehow got it to work, you couldn't do anything else at the same time.

Now, one additional complication when running an email server/service on your own PC, is that there are a LOT of email servers out there that will reject any email originating on an IP address that is inside a known block of dialup/cable/DSL IP's. Unless you either your stuff through your ISP's email server or have your program run on a hosting server somewhere, there's a good chance that many people wouldn't be able to receive the messages you are sending out.


Nike(Posted 2009) [#6]
Ok, then this will be harder then i thought... if you run this code:
tcp=OpenTCPStream( "www.theadventurescape.com",80 ) 
;WriteLine tcp,"GET http://www.theadventurescape.com/uap.txt HTTP/1.0" 
WriteLine tcp,"GET http://www.theadventurescape.com/uap.txt" 
WriteLine tcp,Chr$(10) 
While Not Eof(tcp)
Print ReadLine$( tcp )
Wend 
WaitKey()

it will show the txt file i intended to hold usernames and passwords. Is there a way to get all of the other stuff out? Like on that code, how would i get it to just show the e-mails and passwords? (Those will not the real passwords)


Sauer(Posted 2009) [#7]
You would need to store the ReadLine$(tcp) return value as some variable, and either store it in an array, type, or text file on the local machine. From there the client code could interpret the messages as needed.


Nike(Posted 2009) [#8]
So if I had this for the login, i would not have to use MySQL or run a server off of my computer as long as my website is up?


Sauer(Posted 2009) [#9]
There's always a work-around to things, so I guess you can. Try it out and let us know how it goes.

A system like this will have security issues, as anyone can read the text file.