Jump to content
MakeWebGames

Ajax Gang/Channel Chat System - $7.50


Dave

Recommended Posts

Ok so many thing don't work. I can't enter any requirement for chat channel. In my game and in your demo on your website. What going wrong ?

Saving setting in chat setting do nothing. ( no probleme with this in your demo )

Warning: Invalid argument supplied for foreach() in /staff_chat.php on line 94

I dont want post line of code because is a paid code

Thanks

Sorry I didn't reply to your email over the weekend I've been very busy moving house.

What version of McCodes are you using? If you're using Ravans there's code in sglobals.php which "attempts" to secure all $_POST & $_GET variables and as the data is passed through the system as a serialized string it breaks it.

Link to comment
Share on other sites

  • Replies 80
  • Created
  • Last Reply

Top Posters In This Topic

Thanks for reply

I got McCodes 2.0.2b my staff files was move to an other folder

This is my sglobals.php

 

<?php
/*---------------------------------
--   MCCodes 2.0
--   By Dabomstew
---------------------------------*/
session_start();
if(get_magic_quotes_gpc() == 0)
{
foreach($_POST as $k => $v)
{
 $_POST[$k]=addslashes($v);
}
foreach($_GET as $k => $v)
{
 $_GET[$k]=addslashes($v);
}
}

require "../global_func.php";
if($_SESSION['loggedin']==0) { header("Location: ../index.html");exit; }
$userid=$_SESSION['userid'];
require "../header.php";

include "../config.php";
global $_CONFIG;
define("MONO_ON", 1);
require "../class/class_db_{$_CONFIG['driver']}.php";
$db=new database;
$db->configure($_CONFIG['hostname'],
$_CONFIG['username'],
$_CONFIG['password'],
$_CONFIG['database'],
$_CONFIG['persistent']);
$db->connect();
$c=$db->connection_id;
$set=array();
$settq=$db->query("SELECT * FROM settings");
while($r=$db->fetch_row($settq))
{
$set[$r['conf_name']]=$r['conf_value'];
}
$domain=$_SERVER['HTTP_HOST'];

global $jobquery, $housequery;
if($jobquery)
{
$is=$db->query("SELECT u.*,us.*,j.*,jr.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN jobs j ON j.jID=u.job LEFT JOIN jobranks jr ON jr.jrID=u.jobrank WHERE u.userid=$userid");
}
else if($housequery)
{
$is=$db->query("SELECT u.*,us.*,h.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN houses h ON h.hWILL=u.maxwill WHERE u.userid=$userid");
}
else
{
$is=$db->query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid");
}
$ir=$db->fetch_row($is);
if($ir['force_logout'])
{
$db->query("UPDATE users SET force_logout=0 WHERE userid=$userid");
session_unset();
session_destroy();
header("Location: ../login.php");
exit;
}
if($ir['user_level'] <= 1)
{
die("403: Access Denied");
}
global $macropage;
if($macropage && !$ir['verified'] && $set['validate_on']==1)
{
header("Location: ../macro1.php?refer=$macropage");
} 
check_level();
$h = new headers;
$h->startheaders();
$fm=money_formatter($ir['money']);
$cm=money_formatter($ir['crystals'],'');
$lv=date('F j, Y, g:i a',$ir['laston']);
global $atkpage;
$staffpage=1;
if($atkpage)
{
$h->userdata($ir,$lv,$fm,$cm,0);
}
else
{
$h->userdata($ir,$lv,$fm,$cm);
}

$h->smenuarea();

?>

 

I have create an other sglobals2.php without this line

 

if(get_magic_quotes_gpc() == 0)
{
foreach($_POST as $k => $v)
{
 $_POST[$k]=addslashes($v);
}
foreach($_GET as $k => $v)
{
 $_GET[$k]=addslashes($v);
}
}

 

Now All work but i have this line appears in chat box

array(1) { [0]=> array(3) { [0]=> string(5) "level" [1]=> string(1) ">" [2]=> string(1) "0" } }

I think this is my requirement unserialize. Why this appears in my chat box ?

thanks

Link to comment
Share on other sites

Thanks for reply

I got McCodes 2.0.2b my staff files was move to an other folder

This is my sglobals.php

<?php
/*---------------------------------
--   MCCodes 2.0
--   By Dabomstew
---------------------------------*/
session_start();
if(get_magic_quotes_gpc() == 0)
{
foreach($_POST as $k => $v)
{
 $_POST[$k]=addslashes($v);
}
foreach($_GET as $k => $v)
{
 $_GET[$k]=addslashes($v);
}
}

require "../global_func.php";
if($_SESSION['loggedin']==0) { header("Location: ../index.html");exit; }
$userid=$_SESSION['userid'];
require "../header.php";

include "../config.php";
global $_CONFIG;
define("MONO_ON", 1);
require "../class/class_db_{$_CONFIG['driver']}.php";
$db=new database;
$db->configure($_CONFIG['hostname'],
$_CONFIG['username'],
$_CONFIG['password'],
$_CONFIG['database'],
$_CONFIG['persistent']);
$db->connect();
$c=$db->connection_id;
$set=array();
$settq=$db->query("SELECT * FROM settings");
while($r=$db->fetch_row($settq))
{
$set[$r['conf_name']]=$r['conf_value'];
}
$domain=$_SERVER['HTTP_HOST'];

global $jobquery, $housequery;
if($jobquery)
{
$is=$db->query("SELECT u.*,us.*,j.*,jr.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN jobs j ON j.jID=u.job LEFT JOIN jobranks jr ON jr.jrID=u.jobrank WHERE u.userid=$userid");
}
else if($housequery)
{
$is=$db->query("SELECT u.*,us.*,h.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid LEFT JOIN houses h ON h.hWILL=u.maxwill WHERE u.userid=$userid");
}
else
{
$is=$db->query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid");
}
$ir=$db->fetch_row($is);
if($ir['force_logout'])
{
$db->query("UPDATE users SET force_logout=0 WHERE userid=$userid");
session_unset();
session_destroy();
header("Location: ../login.php");
exit;
}
if($ir['user_level'] <= 1)
{
die("403: Access Denied");
}
global $macropage;
if($macropage && !$ir['verified'] && $set['validate_on']==1)
{
header("Location: ../macro1.php?refer=$macropage");
} 
check_level();
$h = new headers;
$h->startheaders();
$fm=money_formatter($ir['money']);
$cm=money_formatter($ir['crystals'],'');
$lv=date('F j, Y, g:i a',$ir['laston']);
global $atkpage;
$staffpage=1;
if($atkpage)
{
$h->userdata($ir,$lv,$fm,$cm,0);
}
else
{
$h->userdata($ir,$lv,$fm,$cm);
}

$h->smenuarea();

?>

I have create an other sglobals2.php without this line

if(get_magic_quotes_gpc() == 0)
{
foreach($_POST as $k => $v)
{
 $_POST[$k]=addslashes($v);
}
foreach($_GET as $k => $v)
{
 $_GET[$k]=addslashes($v);
}
}

Now All work but i have this line appears in chat box

array(1) { [0]=> array(3) { [0]=> string(5) "level" [1]=> string(1) ">" [2]=> string(1) "0" } }

I think this is my requirement unserialize. Why this appears in my chat box ?

thanks

Do you wanna contact me on Skype? Might be easier to determine what's going wrong.

Add me on Skype at oxydennet

Link to comment
Share on other sites

  • 3 months later...

I recently purchased this mod and love it. I am having problems with trying to change the color of the names based on user level and if they have donated but everything I have tried just keeps breaking the chat. What I am wanting color wise is to have staff as maroon, donators as navy and the rest as black. Could this even be done with this mod?

Link to comment
Share on other sites

I recently purchased this mod and love it. I am having problems with trying to change the color of the names based on user level and if they have donated but everything I have tried just keeps breaking the chat. What I am wanting color wise is to have staff as maroon, donators as navy and the rest as black. Could this even be done with this mod?

It runs all usernames through a function called username() on line 28 of chat_ajax.php. If you add in your if statement checks into this function and then wrap the username in a span with the appropriate colour defined in either a class or (if you're feeling lazy) in a style tag.

You'll need to remember to change the query to select the username and user_level for your checks.

Link to comment
Share on other sites

Thank you for the quick response. I will try that out. Wish me luck for I like most who come here am a noob at coding. lol

How hard would you say it would be to put in a whisper or pm option?

No problem! Good luck, it's not massively complicated just read up on if statements if you're unsure.

if($user['user_level'] == 2) {    
   // Show Admin Username
} else if($user['user_level'] == 3) {
   // Show another username
} else.......

The way the system currently functions it would be surprisingly difficult. Really need to rebuild the system.

Link to comment
Share on other sites

Has anyone been able to make the option to close/open the chats?

I have attempted it by putting the options into the account page then wrapping the chats in if statements but it only worked on the gane chat.

No matter where I tried to wrap the if around the multi channel section it wouldn't let me chat in the chat anymore.

The close/show worked but when trying to chat it'd say that the chat either didn't exist or I didn't have access to it.

Link to comment
Share on other sites

Has anyone been able to make the option to close/open the chats?

I have attempted it by putting the options into the account page then wrapping the chats in if statements but it only worked on the gane chat.

No matter where I tried to wrap the if around the multi channel section it wouldn't let me chat in the chat anymore.

The close/show worked but when trying to chat it'd say that the chat either didn't exist or I didn't have access to it.

Do you mean like leave a chat room?

Link to comment
Share on other sites

Do you mean like leave a chat room?

No I mean have it to where the chat won't show at all for someone who has that chat set to hidden.

I was able to get the function to work like I wanted it to but only worked 100% with the gang chat.

The multiple chat section however didn't work 100%. It would show and hide just fine but for some reason you could not chat in that chat what so ever even if it was not hidden.

Link to comment
Share on other sites

make it a setting or requirement for the user and have them change it in preferences

Edit:

Let me go more into details and see if this works.

I believe there is an option when creating the chats where you define certain requirements for the users to have to access the specific chat you are creating.

So what you would do is make a new column in the users table and call it like "chat_open" set it enum, int, or whatever tickles your fancy.

Then when creating/editing the chat you just add your requirement(s) for keeping the chat open for them. You can then add something in preferences for them to adjust accordingly. Personally I would make one for each chat you make and you can serialize it or encode it so its just still one column in the users table, this way they can keep maybe a certain chat open that they like the best

Edited by KyleMassacre
Link to comment
Share on other sites

make it a setting or requirement for the user and have them change it in preferences

Edit:

Let me go more into details and see if this works.

I believe there is an option when creating the chats where you define certain requirements for the users to have to access the specific chat you are creating.

So what you would do is make a new column in the users table and call it like "chat_open" set it enum, int, or whatever tickles your fancy.

Then when creating/editing the chat you just add your requirement(s) for keeping the chat open for them. You can then add something in preferences for them to adjust accordingly. Personally I would make one for each chat you make and you can serialize it or encode it so its just still one column in the users table, this way they can keep maybe a certain chat open that they like the best

Didn't actually think about doing it like this Kyle. Good shout!

You could even setup multiple variables in the user table 'global_chat','trade_chat' and then add that as a requirement.

Link to comment
Share on other sites

make it a setting or requirement for the user and have them change it in preferences

Edit:

Let me go more into details and see if this works.

I believe there is an option when creating the chats where you define certain requirements for the users to have to access the specific chat you are creating.

So what you would do is make a new column in the users table and call it like "chat_open" set it enum, int, or whatever tickles your fancy.

Then when creating/editing the chat you just add your requirement(s) for keeping the chat open for them. You can then add something in preferences for them to adjust accordingly. Personally I would make one for each chat you make and you can serialize it or encode it so its just still one column in the users table, this way they can keep maybe a certain chat open that they like the best

 

I also didn't think to do it that way. Thank you Kyle.

I will make a user_setting table to store that information since I have other things using a show/hide feature.

Thanks again. :)

Link to comment
Share on other sites

A whole 'nother table would be wiser in my opinion instead of adding more stuff to the users table but that would require a lot more work when altering modules......

I take that back maybe just join the new table with users and userstats in the $ir variable in your globals. :p Either way, there are plenty of ways to go about this but the easiest way is just add more columns to the users table since from what I recall is this module grabs all cloumns from the users table in the chat box settings.

Link to comment
Share on other sites

A whole 'nother table would be wiser in my opinion instead of adding more stuff to the users table but that would require a lot more work when altering modules......

I take that back maybe just join the new table with users and userstats in the $ir variable in your globals. :p Either way, there are plenty of ways to go about this but the easiest way is just add more columns to the users table since from what I recall is this module grabs all cloumns from the users table in the chat box settings.

As the chat is loaded on every page so you'll need those variables it's probably more efficient to join in the $ir query anyway. Providing you setup your foreign keys correctly!

Link to comment
Share on other sites

  • 3 weeks later...
any ideas on how to stop it from forcing the user to scroll to the bottom everytime it calls the ajax? making some modifications but this is the one that is annoying me the most as you can't see more than 4-5 messages up.

Pretty simply! Open up chat_globals.php and find the function scrollBottom() and comment out it's contents (don't remove the function entirely).

function scrollBottom() {    
   //$('.chat_box').each(function() {
   //    $(this).children('.chat_contents').scrollTop($(this).children('.chat_contents')[0].scrollHeight);
   //});    
}

Kinda thing

Link to comment
Share on other sites

i've tried this, but this then means when you navigate to a new page, the chat box does not start at the bottom, meaning you have to scroll to the bottom to see the newest messages. I want it so that I can scroll up the messages without it forcing me to the bottom every 2 seconds when the ajax kicks in.

Make use of;

$(document).ready( function() {

});
Link to comment
Share on other sites

i've tried this, but this then means when you navigate to a new page, the chat box does not start at the bottom, meaning you have to scroll to the bottom to see the newest messages. I want it so that I can scroll up the messages without it forcing me to the bottom every 2 seconds when the ajax kicks in.

Revert your changes to the scrollBottom(); function and then comment out where it's called just after the Ajax request.

Then add this in <script /> tags

$(document).ready( function() {     
   scrollBottom();
});
Link to comment
Share on other sites

  • 2 months later...
I have my colour names in my users db, cname, can you tel me how to add this to the script i have tried but still cant get it work i would also like to add viewuser from the chat box

It would really depend on how you've stored the data.

You'll just need to edit chat_ajax.php and change the part of the script where it pulls out the username and replace it with however you colour code names.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...