View Full Version : YAPIH (Yet Another PHPMyChat Integration Hack) 1.0
version
04-08-2002, 10:00 PM
YAPIH (Yet Another PHPMyChat Integration Hack) 1.0 by Joshua McNeese <jmcneese@enterthemuse.com>
Now, first off, this is not an 'out-of-the-box' hack, that you can just uncompress and change a config file and expect to work right off the bat. This hack was the result of me spending a considerable amount of time hand-editing files and replacing variables to convice PHPMyChat to use the VBulletin user database table. You will have to modify this to work with your server/configuration, and if you are not familiar with the PHP internals of VBulletin or with MySQL, turn back now. You have been warned.
(1) Uncompress YAPIH-1.0.zip in the ServerRoot of your server, so that you will access the chat via http://yourhost.com/chat/
(2) Execute the SQL commands in the file 'chat.sql'. This will create the tables needed for PHPMyChat as well as modify your user table. Altering your user table is dangerous, so be sure to have backups handy.
(3) Modify your VB templates:
ADD these two variables to your 'phpinclude' template:
$chatname = str_replace(" ", "%20", $bbuserinfo[username]);
$chatpass = $bbuserinfo[password];
This will replace any space in a username with spaces, as PHPMyChat does not accept spaces in names, and assign it to the variable $chatname. The users hashed password is assigned to $chatpass, for convenience.
(4) Edit the /chat/config/config.lib.php3 to match your server/configuation/preference.
(5) Now, the last (and tricky) part. What you have now is a working PHPMyChat installation that will authenticate on the VBulletin user table, if you followed the instructions faithfully and received no errors. What must be done now is provide your users with a way to access the chatrooms that you have created. I do this via a DHTML/PHP4 menu panel that lists the available chatrooms, and opens the chatroom in a 600x400 java popup box. You can do this anyway you want, so long as the link is provided via a template in VBulletin, or if you know how to pass variables to custom PHP scripts from within the 'phpinclude' template (which is what I do). The URL you must use is in this format:
/chat/index.php3?U=$chatname&PWD_Hash=$chatpass&Ver=H&L=english&R0=$chatroom&T=1&D=10&N=200&EN=1
Where $chatname and $chatpass are provided by the 'phpinclude' template, and $chatroom is provided by however you choose to assign that variable. It's up to you to figure out how you wish to do so, because everyone structures their site navigation in a different way.
To see the end-user representation of this hack, go to http://www.enterthemuse.com/ and login as 'test', password 'test'. On the left side of the site is a panel-based menu that will include a section 'Chat'. Take a look around, pay attention to where the URLs point and try it out.
It might work for you, it might not, it's totally dependent on your understanding of how to pass variables from your VB templates (in particular 'phpinclude'). Try it, and if all else fails, post your experiences on vb.org.
Download it HERE (http://www.enterthemuse.com/stuff/YAPIH-1.0.zip).
Good luck,
Joshua McNeese
version
04-19-2002, 12:55 PM
i've seen plenty of referrals from vb.org and people fiddling around as test, but has no one actually tried this yet? i am surprised, because there are loads of people always requesting this very thing. :surprised:
I cant believe there are no replies to this.
Well I have just installed it and so far so good.
I did take a full mysqldump back up - perhaps your warnings put people off - so they should.
I can hot link from forums to the phpmychat ok - all I would love to do now is have a dynamic list of live chat rooms from phpmychat, a list of users that are in there - Any ideas Please :)
Also some tidying of course for my own site and wondering how best to integrate your "gender" for the user table into the registration process - what type of input is this supposed to be?
And a lot of testing of course - user drop out restarts that sort of thing.
Thanks,
Steve
www.southport.gb.com
TWTCommish
06-03-2002, 02:00 PM
There isn't by any chance any EASY way to integrate phpMyChat with the vB layout, is there?
I found this one very clear to implement.
Just make sure you do a mysqldump backup first (eg as instructed in vbulletin.com Server - moving server - dummies version).
This is the 3rd variant I have tried and if you want only VB registered users in the chat - it looks the best IMHO
ixian
06-03-2002, 02:33 PM
I think this hack would get a lot more response, and perhaps become one of the more popular hacks, if a bit more in the way of instructions were provided, particularly on passing variables.
I uploaded the files in a /chat directory, no problem.
I created/added the tables as outlines in chat.sql, no problem
I added the variables to my phpincludes template, no problem.
It's the link usage I have a problem with. I can create a link easy - I use a DHTML menu myself - and the chat index opens, but the variables for vb user/password (yes I am logged in) are not passed along. This is natural enough, I imagine, because when calling it from the front page of my site the phpincludes template is not read. I can't seem to get the username/password passed along even if I link to it within my forums.
In particular, this statement:
or if you know how to pass variables to custom PHP scripts from within the 'phpinclude' template (which is what I do).
Catches my eye - if we don't know how, and you do, you think you could share? Even an example of how you did it would be helpful.
There also needs to be a way to redirect to the user_not_logged_on template for folks who aren't registered.
I could try taking a crack at it, but it might be easier if Version gave some pointers here.
version
06-04-2002, 07:32 AM
ixian, the phpinclude template is always parsed, even for the front page of the site, if you include("$forumpath/global.php").
here's the chatstuff in my phpinclude template:
if ($bbuserinfo[userid] != "0") {
$chatname = str_replace(" ", "%20", $bbuserinfo[username]);
$chatpass = $bbuserinfo[password];
$db=mysql_connect($servername,$dbusername,$dbpassw ord) or die("Can't open connection to MySQL");
mysql_select_db($dbname) or die("Can't select database");
mysql_query("DELETE from chat_users where u_time < ".(time() - 240)." and u_time > 0");
$num_chatters_query = mysql_query("SELECT DISTINCT username FROM chat_users WHERE room != \"PRIVATE_ROOM\"");
$num_chatters = mysql_num_rows($num_chatters_query);
if ($num_chatters == "0") {
$chatextra = "";
} elseif ($num_chatters == "1") {
$chatextra = "(1 user)";
$istext = "is";
$membertext = "member";
} else {
$chatextra = "($num_chatters users)";
$istext = "are";
$membertext = "members";
}
$who_chatters_query = mysql_query("SELECT DISTINCT username FROM chat_users");
while ($chatters = mysql_fetch_array($who_chatters_query)) {
$who_chatters .= " $chatters[username] ";
}
eval("\$chatinfo = \"".gettemplate("forumhome_chatinfo")."\";");
}
also in my phpinclude, specifically the bit that builds the dynamic menu:
ob_start();
$pan = new Panel();
$pan->addPanel( "1", "General", "$forumpath/menu_general.php" );
$pan->addPanel( "2", "Help", "$forumpath/menu_help.php" );
if ($bbuserinfo[userid] != "0") {
$pan->addPanel( "3", "User", "$forumpath/menu_user.php" );
$pan->addPanel( "4", "Chat $chatextra", "$baseurl/forums/menu_chat.php?username=$chatname&password=$chatpass" );
$pan->addPanel( "5", "Misc.", "$baseurl/forums/menu_misc.php?username=$chatname&password=$chatpass&userid=$bbuserinfo[userid]" );
if ($bbuserinfo[usergroupid] == "6") {
$pan->addPanel( "6", "Moderator", "$baseurl/forums/menu_mod.php?username=$chatname&password=$chatpass" );
$pan->addPanel( "7", "Administrator", "$baseurl/forums/menu_admin.php?username=$chatname&password=$chatpass" );
$pan->addPanel( "8", "Test", "$baseurl/forums/menu_test.php?username=$chatname&password=$chatpass&userid=$bbuserinfo[userid]" );
}
if ($bbuserinfo[usergroupid] == "7" || $bbuserinfo[usergroupid] == "5") {
$pan->addPanel( "6", "Moderator", "$baseurl/forums/menu_mod.php?username=$chatname&password=$chatpass" );
$pan->addPanel( "7", "Test", "$baseurl/forums/menu_test.php?username=$chatname&password=$chatpass&userid=$bbuserinfo[userid]" );
}
}
$pan->Display();
$menucontents = ob_get_contents();
ob_end_clean();
as you can see, i pass variables to my subscripts variables in the URLs, i.e. $chatname as $username, $bbuserinfo[userid] as $userid.
here is the contents of the "menu_chat.php" script mentioned above:
print "<a href=\"/chat/index.php3?U=$username&PWD_Hash=$password&Ver=H&L=english&R0=General&T=1&D=10&N=200&EN=1\">General Chat</a><br>
<a href=\"/chat/index.php3?U=$username&PWD_Hash=$password&Ver=H&L=english&R0=Poetry+Slam&T=1&D=10&N=200&EN=1\">Poetry Slam</a><br>";
i am also attaching the template for the forumhome_chatinfo. let me know if there is more questions, and if someone wants to add more (or better) instructions to my package, send me the changes and i will give you credit. (busy life right now, got twins on the way :))
ixian
06-10-2002, 06:58 PM
The only php pages on my site are the forums. The rest is done via ssi. I have a feeling something will get jacked but good if I try to included global.php on my non-php front page. I wish there was an easy way to add this as a forums addon, right now I can't make heads or tails of what you are doing with the phpinclude template.
version
06-11-2002, 04:10 PM
ixian,
ah, i understand what you mean now. what i can suggest is that you build a front page in PHP, since that can be coded in such a way as to work like SSI (ala include(), exec(), virtual(), etc.), then you can include the global.php and have the phpinclude parsed even for your front page.
what exactly are you trying to display on your front page? give me an example, and maybe i can help out with an alternative.
solent
06-13-2002, 07:14 AM
well i try it and i found it great although i have a couple of problems.
First my username and password is not directly passed when i click on the chat rooms although i did exactly as you said.
Second the chat room dose not open in a new window in the specified resolution that i passed to it.
Any ideas please
BigJohnson
06-13-2002, 08:38 AM
This hack look amazing i am just having some trouble with one thing though. When i go to register and i register and click send info i get this data base error.
Database error: Invalid SQL: INSERT INTO user VALUES ('Nem1386', '1', '62fbd3c41f33c0b62996c15429cf55fa', 'Kyle', 'Walker', '', '', 'Nem@aol.com', 0, 'user', '',1023960753, '24.186.207.37', '')
MySQL error: 1136 (Column count doesn't match value count at row 1)
Session halted.
Does anyone no what i can do?
version
06-13-2002, 11:26 AM
Originally posted by solent
well i try it and i found it great although i have a couple of problems.
First my username and password is not directly passed when i click on the chat rooms although i did exactly as you said.
Second the chat room dose not open in a new window in the specified resolution that i passed to it.
Any ideas please
wherever you are calling the chat url from (whether in a vbb page or in a seperate page) you must make sure that $chatname and $chatpass are declared (i showed how i did it in the phpinclude template), and further that is it correctly passed to the actual chat script. this is totally up to you how you want to do this. i do it via an intermediary script (menu_chat.php), which then interprets $chatname as $username and $chatpass as $password. think about the sequence of how things are layed out and then decide how it must be done for your site, because there is no one-size-fits-all answer.
regarding the chatroom window, you must use a javascript popUp script if you want to specify resolutions.
BigJohnson
06-13-2002, 06:13 PM
What about my prb up two posts. ;)
ixian
06-13-2002, 06:58 PM
Originally posted by version
ixian,
ah, i understand what you mean now. what i can suggest is that you build a front page in PHP, since that can be coded in such a way as to work like SSI (ala include(), exec(), virtual(), etc.), then you can include the global.php and have the phpinclude parsed even for your front page.
what exactly are you trying to display on your front page? give me an example, and maybe i can help out with an alternative.
I'm not gonna rebuild my entire site design for a hack, no matter how good:) Converting to php would totally jack about 900 different things I built.
Here's all I want, maybe I am making this too difficult:
Have a link on my front page to the chat room that auto-logs someone in with their vb name and password, or redirects them to the registration page if not.
What I'm thinking is, I should create a seperate page for chat. Maybe even a vb template. Then, all the link on the front page does is take them to that page, where they can then log in, etc, etc.
Anyone have a quick vb template and a way to call it withen a php page?
solent
06-14-2002, 06:32 AM
well version i don't use dhtml menus.
again i passed the exact code as you did in my phpinclude but yet username and password are not passed through.
any other ideas.
by the way great site you have m8. aswome i have to admit that is the best board site i have ever since.
can i contact you to give me a couple of tips??
version
06-14-2002, 02:35 PM
sure
ixian
07-01-2002, 09:52 PM
Gave up on the front page integration, just created a template for it in vb, and I link to it. Works pretty well now, so off to click the "install" button I go.
Couple quick questions Version:
[Edit - NM, found the answers. I'll post them for others]
Where do you set the page <TITLE> at? Dunno if you know this, but it's set to "ETM Chat" which probably works for you but doesn't apply to me:)
Answer - in the chat/lib/index.lib.php3 file, NOT chat/index.php3. You can change a lot of variables in the former file.
Which CSS file/variables do ya edit for changing the chat color settings (background, etc).
start_page.css.php3. There are many variables - to change the main window background, for example, it's the 'background-color' attribute of the class 'ChatBody'. Play around and enjoy.
Last (guess this is 3 questions:) )
Where do you change the default text users see when they first enter a room?
Still haven't got the answer to this one....yet
Thanks!
solent
07-02-2002, 03:51 AM
i still have a problem parseing my variables to the chat javascript window.
everything else works fine.
although i included everything that version said in my phpinclude template.
rstark
07-20-2002, 08:21 AM
Originally posted by version
(2) Execute the SQL commands in the file 'chat.sql'. This will create the tables needed for PHPMyChat as well as modify your user table. Altering your user table is dangerous, so be sure to have backups handy.
Okay, I'm a dummy. How do you do this? :dead:
solent
07-22-2002, 04:07 AM
i am using linux and i do it through webmin. Very easy to execute and backup and administrate any my-sql database.
another solution for you is to do it with phpMyAdmin. it is very cool web based my-sql clinet tool
TalkHardRandy
08-04-2002, 08:43 AM
Originally posted by ixian
Gave up on the front page integration, just created a template for it in vb, and I link to it. Works pretty well now...
Any hope of seeing that template & the instructions for linking it?
* TalkHardRandy hoping...
* TalkHardRandy praying...
ManagerJosh
08-11-2002, 07:50 AM
Very intresting hack though I'm not sure what I did wrong. I decided to test out the installation process on a clean version of vb2.2.6 on a server I have at home and for some reason it isn't cooperating..
I can't get people to login nor have I figured out. I did as suggested, even added the additional coding to the phpinclude template (mind for some reason the server decided not to connect to the mysql)
Could someone enlighten what I did wrong here?
Bob Ricci
08-26-2002, 07:53 PM
I'm fairly new to vB but catch on quickly. I'm also learning php and can pass variables. I'd like to completely install this hack, but I have a couple questions:
1) For this hack to work, does the phpmychat table need to be created as a table within the same db as vB? I've created a separate table for phpmychat.
2) phpinclude has been edited to add the vars $chatname and $chatpass - do I need to modify global.php to include this file, or is it already an included file? I can check this one myself, I suppose.
3) Last question. The var $chatroom can be defined by me for use on a button or {a href} links. But what is the content of this var? The name given in phpmychat? We have multiple 'rooms' already using another software tool, but would prefer embedded integration with vB.
I'm using vB 2.2.6. phpMyChat is installed and functional. I call it using a simple button that opens it as target=_blank so my users never really leave vB. I can certainly change this.
HEY! One more question. Is there a way to show in Who's On-Line which users are in chat? That would be kewl!
Bob Ricci
08-29-2002, 07:47 AM
I'm really surprised that I haven't received a single response and it has been several days. At any rate, I have answered most of my own questions. Here is where I am at:
I have added:
$chatname=str_replace(" ", "%20", $bbuserinfo[username]);
$chatpass=$bbuserinfo[password];
$chatroom="General";
to phpinclude. I have created a link EXACTLY as indicated in the instructions. In fact, I've followed all of the instructions. But each time I pass the user name with a space replaced by %20 I am told by phpMyChat that usernames with spaces are not allowed.
I can log into phpMyChat just fine without integration. It works.
What am I missing?
ManagerJosh
08-31-2002, 08:43 PM
How do I access administrative features in phpmychat? I get Warning: Failed opening './localization/6.lib.php3' for inclusion (include_path='.:/usr/share/php') when I try to use it :-X
Smelly Fed
09-03-2002, 12:13 PM
Am having trouble getting phpmyChat (integrated with my vbulletin userbase) to allow users with AOL 7.0 to enter chat. Anyone else experienced this and more importantly, anyone else figure a way to fix this?
Originally posted by solent
well version i don't use dhtml menus.
again i passed the exact code as you did in my phpinclude but yet username and password are not passed through.
I couldnt make it work in phpinclude template somehow, so I just add the lines into index.php, and it works just fine. This hack is great ;)
$chatname = str_replace(" ", "%20", $bbuserinfo[username]);
$chatpass = $bbuserinfo[password];
Silver_2000_)!
10-29-2002, 04:09 AM
Originally posted by Smelly Fed
Am having trouble getting phpmyChat (integrated with my vbulletin userbase) to allow users with AOL 7.0 to enter chat. Anyone else experienced this and more importantly, anyone else figure a way to fix this?
Fred
The only way I got AOL users to be happy in chat is to tell them to use Internet explorer... Otherwise they login ok but cant post and get logged out before than can post
I was looking to integrate the phpmychat into my VB forum to keep the chat trolls to a minimum but so far the hacks seem unreliable
Doug
I too have the same problem with AOL users for the last few weeks. Anyone any idea of what the problem might be?
svoec
01-15-2003, 05:45 PM
hey guys...
I did some work, and came up with a 'chat entry page' for this hack.
Just add a link somewhere on your forum for CHAT - that points to this page . You can even link to this page from any html, ssi, shtml or whatever page.
What it does is transfer all the variables for you, and give the user some info about chat (how many people are in chat, who they are, what chat rooms are open) -- I also thought it would be a good place to display rules and stuff.
This also makes the hack easier to install, because you don't have to edit any of the templates or php files. (not really a big deal anyway)
this is very ugly, and is just for illustration purposes right now. Most of the code (99%) is from what version posted earlier, so I can't really take much credit for any of this...
this version does not show a list of available chat room, as I plan to control what rooms are open myself by editing this file. I generally only use one chat room. - but this part wouldn't be too hard to add. (I left the code needed for it in)
Maybe after I finish this, I will post a better looking version of it.--
Let me know if anyone is interested in seeing the finished entry page.
I am pretty new to this stuff, and I KNOW there is some extra code in there that I don't need (but I'm not done yet) -- I am open to sugestions of what else people would like to see in here.
You will have (AT LEAST) have to do some edits here, especially the login stuff at the bottom -(www.yoursite.com)
This script drops straight in your forum folder.
with a little html cleanup, this will be a nice piece!
rstark
01-17-2003, 05:23 AM
Originally posted by ixian
Last (guess this is 3 questions:) )
Where do you change the default text users see when they first enter a room?
Still haven't got the answer to this one....yet
Thanks!
It's in the welcome.lib.php3 file located in the \chat\lib folder
svoec
01-17-2003, 12:29 PM
it's in the phpmychat docs..(probably why you didn't get a answer)
it is in the /chat/lib/welcome.lib.php3
:Judge:
01-18-2003, 03:10 AM
Is this my best option to intergrate the two?
rstark
01-20-2003, 08:59 PM
Originally posted by version
ixian, the phpinclude template is always parsed, even for the front page of the site, if you include("$forumpath/global.php").
here's the chatstuff in my phpinclude template:
if ($bbuserinfo[userid] != "0") {
$chatname = str_replace(" ", "%20", $bbuserinfo[username]);
$chatpass = $bbuserinfo[password];
$db=mysql_connect($servername,$dbusername,$dbpassw ord) or die("Can't open connection to MySQL");
mysql_select_db($dbname) or die("Can't select database");
mysql_query("DELETE from chat_users where u_time < ".(time() - 240)." and u_time > 0");
$num_chatters_query = mysql_query("SELECT DISTINCT username FROM chat_users WHERE room != \"PRIVATE_ROOM\"");
$num_chatters = mysql_num_rows($num_chatters_query);
if ($num_chatters == "0") {
$chatextra = "";
} elseif ($num_chatters == "1") {
$chatextra = "(1 user)";
$istext = "is";
$membertext = "member";
} else {
$chatextra = "($num_chatters users)";
$istext = "are";
$membertext = "members";
}
$who_chatters_query = mysql_query("SELECT DISTINCT username FROM chat_users");
while ($chatters = mysql_fetch_array($who_chatters_query)) {
$who_chatters .= " $chatters[username] ";
}
eval("\$chatinfo = \"".gettemplate("forumhome_chatinfo")."\";");
}
as you can see, i pass variables to my subscripts variables in the URLs, i.e. $chatname as $username, $bbuserinfo[userid] as $userid.
here is the contents of the "menu_chat.php" script mentioned above:
print "<a href=\"/chat/index.php3?U=$username&PWD_Hash=$password&Ver=H&L=english&R0=General&T=1&D=10&N=200&EN=1\">General Chat</a><br>
<a href=\"/chat/index.php3?U=$username&PWD_Hash=$password&Ver=H&L=english&R0=Poetry+Slam&T=1&D=10&N=200&EN=1\">Poetry Slam</a><br>";
i am also attaching the template for the forumhome_chatinfo. let me know if there is more questions, and if someone wants to add more (or better) instructions to my package, send me the changes and i will give you credit. (busy life right now, got twins on the way :))
When I try to add this, I get:
Warning: Access denied for user: 'user_com@localhost' (Using password: NO) in /home/oursite/public_html/forums/global.php(302) : eval()'d code on line 23
Warning: MySQL Connection Failed: Access denied for user: 'user_com@localhost' (Using password: NO) in /home/oursite/public_html/forums/global.php(302) : eval()'d code on line 23
Can't open connection to MySQL
svoec
01-20-2003, 10:18 PM
somewhere in there, you need to include either global.php, or admin/config.php
your variables for the username and password are not getting set.
rstark
01-20-2003, 10:29 PM
Originally posted by svoec
somewhere in there, you need to include either global.php, or admin/config.php
your variables for the username and password are not getting set.
Thanks svoec, but can you be a little more specific on where to include this? In the phpinclude template?
rstark
01-20-2003, 10:49 PM
Nevermind, I got it to work. Thanks!
TalkHardRandy
01-29-2003, 07:06 PM
Though version hasn't been on in a while, I wanted to say that despite looking like a difficult hack to install, it went in rather smoothly.
Very cool hack!!!
speedway
02-27-2003, 12:31 PM
Ummm...anyone know where I can get this hack...the download link doesn't seem to work.
Cheers
dotagious
04-27-2003, 05:28 AM
02-27-03 at 10:31 AM speedway said this in Post #39 (https://vborg.vbsupport.ru/showthread.php?postid=358984#post358984)
Ummm...anyone know where I can get this hack...the download link doesn't seem to work.
Cheers
Same here. =(
matthewc
05-19-2003, 12:15 AM
Yeah, looks like he switched to invisionboard. Does ANYONE have this hack? pweezy?
salnet
07-17-2003, 06:23 PM
Has anyone the hack? Here is it down.
My eMail: timo.salmen@salnet.de
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.