has("user", ["AND" => ["id" => $_POST['opid'], "available" => 1]]); if (!$oponline) $print_offline = '
  • '.$jkl["g139"].'

  • '; $chatmsg = ''; echo $chatmsg; } break; case 'send-msg': if (empty($_POST['message'])) { echo $jkl['e1']; } else { $message = trim($_POST['message']); $message = filter_var($message, FILTER_SANITIZE_FULL_SPECIAL_CHARS); $jakdb->insert("operatorchat", ["opid" => $opcacheid, "fromid" => $_POST['uid'], "toid" => $_POST['opid'], "message" => $message, "sent" => time()]); $lastid = $jakdb->id(); if ($lastid) { // Now let us add the active chat file so the operator can come online. $chatsfile = APP_PATH.JAK_CACHE_DIRECTORY.'/chats'.$opcacheid.'.txt'; if (file_exists($chatsfile)) { unlink($chatsfile); } // Write the from to operator id $opid = time().":#:".$_POST['uid'].":#:".$_POST['opid'].":#:".$_POST['uname']."\n"; // Create, write or append to the file. file_put_contents($chatsfile, $opid, FILE_APPEND); echo 'success'; } else { echo $jkl['e1']; } } break; default: return false; }