• 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

_GET Parameters seemingly ignored

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

Post a reply
9 posts • Page 1 of 1

Postby realitymage » Mon Sep 03, 2007 10:16 am

Hi, I have a script that takes GET arguments and uses them to set the nick and room. However, they don't work as expected:

1. Setting the nick via URL only works the first time. After that, nick is pulled from the cache, despite it being a (theoretically) dynamic variable.

2. Setting the room via URL NEVER works. I really can't understand why.

Here is link to the room:
http://www.mathim.com/chatEngine/index. ... oom&sn=Ned

Here is link to a page that will delete all the stored data in /data/private/:
http://www.mathim.com/chatEngine/flush.php

Here is code to the index.php page

Code: Select all
<?php

require_once "../config.php";
require_once dirname(__FILE__)."/src/phpfreechat.class.php";

$sn = $_GET["sn"];
$room = strval($_GET["room"]);
$invite = $_GET["invite"];

$channels = array($_GET["room"]);

$params = array();
$params["serverid"]       = md5(__FILE__); // calculate a unique id for this chat
$params["title"]          = $conf_slogan;
if($room != "")
{
$params["channels"] = $channels;
}
if($sn != "") $params["nick"] = $sn;  // setup the intitial nickname
$params["frozen_nick"]    = false;     // do not allow to change the nickname
$params["shownotice"]     = 3;        // 0 = nothing, 1 = just nickname changes, 2 = connect/quit, 3 = nick + connect/quit
$params["max_nick_len"]   = 20;       // nickname length could not be longer than 10 caracteres
$params["max_text_len"]   = 300;      // a message cannot be longer than 50 caracteres
$params["max_channels"]   = 3;        // limit the number of joined channels tab to 3
$params["max_privmsg"]    = 3;        // limit the number of private message tab to 1
$params["max_msg"]        = 15;       // max message in the history is 15 (message seen when reloading the chat)
#$params["height"]         = "450px";  // height of chat area is 230px
#$params["width"]          = "800px";  // width of chat area is 800px
$params["debug"]          = true;     // activate debug console
$params["connect_at_startup"] = true;
$params["start_minimized"]    = false;
$params["nickmarker"]     = true;
$params["showsmileys"]          = false;
$params["showsmileys"]          = false;
$params["clock"]          = true;
$params["data_public_url"] = "/chatEngine/data/public";
$params["server_script_url"] = "/chatEngine/index.php";

$chat = new phpFreeChat( $params );

print "<b>Extra Debugging :</b><br>n";

print "<b>Params:</b><br>";
print_r($params);

print "<br><b>_GET:</b> <br>";
print_r($_GET);

print "n<br><b>Room:</b> $roomn";

print "n<br><b>Channels:</b>";
print_r($channels);

$c =& pfcGlobalConfig::Instance();

print_r($c->channels);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <title>MathIM:
<?php

if($params["channel"] !="") print $params["channel"];
else print $conf_slogan;

?>
</title>
 </head>
 <body>

<?php require_once "../theme/header.php"?>

<div class="content">
  <?php $chat->printChat(); ?>
</div>

</body></html>

Please help me make this program behave. Thanks.
realitymage
New member
 
Posts: 1
Joined: Mon Sep 03, 2007 10:09 am
Top

Postby King Moonraiser » Tue Sep 04, 2007 9:25 pm

I assume you're verifying those values are passed with the print_r statements. You need to convert the screen name variable to utf-8 format. See the FAQ how to do that.
King Moonraiser
Member
 
Posts: 98
Joined: Fri Jun 22, 2007 9:42 pm
  • Website
Top

Postby onslo » Mon Sep 10, 2007 11:43 am

I have the exact same problem with dynamic channel/room names which are set by $_GET.
The thing is that this used to work just fine in Beta9 but seems to have been broken in Beta11 (not sure about Beta10, never installed it).

I really need this to work and any help would be appreciated.

Regards

Onslo
Last edited by onslo on Mon Sep 10, 2007 11:43 am, edited 1 time in total.
onslo
Member
 
Posts: 14
Joined: Wed May 02, 2007 1:41 pm
Top

Postby King Moonraiser » Mon Sep 10, 2007 2:40 pm

Are you sure those room names are in UTF-8 format?
King Moonraiser
Member
 
Posts: 98
Joined: Fri Jun 22, 2007 9:42 pm
  • Website
Top

Postby onslo » Mon Sep 10, 2007 3:27 pm

Even if i encode them as UTF8...

Code: Select all
$params["channels"] =  array(utf8_encode(Room_ . $_GET['chatid']));

Only the first channel that you join is shown.

Rgs

Onslo
onslo
Member
 
Posts: 14
Joined: Wed May 02, 2007 1:41 pm
Top

Postby onslo » Mon Sep 17, 2007 2:20 pm

It's possibly related to the removal of these code lines from pfcclient.js :

Code: Select all
        // join the default channels comming from the parameter list
        for (var i=0; i<pfc_defaultchan.length; i++)
        {
          if (i<pfc_defaultchan.length-1)
            cmd = '/join2';
          else
            cmd = '/join';
          cmd += ' "'+pfc_defaultchan[i]+'"';
          this.sendRequest(cmd);
        }
        // now join channels comming from sessions
        for (var i=0; i<pfc_userchan.length; i++)
        {
          if (i<pfc_userchan.length-1)
            cmd = '/join2';
          else
            cmd = '/join';
          cmd += ' "'+pfc_userchan[i]+'"';
          this.sendRequest(cmd);
        }

        // join the default privmsg comming from the parameter list
        for (var i=0; i<pfc_defaultprivmsg.length; i++)
        {
          if (i<pfc_defaultprivmsg.length-1)
            cmd = '/privmsg2';
          else
            cmd = '/privmsg';
          cmd += ' "'+pfc_defaultprivmsg[i]+'"';
          this.sendRequest(cmd);
        }
        // now join privmsg comming from the sessions
        for (var i=0; i<pfc_userprivmsg.length; i++)
        {
          this.sendRequest('/privmsg "'+pfc_userprivmsg[i]+'"');
        }

The above is present in beta9 code but not in beta10 or beta11 code.
In fact, looking at SVN it appears t have been reomved from pfcclient.js in revision 984 (messaged "work on simplifications").

If I add this back into pfcclient.js at the right place then multiple rooms seems to work again when created via $_GET params.

Was there a specific reason to remove this section of code in the first place ?

Rgs

Onslo
onslo
Member
 
Posts: 14
Joined: Wed May 02, 2007 1:41 pm
Top

Postby phpfreechat » Mon Sep 17, 2007 6:58 pm

onslo this code has been moved in the src/commands/connect.class.php file
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top

Postby onslo » Tue Sep 18, 2007 8:33 am

Kerphi,

Are you sure ?

I see no sign of this code in the connect.class.php file.

If the code exists elsewhere then why do I need to have it in the pfcclient.js file in order for the dynamic room/channel creation to work properly ?

Rgs

Onslo
onslo
Member
 
Posts: 14
Joined: Wed May 02, 2007 1:41 pm
Top

Postby phpfreechat » Tue Sep 18, 2007 5:13 pm

Yes i'm sure, here is the piece of code in connect.class.php from subversion trunk:
Code: Select all
      $chanlist = (count($u->channels) == 0) ? $c->channels : $u->getChannelNames();
      for($i = 0 ; $i < count($chanlist) ; $i++)
      {
        $cmdp = array();
        $cmdp["param"] = $chanlist[$i];
        $cmd =& pfcCommand::Factory( $i < count($chanlist)-1 || !$joinoldchan ? 'join2' : 'join' );
        $cmd->run($xml_reponse, $cmdp);
      }

      $pvlist = (count($u->privmsg) == 0) ? $c->privmsg : $u->getPrivMsgNames();
      for($i = 0 ; $i < count($pvlist) ; $i++)
      {
        $cmdp = array();
        $cmdp["param"] = $pvlist[$i];
        $cmd =& pfcCommand::Factory( $i < count($pvlist)-1 || !$joinoldchan ? 'privmsg2' : 'privmsg' );
        $cmd->run($xml_reponse, $cmdp);
      }
phpfreechat
Site Admin
 
Posts: 2657
Joined: Tue Feb 07, 2006 3:35 pm
Location: France
Top


Post a reply
9 posts • Page 1 of 1

Return to General Support (v1.x)

Who is online

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