Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

New to php

Status
Not open for further replies.

MAWarGod

Programmer
Feb 15, 2002
352
US
I am trying to make a functional skeleton of a web based chat server with php
Using a basic framework for this concept and functions. I haven’t been able to find any open source programs like this that showed the concept on how to stream real time data into the browser like the web based chat rooms on chatro, webmaze or alterrealm does
So I guess I need a login page (login.html) that passes, pushes or strings the data input or info that I would name $USER, $LOGIN, $PASSWORD, $USERPASS, $HISTORY, $NOPIC and $SAYS now this would also pass name:user ip to a file log userip.txt
<FORM METHOD="POST"
ACTION=" target=_top>
<TABLE WIDTH="550" BORDER="1" CELLSPACING="0">
<TR>
<TD ALIGN="RIGHT">Name:</TD>
<TD> <INPUT NAME="USER" VALUE="To Lazy to type" SIZE="20"></TD>
</TR>
<TR>
<TD ALIGN="CENTER" VALIGN="MIDDLE">
<TABLE WIDTH="100%" BORDER="0"
CELLSPACING="0">
<TR>
<TD ALIGN="RIGHT">Login:</TD>
<TD> <INPUT NAME="LOGIN"
SIZE="10"></TD>
</TR>
</TABLE> </TD>
<TD ALIGN="CENTER" VALIGN="MIDDLE">
<TABLE WIDTH="100%" BORDER="0"
CELLSPACING="0">
<TR>
<TD ALIGN="RIGHT">Password:</TD>
<TD> <INPUT NAME="USERPASS"
VALUE="" SIZE="10"></TD>
</TR>
</TABLE> </TD>
</TR>
<TR>
<TD ALIGN="CENTER" VALIGN="MIDDLE" COLSPAN="2">
<SELECT NAME="SAYS" SIZE="1">
<OPTION VALUE="<i>walks in....</i>">Visitors</OPTION>
<OPTION VALUE="<i>is within ....</i>">Member</OPTION>

</SELECT> </TD>
</TR>
<TR>
<TD ALIGN="CENTER" VALIGN="MIDDLE" COLSPAN="2">
<TABLE WIDTH="100%" BORDER="0"
CELLPADDING="03" CELLSPACING="0">
<TR>
<TD ALIGN="CENTER"
VALIGN="MIDDLE">History: <INPUT NAME="HISTORY" VALUE="5" SIZE="2" MAXLENGTH="2"></TD>
<TD ALIGN="CENTER" VALIGN="MIDDLE">Verbose <select name="VERBOSE" size="1"><option selected value="0">NO</option><option value="1">YES</option></select></TD>
<TD ALIGN="CENTER" VALIGN="MIDDLE"><b>Image Filtering <select
name="NOPIC" size="1">
<option selected value="0">Avatars On</option>
<option value="1">No Avatars</option>
<option value="1">No Images</option>
</select></TD>
</TR>
</TABLE> </TD>
</TR>
<TR>
<TD ALIGN="CENTER" VALIGN="MIDDLE"
COLSPAN="2"><INPUT TYPE="SUBMIT" VALUE="Chat Now"></TD>
</TR>
</TABLE> </FORM>

userip.txt
$user:$ip
myname:123.123.12.09
even if the file read from body log

room body log or body.txt
207.255.110.120:(Sun Sep 25 16:04:54 2005) To Lazy to type : <i>walks in....</i><BR>
or
207.255.110.120:(Sun Sep 25 16:05:05 2005) <img src= align=left><center></img><br><center><FONT FACE=garamond><FONT COLOR =silver><FONT SIZE=4>MY NAME<br>*some words*</font><br>*some more words*<br><FONT COLOR =silver><FONT SIZE=4><a target=_window>My site</a><br><a href= COLOR =blue><FONT SIZE=3>: <i>walks in....</i><BR>

the time and date would be nice but til I get basics

frames.pl a parser that validates the user login and enter post then parses them
also displaying banner.pl, body.txt and info.pl
<html>

<frameset rows="120,*">
<frame name=BANNER src="BANNER.pl?USER=$USER&SAYS=$SAYS$">
<frame name="BODY" src="BODY.txt?USER=$USER&SAYS=$SAYS$">
</frameset>
<frame name="INFO" src="info.pl or cgi or even html">
</frameset>

banner.pl serves parsed form and adds in current chatters name and list of other chatters a list of actions both read from a txt file or files on the server.

[MAIN]
<CENTERfont color=blueB> : $1 - $2 users</B/CENTER>
<PRE>
<B>$USER</BACTIONLISTUSERLIST>
Message: <INPUT TYPE="TEXT" NAME="SAYS" SIZE=40 VALUE=""
INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="* Submit *">
<INPUT NAME="LOGIN" TYPE="HIDDEN" VALUE="$LOGIN"
INPUT NAME="USER" TYPE="HIDDEN" VALUE="$USER"
INPUT NAME="USERPASS" TYPE="HIDDEN" VALUE="$USERPASS"
INPUT NAME="PASSWORD" TYPE="HIDDEN" VALUE="$PASSWORD"
INPUT NAME="NOPIC" TYPE="HIDDEN" VALUE="$NOPIC"
INPUT NAME="VERBOSE" TYPE="HIDDEN" VALUE="$VERBOSE"
INPUT NAME="HISTORY" TYPE="HIDDEN" VALUE="$HISTORY"
/FORMFORM ACTION="/" METHOD="POST" TARGET="_top"
INPUT NAME="LOGIN" TYPE="HIDDEN" VALUE="$LOGIN"
INPUT NAME="USER" TYPE="HIDDEN" VALUE="$USER"
INPUT NAME="USERPASS" TYPE="HIDDEN" VALUE="$USERPASS"
INPUT NAME="PASSWORD" TYPE="HIDDEN" VALUE="$PASSWORD"
INPUT NAME="NOPIC" TYPE="HIDDEN" VALUE="$NOPIC"
INPUT NAME="VERBOSE" TYPE="HIDDEN" VALUE="$VERBOSE"
INPUT NAME="HISTORY" TYPE="HIDDEN" VALUE="$HISTORY"
INPUT NAME="GOTO" TYPE="SUBMIT" VALUE="Goto"
GOTOLISTINPUT NAME="LEAVEIT" TYPE="SUBMIT" VALUE="Leave"
INPUT NAME="RELOAD" TYPE="SUBMIT" VALUE="Reload"
INPUT NAME="CONFIG" TYPE="SUBMIT" VALUE="Config">


And body is a html read out of the chat log or txt

$ VERBOSE is a line separating the posts
$ HISTORY is how many past posts the login $USER wants to see when entering room
USER and USERPASS are for members the room
LOGIN and $PASSWORD are from the administrators of the room
NOPIC turns picture display on and off on entering the room
Goto or leave redirects users to other room or url
CONFIG allows $USER to redo $USER name, pic’s on or off ,verbose

Now in most html chat the $user will input a string html code like

<img src= align=left><center></img><br><center><FONT FACE=garamond><FONT COLOR =silver><FONT SIZE=4>MY NAME<br>*some words*</font><br>*some more words*<br><FONT COLOR =silver><FONT SIZE=4><a target=_window>My site</a><br><a href= COLOR =blue><FONT SIZE=3>




$USER, , $USERPASS, $LOGIN, $PASSWORD, $HISTORY, $NOPIC, $SAYS, $AUTOSCROLL, $ACTION, $ WHOTO

these all would be user input on login or index page dropdowns or txtbox or checkboxes

So how is the best way to from these to stream real time data into the browser.


USER=Myname the one I typed in txtbox
USERPASS=Mypass the one I typed in txtbox (if one uses will not have to have a pass to enter room)
SAYS=Enters+the+room... default or typed in text box
HISTORY=20 (how many lines up on the temp log) entered in txt box
VERBOSE=1 1 = <HR> 0 = nothing or on and off
LOGIN= ( the admin name)
PASSWORD (the admin password)
ACTION here would be hidden and set to nothing, but reads off a file of actions the chatter could have in room
Like
Say to $user1 say to $user2
WHOTO=ALL is set to all for entering the room, but in room the chatter could select who they want to talk at, like MYNAME SAYS to HERNAME Hello

So I want these to write to a file (or be logged)

USER:USERPASS:LOGIN:pASSWORD:SAYS:HISTORY:VERBOSE:ACTION: WHOTO


169.70.234.228:::<img src= align=left><center></img><br><center><FONT FACE=garamond><FONT COLOR =silver><FONT SIZE=4>WarGod of Venna<br>*Administrator*</font><br>*Never say Never*<br><FONT COLOR =silver><FONT SIZE=4><a href= target=_window>Chat Venues</a><br><a href= COLOR =blue><FONT SIZE=3><center>:::aSasaSAS:::WarGod of Venna*Administrator**Never say Never*Chat VenuesVenna:::chocolate:::10:::10:::1:::1:::1167263638:::asASasa

I sorta got a start on it in cgi

use CGI;
my $q = new CGI;
my $ip_addr = $ENV{'REMOTE_ADDR'};
my $new_text = strip_html( $old_text );


open (MSG, ">>log.txt");
print MSG "\n"
. $ip_addr . ":::" . $q->param('name') . ":::" . $q->param('password') . ":::" . strip_html($q->param('name')) . ":::" . $q->param('CHATCOLOR') . ":::" . $q->param('refresh_rate') . ":::" . $q->param('histroy') . ":::" . $q->param('nopic') . ":::" . $q->param('verbose') . ":::" . time . ":::" . $q->param('msg');
close (MSG);
open (WHO, ">>/home/chatvenu/public_html/cgi-bin/mychat/userlog.who");
print WHO "\n"
. $ip_addr . ":" . strip_html($q->param('name'));
close (WHO);
sub strip_html {
my $text = shift;
$text =~ s/<(?:[^>'"]*|(['"]).*?\1)*>//gs;
return $text;
}

but I am wondering if this done in php
 
Yes Chat has been done and redone many times but this type of chat I have never seen done in just scripts magma in the 90's had a chat server and this is the kind of format I am trying to achieve Now of course if I could find these zip files called chatserver166.linux.tar.Z or chatserver165_sun_5x_tar.gz I maybe able to morph These around the .net issues I have in My window version of the magma’s chatserver.

I have taken many chat scripts apart glued then together so to speak and have not come up
With what I need for the functions of the chatserver and to the people that use these types of chats its important to them. I think I have downloaded more chat scripts of just ever language Out there. But I did find a project that dzzie of yahoo was working on

To quote them
“this form of web chat can also be accomplished using php or asp actually
it probably would have been easier to not have to create my own web server
for the dumb thing.. but i wanted it to be stand alone so *shrugs*

have fun

-dzzie”

I want to be able to upload these files to a host server and not have to pay High cable bills
Lol,


Also I am will to learn it from the ground up so to speak this way I know ever part and can add features and customize at will..

There are a few html chat sites these days but most come in a “can” and I feel it’s the features that set them apart. So this could give the site a edge also..

login
Code:
<html>
<form action="/frames.html" method=get>
<table>
<tr>
	<td>Name: </td><td><input type=text name="USER"><br></td>
</tr>
<tr>
	<td>Says: </td><td><input type=text name=SAYS value="Enters the Room"><br></td>
</tr>
<tr><td align=center colspan=2><input type=submit value=Enter></td></tr>
</table>
</form>




banner
Code:
<html><head><title>%roomname%</title></head>

<body bgcolor="#000000" text="#ffffff" link="#ffffff" vlink="#ffffff">

<FORM METHOD="GET" ACTION="/banner.html" NAME="input" >

<table cellpadding=0 border=0 width="100%">

<tr><td> %USERNAME% </td><td>

<select name="ACTION">
	<option value="says to">says to
	<option value="whispers to">PRIVATELY whispers to
</select> 

<select name="WHOTO">
	<option value="ALL">ALL
	%CHATTERS%
</select> 

</td></tr>

<tr><td>Message : </td><td>

<INPUT TYPE="TEXT" NAME="SAYS" SIZE=40 VALUE="">
<INPUT TYPE="SUBMIT" NAME="SUBMIT" VALUE="* Submit *">
<INPUT NAME="USER" TYPE="HIDDEN" VALUE="%USERNAME%">
<INPUT NAME="NOPIC" TYPE="HIDDEN" VALUE="">

</FORM>

</td></tr>
</table>

<table width=100% bgcolor="#9933CC"><tr><td>

<FORM ACTION="config.html" METHOD="GET" TARGET="_top">
	<INPUT NAME="USER"      TYPE="HIDDEN" VALUE="%USERNAME%">
	<INPUT NAME="NOPIC"     TYPE="HIDDEN" VALUE="">
	<INPUT NAME="LEAVEIT"   TYPE="SUBMIT" VALUE="Leave">
	<INPUT NAME="RELOAD"    TYPE="SUBMIT" VALUE="Reload">
	<INPUT NAME="DOCONFIG"  TYPE="SUBMIT" VALUE="Full Config">
</FORM>

</td></tr></table>

<script> input.SAYS.focus(); </script>

</BODY></HTML>

this is the html of what I trying the top frame and login page look like.




MA WarGod

I believe if someone can think it, it can be programmed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top