";} else {echo " We just got through cleaning room " . $roomclean;}
}
}
function lobby()
{global $logout_script,$CL_login,$third_login,$Pro_login;
$link_id=db_connect();
$randevent=rand(0,100);
$randroom=rand(1,23);cleanuproom($randroom);
if($_SESSION['listing_only']==1)
{echo "Sorry, you are registered as a listing-only member,therefore, you do not have access to the secure chat feature.
";
} else {
db_connect();
echo "You are at the reception desk. You cannot chat at the reception desk. If you are early for your appointment, you can go into a room that is not being used. If you want to log out click here. ";
if(!empty($_SESSION['userCLid'])){echo "If you are a client, look for the room with your health care provider's name. You can only chat to health care providers, not to clients, because of confidentiality concerns. The health care provider will enter the room when she or he arrives. ";}
echo "If you want to close this window, click ";
$QRec="SELECT room, occup_id, therapist FROM chat_room ORDER BY room";
$RRec=mysql_query($QRec);
$roomnow=0; $no_occ=0;
while($Recarray=mysql_fetch_array($RRec))
{
$room=$Recarray['room'];
if($room != $roomnow)
{
if($no_occ >= 2) {echo " is in use";}
else if(($no_occ==1) && ($therapist==1)) {echo " " . $occup . " is waiting";}
else if(($no_occ==1 && !$therapist) && (empty($_SESSION['userProid']))){echo " a client is waiting";}
else if($no_occ==1 && !$therapist) {echo " " . $occup . " is waiting";}
else {}
$no_occ=0;
echo "
Room $room";
$no_occ++;
$therapist=$Recarray['therapist'];
} else {
$no_occ++;
}
$roomnow = $room;
$occup=$Recarray['occup_id'];
}
if($no_occ >= 2) {echo " is in use";}
else if($no_occ==1 && $therapist) {echo " " . $occup . " is waiting";}
else if(($no_occ==1 && !$therapist) && (empty($_SESSION['userProid']))){echo " a client is waiting";}
else if($no_occ==1 && !$therapist) {echo " " . $occup . " is waiting";}
else {}
}//end of else listing_only
}
function retrieve_id($room_no)
{
$link_id = db_connect();
if(!$link_id) die(sql_error());
$chat_sql="SELECT occup_id, therapist FROM chat_room WHERE room=$room_no";
$occup_result=mysql_query($chat_sql);
if(!empty($_SESSION['userProid']))
{
$display_id=$_SESSION['userProid'];
}/// end of if
else if(!empty($_SESSION['user3id1']))
{
$display_id=$_SESSION['user3id1'];
}///end of else if
else if(!empty($_SESSION['userCLid']))
{
$display_id=$_SESSION['userCLid'];
}///end of else if
else {}
while($occup_array=mysql_fetch_array($occup_result))
{$occupt=$occup_array['occup_id']; $istherapist=$occup_array['therapist'];
if($occupt != $display_id && $istherapist)
{
$return_id=$occupt;
}
else if(($occupt != $display_id && !$istherapist) && empty($_SESSION['userProid']))
{
$return_id="a client (cannot chat)";
}
else if(($occupt != $display_id && !$istherapist) && !empty($_SESSION['userProid']))
{
$return_id=$occupt;
} else {
}
}
return $return_id;
}
function get_suser_id()
{
if (!empty($_SESSION['userProid']))
{
$display_id=$_SESSION['userProid'];
}/// end of if
else if(!empty($_SESSION['user3id1']))
{
$display_id=$_SESSION['user3id1'];
}///end of else if
else if(!empty($_SESSION['userCLid']))
{
$display_id=$_SESSION['userCLid'];
}///end of else if
else {}
return $display_id;
}
function get_iv()
{
$size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_CBC);
srand((float) microtime() * 1000000);
$result_iv = mcrypt_create_iv($size, MCRYPT_RAND);
return $result_iv;
}///////end function get_iv
function chat_form($room_no, $me)
{
add_msg_form($room_no, $me);
leave_room_form();
}
function add_msg_form($room_no, $me)
{
echo "