Go Back   Gaming Gutter > Non-Gaming > Programming > Tutorials


Tutorials - Looking for programming tutorials to increase your knowledge? Do so here.

» Site Navigation
» Home
» FAQ
» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Advertisement
» Recent Threads
Go to first new post Selling a few pets for NP
Yesterday 09:06 AM
Last post by kamikaze_turtle
Today 05:55 PM
4 Replies, 5 Views
Go to first new post Selling lab account with...
Today 04:08 PM
by drdd10
Last post by drdd10
Today 05:55 PM
6 Replies, 7 Views
Go to first new post [S]elling Spotted pet...
Today 03:53 PM
by jtdusk
Last post by jtdusk
Today 05:50 PM
2 Replies, 3 Views
Go to first new post [B]: Legit Royal PB with...
Today 05:40 PM
Last post by fallingupriver
Today 05:48 PM
2 Replies, 3 Views
Go to first new post \o/MTVAwards\o/
Today 04:46 PM
by Connor
Last post by Oraski
Today 05:47 PM
1 Replies, 2 Views
Reply
 
LinkBack Thread Tools Display Modes

 [VB6]Create Chat Program[PHP]
Old 02-23-2007, 06:35 PM   #1 (permalink)
Bump J Bump J is offline
Banned
 
Bump J is offline
Join Date: Feb 2007
Posts: 100
iTrader: 0 / 0%
Bump J Is gaining popularity
Rep Power: 0
[VB6]Create Chat Program[PHP]

Heres a cheap chatter source

1st open up notepad and put this code
PHP Code:
<form action="conversation.php" method="post">
<center>
Username: <br><input type="text" name="user" /> <br>
Enter Your Message: <br><input type="text" name="message" /> <br>
<input type="submit" />
</center>
</form>

<?php
$myFile 
"conv.txt";

if (
$_POST["user"] || $_POST["message"] !=  '')
{


if (
filesize($myFile) >= '50000'///if the file is over 50,000 bytes its starts new converstion
    
{
        
$fh fopen($myFile'w') or die("can't open file"); ///opens conv.txt which is in your FTP server and writes a new conversation
        
$stringData $_POST["user"] . ": " .$_POST["message"] . "\n"///puts the username which is in the textbox and the message which is in the textbox
        
fwrite($fh$stringData); /// writes in conv.txt
        
fclose($fh); ///closes conv.txt
    
}

else 
///if its not 50,000 bytes then it adds to the conversation

    
{
        
$fh fopen($myFile'a') or die("can't open file"); ///opens conv.txt which is in your FTP server and appends to the conversation
        
$stringData $_POST["user"] . ": " .$_POST["message"] . "\n"///puts the username which is in the textbox and the message which is in the textbox
        
fwrite($fh,$stringData); /// writes in conv.txt
        
fclose($fh); ///closes conv.txt
    
}
}
?>
save it as conversation.php and upload it to your FTP server


2nd make empty txt file whose name is conv.txt and upload it to your FTP server


3rd Open VB and add this code

Code:
Dim strHTML As String
Dim strConv As String
Dim lngCount As Long

Private Sub Command1_Click()
If Len(txtUser.Text) = 0 Then
MsgBox "Enter Username"
ElseIf Len(txtMessage.Text) = 0 Then
MsgBox "Enter Message"
Else
strHTML = HTTP.PostWrapper("http://YOURSITE.com/conversation.php", "user=" & txtUser.Text & "&message=" & txtMessage.Text, "http://YOURSITE.com/conversation.php")
txtMessage.Text = ""
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
End
End Sub

Private Sub Form_Load
Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()
strConv = HTTP.DownloadFile("http://YOURSITE.com/conv.txt", App.Path & "Conv.txt")
List1.Clear
LoadList List1, App.Path & "Conv.txt"
lngCount = List1.ListCount - 1
List1.ListIndex = lngCount
End Sub
and remember to add these functions to HTTPWrapper

Code:
Private Function CheckForFile(filename) As Boolean
    CheckForFile = (Dir(filename) <> "")
End Function

Public Function DownloadFile(URL As String, Path As String)
    Dim Filenum As Integer, strHTML As String
    If CheckForFile(Path) = True Then
        Kill Path
    End If
    Filenum = FreeFile
    strHTML = StripHeaders(GetWrapper(URL))
    Open Path For Output As Filenum
        Print #Filenum, strHTML
    Close Filenum
End Function

Public Function StripHeaders(strHTML As String) As String
    Dim strParts() As String
    'Split at the two line break
    strParts = Split(strHTML, vbCrLf & vbCrLf, 2)
    StripHeaders = strParts(1) 'return the body
End Function

'FUNCTIONS RIPPED FROM RIPPERWRAPPER
  Reply With Quote
Reply

Bookmarks



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

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

Powered by vBadvanced CMPS v3.0 RC2

All times are GMT -7. The time now is 05:58 PM.


vBulletin skin developed by: eXtremepixels
The contents of this webpage are copyright © 2006-2008 GamingGutter.com. All Rights Reserved.

Page generated in 0.09888101 seconds (100.00% PHP - 0% MySQL) with 19 queries