Author Topic: How to show operator status from any page  (Read 20874 times)

0 Members and 1 Guest are viewing this topic.

2DMonkey

  • Jr. Member
  • **
  • Posts: 2
How to show operator status from any page
« on: February 17, 2013, 07:47:59 AM »
Hi all,

I was struggling to find a way to display the operator status on my site without using the button generator code. The following snippet lets you display your status in any way you like; with your own custom buttons or just text. You can paste it anywhere and it will work. Just change the path to your live chat.

<php
   $button = "http://pathtoyourlivechat.com /b.php?i=simple";
   $status = "i=simple";
   copy($button, $status);
   if (filesize($status) < 4500) {
      echo "<p>Online</p>";
   } else {
      echo "<p>Offline</p>";
   }
?>


Best regards,

2DMonkey

moreeagles

  • Jr. Member
  • **
  • Posts: 3
Re: How to show operator status from any page
« Reply #1 on: April 20, 2013, 12:16:46 AM »
You have to make sure your HTaccess file allows you to run php scripts on the page you're listing it on, otherwise yes, you can run it on any page. Very Handy.

nickel

  • Jr. Member
  • **
  • Posts: 3
Re: How to show operator status from any page
« Reply #2 on: January 22, 2014, 02:23:50 PM »
The much better way:

Status.php
Code: [Select]
<?php

require_once('libs/common.php');
require_once(
'libs/chat.php');
require_once(
'libs/operator.php');
require_once(
'libs/groups.php');

$groupid verifyparam"group""/^\d{1,10}$/""");

$status has_online_operators($groupid) ? "on" "off";

echo 
$status;

?>

With this small script there is no need to check any button-size or something else... with "status.php?group=<id>" you're able to check, if there is someone on or off in the defined group.

Regards,

nickel

wooshman

  • Full Member
  • ***
  • Posts: 8
Re: How to show operator status from any page
« Reply #3 on: April 25, 2014, 08:41:38 PM »
The much better way:

Status.php
Code: [Select]
<?php

require_once('libs/common.php');
require_once(
'libs/chat.php');
require_once(
'libs/operator.php');
require_once(
'libs/groups.php');

$groupid verifyparam"group""/^\d{1,10}$/""");

$status has_online_operators($groupid) ? "on" "off";

echo 
$status;

?>

With this small script there is no need to check any button-size or something else... with "status.php?group=<id>" you're able to check, if there is someone on or off in the defined group.

Regards,

nickel

By putting this code on every page and not echoing the status, you are free to check the status = "on" and then do what you want with that info.

For one of my sites, I have in the Nav Bar - Live Chat Online or Offline, A "speak to online agent now" div (if status = on) or doesn't show if off.