1
SLEO577
Using PHP to find User...
  • 2005/9/14 18:40

  • SLEO577

  • Not too shy to talk

  • Posts: 110

  • Since: 2005/6/27


I am installing a Chatroom and Instant Messenager program and I am trying to use XOOPS membership's database so that the chatroom and IM can put there user name automatically in the (NickName) field, rather than have the members type it in and hit the submit button.

I am using a php file:
//BUDDYLIST.PHP//

$DB_USR "myDataUser";
$DB_PWD "******";
$DB_NAME "myDataName";
$DB_HOST "localhost";

$db mysql_connect($DB_HOST$DB_USR$DB_PWD)
or die (
"Could not connect to database");
mysql_select_db($DB_NAME$db);
if (
$request=="add"){
$query2 "INSERT INTO `buddylist`(`user`,`buddy`) VALUES('$user','$buddy')";
$result mysql_query($query2);
if (!
$result) {
die(
'Invalid query: ' mysql_error());
}

}
if (
$request=="remove"){
$query2 "DELETE FROM `buddylist` WHERE user='$user' and buddy='$buddy'";
$result mysql_query($query2);
if (!
$result) {
die(
'Invalid query: ' mysql_error());
}
}

[
color=CC0000]$query3 "SELECT `buddy` FROM `buddylist` WHERE user='$user_username'";[/color]
$result3 mysql_query($query3);
$numofrows=mysql_num_rows($result3);
for(
$ii=0;$ii<$numofrows;$ii++)
{
 
mysql_fetch_row($result3);
 if(
$ii==$numofrows-1)
 {
  
$budy.=mysql_result($result3,$ii,"buddy");
 }
 else
 {
 
$budy.=mysql_result($result3,$ii,"buddy").",";
 }
 
}

echo(
"$buddy");

?>


And to find the username and their ID the following file:
    include("connect.php");

?>








 
welcome

 











but I am not sure if the (WHERE user='$xoops_username'") is the right snippet to use to find the XOOPS username. Should it be just (WHERE user='$user'")? The items in RED are is script I was concern about.

2
Mithrandir
Re: Using PHP to find User...

Are you in a XOOPS context, when writing that code? I mean, do you include mainfile.php at the top of the page?
"When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point-of-view is seldom necessary."

Cusix Software

3
SLEO577
Re: Using PHP to find User...
  • 2005/9/14 19:14

  • SLEO577

  • Not too shy to talk

  • Posts: 110

  • Since: 2005/6/27


No Mithrandir, I did not include the mainfile.php. But I put the applet file (myApplet.js) into a "Custom Block" that calls to the chatroom and IM program. The two php files above call to the XOOPS user database to locate the username and input it into the applet (username) field.

Kind of like AOL's Chatroom/Instant Messenager that works once you are logged into AOL with your screen name it displayes it for you and bypasses the user from inputting it into a field and hitting a submit button.

4
Mithrandir
Re: Using PHP to find User...

just out of curiousity - does this work if you put it in a custom PHP block:
?>








Change the URL of buddylist.php in the include statement to the absolute URL
"When you can flatten entire cities at a whim, a tendency towards quiet reflection and seeing-things-from-the-other-fellow's-point-of-view is seldom necessary."

Cusix Software

5
SLEO577
Re: Using PHP to find User...
  • 2005/9/14 19:47

  • SLEO577

  • Not too shy to talk

  • Posts: 110

  • Since: 2005/6/27


No Mith, for some reason I am still having a problem with it finding the $user in the XOOPS database. I some how have the path to the user or users id wrong.

6
SLEO577
Re: Using PHP to find User...
  • 2005/9/14 19:57

  • SLEO577

  • Not too shy to talk

  • Posts: 110

  • Since: 2005/6/27


Actually Mith, I'm putting the direct path to the URL for the userinfo.php and I think I may have it. If I can get this to work, I will PM you the info to get into the VPN we have to see. I think this would be a great module for XOOPS.

7
SLEO577
Re: Using PHP to find User...
  • 2005/9/14 20:32

  • SLEO577

  • Not too shy to talk

  • Posts: 110

  • Since: 2005/6/27


Okay Mith,

My plan is to get the buddylist working so I know the exact syntax for the buddylist param and work on just getting the XOOPS users able to auto login into the Chatroom and IM by pulling the username from the XOOPS database and I should be set.

8
SLEO577
Re: Using PHP to find User...
  • 2005/9/15 5:35

  • SLEO577

  • Not too shy to talk

  • Posts: 110

  • Since: 2005/6/27


Mith,

Just an update.....it is connecting if I run the script you mention as a html instead of a PHP Script. If I run the script you mentioned as a PHP Script in a custom block I get the following error:
Parse errorparse errorunexpected in /vpn/flstate/VSAS/class/xoopsblock.php(146) : eval()'d code on line 17
It connects and opens up both the chatroom and IM programs, but it still cannot determine who the user is. It shows the user once it connects to the chatroom or IM as just: ?>

I will be working on this more tomorrow and will let you know if I make any head way. It may be the portion of the script:
$GLOBALS['xoopsConfig']['anonymous'];?>

that is creating the problem. I have not allowed any portion of the website to be used by "Guest". It is strictly a Registered Members only website.

Login

Who's Online

371 user(s) are online (310 user(s) are browsing Support Forums)


Members: 0


Guests: 371


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits