Jump to content

Featured Replies

:bunny: Hi Mike!

Great to have the Chat Room back. Only problem I encountered was that the only sound command that works is /hey. I could not access any of the others.

You will have made 2Many's day, especially if the sounds are working!

Kmack can now take breaks from work!

thanks,

Ken


I'm having trouble with the code for the main page. If anyone here knows how to program PHP, I would appreciate some help. It's just not working for me. The last line of code I commented out is also not right.


<?
$blocks_modules['webchat'] = array(
'func_display' => 'blocks_webchat_block',
'text_type' => 'WebChat',
'text_type_long' => "WebChat Box",
'allow_create' => true,
'allow_delete' => true,
'form_content' => false,
'form_refresh' => false,
'show_preview' => true
);
function blocks_webchat_block($row){
global $cookie, $prefix, $currentlang;

// two fixed vars you can to change, but definitely the $modulename one to your installed folder for WebChat
$showusers = true;
$modulename = "WebChat";

$basepath = "modules/$modulename";

if (file_exists("$basepath/language/lang-english.php")) {
include "$basepath/language/lang-english.php";
} else {
include "$basepath/language/lang-english.php";
}

require "$basepath/inc/config.php";

$tstamp = time();
$tstamp -= $usertime;
$q=mysql_query("delete from ".$prefix."_chatuser where last < ".$tstamp);

$content = "<table border=\"0\" cellspacing=\"5\">";
$sql = "select ".$prefix."_chatroom.*, count(".$prefix."_chatuser.rid) as users from ".$prefix."_chatroom left join ".$prefix."_chatuser on ".$prefix."_chatuser.rid = ".$prefix."_chatroom.rid group by ".$prefix."_chatroom.rid order by ".$prefix."_chatroom.typ, ".$prefix."_chatroom.name";
$q = mysql_query($sql);
if(mysql_num_rows($q) == 0){
$content .= MSG_001;
} else {
while($result = mysql_fetch_array($q)) {
$content .= "<tr valign=\"top\"><td><a href=\"modules.php?op=modload&name=".$modulename."&file=index&roomid=$result[rid]\">$result[name]</a></td>";
$content .= "<td>".$result[users].($result[users]==1?" user":" users");
$content .= "<br><i>";
if($showusers && $result[users] != 0){
$first = true;
$q2 = mysql_query("select name from ".$prefix."_chatuser where rid = ".$result[rid]);
while($result2 = mysql_fetch_array($q2)){
if($first) {
$first = false;
$content .= $result2[name];
} else
$content .= ", ".$result2[name];
}
}
$content .= "</i></td></tr>";
}
}
$content .= "</table>";
$row[content] = $content;
// themesideblock($row);
}
?>

Mike: Although I'm not a programmer in PHP, what experience I have is that I can sometimes look at code and pick out oddities that my friends who DO write code say helps them.

So, here goes.

I'm putting my comments in, right below the line in question:


<?
$blocks_modules['webchat'] = array(
'func_display' => 'blocks_webchat_block',
'text_type' => 'WebChat',

Why are all these in single quotes?


'text_type_long' => "WebChat Box",

While this one is in double quotes?


'allow_create' => true,
'allow_delete' => true,
'form_content' => false,
'form_refresh' => false,
'show_preview' => true
);
function blocks_webchat_block($row){
global $cookie, $prefix, $currentlang;

// two fixed vars you can to change, but definitely the $modulename one to your installed folder for WebChat
$showusers = true;
$modulename = "WebChat";

$basepath = "modules/$modulename";

if (file_exists("$basepath/language/lang-english.php")) {
include "$basepath/language/lang-english.php";
} else {
include "$basepath/language/lang-english.php";
}

require "$basepath/inc/config.php";

$tstamp = time();
$tstamp -= $usertime;
$q=mysql_query("delete from ".$prefix."_chatuser where last < ".$tstamp);

$content = "<table border=\"0\" cellspacing=\"5\">";
$sql = "select ".$prefix."_chatroom.*, count(".$prefix."_chatuser.rid) as users from ".$prefix."_chatroom left join ".$prefix."_chatuser on ".$prefix."_chatuser.rid = ".$prefix."_chatroom.rid group by ".$prefix."_chatroom.rid order by ".$prefix."_chatroom.typ, ".$prefix."_chatroom.name";
$q = mysql_query($sql);
if(mysql_num_rows($q) == 0){
$content .= MSG_001;
} else {
while($result = mysql_fetch_array($q)) {
$content .= "<tr valign=\"top\"><td><a href=\"modules.php?op=modload&name=".$modulename."&file=index&roomid=$result[rid]\">$result[name]</a></td>";
$content .= "<td>".$result[users].($result[users]==1?" user":" users");
$content .= "<i>";
if($showusers && $result[users] != 0){
$first = true;
$q2 = mysql_query("select name from ".$prefix."_chatuser where rid = ".$result[rid]);
while($result2 = mysql_fetch_array($q2)){
if($first) {

Maybe in php the IF statement defaults to IF( x=true, then), but if not, you haven't provided a logical test for the IF.


$first = false;
$content .= $result2[name];
} else
$content .= ", ".$result2[name];
}
}
$content .= "</i></td></tr>";
}
}
$content .= "</table>";
$row[content] = $content;
// themesideblock($row);
}
?>

Hope this helps.

Enrique

Hi Enrique,

Awesome job! I'll try to modify a few of those tonight and give it another whirl on the main page. You're right, some of that code seems to not follow the other code bits.

PS: I edited your post and put [ php ] and [ / php ] around the code so could read it easier. *makes the code stand out in color*

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Who's Online (See full list)


Important Information

By using this site, you agree to our Privacy Policy and Guidelines. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.