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

/topic .. work in progress.. please help

Post a bug fix, a new feature, a theme ...

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

Post a reply
1 post • Page 1 of 1

Postby hazefm » Wed Aug 19, 2009 9:22 pm

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.. :)
hazefm
Member
 
Posts: 13
Joined: Tue Aug 18, 2009 2:35 am
Top

Post a reply
1 post • Page 1 of 1

Return to Contributions (v1.x)

Who is online

Users browsing this forum: No registered users and 3 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