• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ General Support (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

change chatroom title on the fly?

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
4 posts • Page 1 of 1

Postby mak2k » Thu Mar 15, 2007 3:16 am

I stumbled upon this site while looking for intro about PHP and AJAX (just learned how to use it today.. and it's freaking cool stuff!!!) and i have to say i'm INCREDIBLY impressed! I was looking for a chatroom for my online community. So far, i'm happy with this.

I was wonder if it's possible to change the chatroom title on the fly? I know i can write my own command, but i was wondering how i can do it? I know i can change it in index.php with the params["title"] but that requires me to rehash the page. Also, what is the maximum amount of people that can be on this chat at a time?

Thanks
mak2k
New member
 
Posts: 2
Joined: Thu Mar 15, 2007 3:09 am
Top

Postby Yautja_cetanu » Fri Mar 23, 2007 12:53 am

Ideally if you could do that, then you could change the title to notify people of a new message similar to googletalk on googlemail
Yautja_cetanu
Member
 
Posts: 18
Joined: Sat Feb 25, 2006 1:47 am
Top

Postby dannic » Sun Apr 29, 2007 6:44 pm

The thing I have been looking at is closing the chat window then opening it back up with a new title.
Of course that means a new chat room too. Now I don't know that is what you are talking about.
dannic
Member
 
Posts: 18
Joined: Fri Jan 05, 2007 1:12 am
Top

Postby hazefm » Tue Aug 18, 2009 8:33 am

I'm working on something like this as well...
i have a command class, and an template hack, but I'm missing parts.. I just started learning ajax ;)

Code: Select all
<?php
//topic.class.php

require_once(dirname(__FILE__)."/../pfccommand.class.php");

class pfcCommand_topic extends pfcCommand
{
  var $usage = "/topic {message}";

  function run(&$xml_reponse, $p)
  {
    $clientid    = $p["clientid"];
    $param       = $p["param"];
    $sender      = $p["sender"];
    $recipient   = $p["recipient"];
    $recipientid = $p["recipientid"];
   
    $c  =& pfcGlobalConfig::Instance();
    $u  =& pfcUserConfig::Instance();
    $ct =& pfcContainer::Instance();

    if (trim($param) == "")
    {
    $fh = @fopen('topic.dat', 'r+');
    $topic = @fread($fh, filesize('topic.dat'));
    fclose($fh);
    $ct->write($recipient, "*topic*", $this->name, "current topic: [i][u]".$topic."[/i][/u]");
    return;
    }
    $msg = phpFreeChat::PreFilterMsg($param);
    $ct->write($recipient, "*topic*", $this->name, $u->getNickname()." changes the topic to: [i][u]".$msg."[/i][/u]");
    // Write out the topic data
    $fh = @fopen('topic.dat', 'r+');
    $topic = @fread($fh, filesize('topic.dat'));
    if ($topic == $msg."n"){
    fclose($fh);
    die(0);
    }else{
    @fclose($fh); // if it errors, then the file doesn't exist, and the stream was never open
    $fh = fopen('topic.dat', 'w');
    fwrite($fh, $msg."n");
    }
    fclose($fh);
  }
}

?>

One problem is, I cannot seem to figure out away to only allow admins or operators access to change the topic.

Now for the template hack (default)

replace this:
Code: Select all
 <h2 id="pfc_title"><?php echo $title; ?></h2>

with this:
Code: Select all
<?php
    $fh = @fopen('topic.dat', 'r+');
    $topic = @fread($fh, filesize('topic.dat'));
    fclose($fh);
?>
<h2 id="pfc_title"><?php echo $topic; ?></h2>

The problem is, I'm just learning ajax, I am unsure how to have this piece of code refresh w/o refreshing the whole page.

Hopefully someone with knowledge will step in and help out.. :)
Last edited by hazefm on Tue Aug 18, 2009 8:45 am, edited 1 time in total.
hazefm
Member
 
Posts: 13
Joined: Tue Aug 18, 2009 2:35 am
Top


Post a reply
4 posts • Page 1 of 1

Return to General Support (v1.x)

Who is online

Users browsing this forum: No registered users and 22 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
cron
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub