Contributions > Plugins, tips, and tricks

How to show operator status from any page

(1/1)

2DMonkey:
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:
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:
The much better way:

Status.php

--- Code: ---<?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;

?>
--- End code ---

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:

--- Quote from: nickel on January 22, 2014, 02:23:50 PM ---The much better way:

Status.php

--- Code: ---<?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;

?>
--- End code ---

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

--- End quote ---

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.

Navigation

[0] Message Index

Go to full version