Initial Commit
This commit is contained in:
+276
@@ -0,0 +1,276 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 2.0 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2021 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = $chatid = $contactid = $invid = $invmsg = "";
|
||||
$takechat = $denychat = $taketransfer = $ostatus = $denytransfer = $deletechat = $deletecontact = false;
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
if (isset($_REQUEST['chatid']) && !empty($_REQUEST['chatid'])) $chatid = $_REQUEST['chatid'];
|
||||
if (isset($_REQUEST['contactid']) && !empty($_REQUEST['contactid'])) $contactid = $_REQUEST['contactid'];
|
||||
if (isset($_REQUEST['takechat']) && !empty($_REQUEST['takechat'])) $takechat = $_REQUEST['takechat'];
|
||||
if (isset($_REQUEST['denychat']) && !empty($_REQUEST['denychat'])) $denychat = $_REQUEST['denychat'];
|
||||
if (isset($_REQUEST['taketransfer']) && !empty($_REQUEST['taketransfer'])) $taketransfer = $_REQUEST['taketransfer'];
|
||||
if (isset($_REQUEST['denytransfer']) && !empty($_REQUEST['denytransfer'])) $denytransfer = $_REQUEST['denytransfer'];
|
||||
if (isset($_REQUEST['deletechat']) && !empty($_REQUEST['deletechat'])) $deletechat = $_REQUEST['deletechat'];
|
||||
if (isset($_REQUEST['deletecontact']) && !empty($_REQUEST['deletecontact'])) $deletecontact = $_REQUEST['deletecontact'];
|
||||
if (isset($_REQUEST['invid']) && !empty($_REQUEST['invid'])) $invid = $_REQUEST['invid'];
|
||||
if (isset($_REQUEST['invmsg']) && !empty($_REQUEST['invmsg'])) $invmsg = $_REQUEST['invmsg'];
|
||||
if (isset($_REQUEST['ostatus']) && !empty($_REQUEST['ostatus'])) $ostatus = $_REQUEST['ostatus'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
// Select the user fields
|
||||
$jakuser = new JAK_user($usr);
|
||||
// Only the SuperAdmin in the config file see everything
|
||||
if ($jakuser->jakSuperadminaccess($userid)) {
|
||||
define('JAK_SUPERADMINACCESS', true);
|
||||
} else {
|
||||
define('JAK_SUPERADMINACCESS', false);
|
||||
}
|
||||
|
||||
// Cache stuff
|
||||
if (file_exists(APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$jakuser->getVar("id").'.php')) include_once APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$jakuser->getVar("id").'.php';
|
||||
|
||||
// timezone from server
|
||||
date_default_timezone_set(JAK_TIMEZONESERVER);
|
||||
$jakdb->query('SET time_zone = "'.date("P").'"');
|
||||
|
||||
$USER_LANGUAGE = strtolower($jakuser->getVar("language"));
|
||||
|
||||
// Import the language file
|
||||
if ($USER_LANGUAGE && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$USER_LANGUAGE.'.php')) {
|
||||
include_once APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$USER_LANGUAGE.'.php';
|
||||
$lang = $USER_LANGUAGE;
|
||||
} else {
|
||||
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
|
||||
$lang = JAK_LANG;
|
||||
}
|
||||
|
||||
// Change status on live chat
|
||||
if ($ostatus && !empty($ostatus) && is_numeric($ostatus)) {
|
||||
|
||||
if ($ostatus == 1) {
|
||||
|
||||
// operator makes himself available
|
||||
$jakdb->update("user", ["available" => 1], ["id" => $userid]);
|
||||
|
||||
die(json_encode(array('status' => true, 'task' => "ostatus", "statusid" => 1)));
|
||||
|
||||
} elseif ($ostatus == 2) {
|
||||
|
||||
// Operator goes busy
|
||||
$jakdb->update("user", ["available" => 2], ["id" => $userid]);
|
||||
|
||||
die(json_encode(array('status' => true, 'task' => "ostatus", "statusid" => 2)));
|
||||
|
||||
} else {
|
||||
|
||||
// operator goes offline
|
||||
$jakdb->update("user", ["available" => 0], ["id" => $userid]);
|
||||
|
||||
die(json_encode(array('status' => true, 'task' => "ostatus", "statusid" => 3)));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Take the chat and go to the chat window
|
||||
if ($takechat && !empty($chatid) && is_numeric($chatid)) {
|
||||
|
||||
// Check if we have an operator
|
||||
$sessup = $jakdb->update("sessions", ["operatorid" => $userid, "operatorname" => $jakuser->getVar("name")], ["AND" => ["operatorid" => [0, $userid], "id" => $chatid]]);
|
||||
if ($sessup) {
|
||||
|
||||
$jakdb->update("checkstatus", ["newc" => 1, "operatorid" => $userid, "operator" => $jakuser->getVar("name"), "pusho" => 1, "statuso" => time()], ["convid" => $chatid]);
|
||||
|
||||
if (!empty($HD_ANSWERS) && is_array($HD_ANSWERS)) foreach ($HD_ANSWERS as $v) {
|
||||
|
||||
if ($v["msgtype"] == 2 && $v["lang"] == $lang) {
|
||||
|
||||
$clientname = $jakdb->get("sessions", "name", ["id" => $chatid]);
|
||||
|
||||
$phold = array("%operator%","%client%","%email%");
|
||||
$replace = array($jakuser->getVar("name"), $clientname, JAK_EMAIL);
|
||||
$message = str_replace($phold, $replace, $v["message"]);
|
||||
|
||||
$jakdb->insert("transcript", [
|
||||
"name" => $jakuser->getVar("name"),
|
||||
"message" => $message,
|
||||
"user" => $userid.'::'.$jakuser->getVar("username"),
|
||||
"operatorid" => $userid,
|
||||
"convid" => $chatid,
|
||||
"class" => "admin",
|
||||
"time" => $jakdb->raw("NOW()")]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Take the chat go to chat
|
||||
die(json_encode(array('status' => true, 'task' => "takechat")));
|
||||
|
||||
} else {
|
||||
|
||||
// someone else was quicker
|
||||
die(json_encode(array('status' => false, 'task' => "takechat", 'errorcode' => 10)));
|
||||
}
|
||||
}
|
||||
|
||||
// allow uploading files for the client
|
||||
if ($denychat && !empty($chatid) && is_numeric($chatid)) {
|
||||
|
||||
if ($jakdb->update("sessions", ["deniedoid" => $userid, "status" => 0, "ended" => time()], ["id" => $chatid])) {
|
||||
$jakdb->update("checkstatus", ["denied" => 1, "hide" => 1], ["convid" => $chatid]);
|
||||
|
||||
// Deny chat stay in queue
|
||||
die(json_encode(array('status' => true, 'task' => "denychat")));
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'task' => "denychat", 'errorcode' => 7)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Accept the transfer
|
||||
if ($taketransfer && !empty($chatid) && is_numeric($chatid)) {
|
||||
|
||||
$trow = $jakdb->get("checkstatus", ["convid", "transferid"], ["convid" => $chatid]);
|
||||
|
||||
if ($trow) {
|
||||
|
||||
$jakdb->insert("transcript", [
|
||||
"name" => $jakuser->getVar("name"),
|
||||
"message" => $jakuser->getVar("name").' '.$jkl["g121"],
|
||||
"user" => $userid.'::'.$jakuser->getVar("username"),
|
||||
"operatorid" => $userid,
|
||||
"convid" => $trow["convid"],
|
||||
"class" => "admin",
|
||||
"time" => $jakdb->raw("NOW()")]);
|
||||
|
||||
$jakdb->update("sessions", ["operatorid" => $userid, "operatorname" => $jakuser->getVar("name")], ["id" => $trow['convid']]);
|
||||
|
||||
$jakdb->update("checkstatus", ["operatorid" => $userid, "operator" => $jakuser->getVar("name"), "transferid" => 0, "transferoid" => 0], ["convid" => $trow['convid']]);
|
||||
$jakdb->update("transfer", ["used" => 1], ["id" => $trow["transferid"]]);
|
||||
|
||||
// accept transfer go to chat
|
||||
die(json_encode(array('status' => true, 'task' => "taketransfer")));
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'task' => "taketransfer", 'errorcode' => 7)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Send a knock knock
|
||||
if ($denytransfer && !empty($chatid) && is_numeric($chatid)) {
|
||||
|
||||
$trow = $jakdb->get("checkstatus", ["convid", "transferid"], ["convid" => $chatid]);
|
||||
|
||||
if ($trow) {
|
||||
|
||||
$jakdb->update("checkstatus", ["transferid" => 0, "transferoid" => 0], ["convid" => $trow['convid']]);
|
||||
$jakdb->update("transfer", ["used" => 2], ["id" => $trow["transferid"]]);
|
||||
|
||||
// Deny transfer stay in queue
|
||||
die(json_encode(array('status' => true, 'task' => "denytransfer")));
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'task' => "denytransfer", 'errorcode' => 7)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Invite website vistors from mobile phone
|
||||
if ($invid && !empty($invid) && is_numeric($invid)) {
|
||||
|
||||
if ($invmsg && !empty($invmsg)) {
|
||||
|
||||
$result = $jakdb->update("buttonstats", ["opid" => $userid, "message" => $invmsg, "readtime" => 0], ["id" => $invid]);
|
||||
|
||||
// Now let us delete and recreate the proactive cache file
|
||||
$proactivefile = APP_PATH.JAK_CACHE_DIRECTORY.'/mproactive.php';
|
||||
|
||||
// Delete the current proactive file
|
||||
if (file_exists($proactivefile)) unlink($proactivefile);
|
||||
|
||||
// Get the departments
|
||||
$manualproactive = $jakdb->select("buttonstats", ["id", "session", "message"], ["readtime" => 0, "ORDER" => ["lasttime" => "DESC"]]);
|
||||
|
||||
$pafile = "<?php\n";
|
||||
|
||||
$pafile .= "\$mproactiveserialize = '".base64_encode(gzcompress(serialize($manualproactive)))."';\n\n\$LV_MPROACTIVE = unserialize(gzuncompress(base64_decode(\$mproactiveserialize)));\n\n";
|
||||
|
||||
$pafile .= "?>";
|
||||
|
||||
if (JAK_base::jakWriteinCache($proactivefile, $pafile, '')) {
|
||||
die(json_encode(array('status' => true, 'task' => "invite")));
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'task' => "invite")));
|
||||
}
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'task' => "invite", 'errorcode' => 8)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Delete conversation
|
||||
if ($deletechat && !empty($chatid) && is_numeric($chatid)) {
|
||||
|
||||
if (JAK_SUPERADMINACCESS) {
|
||||
|
||||
$sessionid = $jakdb->get("sessions", "id", ["id" => $chatid]);
|
||||
$jakdb->delete("transcript", ["convid" => $sessionid]);
|
||||
$jakdb->delete("checkstatus", ["convid" => $sessionid]);
|
||||
$result = $jakdb->delete("sessions", ["id" => $chatid]);
|
||||
|
||||
// Deny transfer stay in queue
|
||||
die(json_encode(array('status' => true, 'task' => "deletechat")));
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'task' => "deletechat", 'errorcode' => 7)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Delete offline message
|
||||
if ($deletecontact && !empty($contactid) && is_numeric($contactid)) {
|
||||
|
||||
if (JAK_SUPERADMINACCESS) {
|
||||
|
||||
$jakdb->delete("contactsreply", ["contactid" => $contactid]);
|
||||
$result = $jakdb->delete("contacts", ["id" => $contactid]);
|
||||
|
||||
// Deny transfer stay in queue
|
||||
die(json_encode(array('status' => true, 'task' => "deletecontact")));
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'task' => "deletecontact", 'errorcode' => 8)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1, 'errorcode' => false)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7, 'errorcode' => false)));
|
||||
?>
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 1.2 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2021 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = $contactid = "";
|
||||
$errors = $rowi = array();
|
||||
$sendform = false;
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
if (isset($_REQUEST['contactid']) && !empty($_REQUEST['contactid'])) $contactid = $_REQUEST['contactid'];
|
||||
if (isset($_REQUEST['sendform']) && !empty($_REQUEST['sendform'])) $sendform = $_REQUEST['sendform'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
// Get the user fields
|
||||
$jakuser = new JAK_user($usr);
|
||||
|
||||
// Check if a sibling has logged in
|
||||
if ($jakuser->getVar("opid") != 0) {
|
||||
$opcacheid = $jakuser->getVar("opid");
|
||||
} else {
|
||||
$opcacheid = $jakuser->getVar("id");
|
||||
}
|
||||
|
||||
// Cache stuff
|
||||
if (file_exists(APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php')) include_once APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php';
|
||||
|
||||
// timezone from server
|
||||
date_default_timezone_set(JAK_TIMEZONESERVER);
|
||||
$jakdb->query('SET time_zone = "'.date("P").'"');
|
||||
|
||||
if (!empty($contactid)) $rowi = $jakdb->get("contacts", ["name", "email", "message", "latitude", "longitude"], ["id" => $contactid]);
|
||||
|
||||
if ($sendform && !empty($contactid)) {
|
||||
|
||||
if (empty($_REQUEST['subject'])) {
|
||||
$errors['subject'] = true;
|
||||
}
|
||||
|
||||
if (empty($_REQUEST['message'])) {
|
||||
$errors['message'] = true;
|
||||
}
|
||||
|
||||
if (count($errors) == 0) {
|
||||
|
||||
// Ok, we send the email // email address, cc email address, reply to, subject, message, attachment
|
||||
if (jak_send_email($rowi['email'], "", "", trim($_REQUEST['subject']), trim(nl2br($_REQUEST['message'])), "")) {
|
||||
|
||||
// Get the operator details
|
||||
$jakuser = new JAK_user($usr);
|
||||
|
||||
// Insert the stuff into the database
|
||||
$jakdb->insert("contactsreply", [
|
||||
"contactid" => $contactid,
|
||||
"operatorid" => $jakuser->getVar("id"),
|
||||
"operatorname" => $jakuser->getVar("username"),
|
||||
"subject" => trim($_REQUEST['subject']),
|
||||
"message" => trim($_REQUEST['message']),
|
||||
"sent" => $jakdb->raw("NOW()")]);
|
||||
|
||||
$jakdb->update("contacts", ["reply" => 1, "answered" => $jakdb->raw("NOW()")], ["id" => $contactid]);
|
||||
|
||||
// Write the log file
|
||||
JAK_base::jakWhatslog('', $opcacheid, $userid, 0, 32, $lastid, (isset($_COOKIE['WIOgeoData']) ? $_COOKIE['WIOgeoData'] : ''), $jakuser->getVar("username"), $_SERVER['REQUEST_URI'], $ipa, $valid_agent);
|
||||
|
||||
// Form has been sent, let's send the success status
|
||||
die(json_encode(array('status' => true)));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errors' => $errors)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Display the message content and location from the client
|
||||
die(json_encode(array('status' => true, 'data' => $rowi)));
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1, 'errorcode' => false)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7, 'errorcode' => false)));
|
||||
?>
|
||||
@@ -0,0 +1,319 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 2.1 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2022 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = $ticketid = $operatorid = $depid = $message = $status = $tstatus = $priority = $option = $notes = $private = $toldstatus = $oldopid = $olddepid = $oldpriority = $oldoption = $oldprivate = "";
|
||||
$errors = array();
|
||||
$sendform = $answersaved = false;
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
if (isset($_REQUEST['ticketid']) && !empty($_REQUEST['ticketid'])) $ticketid = $_REQUEST['ticketid'];
|
||||
if (isset($_REQUEST['operatorid']) && !empty($_REQUEST['operatorid'])) $operatorid = $_REQUEST['operatorid'];
|
||||
if (isset($_REQUEST['depid']) && !empty($_REQUEST['depid'])) $depid = $_REQUEST['depid'];
|
||||
if (isset($_REQUEST['message']) && !empty($_REQUEST['message'])) $message = $_REQUEST['message'];
|
||||
if (isset($_REQUEST['status']) && !empty($_REQUEST['status'])) $status = $_REQUEST['status'];
|
||||
if (isset($_REQUEST['tstatus']) && !empty($_REQUEST['tstatus'])) $tstatus = $_REQUEST['tstatus'];
|
||||
if (isset($_REQUEST['priority']) && !empty($_REQUEST['priority'])) $priority = $_REQUEST['priority'];
|
||||
if (isset($_REQUEST['option']) && !empty($_REQUEST['option'])) $option = $_REQUEST['option'];
|
||||
if (isset($_REQUEST['notes']) && !empty($_REQUEST['notes'])) $notes = $_REQUEST['notes'];
|
||||
if (isset($_REQUEST['private']) && !empty($_REQUEST['private'])) $private = $_REQUEST['private'];
|
||||
if (isset($_REQUEST['toldstatus']) && !empty($_REQUEST['toldstatus'])) $toldstatus = $_REQUEST['toldstatus'];
|
||||
if (isset($_REQUEST['oldopid']) && !empty($_REQUEST['oldopid'])) $oldopid = $_REQUEST['oldopid'];
|
||||
if (isset($_REQUEST['olddepid']) && !empty($_REQUEST['olddepid'])) $olddepid = $_REQUEST['olddepid'];
|
||||
if (isset($_REQUEST['oldpriority']) && !empty($_REQUEST['oldpriority'])) $oldpriority = $_REQUEST['oldpriority'];
|
||||
if (isset($_REQUEST['oldoption']) && !empty($_REQUEST['oldoption'])) $oldoption = $_REQUEST['oldoption'];
|
||||
if (isset($_REQUEST['oldprivate']) && !empty($_REQUEST['oldprivate'])) $oldprivate = $_REQUEST['oldprivate'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
// User is logged in
|
||||
if ($usr) {
|
||||
|
||||
// Select the user fields
|
||||
$jakuser = new JAK_user($usr);
|
||||
|
||||
// Check if a sibling has logged in
|
||||
if ($jakuser->getVar("opid") != 0) {
|
||||
$opcacheid = $jakuser->getVar("opid");
|
||||
} else {
|
||||
$opcacheid = $jakuser->getVar("id");
|
||||
}
|
||||
|
||||
// Cache stuff
|
||||
if (file_exists(APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php')) include_once APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php';
|
||||
|
||||
// timezone from server
|
||||
date_default_timezone_set(JAK_TIMEZONESERVER);
|
||||
$jakdb->query('SET time_zone = "'.date("P").'"');
|
||||
|
||||
// Check if a sibling has logged in
|
||||
if ($jakuser->getVar("opid") != 0) $opcacheid = $jakuser->getVar("opid");
|
||||
|
||||
// Operator language
|
||||
$USER_LANGUAGE = strtolower($jakuser->getVar("language"));
|
||||
|
||||
// Import the language file
|
||||
if ($USER_LANGUAGE && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$USER_LANGUAGE.'.php')) {
|
||||
include_once APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$USER_LANGUAGE.'.php';
|
||||
$lang = $USER_LANGUAGE;
|
||||
} else {
|
||||
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
|
||||
$lang = JAK_LANG;
|
||||
}
|
||||
|
||||
if (!empty($ticketid) && is_numeric($ticketid)) {
|
||||
|
||||
// Update the ticket
|
||||
$jakdb->update("support_tickets", ["depid" => $depid, "operatorid" => $operatorid, "priorityid" => $priority, "toptionid" => $option, "private" => $private], ["AND" => ["id" => $ticketid, "opid" => $opcacheid]]);
|
||||
|
||||
// Now check if we have an answer
|
||||
if (!empty($message)) {
|
||||
|
||||
// Filter the content
|
||||
$contentf = jak_clean_safe_userpost($message);
|
||||
|
||||
$result = $jakdb->insert("ticket_answers", ["ticketid" => $ticketid,
|
||||
"operatorid" => $userid,
|
||||
"content" => $contentf,
|
||||
"lastedit" => $jakdb->raw("NOW()"),
|
||||
"sent" => $jakdb->raw("NOW()")]);
|
||||
|
||||
// Get the ID from the ticket
|
||||
$lastid = $jakdb->id();
|
||||
|
||||
// Write the log file
|
||||
JAK_base::jakWhatslog('', $opcacheid, $userid, 0, 32, $lastid, (isset($_COOKIE['WIOgeoData']) ? $_COOKIE['WIOgeoData'] : ''), $jakuser->getVar("username"), $_SERVER['REQUEST_URI'], $ipa, "RestApi");
|
||||
|
||||
// Update the ticket
|
||||
$jakdb->update("support_tickets", ["status" => 2, "updated" => time()], ["AND" => ["id" => $ticketid, "opid" => $opcacheid]]);
|
||||
|
||||
// Finally we inform the customer about the answer
|
||||
$JAK_FORM_DATA = $jakdb->get("support_tickets", ["[>]support_departments" => ["depid" => "id"], "[>]clients" => ["clientid" => "id"]], ["support_tickets.id", "support_tickets.depid", "support_tickets.operatorid", "support_tickets.subject", "support_tickets.content", "support_tickets.clientid", "support_tickets.ip", "support_tickets.referrer", "support_tickets.notes", "support_tickets.private", "support_tickets.status", "support_tickets.attachments", "support_tickets.initiated", "support_tickets.ended", "support_tickets.updated", "support_tickets.priorityid", "support_tickets.toptionid", "support_departments.title", "clients.name", "clients.email", "clients.support_dep", "clients.credits", "clients.paid_until"], ["AND" => ["support_tickets.id" => $ticketid, "support_tickets.opid" => $opcacheid]]);
|
||||
|
||||
// Calculate the update time
|
||||
$responsetime = time() - $JAK_FORM_DATA["updated"];
|
||||
|
||||
// Let's check if that is is the first answer and it is not a private note
|
||||
$firstcontact = 0;
|
||||
if ($JAK_FORM_DATA["initiated"] == $JAK_FORM_DATA["updated"]) $firstcontact = 1;
|
||||
|
||||
// Insert response time
|
||||
insertResponsetime($userid, $opcacheid, $ticketid, $responsetime, $firstcontact);
|
||||
|
||||
// Rest Api URL
|
||||
$ticketurl = str_replace('rest/', '', JAK_rewrite::jakParseurl(JAK_SUPPORT_URL, 't', $ticketid, JAK_rewrite::jakCleanurl($JAK_FORM_DATA["subject"])));
|
||||
|
||||
// Let's check if we have an imap
|
||||
$answeremail = $ticktext = '';
|
||||
$check_imap = $jakdb->get("php_imap", "emailanswer", ["depid" => $JAK_FORM_DATA["depid"]]);
|
||||
if ($check_imap) {
|
||||
$answeremail = $check_imap;
|
||||
$subjectl = JAK_TITLE.' - [#'.$ticketid.'] - RE:'.$JAK_FORM_DATA['subject'];
|
||||
} else {
|
||||
$subjectl = JAK_TITLE.' - RE:'.$JAK_FORM_DATA['subject'];
|
||||
}
|
||||
|
||||
// Get the ticket answer template
|
||||
if (!empty($HD_ANSWERS) && is_array($HD_ANSWERS)) foreach ($HD_ANSWERS as $v) {
|
||||
|
||||
if ($v["msgtype"] == 21 && $v["lang"] == JAK_LANG) {
|
||||
|
||||
$phold = array('{url}', '{title}', '{cemail}', '{cname}', '{credits}', '{paid_until}', '{ticket}', '{subject}', '{ticketurl}', '{email}', '{ticketcontent}');
|
||||
$replace = array(BASE_URL, JAK_TITLE, $JAK_FORM_DATA['email'], $JAK_FORM_DATA['name'], $JAK_FORM_DATA['credits'], $JAK_FORM_DATA['paid_until'], '#'.$ticketid, $JAK_FORM_DATA['subject'], $ticketurl, $answeremail, replace_urls_emails($contentf, BASE_URL, JAK_FILES_DIRECTORY));
|
||||
$ticktext = str_replace($phold, $replace, $v["message"]);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!empty($ticktext)) {
|
||||
|
||||
$ticktext = '<p style="color:#c1c1c1;">-------------## Do Not Remove ##-------------</p>'.$ticktext;
|
||||
|
||||
// Get the email template
|
||||
$nlhtml = file_get_contents(APP_PATH.'template/'.JAK_FRONT_TEMPLATE.'/email/index.html');
|
||||
|
||||
// Change fake vars into real ones.
|
||||
$cssAtt = array('{emailcontent}', '{weburl}', '{title}', '{emailtpllogo}', '{emailtplcopy}');
|
||||
$cssUrl = array($ticktext, BASE_URL, JAK_TITLE, JAK_EMAILTPLLOGO, JAK_EMAILTPLCOPY);
|
||||
$nlcontent = str_replace($cssAtt, $cssUrl, $nlhtml);
|
||||
|
||||
$body = str_ireplace("[\]", "", $nlcontent);
|
||||
|
||||
// Ok, we send the email // email address, cc email address, reply to, subject, message, attachment
|
||||
jak_send_email($JAK_FORM_DATA['email'], "", $answeremail, $subjectl, $body, "");
|
||||
|
||||
}
|
||||
|
||||
$answersaved = true;
|
||||
$sendform = true;
|
||||
|
||||
}
|
||||
|
||||
// Check if we have a change in the notes
|
||||
if (!empty($notes)) {
|
||||
|
||||
$savenotes = filter_var($notes, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
// Update the ticket
|
||||
$jakdb->update("support_tickets", ["notes" => $savenotes], ["id" => $ticketid]);
|
||||
|
||||
$sendform = true;
|
||||
|
||||
}
|
||||
|
||||
if (JAK_BILLING_MODE == 1 && $JAK_FORM_DATA["clientid"] != 0) {
|
||||
|
||||
// Check if we have a change in the departmant
|
||||
if ($depid != $olddepid) {
|
||||
if (isset($HD_SUPPORT_DEPARTMENTS) && is_array($HD_SUPPORT_DEPARTMENTS)) foreach ($HD_SUPPORT_DEPARTMENTS as $v) {
|
||||
if ($v["id"] == $olddepid) {
|
||||
$oldcredits = $v["credits"];
|
||||
}
|
||||
}
|
||||
if (isset($HD_SUPPORT_DEPARTMENTS) && is_array($HD_SUPPORT_DEPARTMENTS)) foreach ($HD_SUPPORT_DEPARTMENTS as $v) {
|
||||
if ($v["id"] == $depid) {
|
||||
$newcredits = $v["credits"];
|
||||
}
|
||||
}
|
||||
|
||||
if ($newcredits > $oldcredits) {
|
||||
$newc = $newcredits - $oldcredits;
|
||||
$jakdb->update("clients", ["credits[-]" => $newc], ["id" => $JAK_FORM_DATA["clientid"]]);
|
||||
// Credit system control
|
||||
$jakdb->insert("taken_credits", ["clientid" => $JAK_FORM_DATA["clientid"], "operatorid" => $userid, "credits" => $newc, "created" => $jakdb->raw("NOW()")]);
|
||||
} elseif ($newcredits < $oldcredits) {
|
||||
$newc = $oldcredits - $newcredits;
|
||||
$jakdb->update("clients", ["credits[+]" => $newc], ["id" => $JAK_FORM_DATA["clientid"]]);
|
||||
// Credit system control
|
||||
$jakdb->insert("taken_credits", ["clientid" => $JAK_FORM_DATA["clientid"], "operatorid" => $userid, "credits" => $newc, "taken" => 0, "created" => $jakdb->raw("NOW()")]);
|
||||
}
|
||||
|
||||
$sendform = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if we have a change in the priority
|
||||
if ($priority != $oldpriority) {
|
||||
$oldcredits = $jakdb->get("ticketpriority", "credits", ["id" => $oldpriority]);
|
||||
$newcredits = $jakdb->get("ticketpriority", "credits", ["id" => $priority]);
|
||||
|
||||
if ($newcredits > $oldcredits) {
|
||||
$newc = $newcredits - $oldcredits;
|
||||
$jakdb->update("clients", ["credits[-]" => $newc], ["id" => $JAK_FORM_DATA["clientid"]]);
|
||||
// Credit system control
|
||||
$jakdb->insert("taken_credits", ["clientid" => $JAK_FORM_DATA["clientid"], "operatorid" => $userid, "credits" => $newc, "created" => $jakdb->raw("NOW()")]);
|
||||
} elseif ($newcredits < $oldcredits) {
|
||||
$newc = $oldcredits - $newcredits;
|
||||
$jakdb->update("clients", ["credits[+]" => $newc], ["id" => $JAK_FORM_DATA["clientid"]]);
|
||||
// Credit system control
|
||||
$jakdb->insert("taken_credits", ["clientid" => $JAK_FORM_DATA["clientid"], "operatorid" => $userid, "credits" => $newc, "taken" => 0, "created" => $jakdb->raw("NOW()")]);
|
||||
}
|
||||
|
||||
$sendform = true;
|
||||
}
|
||||
|
||||
// Check if we have a change in the option
|
||||
if ($option != $oldoption) {
|
||||
$oldcredits = $jakdb->get("ticketoptions", "credits", ["id" => $oldoption]);
|
||||
$newcredits = $jakdb->get("ticketoptions", "credits", ["id" => $option]);
|
||||
|
||||
if ($newcredits > $oldcredits) {
|
||||
$newc = $newcredits - $oldcredits;
|
||||
$jakdb->update("clients", ["credits[-]" => $newc], ["id" => $JAK_FORM_DATA["clientid"]]);
|
||||
// Credit system control
|
||||
$jakdb->insert("taken_credits", ["clientid" => $JAK_FORM_DATA["clientid"], "operatorid" => $userid, "credits" => $newc, "created" => $jakdb->raw("NOW()")]);
|
||||
} elseif ($newcredits < $oldcredits) {
|
||||
$newc = $oldcredits - $newcredits;
|
||||
$jakdb->update("clients", ["credits[+]" => $newc], ["id" => $JAK_FORM_DATA["clientid"]]);
|
||||
// Credit system control
|
||||
$jakdb->insert("taken_credits", ["clientid" => $JAK_FORM_DATA["clientid"], "operatorid" => $userid, "credits" => $newc, "taken" => 0, "created" => $jakdb->raw("NOW()")]);
|
||||
}
|
||||
|
||||
$sendform = true;
|
||||
}
|
||||
|
||||
// ticket status update
|
||||
if ($tstatus != $toldstatus) {
|
||||
|
||||
// Has it ended forever
|
||||
$tended = 0;
|
||||
if ($tstatus == 3 || $tstatus == 4) $tended = time();
|
||||
|
||||
// Now let's update the status
|
||||
$jakdb->update("support_tickets", ["status" => $tstatus, "ended" => $tended], ["AND" => ["id" => $ticketid, "opid" => $opcacheid]]);
|
||||
|
||||
$sendform = true;
|
||||
|
||||
}
|
||||
|
||||
// And we complete the custom fields
|
||||
$formfields = $jakdb->select('customfields', "val_slug", ["AND" => ["opid" => $opcacheid, "fieldlocation" => 2]]);
|
||||
if (isset($formfields) && !empty($formfields)) {
|
||||
foreach ($formfields as $v) {
|
||||
if (isset($_REQUEST[$v]) && is_array($_REQUEST[$v]) && !empty($_REQUEST[$v])) {
|
||||
$joinval = join(',', $_REQUEST[$v]);
|
||||
$jakdb->update("support_tickets", [$v => filter_var($joinval, FILTER_SANITIZE_FULL_SPECIAL_CHARS)], ["id" => $ticketid]);
|
||||
} elseif (isset($_REQUEST[$v]) && !empty($_REQUEST[$v])) {
|
||||
$jakdb->update("support_tickets", [$v => filter_var($_REQUEST[$v], FILTER_SANITIZE_FULL_SPECIAL_CHARS)], ["id" => $ticketid]);
|
||||
} elseif (isset($v)) {
|
||||
$jakdb->update("support_tickets", [$v => ""], ["id" => $ticketid]);
|
||||
}
|
||||
}
|
||||
|
||||
// Send form status
|
||||
$sendform = true;
|
||||
}
|
||||
|
||||
// We have a change in the operator, let's inform the new operator.
|
||||
if ($operatorid != $oldopid && $operatorid != $userid) {
|
||||
|
||||
// The new operator
|
||||
$new_operator_ticket = $jakdb->get("user", ["username", "email"], ["id" => $operatorid]);
|
||||
|
||||
// The URL
|
||||
$opurlt = sprintf($jkl['g330'], JAK_rewrite::jakParseurl('support', 'read', $ticketid));
|
||||
|
||||
// Ok, we send the email // email address, cc email address, reply to, subject, message, attachment
|
||||
jak_send_email($new_operator_ticket['email'], "", "", JAK_TITLE.' - '.$jkl['hd177'].' / '.$JAK_FORM_DATA['subject'], $opurlt, "");
|
||||
|
||||
// Send form status
|
||||
$sendform = true;
|
||||
}
|
||||
|
||||
// Ok we do have everything, let's role...
|
||||
if ($answersaved || $sendform) {
|
||||
|
||||
// Form has been sent, let's send the success status
|
||||
die(json_encode(array('status' => true, 'answered' => $answersaved, 'sendform' => $sendform)));
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errors' => $errors)));
|
||||
}
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7, 'errorcode' => false)));
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 9, 'errorcode' => false)));
|
||||
}
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7, 'errorcode' => false)));
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1, 'errorcode' => false)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7, 'errorcode' => false)));
|
||||
?>
|
||||
+102
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = "";
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
if (empty($_FILES['useravatar']['name'])) die(json_encode(array('status' => false, 'errorcode' => 2)));
|
||||
|
||||
if (!empty($_FILES['useravatar']['name'])) {
|
||||
|
||||
$filename = $_FILES['useravatar']['name']; // original filename
|
||||
$tmpf = explode(".", $filename);
|
||||
$jak_xtension = end($tmpf);
|
||||
|
||||
if ($jak_xtension == "jpg" || $jak_xtension == "jpeg" || $jak_xtension == "png" || $jak_xtension == "gif") {
|
||||
|
||||
if ($_FILES['useravatar']['size'] <= 2000000) {
|
||||
|
||||
list($width, $height, $type, $attr) = getimagesize($_FILES['useravatar']['tmp_name']);
|
||||
$mime = image_type_to_mime_type($type);
|
||||
|
||||
if (($mime == "image/jpeg") || ($mime == "image/pjpeg") || ($mime == "image/png") || ($mime == "image/gif")) {
|
||||
|
||||
// first get the target path
|
||||
$targetPathd = APP_PATH.JAK_FILES_DIRECTORY.'/'.$userid.'/';
|
||||
$targetPath = str_replace("//","/",$targetPathd);
|
||||
// Create the target path
|
||||
if (!is_dir($targetPath)) {
|
||||
mkdir($targetPath, 0755);
|
||||
copy(APP_PATH.JAK_FILES_DIRECTORY."/index.html", $targetPath . "/index.html");
|
||||
|
||||
}
|
||||
|
||||
// if old avatars exist delete it
|
||||
foreach(glob($targetPath.'*.*') as $jak_unlink){
|
||||
unlink($jak_unlink);
|
||||
copy(APP_PATH.JAK_FILES_DIRECTORY."/index.html", $targetPath . "/index.html");
|
||||
}
|
||||
|
||||
$tempFile = $_FILES['useravatar']['tmp_name'];
|
||||
$origName = substr($_FILES['useravatar']['name'], 0, -4);
|
||||
$name_space = strtolower($_FILES['useravatar']['name']);
|
||||
$middle_name = str_replace(" ", "_", $name_space);
|
||||
$middle_name = str_replace(".jpeg", ".jpg", $name_space);
|
||||
$glnrrand = rand(10, 99);
|
||||
$bigPhoto = str_replace(".", "_" . $glnrrand . ".", $middle_name);
|
||||
$smallPhoto = str_replace(".", "_t.", $bigPhoto);
|
||||
|
||||
$targetFile = str_replace('//','/',$targetPath) . $bigPhoto;
|
||||
$origPath = '/'.$userid.'/';
|
||||
$dbSmall = $origPath.$smallPhoto;
|
||||
$newavatar = JAK_FILES_DIRECTORY.$origPath.$smallPhoto;
|
||||
|
||||
require_once APP_PATH.'include/functions_thumb.php';
|
||||
// Move file and create thumb
|
||||
move_uploaded_file($tempFile,$targetFile);
|
||||
|
||||
create_thumbnail($targetPath, $targetFile, $smallPhoto, JAK_USERAVATWIDTH, JAK_USERAVATHEIGHT, 80);
|
||||
|
||||
// SQL update
|
||||
$jakdb->update("user", ["picture" => $dbSmall], ["id" => $userid]);
|
||||
|
||||
die(json_encode(array('status' => true, 'newurl' => $newavatar)));
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 2)));
|
||||
}
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 3)));
|
||||
}
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 2)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
?>
|
||||
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = $avatar = "";
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
if (isset($_REQUEST['avatar']) && !empty($_REQUEST['avatar'])) $avatar = $_REQUEST['avatar'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
if (empty($avatar)) die(json_encode(array('status' => false, 'errorcode' => 2)));
|
||||
|
||||
$imgdata = base64_decode($avatar);
|
||||
$im = imagecreatefromstring($imgdata);
|
||||
if ($im !== false) {
|
||||
|
||||
// if you need the image mime type
|
||||
$f = finfo_open();
|
||||
$mime = finfo_buffer($f, $imgdata, FILEINFO_MIME_TYPE);
|
||||
|
||||
if (($mime == "image/jpeg") || ($mime == "image/pjpeg") || ($mime == "image/png") || ($mime == "image/gif")) {
|
||||
|
||||
// first get the target path
|
||||
$targetPathd = APP_PATH.JAK_FILES_DIRECTORY.'/'.$userid.'/';
|
||||
$targetPath = str_replace("//","/",$targetPathd);
|
||||
// Create the target path
|
||||
if (!is_dir($targetPath)) {
|
||||
mkdir($targetPath, 0755);
|
||||
copy(APP_PATH.JAK_FILES_DIRECTORY."/index.html", $targetPath . "/index.html");
|
||||
|
||||
}
|
||||
|
||||
// if old avatars exist delete it
|
||||
foreach(glob($targetPath.'*.*') as $jak_unlink){
|
||||
unlink($jak_unlink);
|
||||
copy(APP_PATH.JAK_FILES_DIRECTORY."/index.html", $targetPath . "/index.html");
|
||||
}
|
||||
|
||||
$curtime = time();
|
||||
|
||||
// Get the correct ending.
|
||||
if ($mime == "image/jpeg" || $mime == "image/pjpeg") {
|
||||
$imend = ".jpg";
|
||||
} elseif ($mime == "image/gif") {
|
||||
$imend = ".gif";
|
||||
} else {
|
||||
$imend = ".png";
|
||||
}
|
||||
|
||||
$bigPhoto = 'avatarb'.$curtime.$imend;
|
||||
$smallPhoto = 'avatar'.$curtime.$imend;
|
||||
|
||||
$targetFile = str_replace('//','/',$targetPath) . $bigPhoto;
|
||||
$origPath = '/'.$userid.'/';
|
||||
$dbSmall = $origPath.$smallPhoto;
|
||||
$newavatar = JAK_FILES_DIRECTORY.$origPath.$bigPhoto;
|
||||
|
||||
// Save as the correct ending
|
||||
if ($imend == ".jpg") {
|
||||
imagejpeg($im, $targetFile);
|
||||
} elseif ($imend == ".gif") {
|
||||
imagegif($im, $targetFile);
|
||||
} else {
|
||||
imagepng($im, $targetFile);
|
||||
}
|
||||
|
||||
require_once APP_PATH.'include/functions_thumb.php';
|
||||
create_thumbnail($targetPath, $targetFile, $smallPhoto, JAK_USERAVATWIDTH, JAK_USERAVATHEIGHT, 80);
|
||||
|
||||
imagedestroy($im);
|
||||
|
||||
// SQL update
|
||||
$jakdb->update("user", ["picture" => $dbSmall], ["id" => $userid]);
|
||||
|
||||
// Output the avatar
|
||||
die(json_encode(array('status' => true, 'newurl' => $newavatar)));
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 2)));
|
||||
}
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 9)));
|
||||
}
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
?>
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 2.1.2 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2023 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = "";
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
// Select the fields
|
||||
$jakuser = new JAK_user($usr);
|
||||
// Only the SuperAdmin in the config file see everything
|
||||
if ($jakuser->jakSuperadminaccess($userid)) {
|
||||
define('JAK_SUPERADMINACCESS', true);
|
||||
} else {
|
||||
define('JAK_SUPERADMINACCESS', false);
|
||||
}
|
||||
|
||||
// Check if a sibling has logged in
|
||||
if ($jakuser->getVar("opid") != 0) {
|
||||
$opcacheid = $jakuser->getVar("opid");
|
||||
} else {
|
||||
$opcacheid = $jakuser->getVar("id");
|
||||
}
|
||||
|
||||
// Cache stuff
|
||||
if (file_exists(APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php')) include_once APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php';
|
||||
|
||||
// timezone from server
|
||||
date_default_timezone_set(JAK_TIMEZONESERVER);
|
||||
$jakdb->query('SET time_zone = "'.date("P").'"');
|
||||
|
||||
// Check if a sibling has logged in
|
||||
if ($jakuser->getVar("opid") != 0) $opcacheid = $jakuser->getVar("opid");
|
||||
|
||||
// Ok, we have check for some data, pull it
|
||||
if (jak_get_access("leads_all", $jakuser->getVar("permissions"), JAK_SUPERADMINACCESS)) {
|
||||
$data = $jakdb->select("sessions", ["[>]departments" => ["department" => "id"]], ["sessions.id", "sessions.usr_avatar", "sessions.name", "sessions.initiated", "sessions.operatorname", "sessions.status", "departments.title"], ["sessions.opid" => $opcacheid, "ORDER" => ["sessions.initiated" => "DESC"], "LIMIT" => 30]);
|
||||
} else {
|
||||
$data = $jakdb->select("sessions", ["[>]departments" => ["department" => "id"]], ["sessions.id", "sessions.usr_avatar", "sessions.name", "sessions.initiated", "sessions.operatorname", "sessions.status", "departments.title"], ["AND" => ["sessions.opid" => $opcacheid, "sessions.operatorid" => $userid], "ORDER" => ["sessions.initiated" => "DESC"], "LIMIT" => 30]);
|
||||
}
|
||||
|
||||
// PHP 8.2.3 Fix
|
||||
array_walk_recursive($data, function (&$v) { $v = (string)$v; });
|
||||
|
||||
if (isset($data) && !empty($data)) {
|
||||
die(json_encode(array('status' => true, 'data' => $data, 'filepath' => '', 'url' => BASE_URL)));
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 9)));
|
||||
}
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
?>
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 1.0.2 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = $chatid = "";
|
||||
$sendform = false;
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
if (isset($_REQUEST['chatid']) && !empty($_REQUEST['chatid'])) $chatid = $_REQUEST['chatid'];
|
||||
if (isset($_REQUEST['sendform']) && !empty($_REQUEST['sendform'])) $sendform = $_REQUEST['sendform'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash) && !empty($chatid) && is_numeric($chatid)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
if ($sendform) {
|
||||
|
||||
$jakdb->update("transcript", ["name" => $_REQUEST['name']], ["AND" => ["convid" => $chatid, "class" => "user"]]);
|
||||
|
||||
$jakdb->update("checkstatus", ["datac" => 1], ["convid" => $chatid]);
|
||||
|
||||
$email = $phone = $note = "";
|
||||
if (isset($_REQUEST['email']) && !empty($_REQUEST['email'])) $email = $_REQUEST['email'];
|
||||
if (isset($_REQUEST['phone']) && !empty($_REQUEST['phone'])) $phone = $_REQUEST['phone'];
|
||||
if (isset($_REQUEST['note']) && !empty($_REQUEST['note'])) $note = $_REQUEST['note'];
|
||||
$result = $jakdb->update("sessions", ["name" => $_REQUEST['name'], "email" => $email, "phone" => $phone, "notes" => $note], ["id" => $chatid]);
|
||||
|
||||
// Form has been sent, let's send the success status
|
||||
die(json_encode(array('status' => true)));
|
||||
|
||||
}
|
||||
|
||||
// Let's check if the chat exists and pull the data
|
||||
$data = $jakdb->get("sessions", ["[>]buttonstats" => ["session" => "session"], "[>]checkstatus" => ["id" => "convid"]], ["sessions.id", "sessions.usr_avatar", "sessions.name", "sessions.email", "sessions.phone", "sessions.country", "sessions.city", "sessions.latitude", "sessions.longitude", "sessions.notes", "sessions.countrycode", "sessions.initiated", "sessions.operatorname", "buttonstats.referrer", "buttonstats.agent"], ["sessions.id" => $chatid]);
|
||||
|
||||
if (isset($data) && !empty($data)) {
|
||||
// Correct the avatar path
|
||||
$data["usr_avatar"] = $data["usr_avatar"];
|
||||
die(json_encode(array('status' => true, 'data' => $data)));
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 9)));
|
||||
}
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
?>
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 2.1.2 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2023 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
/*
|
||||
Error Code for use in Xcode or Android SDK returned via errorcode
|
||||
1 = User is not logged in
|
||||
2 = File format is incorrect
|
||||
3 = File is too big for the server
|
||||
4 = Username/Email or Password is wrong
|
||||
5 = Please enter a valid email address
|
||||
6 = This email address does not exist
|
||||
7 = Something went wrong please try again
|
||||
8 = No permissions
|
||||
9 = No data available
|
||||
10 = Chat has been taken already
|
||||
11 = Please enter a message
|
||||
12 = There is no rest api installed on this URL.
|
||||
|
||||
Error Arrays for use in Xcode or Android SDK, errors will return an array with the same input field names = true
|
||||
$errors = array("name" => true, "new_password" => true);
|
||||
|
||||
Device and Token for login.php
|
||||
Important to register or update for Push Notifications
|
||||
$_REQUEST['device'] (ios or android), $_REQUEST['token'] (device token)
|
||||
*/
|
||||
|
||||
// Absolute Path
|
||||
$app_path = dirname(__file__) . DIRECTORY_SEPARATOR;
|
||||
define('APP_PATH', str_replace("rest".DIRECTORY_SEPARATOR, "", $app_path));
|
||||
|
||||
if (isset($_SERVER['SCRIPT_NAME'])) {
|
||||
|
||||
# on Windows _APP_MAIN_DIR becomes \ and abs url would look something like HTTP_HOST\/restOfUrl, so \ should be trimed too
|
||||
# @modified Chis Florinel <chis.florinel@candoo.ro>
|
||||
$app_main_dir = str_replace("rest/", "", $_SERVER['SCRIPT_NAME']);
|
||||
$app_main_dir = rtrim(dirname($app_main_dir), '/\\');
|
||||
define('_APP_MAIN_DIR', $app_main_dir);
|
||||
} else {
|
||||
die('[rest/config.php] Cannot determine APP_MAIN_DIR, please set manual and comment this line');
|
||||
}
|
||||
|
||||
//Import the PHPMailer class into the global namespace
|
||||
use PHPMailer\PHPMailer\PHPMailer;
|
||||
use PHPMailer\PHPMailer\SMTP;
|
||||
use PHPMailer\PHPMailer\Exception;
|
||||
|
||||
// The DB connections data
|
||||
require_once APP_PATH.'include/db.php';
|
||||
|
||||
// Get the DB class
|
||||
require_once APP_PATH.'class/class.db.php';
|
||||
|
||||
// All important files
|
||||
include_once APP_PATH.'include/functions.php';
|
||||
include_once APP_PATH.'class/class.jakbase.php';
|
||||
include_once APP_PATH.'class/class.userlogin.php';
|
||||
include_once APP_PATH.'class/class.user.php';
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
// Change for 3.0.3
|
||||
use JAKWEB\JAKsql;
|
||||
|
||||
// Database connection
|
||||
$jakdb = new JAKsql([
|
||||
// required
|
||||
'database_type' => JAKDB_DBTYPE,
|
||||
'database_name' => JAKDB_NAME,
|
||||
'server' => JAKDB_HOST,
|
||||
'username' => JAKDB_USER,
|
||||
'password' => JAKDB_PASS,
|
||||
'charset' => 'utf8',
|
||||
'port' => JAKDB_PORT,
|
||||
'prefix' => JAKDB_PREFIX,
|
||||
|
||||
// [optional] driver_option for connection, read more from http://www.php.net/manual/en/pdo.setattribute.php
|
||||
'option' => [PDO::ATTR_CASE => PDO::CASE_NATURAL]
|
||||
]);
|
||||
|
||||
// Launch the user login class
|
||||
$jakuserlogin = new JAK_userlogin();
|
||||
|
||||
// Check if https is activated
|
||||
if (JAK_SITEHTTPS) {
|
||||
define('BASE_URL', 'https://' . FULL_SITE_DOMAIN . _APP_MAIN_DIR . '/');
|
||||
} else {
|
||||
define('BASE_URL', 'http://' . FULL_SITE_DOMAIN . _APP_MAIN_DIR . '/');
|
||||
}
|
||||
|
||||
// Get the users ip address
|
||||
$ipa = get_ip_address();
|
||||
?>
|
||||
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 2.1.2 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2023 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = "";
|
||||
$newdata = array();
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
// Select the fields
|
||||
$jakuser = new JAK_user($usr);
|
||||
// Only the SuperAdmin in the config file see everything
|
||||
if ($jakuser->jakSuperadminaccess($userid)) {
|
||||
define('JAK_SUPERADMINACCESS', true);
|
||||
} else {
|
||||
define('JAK_SUPERADMINACCESS', false);
|
||||
}
|
||||
|
||||
// Check if a sibling has logged in
|
||||
if ($jakuser->getVar("opid") != 0) {
|
||||
$opcacheid = $jakuser->getVar("opid");
|
||||
} else {
|
||||
$opcacheid = $jakuser->getVar("id");
|
||||
}
|
||||
|
||||
// Cache stuff
|
||||
if (file_exists(APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php')) include_once APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php';
|
||||
|
||||
// timezone from server
|
||||
date_default_timezone_set(JAK_TIMEZONESERVER);
|
||||
$jakdb->query('SET time_zone = "'.date("P").'"');
|
||||
|
||||
// Check if a sibling has logged in
|
||||
if ($jakuser->getVar("opid") != 0) $opcacheid = $jakuser->getVar("opid");
|
||||
|
||||
// Ok, we have check for some data, pull it
|
||||
if (jak_get_access("off_all", $jakuser->getVar("permissions"), JAK_SUPERADMINACCESS)) {
|
||||
$data = $jakdb->select("contacts", ["id", "name", "email", "answered", "sent"], ["opid" => $opcacheid, "ORDER" => ["sent" => "DESC"], "LIMIT" => 30]);
|
||||
}
|
||||
|
||||
if (isset($data) && !empty($data)) {
|
||||
|
||||
foreach ($data as $row) {
|
||||
|
||||
if ($row["answered"] == "1980-05-06 00:00:00") {
|
||||
$answered = 0;
|
||||
$avatar = JAK_FILES_DIRECTORY.'/system.jpg';
|
||||
} else {
|
||||
$answered = 1;
|
||||
$avatar = JAK_FILES_DIRECTORY.'/system.jpg';
|
||||
}
|
||||
// Write the new data
|
||||
$newdata[] = array('id' => strval($row['id']), 'name' => $row['name'], 'email' => $row['email'], 'answered' => $answered, 'avatar' => $avatar, 'sent' => $row['sent']);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($newdata) && !empty($newdata)) {
|
||||
die(json_encode(array('status' => true, 'data' => $newdata)));
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 9)));
|
||||
}
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
?>
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 1.0.4 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = "";
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
// Select the fields
|
||||
$jakuser = new JAK_user($usr);
|
||||
// Only the SuperAdmin in the config file see everything
|
||||
if ($jakuser->jakSuperadminaccess($userid)) {
|
||||
define('JAK_SUPERADMINACCESS', true);
|
||||
} else {
|
||||
define('JAK_SUPERADMINACCESS', false);
|
||||
}
|
||||
|
||||
// Check if a sibling has logged in
|
||||
if ($jakuser->getVar("opid") != 0) {
|
||||
$opcacheid = $jakuser->getVar("opid");
|
||||
} else {
|
||||
$opcacheid = $jakuser->getVar("id");
|
||||
}
|
||||
|
||||
// Cache stuff
|
||||
if (file_exists(APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php')) include_once APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php';
|
||||
|
||||
// timezone from server
|
||||
date_default_timezone_set(JAK_TIMEZONESERVER);
|
||||
$jakdb->query('SET time_zone = "'.date("P").'"');
|
||||
|
||||
// Check if a sibling has logged in
|
||||
if ($jakuser->getVar("opid") != 0) $opcacheid = $jakuser->getVar("opid");
|
||||
|
||||
// Reset
|
||||
$totalAll = $commCtotal = $statsCtotal = $visitCtotal = $totalAllOT = $totalAllWT = 0;
|
||||
|
||||
if (jak_get_access("statistic_all", $jakuser->getVar("permissions"), JAK_SUPERADMINACCESS)) {
|
||||
|
||||
// Get all users from this operator
|
||||
$sessids = $jakdb->select("sessions", "id", ["OR" => ["opid" => $opcacheid, "operatorid" => $userid]]);
|
||||
|
||||
// Get the stats
|
||||
$commCtotal = $jakdb->count("transcript", ["convid" => $sessids]);
|
||||
$statsCtotal = $jakdb->count("user_stats", ["userid" => $userid]);
|
||||
$visitCtotal = $jakdb->count("buttonstats", ["opid" => $opcacheid]);
|
||||
|
||||
} else {
|
||||
|
||||
// Get all convid into an array
|
||||
$sessids = $jakdb->select("sessions", "id", ["AND" => ["opid" => $opcacheid, "operatorid" => $userid]]);
|
||||
// Get all messages from the convids
|
||||
$commCtotal = $jakdb->count("transcript", ["convid" => $sessids]);
|
||||
$statsCtotal = $jakdb->count("user_stats", ["userid" => $userid]);
|
||||
$visitCtotal = $jakdb->count("buttonstats", ["AND" => ["opid" => $opcacheid, "depid" => [$jakuser->getVar("departments")]]]);
|
||||
|
||||
}
|
||||
|
||||
// Get the totals
|
||||
$totalAll = $jakdb->count("support_tickets", ["opid" => $opcacheid]);
|
||||
|
||||
// Open Tickets
|
||||
$totalAllOT = $jakdb->count("support_tickets", ["AND" => ["status" => 1, "opid" => $opcacheid]]);
|
||||
// Awaiting Reply Tickets
|
||||
$totalAllWT = $jakdb->count("support_tickets", ["AND" => ["status" => 2, "opid" => $opcacheid]]);
|
||||
|
||||
|
||||
die(json_encode(array('status' => true, 'totaltickets' => $totalAll, 'totalmsg' => $commCtotal, 'totalfeedback' => $statsCtotal, 'totalvisitor' => $visitCtotal, 'totalopen' => $totalAllOT, 'totalwait' => $totalAllWT)));
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
?>
|
||||
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 1.1.2 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2020 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = $chatid = "";
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
if (isset($_REQUEST['chatid']) && !empty($_REQUEST['chatid'])) $chatid = $_REQUEST['chatid'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash) && !empty($chatid) && is_numeric($chatid)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
if (empty($_FILES['fileupload']['name'])) die(json_encode(array('status' => false, 'errorcode' => 2)));
|
||||
|
||||
// Select the user fields
|
||||
$jakuser = new JAK_user($usr);
|
||||
|
||||
// Cache stuff
|
||||
if (file_exists(APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$jakuser->getVar("id").'.php')) include_once APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$jakuser->getVar("id").'.php';
|
||||
|
||||
// timezone from server
|
||||
date_default_timezone_set(JAK_TIMEZONESERVER);
|
||||
$jakdb->query('SET time_zone = "'.date("P").'"');
|
||||
|
||||
// User has no permission to upload files, abort
|
||||
if (!$jakuser->getVar("files")) die(json_encode(array('status' => false, 'errorcode' => 8)));
|
||||
|
||||
if (!empty($_FILES['fileupload']['name'])) {
|
||||
|
||||
$filename = $_FILES['fileupload']['name']; // original filename
|
||||
$jak_xtension = pathinfo($_FILES['fileupload']['name']);
|
||||
|
||||
// Check if the extension is valid
|
||||
$allowedf = explode(',', JAK_ALLOWEDO_FILES);
|
||||
if (in_array(".".$jak_xtension['extension'], $allowedf)) {
|
||||
|
||||
// Get the maximum upload or set to 2
|
||||
$postmax = (ini_get('post_max_size') ? filter_var(ini_get('post_max_size'), FILTER_SANITIZE_NUMBER_INT) : "2");
|
||||
|
||||
if ($_FILES['fileupload']['size'] <= ($postmax * 1000000)) {
|
||||
|
||||
// first get the target path
|
||||
$targetPathd = '../'.JAK_FILES_DIRECTORY.'/operator/';
|
||||
$targetPath = str_replace("//", "/", $targetPathd);
|
||||
|
||||
$tempFile = $_FILES['fileupload']['tmp_name'];
|
||||
$name_space = explode(".", $_FILES["fileupload"]["name"]);
|
||||
// Keep the file name but sanitized
|
||||
$fileName = mb_ereg_replace("([^\w\s\d\-_~,;\[\]\(\).])", '', $name_space[0]);
|
||||
$fileName = mb_ereg_replace("([\.]{2,})", '', $fileName);
|
||||
$ufile = 'app_'.str_replace('.', '_', microtime(true)).'_'.$fileName. '.' . end($name_space);
|
||||
|
||||
$targetFile = str_replace('//','/',$targetPath).$ufile;
|
||||
$origPath = '/operator/';
|
||||
$message = $origPath.$ufile;
|
||||
|
||||
// Move file
|
||||
move_uploaded_file($tempFile, $targetFile);
|
||||
|
||||
$jakdb->insert("transcript", [
|
||||
"name" => $jakuser->getVar("name"),
|
||||
"message" => $message,
|
||||
"user" => $userid.'::'.$jakuser->getVar("username"),
|
||||
"operatorid" => $userid,
|
||||
"convid" => $chatid,
|
||||
"class" => "download",
|
||||
"time" => $jakdb->raw("NOW()")]);
|
||||
|
||||
$jakdb->update("checkstatus", ["newc" => 1, "typeo" => 0], ["convid" => $chatid]);
|
||||
|
||||
die(json_encode(array('status' => true)));
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 3)));
|
||||
}
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 2)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
?>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 2.0.4 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2022 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$email = "";
|
||||
// Get the email
|
||||
if (isset($_REQUEST['email']) && !empty($_REQUEST['email']) && filter_var($_REQUEST['email'], FILTER_VALIDATE_EMAIL)) $email = filter_var($_REQUEST['email'], FILTER_SANITIZE_EMAIL);
|
||||
|
||||
if (!empty($email)) {
|
||||
|
||||
$fwhen = time();
|
||||
|
||||
// Check if this user exist
|
||||
$user_check = $jakuserlogin->jakForgotpassword($email, $fwhen);
|
||||
|
||||
if ($user_check == true) {
|
||||
|
||||
// Include the mail library
|
||||
include_once APP_PATH.'class/PHPMailerAutoload.php';
|
||||
|
||||
// Import the language file
|
||||
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
|
||||
|
||||
// Get user details
|
||||
$oname = $jakdb->get("user", "name", ["AND" => ["email" => $email, "access" => 1]]);
|
||||
|
||||
if (jak_send_email($email, "", "", JAK_TITLE.' - '.$jkl['l13'], sprintf($jkl['l14'], $oname, '<a href="'.JAK_rewrite::jakParseurl('forgot-password', $fwhen).'">'.JAK_rewrite::jakParseurl('forgot-password', $fwhen).'</a>', JAK_TITLE), "")) {
|
||||
|
||||
die(json_encode(array('status' => true)));
|
||||
}
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 6)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 5)));
|
||||
?>
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 2.1.2 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2023 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$username = $userpass = $token = $device = $appversion = $appname = "";
|
||||
if (isset($_REQUEST['username']) && !empty($_REQUEST['username'])) $username = $_REQUEST['username'];
|
||||
if (isset($_REQUEST['password']) && !empty($_REQUEST['password'])) $userpass = $_REQUEST['password'];
|
||||
if (isset($_REQUEST['device']) && !empty($_REQUEST['device'])) $device = $_REQUEST['device'];
|
||||
if (isset($_REQUEST['token']) && !empty($_REQUEST['token'])) $token = $_REQUEST['token'];
|
||||
if (isset($_REQUEST['appversion']) && !empty($_REQUEST['appversion'])) $appversion = $_REQUEST['appversion'];
|
||||
if (isset($_REQUEST['appname']) && !empty($_REQUEST['appname'])) $appname = $_REQUEST['appname']; // (LC3 or HD3)
|
||||
|
||||
if (!empty($username) && !empty($userpass)) {
|
||||
|
||||
// A few information from the device
|
||||
$valid_agent = filter_var($_REQUEST['device'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$valid_ip = filter_var($ipa, FILTER_VALIDATE_IP);
|
||||
$valid_username = filter_var($username, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$userpass = filter_var($userpass, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
|
||||
// Write the log file each time someone tries to login before
|
||||
JAK_base::jakWhatslog('', 0, 0, 0, 1, 0, (isset($_COOKIE['WIOgeoData']) ? $_COOKIE['WIOgeoData'] : ''), $valid_username, $device, $valid_ip, $valid_agent);
|
||||
|
||||
$user_check = $jakuserlogin->jakCheckuserdata($valid_username, $userpass);
|
||||
if ($user_check == true) {
|
||||
|
||||
// Now login in the user and return tha data
|
||||
$user = $jakuserlogin->jakrestLogin($user_check, $userpass);
|
||||
|
||||
// Get the user details
|
||||
$jakuser = new JAK_user($user);
|
||||
|
||||
// Check if a sibling has logged in
|
||||
$opcacheid = $jakuser->getVar("id");
|
||||
if ($jakuser->getVar("opid") != 0) {
|
||||
$opcacheid = $jakuser->getVar("opid");
|
||||
}
|
||||
|
||||
// Write the log file each time someone login after to show success
|
||||
JAK_base::jakWhatslog('', $opcacheid, $user_check["id"], 0, 2, 0, '', $user_check["username"], '', $valid_ip, '');
|
||||
|
||||
// finally update the push notification table if we need to do so, max 2 devices (One for Android and One for IOS)
|
||||
if (!empty($device) && !empty($token)) $jakuserlogin->jakWriteDeviceToken($jakuser->getVar("id"), $opcacheid, $device, $token, $appname, $appversion);
|
||||
|
||||
// Only the SuperAdmin in the config file see everything
|
||||
if ($jakuser->jakSuperadminaccess($jakuser->getVar("id"))) {
|
||||
$superadmin = true;
|
||||
} else {
|
||||
$superadmin = false;
|
||||
}
|
||||
|
||||
// Get the maximum upload or set to 2
|
||||
$postmax = (ini_get('post_max_size') ? filter_var(ini_get('post_max_size'), FILTER_SANITIZE_NUMBER_INT) : "2");
|
||||
|
||||
// Cache stuff
|
||||
if (file_exists(APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php')) include_once APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php';
|
||||
|
||||
// timezone from server
|
||||
date_default_timezone_set(JAK_TIMEZONESERVER);
|
||||
$jakdb->query('SET time_zone = "'.date("P").'"');
|
||||
|
||||
// Return the json object
|
||||
die(json_encode(array('status' => true, 'userid' => strval($jakuser->getVar("id")), 'name' => $jakuser->getVar("name"), 'username' => $jakuser->getVar("username"), 'hash' => $jakuser->getVar("idhash"), 'email' => $jakuser->getVar("email"), 'picture' => JAK_FILES_DIRECTORY.$jakuser->getVar("picture"), 'responses' => strval($jakuser->getVar("responses")), 'files' => strval($jakuser->getVar("files")), 'transfer' => strval($jakuser->getVar("transferc")), 'permissions' => $jakuser->getVar("permissions"), 'superadmin' => $superadmin, 'postmaxsize' => $postmax, 'filetypes' => JAK_ALLOWEDO_FILES, 'urlabout' => "https://jakweb.ch", 'urlterms' => "https://jakweb.ch/terms-condition", 'urlprivacy' => "https://jakweb.ch/privacy")));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 4)));
|
||||
?>
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = "";
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
$jakuserlogin->jakLogoutRest($userid);
|
||||
die(json_encode(array('status' => true)));
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
}
|
||||
|
||||
}
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
?>
|
||||
@@ -0,0 +1,108 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 2.1.2 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2023 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
// include the PHP library (if not autoloaded)
|
||||
require(APP_PATH.'class/class.emoji.php');
|
||||
|
||||
$userid = $loginhash = $chatid = "";
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
if (isset($_REQUEST['chatid']) && !empty($_REQUEST['chatid'])) $chatid = $_REQUEST['chatid'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash) && !empty($chatid) && is_numeric($chatid)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
$statusmsg = $chatended = $typingstatus = false;
|
||||
$chatmsg = array();
|
||||
|
||||
if (is_numeric($chatid)) {
|
||||
|
||||
if (!isset($_REQUEST['lastmsgid']) && !is_numeric($_REQUEST['lastmsgid'])) {
|
||||
$lastid = 0;
|
||||
} else {
|
||||
$lastid = $_REQUEST['lastmsgid'];
|
||||
}
|
||||
|
||||
$result = $jakdb->select("transcript", ["[>]user" => ["operatorid" => "id"], "[>]sessions" => ["convid" => "id"]], ["transcript.id", "transcript.name", "transcript.message", "transcript.operatorid", "transcript.time", "transcript.class", "transcript.starred", "transcript.quoted", "transcript.editoid", "transcript.edited", "transcript.convid", "transcript.plevel", "user.picture", "sessions.usr_avatar", "sessions.status", "sessions.template"], ["AND" => ["transcript.convid" => $chatid, "transcript.id[>]" => $lastid], "ORDER" => ["transcript.id" => "ASC"]]);
|
||||
|
||||
if (isset($result) && !empty($result)) {
|
||||
|
||||
foreach ($result as $row) {
|
||||
|
||||
// Right
|
||||
$msgposition = 1;
|
||||
// Left
|
||||
if ($row["class"] == "user") $msgposition = 2;
|
||||
|
||||
// On which class to show a system image
|
||||
$systemimg = array("bot", "notice", "url", "ended");
|
||||
|
||||
// Get the avatar
|
||||
$cimage = $row["usr_avatar"];
|
||||
if ($row["picture"] && $row["operatorid"]) $cimage = JAK_FILES_DIRECTORY.$row["picture"];
|
||||
if (in_array($row["class"], $systemimg)) $cimage = 'lctemplate/'.$row['template'].'/avatar/system.jpg';
|
||||
|
||||
// Get the quote msg
|
||||
$quotemsg = '';
|
||||
if ($row['quoted']) {
|
||||
$quotemsg = $jakdb->get("transcript", "message", ["id" => $row["quoted"]]);
|
||||
}
|
||||
|
||||
// we have file
|
||||
$msgfile = false;
|
||||
if ($row['class'] == "download" && file_exists(APP_PATH.JAK_FILES_DIRECTORY.$row['message'])) {
|
||||
$msgfile = JAK_FILES_DIRECTORY.$row['message'];
|
||||
// Left
|
||||
if ($row["operatorid"] == 0) $msgposition = 2;
|
||||
$message = false;
|
||||
} else {
|
||||
// Convert the smilies to unicode
|
||||
$message = Emojione\Emojione::shortnameToUnicode($row['message']);
|
||||
}
|
||||
|
||||
// respond with the array
|
||||
$chatmsg[] = array('id' => strval($row['id']), 'image' => $cimage, 'name' => $row['name'], 'time' => $row['time'], 'class' => $row['class'], 'starred' => strval($row['starred']), 'editoid' => strval($row['editoid']), 'edited' => $row['edited'], 'plevel' => strval($row['plevel']), 'message' => $message, 'msgfile' => $msgfile, 'quotemsg' => $quotemsg, 'msgposition' => $msgposition);
|
||||
|
||||
$lastid = $row["id"];
|
||||
$chatstatus = $row["status"];
|
||||
}
|
||||
}
|
||||
|
||||
// Let's check the status
|
||||
if (!isset($chatstatus)) {
|
||||
$chatstatus = $jakdb->get("sessions", "status", ["id" => $chatid]);
|
||||
|
||||
if ($chatstatus) {
|
||||
$typingstatus = $jakdb->get("checkstatus", "typec", ["convid" => $chatid]);
|
||||
}
|
||||
}
|
||||
|
||||
// Return the messages
|
||||
die(json_encode(array('status' => true, 'chatmsg' => $chatmsg, 'lastid' => strval($lastid), 'typingstatus' => $typingstatus, 'chatstatus' => strval($chatstatus))));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
?>
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 2.1.2 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2023 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = "";
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
// Get the current time
|
||||
$currentime = time();
|
||||
|
||||
// Get the user fields
|
||||
$jakuser = new JAK_user($usr);
|
||||
|
||||
// Check if a sibling has logged in
|
||||
if ($jakuser->getVar("opid") != 0) {
|
||||
$opcacheid = $jakuser->getVar("opid");
|
||||
} else {
|
||||
$opcacheid = $jakuser->getVar("id");
|
||||
}
|
||||
|
||||
// Cache stuff
|
||||
if (file_exists(APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$jakuser->getVar("id").'.php')) include_once APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$jakuser->getVar("id").'.php';
|
||||
|
||||
// timezone from server
|
||||
date_default_timezone_set(JAK_TIMEZONESERVER);
|
||||
$jakdb->query('SET time_zone = "'.date("P").'"');
|
||||
|
||||
$useronline = array();
|
||||
|
||||
// 5 Minutes ago
|
||||
$mino = date('Y-m-d H:i:s', $currentime - 5 * 60);
|
||||
|
||||
// Get the user department
|
||||
$usrdep = $jakuser->getVar("chat_dep");
|
||||
|
||||
// Now only get the department for the user
|
||||
if (isset($usrdep) && is_numeric($usrdep) && $usrdep != 0) {
|
||||
$useronline = $jakdb->select("buttonstats", ["[>]sessions" => ["session" => "session"]], ["buttonstats.id", "buttonstats.referrer", "buttonstats.agent", "buttonstats.hits", "buttonstats.ip", "buttonstats.lasttime", "buttonstats.time", "buttonstats.readtime", "sessions.initiated", "sessions.ended"], ["AND" => ["buttonstats.opid" => $opcacheid, "buttonstats.singleopid" => [0, $userid], "buttonstats.depid" => $usrdep, "#buttonstats.lasttime[>]" => $mino], "GROUP" => "buttonstats.session", "ORDER" => ["buttonstats.lasttime" => "DESC"], "LIMIT" => 30]);
|
||||
} elseif (isset($usrdep) && $usrdep == 0) {
|
||||
$useronline = $jakdb->select("buttonstats", ["[>]sessions" => ["session" => "session"]], ["buttonstats.id", "buttonstats.referrer", "buttonstats.agent", "buttonstats.hits", "buttonstats.ip", "buttonstats.lasttime", "buttonstats.time", "buttonstats.readtime", "sessions.initiated", "sessions.ended"], ["AND" => ["buttonstats.opid" => $opcacheid, "buttonstats.singleopid" => [0, $userid], "#buttonstats.lasttime[>]" => $mino], "GROUP" => "buttonstats.session", "ORDER" => ["buttonstats.lasttime" => "DESC"], "LIMIT" => 30]);
|
||||
} elseif (isset($usrdep)) {
|
||||
$useronline = $jakdb->select("buttonstats", ["[>]sessions" => ["session" => "session"]], ["buttonstats.id", "buttonstats.referrer", "buttonstats.agent", "buttonstats.hits", "buttonstats.ip", "buttonstats.lasttime", "buttonstats.time", "buttonstats.readtime", "sessions.initiated", "sessions.ended"], ["AND" => ["buttonstats.opid" => $opcacheid, "buttonstats.singleopid" => [0, $userid], "buttonstats.depid" => explode(",",$usrdep), "#buttonstats.lasttime[>]" => $mino], "GROUP" => "buttonstats.session", "ORDER" => ["buttonstats.lasttime" => "DESC"], "LIMIT" => 30]);
|
||||
}
|
||||
|
||||
if (isset($useronline) && !empty($useronline)) {
|
||||
|
||||
$uo = array();
|
||||
foreach ($useronline as $v) {
|
||||
|
||||
if (empty($v["initiated"])) $v["initiated"] = 0;
|
||||
if (empty($v["ended"])) $v["ended"] = 0;
|
||||
$v["proactive"] = $v["readtime"];
|
||||
|
||||
$uo[] = $v;
|
||||
}
|
||||
|
||||
// PHP 8.2.3 Fix
|
||||
array_walk_recursive($uo, function (&$v) { $v = (string)$v; });
|
||||
|
||||
die(json_encode(array('status' => true, 'useronline' => $uo)));
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 9)));
|
||||
}
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
?>
|
||||
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
include_once APP_PATH.JAK_OPERATOR_LOC.'/include/admin.function.php';
|
||||
|
||||
$userid = $loginhash = "";
|
||||
$errors = array();
|
||||
$updatepass = false;
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
if (!isset($_REQUEST['name']) || empty($_REQUEST['name'])) {
|
||||
$errors['name'] = true;
|
||||
}
|
||||
|
||||
if (!isset($_REQUEST['email']) || $_REQUEST['email'] == '' || !filter_var($_REQUEST['email'], FILTER_VALIDATE_EMAIL)) {
|
||||
$errors['email'] = true;
|
||||
}
|
||||
|
||||
if (!isset($_REQUEST['email']) || jak_field_not_exist_id($_REQUEST['email'], $userid, "user", "email")) {
|
||||
$errors['email'] = true;
|
||||
}
|
||||
|
||||
if (!isset($_REQUEST['username']) || !preg_match('/^([a-zA-Z0-9\-_])+$/', $_REQUEST['username'])) {
|
||||
$errors['username'] = true;
|
||||
}
|
||||
|
||||
if (!isset($_REQUEST['username']) || jak_field_not_exist_id($_REQUEST['username'], $userid, "user", "username")) {
|
||||
$errors['username'] = true;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['password']) && !empty($_REQUEST['password']) && (!empty($_REQUEST['new_password']) || !empty($_REQUEST['confirm_new_password']))) {
|
||||
if ($_REQUEST['new_password'] != $_REQUEST['confirm_new_password']) {
|
||||
$errors['new_password'] = true;
|
||||
} elseif (strlen($_REQUEST['new_password']) <= '7') {
|
||||
$errors['new_password'] = true;
|
||||
} else {
|
||||
$updatepass = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($errors) == 0) {
|
||||
|
||||
// Let's update the password
|
||||
if ($updatepass) $jakdb->update("user", ["password" => hash_hmac('sha256', $_REQUEST['new_password'], DB_PASS_HASH)], ["id" => $userid]);
|
||||
|
||||
// Update other fields
|
||||
$jakdb->update("user", ["username" => trim($_REQUEST['username']),
|
||||
"name" => trim($_REQUEST['name']),
|
||||
"email" => filter_var($_REQUEST['email'], FILTER_SANITIZE_EMAIL)], ["id" => $userid]);
|
||||
|
||||
|
||||
die(json_encode(array('status' => true)));
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errors' => $errors)));
|
||||
}
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
?>
|
||||
+277
@@ -0,0 +1,277 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 2.1.2 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2023 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = "";
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
// Select the fields
|
||||
$jakuser = new JAK_user($usr);
|
||||
|
||||
$USER_LANGUAGE = strtolower($jakuser->getVar("language"));
|
||||
$USER_DEPARTMENTS = $jakuser->getVar("chat_dep");
|
||||
|
||||
// Check if a sibling has logged in
|
||||
if ($jakuser->getVar("opid") != 0) {
|
||||
$opcacheid = $jakuser->getVar("opid");
|
||||
} else {
|
||||
$opcacheid = $jakuser->getVar("id");
|
||||
}
|
||||
|
||||
// Cache stuff
|
||||
if (file_exists(APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php')) include_once APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php';
|
||||
|
||||
// timezone from server
|
||||
date_default_timezone_set(JAK_TIMEZONESERVER);
|
||||
$jakdb->query('SET time_zone = "'.date("P").'"');
|
||||
|
||||
// Check if a sibling has logged in
|
||||
if ($jakuser->getVar("opid") != 0) $opcacheid = $jakuser->getVar("opid");
|
||||
|
||||
// Import the language file
|
||||
if ($USER_LANGUAGE && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$USER_LANGUAGE.'.php')) {
|
||||
include_once APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$USER_LANGUAGE.'.php';
|
||||
} else {
|
||||
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
|
||||
}
|
||||
|
||||
// Reset vars
|
||||
$transfer_msg = $soundjs = $soundmsgjs = '';
|
||||
$newclient = $newmsg = $transferid = $convtransfer = 0;
|
||||
$loadClients = $jsmsg = $convid = $answers = $typing = false;
|
||||
|
||||
$resnew = $jakdb->select("checkstatus", ["convid", "depid", "operatorid", "operator", "newo", "transferoid", "transferid", "typec", "statusc", "initiated"], ["AND" => ["opid" => $opcacheid, "hide" => 0, "denied" => 0]]);
|
||||
|
||||
if (isset($resnew) && !empty($resnew)) {
|
||||
|
||||
foreach ($resnew as $row) {
|
||||
|
||||
// We have a dead client connection cancel it.
|
||||
if ($row['statusc'] && (time() - $row['statusc']) > JAK_CLIENT_LEFT) {
|
||||
|
||||
$jakdb->update("sessions", ["status" => 0, "ended" => time()], ["id" => $row['convid']]);
|
||||
$jakdb->update("checkstatus", ["hide" => 1], ["convid" => $row['convid']]);
|
||||
|
||||
// We need the client name
|
||||
$cname = $jakdb->get("sessions", "name", ["convid" => $row['convid']]);
|
||||
|
||||
$jakdb->insert("transcript", [
|
||||
"name" => $jkl['g274'],
|
||||
"message" => sprintf($jkl['g168'], $cname),
|
||||
"convid" => $row['convid'],
|
||||
"class" => "notice",
|
||||
"plevel" => 2,
|
||||
"time" => $jakdb->raw("NOW()")]);
|
||||
break;
|
||||
}
|
||||
|
||||
// We have an expired client cancel it
|
||||
if ($row['statusc'] && (time() - $row['statusc']) > JAK_CLIENT_EXPIRED) {
|
||||
|
||||
$jakdb->update("sessions", ["status" => 0, "ended" => time()], ["id" => $row['convid']]);
|
||||
$jakdb->update("checkstatus", ["hide" => 1], ["convid" => $row['convid']]);
|
||||
|
||||
$jakdb->insert("transcript", [
|
||||
"name" => $jkl['g274'],
|
||||
"message" => $jkl['g72'],
|
||||
"convid" => $row['convid'],
|
||||
"class" => "notice",
|
||||
"time" => $jakdb->raw("NOW()")]);
|
||||
break;
|
||||
}
|
||||
|
||||
// We have a transfer, need to display it!
|
||||
if ($row['transferoid'] == $userid) {
|
||||
|
||||
$trow = $jakdb->get("transfer", ["fromname", "message"], ["AND" => ["tooid" => $userid, "convid" => $row['convid'], "used" => 0]]);
|
||||
|
||||
if (isset($trow) && !empty($trow)) {
|
||||
|
||||
// Display underneath the button
|
||||
$transfer_msg = $trow["message"];
|
||||
$transferid = $row['transferid'];
|
||||
$convtransfer = $row["convid"];
|
||||
$convid[] = $row["convid"];
|
||||
$jsmsg = sprintf($jkl['g110'], $trow["fromname"]);
|
||||
$loadClients = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Only load if we are in the correct department
|
||||
if ($USER_DEPARTMENTS == 0 || $row["depid"] == $USER_DEPARTMENTS || in_array($row["depid"], explode(",", $USER_DEPARTMENTS))) {
|
||||
// check for new conversations
|
||||
if ($row['operatorid'] == 0 || ($row['operatorid'] == $userid && empty($row['operator']))) {
|
||||
$newclient = 1;
|
||||
$soundjs = JAK_RING_TONE;
|
||||
if ($row['typec']) $typing[] = $row['convid'];
|
||||
$convid[] = $row["convid"];
|
||||
$loadClients = true;
|
||||
}
|
||||
if ($row['operatorid'] == $userid && !empty($row['operator'])) {
|
||||
$jakdb->update("checkstatus", ["statuso" => time()], ["convid" => $row['convid']]);
|
||||
if ($row['typec']) $typing[] = $row['convid'];
|
||||
$convid[] = $row["convid"];
|
||||
$loadClients = true;
|
||||
}
|
||||
if ($row['operatorid'] == $userid && $row['newo']) {
|
||||
$newmsg = 2;
|
||||
$soundmsgjs = JAK_MSG_TONE;
|
||||
$answers[] = $row['convid'];
|
||||
if ($row['typec']) $typing[] = $row['convid'];
|
||||
$convid[] = $row["convid"];
|
||||
$loadClients = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reset convlist
|
||||
$convlist = array();
|
||||
|
||||
// Only go for it if we want to
|
||||
if ($loadClients) {
|
||||
|
||||
// Now let's get the conversation list
|
||||
$new = $updated = $current = $transfer = array();
|
||||
$count = 0;
|
||||
$dep_title = "";
|
||||
|
||||
$resconv = $jakdb->select("sessions", ["id", "department", "name", "usr_avatar", "operatorname", "status", "initiated", "ended"], ["id" => $convid]);
|
||||
|
||||
if (isset($resconv) && !empty($resconv)) {
|
||||
|
||||
foreach ($resconv as $row) {
|
||||
|
||||
if ($row['status']) {
|
||||
|
||||
// Get all available chats
|
||||
if ($row['operatorname'] == "") {
|
||||
$new[$count]["name"] = $row['name'];
|
||||
$new[$count]["usr_avatar"] = $row['usr_avatar'];
|
||||
$new[$count]["convid"] = $row['id'];
|
||||
$new[$count]["initiated"] = $row['initiated'];
|
||||
$new[$count]["typing"] = false;
|
||||
if (!empty($typing) && in_array($row['id'], $typing)) $new[$count]["typing"] = true;
|
||||
// Get the transfer into the array as well
|
||||
} elseif ($row["id"] == $convtransfer) {
|
||||
$transfer[$count]["name"] = $row['name'];
|
||||
$transfer[$count]["usr_avatar"] = $row['usr_avatar'];
|
||||
$transfer[$count]["convid"] = $row['id'];
|
||||
$transfer[$count]["initiated"] = $row['initiated'];
|
||||
$transfer[$count]["typing"] = false;
|
||||
if (!empty($typing) && in_array($row['id'], $typing)) $transfer[$count]["typing"] = true;
|
||||
// Get updated chats
|
||||
} elseif (!empty($answers) && $row['operatorname'] && in_array($row['id'], $answers)) {
|
||||
$updated[$count]["name"] = $row['name'];
|
||||
$updated[$count]["usr_avatar"] = $row['usr_avatar'];
|
||||
$updated[$count]["convid"] = $row['id'];
|
||||
$updated[$count]["initiated"] = $row['initiated'];
|
||||
$updated[$count]["typing"] = false;
|
||||
if (!empty($typing) && in_array($row['id'], $typing)) $updated[$count]["typing"] = true;
|
||||
// Get the rest
|
||||
} else {
|
||||
$current[$count]["name"] = $row['name'];
|
||||
$current[$count]["usr_avatar"] = $row['usr_avatar'];
|
||||
$current[$count]["convid"] = $row['id'];
|
||||
$current[$count]["initiated"] = $row['initiated'];
|
||||
$current[$count]["typing"] = false;
|
||||
if (!empty($typing) && in_array($row['id'], $typing)) $current[$count]["typing"] = true;
|
||||
}
|
||||
|
||||
// Now load the department title if we have any
|
||||
if (isset($row["department"]) && is_numeric($row["department"])) {
|
||||
|
||||
foreach ($HD_DEPARTMENTS as $d) {
|
||||
# code...
|
||||
if ($d["id"] == $row["department"]) {
|
||||
$dep_title = $d["title"];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!$row['status']) {
|
||||
if (((time() - $row['ended']) > 300)) {
|
||||
|
||||
$jakdb->update("checkstatus", ["hide" => 1], ["convid" => $row['id']]);
|
||||
|
||||
$jakdb->insert("transcript", [
|
||||
"name" => $jkl['g274'],
|
||||
"message" => $jkl['g73'],
|
||||
"convid" => $row['id'],
|
||||
"class" => "notice",
|
||||
"plevel" => 2,
|
||||
"time" => $jakdb->raw("NOW()")]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$count = $count + 1;
|
||||
}
|
||||
|
||||
shuffle($new);
|
||||
shuffle($updated);
|
||||
shuffle($current);
|
||||
shuffle($transfer);
|
||||
sort($new);
|
||||
sort($updated);
|
||||
sort($current);
|
||||
sort($transfer);
|
||||
$newTotal = count($new);
|
||||
$updatedTotal = count($updated);
|
||||
$currentTotal = count($current);
|
||||
$transferTotal = count($transfer);
|
||||
|
||||
// Status 1 = New client (confirm or send to contact), 2 = New Message, 3 = Unchanged status
|
||||
|
||||
for($i = 0; $i < $newTotal; $i ++ ) {
|
||||
$convlist[] = array('status' => 1, 'department' => $dep_title, 'chatid' => strval($new[$i]["convid"]), 'name' => $new[$i]["name"], 'avatar' => $new[$i]["usr_avatar"], 'typing' => $new[$i]["typing"], 'initiated' => strval($new[$i]["initiated"]));
|
||||
}
|
||||
for($i = 0; $i < $updatedTotal; $i ++ ) {
|
||||
$convlist[] = array('status' => 2, 'department' => $dep_title, 'chatid' => strval($updated[$i]["convid"]), 'name' => $updated[$i]["name"], 'avatar' => $updated[$i]["usr_avatar"], 'typing' => $updated[$i]["typing"], 'initiated' => strval($updated[$i]["initiated"]));
|
||||
}
|
||||
for($i = 0; $i < $currentTotal; $i ++ ) {
|
||||
$convlist[] = array('status' => 3, 'department' => $dep_title, 'chatid' => strval($current[$i]["convid"]), 'name' => $current[$i]["name"], 'avatar' => $current[$i]["usr_avatar"], 'typing' => $current[$i]["typing"], 'initiated' => strval($current[$i]["initiated"]));
|
||||
}
|
||||
for($i = 0; $i < $transferTotal; $i ++ ) {
|
||||
$convlist[] = array('status' => 4, 'department' => $dep_title, 'chatid' => strval($transfer[$i]["convid"]), 'name' => $transfer[$i]["name"], 'avatar' => $transfer[$i]["usr_avatar"], 'typing' => $transfer[$i]["typing"], 'initiated' => strval($transfer[$i]["initiated"]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isset($convlist) && !empty($convlist)) {
|
||||
die(json_encode(array('status' => true, 'convlist' => $convlist, 'newclient' => $newclient, 'newmsg' => $newmsg, 'transferid' => $transferid, 'transfermsg' => $transfer_msg, 'transfernotifcation' => $jsmsg, 'url' => BASE_URL)));
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 9)));
|
||||
}
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
?>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$lcurl = "";
|
||||
if (isset($_REQUEST['url']) && !empty($_REQUEST['url'])) $lcurl = $_REQUEST['url'];
|
||||
if (isset($_REQUEST['device']) && !empty($_REQUEST['device'])) $device = $_REQUEST['device'];
|
||||
if (isset($_REQUEST['token']) && !empty($_REQUEST['token'])) $token = $_REQUEST['token'];
|
||||
|
||||
if (!empty($lcurl) && filter_var($lcurl, FILTER_VALIDATE_URL)) {
|
||||
|
||||
// Return the json object
|
||||
die(json_encode(array('status' => true, 'ios' => "", 'android' => "", 'title' => "CloudDesk 3")));
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 12)));
|
||||
?>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = $chatid = "";
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
die(json_encode(array('status' => true)));
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
?>
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 1.0.4 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = "";
|
||||
$newdata = array();
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
// Select the fields
|
||||
$jakuser = new JAK_user($usr);
|
||||
// Only the SuperAdmin in the config file see everything
|
||||
if ($jakuser->jakSuperadminaccess($userid)) {
|
||||
define('JAK_SUPERADMINACCESS', true);
|
||||
} else {
|
||||
define('JAK_SUPERADMINACCESS', false);
|
||||
}
|
||||
|
||||
// Check if a sibling has logged in
|
||||
if ($jakuser->getVar("opid") != 0) {
|
||||
$opcacheid = $jakuser->getVar("opid");
|
||||
} else {
|
||||
$opcacheid = $jakuser->getVar("id");
|
||||
}
|
||||
|
||||
// Cache stuff
|
||||
if (file_exists(APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php')) include_once APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php';
|
||||
|
||||
// timezone from server
|
||||
date_default_timezone_set(JAK_TIMEZONESERVER);
|
||||
$jakdb->query('SET time_zone = "'.date("P").'"');
|
||||
|
||||
// Check if a sibling has logged in
|
||||
if ($jakuser->getVar("opid") != 0) $opcacheid = $jakuser->getVar("opid");
|
||||
|
||||
// Ok, we have check for some data, pull it
|
||||
if (jak_get_access("support", $jakuser->getVar("permissions"), JAK_SUPERADMINACCESS)) {
|
||||
|
||||
// Filter the right result or show all
|
||||
if (is_numeric($jakuser->getVar("support_dep")) && $jakuser->getVar("support_dep") != 0) {
|
||||
$newdata = $jakdb->select("support_tickets", ["[>]support_departments" => ["depid" => "id"]], ["support_tickets.id", "support_tickets.subject", "support_departments.title(department)", "support_tickets.name", "support_tickets.email", "support_tickets.private", "support_tickets.status", "support_tickets.updated"], ["AND" => ["OR" => ["support_tickets.operatorid" => $jakuser->getVar("id"), "support_tickets.depid" => $jakuser->getVar("support_dep")], "support_tickets.opid" => $opcacheid], "ORDER" => ["support_tickets.updated" => "DESC"]]);
|
||||
} elseif (!((boolean)$jakuser->getVar("support_dep")) && $jakuser->getVar("support_dep") != 0) {
|
||||
$newdata = $jakdb->select("support_tickets", ["[>]support_departments" => ["depid" => "id"]], ["support_tickets.id", "support_tickets.subject", "support_departments.title(department)", "support_tickets.name", "support_tickets.email", "support_tickets.private", "support_tickets.status", "support_tickets.updated"], ["AND" => ["OR" => ["support_tickets.operatorid" => $jakuser->getVar("id"), "support_tickets.depid" => [$jakuser->getVar("support_dep")]], "support_tickets.opid" => $opcacheid], "ORDER" => ["support_tickets.updated" => "DESC"]]);
|
||||
} else {
|
||||
$newdata = $jakdb->select("support_tickets", ["[>]support_departments" => ["depid" => "id"]], ["support_tickets.id", "support_tickets.subject", "support_departments.title(department)", "support_tickets.name", "support_tickets.email", "support_tickets.private", "support_tickets.status", "support_tickets.updated"], ["support_tickets.opid" => $opcacheid, "ORDER" => ["support_tickets.updated" => "DESC"]]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isset($newdata) && !empty($newdata)) {
|
||||
die(json_encode(array('status' => true, 'tickets' => $newdata)));
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 9)));
|
||||
}
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
?>
|
||||
@@ -0,0 +1,319 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 2.0.6 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2022 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = $ticketid = $answerid = $editticket = $editanswer = $deleteticket = $deleteanswer = $subject = $message = $searchticket = "";
|
||||
$readticket = false;
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
if (isset($_REQUEST['ticketid']) && !empty($_REQUEST['ticketid'])) $ticketid = $_REQUEST['ticketid'];
|
||||
if (isset($_REQUEST['answerid']) && !empty($_REQUEST['answerid'])) $answerid = $_REQUEST['answerid'];
|
||||
if (isset($_REQUEST['readticket']) && !empty($_REQUEST['readticket'])) $readticket = $_REQUEST['readticket'];
|
||||
if (isset($_REQUEST['editticket']) && !empty($_REQUEST['editticket'])) $editticket = $_REQUEST['editticket'];
|
||||
if (isset($_REQUEST['editanswer']) && !empty($_REQUEST['editanswer'])) $editanswer = $_REQUEST['editanswer'];
|
||||
if (isset($_REQUEST['deleteticket']) && !empty($_REQUEST['deleteticket'])) $deleteticket = $_REQUEST['deleteticket'];
|
||||
if (isset($_REQUEST['deleteanswer']) && !empty($_REQUEST['deleteanswer'])) $deleteanswer = $_REQUEST['deleteanswer'];
|
||||
if (isset($_REQUEST['subject']) && !empty($_REQUEST['subject'])) $subject = $_REQUEST['subject'];
|
||||
if (isset($_REQUEST['message']) && !empty($_REQUEST['message'])) $message = $_REQUEST['message'];
|
||||
if (isset($_REQUEST['message']) && !empty($_REQUEST['message'])) $message = $_REQUEST['message'];
|
||||
if (isset($_REQUEST['searchticket']) && !empty($_REQUEST['searchticket'])) $searchticket = $_REQUEST['searchticket'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
// Select the user fields
|
||||
$jakuser = new JAK_user($usr);
|
||||
// Only the SuperAdmin in the config file see everything
|
||||
if ($jakuser->jakSuperadminaccess($userid)) {
|
||||
define('JAK_SUPERADMINACCESS', true);
|
||||
} else {
|
||||
define('JAK_SUPERADMINACCESS', false);
|
||||
}
|
||||
|
||||
// Check if a sibling has logged in
|
||||
if ($jakuser->getVar("opid") != 0) {
|
||||
$opcacheid = $jakuser->getVar("opid");
|
||||
} else {
|
||||
$opcacheid = $jakuser->getVar("id");
|
||||
}
|
||||
|
||||
// Cache stuff
|
||||
if (file_exists(APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php')) include_once APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php';
|
||||
|
||||
// timezone from server
|
||||
date_default_timezone_set(JAK_TIMEZONESERVER);
|
||||
$jakdb->query('SET time_zone = "'.date("P").'"');
|
||||
|
||||
// Check if a sibling has logged in
|
||||
if ($jakuser->getVar("opid") != 0) $opcacheid = $jakuser->getVar("opid");
|
||||
|
||||
$USER_LANGUAGE = strtolower($jakuser->getVar("language"));
|
||||
|
||||
// Import the language file
|
||||
if ($USER_LANGUAGE && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$USER_LANGUAGE.'.php')) {
|
||||
include_once APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$USER_LANGUAGE.'.php';
|
||||
$lang = $USER_LANGUAGE;
|
||||
} else {
|
||||
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
|
||||
$lang = JAK_LANG;
|
||||
}
|
||||
|
||||
// Read the ticket
|
||||
if ($searchticket && !empty($searchticket)) {
|
||||
|
||||
// let's go through the tables
|
||||
$filtered = filter_var($searchticket, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$keyword = strtolower($filtered);
|
||||
|
||||
$seachresult = array();
|
||||
|
||||
if (is_numeric($jakuser->getVar("support_dep")) && $jakuser->getVar("support_dep") != 0) {
|
||||
$seachresult = $jakdb->select("support_tickets", ["[>]support_departments" => ["depid" => "id"]], ["support_tickets.id", "support_tickets.subject", "support_tickets.content", "support_tickets.email", "support_tickets.name", "support_tickets.initiated", "support_tickets.updated", "support_tickets.ended", "support_tickets.private", "support_tickets.status", "support_departments.title(department)"], ["AND" => ["OR" => ["support_tickets.subject[~]" => $keyword, "support_tickets.content[~]" => $keyword, "support_tickets.name[~]" => $keyword], "support_tickets.opid" => $opcacheid, "support_tickets.depid" => $jakuser->getVar("support_dep")], "ORDER" => ["support_tickets.updated" => "DESC"], "LIMIT" => 10]);
|
||||
} elseif (!((boolean)$jakuser->getVar("support_dep")) && $jakuser->getVar("support_dep") != 0) {
|
||||
$seachresult = $jakdb->select("support_tickets", ["[>]support_departments" => ["depid" => "id"]], ["support_tickets.id", "support_tickets.subject", "support_tickets.content", "support_tickets.email", "support_tickets.name", "support_tickets.initiated", "support_tickets.updated", "support_tickets.ended", "support_tickets.private", "support_tickets.status", "support_departments.title(department)"], ["AND" => ["OR" => ["support_tickets.subject[~]" => $keyword, "support_tickets.content[~]" => $keyword, "support_tickets.name[~]" => $keyword], "support_tickets.opid" => $opcacheid, "support_tickets.depid" => [$jakuser->getVar("support_dep")]], "ORDER" => ["support_tickets.updated" => "DESC"], "LIMIT" => 10]);
|
||||
} else {
|
||||
$seachresult = $jakdb->select("support_tickets", ["[>]support_departments" => ["depid" => "id"]], ["support_tickets.id", "support_tickets.subject", "support_tickets.content", "support_tickets.email", "support_tickets.name", "support_tickets.initiated", "support_tickets.updated", "support_tickets.ended", "support_tickets.private", "support_tickets.status", "support_departments.title(department)"], ["AND" => ["OR" => ["support_tickets.subject[~]" => $keyword, "support_tickets.content[~]" => $keyword, "support_tickets.name[~]" => $keyword], "support_tickets.opid" => $opcacheid], "ORDER" => ["support_tickets.updated" => "DESC"], "LIMIT" => 10]);
|
||||
}
|
||||
|
||||
if (isset($seachresult) && !empty($seachresult)) {
|
||||
|
||||
// Take the chat go to chat
|
||||
die(json_encode(array('status' => true, 'task' => "search", 'searchresult' => $seachresult)));
|
||||
|
||||
} else {
|
||||
|
||||
// There is no data with this ticket
|
||||
die(json_encode(array('status' => false, 'task' => "search", 'errorcode' => 9)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Read the ticket
|
||||
if ($readticket && !empty($ticketid) && is_numeric($ticketid)) {
|
||||
|
||||
$JAK_FORM_DATA = $jakdb->get("support_tickets", ["[>]support_departments" => ["depid" => "id"], "[>]clients" => ["clientid" => "id"]], ["support_tickets.id", "support_tickets.depid", "support_tickets.operatorid", "support_tickets.subject", "support_tickets.content", "support_tickets.clientid", "support_tickets.ip", "support_tickets.referrer", "support_tickets.notes", "support_tickets.private", "support_tickets.status", "support_tickets.attachments", "support_tickets.initiated", "support_tickets.ended", "support_tickets.updated", "support_tickets.priorityid", "support_tickets.toptionid", "support_departments.title", "clients.name", "clients.email", "clients.support_dep", "clients.credits", "clients.paid_until"], ["AND" => ["support_tickets.opid" => $opcacheid, "support_tickets.id" => $ticketid]]);
|
||||
|
||||
// Get all operators
|
||||
$OPERATOR_ALL = $jakdb->select("user", ["id", "name", "email"], ["OR #andclause" => ["AND #the first condition" => ["id" => $userid], "AND #the second condition" => ["permissions[~]" => "support", "support_dep" => [0, $JAK_FORM_DATA["depid"]], "access" => 1, "opid" => $opcacheid]], "ORDER" => ["name" => "ASC"]]);
|
||||
|
||||
if ($jakuser->getVar("support_dep") == 0) {
|
||||
$DEPARTMENTS_ALL = $jakdb->select("support_departments", ["id", "title"], ["opid" => $opcacheid, "ORDER" => ["dorder" => "ASC"]]);
|
||||
} else {
|
||||
$DEPARTMENTS_ALL = $jakdb->select("support_departments", ["id", "title"], ["AND" => ["id" => [$jakuser->getVar("support_dep")], "opid" => $opcacheid], "ORDER" => ["dorder" => "ASC"]]);
|
||||
}
|
||||
|
||||
// Get all priorities
|
||||
$PRIORITY_ALL = $jakdb->select("ticketpriority", "*", ["AND" => ["depid" => [0, $JAK_FORM_DATA["depid"]], "opid" => $opcacheid]]);
|
||||
// Get all options
|
||||
$TOPTIONS_ALL = $jakdb->select("ticketoptions", "*", ["AND" => ["depid" => [0, $JAK_FORM_DATA["depid"]], "opid" => $opcacheid]]);
|
||||
|
||||
// Get the ticket Answers
|
||||
$JAK_ANSWER_DATA = $jakdb->select("ticket_answers", ["[>]user" => ["operatorid" => "id"], "[>]clients" => ["clientid" => "id"]], ["ticket_answers.id", "ticket_answers.content", "ticket_answers.lastedit", "ticket_answers.sent", "user.id(oid)", "user.name(oname)", "clients.id(cid)", "clients.name(cname)"], ["ticket_answers.ticketid" => $ticketid, "ORDER" => ["ticket_answers.sent" => "DESC"]]);
|
||||
|
||||
// Get the standard support responses
|
||||
$JAK_RESPONSE_DATA = array();
|
||||
// Standard Message
|
||||
$JAK_RESPONSE_DATA[] = array("message" => 0, "title" => $jkl["g7"]);
|
||||
if (isset($HD_RESPONSEST) && is_array($HD_RESPONSEST)) {
|
||||
|
||||
// get the responses from the file specific for this client
|
||||
foreach($HD_RESPONSEST as $r) {
|
||||
|
||||
if ($r["depid"] == 0 || $r["depid"] == $JAK_FORM_DATA["depid"]) {
|
||||
|
||||
$phold = array("%operator%","%client%","%email%");
|
||||
$replace = array($jakuser->getVar("name"), $JAK_FORM_DATA["name"], JAK_EMAIL);
|
||||
$message = str_replace($phold, $replace, $r["message"]);
|
||||
|
||||
$JAK_RESPONSE_DATA[] = array("message" => base64_encode($message), "title" => $r["title"]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Get the custom fields if any
|
||||
$fields = array();
|
||||
$custom_fields = array();
|
||||
if ($JAK_FORM_DATA["depid"] != 0) {
|
||||
$depid = [0, $JAK_FORM_DATA["depid"]];
|
||||
} else {
|
||||
$depid = $JAK_FORM_DATA["depid"];
|
||||
}
|
||||
$formfields = $jakdb->select('customfields', "*", ["AND" => ["opid" => $opid, "fieldlocation" => 2, "depid" => $depid], "ORDER" => ["dorder" => "ASC"]]);
|
||||
|
||||
// Get the correct language
|
||||
$usrlang = $jakuser->getVar("language");
|
||||
if (!empty($usrlang) && $usrlang != JAK_LANG) {
|
||||
$translations = $jakdb->select('translations', ["customfieldid", "title", "description"], ["AND" => ["opid" => $opid, "lang" => $usrlang, "customfieldid[!]" => 0]]);
|
||||
}
|
||||
|
||||
// Custom fields
|
||||
$fieldoptions = array();
|
||||
if (isset($formfields) && !empty($formfields)) {
|
||||
|
||||
$JAK_CUSTOM_FIELD_DATA = $jakdb->get("support_tickets", "*", ["AND" => ["opid" => $opid, "id" => $ticketid]]);
|
||||
|
||||
foreach ($formfields as $v) {
|
||||
|
||||
|
||||
if ($v["fieldtype"] == 2 || $v["fieldtype"] == 3 || $v["fieldtype"] == 4) {
|
||||
$fieldoptions = explode(",", $v["field_html"]);
|
||||
// Set translation to false because it does not exist
|
||||
$tl = false;
|
||||
}
|
||||
|
||||
// Get the translation
|
||||
if (isset($translations) && !empty($translations)) foreach ($translations as $t) {
|
||||
if ($t["customfieldid"] == $v["id"]) {
|
||||
$v["title"] = $t["title"];
|
||||
if ($v["fieldtype"] == 2 || $v["fieldtype"] == 3 || $v["fieldtype"] == 4) {
|
||||
$fieldoptionstrans = explode(",", $t["description"]);
|
||||
$fieldoptions = array_combine($fieldoptions, $fieldoptionstrans);
|
||||
// Set translation to true because it does exist
|
||||
$tl = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fields[] = array("id" => $v["id"], "type" => $v["fieldtype"], "title" => $v["title"], "slug" => $v["val_slug"], "value" => $JAK_CUSTOM_FIELD_DATA[$v["val_slug"]], "options" => $fieldoptions);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($fields)) $custom_fields = $fields;
|
||||
|
||||
// Get the attachments if any
|
||||
$JAK_TICKET_FILES = $JAK_TICKET_FILE_ARRAY = $ticket = array();
|
||||
$JAK_FILES_PATH = BASE_URL.'_showfile.php?=';
|
||||
if ($JAK_FORM_DATA["attachments"] != 0) $JAK_TICKET_FILES = jak_get_files_encrypt(CLIENT_UPLOAD_DIR.'/'.$opcacheid.'/support/'.$ticketid);
|
||||
|
||||
if (isset($JAK_TICKET_FILES) && is_array($JAK_TICKET_FILES)) foreach($JAK_TICKET_FILES as $k) { if (getimagesize($k["path"])) {
|
||||
$JAK_TICKET_FILE_ARRAY[] = jak_encrypt_decrypt($k["encrypt"]);
|
||||
} }
|
||||
|
||||
if (isset($JAK_FORM_DATA) && !empty($JAK_FORM_DATA)) {
|
||||
|
||||
$ticket = array("id" => $JAK_FORM_DATA["id"], "subject" => $JAK_FORM_DATA["subject"], "content" => $JAK_FORM_DATA["content"], "depid" => $JAK_FORM_DATA["depid"], "operatorid" => $JAK_FORM_DATA["operatorid"], "clientid" => $JAK_FORM_DATA["clientid"], "private" => $JAK_FORM_DATA["private"], "status" => $JAK_FORM_DATA["status"], "notes" => $JAK_FORM_DATA["notes"], "ip" => $JAK_FORM_DATA["ip"], "referrer" => $JAK_FORM_DATA["referrer"], "attachments" => $JAK_FORM_DATA["attachments"], "initiated" => $JAK_FORM_DATA["initiated"], "ended" => $JAK_FORM_DATA["ended"], "updated" => $JAK_FORM_DATA["updated"], "priorityid" => $JAK_FORM_DATA["priorityid"], "toptionid" => $JAK_FORM_DATA["toptionid"], "department" => $JAK_FORM_DATA["title"], "clientname" => $JAK_FORM_DATA["name"], "clientemail" => $JAK_FORM_DATA["email"], "clientdep" => $JAK_FORM_DATA["support_dep"], "clientcredit" => $JAK_FORM_DATA["credits"], "clientpaid" => $JAK_FORM_DATA["paid_until"], "answers" => $JAK_ANSWER_DATA, "opall" => $OPERATOR_ALL, "depall" => $DEPARTMENTS_ALL, "priorityall" => $PRIORITY_ALL, "optionsall" => $TOPTIONS_ALL, "responseall" => $JAK_RESPONSE_DATA, "customfields" => $custom_fields, "files" => $JAK_TICKET_FILE_ARRAY, "filespath" => $JAK_FILES_PATH);
|
||||
|
||||
}
|
||||
|
||||
if (isset($ticket) && !empty($ticket)) {
|
||||
|
||||
// Take the chat go to chat
|
||||
die(json_encode(array('status' => true, 'ticket' => $ticket)));
|
||||
|
||||
} else {
|
||||
|
||||
// There is no data with this ticket
|
||||
die(json_encode(array('status' => false, 'task' => "ticket", 'errorcode' => 9)));
|
||||
}
|
||||
}
|
||||
|
||||
// Edit ticket
|
||||
if ($editticket && !empty($ticketid) && is_numeric($ticketid)) {
|
||||
|
||||
if (jak_row_exist($ticketid, "support_tickets")) {
|
||||
|
||||
$subjectf = filter_var($subject, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$contentf = jak_clean_safe_userpost($message);
|
||||
|
||||
// Update the ticket
|
||||
$jakdb->update("support_tickets", ["subject" => $subjectf, "content" => $contentf], ["AND" => ["opid" => $opcacheid, "id" => $ticketid]]);
|
||||
|
||||
// Deny transfer stay in queue
|
||||
die(json_encode(array('status' => true, 'task' => "editticket")));
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'task' => "editticket", 'errorcode' => 7)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Edit answer
|
||||
if ($editanswer && !empty($ticketid) && is_numeric($ticketid) && is_numeric($answerid)) {
|
||||
|
||||
if (jak_row_exist($ticketid, $opcacheid, "support_tickets")) {
|
||||
|
||||
$contentf = jak_clean_safe_userpost($message);
|
||||
|
||||
// Update the answer
|
||||
$jakdb->update("ticket_answers", ["content" => $contentf], ["id" => $answerid]);
|
||||
|
||||
// Deny transfer stay in queue
|
||||
die(json_encode(array('status' => true, 'task' => "editanswer")));
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'task' => "editanswer", 'errorcode' => 7)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Delete answer
|
||||
if ($deleteanswer && !empty($ticketid) && is_numeric($ticketid) && is_numeric($answerid)) {
|
||||
|
||||
if (jak_row_exist($ticketid, $opcacheid, "support_tickets")) {
|
||||
|
||||
// Delete the answer
|
||||
$jakdb->delete("ticket_answers", ["AND" => ["id" => $answerid, "ticketid" => $ticketid]]);
|
||||
|
||||
// Deny transfer stay in queue
|
||||
die(json_encode(array('status' => true, 'task' => "deleteanswer")));
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'task' => "deleteanswer", 'errorcode' => 7)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Delete ticket
|
||||
if ($deleteticket && !empty($ticketid) && is_numeric($ticketid)) {
|
||||
|
||||
if (JAK_SUPERADMINACCESS) {
|
||||
|
||||
// Delete the ticket
|
||||
$jakdb->delete("support_tickets", ["AND" => ["opid" => $opcacheid, "id" => $ticketid]]);
|
||||
|
||||
// Delete the answer
|
||||
$jakdb->delete("ticket_answers", ["ticketid" => $ticketid]);
|
||||
|
||||
// Delete all attachments
|
||||
$targetPath = APP_PATH.JAK_FILES_DIRECTORY.'/support/'.$ticketid.'/';
|
||||
$removedouble = str_replace("//","/",$targetPath);
|
||||
foreach(glob($removedouble.'*.*') as $jak_unlink) {
|
||||
// Delete all files
|
||||
@unlink($jak_unlink);
|
||||
}
|
||||
// Delete the folder
|
||||
@rmdir($targetPath);
|
||||
|
||||
// Deny transfer stay in queue
|
||||
die(json_encode(array('status' => true, 'task' => "deleteticket")));
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'task' => "deleteticket", 'errorcode' => 7)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1, 'errorcode' => false)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7, 'errorcode' => false)));
|
||||
?>
|
||||
+249
@@ -0,0 +1,249 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 2.0.2 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2022 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
// include the PHP library (if not autoloaded)
|
||||
require(APP_PATH.'class/class.emoji.php');
|
||||
|
||||
$userid = $loginhash = $chatid = $message = "";
|
||||
$task = false;
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
if (isset($_REQUEST['chatid']) && !empty($_REQUEST['chatid'])) $chatid = $_REQUEST['chatid'];
|
||||
if (isset($_REQUEST['task']) && !empty($_REQUEST['task'])) $task = $_REQUEST['task'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash) && !empty($chatid) && is_numeric($chatid)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
// Select the user fields
|
||||
$jakuser = new JAK_user($usr);
|
||||
|
||||
// Check if a sibling has logged in
|
||||
if ($jakuser->getVar("opid") != 0) {
|
||||
$opcacheid = $jakuser->getVar("opid");
|
||||
} else {
|
||||
$opcacheid = $jakuser->getVar("id");
|
||||
}
|
||||
|
||||
// Cache stuff
|
||||
if (file_exists(APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php')) include_once APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php';
|
||||
|
||||
// timezone from server
|
||||
date_default_timezone_set(JAK_TIMEZONESERVER);
|
||||
$jakdb->query('SET time_zone = "'.date("P").'"');
|
||||
|
||||
$USER_LANGUAGE = strtolower($jakuser->getVar("language"));
|
||||
|
||||
// Import the language file
|
||||
if ($USER_LANGUAGE && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$USER_LANGUAGE.'.php')) {
|
||||
include_once APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$USER_LANGUAGE.'.php';
|
||||
$lang = $USER_LANGUAGE;
|
||||
} else {
|
||||
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
|
||||
$lang = JAK_LANG;
|
||||
}
|
||||
|
||||
// Typing status
|
||||
if ($task == "typing") {
|
||||
|
||||
$result = $jakdb->update("checkstatus", ["typeo" => 1], ["convid" => $chatid]);
|
||||
|
||||
if ($result) {
|
||||
// Take the chat go to chat
|
||||
die(json_encode(array('status' => true, 'task' => "typing")));
|
||||
}
|
||||
|
||||
// Take the chat go to chat
|
||||
die(json_encode(array('status' => false, 'task' => 7)));
|
||||
|
||||
}
|
||||
|
||||
// Typing status false
|
||||
if ($task == "untyping") {
|
||||
|
||||
$result = $jakdb->update("checkstatus", ["typeo" => 0], ["convid" => $chatid]);
|
||||
|
||||
if ($result) {
|
||||
// Take the chat go to chat
|
||||
die(json_encode(array('status' => true, 'task' => "untyping")));
|
||||
}
|
||||
|
||||
// Take the chat go to chat
|
||||
die(json_encode(array('status' => false, 'task' => 7)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Save the message
|
||||
if ($task == "new") {
|
||||
|
||||
$message = trim($_REQUEST['message']);
|
||||
|
||||
if (!empty($message)) {
|
||||
|
||||
$row = $jakdb->get("checkstatus", ["convid", "hide"], ["convid" => $chatid]);
|
||||
|
||||
if (isset($row) && !empty($row)) {
|
||||
|
||||
// We sanitize the input
|
||||
$message = strip_tags($message);
|
||||
$message = filter_var($message, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$message = trim($message);
|
||||
|
||||
// Convert the smilies to shortcode
|
||||
$message = Emojione\Emojione::toShort($message);
|
||||
|
||||
if (!$row['hide']) {
|
||||
|
||||
// Check if we have to quote
|
||||
$msgquote = 0;
|
||||
if (isset($_REQUEST['msgid']) && !empty($_REQUEST['msgid']) && is_numeric($_REQUEST['msgid'])) $msgquote = $_REQUEST['msgid'];
|
||||
|
||||
$jakdb->insert("transcript", [
|
||||
"name" => $jakuser->getVar("name"),
|
||||
"message" => $message,
|
||||
"user" => $userid.'::'.$jakuser->getVar("username"),
|
||||
"operatorid" => $userid,
|
||||
"convid" => $row['convid'],
|
||||
"quoted" => $msgquote,
|
||||
"class" => "admin",
|
||||
"time" => $jakdb->raw("NOW()")]);
|
||||
|
||||
// Update the status after answer
|
||||
$jakdb->update("checkstatus", ["newc" => 1, "typeo" => 0, "newo" => 0, "statuso" => time()], ["convid" => $row['convid']]);
|
||||
|
||||
// Take the chat go to chat
|
||||
die(json_encode(array('status' => true, 'task' => "sendmsg")));
|
||||
|
||||
} elseif ($row['hide']) {
|
||||
|
||||
if (!empty($HD_ANSWERS) && is_array($HD_ANSWERS)) foreach ($HD_ANSWERS as $v) {
|
||||
|
||||
if ($v["msgtype"] == 4 && $v["lang"] == $lang) {
|
||||
|
||||
$phold = array("%operator%","%client%","%email%");
|
||||
$replace = array($jakuser->getVar("name"), $jakuser->getVar("username"), JAK_EMAIL);
|
||||
$message = str_replace($phold, $replace, $v["message"]);
|
||||
|
||||
$jakdb->insert("transcript", [
|
||||
"name" => $jakuser->getVar("name"),
|
||||
"message" => $message,
|
||||
"convid" => $row['convid'],
|
||||
"class" => "notice",
|
||||
"time" => $jakdb->raw("NOW()")]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Take the chat go to chat
|
||||
die(json_encode(array('status' => true, 'task' => "sendmsg")));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 11)));
|
||||
|
||||
}
|
||||
|
||||
// Edit a message
|
||||
if ($task == "edit") {
|
||||
|
||||
$message = trim($_REQUEST['message']);
|
||||
|
||||
if (!empty($message) && isset($_REQUEST['msgid']) && is_numeric($_REQUEST['msgid'])) {
|
||||
|
||||
// We sanitize the input
|
||||
$message = strip_tags($message);
|
||||
$message = filter_var($message, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$message = trim($message);
|
||||
|
||||
// update the message
|
||||
$jakdb->update("transcript", ["message" => $message, "editoid" => $userid, "edited" => $jakdb->raw("NOW()")], ["AND" => ["id" => $_REQUEST['msgid'], "convid" => $chatid]]);
|
||||
|
||||
// send to client
|
||||
$jakdb->update("checkstatus", ["msgedit" => $_REQUEST['msgid'], "typeo" => 0], ["convid" => $chatid]);
|
||||
|
||||
// Take the chat go to chat
|
||||
die(json_encode(array('status' => true, 'task' => "editmsg")));
|
||||
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
|
||||
}
|
||||
|
||||
// Starred Message
|
||||
if ($task == "starred") {
|
||||
|
||||
// message = starred
|
||||
if (isset($_REQUEST['message']) && isset($_REQUEST['msgid']) && is_numeric($_REQUEST['msgid'])) {
|
||||
|
||||
if ($_REQUEST['message'] == 1) {
|
||||
$starred = 0;
|
||||
} else {
|
||||
$starred = 1;
|
||||
}
|
||||
|
||||
$update = $jakdb->update("transcript", ["starred" => $starred], ["AND" => ["id" => $_REQUEST['msgid'], "convid" => $chatid]]);
|
||||
|
||||
// Take the chat go to chat
|
||||
die(json_encode(array('status' => true, 'task' => "starrmsg")));
|
||||
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
|
||||
}
|
||||
|
||||
// Delete a message
|
||||
if ($task == "delete") {
|
||||
|
||||
// message = plevel
|
||||
if (isset($_REQUEST['message']) && isset($_REQUEST['msgid']) && is_numeric($_REQUEST['msgid'])) {
|
||||
|
||||
if ($_REQUEST['message'] == 1) {
|
||||
$plevel = 2;
|
||||
} else {
|
||||
$plevel = 1;
|
||||
}
|
||||
|
||||
// Update the plevel in the transcript table
|
||||
$update = $jakdb->update("transcript", ["plevel" => $plevel], ["AND" => ["id" => $_REQUEST['msgid'], "convid" => $chatid]]);
|
||||
|
||||
// Update the status page
|
||||
$jakdb->update("checkstatus", ["typeo" => 0, "msgdel" => $_REQUEST['msgid']], ["convid" => $chatid]);
|
||||
|
||||
// Take the chat go to chat
|
||||
die(json_encode(array('status' => true, 'task' => "deletemsg")));
|
||||
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
?>
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 1.0.2 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = $ticketid = $attach = "";
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
if (isset($_REQUEST['ticketid']) && !empty($_REQUEST['ticketid'])) $ticketid = $_REQUEST['ticketid'];
|
||||
if (isset($_REQUEST['attach']) && !empty($_REQUEST['attach'])) $attach = $_REQUEST['attach'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
if (empty($ticketid) || empty($attach)) die(json_encode(array('status' => false, 'errorcode' => 2)));
|
||||
|
||||
$imgdata = base64_decode($attach);
|
||||
$im = imagecreatefromstring($imgdata);
|
||||
if ($im !== false) {
|
||||
|
||||
// if you need the image mime type
|
||||
$f = finfo_open();
|
||||
$mime = finfo_buffer($f, $imgdata, FILEINFO_MIME_TYPE);
|
||||
|
||||
if (($mime == "image/jpeg") || ($mime == "image/pjpeg") || ($mime == "image/png") || ($mime == "image/gif")) {
|
||||
|
||||
// first get the target path
|
||||
$targetPathd = CLIENT_UPLOAD_DIR.'/'.$opcacheid.'/support/'.$ticketid.'/';
|
||||
$targetPath = str_replace("//", "/", $targetPathd);
|
||||
|
||||
// Create the target path
|
||||
if (!is_dir($targetPath)) {
|
||||
mkdir($targetPath, 0755);
|
||||
copy(APP_PATH.JAK_FILES_DIRECTORY."/index.html", $targetPath . "/index.html");
|
||||
|
||||
}
|
||||
|
||||
// Get the correct ending.
|
||||
if ($mime == "image/jpeg" || $mime == "image/pjpeg") {
|
||||
$imend = ".jpg";
|
||||
} elseif ($mime == "image/gif") {
|
||||
$imend = ".gif";
|
||||
} else {
|
||||
$imend = ".png";
|
||||
}
|
||||
|
||||
$ufile = 'opfiletm_'.round(microtime(true)) . '.' . end($imend);
|
||||
|
||||
// The path to upload
|
||||
$targetFile = str_replace('//','/',$targetPath).$ufile;
|
||||
// The path to show
|
||||
$targetShow = BASE_URL.'_showfile.php?='.jak_encrypt_decrypt(str_replace('//', '/', '/'.$opcacheid.'/support/'.$ticketid.'/').$ufile.':#:'.$ufile.':#:'.$mime_type);
|
||||
|
||||
// Save as the correct ending
|
||||
if ($ufile == ".jpg") {
|
||||
imagejpeg($im, $targetFile);
|
||||
} elseif ($ufile == ".gif") {
|
||||
imagegif($im, $targetFile);
|
||||
} else {
|
||||
imagepng($im, $targetFile);
|
||||
}
|
||||
|
||||
imagedestroy($im);
|
||||
|
||||
// Update counter on ticket
|
||||
$jakdb->update("support_tickets", ["attachments[+]" => 1], ["id" => $ticketid]);
|
||||
|
||||
// Output the ticket
|
||||
die(json_encode(array('status' => true, 'newattach' => $targetShow, 'filename' => $ufile)));
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 2)));
|
||||
}
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 9)));
|
||||
}
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
?>
|
||||
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 1.0.2 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = "";
|
||||
$appactive = false;
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
if (isset($_REQUEST['appactive']) && !empty($_REQUEST['appactive'])) $appactive = $_REQUEST['appactive'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
if ($appactive) {
|
||||
|
||||
// Update User
|
||||
$jakdb->update("user", ["lastactivity" => time(), "session" => session_id()], ["id" => $userid]);
|
||||
|
||||
} else {
|
||||
|
||||
// Set to 0
|
||||
$jakdb->update("user", ["available" => 0], ["id" => $userid]);
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => true)));
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
?>
|
||||
@@ -0,0 +1,296 @@
|
||||
<?php
|
||||
|
||||
header("Cache-Control: no-cache, must-revalidate");
|
||||
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
|
||||
|
||||
/*===============================================*\
|
||||
|| ############################################# ||
|
||||
|| # JAKWEB.CH / Version 2.1.2 # ||
|
||||
|| # ----------------------------------------- # ||
|
||||
|| # Copyright 2023 JAKWEB All Rights Reserved # ||
|
||||
|| ############################################# ||
|
||||
\*===============================================*/
|
||||
|
||||
if (!file_exists('config.php')) die('rest_api config.php not exist');
|
||||
require_once 'config.php';
|
||||
|
||||
$userid = $loginhash = $chatid = "";
|
||||
$errors = $operator = $responses = $udepl = array();
|
||||
$task = false;
|
||||
$timeout = 180;
|
||||
if (isset($_REQUEST['userid']) && !empty($_REQUEST['userid']) && is_numeric($_REQUEST['userid'])) $userid = $_REQUEST['userid'];
|
||||
if (isset($_REQUEST['loginhash']) && !empty($_REQUEST['loginhash'])) $loginhash = $_REQUEST['loginhash'];
|
||||
if (isset($_REQUEST['chatid']) && !empty($_REQUEST['chatid'])) $chatid = $_REQUEST['chatid'];
|
||||
if (isset($_REQUEST['task']) && !empty($_REQUEST['task'])) $task = $_REQUEST['task'];
|
||||
|
||||
if (!empty($userid) && !empty($loginhash) && !empty($chatid) && is_numeric($chatid)) {
|
||||
|
||||
// Let's check if we are logged in
|
||||
$usr = $jakuserlogin->jakCheckrestlogged($userid, $loginhash);
|
||||
|
||||
if ($usr) {
|
||||
|
||||
// Select the user fields
|
||||
$jakuser = new JAK_user($usr);
|
||||
|
||||
// Check if a sibling has logged in
|
||||
if ($jakuser->getVar("opid") != 0) {
|
||||
$opcacheid = $jakuser->getVar("opid");
|
||||
} else {
|
||||
$opcacheid = $jakuser->getVar("id");
|
||||
}
|
||||
|
||||
// Cache stuff
|
||||
if (file_exists(APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php')) include_once APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php';
|
||||
|
||||
// timezone from server
|
||||
date_default_timezone_set(JAK_TIMEZONESERVER);
|
||||
$jakdb->query('SET time_zone = "'.date("P").'"');
|
||||
|
||||
$USER_LANGUAGE = strtolower($jakuser->getVar("language"));
|
||||
|
||||
// Import the language file
|
||||
if ($USER_LANGUAGE && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$USER_LANGUAGE.'.php')) {
|
||||
include_once APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$USER_LANGUAGE.'.php';
|
||||
} else {
|
||||
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
|
||||
}
|
||||
|
||||
// Send standard responds
|
||||
if ($task == "respond") {
|
||||
|
||||
if (empty($_REQUEST['respondid'])) {
|
||||
$errors['respondid'] = true;
|
||||
}
|
||||
|
||||
if (count($errors) == 0) {
|
||||
|
||||
$row = $jakdb->get("sessions", ["name", "operatorname", "department"], ["id" => $chatid]);
|
||||
|
||||
// get the responses from the file specific for this client
|
||||
foreach($HD_RESPONSES as $r) {
|
||||
|
||||
if ($r["id"] == $_REQUEST["respondid"]) {
|
||||
|
||||
$phold = array("%operator%","%client%","%email%");
|
||||
$replace = array($row['operatorname'], $row["name"], JAK_EMAIL);
|
||||
$message = str_replace($phold, $replace, $r["message"]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isset($message) && !empty($message)) {
|
||||
|
||||
$cs = $jakdb->get("checkstatus", "convid", ["convid" => $chatid]);
|
||||
|
||||
if (isset($row) && !empty($row)) {
|
||||
|
||||
// We sanitize the input
|
||||
$message = strip_tags($message);
|
||||
$message = filter_var($message, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
|
||||
$message = trim($message);
|
||||
|
||||
$jakdb->insert("transcript", [
|
||||
"name" => $jakuser->getVar("name"),
|
||||
"message" => $message,
|
||||
"user" => $userid.'::'.$jakuser->getVar("username"),
|
||||
"operatorid" => $userid,
|
||||
"convid" => $cs,
|
||||
"quoted" => 0,
|
||||
"class" => "admin",
|
||||
"time" => $jakdb->raw("NOW()")]);
|
||||
|
||||
// Update the status after answer
|
||||
$jakdb->update("checkstatus", ["newc" => 1, "typeo" => 0, "newo" => 0, "statuso" => time()], ["convid" => $cs]);
|
||||
|
||||
// Transfer success display message
|
||||
die(json_encode(array('status' => true, 'task' => "respond")));
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errors' => $errors)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// allow uploading files for the client
|
||||
if ($task == "file") {
|
||||
|
||||
$sendfile = $jakdb->get("checkstatus", "files", ["convid" => $chatid]);
|
||||
|
||||
if ($sendfile == 1) {
|
||||
$jakdb->update("checkstatus", ["files" => 0], ["convid" => $chatid]);
|
||||
// File upload off
|
||||
die(json_encode(array('status' => true, 'task' => "files", 'upload' => false)));
|
||||
|
||||
} else {
|
||||
$jakdb->update("checkstatus", ["files" => 1], ["convid" => $chatid]);
|
||||
// File upload on
|
||||
die(json_encode(array('status' => true, 'task' => "files", 'upload' => true)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// End the sessions
|
||||
if ($task == "end") {
|
||||
|
||||
// check to see if conversation has to be stored
|
||||
$row = $jakdb->get("sessions", ["id", "name", "email"], ["id" => $chatid]);
|
||||
|
||||
$jakdb->update("sessions", ["status" => 0, "ended" => time()], ["id" => $row['id']]);
|
||||
$jakdb->update("checkstatus", ["hide" => 1], ["convid" => $row['id']]);
|
||||
|
||||
$jakdb->insert("transcript", [
|
||||
"name" => $jakuser->getVar("name"),
|
||||
"message" => $jkl['g63'],
|
||||
"user" => $jakuser->getVar("id").'::'.$jakuser->getVar("username"),
|
||||
"operatorid" => $jakuser->getVar("id"),
|
||||
"convid" => $row['id'],
|
||||
"class" => "notice",
|
||||
"time" => $jakdb->raw("NOW()")]);
|
||||
|
||||
die(json_encode(array('status' => true, 'task' => "endsession")));
|
||||
|
||||
}
|
||||
|
||||
// Send a knock knock
|
||||
if ($task == "knock") {
|
||||
|
||||
$result = $jakdb->update("checkstatus", ["knockknock" => 1], ["convid" => $chatid]);
|
||||
|
||||
die(json_encode(array('status' => true, 'task' => "knock")));
|
||||
|
||||
}
|
||||
|
||||
// Send the transfer request
|
||||
if ($task == "transfer") {
|
||||
|
||||
if ($jakuser->getVar("transferc") == 0) die(json_encode(array('status' => false, 'errorcode' => 8)));
|
||||
|
||||
if (empty($_REQUEST['operator'])) {
|
||||
$errors['operator'] = true;
|
||||
}
|
||||
|
||||
if (empty($_REQUEST['transfermsg'])) {
|
||||
$errors['transfermsg'] = true;
|
||||
}
|
||||
|
||||
if (count($errors) == 0) {
|
||||
|
||||
// check to see if conversation has to be stored
|
||||
$toname = $jakdb->get("user", "name", ["id" => $_REQUEST['operator']]);
|
||||
|
||||
$msg = strip_tags($_REQUEST['transfermsg']);
|
||||
|
||||
$jakdb->insert("transfer", ["convid" => strval($chatid), "fromoid" => strval($jakuser->getVar("id")), "fromname" => $jakuser->getVar("name"), "tooid" => $_REQUEST['operator'], "toname" => $toname, "message" => $msg, "created" => $jakdb->raw("NOW()")]);
|
||||
|
||||
$lastid = $jakdb->id();
|
||||
|
||||
if ($lastid) {
|
||||
$jakdb->update("checkstatus", ["transferoid" => $_REQUEST['operator'], "transferid" => $lastid], ["convid" => $chatid]);
|
||||
}
|
||||
|
||||
// Transfer success display message and go back to queue
|
||||
die(json_encode(array('status' => true, 'task' => "transfer")));
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errors' => $errors)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Get the predefined messages plus online operators
|
||||
if ($jakuser->getVar("responses") == 1) {
|
||||
$depid = $jakdb->get("sessions", "department", ["id" => $chatid]);
|
||||
if (isset($depid) && !empty($depid) && isset($HD_RESPONSES) && is_array($HD_RESPONSES)) {
|
||||
|
||||
$responses[] = array('id' => 0, 'message' => $jkl["g7"]);
|
||||
|
||||
// get the responses from the file specific for this client
|
||||
foreach($HD_RESPONSES as $r) {
|
||||
|
||||
if ($r["department"] == 0 || $r["department"] == $depid) {
|
||||
|
||||
$responses[] = array('id' => $r['id'], 'message' => $r["title"]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
$responses[] = array('id' => 0, 'message' => $jkl["g7"]);
|
||||
}
|
||||
} else {
|
||||
$responses[] = array('id' => 0, 'message' => $jkl["e37"]);
|
||||
}
|
||||
|
||||
if ($jakuser->getVar("transferc") == 1) {
|
||||
|
||||
// Get all the operators
|
||||
$result = $jakdb->select("user", ["id", "chat_dep", "username", "name", "available", "lastactivity"], ["AND" => ["OR" => ["id" => $opcacheid, "opid" => $opcacheid], "access" => 1, "available" => 1, "id[!]" => $userid]]);
|
||||
|
||||
// Get departments
|
||||
$lsdata = $jakdb->select("departments", ["id", "title"], ["ORDER" => ["dorder" => "ASC"]]);
|
||||
|
||||
if (isset($result) && !empty($result)) {
|
||||
foreach ($result as $row) {
|
||||
|
||||
if (time() > ($row['lastactivity'] + $timeout)) {
|
||||
$jakdb->update("user", ["available" => 0], ["id" => $row['id']]);
|
||||
}
|
||||
|
||||
if ($row["chat_dep"] == 0) {
|
||||
$udep = $jkl['g105'];
|
||||
} else {
|
||||
|
||||
if (isset($lsdata) && is_array($lsdata)) foreach($lsdata as $z) {
|
||||
|
||||
if (in_array($z["id"], explode(',', $row["chat_dep"]))) {
|
||||
|
||||
$udepl[] = $z["title"];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!empty($udepl) && is_array($udepl)) $departmentlist = join(", ", $udepl);
|
||||
|
||||
if (isset($departmentlist) && $departmentlist) $udep = $jkl['m9'].': '.$departmentlist;
|
||||
|
||||
$operator[] = array('id' => strval($row['id']), 'operators' => $row['name'].' - '.$row['username'].' ('.$udep.')');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ($operator) {
|
||||
$oselect = $operator;
|
||||
|
||||
} else {
|
||||
$oselect[] = array('id' => 0, 'operators' => $jkl['g114']);
|
||||
}
|
||||
|
||||
} else {
|
||||
$oselect[] = array('id' => 0, 'operators' => $jkl['e37']);
|
||||
}
|
||||
|
||||
// Get the current upload status
|
||||
$sendfile = $jakdb->get("checkstatus", "files", ["convid" => $chatid]);
|
||||
|
||||
// PHP 8.2.3 Fix
|
||||
array_walk_recursive($responses, function (&$v) { $v = (string)$v; });
|
||||
array_walk_recursive($oselect, function (&$v) { $v = (string)$v; });
|
||||
|
||||
// Display the message content and location from the client
|
||||
die(json_encode(array('status' => true, 'responses' => $responses, 'operators' => $oselect, 'fileupload' => strval($sendfile))));
|
||||
|
||||
} else {
|
||||
die(json_encode(array('status' => false, 'errorcode' => 1)));
|
||||
}
|
||||
}
|
||||
|
||||
die(json_encode(array('status' => false, 'errorcode' => 7)));
|
||||
?>
|
||||
Reference in New Issue
Block a user