Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By shauvik on
I tried installing Yshout but it doesn't seem to work for my 4.7 .. also phpfreechat is under development and it hasn't been updated for 4.7...
So, i made a php page in Drupal to just get going...
It would be nice if any chat module is ready for 4.7 ... please do tell me if any one gets one :)
<?php if (!$GLOBALS["user"]->uid) : ?>
Not logged in - Please log in to access the Chat...
<?php else : ?>
<?php
mysql_connect ("localhost", "username", "password") or die
('I cannot connect to the database because: ' . mysql_error());
if(isset($_POST['ad_shout'])) {
$sqlshoutSB = '';
$queryshoutSB = "INSERT INTO `shoutbox` (`SBname` , `SBshout` , `SBdate`)
VALUES ('".$_POST['SBname']."', '".$_POST['SBshout']."', '".$_POST['SBdate']."')";
$sqlshoutSB .= mysql_query($queryshoutSB)
or die(mysql_error());
}
?>
<?php
$query = "SELECT count(*) as cnt FROM `shoutbox`";
$sql = mysql_query($query) or die(mysql_error());
$record = mysql_fetch_object($sql);
$query = "SELECT * FROM `shoutbox` ORDER BY `SBid` ASC LIMIT ".($record->cnt-20).",20";
$sql = mysql_query($query) or die(mysql_error());
?>
<table width="100%" height="400" cellpadding="5" cellspacing="1" bgcolor="#666666">
<tr>
<td bgcolor="#EFEFEF" width="90%" valign="top" height="300">
<?php
while($record = mysql_fetch_object($sql)) {
echo "[".$record->SBdate."] <b>".$record->SBname.": </b><em>".$record->SBshout."</em><br />";
}
?>
</td>
</tr>
<td bgcolor="#666666" valign="bottom">
<form name="ad_shout" method="POST" action="<?php echo $_SERVER['REQUEST_URI'] ?>">
<input type="hidden" name="SBname" value="<?php echo $GLOBALS['user']->name; ?>">
<font color="#FFFFFF">Message: <br /><textarea cols="50" rows="3" name="SBshout"></textarea>
<input type="hidden" name="SBdate" value="<?php echo date(d."/".n."/".y."-".G.":".i.":".s); ?>">
<input type="submit" name="ad_shout" value="Shout!">
</form>
</td>
</tr>
</table>
<?php endif; ?>
And here is the SQL Query for creating the database..
CREATE TABLE `shoutbox` (
`SBid` INT(8) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`SBname` VARCHAR(26) NOT NULL,
`SBshout` TEXT NOT NULL,
`SBdate` VARCHAR(40) NOT NULL
)TYPE = myisam;
courtesy: Webpuma hosting
Tell me if it is of help to anyone :)
Comments
One more thing... the code
One more thing... the code assumes that you have atleast 20 chat entries in the database...
either you can enter any test data there
OR can edit this line
$query = "SELECT * FROM `shoutbox` ORDER BY `SBid` ASC LIMIT ".($record->cnt-20).",20";
with
$query = "SELECT * FROM `shoutbox` ORDER BY `SBid` DESC LIMIT 20";
With this you will see the entries in reverse order and you can undo this when you have more than 20 entries in the database.. :)
Shauvik Roy Choudhary
http://shauvik.com
Irc Chat eirc java
I am using a java eirc enable chat check the source code here at www.coolsmile.net
I have the chat connecting with irc (dalnet server)
Its easy to call profile users fields to be in chat information
Check out this, the main site is drupal powered site and i am making a seperate chat, any coder can make this chat program integrate with drupal as module
http://www.biladi.ma/chat
---
All Google Blogs in one place
http://www.googledemo.org