• 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

motd command (Message of the day)

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

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

Post a reply
9 posts • Page 1 of 1

Postby MaDc0w » Wed Aug 20, 2008 1:55 pm

Well I'm still waiting around and built a simple /motd command that can also be displayed automatically after a user connects.

Create a new file src/commands/motd.class.php.

Paste the following into it and edit it to your liking:

Code: Select all
<?php
/**
 * motd.class.php
 *
 * Copyright © 2008 MaDc0w <MaDc0w@undergroundz.org>
 * phpFreeChat Copyright © 2008 Stephane Gully <stephane.gully@gmail.com>
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, 51 Franklin St, Fifth Floor,
 * Boston, MA  02110-1301  USA
 */

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

class pfcCommand_motd extends pfcCommand
{
  var $usage = "/motd";
 
  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();

    $msg  = "";
    $msg .= "<center><h2>Message of the day:</h2></center>";
    $msg .= "<div style="float: center; text-align: center; height: 100%; width: 100%; background: white; border: 1px solid black;">";"
    $msg .= </div>";
    $msg .= "<span style="font-size: 20pt; font-family: Arial; color: green;">Welcome to the chat!</span><br>";
    $msg .= "<ul>";
    $msg .= "<b>Type /help to see available commands</b><br>";
    $msg .= "<li style="margin-left: 20px; font-weight: bold;">Have fun.</li>";
    $msg .= "<li style="margin-left: 20px; font-weight: bold;">Give feedback!</li>";
    $msg .= "</ul>";
    $msg .= "<a href="http://www.phpfreechat.net/forum/viewtopic.php?id=3145" target="_blank">";
    $msg .= "<img src="http://www.phpfreechat.net/pub/logo2_80x15.png" alt="">";
    $msg .= "</a>";
    $msg .= "<i> Get your own copy of motd now!</i>";

    $xml_reponse->script("pfc.handleResponse('help', 'ok', '".addslashes($msg)."');");
  }
}

?>

To make it run automatically:

Open src/commands/connect.class.php and add before:

Code: Select all
      $xml_reponse->script("pfc.handleResponse('".$this->name."', 'ok', Array('".addslashes($nick)."'));");

These 2 lines:

Code: Select all
   
      $cmd =& pfcCommand::Factory('motd');
      $cmd->run($xml_reponse, $cmdp);

Have fun.

MaDc0w
Last edited by MaDc0w on Thu Oct 02, 2008 11:18 pm, edited 1 time in total.
MaDc0w
MaDc0w
Member
 
Posts: 20
Joined: Tue Aug 12, 2008 10:32 am
  • Website
Top

Postby fozzy » Fri Sep 19, 2008 10:59 am

I don't have that portion of txt in my connect.class.php file

Are you sure its in that file?

Thanks in advance
fozzy
New member
 
Posts: 4
Joined: Thu Sep 18, 2008 2:15 pm
Top

Postby MaDc0w » Sun Sep 21, 2008 10:26 am

Yes i'm very sure.

It's line 82 in src/commands/connect.class.php.
MaDc0w
MaDc0w
Member
 
Posts: 20
Joined: Tue Aug 12, 2008 10:32 am
  • Website
Top

Postby PKHG » Tue Sep 23, 2008 1:45 pm

I get a pop-upscreen (like alert from javascript) where the tags are NOT replaced ... (security setting?)
PKHG
New member
 
Posts: 6
Joined: Sun Sep 21, 2008 5:14 pm
Top

Postby MaDc0w » Sun Sep 28, 2008 5:51 pm

I can't reproduce your error.

I'll reinstall my test environment next week and retest.

I do remember having such a problem with other commands. Don't remember what I did to
fix/change it though.
MaDc0w
MaDc0w
Member
 
Posts: 20
Joined: Tue Aug 12, 2008 10:32 am
  • Website
Top

Postby PKHG » Mon Sep 29, 2008 9:51 am

Yes, please, I will try again (later) ...
PKHG
New member
 
Posts: 6
Joined: Sun Sep 21, 2008 5:14 pm
Top

Postby MaDc0w » Tue Sep 30, 2008 7:01 am

Please try this:

Replace:

$xml_reponse->script("pfc.handleResponse('kick', 'ok', '".addslashes($msg)."');");


With


$xml_reponse->script("pfc.handleResponse('help', 'ok', '".addslashes($msg)."');");



I'm "stealing" the "ok response" from the fuction handleResponse in pfcclient.js.
I Just noticed the original code has no "ok response" for kick as I added that myself.
MaDc0w
MaDc0w
Member
 
Posts: 20
Joined: Tue Aug 12, 2008 10:32 am
  • Website
Top

Postby chemo » Thu Oct 02, 2008 6:11 pm

It works fine. I had the same problem as PKHG but the replacement fixed the bug.

Many thanks. It's very useful for my web. :)
chemo
New member
 
Posts: 3
Joined: Thu Jun 28, 2007 8:24 am
Top

Postby MaDc0w » Thu Oct 02, 2008 11:20 pm

Thanks for testing.

First post has been corrected.
MaDc0w
MaDc0w
Member
 
Posts: 20
Joined: Tue Aug 12, 2008 10:32 am
  • Website
Top


Post a reply
9 posts • Page 1 of 1

Return to Contributions (v1.x)

Who is online

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