Link to home
Start Free TrialLog in
Avatar of Steve_Newbie
Steve_Newbie

asked on

passing member.php username login cookie to flash chat login screen

I'm trying to integrate a basic Flash chat into my site, have rudimentary knowledge of PHP and really nothing in Flash, but have, I think, a basic question.  

Can someone help just pass my main site username/NickName,  for which a cookie is set at main site login,  to a FlashChat login screen field and echo/print it in there?   Ideally I'd like to get rid of the FlashChat user name login field totally and simply have the room selection...but unless that is easy, the former solution would be fine for now.  I assume the latter would require a swf decompilation etc etc??....would certainly like to move towards that, but first things first......  

The cookie is set on the main login member.php page, which is in the root directory:
             setcookie( "imNick", $p_arr[NickName], 0, '/' );

The chat.php file which contains the login code below is in a /FlashChat subdirectory:


<?php
ob_start();
//

$nick = $HTTP_POST_VARS[nick];

$roomid = $HTTP_POST_VARS[roomid];


//

require "config.inc.php";

session_start();

dbget_dbopen();

//

$this_chatter_logged = false;

$onunload_action = "";

if($nick and $roomid){

      make_session_unregister();

      make_session_unregister_chat();

      $chatsession = chat_login_room($nick,$roomid);

      if($chatsession){

            $last_msg_id = $chatsession[lastid];

            $user_login = $chatsession[nick];

            $chat_room_id = $roomid;

            $uid = 0;            //Vulnerable

            $user_role = "";      //Vulnerable

            make_session_register();

            make_session_register_chat();

            $onunload_action = "onunload=\"javascript:hiddenScreen('chatout.php');\"";

            $this_chatter_logged = true;

      }

}

dbget_dbclose();

if($this_chatter_logged){

      $nick = urlencode($user_login);

      $this_swf = "chat.swf?chat_delay=$def_chat_delay&chat_nick=$nick&chat_ad_movie=chatad.php&chat_ad_x=$def_ad_x&chat_ad_y=$def_ad_y&chat_ad_width=$def_ad_width&chat_ad_height=$def_ad_height";

      include "tmp.chatrun.php";

}else{

      include "tmp.chatlogin.php";

}

?>

#########################################################
The associated html which is in tmp.chatlogin.php file in /FlashChat  is as follows :
#########################################################

<tr>

      <td valign=bottom class=tip bgcolor="<?=$def_bgc_head_sep?>" height=125>

      <form name=chat action=chat.php method=post onsubmit="return (document.chat.nick.value.length>0?true:false);">

      <table width=100% border=0 cellspacing=0 cellpadding=1>

      <tr>

            <td rowspan=3 width=5%>&nbsp;</td>

            <td rowspan=3 class=tipf valign=top width=35%><?=$msg_chat_tip?></td>

            <td align=right valign=middle class=tip width=30%>

                  <?=$msg_select_nick?>&nbsp;

            </td>

            <td align=left valign=middle class=tip width=30%>

                  <input class=textfield name=nick>

            </td>

      </tr>

      <tr>

            <td align=right valign=middle class=tip>

                  <?=$msg_select_room?>&nbsp;

            </td>

            <td align=left valign=middle class=tip>

                  <?include "selectroom.inc.php";?>

            </td>

      </tr>

#########################################################

Thanks.  Please let me know if I am leaving anything critical out that is needed.  

Steve

Avatar of Steve_Newbie
Steve_Newbie

ASKER

OK, not sure if this is harder than I think......and associated point value, so increasing to 200.  Still relatively new to the board overall.   Help please.
Thanks.
S
Well here is a link to setting and reading cookies inside of flash.
 http://www.permadi.com/tutorial/flashCookie/


But do you have the Fla's or just the swf's, because if you don't have the fla's then there really isn't anything that we can do.

But Basically in flash you would have
if (cookie=="false")
{}
else{textbox = cookie;}}


But first you would have to load the get cookie.php file that reads the cookie set and returns a value of the cookie or false if no cookie has been set that was set from your home page.

So Mainly it has to do with php and not so much the flash side because all you are going to do is call up the php page and get the value from it.

Hope this helps a little
Fixitben
Thanks.  OK, I created a getcookie.php file, which is in the /FlashChat subdirectory where the php login files are and where chat.swf is,  and included the main site login file where the cookie was set (member.php)
The cookie is definitely set on the php side as I can echo it in the  tmp.chatlogin.php file just below the textfield where the login name is supposed to be entered.


<?php include "../member.php";?>
<?php
eval("\$p_arr[NickName]=\$$imNick;");
echo("cookieValue=$p_arr[NickName]");
?>


Also, here is the AS part of the FLA file that I think is relevant to the login:

// Frame 1 actions...

function process_client_message(msg) {
   get_users(false);
   msg = escape(msg);
   getURL(def_script_send + "?msg=" + msg + "&receiver_ip=" + this.chat_sendto_ip,this,"Error GetURL2" metod=194);
};
function process_server_message() {
   this.messages = Number (this.messages);
   if (this.messages > 0) {
         for (i = 1;  i <= this.messages; i ++) {
               this.chat.doReceiveMessage("cmsg" add i);
               }
         this.messages = 0;
         }
};
function chat_connect() {
   this.chat_interval = setInterval(this,"on_chat_interval",this.chat_interval_receive);
};
function chat_disconnect() {
   clearInterval(this.chat_interval);
};
function on_chat_interval() {
   getURL(def_script_receive,this,"Error GetURL2" metod=194);
   getURL(def_script_chatters,this.users_list,"Error GetURL2" metod=194);
};
function get_users(c) {
   if (c) {
         users_list.play();
         }
   else {
   users_list.gotoAndStop(1);
   }
};
function select_user(l , d) {
   if ( l <> this.chat_nick) {
         this.chat_sendto_nick = l;
         this.chat_sendto_ip = d;
         }
   else {
   this.chat_sendto_nick = ;
   this.chat_sendto_ip = ;
   }
};
function get_link() {
   this.chat_sendto_nick = ;
   this.chat_sendto_ip = ;
};
def_text_color = "0xFFFFFF";
def_script_send = "chatsend.php";
def_script_receive = "chatrec.php";
def_script_chatters = "chatusers.php";
this.error = ;
this.messages = 0;
this.chatters = 0;
this.chat_interval_receive = this.chat_delay;
this.chat_text_color = this.def_text_color;
this.chat_sendto_nick = ;
this.chat_sendto_ip = ;
this.chat_link_url = ;


Stuck from here on out......help?

Thanks.
S
Can you post the fla somewhere?  

Because those are just functions and they have to be used somewhere  I need to see how they are used and where.

fixitben
OK, have a problem then. The files I extracted were by decompilation of the swf.  I don't think I can output the entire decompiled swf in fla format, at least with this software app.  So, we might be up against the problem you mentioned.  The product is available at   http://ecomstudio.net/sales/#9
and is basically a free GPL package app download (Flash Chat 1.9F GPL Package).  If you have the time to look at it, that would be great.  IF not, I understand and will just assign the points since you did answer the question I posed......I just can't get the final part done with my lack of knowledge in this area.  Please advise.
Thanks.
S  
ASKER CERTIFIED SOLUTION
Avatar of fixitben
fixitben

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I guess I need an education on this.  This is a free product. The GPL agreement that I read says that you can do anything with it as long as I display their copy-right on the product.  I spoke with the sales department (they sell other products for$$) and they had no problem with what I was trying to do....however, since this was sales and they do not have tech support for free products, they would not go any further to help in this regard.  So, I don't think I can get anything else from them.....but, am I wrong with all of the above? I can't see where the GPL is broken with all of this.  Please advise as a last comment.....
Thanks again.
Steve
I was just saying that You could have broken it.  Most of the time if you alter someone's stuff or use any of it in a way that they haven't said you could.  Which decompiling would normally be one of those?  You can break the agreement.  I was just warning you that it could be breaking the GPL.  Sorry I didn't put enought Emphasis on the Probably.  

Fixitben
OK.  Thanks. Much appreciated.  I will see if they will send the FLA file.  They were very helpful before, except for any tech support.

Thanks again....learned a lot anyway re: cookies in Flash (might end up using another app for the same function).....and will repost if I can get the original FLA.

Steve