• 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

The \"Forcenick\" command for the admin to force a nick chan

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

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

Post a reply
11 posts • Page 1 of 1

Postby skchandon » Wed Sep 02, 2009 6:13 am

I am running a small chatroom based on PFC ( and let me tell you its the best :D :D )
And sometimes there are a few people who would go on being highly inventive and take bad/improper nick.
so I wrote this small command that the admin can use to force a nick name change.
The command goes like this: /forcenick old_badnick new_freshnick
Hope it helps and feel free to tailor it to your needs.
Code: Select all
<?php
//FileName: forcenick.class.php
//- - - - - - - - - - - - -
//Desc: Changes the nick of an user. Can be used by an Admin only.
//Author: Shah Chandon
//Date:   Jul 2009
//-------------------------------------------------------------------------------

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


class pfcCommand_forcenick extends pfcCommand
{
  var $usage = "/forcenick {old_nickname} {new_nickname}";
 
  function run(&$xml_reponse, $p)
  {
     $clientid    = $p["clientid"];
    $param       = $p["param"];
    $params      = $p["params"];
    $sender      = $p["sender"];
    $recipient   = $p["recipient"];
    $recipientid = $p["recipientid"];
   
    $c =& pfcGlobalConfig::Instance();
    $u =& pfcUserConfig::Instance();
    $ct =& pfcContainer::Instance();

    $oldnick   = isset($params[0]) ? $params[0] : '';
    $newnick = isset($params[1]) ? $params[1] : '';
    $admin_nick = $ct->getNickname($u->nickid);
   
    $isadmin = $ct->getUserMeta($u->nickid, 'isadmin');
    if (!$isadmin)
    {
      $cmdp = $p;
      $cmdp["param"] = _pfc("Must be an Admin");
     
      $cmd =& pfcCommand::Factory("error");
      $cmd->run($xml_reponse, $cmdp);
      return;
    }
    $oldnickid = $ct->getNickId($oldnick);
   
    $targetisadmin = $ct->getUserMeta($oldnickid, 'isadmin');
   
    if($targetisadmin)
    {
      //cannot kick and admin -- error
      $cmdp = $p;
      $cmdp["param"] = _pfc("Cannot change an ADMIN");
      $cmdp["param"] .= " (Whats going on!! Why Are you trying to CHANGE an ADMIN NICK??!!)";
      $cmd =& pfcCommand::Factory("error");
      $cmd->run($xml_reponse, $cmdp);
      return;
    }
   
    if ($newnick == '' || $oldnick== '')
    {
      // error
      $cmdp = $p;
      $cmdp["param"] = _pfc("Missing parameter");
      $cmdp["param"] .= " (".$this->usage.")";
      $cmd =& pfcCommand::Factory("error");
      $cmd->run($xml_reponse, $cmdp);
      return;
    }
   
   $cmdstr = 'nick';
   $cmdp = array();
   $cmdp['params'][] = $newnick;
   $cmdp['param'] = $newnick;
   $cmdp['forced']=$admin_nick;
   
   //$cmdp['params'][] = ''; // blank password
   
   
    pfcCommand::AppendCmdToPlay($oldnickid, $cmdstr, $cmdp);
   
   
  }
}






?>
Last edited by skchandon on Thu Sep 17, 2009 12:59 am, edited 1 time in total.
skchandon
New member
 
Posts: 6
Joined: Sat Aug 08, 2009 12:10 am
Top

Postby OldWolf » Thu Sep 03, 2009 12:03 am

Thank you for your contribution. :)
Signature:
Read before Posting: Forum Rules
Note: I am unable to offer support through PM/e-mail at this time.
OldWolf
Site Admin
 
Posts: 1918
Joined: Sun Sep 23, 2007 5:48 am
Top

Postby skchandon » Thu Sep 03, 2009 5:56 am

You are welcome :)
I hope it becomes a useful command
Last edited by skchandon on Thu Sep 03, 2009 5:57 am, edited 1 time in total.
skchandon
New member
 
Posts: 6
Joined: Sat Aug 08, 2009 12:10 am
Top

Postby hazefm » Sat Sep 12, 2009 6:45 pm

just tried it out.. there is a problem.. when you /forcenick user newnick the new nick becomes array..

it just says array.. as the user name, no matter what you type in the command.. any idea on how to fix it?
hazefm
Member
 
Posts: 13
Joined: Tue Aug 18, 2009 2:35 am
Top

Postby skchandon » Sat Sep 12, 2009 8:53 pm

Well, it is working for me as it is..in any case.. the only problem i can think of..

( bear in mind, I am not sure if the solution below would work, but I just have a hunch ...)

In the code above, where it says:

Code: Select all
    $cmdstr = 'nick';
    $cmdp = array();
    $cmdp['params'][] = $newnick;
    $cmdp['param'][] = $newnick;
    $cmdp['forced']=$admin_nick;

change the line:
$cmdp['param'][] = $newnick;
to
$cmdp['param'] = $newnick;

so the Modified Code would look like the following:
Code: Select all
    $cmdstr = 'nick';
    $cmdp = array();
    $cmdp['params'][] = $newnick;
    $cmdp['param'] = $newnick;
    $cmdp['forced']=$admin_nick;

Please let me know if it works or not
Thanks
Last edited by skchandon on Sat Sep 12, 2009 8:56 pm, edited 1 time in total.
skchandon
New member
 
Posts: 6
Joined: Sat Aug 08, 2009 12:10 am
Top

Postby hazefm » Wed Sep 16, 2009 7:50 pm

yes sir!.. that fixes the problem... I'm using the newest versions of this script package, so that might have been the reason it was not working...

thanks alot!!
hazefm
Member
 
Posts: 13
Joined: Tue Aug 18, 2009 2:35 am
Top

Postby skchandon » Thu Sep 17, 2009 1:02 am

hazefm wrote:yes sir!.. that fixes the problem... I'm using the newest versions of this script package, so that might have been the reason it was not working...

thanks alot!!

You are most welcome :D
Note to other readers: I have also incorporated the change in my original post. So you can just copy/paste the first post and you won't have to make any such changes as discussed in the last few replies.
Thanks
Last edited by skchandon on Thu Sep 17, 2009 1:04 am, edited 1 time in total.
skchandon
New member
 
Posts: 6
Joined: Sat Aug 08, 2009 12:10 am
Top

Postby re*s.t.a.r.s.*2 » Wed Nov 04, 2009 8:59 pm

Hi i just want to add that this works ok for version 1.2 of pfc , and to clarify that this file forcenick.class.php must go in the folder /src/commands and that it wont work if you have the
$params["frozen_nick"] = true; enabled, so you need to disable this in order to work , hope it helps..
Free Singles Chat Rooms No Registration Required
Text and Chat Singles no need to register or app required
Sala De Bate Papo Online Grátis E Sem Cadastro
re*s.t.a.r.s.*2
Support Team
 
Posts: 612
Joined: Wed Sep 24, 2008 4:04 pm
Location: los angeles CA
  • Website
Top

Postby skchandon » Thu Nov 05, 2009 3:21 am

@re*s.t.a.r.s.*2: Thank you very much for clarifying that and also for posting your findings. I was not even aware of $params["frozen_nick"] had such effect on this command. :D
skchandon
New member
 
Posts: 6
Joined: Sat Aug 08, 2009 12:10 am
Top

Postby Hationyx » Mon Nov 15, 2010 9:32 pm

Edit- nevermind i'm just stupid.
Last edited by Hationyx on Mon Nov 15, 2010 10:12 pm, edited 1 time in total.
Hationyx
New member
 
Posts: 5
Joined: Sun Nov 14, 2010 3:50 pm
Top

Postby CodezStar » Tue Mar 01, 2011 3:27 pm

It worked fine with version 1.3 also.
CodezStar
New member
 
Posts: 6
Joined: Tue Mar 01, 2011 3:25 pm
Top


Post a reply
11 posts • Page 1 of 1

Return to Contributions (v1.x)

Who is online

Users browsing this forum: No registered users and 12 guests

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