1<?php
2
3require_once(dirname(__FILE__)."/../pfccommand.class.php");
4
5class pfcCommand_asknick extends pfcCommand
6{
7  function run(&$xml_reponse, $p)
8  {
9    $clientid    = $p["clientid"];
10    $param       = $p["param"];
11    $sender      = $p["sender"];
12    $recipient   = $p["recipient"];
13    $recipientid = $p["recipientid"];
14
15    $c =& pfcGlobalConfig::Instance();
16    $u =& pfcUserConfig::Instance();
17
18    $nicktochange = phpFreeChat::FilterNickname($param);
19
20    if ($c->frozen_nick)
21    {
22      // assign a random nick
23      $cmdp = $p;
24      $cmdp["param"] = $nicktochange."".rand(1,1000);
25      $cmd =& pfcCommand::Factory("nick");
26      $cmd->run($xml_reponse, $cmdp);
27    }
28    else
29    {
30      if ($nicktochange == "")
31      {
32        $nicktochange = $u->nick;
33        $msg = _pfc("Please enter your nickname");
34      }
35      else
36        $msg = "'".$nicktochange."' is used, please choose another nickname.";
37      $xml_reponse->script("var newnick = prompt('".addslashes($msg)."', '".addslashes($nicktochange)."'); if (newnick) pfc.sendRequest('/nick \"'+newnick+'\"');");
38    }
39  }
40}
41
42?>