Initial Commit

This commit is contained in:
2024-02-08 12:07:49 -07:00
parent 5813b1109f
commit 43077b57ed
5471 changed files with 682195 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 1.2 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2021 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[config.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (!file_exists('../../class/ssp.class.php')) die('ajax/[ssp.class.php] config.php not exist');
require_once '../../class/ssp.class.php';
// Where get only the operator specific messages
$where = "opid = ".$opcacheid;
// DB table to use
$table = JAKDB_PREFIX.'blog';
// Table's primary key
$primaryKey = 'id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array( 'db' => 'id', 'dbjoin' => 'id', 'dt' => 0 ),
array( 'db' => 'id', 'dbjoin' => 'id', 'dt' => 1, 'formatter' => function( $d, $row ) {
return '<input type="checkbox" name="jak_delete_blogs[]" class="highlight" value="'.$d.':#:'.$row['active'].'">';
} ),
array( 'db' => 'title', 'dbjoin' => 'title', 'dt' => 2, 'formatter' => function( $d, $row ) {
return '<a class="btn btn-sm btn-primary" href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('blog', 'edit', $row['id'])).'">'.$d.'</a>';
} ),
array( 'db' => 'lang', 'dbjoin' => 'lang', 'dt' => 3 ),
array( 'db' => 'content', 'dbjoin' => 'content', 'dt' => 4, 'formatter' => function( $d, $row ) {
return jak_cut_text($d, 100, "...");
} ),
array( 'db' => 'dorder', 'dbjoin' => 'dorder', 'dt' => 5 ),
array( 'db' => 'active', 'dbjoin' => 'active', 'dt' => 6, 'formatter' => function( $d, $row ) {
return ($d == 1 ? '<i class="fa fa-check"></i>' : '<i class="fa fa-times"></i>');
} ),
array( 'db' => 'time', 'dbjoin' => 'time', 'dt' => 7, 'formatter' => function( $d, $row ) {
return JAK_base::jakTimesince($d, JAK_DATEFORMAT, JAK_TIMEFORMAT);
} )
);
die(json_encode(SSP::simple( $_GET, $table, $primaryKey, $columns, $where )));
?>
+92
View File
@@ -0,0 +1,92 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 1.0 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[oprequests.php] config.php not exist');
require_once '../../config.php';
if(!isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
$switchc = '';
if (isset($_POST['cal-action']) && !empty($_POST['cal-action'])) $switchc = $_POST['cal-action'];
// Back to dashboard
$backtodash = str_replace('ajax/', '', BASE_URL);
switch ($switchc) {
case 'cal-new':
# code
if (isset($_POST['cal-title']) && !empty($_POST['cal-title'])) {
$startdate = date('Y-m-d H:i:s ', strtotime($_POST['cal-start']));
$enddate = date('Y-m-d H:i:s ', strtotime($_POST['cal-end']));
$result = $jakdb->insert("events", ["opid" => $opcacheid, "title" => $_POST['cal-title'], "content" => $_POST['cal-content'], "color" => $_POST['cal-color'], "start" => $startdate, "end" => $enddate, "lastedit" => $jakdb->raw("NOW()"), "created" => $jakdb->raw("NOW()")]);
if ($result) {
$_SESSION["successmsg"] = $jkl['g14'];
jak_redirect($backtodash);
}
}
$_SESSION["errormsg"] = $jkl['i4'];
jak_redirect($backtodash);
break;
case 'cal-edit':
# code...
if (isset($_POST['cal-id']) && is_numeric($_POST['cal-id']) && $jakdb->has("events", ["id" => $_POST['cal-id']]) && isset($_POST['cal-title']) && !empty($_POST['cal-title'])) {
if (isset($_POST['cal-delete']) && $_POST['cal-delete'] == 1) {
$jakdb->delete("events", ["id" => $_POST['cal-id']]);
} else {
$startdate = date('Y-m-d H:i:s ', strtotime($_POST['cal-start']));
$enddate = date('Y-m-d H:i:s ', strtotime($_POST['cal-end']));
if ($jakdb->update("events", ["title" => $_POST['cal-title'], "content" => $_POST['cal-content'], "color" => $_POST['cal-color'], "start" => $startdate, "end" => $enddate, "lastedit" => $jakdb->raw("NOW()")], ["AND" => ["id" => $_POST['cal-id'], "opid" => $opcacheid]])) {
}
}
$_SESSION["successmsg"] = $jkl['g14'];
jak_redirect($backtodash);
}
$_SESSION["errormsg"] = $jkl['i'];
jak_redirect($backtodash);
break;
case 'cal-date':
# code...
if (isset($_POST['cal-id']) && is_numeric($_POST['cal-id']) && $jakdb->has("events", ["id" => $_POST['cal-id']])) {
// Datefromat
$startdate = date('Y-m-d H:i:s ', strtotime($_POST['cal-start']));
$enddate = date('Y-m-d H:i:s ', strtotime($_POST['cal-end']));
if ($jakdb->update("events", ["start" => $startdate, "end" => $enddate], ["AND" => ["id" => $_POST['cal-id'], "opid" => $opcacheid]])) {
die(json_encode(array('status' => 1)));
}
}
die(json_encode(array('status' => 0)));
break;
default:
# code...
die(json_encode(array('status' => 0)));
}
?>
+517
View File
@@ -0,0 +1,517 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 2.1.4 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2023 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[oprequests.php] config.php not exist');
require_once '../../config.php';
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (!is_numeric($_POST['uid']) && !is_numeric($_POST['convid'])) die("There is no such conversation");
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
$switchc = '';
if (isset($_POST['creq']) && !empty($_POST['creq'])) $switchc = $_POST['creq'];
switch ($switchc) {
case 'info':
# code
$row = $jakdb->get("sessions", ["[>]departments" => ["department" => "id"], "[>]buttonstats" => ["session" => "session"], "[>]checkstatus" => ["id" => "convid"], "[>]chatwidget" => ["widgetid" => "id"]], ["sessions.id", "sessions.department", "sessions.operatorid", "sessions.clientid", "sessions.usr_avatar", "sessions.name", "sessions.email", "sessions.country", "sessions.city", "sessions.latitude", "sessions.longitude", "sessions.countrycode", "sessions.lang", "sessions.initiated", "sessions.operatorname", "sessions.credits", "sessions.status", "departments.title(dep_title)", "buttonstats.referrer", "buttonstats.firstreferrer", "buttonstats.agent", "buttonstats.hits", "buttonstats.ip", "checkstatus.files", "chatwidget.title(widget_title)"], ["AND" => ["sessions.id" => $_POST['convid'], "sessions.opid" => $opcacheid]]);
if (isset($row) && !empty($row)) {
// Reset
$showphone = $showemail = $responses = $transferc = $knockknock = $endsess = $usrf = $blockip = '';
// Show standard flag
$usrc = $row['ip'];
// Show country code
if (isset($row['countrycode']) && !empty($row['countrycode']) && $row['countrycode'] != 'xx') $usrc = '<img src="'.str_replace("ajax/", "", BASE_URL).'img/blank.png" class="flag flag-'.$row['countrycode'].'" alt="'.$row['country'].'" title="'.$row['country'].' - '.$row['city'].'"> '.$row['ip'];
// Show email
if (filter_var($row['email'], FILTER_VALIDATE_EMAIL)) $showemail = '<p class="text-muted"><i class="fa fa-envelope-o"></i> '.$row['email'].'</p>';
// Chat is active
if ($row["status"]) {
// Show files
$usrf = '<a href="javascript:void(0)" class="btn btn-info btn-sm" onclick="usrFiles('.$row['id'].');" id="user_files"><i class="fa fa-lock"></i> '.$jkl['u9'].'</a>';
// Allowed to send files
if ($row['files']) $usrf = ' <a href="javascript:void(0)" class="btn btn-info btn-sm" onclick="usrFiles('.$row['id'].');" id="user_files"><i class="fa fa-check"></i> '.$jkl['u9'].'</a>';
$knockknock = ' <a data-toggle="modal" class="btn btn-primary btn-sm" href="'.BASE_URL.'knockknock.php?id='.$row['id'].'" data-target="#jakModal"><i class="fa fa-bell"></i> '.$jkl['g223'].'</a>';
// Can transfer clients
if ($jakuser->getVar("transferc")) $transferc = '<a data-toggle="modal" class="btn btn-warning btn-sm" href="'.BASE_URL.'transfer.php?id='.$row['id'].'&amp;userid='.$row['operatorid'].'" data-target="#jakModal"><i class="fa fa-share-alt"></i> '.$jkl['g286'].'</a>';
// end session
$endsess = ' <a data-toggle="modal" class="btn btn-danger btn-sm" href="'.BASE_URL.'delconv.php?id='.$row['id'].'" data-target="#jakModal"><i class="fa fa-power-off"></i> '.$jkl['g62'].'</a>';
}
// get the client button
if ($row['clientid'] != 0) {
$isclient = ' <a class="btn btn-rose btn-sm" href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('users', 'clients', 'edit', $row['clientid'])).'"><i class="fa fa-user"></i> '.$jkl['g287'].'</a>';
} else {
$isclient = ' <a class="btn btn-rose btn-sm" href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('users', 'clients', 'new', 'chat', $row['id'])).'"><i class="fa fa-user"></i> '.$jkl['hd112'].'</a>';
}
// Let's check if the ip is valid
if (filter_var($row["ip"], FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
$blockip = ' <a href="javascript:void(0)" class="btn btn-danger btn-sm" onclick="usrBan('.$row['id'].',\''.$row['ip'].'\')" id="user_ban"><i class="fa fa-ban"></i> '.$jkl['g348'].'</a>';
}
$clientinfo = '<div class="info-side-messages">';
$clientinfo .= '<div class="media">
<img class="d-flex mr-3 img-thumbnail" src="'.str_replace(JAK_OPERATOR_LOC."/ajax/", "", BASE_URL.$row['usr_avatar']).'" width="53" height="53" alt="'.$row['name'].'">
<div class="media-body">
<h4 class="media-heading">'.$row['name'].'</h4>
<div class="media-text">
<p class="text-muted"><i class="fa fa-clock-o"></i> '.JAK_base::jakTimesince($row['initiated'], "", JAK_TIMEFORMAT).' | <i class="fa fa-globe"></i> '.$usrc.' | <i class="fa fa-eye"></i> '.$row['hits'].'</p>
'.$showemail.'
<p class="text-muted"><i class="far fa-browser"></i> '.$row['widget_title'].'</p>
<p class="text-muted"><i class="fa fa-university"></i> '.(isset($row["dep_title"]) && !empty($row["dep_title"]) ? $row["dep_title"] : '-').'</p>
<p class="text-muted"><i class="fa fa-language"></i> '.(!empty($row['lang']) ? strtoupper($row['lang']) : '-').'</p>
'.(JAK_BILLING_MODE == 1 && $row["credits"] != 0 ? '<p class="text-muted"><i class="fa fa-gamepad"></i> '.sprintf($jkl['hd232'], $row["credits"]).'</p>' : '').'
<p class="text-muted"><i class="fa fa-laptop"></i> '.$row['agent'].'</p>
<p class="text-muted"><i class="fa fa-link"></i> '.$row['referrer'].'</p>
</div>
</div>
</div>
<hr>';
$clientinfo .= '<p>'.$usrf.$knockknock.$isclient.$blockip.'</p><p> <a data-toggle="modal" class="btn btn-success btn-sm" href="'.str_replace("ajax/", "", JAK_rewrite::jakParseurl('notes', $row['id'])).'" data-target="#jakModal"><i class="fa fa-comments"></i> '.$jkl['g181'].'</a> '.$transferc.$endsess.'</p>
<hr>';
if (JAK_SHOW_IPS && $row['latitude']) {
$clientinfo .= '<div id="cmap_canvas" style="height: 300px;"></div><script type="text/javascript">
var cmap = L.map("cmap_canvas", {zoomControl:true}).setView(['.$row['latitude'].','.$row['longitude'].'], 8);
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
attribution: \'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, \' +
\'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>\'
}).addTo(cmap);
// Disable drag and zoom handlers.
cmap.dragging.disable();
cmap.touchZoom.disable();
cmap.doubleClickZoom.disable();
cmap.scrollWheelZoom.disable();
var marker = L.marker(['.$row['latitude'].','.$row['longitude'].']).addTo(cmap);
marker.bindPopup("'.$row['country'].' | '.$row['city'].'").openPopup();
</script>';
}
$clientinfo .= '</div>';
die(json_encode(array('status' => 1, 'html' => $clientinfo, 'title' => $jkl['g40'], 'icon' => 'info')));
}
die(json_encode(array('status' => 0, 'text' => $jkl['i2'])));
break;
case 'edit':
# code...
$row = $jakdb->get("sessions", ["id", "operatorid", "department", "lang", "name", "email", "phone", "notes"], ["AND" => ["id" => $_POST['convid'], "opid" => $opcacheid]]);
if (isset($row) && !empty($row)) {
// The language list
$allang = "";
foreach(jak_the_lang() as $k => $l) {
$allang .= '<option value="'.$k.'"'.(isset($row['lang']) && $row['lang'] != 0 && $row['lang'] == $k ? ' selected' : '').'>'.$l.'</option>';
}
// Get all departments
$alldep = '<option value="0">'.$jkl["g105"].'</option>';
if (isset($HD_DEPARTMENTS) && is_array($HD_DEPARTMENTS)) foreach($HD_DEPARTMENTS as $z) {
$alldep .= '<option value="'.$z["id"].'"'.(isset($row['department']) && $row['department'] != 0 && $row['department'] == $z["id"] ? ' selected' : '').'>'.$z["title"].'</option>';
}
$editclient = '<div class="info-side-messages"><form id="cNotes" method="post" action="'.$_SERVER['REQUEST_URI'].'">';
// Department
$editclient .= '<div class="form-group">
<label class="control-label" for="department">'.$jkl["g131"].'</label>
<select name="jak_depid" id="department" class="selectpicker col-12">
'.$alldep.'
</select>
</div><input type="hidden" name="olddepid" value"'.$row['department'].'">';
// Language
$editclient .= '<div class="form-group">
<label class="control-label" for="language">'.$jkl["g22"].'</label>
<select name="jak_lang" id="language" class="selectpicker col-12" data-live-search="true">
'.$allang.'
</select>
</div>';
// Name
$editclient .= '<div class="form-group">
<label class="control-label" for="name">'.$jkl["g54"].'</label>
<input type="text" name="name" id="name" class="form-control" value="'.$row['name'].'">
</div>';
// Email
$editclient .= '<div class="form-group">
<label class="control-label" for="email">'.$jkl['u1'].'</label>
<input type="text" name="email" id="email" class="form-control" value="'.$row['email'].'">
</div>';
// Phone
$editclient .= '<div class="form-group">
<label class="control-label" for="phone">'.$jkl['u14'].'</label>
<input type="text" name="phone" id="phone" class="form-control" value="'.$row['phone'].'">
</div>';
// Notes
$editclient .= '<div class="form-group">
<label class="control-label" for="note">'.$jkl["g181"].'</label>
<textarea rows="5" name="note" id="note" class="form-control">'.$row['notes'].'</textarea>
</div>';
$editclient .= '<button type="submit" id="formsubmit" class="btn btn-primary btn-block">'.$jkl["g38"].'</button><input type="hidden" name="edit_customer" value="1"><input type="hidden" name="uid" value="'.$row['operatorid'].'"><input type="hidden" name="convid" id="convid" value="'.$row['id'].'"></form><script>var jsurl = "'.str_replace("ajax/", "", BASE_URL."js/notes.js").'";$.getScript(jsurl);</script>';
$editclient .= '</div>';
die(json_encode(array('status' => 1, 'html' => $editclient, 'title' => $jkl['g287'], 'icon' => "person")));
}
die(json_encode(array('status' => 0, 'text' => $jkl['i2'])));
break;
case 'search':
# code...
$searchmsg = '<div class="info-side-messages">';
// Name
$searchmsg .= '<div class="form-group">
<label class="sr-only" for="name">'.$jkl["s5"].'</label>
<input type="text" name="name" id="name" class="form-control" onkeyup="showResult(this.value,'.$_POST['convid'].')" placeholder="'.$jkl["s5"].'">
</div>';
$searchmsg .= '<div id="livesearch"></div>';
$searchmsg .= '<script>var jsurl = "'.str_replace("ajax/", "", BASE_URL."js/search.js").'";$.getScript(jsurl);</script>';
$searchmsg .= '</div>';
die(json_encode(array('status' => 1, 'html' => $searchmsg, 'title' => $jkl['s6'], 'icon' => 'search')));
break;
case 'files':
# code...
$result = $jakdb->select("transcript", ["[>]user" => ["operatorid" => "id"], "[>]sessions" => ["convid" => "id"]], ["transcript.id", "transcript.name", "transcript.message", "transcript.operatorid", "transcript.time", "transcript.class", "transcript.quoted", "transcript.edited", "transcript.editoid", "transcript.convid", "user.picture", "sessions.usr_avatar"], ["AND" => ["transcript.convid" => $_POST['convid'], "transcript.class" => "download", "sessions.opid" => $opcacheid], "ORDER" => ["transcript.id" => "ASC"]]);
if (isset($result) && !empty($result)) {
// Get the absolute url for the image
$base_url = str_replace(JAK_OPERATOR_LOC.'/ajax/', '', BASE_URL);
$sharedfiles = '<div class="info-side-messages">';
foreach ($result as $row) {
// On which class to show a system image
$systemimg = array("bot", "notice", "url", "ended");
$oimage = str_replace(JAK_OPERATOR_LOC."/ajax/", "", BASE_URL.$row["usr_avatar"]);
if ($row["picture"] && $row["operatorid"]) $oimage = str_replace(JAK_OPERATOR_LOC."/ajax/", "", BASE_URL.JAK_FILES_DIRECTORY.$row["picture"]);
if (in_array($row["class"], $systemimg)) $oimage = str_replace(JAK_OPERATOR_LOC."/ajax/", "", BASE_URL.JAK_FILES_DIRECTORY."/system.jpg");
// Convert the message into something nice
$message = $row['message'];
$lightbox = "";
// Split message
$splitmsg = explode(":#:", $message);
if (file_exists(CLIENT_UPLOAD_DIR.$splitmsg[0])) {
// Get the file
$theupfile = $base_url.'_showfile.php?i='.jak_encrypt_decrypt($splitmsg[0].':#:'.$splitmsg[1].':#:'.$splitmsg[2]);
// We have an image
if (getimagesize(CLIENT_UPLOAD_DIR.$splitmsg[0])) {
$message = '<a href="'.$theupfile.'" data-toggle="lightbox" data-type="image"><img src="'.$theupfile.'" class="img-thumbnail img-fluid chat-img" alt="chat-img"></a>';
} else {
$message = '<a href="'.$theupfile.'" target="_blank"><i class="fa fa-download"></i> '.basename($splitmsg[1]).'</a>';
}
} else {
$message = $jkl['i16'];
}
$sharedfiles .= '<div class="media">
<img class="d-flex mr-3 img-thumbnail" src="'.$oimage.'" width="53" height="53" alt="'.$row['name'].'">
<div class="media-body">
<h4 class="media-heading">'.$row['name'].' <small>'.JAK_base::jakTimesince($row['time'], "", JAK_TIMEFORMAT).($row['editoid'] ? ' | <i class="fa fa-edit"></i> '.JAK_base::jakTimesince($row['edited'], "", JAK_TIMEFORMAT) : '').'</small>'.(!in_array($row["class"], $systemimg) ? ' <div class="chat-edit"><a href="javascript:void(0)" class="chat-edit-link clipboard" data-clipboard-target="#msg'.$row['id'].'"><i class="fa fa-clipboard"></i></a></div>' : '').'</h4>
<div class="media-text">'.stripcslashes($message).'</div>
</div>
</div>
<hr>';
}
$sharedfiles .= '</div>';
die(json_encode(array('status' => 1, 'html' => $sharedfiles, 'title' => $jkl['g288'], 'icon' => 'attach_file')));
} else {
// Nothing available
die(json_encode(array('status' => 0, 'text' => $jkl["i3"])));
}
break;
case 'starred':
# code...
$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.edited", "transcript.editoid", "transcript.convid", "user.picture", "sessions.usr_avatar"], ["AND" => ["transcript.convid" => $_POST['convid'], "transcript.starred" => 1, "sessions.opid" => $opcacheid], "ORDER" => ["transcript.id" => "ASC"]]);
if (isset($result) && !empty($result)) {
// include the PHP library (if not autoloaded)
require('../../class/class.emoji.php');
$starredmsg = '<div class="info-side-messages">';
foreach ($result as $row) {
// On which class to show a system image
$systemimg = array("bot", "notice", "url", "ended", "download");
$oimage = str_replace(JAK_OPERATOR_LOC."/ajax/", "", BASE_URL.$row["usr_avatar"]);
if ($row["picture"] && $row["operatorid"]) $oimage = str_replace(JAK_OPERATOR_LOC."/ajax/", "", BASE_URL.JAK_FILES_DIRECTORY.$row["picture"]);
if (in_array($row["class"], $systemimg)) $oimage = str_replace(JAK_OPERATOR_LOC."/ajax/", "", BASE_URL.JAK_FILES_DIRECTORY."/system.jpg");
// We convert the br
$message = nl2br($row['message'], false);
// we have file
if ($row['class'] == "download") {
// Split message
$splitmsg = explode(":#:", $message);
if (file_exists(CLIENT_UPLOAD_DIR.$splitmsg[0])) {
// Get the file
$theupfile = $base_url.'_showfile.php?i='.jak_encrypt_decrypt($splitmsg[0].':#:'.$splitmsg[1].':#:'.$splitmsg[2]);
// We have an image
if (getimagesize(CLIENT_UPLOAD_DIR.$splitmsg[0])) {
$messageemoji = '<a href="'.$theupfile.'" data-toggle="lightbox" data-type="image"><img src="'.$theupfile.'" class="img-thumbnail img-fluid chat-img" alt="chat-img"></a>';
} else {
$messageemoji = '<a href="'.$theupfile.'" target="_blank"><i class="fa fa-download"></i> '.basename($splitmsg[1]).'</a>';
}
} else {
$messageemoji = $jkl['i16'];
}
} else {
// We convert the urls
$messageemoji = replace_urls($message);
}
// Convert emotji
$messageemoji = Emojione\Emojione::toImage($messageemoji);
// Get the quote msg
$quotemsg = '';
if ($row['quoted']) {
$quotemsg = $jakdb->get("transcript", "message", ["id" => $row["quoted"]]);
// Convert urls
$quotemsg = nl2br(replace_urls($quotemsg), false);
// Convert emotji
$quotemsg = Emojione\Emojione::toImage($quotemsg);
}
$starredmsg .= '<div class="media">
<img class="d-flex mr-3 img-thumbnail" src="'.$oimage.'" width="53" height="53" alt="'.$row['name'].'">
<div class="media-body">
<h4 class="media-heading">'.$row['name'].' <small>'.JAK_base::jakTimesince($row['time'], "", JAK_TIMEFORMAT).($row['editoid'] ? ' | <i class="fa fa-edit"></i> '.JAK_base::jakTimesince($row['edited'], "", JAK_TIMEFORMAT) : '').'</small>'.(!in_array($row["class"], $systemimg) ? ' <div class="chat-edit"><a href="javascript:void(0)" class="chat-edit-link clipboard" data-clipboard-target="#msg'.$row['id'].'"><i class="fa fa-clipboard"></i></a> <a href="javascript:void(0)" class="edit-starred" data-id="'.$row['id'].'" data-starred="'.$row['starred'].'"><i class="fa fa-star'.($row['starred'] ? '' : '-o').'"></i></a></div>' : '').'</h4>
<div class="media-text">'.($row['quoted'] ? '<blockquote class="blockquote"><i class="fa fa-reply"></i> '.$quotemsg.'</blockquote>' : '').stripcslashes($messageemoji).'</div>
</div>
</div>
<hr>';
}
$starredmsg .= '</div>';
die(json_encode(array('status' => 1, 'html' => $starredmsg, 'title' => $jkl['g275'], 'icon' => 'star')));
} else {
// Nothing available
die(json_encode(array('status' => 0, 'text' => $jkl["i3"])));
}
break;
case 'faq':
# code...
$faq_url = false;
$department = $jakdb->get("sessions", "department", ["AND" => ["id" => $_POST['convid'], "opid" => $opcacheid, "operatorid" => $_POST['uid']]]);
if ($department) {
foreach ($HD_DEPARTMENTS as $d) {
if (in_array($department, $d)) {
if ($d['faq_url']) $faq_url = $d['faq_url'];
}
}
}
if ($faq_url) {
$loadiframe = '<iframe seamless="seamless" class="faq-frame" frameborder="0" src="'.$faq_url.'"></iframe>';
die(json_encode(array('status' => 1, 'html' => $loadiframe, 'title' => $jkl['hd1'], 'icon' => 'help_outline')));
}
// Nothing worked cancel
die(json_encode(array('status' => 0, 'text' => $jkl["i2"])));
break;
case 'history':
# code...
$row = $jakdb->get("sessions", ["name", "email"], ["AND" => ["id" => $_POST['convid'], "opid" => $opcacheid]]);
if (isset($row) && !empty($row)) {
$email = '';
if (filter_var($row['email'], FILTER_VALIDATE_EMAIL)) $email = $row['email'];
$oldsessions = $jakdb->select("sessions", ["id", "name", "initiated"], ["OR #c" => ["AND #first" => ["id[!]" => $_POST['convid'], "name" => $row["name"], "opid" => $opcacheid], "AND #second" => ["id[!]" => $_POST['convid'], "email" => $email, "opid" => $opcacheid]], "ORDER" => ["initiated" => "DESC"], "LIMIT" => 5]);
if (isset($oldsessions) && !empty($oldsessions)) {
// include the PHP library (if not autoloaded)
require('../../class/class.emoji.php');
$historymsg = '<div class="info-side-messages"><div class="accordion" id="chat_history">';
foreach ($oldsessions as $rows) {
$historymsg .= '<div class="card card-body">
<h4 class="card-title">
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#collapse'.$rows["id"].'">'.$rows["name"].'</button>
<span class="badge badge-dark pull-right">'.JAK_base::jakTimesince($rows['initiated'], JAK_DATEFORMAT, JAK_TIMEFORMAT).'</span>
</h4>
<div id="collapse'.$rows["id"].'" class="collapse" data-parent="#chat_history">
<div class="panel-body history-chat">';
$chatmsg = $jakdb->select("transcript", ["[>]user" => ["operatorid" => "id"], "[>]sessions" => ["convid" => "id"]], ["transcript.id", "transcript.name", "transcript.message", "transcript.operatorid", "transcript.time", "transcript.class", "transcript.quoted", "transcript.edited", "transcript.editoid", "transcript.convid", "user.picture", "sessions.usr_avatar"], ["transcript.convid" => $rows['id'], "ORDER" => ["transcript.id" => "ASC"]]);
if (isset($chatmsg) && !empty($chatmsg)) {
foreach ($chatmsg as $z) {
// On which class to show a system image
$systemimg = array("bot", "notice", "url", "ended");
$oimage = str_replace(JAK_OPERATOR_LOC."/ajax/", "", BASE_URL.$z["usr_avatar"]);
if ($z["picture"] && $z["operatorid"]) $oimage = str_replace(JAK_OPERATOR_LOC."/ajax/", "", BASE_URL.JAK_FILES_DIRECTORY.$z["picture"]);
if (in_array($z["class"], $systemimg)) $oimage = str_replace(JAK_OPERATOR_LOC."/ajax/", "", BASE_URL.JAK_FILES_DIRECTORY."/system.jpg");
// We convert the urls/br
$message = nl2br(replace_urls($z['message']), false);
// Convert emotji
$messageemoji = Emojione\Emojione::toImage($message);
// Get the quote msg
$quotemsg = '';
if ($z['quoted']) {
$quotemsg = $jakdb->get("transcript", "message", ["id" => $z["quoted"]]);
// Convert urls
$quotemsg = nl2br(replace_urls($quotemsg), false);
// Convert emotji
$quotemsg = Emojione\Emojione::toImage($quotemsg);
}
$historymsg .= '<div class="media">
<img class="d-flex mr-3 img-thumbnail" src="'.$oimage.'" width="53" height="53" alt="'.$z['name'].'"></a>
<div class="media-body">
<h4 class="media-heading">'.$z['name'].' <small>'.JAK_base::jakTimesince($z['time'], "", JAK_TIMEFORMAT).($z['editoid'] ? ' | <i class="fa fa-edit"></i> '.JAK_base::jakTimesince($row['edited'], "", JAK_TIMEFORMAT) : '').'</small></h4>
<div class="media-text">'.($z['quoted'] ? '<blockquote class="blockquote"><i class="fa fa-reply"></i> '.$quotemsg.'</blockquote>' : '').stripcslashes($messageemoji).'</div>
</div>
</div>
<hr>';
}
}
$historymsg .= '</div>
</div>
</div>';
}
$historymsg .= '</div>';
die(json_encode(array('status' => 1, 'html' => $historymsg, 'title' => $jkl['m1'], 'icon' => 'history')));
}
}
// Nothing available
die(json_encode(array('status' => 0, 'text' => $jkl["i3"])));
break;
default:
# code...
// Save client data
if (isset($_POST['edit_customer']) && is_numeric($_POST['convid'])) {
$jkp = $_POST;
$namechange = false;
$username = $jakdb->get("sessions", "name", ["AND" => ["id" => $jkp['convid'], "opid" => $opcacheid]]);
// Filter the new name
$newname = filter_var(jak_input_filter($jkp['name']), FILTER_SANITIZE_FULL_SPECIAL_CHARS);
// Do we have a new name
if (isset($newname) && $newname != $username) $namechange = true;
// Change the name
if ($namechange) $jakdb->update("transcript", ["name" => $newname], ["AND" => ["convid" => $jkp['convid'], "class" => "user"]]);
// Now we have maybe a change in the department
if ($jkp['jak_depid'] != $jkp['olddepid']) {
// Let's figure out the new name from the department
$newdeptitle = $jakdb->get("departments", "title", ["id" => $jkp['jak_depid']]);
// Update the databases
$jakdb->update("checkstatus", ["depid" => $jkp['jak_depid'], "department" => $newdeptitle], ["convid" => $jkp['convid']]);
$jakdb->update("sessions", ["department" => $jkp['jak_depid']], ["AND" => ["id" => $jkp['convid'], "opid" => $opcacheid]]);
// We will run the new name change process
$namechange = true;
}
// Finally we change the rest of the session values
$result = $jakdb->update("sessions", ["lang" => $jkp['jak_lang'], "name" => $newname, "email" => filter_var($jkp['email'], FILTER_SANITIZE_EMAIL), "phone" => filter_var($jkp['phone'], FILTER_SANITIZE_NUMBER_INT), "notes" => filter_var($jkp['note'], FILTER_SANITIZE_FULL_SPECIAL_CHARS)], ["AND" => ["id" => $jkp['convid'], "opid" => $opcacheid]]);
// We can update the status to changed
$jakdb->update("checkstatus", ["datac" => 1], ["convid" => $jkp['convid']]);
if ($result) {
// Ajax Request
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
header('Cache-Control: no-cache');
die(json_encode(array('status' => 1, 'namechange' => $namechange, 'label' => "name")));
}
} else {
// Ajax Request
if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) {
header('Cache-Control: no-cache');
die(json_encode(array('status' => 2, 'txt' => $jkl['i'])));
}
}
}
break;
}
?>
+54
View File
@@ -0,0 +1,54 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 2.0.4 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2022 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[config.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (!file_exists('../../class/ssp.class.php')) die('ajax/[ssp.class.php] config.php not exist');
require_once '../../class/ssp.class.php';
// Where get only the operator specific messages
$where = 'opid = '.$opcacheid;
// DB table to use
$table = JAKDB_PREFIX.'clients';
$table2 = '';
// Table's primary key
$primaryKey = 'id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array( 'db' => 'id', 'dbjoin' => 'id', 'dt' => 0 ),
array( 'db' => 'id', 'dbjoin' => 'id', 'dt' => 1, 'formatter' => function( $d, $row ) {
return '<input type="checkbox" name="jak_delock_all[]" class="highlight" value="'.$d.':#:'.$row['access'].'">';
} ),
array( 'db' => 'name', 'dbjoin' => 'name', 'dt' => 2, 'formatter' => function( $d, $row ) {
return '<a class="btn btn-sm btn-primary" href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('users', 'clients', 'edit', $row['id'])).'">'.$d.'</a>';
} ),
array( 'db' => 'email', 'dbjoin' => 'email', 'dt' => 3 ),
array( 'db' => 'credits', 'dbjoin' => 'credits', 'dt' => 4 ),
array( 'db' => 'paid_until', 'dbjoin' => 'paid_until', 'dt' => 5, 'formatter' => function( $d, $row ) {
return ($d != '1980-05-06' ? JAK_base::jakTimesince($d, JAK_DATEFORMAT, '') : '-');
} ),
array( 'db' => 'access', 'dbjoin' => 'access', 'dt' => 6, 'formatter' => function( $d, $row ) {
return ($d == 1 ? '<i class="fa fa-check"></i>' : '<i class="fa fa-times"></i>');
} ),
array( 'db' => 'lastactivity', 'dbjoin' => 'lastactivity', 'dt' => 7, 'formatter' => function( $d, $row ) {
return ($d != 0 ? JAK_base::jakTimesince($d, JAK_DATEFORMAT, JAK_TIMEFORMAT) : '-');
} )
);
die(json_encode(SSP::simple( $_GET, $table, $primaryKey, $columns, $where )));
?>
+53
View File
@@ -0,0 +1,53 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 2.0.5 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2022 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[config.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (!file_exists('../../class/ssp.class.php')) die('ajax/[ssp.class.php] config.php not exist');
require_once '../../class/ssp.class.php';
// Where get only the operator specific messages
$where = "t1.opid = ".$opcacheid;
// DB table to use
$table = JAKDB_PREFIX.'contacts AS t1';
$table2 = ' LEFT JOIN '.JAKDB_PREFIX.'departments AS t2 ON (t1.depid = t2.id)';
// Table's primary key
$primaryKey = 't1.id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array( 'db' => 't1.id', 'dbjoin' => 'id', 'dt' => 0 ),
array( 'db' => 't1.id', 'dbjoin' => 'id', 'dt' => 1, 'formatter' => function( $d, $row ) {
return '<input type="checkbox" name="jak_delete_contacts[]" class="highlight" value="'.$d.'">';
} ),
array( 'db' => 't1.name', 'dbjoin' => 'name', 'dt' => 2, 'formatter' => function( $d, $row ) {
return '<a class="btn btn-sm btn-primary" data-toggle="modal" href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('contacts', 'readmsg', $row['id'], 1)).'" data-target="#jakModal">'.(isset($d) && !empty($d) ? $d : '-').'</a>';
} ),
array( 'db' => 't1.email', 'dbjoin' => 'email', 'dt' => 3, 'formatter' => function( $d, $row ) {
return (filter_var($d, FILTER_VALIDATE_EMAIL) ? '<a class="btn btn-sm btn-primary" data-toggle="modal" href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('contacts', 'readmsg', $row['id'], 1)).'" data-target="#jakModal">'.$d.'</a>' : '-');
} ),
array( 'db' => 't1.answered', 'dbjoin' => 'answered', 'dt' => 4, 'formatter' => function( $d, $row ) {
return ($d != "1980-05-06 00:00:00" ? JAK_base::jakTimesince($d, JAK_DATEFORMAT, JAK_TIMEFORMAT) : '-');
} ),
array( 'db' => 't1.sent', 'dbjoin' => 'sent', 'dt' => 5, 'formatter' => function( $d, $row ) {
return JAK_base::jakTimesince($d, JAK_DATEFORMAT, JAK_TIMEFORMAT);
} )
);
die(json_encode(SSP::join( $_GET, $table, $table2, '', $primaryKey, $columns, $where, $where )));
?>
+38
View File
@@ -0,0 +1,38 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 2.1.2 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2023 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[available.php] config.php not exist');
require_once '../../config.php';
if(!isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
if (is_numeric($_GET['id'])) {
echo '<div class="modal-header"><h4 class="modal-title">'.JAK_TITLE.'</h4><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button></div>
<div class="modal-body"><div class="padded-box"><form method="post" action="'.str_replace('ajax/', '', BASE_URL).'index.php">';
echo '<p>'.$jkl['e35'].'</p>';
echo '
<input type="hidden" name="id" id="id" value="'.$_GET['id'].'" />
<button class="btn btn-danger btn-block" type="submit" name="delete_conv" value="delete">'.$jkl['g19'].'</button>
</form></div></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">'.$jkl["g180"].'</button>
</div>';
}
?>
+85
View File
@@ -0,0 +1,85 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 1.2 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2021 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[config.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
// Short-circuit if the client did not give us a date range.
if (!isset($_GET['start']) || !isset($_GET['end'])) {
die("Please provide a date range.");
}
// Set NULL
$events = array();
// Parse the start/end parameters.
// These are assumed to be ISO8601 strings with no time nor timezone, like "2013-12-29".
// Since no timezone will be present, they will parsed as UTC.
$range_start = $_GET['start'];
$range_end = $_GET['end'];
// Get the entries out the database
$eventsrange = $jakdb->select("events", ["id", "content", "color", "start", "end", "title"], ["AND" => ["opid" => $opcacheid, "start[>]" => $range_start, "end[<]" => $range_end]]);
if (isset($eventsrange) && !empty($eventsrange)) foreach ($eventsrange as $row) {
// font color
if (in_array($row["color"], array("#000000", "#0071c5", "#FF0000", "#008000"))) {
$fcolor = "#ffffff";
} else {
$fcolor = "#333333";
}
$events[] = array('id' => $row['id'], 'title' => $row["title"], 'content' => $row["content"], 'start' => $row["start"], 'end' => $row["end"], 'color' => $row["color"], 'textColor' => $fcolor);
}
// We load the tickets in this period
if (JAK_CALENDAR_TICKETS && jak_get_access("support", $jakuser->getVar("permissions"), JAK_MAIN_OP)) {
$ticketrange = $jakdb->select("support_tickets", ["id", "subject", "name", "initiated"], ["AND" => ["opid" => $opcacheid, "initiated[>]" => strtotime($range_start), "ended[<]" => strtotime($range_end)]]);
if (isset($ticketrange) && !empty($ticketrange)) foreach ($ticketrange as $row) {
$events[] = array('title' => $row["subject"].' - '.$row["name"], 'url' => str_replace('ajax/', '', JAK_rewrite::jakParseurl('support', 'read', $row['id'])), 'start' => date("Y-m-d H:i:s", $row["initiated"]), 'end' => date("Y-m-d H:i:s", ($row["initiated"] + 3600)), 'color' => "#d649d8", 'editable' => false);
}
}
// We load the chats in this period
if (JAK_CALENDAR_CHATS && jak_get_access("leads_all", $jakuser->getVar("permissions"), JAK_MAIN_OP)) {
$chatrange = $jakdb->select("sessions", ["id", "name", "initiated"], ["AND" => ["opid" => $opcacheid, "initiated[>]" => strtotime($range_start), "ended[<]" => strtotime($range_end)]]);
if (isset($chatrange) && !empty($chatrange)) foreach ($chatrange as $row) {
$events[] = array('title' => $row["name"], 'url' => str_replace('ajax/', '', JAK_rewrite::jakParseurl('live', $row['id'])), 'start' => date("Y-m-d H:i:s", $row["initiated"]), 'end' => date("Y-m-d H:i:s", ($row["initiated"] + 3600)), 'color' => "#49abd8", 'editable' => false);
}
}
// We load the offline messages in this period
if (JAK_CALENDAR_OFFLINE && jak_get_access("off_all", $jakuser->getVar("permissions"), JAK_MAIN_OP)) {
$offrange = $jakdb->select("contacts", ["name", "email", "sent"], ["AND" => ["opid" => $opcacheid, "sent[>=]" => $range_start, "sent[<=]" => $range_end]]);
if (isset($offrange) && !empty($offrange)) foreach ($offrange as $row) {
$enddate = new DateTime($row["sent"]);
$enddate->modify('+1 hour');
$events[] = array('title' => $row["name"].' - '.$row["email"], 'url' => str_replace('ajax/', '', JAK_rewrite::jakParseurl('contacts')), 'start' => $row["sent"], 'end' => $enddate->format('Y-m-d H:i:s'), 'color' => "#d88c49", 'editable' => false);
}
}
// We load the payments in this period
if (JAK_CALENDAR_PURCHASES && jak_get_access("billing", $jakuser->getVar("permissions"), JAK_MAIN_OP)) {
$ticketrange = $jakdb->select("subscriptions_client", ["[>]clients" => ["clientid" => "id"]], ["subscriptions_client.clientid", "subscriptions_client.paidwhen", "clients.name", "clients.email"], ["AND" => ["subscriptions_client.opid" => $opcacheid, "subscriptions_client.success" => 1, "subscriptions_client.paidwhen[>=]" => $range_start, "subscriptions_client.paidwhen[<=]" => $range_end]]);
if (isset($ticketrange) && !empty($ticketrange)) foreach ($ticketrange as $row) {
$enddate = new DateTime($row["paidwhen"]);
$enddate->modify('+1 hour');
$events[] = array('title' => $row["name"].' - '.$row["email"], 'url' => str_replace('ajax/', '', JAK_rewrite::jakParseurl('users', 'clients', 'edit', $row['clientid'])), 'start' => $row["paidwhen"], 'end' => $enddate->format('Y-m-d H:i:s'), 'color' => "#71d849", 'editable' => false);
}
}
die(json_encode($events));
?>
+56
View File
@@ -0,0 +1,56 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 2.0.5 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2022 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[config.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (!file_exists('../../class/ssp.class.php')) die('ajax/[ssp.class.php] config.php not exist');
require_once '../../class/ssp.class.php';
// Where get only the operator specific messages
$where = "t1.opid = ".$opcacheid;
// DB table to use
$table = JAKDB_PREFIX.'faq_article AS t1';
$table2 = ' LEFT JOIN '.JAKDB_PREFIX.'faq_categories AS t2 ON (t1.catid = t2.id)';
// Table's primary key
$primaryKey = 't1.id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array( 'db' => 't1.id', 'dbjoin' => 'id', 'dt' => 0 ),
array( 'db' => 't1.id', 'dbjoin' => 'id', 'dt' => 1, 'formatter' => function( $d, $row ) {
return '<input type="checkbox" name="jak_delete_faqs[]" class="highlight" value="'.$d.':#:'.$row['active'].':#:'.$row['catid'].'">';
} ),
array( 'db' => 't1.title', 'dbjoin' => 'title', 'dt' => 2, 'formatter' => function( $d, $row ) {
return '<a class="btn btn-sm btn-primary" href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('faq', 'edit', $row['id'])).'">'.$d.'</a>';
} ),
array( 'db' => 't1.lang', 'dbjoin' => 'lang', 'dt' => 3 ),
array( 'db' => 't2.title AS deptitle', 'dbjoin' => 'deptitle', 'dt' => 4, 'formatter' => function( $d, $row ) {
return (isset($d) ? '<a href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('departments', 'faq', 'edit', $row['id'])).'">'.$d.'</a>' : '-');
} ),
array( 'db' => 't1.dorder', 'dbjoin' => 'dorder', 'dt' => 5 ),
array( 'db' => 't1.active', 'dbjoin' => 'active', 'dt' => 6, 'formatter' => function( $d, $row ) {
return ($d == 1 ? '<i class="fa fa-check"></i>' : '<i class="fa fa-times"></i>');
} ),
array( 'db' => 't1.time', 'dbjoin' => 'time', 'dt' => 7, 'formatter' => function( $d, $row ) {
return JAK_base::jakTimesince($d, JAK_DATEFORMAT, JAK_TIMEFORMAT);
} ),
array( 'db' => 'catid', 'dbjoin' => 'catid', 'dt' => 'mid' )
);
die(json_encode(SSP::join( $_GET, $table, $table2, '', $primaryKey, $columns, $where, $where )));
?>
View File
+147
View File
@@ -0,0 +1,147 @@
<?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 2021 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[available.php] config.php not exist');
require_once '../../config.php';
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
$lang = $_SESSION['jak_lcp_lang'];
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
$lang = JAK_LANG;
}
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die(json_encode(array('status' => 0, "html" => $jkl['g79'])));
if ($_POST['conv'] == "open" || (!is_numeric($_POST['id']) && !is_numeric($_POST['uid']))) die(json_encode(array('status' => 0, "html" => $jkl['g79'])));
// We sanitize the input
$message = strip_tags($_POST['msg']);
$message = filter_var($message, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$message = trim($message);
// Check for empty message
if (empty($message)) die(json_encode(array('status' => 0, "html" => $jkl['e1'])));
// Check for duplicate messages
if (isset($_SESSION["oplastmsg"]) && $_SESSION["oplastmsg"] == $message) die(json_encode(array("status" => 0, "html" => $jkl['e45'])));
$row = $jakdb->get("checkstatus", ["convid", "hide"], ["convid" => $_POST['id']]);
if (isset($row) && !empty($row)) {
define('BASE_URL_IMG', str_replace(JAK_OPERATOR_LOC.'/ajax/', '', BASE_URL));
if (!$row['hide']) {
if (isset($_POST['msgedit']) && !empty($_POST['msgedit']) && is_numeric($_POST['msgedit'])) {
// include the PHP library (if not autoloaded)
require('../../class/class.emoji.php');
// update the message
$jakdb->update("transcript", ["message" => $message, "editoid" => $_POST['userid'], "edited" => $jakdb->raw("NOW()")], ["AND" => ["id" => $_POST['msgedit'], "convid" => $row['convid']]]);
// send to client
$jakdb->update("checkstatus", ["msgedit" => $_POST['msgedit'], "typeo" => 0], ["convid" => $row['convid']]);
// Show the edited symbol with the date
$showedit = ' | <i class="fa fa-edit"></i> '.JAK_base::jakTimesince(time(), "", JAK_TIMEFORMAT);
// We convert the urls/br
$messageemoji = nl2br(replace_urls($message), false);
$messageemoji = Emojione\Emojione::toImage($messageemoji);
die(json_encode(array('status' => 1, 'edit' => $messageemoji, 'editblank' => $message, 'editid' => $_POST['msgedit'], 'showedit' => $showedit)));
} else {
// Check if we have to quote
$msgquote = 0;
if (isset($_POST['msgquote']) && !empty($_POST['msgquote']) && is_numeric($_POST['msgquote'])) $msgquote = $_POST['msgquote'];
// Check if we have a short code for the message.
if (!empty($HD_RESPONSES) && is_array($HD_RESPONSES)) foreach ($HD_RESPONSES as $r) {
if ($message == $r["short_code"]) {
$message = $r["message"];
break;
}
}
// the last message in a session
$_SESSION["oplastmsg"] = $message;
$jakdb->insert("transcript", [
"name" => $_POST['oname'],
"message" => $message,
"user" => $_POST['userid'].'::'.$_POST['uname'],
"operatorid" => $_POST['userid'],
"convid" => $row['convid'],
"quoted" => $msgquote,
"class" => "admin",
"time" => $jakdb->raw("NOW()")]);
if (!empty($_POST['url'])) {
$jakdb->insert("transcript", [
"name" => $_POST['oname'],
"message" => $_POST['url'],
"user" => $_POST['userid'].'::'.$_POST['uname'],
"operatorid" => $_POST['userid'],
"convid" => $row['convid'],
"class" => "url",
"plevel" => 1,
"time" => $jakdb->raw("NOW()")]);
}
// Update the status after answer
$jakdb->update("checkstatus", ["newc" => 1, "typeo" => 0, "newo" => 0, "statuso" => time()], ["convid" => $row['convid']]);
}
die(json_encode(array('status' => 1, 'edit' => false)));
} 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($_POST['oname'], $_POST['uname'], JAK_EMAIL);
$message = str_replace($phold, $replace, $v["message"]);
$jakdb->insert("transcript", [
"name" => $_POST['oname'],
"message" => $message,
"convid" => $row['convid'],
"class" => "notice",
"time" => $jakdb->raw("NOW()")]);
}
}
die(json_encode(array('status' => 1, 'edit' => false)));
} else {
die(json_encode(array('status' => 0, "html" => $jkl['e1'])));
}
}
?>
+44
View File
@@ -0,0 +1,44 @@
<?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('ajax/[invitation.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (!is_numeric($_POST['id']) && !is_numeric($_POST['uid'])) die("There is no such thing!");
$result = $jakdb->update("buttonstats", ["opid" => $_POST['uid'], "message" => $_POST['msg'], "readtime" => 0], ["id" => $_POST['id']]);
// Now let us delete and recreate the proactive cache file
$proactivefile = APP_PATH.JAK_CACHE_DIRECTORY.'/mproactive.php';
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, '')) {
echo json_encode(array('status' => 1));
} else {
echo json_encode(array('status' => 0));
}
?>
+47
View File
@@ -0,0 +1,47 @@
<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 3.1.2 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[usronline.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (!is_numeric($_GET['id'])) die("There is no such thing!");
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
$result = $jakdb->update("checkstatus", ["knockknock" => 1], ["convid" => $_GET['id']]);
if ($result) {
echo '<div class="modal-header"><h4 class="modal-title">'.$jkl['g223'].'</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</div>
<div class="modal-body"><div class="padded-box"><div class="alert alert-success">'.$jkl['g14'].'</div></div></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">'.$jkl["g180"].'</button>
</div>';
} else {
echo '<div class="modal-header"><h4 class="modal-title">'.$jkl['g223'].'</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</div>
<div class="modal-body"><div class="padded-box"><div class="alert alert-error">'.$jkl['sql'].'</div></div></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">'.$jkl["g180"].'</button>
</div>';
}
?>
+59
View File
@@ -0,0 +1,59 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 2.0.2 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2022 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[config.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (!file_exists('../../class/ssp.class.php')) die('ajax/[ssp.class.php] config.php not exist');
require_once '../../class/ssp.class.php';
$where = "t1.opid = ".$opcacheid;
if (!jak_get_access("leads_all", $jakuser->getVar("permissions"), $jakuser->jakSuperadminaccess($jakuser->getVar("id")))) $where = " AND t1.operatorid = ".$jakuser->getVar("id");
// DB table to use
$table = JAKDB_PREFIX.'sessions AS t1';
$table2 = ' LEFT JOIN '.JAKDB_PREFIX.'user AS t2 ON (t1.operatorid = t2.id)';
$table3 = ' LEFT JOIN '.JAKDB_PREFIX.'departments AS t3 ON (t1.department = t3.id)';
// Table's primary key
$primaryKey = 't1.id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array( 'db' => 't1.id', 'dbjoin' => 'id', 'dt' => 0 ),
array( 'db' => 't1.id', 'dbjoin' => 'id', 'dt' => 1, 'formatter' => function( $d, $row ) {
return '<input type="checkbox" name="jak_delete_leads[]" class="highlight" value="'.$d.'">';
} ),
array( 'db' => 't1.name', 'dbjoin' => 'name', 'dt' => 2, 'formatter' => function( $d, $row ) {
return '<a class="btn btn-sm btn-primary" data-toggle="modal" href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('leads', 'readleads', $row['id'], 1)).'" data-target="#jakModal"><i class="fa fa-envelope"></i></a> <a class="btn btn-sm btn-info" href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('support', 'new', 'chat', $row['id'])).'"><i class="fa fa-ticket"></i></i></a> <a class="btn btn-sm btn-rose" href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('live', $row['id'])).'">'.$d.'</i></a>';
} ),
array( 'db' => 't1.email', 'dbjoin' => 'email', 'dt' => 3, 'formatter' => function( $d, $row ) {
return (filter_var($d, FILTER_VALIDATE_EMAIL) ? '<a data-toggle="modal" href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('leads', 'clientcontact', $row['id'], 1)).'" data-target="#jakModal">'.$d.'</i></a>' : '-');
} ),
array( 'db' => 't2.username', 'dbjoin' => 'username', 'dt' => 4 ),
array( 'db' => 't3.title', 'dbjoin' => 'title', 'dt' => 5 ),
array( 'db' => 't1.notes', 'dbjoin' => 'notes', 'dt' => 6, 'formatter' => function( $d, $row ) {
return '<a class="btn'.(!empty($d) ? ' btn-success' : ' btn-default').' btn-sm" data-toggle="modal" href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('notes', $row['id'])).'" data-target="#jakModal"><i class="fa fa-sticky-note"></i></a>';
} ),
array( 'db' => 't1.deniedoid', 'dbjoin' => 'deniedoid', 'dt' => 7, 'formatter' => function( $d, $row ) {
return ($d ? '<span class="badge badge-danger"><i class="fa fa-file-alt"></i></span>' : '<span class="badge badge-dark"><i class="fa fa-comments"></i></span>');
} ),
array( 'db' => 't1.initiated', 'dbjoin' => 'initiated', 'dt' => 8, 'formatter' => function( $d, $row ) {
return JAK_base::jakTimesince($d, JAK_DATEFORMAT, JAK_TIMEFORMAT);
} )
);
die(json_encode(SSP::join( $_GET, $table, $table2, $table3, $primaryKey, $columns, $where, $where )));
?>
+93
View File
@@ -0,0 +1,93 @@
<?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('ajax/[usronline.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
// Get the current time
$currentime = time();
if (!is_numeric($_GET['oid'])) die("There is no such thing!");
switch ($_GET['case']) {
case 'typing':
if (isset($_GET['ticketid']) && isset($_GET['oid'])) {
$jakdb->update("ticket_live_user", ["lastvisit" => time(), "istyping" => 1], ["AND" => ["opid" => $opcacheid, "ticketid" => $_GET['ticketid'], "userid" => $_GET['oid']]]);
}
die(json_encode(array('status' => 1)));
break;
case 'nottyping':
if (isset($_GET['ticketid']) && isset($_GET['oid'])) {
$jakdb->update("ticket_live_user", ["lastvisit" => time(), "istyping" => 0], ["AND" => ["opid" => $opcacheid, "ticketid" => $_GET['ticketid'], "userid" => $_GET['oid']]]);
}
die(json_encode(array('status' => 1)));
break;
case 'live':
if (isset($_GET['ticketid']) && isset($_GET['oid'])) {
// Update the operator that is currently in the ticket
$jakdb->update("ticket_live_user", ["lastvisit" => time()], ["AND" => ["opid" => $opcacheid, "ticketid" => $_GET['ticketid'], "userid" => $_GET['oid']]]);
// the last 5 minutes
$checkLastmin = time() - 300;
$result = $jakdb->select("ticket_live_user", ["userid", "clientid", "istyping", "lastvisit"], ["AND" => ["opid" => $opcacheid, "ticketid" => $_GET['ticketid'], "userid[!]" => $_GET['oid'], "lastvisit[>]" => $checkLastmin], "ORDER" => ["lastvisit" => "DESC"], "LIMIT" => 5]);
}
$opticketlive = "";
if (isset($result) && !empty($result)) foreach ($result as $row) {
# code...
if ($row["userid"] != 0) {
$user = $jakdb->get("user", ["username", "name", "picture"], ["id" => $row["userid"]]);
$picture = $user["picture"];
$name = $user["name"].' <small>('.$user["username"].')</small>';
} else {
$client = $jakdb->get("clients", ["email", "name", "picture"], ["id" => $row["clientid"]]);
$picture = $client["picture"];
$name = $client["name"].' <small>('.$client["email"].')</small>';
}
$opticketlive .= '<div class="media"><img src="'.str_replace(JAK_OPERATOR_LOC."/ajax/", "", BASE_URL.JAK_FILES_DIRECTORY.$picture).'" class="mr-3 rounded-circle'.(isset($row["istyping"]) && $row["istyping"] == 1 ? ' border border-danger' : '').'" width="53" alt="'.$name.'"><div class="media-body"><h5 class="mt-0 mb-0">'.$name.'</h5><p>'.(isset($row["istyping"]) && $row["istyping"] == 1 ? $jkl['g143'] : '').'</p></div></div><hr>';
}
die(json_encode(array("status" => 1, "onlineList" => $opticketlive)));
break;
default:
die(json_encode(array("status" => 0)));
}
?>
+64
View File
@@ -0,0 +1,64 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 1.2 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2021 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[config.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (!file_exists('../../class/ssp.class.php')) die('ajax/[ssp.class.php] config.php not exist');
require_once '../../class/ssp.class.php';
// Only show the correct entries
if (JAK_MAIN_OP) {
$where = "t1.opid IN ('0','".$opcacheid."')";
} else {
$where = "t1.opid = ".$opcacheid;
}
// DB table to use
$table = JAKDB_PREFIX.'whatslog AS t1';
$table2 = ' LEFT JOIN '.JAKDB_PREFIX.'user AS t2 ON (t1.operatorid = t2.id)';
// Table's primary key
$primaryKey = 't1.id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array( 'db' => 't1.id', 'dbjoin' => 'id', 'dt' => 0 ),
array( 'db' => 't1.id', 'dbjoin' => 'id', 'dt' => 1, 'formatter' => function( $d, $row ) {
return '<input type="checkbox" name="jak_delete_logs[]" class="highlight" value="'.$d.'">';
} ),
array( 'db' => 't1.whatsid', 'dbjoin' => 'whatsid', 'dt' => 2, 'formatter' => function( $d, $row ) {
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include (APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include (APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
return sprintf($jkl["wl".$d], '<strong>'.(isset($row["username"]) ? $row["username"] : (isset($row["email"]) ? $row["email"] : $row["name"])).'</strong>');
} ),
array( 'db' => 't1.fromwhere', 'dbjoin' => 'fromwhere', 'dt' => 3, 'formatter' => function( $d, $row ) {
return '<a href="'.$row["fromwhere"].'" class="btn btn-sm btn-info" data-toggle="tooltip" data-placement="top" title="'.$row["fromwhere"].'"><i class="fa fa-link"></i></a> <a href="javascript:void(0)" class="btn btn-sm btn-info" data-toggle="tooltip" data-placement="top" title="'.$row["usragent"].'"><i class="far fa-browser"></i></a> <a href="javascript:void(0)" class="btn btn-sm btn-info" data-toggle="tooltip" data-placement="top" title="'.$row["ip"].'"><i class="fa fa-globe"></i></a> <a href="javascript:void(0)" class="btn btn-sm btn-info" data-toggle="tooltip" data-placement="top" title="'.$row['country'].'"><i class="fa fa-flag"></i></a>';
} ),
array( 'db' => 't1.time', 'dbjoin' => 'time', 'dt' => 4, 'formatter' => function( $d, $row ) {
return JAK_base::jakTimesince($d, JAK_DATEFORMAT, JAK_TIMEFORMAT);
} ),
array( 'db' => 't1.usragent', 'dbjoin' => 'usragent', 'dt' => 'usra' ),
array( 'db' => 't1.ip', 'dbjoin' => 'ip', 'dt' => 'ip' ),
array( 'db' => 't1.country', 'dbjoin' => 'country', 'dt' => 'cou' ),
array( 'db' => 't2.username', 'dbjoin' => 'username', 'dt' => 'usr' ),
array( 'db' => 't1.name', 'dbjoin' => 'name', 'dt' => 'name' )
);
die(json_encode(SSP::join( $_GET, $table, $table2, "", $primaryKey, $columns, $where, $where )));
?>
+203
View File
@@ -0,0 +1,203 @@
<?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 2021 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[usronline.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
// User is on idle let's check if there is a new client
if (isset($_GET['id']) && $_GET['id'] == "check_only" && is_numeric($_GET['opid'])) {
// Now let us add the active chat file so the operator can come online.
$chatsfile = APP_PATH.JAK_CACHE_DIRECTORY.'/chats'.$opcacheid.'.txt';
if (file_exists($chatsfile)) {
$trimmed = file($chatsfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($trimmed as $v) {
$opid = explode(":#:", $v);
// Check if we have a chat request
if ($opid[2] == $_GET['opid'] && $opid[0] > (time() - 10)) {
$nopid[] = $opid[1].":#:".$opid[3];
} else {
$nopid = false;
}
}
// If we have forward the new window array
if (is_array($nopid)) {
die(json_encode(array("startcalling" => true, "win" => $nopid)));
} else {
// Nothing to do, keep idle.
die(json_encode(array("startcalling" => false)));
}
} else {
// Nothing to do, keep idle.
die(json_encode(array("startcalling" => false)));
}
}
if (!is_numeric($_POST['uid'])) die("There is no such thing!");
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
$sent_time = time() - OPERATOR_CHAT_EXPIRE;
$print_offline = '';
switch ($_POST['page']) {
case 'load-msg':
// Check if the Operater is still available
$available = $jakdb->has("user", ["AND" => ["id" => $_POST['partner_id'], "available" => 1]]);
if (!$available) {
$print_offline = '<li class="list-group-item error">'.$jkl["g139"].'</li>';
}
// A few vars
$unreadmsg = false;
$chatmsg = "";
// Load messages
$resultu = $jakdb->select("operatorchat", "*", ["AND #check" => ["OR #first" => ["fromid" => $_POST['uid'], "toid" => $_POST['uid']], "OR #second" => ["operatorchat.fromid" => $_POST['opid'], "operatorchat.toid" => $_POST['opid']], "opid" => $opcacheid, "sent[>]" => $sent_time, "msgpublic" => 0], "ORDER" => ["sent" => "ASC"]]);
if (isset($resultu) && !empty($resultu)) {
foreach ($resultu as $rowu) {
// check if current user has unreceived messages which are older than limit, if yes, display it with date
if ($rowu["sent"] < $sent_time AND $rowu["received"] == 0) {
$updatesqla .= sprintf("WHEN %d THEN '%s' ", $rowu['id'], time());
$updatesqla1 .= sprintf("WHEN %d THEN '%s' ", $rowu['id'], 1);
$alloid[] = $rowu['id'];
$unreadmsg = true;
}
// Load Messages
if (($rowu["fromid"] == $_POST['uid'] && $rowu["toid"] == $_POST['partner_id']) || ($rowu["fromid"] == $_POST['partner_id'] && $rowu["toid"] == $_POST['uid'])) {
//print messages
if ($rowu['system_message'] != 'no') {
$chatmsg .= '<li class="list-group-item system">'. stripcslashes($rowu['message']).'</li>';
} elseif ($rowu['fromid'] != $_POST['uid']) {
$chatmsg .= '<li class="list-group-item me">'.$rowu['message'].'</li>';
} else {
$chatmsg .= '<li class="list-group-item">'.$rowu['message'].'</li>';
}
// If message has been received mark it!
if ($rowu['toid'] == $_POST['uid']) {
$jakdb->update("operatorchat", ["received" => 1], ["AND" => ["id" => $rowu['id'], "opid" => $opcacheid, "received" => 0]]);
}
$last_msg = $rowu['sent'];
}
}
//print last message time if older than 2 mins
$math = time() - $last_msg;
if ($math > 120) {
$chatmsg .= '<li class="list-group-item system">'.str_replace("%s", date("H:i", $last_msg), $jkl["g141"]).'</li>';
}
$chatmsg .= $print_offline;
// Let's update the unread messages
if ($unreadmsg && is_array($alloid)) {
$realid = implode(',', $alloid);
// Update in one query
$jakdb->query('UPDATE '.DB_PREFIX.'operatorchat SET received = CASE id
'.$updatesqla.'
END,
sent = CASE id
'.$updatesqla1.'
END
WHERE id IN ('.$realid.') AND "opid" = '.$opcacheid);
}
die(json_encode(array("status" => true, "msg" => '<ul class="list-group">'.$chatmsg.'</ul>')));
} else {
die(json_encode(array("status" => false)));
}
break;
case 'send-msg':
if (empty($_POST['message'])) {
echo $jkl['e1'];
} else {
$message = trim($_POST['message']);
$message = filter_var($message, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$jakdb->insert("operatorchat", ["opid" => $opcacheid, "fromid" => $_POST['uid'], "toid" => $_POST['to_id'], "message" => $message, "sent" => time()]);
$lastid = $jakdb->id();
if ($lastid) {
// Now let us add the active chat file so the operator can come online.
$chatsfile = APP_PATH.JAK_CACHE_DIRECTORY.'/chats'.$opcacheid.'.txt';
if (file_exists($chatsfile)) {
unlink($chatsfile);
}
// Write the from to operator id
$opid = time().":#:".$_POST['uid'].":#:".$_POST['to_id'].":#:".$_POST['uname']."\n";
// Create, write or append to the file.
file_put_contents($chatsfile, $opid, FILE_APPEND);
die(json_encode(array("status" => true, "txt" => '<li class="list-group-item">'.$message.'</li>')));
} else {
die(json_encode(array("status" => false)));
}
}
break;
default:
return false;
}
+59
View File
@@ -0,0 +1,59 @@
<?php
header('Content-Type: text/event-stream; charset=utf-8');
header("Cache-Control: no-cache");
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 2.5 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2020 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[usronline.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
// User is on idle let's check if there is a new client
if (isset($_GET['id']) && $_GET['id'] == "check_only" && is_numeric($_GET['opid'])) {
// Now let us add the active chat file so the operator can come online.
$chatsfile = APP_PATH.JAK_CACHE_DIRECTORY.'/chats'.$opcacheid.'.txt';
if (file_exists($chatsfile)) {
$trimmed = file($chatsfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($trimmed as $v) {
$opid = explode(":#:", $v);
// Check if we have a chat request
if ($opid[2] == $_GET['opid'] && $opid[0] > (time() - 10)) {
$nopid[] = $opid[1].":#:".$opid[3];
} else {
$nopid = false;
}
}
// If we have forward the new window array
if (is_array($nopid)) {
echo 'retry: 5000\n' . PHP_EOL;
echo 'data: '.json_encode(array("startcalling" => true, "win" => $nopid))."\n\n";
} else {
// Nothing to do, keep idle.
echo 'retry: 5000\n' . PHP_EOL;
echo 'data: '.json_encode(array("startcalling" => false))."\n\n";
}
} else {
// Nothing to do, keep idle.
echo 'retry: 5000\n' . PHP_EOL;
echo 'data: '.json_encode(array("startcalling" => false))."\n\n";
}
}
+410
View File
@@ -0,0 +1,410 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 2.1.4 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2023 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[oprequests.php] config.php not exist');
require_once '../../config.php';
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (!is_numeric($_POST['uid'])) die("There is no such user!");
switch ($_POST['oprq']) {
case 'status':
# code...
if ($_POST['available'] == 1) {
// operator makes himself available
$jakdb->update("user", ["available" => 1], ["id" => $_POST['uid']]);
$row = $jakdb->get("user",["operatorlist", "operatorchat"], ["AND" => ["id" => $_POST['uid'], "access" => 1]]);
die(json_encode(array("status" => 1, "olist" => $row["operatorlist"])));
} elseif ($_POST['available'] == 2) {
// Operator goes busy
$jakdb->update("user", ["available" => 2], ["id" => $_POST['uid']]);
$row = $jakdb->get("user",["operatorlist", "operatorchat"], ["AND" => ["id" => $_POST['uid'], "access" => 1]]);
die(json_encode(array("status" => 2, "olist" => $row["operatorlist"])));
} else {
// operator goes offline
$jakdb->update("user", ["available" => 0], ["id" => $_POST['uid']]);
die(json_encode(array("status" => 2, "olist" => "0")));
}
break;
case 'sound':
# code...
if (isset($_POST['sa']) && is_numeric($_POST['sa'])) {
// operator makes himself available
$jakdb->update("user", ["sound" => $_POST['sa']], ["id" => $_POST['uid']]);
}
die(json_encode(array('status' => 1)));
break;
case 'push':
# code...
if (isset($_POST['pa']) && is_numeric($_POST['pa'])) {
// operator makes himself available
$jakdb->update("user", ["push_notifications" => $_POST['pa']], ["id" => $_POST['uid']]);
// operator likes to turn on/off push notifications for the active chat
if (isset($_POST['convid']) && !empty($_POST['convid'])) {
$jakdb->update("checkstatus", ["pusho" => $_POST['pa']], ["convid" => $_POST['convid']]);
}
}
die(json_encode(array('status' => 1)));
break;
case 'ban':
# code...
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
// Check the input data
if (isset($_POST['id']) && is_numeric($_POST['id']) && isset($_POST['ip'])) {
// First check if it already exists
if (strpos(JAK_IP_BLOCK, $_POST['ip']) !== false) {
die(json_encode(array('status' => 0, 'html' => $jkl['g347'])));
}
// Add the ip to the list
$newipblocklist = (JAK_IP_BLOCK != '' ? JAK_IP_BLOCK.',' : '').$_POST['ip'];
// update the table
$jakdb->update("settings", ["used_value" => $newipblocklist], ["AND" => ["opid" => $opcacheid, "varname" => "ip_block"]]);
// Now let us delete the define cache file
$cachedefinefile = APP_PATH.JAK_CACHE_DIRECTORY.'/opcache'.$opcacheid.'.php';
if (file_exists($cachedefinefile)) {
unlink($cachedefinefile);
}
// Get the user agent
$valid_agent = filter_var($_SERVER['HTTP_USER_AGENT'], FILTER_SANITIZE_FULL_SPECIAL_CHARS);
// Write the log file each time someone login after to show success
JAK_base::jakWhatslog('', $opcacheid, $_POST['uid'], 0, 16, 0, (isset($_COOKIE['WIOgeoData']) ? $_COOKIE['WIOgeoData'] : ''), $_POST['oname'], $_SERVER['REQUEST_URI'], $ipa, $valid_agent);
die(json_encode(array('status' => 1, 'html' => $jkl['g14'])));
} else {
die(json_encode(array('status' => 0, 'html' => $jkl['g116'])));
}
break;
case 'deny':
# code...
if (is_numeric($_POST['id'])) {
// Now cancel the chat
$jakdb->update("sessions", ["deniedoid" => $_POST['uid'], "status" => 0, "ended" => time()], ["id" => $_POST['id']]);
$jakdb->update("checkstatus", ["denied" => 1, "hide" => 1], ["convid" => $_POST['id']]);
die(json_encode(array('cid' => $_POST['id'])));
}
// Nothing worked cancel
die(json_encode(array('cid' => 0)));
break;
case 'hidemsg':
# code...
if (!is_numeric($_POST['id'])) die("There is no such post!");
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
if ($_POST['plevel'] == 1) {
$plevel = 2;
} else {
$plevel = 1;
}
// Update the plevel in the transcript table
$update = $jakdb->update("transcript", ["plevel" => $plevel], ["AND" => ["id" => $_POST['id'], "convid" => $_POST['cid']]]);
if ($update) {
// Update the status page
$jakdb->update("checkstatus", ["typeo" => 0, "msgdel" => $_POST['id']], ["convid" => $_POST['cid']]);
die(json_encode(array('status' => 1, 'txt' => $jkl["g14"], 'plevel' => $plevel)));
} else {
die(json_encode(array('status' => 0, 'txt' => $jkl["i"])));
}
break;
case 'starred':
# code...
if (!is_numeric($_POST['id'])) die("There is no such post!");
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
if ($_POST['starred'] == 1) {
$starred = 0;
} else {
$starred = 1;
}
// Update the starred in the transcript table
$update = $jakdb->update("transcript", ["starred" => $starred], ["AND" => ["id" => $_POST['id'], "convid" => $_POST['cid']]]);
if ($update) {
die(json_encode(array('status' => 1, 'txt' => $jkl["g14"], 'starred' => $starred)));
} else {
die(json_encode(array('status' => 0, 'txt' => $jkl["i"])));
}
break;
case 'sendfile':
# code...
if (!is_numeric($_POST['id'])) die("There is no such post!");
$row = $jakdb->get("files", ["name", "path", "mime_type"], ["id" => $_POST['id']]);
if ($row) {
$jakdb->insert("transcript", [
"name" => $_POST['oname'],
"message" => $row['path'].':#:'.$row['name'].':#:'.$row['mime_type'],
"user" => $_POST['uid'].'::'.$_POST['uname'],
"operatorid" => $_POST['uid'],
"convid" => $_POST['conv'],
"class" => "download",
"time" => $jakdb->raw("NOW()")]);
// Update the status table
$jakdb->update("checkstatus", ["newc" => 1, "typeo" => 0, "newo" => 0, "statuso" => time()], ["convid" => $_POST['conv']]);
die(json_encode(array('status' => 1)));
}
die(json_encode(array('status' => 10)));
break;
case 'transfer':
# code...
if (!is_numeric($_POST['convid'])) die("There is no such conversation!");
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
// Standard message
$noconv = '<a href="#" class="alert-link main-sidebar-toggle d-md-none"><i class="fa fa-bars"></i></a> '.$jkl['g79'];
$trow = $jakdb->get("checkstatus", ["convid", "transferid"], ["convid" => $_POST['convid']]);
if ($trow) {
if ($_POST['accept'] == 1) {
// Get the operator details
$operator = $jakdb->get("user", ["username", "name"], ["id" => $_POST["uid"]]);
$jakdb->insert("transcript", [
"name" => $operator['name'],
"message" => $operator['name'].' '.$jkl["g121"],
"user" => $_POST['uid'].'::'.$operator['username'],
"operatorid" => $_POST['uid'],
"convid" => $trow["convid"],
"class" => "admin",
"time" => $jakdb->raw("NOW()")]);
$jakdb->update("sessions", ["operatorid" => $_POST['uid'], "operatorname" => $operator['name']], ["id" => $trow['convid']]);
$jakdb->update("checkstatus", ["operatorid" => $_POST['uid'], "operator" => $operator['name'], "newc" => 1, "transferid" => 0, "transferoid" => 0], ["convid" => $trow['convid']]);
$jakdb->update("transfer", ["used" => 1], ["id" => $trow["transferid"]]);
die(json_encode(array('status' => 1, 'href' => str_replace("ajax/", "", JAK_rewrite::jakParseurl('live', $trow['convid'])))));
} else {
$jakdb->update("checkstatus", ["transferid" => 0, "transferoid" => 0], ["convid" => $trow['convid']]);
$jakdb->update("transfer", ["used" => 2], ["id" => $trow["transferid"]]);
die(json_encode(array('status' => 0, "noconv" => $noconv)));
}
}
die(json_encode(array('status' => 0, "noconv" => $noconv)));
break;
case 'delstat':
# code...
if (is_numeric($_POST['sid'])) {
// Now delete the record from the database
$jakdb->delete("user_stats", ["id" => $_POST['sid']]);
die(json_encode(array('status' => 1)));
} else {
die(json_encode(array('status' => 0)));
}
break;
case 'supportresponse':
# code...
if (is_numeric($_POST['respid'])) {
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["id"] == $_POST["respid"]) {
$phold = array("%operator%","%client%","%email%");
$replace = array($jakuser->getVar("name"), $_POST["cname"], JAK_EMAIL);
$message = str_replace($phold, $replace, $r["message"]);
die(json_encode(array('status' => 1, 'response' => $message)));
}
}
}
die(json_encode(array('status' => 0)));
} else {
die(json_encode(array('status' => 0)));
}
break;
case 'translatechat':
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
// Let's filter some inputs
$cid = filter_var($_POST['id'], FILTER_SANITIZE_NUMBER_INT);
$caid = filter_var($_POST['cid'], FILTER_SANITIZE_NUMBER_INT);
// Get the language
$chatlang = $jakdb->get("sessions", ["lang"], ["id" => $cid]);
// Get the message itself
$chatmsg = $jakdb->get("transcript", ["message"], ["AND" => ["id" => $cid, "convid" => $caid]]);
// We do need to check the translation table
$transl = $jakdb->get("chat_ai_translations", ["original_lang", "translated_lang", "lang"], ["AND" => ["chatid" => $caid, "answerid" => $cid]]);
// We check if the text is the same and the translation has already been done
if (isset($transl["lang"]) && $transl["lang"] == $_SESSION['jak_lcp_lang']) {
// We can assume that the translation has been done, so we do not need to run it again and pay money for it
$translation = $transl["translated_lang"];
} else {
// We have previous messages
$translation_msg = [];
// User Subject
$translation_msg[] = [
"role" => "user",
"content" => "Please translate this text into following language with iso code '".$_SESSION['jak_lcp_lang']."': ".$chatmsg["message"]
];
// We have no translation so far, let's call the AI service
$jsonData = json_encode(array(
"model" => "gpt-3.5-turbo",
"temperature" => 0.3,
"messages" => $translation_msg
));
// cURL initialization
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, 'https://api.openai.com/v1/chat/completions');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer ".JAK_OPENAI_APIKEY,
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
// Execute the cURL request
$response = curl_exec($ch);
// Close cURL connection
curl_close($ch);
//die(print_r($response."<br>". curl_error($ch)));
// die(json_encode(array('status' => 0, "txt" => print_r($response."<br>". curl_error($ch)))));
// Handle the response
if ($response === false) {
// Error handling
die(json_encode(array('status' => 0, "txt" => $jkl['i2'])));
// echo 'cURL error: ' . curl_error($ch);
} else {
// Process the response
$translation = "";
$responseData = json_decode($response, true);
// Check if we have a valid answer
if (isset($responseData['choices'][0]['message']['content'])) $translation = html_entity_decode(filter_var($responseData['choices'][0]['message']['content'], FILTER_SANITIZE_FULL_SPECIAL_CHARS));
}
// We do have a translation?
if (!empty($translation)) {
// Add the values to the database
$jakdb->insert("chat_ai_translations", [
"opid" => $opcacheid,
"chatid" => $caid,
"answerid" => $cid,
"operatorid" => $_POST['uid'],
"original_lang" => $chatmsg["message"],
"translated_lang" => $translation,
"lang" => $_SESSION['jak_lcp_lang'],
"created" => $jakdb->raw("NOW()")]);
} else {
die(json_encode(array('status' => 0, "txt" => $jkl['i2'])));
}
}
die(json_encode(array('status' => 1, "translation" => $translation, "txt" => $jkl['g14'])));
break;
default:
# code...
break;
}
?>
+130
View File
@@ -0,0 +1,130 @@
<?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 2021 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[usronline.php] config.php not exist');
require_once '../../config.php';
if (!$_SERVER['HTTP_X_REQUESTED_WITH'] && !isset($_SESSION['idhash'])) die("Nothing to see here");
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
if (!is_numeric($_POST['uid']) || !is_numeric($_POST['opid'])) die("There is no such thing!");
$sent_time = time() - OPERATOR_CHAT_EXPIRE;
$print_offline = $chatmsg = '';
switch ($_POST['page']) {
case 'load-msg':
if ($_POST['uid'] == JAK_USERID) {
// Operator is still online
$oponline = $jakdb->has("user", ["AND" => ["id" => $_POST['opid'], "available" => 1]]);
if (!$oponline) $print_offline = '<li class="list-group-item error"><p class="mb-1">'.$jkl["g139"].'</p></li>';
$chatmsg = '<ul class="list-group op-chat">';
// Load Messages
$resultm = $jakdb->select("operatorchat", ["[>]user" => ["fromid" => "id"]], ["operatorchat.id", "operatorchat.fromid", "operatorchat.message", "operatorchat.system_message", "operatorchat.sent", "user.username", "user.available"], ["AND #check" => ["OR #first" => ["operatorchat.fromid" => $_POST['uid'], "operatorchat.toid" => $_POST['uid']], "OR #second" => ["operatorchat.fromid" => $_POST['opid'], "operatorchat.toid" => $_POST['opid']], "operatorchat.opid" => $opcacheid, "operatorchat.sent[>]" => $sent_time, "operatorchat.msgpublic" => 0], "ORDER" => ["operatorchat.sent" => "ASC"]]);
if (isset($resultm) && !empty($resultm)) {
foreach ($resultm as $rowm) {
//print messages
if ($rowm['system_message'] != 'no') {
$chatmsg .= '<li class="list-group-item system"><p class="mb-1">'.$rowm['message'].'</p></li>';
} elseif ($rowm['fromid'] != $_POST['uid']) {
$chatmsg .= '<li class="list-group-item me"><div class="d-flex w-100 justify-content-between"><h5 class="mb-1">'.$rowm['username'].' <span class="badge badge-dark">'.date("H:i", $rowm['sent']).'</span></h5></div><p class="mb-1">'.$rowm['message'].'</p></li>';
} else {
$chatmsg .= '<li class="list-group-item"><div class="d-flex w-100 justify-content-between"><h5 class="mb-1">'.$jkl["g140"].' <span class="badge badge-dark">'.date("H:i", $rowm['sent']).'</span></h5></div><p class="mb-1">'.$rowm['message'].'</p></li>';
}
$last_msg = $rowm['sent'];
}
//print last message time if older than 2 mins
$math = time() - $last_msg;
if ($math > 120) {
$chatmsg .= '<li class="list-group-item system"><p class="mb-1">'.str_replace("%s", date("H:i", $last_msg), $jkl["g141"]).'</p></li>';
}
if ($rowm["available"] == 0) {
$chatmsg .= $print_offline;
}
} else {
$chatmsg .= $print_offline;
}
$chatmsg .= '</ul>';
echo $chatmsg;
}
break;
case 'send-msg':
if (empty($_POST['message'])) {
echo $jkl['e1'];
} else {
$message = trim($_POST['message']);
$message = filter_var($message, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$jakdb->insert("operatorchat", ["opid" => $opcacheid, "fromid" => $_POST['uid'], "toid" => $_POST['opid'], "message" => $message, "sent" => time()]);
$lastid = $jakdb->id();
if ($lastid) {
// Now let us add the active chat file so the operator can come online.
$chatsfile = APP_PATH.JAK_CACHE_DIRECTORY.'/chats'.$opcacheid.'.txt';
if (file_exists($chatsfile)) {
unlink($chatsfile);
}
// Write the from to operator id
$opid = time().":#:".$_POST['uid'].":#:".$_POST['opid'].":#:".$_POST['uname']."\n";
// Create, write or append to the file.
file_put_contents($chatsfile, $opid, FILE_APPEND);
echo 'success';
} else {
echo $jkl['e1'];
}
}
break;
default:
return false;
}
+106
View File
@@ -0,0 +1,106 @@
<?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 2021 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[usronline.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
if (!is_numeric($_POST['uid'])) die("There is no such thing!");
$sent_time = time() - OPERATOR_CHAT_EXPIRE;
$chatmsg = '';
switch ($_POST['page']) {
case 'load-msg':
if ($_POST['uid'] == JAK_USERID) {
// Load Messages
$result = $jakdb->select("operatorchat", ["[>]user" => ["fromid" => "id"]], ["operatorchat.id", "operatorchat.fromid", "operatorchat.message", "operatorchat.system_message", "operatorchat.sent", "user.username"], ["AND" => ["operatorchat.opid" => $opcacheid, "msgpublic" => 1, "sent[>]" => $sent_time], "ORDER" => ["sent" => "ASC"]]);
if (isset($result) && !empty($result)) {
$chatmsg = '<ul class="list-group op-chat">';
foreach ($result as $rowm) {
//print messages
if ($rowm['system_message'] != 'no') {
$chatmsg .= '<li class="list-group-item system"><p class="mb-1">'. stripcslashes($rowm['message']).'</p></li>';
} elseif ($rowm['fromid'] != $_POST['uid']) {
$chatmsg .= '<li class="list-group-item me"><div class="d-flex w-100 justify-content-between"><h5 class="mb-1">'.$rowm['username'].' <span class="badge badge-dark">'.date("H:i", $rowm['sent']).'</span></h5></div><p class="mb-1">'.$rowm['message'].'</p></li>';
} else {
$chatmsg .= '<li class="list-group-item"><div class="d-flex w-100 justify-content-between"><h5 class="mb-1">'.$jkl["g140"].' <span class="badge badge-dark">'.date("H:i", $rowm['sent']).'</span></h5></div><p class="mb-1">'.$rowm['message'].'</p></li>';
}
$last_msg = $rowm['sent'];
}
//print last message time if older than 2 mins
$math = time() - $last_msg;
if ($math > 120) {
$chatmsg .= '<li class="list-group-item system"><p class="mb-1">'.str_replace("%s", date("H:i", $last_msg), $jkl["g141"]).'</p></li>';
}
$chatmsg .= '</ul>';
}
die($chatmsg);
}
break;
case 'send-msg':
if (empty($_POST['message'])) {
echo $jkl['e1'];
} else {
$message = trim($_POST['message']);
$message = filter_var($message, FILTER_SANITIZE_FULL_SPECIAL_CHARS);
$jakdb->insert("operatorchat", ["opid" => $opcacheid, "fromid" => $_POST['uid'], "toid" => 0, "message" => $message, "sent" => time(), "received" => 1, "msgpublic" => 1]);
$lastid = $jakdb->id();
if ($lastid) {
echo 'success';
} else {
echo $jkl['e1'];
}
}
break;
default:
return false;
}
+116
View File
@@ -0,0 +1,116 @@
<?php
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Sat, 6 May 1998 03:10:00 GMT");
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 2.1.4 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2023 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[available.php] config.php not exist');
require_once '../../config.php';
// include the PHP library (if not autoloaded)
require('../../class/class.emoji.php');
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
$statusmsg = $chatended = false;
$chatmsg = $prevtxt = '';
$lastid = 0;
if (!isset($_SESSION["lastido"])) $_SESSION["lastido"] = 0;
// Get the absolute url for the image
$ava_url = str_replace(JAK_OPERATOR_LOC.'/ajax/', '', BASE_URL);
if (is_numeric($_POST['id'])) {
if (isset($_POST['lastid']) && is_numeric($_POST['lastid'])) {
$lastid = $_SESSION["lastido"];
}
$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.template", "sessions.avatarset", "sessions.status"], ["AND" => ["transcript.convid" => $_POST['id'], "transcript.id[>]" => $lastid], "ORDER" => ["transcript.id" => "ASC"]]);
if (isset($result) && !empty($result)) {
foreach ($result as $row) {
// On which class to show a system image
$systemimg = array("bot", "notice", "url", "ended");
$oimage = $ava_url.$row["usr_avatar"];
if ($row["picture"] && $row["operatorid"]) $oimage = $ava_url.JAK_FILES_DIRECTORY.$row["picture"];
if (in_array($row["class"], $systemimg)) $oimage = $ava_url.'lctemplate/'.$row["template"].'/avatar/'.$row["avatarset"].'/system.jpg';
if ($row['class'] == "ended") $chatended = true;
// We convert the br
$message = nl2br($row['message'], false);
// we have file
if ($row['class'] == "download") {
$splitmsg = explode(":#:", $message);
if (file_exists(CLIENT_UPLOAD_DIR.$splitmsg[0])) {
// Get the file
$theupfile = $ava_url.'_showfile.php?i='.jak_encrypt_decrypt($message);
// We have an image
if (getimagesize(CLIENT_UPLOAD_DIR.$splitmsg[0])) {
$messageemoji = '<a href="'.$theupfile.'" download="'.$message.'"><img src="'.$theupfile.'" class="img-thumbnail img-fluid chat-img" alt="shared-chat-img"></a>';
} else {
$messageemoji = '<a href="'.$theupfile.'" target="_blank"><i class="fa fa-download"></i> '.basename($splitmsg[1]).'</a>';
}
} else {
$messageemoji = $jkl['i16'];
}
} else {
// We convert the urls
$messageemoji = replace_urls($message);
}
// Convert emotji
$messageemoji = Emojione\Emojione::toImage($messageemoji);
// Get the quote msg
$quotemsg = '';
if ($row['quoted']) {
$quotemsg = $jakdb->get("transcript", "message", ["id" => $row["quoted"]]);
// Convert urls
$quotemsg = nl2br(replace_urls($quotemsg), false);
// Convert emotji
$quotemsg = Emojione\Emojione::toImage($quotemsg);
}
$chatmsg .= '<div class="media" id="postid_'.$row['id'].'">
<img class="d-flex mr-3 img-thumbnail" src="'.$oimage.'" width="53" height="53" alt="'.$row['name'].'">
<div class="media-body">
<h4 class="media-heading">'.$row['name'].' <small>'.JAK_base::jakTimesince($row['time'], "", JAK_TIMEFORMAT).'<span id="edited_'.$row['id'].'">'.($row['editoid'] ? ' | <i class="fa fa-edit"></i> '.JAK_base::jakTimesince($row['edited'], "", JAK_TIMEFORMAT) : '').'</span></small>'.(!in_array($row["class"], $systemimg) ? ' <div class="chat-edit"><a href="javascript:void(0)" class="chat-edit-link clipboard" data-clipboard-target="#msg'.$row['id'].'"><i class="fa fa-clipboard"></i></a>'.($row['status'] ? ' <a href="javascript:void(0)" class="edit-msg" data-id="'.$row['id'].'" data-msg="'.stripcslashes($message).'"><i class="fa fa-edit"></i></a>' : '').' <a href="javascript:void(0)" class="edit-starred" data-id="'.$row['id'].'" data-starred="'.$row['starred'].'"><i class="fa'.($row['starred'] ? '' : 'l').' fa-star"></i></a> <a href="javascript:void(0)" class="edit-quote" data-id="'.$row['id'].'"><i class="fa fa-quote-right"></i></a>'.($row["class"] == "admin" ? ' <a href="javascript:void(0)" class="edit-remove'.($row["plevel"] == 2 ? ' text-danger' : '').'" data-id="'.$row['id'].'" data-plevel="'.$row['plevel'].'"><i class="fa fa-trash"></i></a>' : '').(!empty(JAK_OPENAI_APIKEY && $row["class"] == "user") ? ' <a href="javascript:" class="translate-chat" data-id="'.$row['id'].'"><i class="fa fa-language"></i> <i class="fa fa-spinner fa-pulse d-none tl-loader"></i></a>' : '').'</div>' : '').'</h4>
<div class="media-text" id="msg'.$row['id'].'">'.($row['quoted'] ? '<blockquote class="blockquote"><i class="fa fa-reply"></i> '.$quotemsg.'</blockquote>' : '').stripcslashes($messageemoji).'</div>'.(!empty(JAK_OPENAI_APIKEY && $row["class"] == "user") ? '<div class="media-text chat_translation" id="aitranslate'.$row['id'].'"></div>' : '').'
</div>
</div>
<hr>';
$lastid = $row["id"];
$_SESSION["lastido"] = $lastid;
}
$statusmsg = true;
}
}
die(json_encode(array('status' => $statusmsg, 'chatended' => $chatended, 'chat' => $chatmsg, 'previewtxt' => $prevtxt, 'lastid' => $lastid)));
?>
+89
View File
@@ -0,0 +1,89 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 3.2 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[available.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
// Reset
$searchmsg = '';
// Search
$keyword = strip_tags($_GET['q']);
$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.edited", "transcript.editoid", "transcript.convid", "user.picture", "sessions.usr_avatar"], ["AND" => ["transcript.convid" => $_GET['convid'], "transcript.message[~]" => $keyword], "ORDER" => ["transcript.id" => "ASC"]]);
if (isset($result) && !empty($result)) {
// include the PHP library (if not autoloaded)
require('../../class/class.emoji.php');
foreach ($result as $row) {
// On which class to show a system image
$systemimg = array("bot", "notice", "url", "ended", "download");
$oimage = str_replace(JAK_OPERATOR_LOC."/ajax/", "", BASE_URL.$row["usr_avatar"]);
if ($row["picture"] && $row["operatorid"]) $oimage = str_replace(JAK_OPERATOR_LOC."/ajax/", "", BASE_URL.JAK_FILES_DIRECTORY.$row["picture"]);
if (in_array($row["class"], $systemimg)) $oimage = str_replace(JAK_OPERATOR_LOC."/ajax/", "", BASE_URL.JAK_FILES_DIRECTORY."/system.jpg");
// We convert the br
$message = nl2br($row['message'], false);
// we have file
if ($row['class'] == "download") {
$lightbox = "";
if (getimagesize(APP_PATH.JAK_FILES_DIRECTORY.$message)) $lightbox = ' download="'.$message.'"';
$message = '<a'.$lightbox.' href="'.str_replace(JAK_OPERATOR_LOC."/ajax/", "", BASE_URL.JAK_FILES_DIRECTORY.$message).'" target="_blank">'.basename($message).'</a>';
} else {
// We convert the urls
$message = replace_urls($message);
}
// Convert emotji
$message = Emojione\Emojione::toImage($message);
// Get the quote msg
$quotemsg = '';
if ($row['quoted']) {
$quotemsg = $jakdb->get("transcript", "message", ["id" => $row["quoted"]]);
// Convert urls
$quotemsg = nl2br(replace_urls($quotemsg), false);
// Convert emotji
$quotemsg = Emojione\Emojione::toImage($quotemsg);
}
$searchmsg .= '<div class="media">
<img class="d-flex mr-3 img-thumbnail" src="'.$oimage.'" width="53" height="53" alt="'.$row['name'].'">
<div class="media-body">
<h4 class="media-heading">'.$row['name'].' <small>'.JAK_base::jakTimesince($row['time'], "", JAK_TIMEFORMAT).($row['editoid'] ? ' | <i class="fa fa-edit"></i> '.JAK_base::jakTimesince($row['edited'], "", JAK_TIMEFORMAT) : '').'</small>'.(!in_array($row["class"], $systemimg) ? ' <div class="chat-edit"><a href="javascript:void(0)" class="chat-edit-link clipboard" data-clipboard-target="#msg'.$row['id'].'"><i class="fa fa-clipboard"></i></a> <a href="javascript:void(0)" class="edit-starred" data-id="'.$row['id'].'" data-starred="'.$row['starred'].'"><i class="fa fa-star'.($row['starred'] ? '' : '-o').'"></i></a></div>' : '').'</h4>
<div class="media-text">'.($row['quoted'] ? '<blockquote class="blockquote"><i class="fa fa-reply"></i> '.$quotemsg.'</blockquote>' : '').stripcslashes($message).'</div>
</div>
</div>
<hr>';
}
echo $searchmsg;
} else {
// Nothing available
echo '<div class="alert alert-rose">'.$jkl["i3"].'</div>';
}
?>
+73
View File
@@ -0,0 +1,73 @@
<?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('ajax/[available.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (!is_numeric($_GET['id'])) die("There is no such user!");
$sqlw = '';
// Now only get the department for the user
if ($_SESSION['usr_department'] && is_numeric($_SESSION['usr_department'])) {
$sqlw = 'department = :depid AND status = 1 AND operatorid = 0 OR ';
}
if ($_SESSION['usr_department']) {
$sqlw = 'department IN(:depid) AND status = 1 AND operatorid = 0 OR ';
}
if ($_SESSION['usr_department'] == 0) {
$sqlw = 'department >= 0 AND status = 1 AND operatorid = 0 OR ';
}
$sth = $jakdb->pdo->prepare("SELECT id, operatorid, answered, updated, transferid, transfermsg FROM ".JAKDB_PREFIX."sessions WHERE ".$sqlw."operatorid = :oid AND status = 1 OR department = 0 AND status = 1 AND operatorid = 0 OR transferid = :oid AND status = 1");
$sth->bindParam(':depid', $_SESSION['usr_department'], PDO::PARAM_INT);
$sth->bindParam(':oid', $_GET['id'], PDO::PARAM_INT);
$sth->execute();
$result = $sth->fetchAll();
if (isset($result) && !empty($result)) {
foreach ($result as $row) {
// We have a transfer, need to display it!
if ($row['transferid'] == $_GET['id']) {
if ($row["transfermsg"]) $split_transfer_msg = explode(':#:', $row["transfermsg"]);
// Display underneath the button
$transfer_msg = '<p>'.$split_transfer_msg[1].' <a href="javascript:void(0)" onclick="acceptTransfer(0, '.$row['transferid'].', '.$row['id'].');"><i class="fa fa-times"></i></a> <a href="javascript:void(0)" onclick="acceptTransfer(1, '.$row['transferid'].', '.$row['id'].');"><i class="fa fa-check"></i></a></p>';
$transferid = $row['transferid'];
}
$newConv = 0;
// check for new conversations
if ($row['operatorid'] == 0) {
$newConv = 1;
}
if ($row['operatorid'] > 0 && ($row['updated'] > $row['answered'])) {
$newConv = 2;
}
}
echo json_encode(array('newc' => $newConv, 'tid' => $transferid, 'tmsg' => $transfer_msg));
} else {
echo json_encode(array('newc' => 0, 'tid' => 0, 'tmsg' => 0));
}
?>
+33
View File
@@ -0,0 +1,33 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 3.2 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('[loadmap.php] config.php not exist');
require_once '../../config.php';
// No ajax requests and user has no permission
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (isset($_POST["depid"]) && is_numeric($_POST["depid"]) && $_POST["depid"] != 0) {
$maparray = $jakdb->select("sessions", ["id", "countrycode", "country", "city", "name", "latitude", "longitude"], ["AND" => ["department" => $_POST["depid"], "longitude[!]" => ''], "ORDER" => ["id" => "DESC"], "LIMIT" => 2000]);
} else {
$maparray = $jakdb->select("sessions", ["id", "countrycode", "country", "city", "name", "latitude", "longitude"], ["longitude[!]" => '', "ORDER" => ["id" => "DESC"], "LIMIT" => 2000]);
}
if ($maparray) {
header('Cache-Control: no-cache');
die(json_encode(array("status" => 1, "markers" => $maparray)));
}
die(json_encode(array("status" => 0)));
?>
+417
View File
@@ -0,0 +1,417 @@
<?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('ajax/[usronline.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
// Get the current time
$currentime = time();
if (jak_get_access("leads", $jakuser->getVar("permissions"), JAK_MAIN_OP) && !is_numeric($_GET['uid'])) die("There is no such thing!");
$useronline = '';
$useronlinemap = array();
$userocount = 0;
if (isset($_GET['uonline']) && $_GET['uonline']) {
// 5 Minutes ago
$mino = date('Y-m-d H:i:s',$currentime - 5 * 60);
// Now only get the department for the user
if (isset($_SESSION['usr_department']) && is_numeric($_SESSION['usr_department']) && $_SESSION['usr_department'] != 0) {
$result = $jakdb->select("buttonstats", ["[>]sessions" => ["session" => "session"]], ["buttonstats.id", "buttonstats.referrer", "buttonstats.firstreferrer", "buttonstats.agent", "buttonstats.hits", "buttonstats.ip", "buttonstats.country", "buttonstats.countrycode", "buttonstats.latitude", "buttonstats.longitude", "buttonstats.lasttime", "buttonstats.time", "buttonstats.readtime", "sessions.initiated", "sessions.ended"], ["AND" => ["buttonstats.opid" => $opcacheid, "buttonstats.singleopid" => [0,$_GET['uid']], "buttonstats.depid" => [0,$_SESSION['usr_department']], "buttonstats.lasttime[>]" => $mino], "GROUP" => "buttonstats.session", "ORDER" => ["buttonstats.lasttime" => "DESC"], "LIMIT" => 50]);
} elseif (isset($_SESSION['usr_department']) && $_SESSION['usr_department'] == 0) {
$result = $jakdb->select("buttonstats", ["[>]sessions" => ["session" => "session"]], ["buttonstats.id", "buttonstats.referrer", "buttonstats.firstreferrer", "buttonstats.agent", "buttonstats.hits", "buttonstats.ip", "buttonstats.country", "buttonstats.countrycode", "buttonstats.latitude", "buttonstats.longitude", "buttonstats.lasttime", "buttonstats.time", "buttonstats.readtime", "sessions.initiated", "sessions.ended"], ["AND" => ["buttonstats.opid" => $opcacheid, "buttonstats.singleopid" => [0,$_GET['uid']], "#buttonstats.lasttime[>]" => $mino], "GROUP" => "buttonstats.session", "ORDER" => ["buttonstats.lasttime" => "DESC"], "LIMIT" => 50]);
} elseif (isset($_SESSION['usr_department'])) {
$result = $jakdb->select("buttonstats", ["[>]sessions" => ["session" => "session"]], ["buttonstats.id", "buttonstats.referrer", "buttonstats.firstreferrer", "buttonstats.agent", "buttonstats.hits", "buttonstats.ip", "buttonstats.country", "buttonstats.countrycode", "buttonstats.latitude", "buttonstats.longitude", "buttonstats.lasttime", "buttonstats.time", "buttonstats.readtime", "sessions.initiated", "sessions.ended"], ["AND" => ["buttonstats.opid" => $opcacheid, "buttonstats.singleopid" => [0,$_GET['uid']], "buttonstats.depid" => explode(",",$_SESSION['usr_department'].',0'), "buttonstats.lasttime[>]" => $mino], "GROUP" => "buttonstats.session", "ORDER" => ["buttonstats.lasttime" => "DESC"], "LIMIT" => 50]);
}
if (isset($result) && !empty($result)) {
$useronline = '<div class="table-responsive"><table class="table table-striped"><th>'.$jkl["g224"].'</th><th>'.$jkl["g169"].'</th><th>'.$jkl["g171"].'</th><th>'.$jkl["g172"].'</th><th>'.$jkl["g11"].'</th><th>'.$jkl["g173"].'</th><th>'.$jkl["g174"].'</th><th></th>';
foreach ($result as $row) {
// Convert time to minutes and hours
$row['lasttime'] = JAK_base::jakTimesince($row['lasttime'], JAK_DATEFORMAT, JAK_TIMEFORMAT);
$row['time'] = JAK_base::jakTimesince($row['time'], JAK_DATEFORMAT, JAK_TIMEFORMAT);
$uclass = '';
$button = '<a href="javascript:void(0)" id="usero-'.$row['id'].'" class="btn btn-secondary btn-sm jakweb-online-user"><i class="fa fa-user"></i></a>';
if ($row['readtime'] == 1) $uclass = ' class="table-warning"';
if ($row['readtime'] == 2) $uclass = ' class="table-success"';
if ($row['readtime'] == 3) $uclass = ' class="table-danger"';
if ($row['readtime'] >= 2) $button = '<a href="javascript:void(0)" class="btn btn-info btn-sm"><i class="fa fa-bell"></i></a>';
if ($row['initiated'] && $row['ended'] == 0) $button = '<a href="javascript:void(0)" class="btn btn-info btn-sm"><i class="fa fa-comment"></i></a>';
$useronline .= '<tr'.$uclass.'><td><img src="'.str_replace("ajax/", "", BASE_URL."img/blank.png").'" class="flag-big flag-'.$row['countrycode'].'" title="'.$row['country'].'" alt="'.$row['country'].'"></td><td><strong>'.$jkl["g169"].':</strong> '.$row['referrer'].'<br><strong>'.$jkl["g170"].':</strong> '.$row['firstreferrer'].'</td><td>'.$row['agent'].'</td><td>'.$row['hits'].'</td><td>'.$row['ip'].'</td><td>'.$row['time'].'</td><td>'.$row['lasttime'].'</td><td>'.$button.'</td></tr>';
// Get the map thing
if (JAK_SHOW_IPS && $row['latitude']) {
$popupd = '<div class="row"><div class="col-2"><a href="javascript:void(0)" id="usero-'.$row['id'].'" class="jakweb-online-user"><img src="'.str_replace("ajax/", "", BASE_URL."img/blank.png").'" class="flag-big flag-'.$row['countrycode'].'" title="'.$row['country'].'" alt="'.$row['country'].'"></a></div><div class="col-10">'.$jkl["g169"].': '.$row['referrer'].'</div></div>';
$useronlinemap[] = array('id' => 'm_'.$row['id'], 'lat' => $row['latitude'], 'lng' => $row['longitude'], 'popup' => $popupd);
}
$userocount++;
}
$useronline .= '</table></div>';
}
}
// We check if we have access to the operator chat and the operator list
$oponline = false;
$countop = 0;
$openop = "";
$newopmsg = "default";
if (isset($_GET['olist']) && $_GET['olist']) {
$resop = $jakdb->select("user", ["id", "username", "name", "operatorchat"], ["AND" => ["OR" => ["opid" => $opcacheid, "id" => $opcacheid], "available" => 1, "id[!]" => $_GET['uid']], "LIMIT" => 20]);
if (isset($resop) && !empty($resop)) {
$oponline = '<ul class="list-group">';
foreach ($resop as $row) {
if ($jakosub['operatorchat']) {
if (!JAK_OPENOP) {
// Pop up Window
if ($row['operatorchat']) $openop = ' <a href="javascript:void(0)" class="btn btn-info btn-sm jakweb-oponline" data-user="'.$row['id'].':#:'.$row['username'].'"><i class="fa fa-user"></i></a>';
} else {
// Slide Up Window
// Now let us add the active chat file so the operator can come online.
$chatsfile = APP_PATH.JAK_CACHE_DIRECTORY.'/chats'.$opcacheid.'.txt';
if (file_exists($chatsfile)) {
$trimmed = file($chatsfile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
foreach ($trimmed as $v) {
$opid = explode(":#:", $v);
// Check if we have a chat request
if ($row['operatorchat'] && $opid[2] == $_GET['uid'] && $opid[0] > ($currentime - 120)) {
$newopmsg = 'primary';
$countops++;
}
}
}
if ($row['operatorchat']) {
$openchat = " onclick=\"if(navigator.userAgent.toLowerCase().indexOf('opera') != -1 && window.event.preventDefault) window.event.preventDefault();this.newWindow = window.open('".str_replace('ajax/', '', JAK_rewrite::jakParseurl('chat', $_GET['uid'], $row['id']))."', 'lsr', 'toolbar=0,scrollbars=1,location=0,status=1,menubar=0,width=600,height=520,resizable=1');this.newWindow.focus();this.newWindow.opener=window;return false;\"";
$openop = '<a href="javascript:void(0)"'.$openchat.' class="btn btn-'.$newopmsg.'" data-user="'.$row['id'].':#:'.$row['username'].'"><i class="fa fa-user"></i></a>';
}
}
}
$oponline .= '<li class="list-group-item">'.$row['name'].' <div class="btn-group btn-group-sm"><a href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('uonline', 'opstat', $row['id'])).'" data-toggle="modal" data-target="#jakModal" class="btn btn-info"><i class="fa fa-chart-bar"></i></a>'.$openop.'</div></li>';
$countop = $countop + 1;
}
$oponline .= '</ul>';
}
}
// Reset vars
$transfer_msg = $jsmsg = $newclient = $soundjs = $cname = $newmsg = $newtitle = $soundmsgjs = '';
$newConv = $transferid = $sendalert = 0;
$loadClients = false;
$convid = $answers = $typing = array();
$resnew = $jakdb->select("checkstatus", ["convid", "depid", "operatorid", "operator", "newo", "transferoid", "transferid", "typec", "alert", "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'] && (($currentime - $row['statusc']) > JAK_CLIENT_LEFT)) {
$jakdb->update("sessions", ["status" => 0, "ended" => $currentime], ["id" => $row['convid']]);
$jakdb->update("checkstatus", ["hide" => 1], ["convid" => $row['convid']]);
$cname = $jakdb->get("sessions", "name", ["id" => $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;
}
// The client is expired
if ($row['statusc'] && (($currentime - $row['statusc']) > JAK_CLIENT_EXPIRED)) {
$jakdb->update("sessions", ["status" => 0, "ended" => $currentime], ["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'] == $_GET['uid']) {
$trow = $jakdb->get("transfer", ["fromname", "message"], ["AND" => ["tooid" => $_GET['uid'], "convid" => $row['convid'], "used" => 0]]);
if (isset($trow) && !empty($trow)) {
// Display underneath the button
$transfer_msg = '<div class="alert alert-secondary"><h3 class="transfer-chat">'.sprintf($jkl['g110'], $trow["fromname"]).'</h3><p>'.$trow["message"].'</p><div class="transfer-btn"><a href="javascript:void(0)" class="btn btn-sm btn-danger" onclick="acceptTransfer(0, '.$row['transferoid'].', '.$row['convid'].');"><i class="fa fa-times"></i></a><a href="javascript:void(0)" class="btn btn-sm btn-success" onclick="acceptTransfer(1, '.$row['transferoid'].', '.$row['convid'].');"><i class="fa fa-check"></i></a></div></div>';
$transferid = $row['transferid'];
$jsmsg = sprintf($jkl['g110'], $trow["fromname"]);
$soundjs = JAK_RING_TONE;
}
}
// Only load if we are in the correct department
if (isset($_SESSION['usr_department']) && ($_SESSION['usr_department'] == 0 || $row["depid"] == $_SESSION['usr_department'] || in_array($row["depid"], explode(",", $_SESSION['usr_department'])) || $row["operatorid"] == $_GET['uid'])) {
// check for new conversations
if ($row['operatorid'] == 0 || ($row['operatorid'] == $_GET['uid'] && empty($row['operator']))) {
$newConv = 1;
if ($row["alert"] == 0) {
$jakdb->update("checkstatus", ["alert" => 1], ["convid" => $row['convid']]);
$sendalert = 1;
}
$newclient = $jkl['g69'];
$soundjs = JAK_RING_TONE;
if ($row['typec']) $typing[] = $row['convid'];
$convid[] = $row["convid"];
$loadClients = true;
}
if ($row['operatorid'] == $_GET['uid'] && !empty($row['operator'])) {
$jakdb->update("checkstatus", ["statuso" => $currentime], ["convid" => $row['convid']]);
if ($row['typec']) $typing[] = $row['convid'];
$convid[] = $row["convid"];
$loadClients = true;
}
if ($row['operatorid'] == $_GET['uid'] && $row['newo']) {
$msginfo = $jakdb->get("transcript", ["name", "message"], ["id" => $row['newo']]);
$newConv = 2;
$cname = $msginfo["name"];
$newmsg = $msginfo["message"];
$newtitle = $jkl['g70'];
$soundmsgjs = JAK_MSG_TONE;
$answers[] = $row['convid'];
if ($row['typec']) $typing[] = $row['convid'];
$convid[] = $row["convid"];
$loadClients = true;
}
}
}
}
// Reset convlist
$convlist = '';
// Now let's get the conversation list
$new = $updated = $current = array();
$count = 0;
// Only go for it if we want to
if ($loadClients) {
// Check if there is a new client, message or a transfer is awaiting for approval.
$resconv = $jakdb->select("sessions", ["[>]buttonstats" => ["session" => "session"]], ["sessions.id", "sessions.name", "sessions.operatorname", "sessions.countrycode", "sessions.status", "sessions.ended", "buttonstats.referrer"], ["sessions.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]["convid"] = $row['id'];
$new[$count]["countrycode"] = $row['countrycode'];
$new[$count]["referrer"] = $row['referrer'];
$new[$count]["typing"] = false;
if (!empty($typing) && in_array($row['id'], $typing)) $new[$count]["typing"] = true;
} elseif (!empty($answers) && $row['operatorname'] && in_array($row['id'], $answers)) {
$updated[$count]["name"] = $row['name'];
$updated[$count]["convid"] = $row['id'];
$updated[$count]["countrycode"] = $row['countrycode'];
$updated[$count]["referrer"] = $row['referrer'];
$updated[$count]["typing"] = false;
if (!empty($typing) && in_array($row['id'], $typing)) $updated[$count]["typing"] = true;
} else {
$current[$count]["name"] = $row['name'];
$current[$count]["convid"] = $row['id'];
$current[$count]["countrycode"] = $row['countrycode'];
$current[$count]["referrer"] = $row['referrer'];
$current[$count]["typing"] = false;
if (!empty($typing) && in_array($row['id'], $typing)) $current[$count]["typing"] = true;
}
}
if (!$row['status']) {
if ((($currentime - $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);
sort($new);
sort($updated);
sort($current);
$newTotal = count($new);
$updatedTotal = count($updated);
$currentTotal = count($current);
for($i = 0; $i < $newTotal; $i ++ ) {
$convlist .= '<a href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('live', $new[$i]["convid"])).'" class="dropdown-item a-confirm-chat" data-convid="'.$new[$i]["convid"].'" data-opid="'.$_GET['uid'].'" data-title="'.addslashes($jkl["g108"]).'" data-type="info" data-okbtn="'.addslashes($jkl["g283"]).'" data-cbtn="'.addslashes($jkl["g203"]).'">'.(isset($new[$i]['countrycode']) && !empty($new[$i]['countrycode'] && $new[$i]['countrycode'] != 'xx') ? '<img src="'.str_replace("ajax/", "", BASE_URL."img/blank.png").'" class="flag flag-'.$new[$i]['countrycode'].'"> ' : '').$new[$i]["name"].'<br>'.$new[$i]["referrer"].'&nbsp;<i class="material-icons">fiber_new</i></a>';
}
for($i = 0; $i < $updatedTotal; $i ++ ) {
$convlist .= '<a href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('live', $updated[$i]["convid"])).'" class="dropdown-item">'.(isset($updated[$i]['countrycode']) && !empty($updated[$i]['countrycode'] && $updated[$i]['countrycode'] != 'xx') ? '<img src="'.str_replace("ajax/", "", BASE_URL."img/blank.png").'" class="flag flag-'.$updated[$i]['countrycode'].'"> ' : '').$updated[$i]["name"].'<br>'.$updated[$i]["referrer"].'&nbsp;<span class="badge badge-'.($updated[$i]["typing"] ? 'success' : 'secondary').'">...</span></a>';
}
for($i = 0; $i < $currentTotal; $i ++ ) {
$convlist .= '<a href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('live', $current[$i]["convid"])).'" class="dropdown-item"> '.(isset($current[$i]['countrycode']) && !empty($current[$i]['countrycode'] && $current[$i]['countrycode'] != 'xx') ? '<img src="'.str_replace("ajax/", "", BASE_URL."img/blank.png").'" class="flag flag-'.$current[$i]['countrycode'].'"> ' : '').$current[$i]["name"].'<br>'.$current[$i]["referrer"].'&nbsp;<span class="badge badge-'.($current[$i]["typing"] ? 'success' : 'secondary').'">...</span></a>';
}
}
}
// Is the site we are on active or already expired
$activeconv = false;
if (is_array($convid) && in_array($_GET['activconv'], $convid)) $activeconv = true;
// Let us check the live preview file
$prevmsgonly = "";
$prevtxt = false;
if (isset($_GET['activconv']) && is_numeric($_GET['activconv']) && $activeconv) {
// Check the file from the cache directory
$livepreviewfile = APP_PATH.JAK_CACHE_DIRECTORY.'/livepreview'.$_GET['activconv'].'.txt';
if (file_exists($livepreviewfile)) {
$prev = $jakdb->get("sessions", ["name", "usr_avatar", "department"], ["id" => $_GET['activconv']]);
// Get the absolute url for the image
$ava_url = str_replace(JAK_OPERATOR_LOC.'/ajax/', '', BASE_URL);
$prevmsg = file_get_contents($livepreviewfile);
// We convert the br
$prevmsg = nl2br($prevmsg, false);
$prevtxt = '<div id="prevcontainer_'.$_GET['activconv'].'"><div class="media livepreview">
<img class="d-flex mr-3 img-thumbnail" src="'.$ava_url.$prev["usr_avatar"].'" width="53" height="53" alt="live preview">
<div class="media-body">
<h4 class="media-heading">'.$prev['name'].' <i class="fa fa-pencil"></i> <small>'.JAK_base::jakTimesince($currentime, "", JAK_TIMEFORMAT).'</small></h4>
<div class="media-text" id="prevmsg_'.$_GET['activconv'].'">'.stripcslashes($prevmsg).'</div>
</div>
</div>
<hr></div>';
$prevmsgonly = stripcslashes($prevmsg);
}
}
// Now get the new tickets that are not solved yet.
$tcount = 0;
$sup_tickets = array();
$utickets = "";
if (jak_get_access("support", $jakuser->getVar("permissions"), JAK_MAIN_OP)) {
// Now only get the department for the user
if (is_numeric($jakuser->getVar("support_dep")) && $jakuser->getVar("support_dep") != 0) {
$sup_tickets = $jakdb->select("support_tickets", ["[>]support_departments" => ["depid" => "id"]], ["support_tickets.id", "support_tickets.subject", "support_tickets.updated"], ["AND" => ["OR" => ["support_tickets.operatorid" => $jakuser->getVar("id"), "support_tickets.depid" => $jakuser->getVar("support_dep")], "support_tickets.opid" => $opcacheid, "support_tickets.status" => 1], "ORDER" => ["support_tickets.updated" => "DESC"], "LIMIT" => 10]);
} elseif (!((boolean)$jakuser->getVar("support_dep")) && $jakuser->getVar("support_dep") != 0) {
$sup_tickets = $jakdb->select("support_tickets", ["[>]support_departments" => ["depid" => "id"]], ["support_tickets.id", "support_tickets.subject", "support_tickets.updated"], ["AND" => ["OR" => ["support_tickets.operatorid" => $jakuser->getVar("id"), "support_tickets.depid" => [$jakuser->getVar("support_dep")]], "support_tickets.opid" => $opcacheid, "support_tickets.status" => 1], "ORDER" => ["support_tickets.updated" => "DESC"], "LIMIT" => 10]);
} else {
$sup_tickets = $jakdb->select("support_tickets", ["[>]support_departments" => ["depid" => "id"]], ["support_tickets.id", "support_tickets.subject", "support_tickets.updated"], ["AND" => ["support_tickets.opid" => $opcacheid, "support_tickets.status" => 1], "ORDER" => ["support_tickets.updated" => "DESC"], "LIMIT" => 10]);
}
if (isset($sup_tickets) && !empty($sup_tickets)) {
foreach ($sup_tickets as $ti) {
$utickets .= '<a href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('support', 'read', $ti["id"])).'" class="dropdown-item">'.$ti["subject"].'&nbsp;<span class="badge badge-secondary">'.JAK_base::jakTimesince($ti["updated"], JAK_DATEFORMAT, JAK_TIMEFORMAT).'</span></a>';
$tcount = $tcount + 1;
}
}
}
die(json_encode(array("useronline" => $useronline, "useronlinemap" => $useronlinemap, "totalonline" => $userocount, "nouseronline" => $jkl['i3'], "oponline" => $oponline, 'newc' => $newConv, 'tid' => $transferid, 'tmsg' => $transfer_msg, 'jsmsg' => $jsmsg, 'newclient' => $newclient, 'soundjs' => $soundjs, 'soundalert' => $sendalert, 'cname' => $cname, 'newmsg' => $newmsg, 'newtitle' => $newtitle, 'soundmsgjs' => $soundmsgjs, "conversation" => $convlist, "tickets" => $utickets, "noconv" => $jkl['g79'], 'totalchats' => $count, 'totaltickets' => $tcount, 'totalops' => $countop, 'previewmsg' => $prevtxt, 'prevmsgonly' => $prevmsgonly)));
?>
+52
View File
@@ -0,0 +1,52 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 1.0 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[config.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (!file_exists('../../class/ssp.class.php')) die('ajax/[ssp.class.php] config.php not exist');
require_once '../../class/ssp.class.php';
$where = 't1.opid = '.$opcacheid;
// DB table to use
$table = JAKDB_PREFIX.'subscriptions_client AS t1';
$table2 = ' LEFT JOIN '.JAKDB_PREFIX.'clients AS t2 ON (t1.clientid = t2.id)';
// Table's primary key
$primaryKey = 't1.id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array( 'db' => 't1.id', 'dbjoin' => 'id', 'dt' => 0 ),
array( 'db' => 't1.id', 'dbjoin' => 'id', 'dt' => 1, 'formatter' => function( $d, $row ) {
return '<input type="checkbox" name="jak_delete_subscriptions[]" class="highlight" value="'.$d.'">';
} ),
array( 'db' => 't2.email', 'dbjoin' => 'email', 'dt' => 2, 'formatter' => function( $d, $row ) {
return '<a class="btn btn-sm btn-primary" href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('users', 'clients', 'edit', $row['clientid'])).'">'.$d.'</a>';
} ),
array( 'db' => 't1.amount', 'dbjoin' => 'amount', 'dt' => 3 ),
array( 'db' => 't1.currency', 'dbjoin' => 'currency', 'dt' => 4 ),
array( 'db' => 't1.paidwhen', 'dbjoin' => 'paidwhen', 'dt' => 5, 'formatter' => function( $d, $row ) {
return JAK_base::jakTimesince($d, JAK_DATEFORMAT, JAK_TIMEFORMAT);
} ),
array( 'db' => 't1.paidhow', 'dbjoin' => 'paidhow', 'dt' => 6 ),
array( 'db' => 't1.success', 'dbjoin' => 'success', 'dt' => 7, 'formatter' => function( $d, $row ) {
return ($d == 1 ? '<i class="fa fa-check"></i>' : '<i class="fa fa-times"></i>');
} ),
array( 'db' => 't1.clientid', 'dbjoin' => 'clientid', 'dt' => 'tdc' )
);
die(json_encode(SSP::join( $_GET, $table, $table2, '', $primaryKey, $columns, $where, $where )));
?>
+132
View File
@@ -0,0 +1,132 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 2.1.3 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2023 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[config.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (!file_exists('../../class/ssp.class.php')) die('ajax/[ssp.class.php] config.php not exist');
require_once '../../class/ssp.class.php';
$where = 't1.opid = '.$opcacheid;
if (isset($_SESSION["sortdepid"]) || isset($_SESSION["sortopid"]) || isset($_SESSION["sortstatus"])) {
if (isset($_SESSION["sortstatus"]) && is_numeric($_SESSION["sortstatus"]) && isset($_SESSION["sortdepid"]) && is_numeric($_SESSION["sortdepid"]) && isset($_SESSION["sortopid"]) && is_numeric($_SESSION["sortopid"])) {
$where .= ' AND t1.status = '.$_SESSION["sortstatus"].' AND t1.operatorid = '.$_SESSION["sortopid"].' AND t1.depid = '.$_SESSION["sortdepid"];
} elseif (isset($_SESSION["sortstatus"]) && is_numeric($_SESSION["sortstatus"]) && isset($_SESSION["sortdepid"]) && is_numeric($_SESSION["sortdepid"]) && !isset($_SESSION["sortopid"])) {
$where .= ' AND t1.status = '.$_SESSION["sortstatus"].' AND t1.depid = '.$_SESSION["sortdepid"];
} elseif (isset($_SESSION["sortstatus"]) && is_numeric($_SESSION["sortstatus"]) && isset($_SESSION["sortopid"]) && is_numeric($_SESSION["sortopid"]) && !isset($_SESSION["sortdepid"])) {
$where .= ' AND t1.status = '.$_SESSION["sortstatus"].' AND t1.operatorid = '.$_SESSION["sortopid"];
} elseif (isset($_SESSION["sortdepid"]) && is_numeric($_SESSION["sortdepid"]) && isset($_SESSION["sortopid"]) && is_numeric($_SESSION["sortopid"]) && !isset($_SESSION["sortstatus"])) {
$where .= ' AND t1.operatorid = '.$_SESSION["sortopid"].' AND t1.depid = '.$_SESSION["sortdepid"];
} elseif (isset($_SESSION["sortdepid"]) && is_numeric($_SESSION["sortdepid"]) && !isset($_SESSION["sortopid"]) && !isset($_SESSION["sortstatus"])) {
$where .= ' AND t1.depid = '.$_SESSION["sortdepid"];
} elseif (isset($_SESSION["sortopid"]) && is_numeric($_SESSION["sortopid"]) && !isset($_SESSION["sortdepid"]) && !isset($_SESSION["sortstatus"])) {
$where .= ' AND t1.operatorid = '.$_SESSION["sortopid"];
} elseif (isset($_SESSION["sortstatus"]) && is_numeric($_SESSION["sortstatus"]) && !isset($_SESSION["sortopid"]) && !isset($_SESSION["sortdepid"])) {
$where .= ' AND t1.status = '.$_SESSION["sortstatus"];
}
}
// and then we filter the support departments
if (is_numeric($jakuser->getVar("support_dep")) && $jakuser->getVar("support_dep") != 0) {
if (isset($_SESSION["sortstatus"]) && is_numeric($_SESSION["sortstatus"])) {
$where .= 't1.status = '.$_SESSION["sortstatus"].' AND (t1.operatorid = '.$jakuser->getVar("id").' OR t1.depid = '.$jakuser->getVar("support_dep").')';
} else {
$where .= 't1.operatorid = '.$jakuser->getVar("id").' OR t1.depid = '.$jakuser->getVar("support_dep");
}
} elseif (!is_numeric($jakuser->getVar("support_dep")) && $jakuser->getVar("support_dep") != 0) {
if (isset($_SESSION["sortstatus"]) && is_numeric($_SESSION["sortstatus"])) {
$where .= 't1.status = '.$_SESSION["sortstatus"].' AND (t1.operatorid = '.$jakuser->getVar("id").' OR t1.depid IN ('.$jakuser->getVar("support_dep").'))';
} else {
$where .= 't1.operatorid = '.$jakuser->getVar("id").' OR t1.depid IN ('.$jakuser->getVar("support_dep").')';
}
} else {
if (isset($_SESSION["sortstatus"]) && is_numeric($_SESSION["sortstatus"])) {
$where .= 't1.status = '.$_SESSION["sortstatus"];
}
}
// DB table to use
$table = JAKDB_PREFIX.'support_tickets AS t1';
$table2 = ' LEFT JOIN '.JAKDB_PREFIX.'support_departments AS t2 ON (t1.depid = t2.id)';
$table3 = '';
// Table's primary key
$primaryKey = 't1.id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array( 'db' => 't1.id', 'dbjoin' => 'id', 'dt' => 0, 'formatter' => function( $d, $row ) {
return '<input type="checkbox" name="jak_delete_tickets[]" class="highlight" value="'.$d.'">';
} ),
array( 'db' => 't1.id', 'dbjoin' => 'id', 'dt' => 1, 'formatter' => function( $d, $row ) {
return '#'.$d;
} ),
array( 'db' => 't1.subject', 'dbjoin' => 'subject', 'dt' => 2, 'formatter' => function( $d, $row ) {
return '<a class="btn btn-sm btn-primary" href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('support', 'read', $row['id'])).'">'.$d.'</a>'.($row['mergeid'] ? ' <a class="btn btn-sm btn-default" href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('support', 'read', $row['mergeid'])).'"><i class="fa fa-compress"></i></a>' : '');
} ),
array( 'db' => 't2.title', 'dbjoin' => 'title', 'dt' => 3 ),
array( 'db' => 't1.name', 'dbjoin' => 'name', 'dt' => 4 ),
array( 'db' => 't1.private', 'dbjoin' => 'private', 'dt' => 5, 'formatter' => function( $d, $row ) {
return (isset($d) && $d != 0 ? '<i class="fa fa-check"></i>' : '<i class="fa fa-times"></i>');
} ),
array( 'db' => 't1.attachments', 'dbjoin' => 'attachments', 'dt' => 6, 'formatter' => function( $d, $row ) {
return (isset($d) && $d != 0 ? '<i class="fa fa-check"></i>' : '<i class="fa fa-times"></i>');
} ),
array( 'db' => 't1.reminder', 'dbjoin' => 'reminder', 'dt' => 7, 'formatter' => function( $d, $row ) {
return (isset($d) && $d == 3 ? '<a href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('support', 'rating', $row['id'])).'" data-toggle="modal" data-target="#jakModal"><i class="fa fa-check"></i></a>' : '<i class="fa fa-times"></i>');
} ),
array( 'db' => 't1.status', 'dbjoin' => 'status', 'dt' => 8, 'formatter' => function( $d, $row ) {
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include (APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include (APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
// Now include the stuff
global $HD_SUPPORT_STATUS;
$support_status = '';
if (isset($HD_SUPPORT_STATUS) && !empty($HD_SUPPORT_STATUS)) foreach ($HD_SUPPORT_STATUS as $v) {
$support_status .= '<a href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('support', 'status', $row['id'], $v['id'], $v['closed'])).'" class="dropdown-item">'.$v["title"].($d == $v['id'] ? '&nbsp;<i class="fa fa-check"></i>' : '').'</a>';
}
return '<div class="btn-group">
<button id="ticket_status_change" type="button" class="btn btn-secondary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-cog"></i>
</button>
<div class="dropdown-menu" aria-labelledby="ticket_status_change">
'.$support_status.'
</div>
</div>';
} ),
array( 'db' => 't1.updated', 'dbjoin' => 'updated', 'dt' => 9, 'formatter' => function( $d, $row ) {
return JAK_base::jakTimesince($d, JAK_DATEFORMAT, JAK_TIMEFORMAT);
} ),
array( 'db' => 't1.status', 'dbjoin' => 'status', 'dt' => 'tdc' , 'formatter' => function( $d, $row ) {
// Now include the stuff
global $HD_SUPPORT_STATUS;
if (isset($HD_SUPPORT_STATUS) && !empty($HD_SUPPORT_STATUS)) foreach ($HD_SUPPORT_STATUS as $v) {
if ($v["id"] == $d) {
return $v["class"];
} }
} ),
array( 'db' => 't1.mergeid', 'dbjoin' => 'mergeid', 'dt' => 'mid' )
);
die(json_encode(SSP::join( $_GET, $table, $table2, $table3, $primaryKey, $columns, $where, $where )));
?>
+142
View File
@@ -0,0 +1,142 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 2.1.3 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2023 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[config.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (!file_exists('../../class/ssp.class.php')) die('ajax/[ssp.class.php] config.php not exist');
require_once '../../class/ssp.class.php';
$where = 't1.opid = '.$opcacheid;
if (isset($_GET["filter"]) && !empty($_GET["filter"])) {
if ($_GET["filter"] == "tomorrow") {
$where .= ' AND t1.duedate = CURDATE() + INTERVAL 1 DAY AND (t1.status = 1 OR t1.status = 2)';
} elseif ($_GET["filter"] == "allopen") {
$where .= ' AND (t1.status = 1 OR t1.status = 2)';
} elseif ($_GET["filter"] == "allclosed") {
$where .= 'AND (t1.status = 3 OR t1.status = 4)';
} elseif ($_GET["filter"] == "alltickets") {
$where .= ' AND t1.initiated != 0';
}
} else {
$where .= ' AND t1.duedate <= CURDATE() AND (t1.status = 1 OR t1.status = 2)';
}
// Custom Filters
if (isset($_SESSION["sortdepid"]) || isset($_SESSION["sortopid"]) || isset($_SESSION["sortstatus"])) {
if (isset($_SESSION["sortstatus"]) && is_numeric($_SESSION["sortstatus"]) && isset($_SESSION["sortdepid"]) && is_numeric($_SESSION["sortdepid"]) && isset($_SESSION["sortopid"]) && is_numeric($_SESSION["sortopid"])) {
$where .= ' AND t1.status = '.$_SESSION["sortstatus"].' AND t1.operatorid = '.$_SESSION["sortopid"].' AND t1.depid = '.$_SESSION["sortdepid"];
} elseif (isset($_SESSION["sortstatus"]) && is_numeric($_SESSION["sortstatus"]) && isset($_SESSION["sortdepid"]) && is_numeric($_SESSION["sortdepid"]) && !isset($_SESSION["sortopid"])) {
$where .= ' AND t1.status = '.$_SESSION["sortstatus"].' AND t1.depid = '.$_SESSION["sortdepid"];
} elseif (isset($_SESSION["sortstatus"]) && is_numeric($_SESSION["sortstatus"]) && isset($_SESSION["sortopid"]) && is_numeric($_SESSION["sortopid"]) && !isset($_SESSION["sortdepid"])) {
$where .= ' AND t1.status = '.$_SESSION["sortstatus"].' AND t1.operatorid = '.$_SESSION["sortopid"];
} elseif (isset($_SESSION["sortdepid"]) && is_numeric($_SESSION["sortdepid"]) && isset($_SESSION["sortopid"]) && is_numeric($_SESSION["sortopid"]) && !isset($_SESSION["sortstatus"])) {
$where .= ' AND t1.operatorid = '.$_SESSION["sortopid"].' AND t1.depid = '.$_SESSION["sortdepid"];
} elseif (isset($_SESSION["sortdepid"]) && is_numeric($_SESSION["sortdepid"]) && !isset($_SESSION["sortopid"]) && !isset($_SESSION["sortstatus"])) {
$where .= ' AND t1.depid = '.$_SESSION["sortdepid"];
} elseif (isset($_SESSION["sortopid"]) && is_numeric($_SESSION["sortopid"]) && !isset($_SESSION["sortdepid"]) && !isset($_SESSION["sortstatus"])) {
$where .= ' AND t1.operatorid = '.$_SESSION["sortopid"];
} elseif (isset($_SESSION["sortstatus"]) && is_numeric($_SESSION["sortstatus"]) && !isset($_SESSION["sortopid"]) && !isset($_SESSION["sortdepid"])) {
$where .= ' AND t1.status = '.$_SESSION["sortstatus"];
}
}
// and then we filter the support departments
if (is_numeric($jakuser->getVar("support_dep")) && $jakuser->getVar("support_dep") != 0) {
if (isset($_SESSION["sortstatus"]) && is_numeric($_SESSION["sortstatus"])) {
$where .= ' AND t1.status = '.$_SESSION["sortstatus"].' AND (t1.operatorid = '.$jakuser->getVar("id").' OR t1.depid = '.$jakuser->getVar("support_dep").')';
} else {
$where .= ' AND (t1.operatorid = '.$jakuser->getVar("id").' OR t1.depid = '.$jakuser->getVar("support_dep").')';
}
} elseif (!is_numeric($jakuser->getVar("support_dep")) && $jakuser->getVar("support_dep") != 0) {
if (isset($_SESSION["sortstatus"]) && is_numeric($_SESSION["sortstatus"])) {
$where .= ' AND t1.status = '.$_SESSION["sortstatus"].' AND (t1.operatorid = '.$jakuser->getVar("id").' OR t1.depid IN ('.$jakuser->getVar("support_dep").'))';
} else {
$where .= ' AND (t1.operatorid = '.$jakuser->getVar("id").' OR t1.depid IN ('.$jakuser->getVar("support_dep").'))';
}
} else {
if (isset($_SESSION["sortstatus"]) && is_numeric($_SESSION["sortstatus"])) {
$where .= ' AND t1.status = '.$_SESSION["sortstatus"];
}
}
// DB table to use
$table = JAKDB_PREFIX.'support_tickets AS t1';
$table2 = ' LEFT JOIN '.JAKDB_PREFIX.'support_departments AS t2 ON (t1.depid = t2.id)';
$table3 = '';
// Table's primary key
$primaryKey = 't1.id';
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case simple
// indexes
$columns = array(
array( 'db' => 't1.id', 'dbjoin' => 'id', 'dt' => 0 ),
array( 'db' => 't1.id', 'dbjoin' => 'id', 'dt' => 1, 'formatter' => function( $d, $row ) {
return '<input type="checkbox" name="jak_delete_tickets[]" class="highlight" value="'.$d.'">';
} ),
array( 'db' => 't1.subject', 'dbjoin' => 'subject', 'dt' => 2, 'formatter' => function( $d, $row ) {
return '<a href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('support', 'read', $row['id'])).'">'.$d.'</a>'.($row['mergeid'] ? ' <a class="badge badge-info" href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('support', 'read', $row['mergeid'])).'"><i class="fa fa-compress"></i></a>' : '');
} ),
array( 'db' => 't2.title', 'dbjoin' => 'title', 'dt' => 3 ),
array( 'db' => 't1.name', 'dbjoin' => 'name', 'dt' => 4 ),
array( 'db' => 't1.private', 'dbjoin' => 'private', 'dt' => 5, 'formatter' => function( $d, $row ) {
return (isset($d) && $d != 0 ? '<i class="fa fa-check"></i>' : '<i class="fa fa-times"></i>');
} ),
array( 'db' => 't1.attachments', 'dbjoin' => 'attachments', 'dt' => 6, 'formatter' => function( $d, $row ) {
return (isset($d) && $d != 0 ? '<i class="fa fa-check"></i>' : '<i class="fa fa-times"></i>');
} ),
array( 'db' => 't1.reminder', 'dbjoin' => 'reminder', 'dt' => 7, 'formatter' => function( $d, $row ) {
return (isset($d) && $d == 3 ? '<a href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('support', 'rating', $row['id'])).'" data-toggle="modal" data-target="#jakModal"><i class="fa fa-check"></i></a>' : '<i class="fa fa-times"></i>');
} ),
array( 'db' => 't1.status', 'dbjoin' => 'status', 'dt' => 8, 'formatter' => function( $d, $row ) {
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include (APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include (APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
// Now include the stuff
global $HD_SUPPORT_STATUS;
$support_status = '';
if (isset($HD_SUPPORT_STATUS) && !empty($HD_SUPPORT_STATUS)) foreach ($HD_SUPPORT_STATUS as $v) {
$support_status .= '<a href="'.str_replace('ajax/', '', JAK_rewrite::jakParseurl('support', 'status', $row['id'], $v['id'], $v['closed'])).'" class="dropdown-item">'.$v["title"].($d == $v['id'] ? '&nbsp;<i class="fa fa-check"></i>' : '').'</a>';
}
return '<div class="btn-group">
<button id="ticket_status_change" type="button" class="btn btn-secondary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-cog"></i>
</button>
<div class="dropdown-menu" aria-labelledby="ticket_status_change">
'.$support_status.'
</div>
</div>';
} ),
array( 'db' => 't1.duedate', 'dbjoin' => 'duedate', 'dt' => 9, 'formatter' => function( $d, $row ) {
// Explode the time format so it is always available
$duedateformat = explode(":#:", JAK_TICKET_DUEDATE_FORMAT);
return date($duedateformat[0], strtotime($d));
} ),
array( 'db' => 't1.status', 'dbjoin' => 'status', 'dt' => 'tdc' ),
array( 'db' => 't1.mergeid', 'dbjoin' => 'mergeid', 'dt' => 'mid' )
);
die(json_encode(SSP::join( $_GET, $table, $table2, $table3, $primaryKey, $columns, $where, $where )));
?>
+78
View File
@@ -0,0 +1,78 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 3.2.2 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[available.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (is_numeric($_POST['id']) && is_numeric($_POST['userid'])) {
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
$lang = $_SESSION['jak_lcp_lang'];
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
$lang = JAK_LANG;
}
// Get the operator
$operator = $jakdb->get("user", ["username", "name"], ["id" => $_POST["userid"]]);
// Set the operator and other stuff
$sessup = $jakdb->update("sessions", ["operatorid" => $_POST['userid'], "operatorname" => $operator['name']], ["AND" => ["operatorid" => [0, $_POST['userid']], "id" => $_POST["id"]]]);
if ($sessup) {
// Update the checkstatus table
$jakdb->update("checkstatus", ["newc" => 1, "operatorid" => $_POST['userid'], "operator" => $operator['name'], "pusho" => $_POST['pusho'], "statuso" => time()], ["convid" => $_POST["id"]]);
// Check if it is a client and if we have a credit based system active
if (JAK_BILLING_MODE == 1) {
$client = $jakdb->get("sessions", ["clientid", "credits"], ["AND" => ["id" => $_POST["id"], "clientid[!]" => 0, "credits[!]" => 0]]);
if ($client) {
$jakdb->update("clients", ["credits[-]" => $client["credits"]], ["id" => $client["clientid"]]);
$jakdb->insert("taken_credits", ["clientid" => $client["clientid"], "operatorid" => $_POST['userid'], "credits" => $client["credits"], "created" => $jakdb->raw("NOW()")]);
}
}
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" => $_POST["id"]]);
$phold = array("%operator%","%client%","%email%");
$replace = array($operator['name'], $clientname, JAK_EMAIL);
$message = str_replace($phold, $replace, $v["message"]);
$jakdb->insert("transcript", [
"name" => $operator['name'],
"message" => $message,
"user" => $_POST['userid'].'::'.$operator['username'],
"operatorid" => $_POST['userid'],
"convid" => $_POST['id'],
"class" => "admin",
"time" => $jakdb->raw("NOW()")]);
}
}
die(json_encode(array('cid' => $_POST['id'])));
} else {
die(json_encode(array('cid' => 0)));
}
} else {
die(json_encode(array('cid' => 0)));
}
?>
+34
View File
@@ -0,0 +1,34 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 1.0.3 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[available.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (!is_numeric($_POST['id'])) die("There is no such user!");
// Sanitize the user status
$ustatus = filter_var($_POST['ops'], FILTER_SANITIZE_NUMBER_INT);
// Set status to false
$status = 0;
// Check if user is logged in
if (JAK_USERID) {
// Update User
$jakdb->update("user", ["available" => $ustatus, "lastactivity" => time(), "session" => session_id()], ["id" => JAK_USERID]);
// Check if it is succesful
$status = 1;
}
die(json_encode(array('status' => $status, 'usrstatus' => $ustatus)));
?>
+104
View File
@@ -0,0 +1,104 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 2.1.2 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2023 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[available.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
if (is_numeric($_GET['id']) && is_numeric($_GET['userid'])) {
$timeout = 180;
$operator = '';
$udepl = array();
$result = $jakdb->select("user", ["id", "hours_array", "phonenumber", "available", "emailnot", "pusho_tok", "push_notifications", "chat_dep", "username", "name", "lastactivity"], ["AND" => ["OR" => ["id" => $opcacheid, "opid" => $opcacheid], "id[!]" => $_GET['userid'], "access" => 1]]);
if (isset($result) && !empty($result)) {
foreach ($result as $row) {
if (time() > ($row['lastactivity'] + $timeout)) {
$jakdb->update("user", ["available" => 0], ["id" => $row['userid']]);
}
if ($row["chat_dep"] == 0) {
$udep = $jkl['g105'];
} else {
if (isset($HD_DEPARTMENTS) && is_array($HD_DEPARTMENTS)) foreach($HD_DEPARTMENTS 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;
$oponline = false;
// Operator is available
if ($row["available"] == 1) {
$operator .= '<option value="'.$row['id'].'">'.$row['name'].' - '.$row['username'].' ('.$udep.')</option>';
$oponline = true;
}
// Now let's check if we have a time available
if (!$oponline && JAK_base::jakAvailableHours($row["hours_array"], date('Y-m-d H:i:s')) && ($row["phonenumber"] || $row["emailnot"] || JAK_NATIVE_APP_TOKEN || $row["pusho_tok"] || $row["push_notifications"])) {
$operator .= '<option value="'.$row['id'].'">'.$row['name'].' - '.$row['username'].' ('.$udep.')</option>';
}
}
}
if ($operator) {
$oselect = $operator;
$showbutton = '<hr><button class="btn btn-primary btn-block" type="submit" name="transfer_customer">'.$jkl['g4'].'</button>';
} else {
$oselect = '<option value="0">'.$jkl['g114'].'</option>';
$showbutton = '';
}
echo '<div class="modal-header"><h4 class="modal-title">'.JAK_TITLE.'</h4>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
</div>
<div class="modal-body"><div class="padded-box"><form method="post" role="form" action="'.str_replace('ajax/', '', BASE_URL).'index.php">';
echo '<p>'.$jkl['g112'].'</p>';
echo '
<label for="transfermsg">'.$jkl['g113'].'</label>
<input type="text" name="transfermsg" id="transfermsg" class="form-control">
<label for="operator">'.$jkl['g106'].'</label>
<select name="operator" id="operator" class="form-control">
'.$oselect.'
</select>
<input type="hidden" name="cid" id="cid" value="'.$_GET['id'].'">
'.$showbutton.'
</form></div></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">'.$jkl["g180"].'</button>
</div>';
}
?>
+329
View File
@@ -0,0 +1,329 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 2.1.4 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2023 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[available.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
$switchtl = $iso_code_clean = "";
if (isset($_POST['wsource']) && !empty($_POST['wsource'])) $switchtl = $_POST['wsource'];
switch($switchtl) {
case 'answer':
// Let's filter some inputs
$tid = filter_var($_POST['id'], FILTER_SANITIZE_NUMBER_INT);
$aid = filter_var($_POST['aid'], FILTER_SANITIZE_NUMBER_INT);
if (!is_numeric($tid)) die(json_encode(array('status' => 0, "txt" => $jkl['g116'])));
$row = $jakdb->get("support_tickets", ["content", "lang"], ["id" => $tid]);
if (isset($row) && !empty($row)) {
if ($aid != 0 && is_numeric($tid) && is_numeric($aid)) {
$row2 = $jakdb->get("ticket_answers", ["content"], ["AND" => ["id" => $aid, "ticketid" => $tid]]);
$row3 = $jakdb->get("ticket_ai_translations", ["original_lang", "translated_lang", "lang"], ["AND" => ["opid" => $opcacheid, "ticketid" => $tid, "ticketanswerid" => $aid]]);
} else {
$row2["content"] = $row["content"];
$row3 = $jakdb->get("ticket_ai_translations", ["original_lang", "translated_lang", "lang"], ["AND" => ["opid" => $opcacheid, "ticketid" => $tid, "ticketanswerid" => 0]]);
}
// We check if the text is the same and the translation has already been done
if (isset($row3["lang"]) && $row3["lang"] == $_SESSION['jak_lcp_lang']) {
// We can assume that the translation has been done, so we do not need to run it again and pay money for it
$translation = $row3["translated_lang"];
} else {
// We have previous messages
$translation_msg = [];
// User Subject
$translation_msg[] = [
"role" => "user",
"content" => "Please translate this text into following language with iso code '".$_SESSION['jak_lcp_lang']."': ".$row2["content"]
];
// We have no translation so far, let's call the AI service
$jsonData = json_encode(array(
"model" => "gpt-3.5-turbo",
"temperature" => 0.3,
"messages" => $translation_msg
));
// cURL initialization
$ch = curl_init();
// Set cURL options
curl_setopt($ch, CURLOPT_URL, 'https://api.openai.com/v1/chat/completions');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer ".JAK_OPENAI_APIKEY,
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
// Execute the cURL request
$response = curl_exec($ch);
// Close cURL connection
curl_close($ch);
//die(print_r($response."<br>". curl_error($ch)));
// die(json_encode(array('status' => 0, "txt" => print_r($response."<br>". curl_error($ch)))));
// Handle the response
if ($response === false) {
// Error handling
die(json_encode(array('status' => 0, "txt" => $jkl['i2'])));
// echo 'cURL error: ' . curl_error($ch);
} else {
// Process the response
$translation = "";
$responseData = json_decode($response, true);
// Check if we have a valid answer
if (isset($responseData['choices'][0]['message']['content'])) $translation = html_entity_decode(filter_var($responseData['choices'][0]['message']['content'], FILTER_SANITIZE_FULL_SPECIAL_CHARS));
}
// We do have a translation?
if (!empty($translation)) {
// Add the values to the database
$jakdb->insert("ticket_ai_translations", [
"opid" => $opcacheid,
"ticketid" => $tid,
"ticketanswerid" => $aid,
"operatorid" => $_POST['uid'],
"original_lang" => $row2["content"],
"translated_lang" => $translation,
"lang" => $_SESSION['jak_lcp_lang'],
"created" => $jakdb->raw("NOW()")]);
// Now we need to know the original language from the text
if (empty($row["lang"])) {
// We have previous messages
$iso_code_msg = [];
// User Subject
$iso_code_msg[] = [
"role" => "user",
"content" => "Please return the language iso code for following text: ".$row2["content"]
];
// We have no translation so far, let's call the AI service
$jsonData2 = json_encode(array(
"model" => "gpt-3.5-turbo",
"temperature" => 0.5,
"messages" => $iso_code_msg
));
// cURL initialization
$ch2 = curl_init();
// Set cURL options
curl_setopt($ch2, CURLOPT_URL, 'https://api.openai.com/v1/chat/completions');
curl_setopt($ch2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch2, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch2, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer ".JAK_OPENAI_APIKEY,
]);
curl_setopt($ch2, CURLOPT_POSTFIELDS, $jsonData2);
// Execute the cURL request
$response2 = curl_exec($ch2);
// Close cURL connection
curl_close($ch2);
// die(print_r($response."<br>". curl_error($ch2)));
// die(json_encode(array('status' => 0, "txt" => print_r($response2."<br>". curl_error($ch2)))));
// Handle the response
if ($response2 === false) {
// Error handling
// die(json_encode(array('status' => 0, "txt" => $jkl['i2'])));
// echo 'cURL error: ' . curl_error($ch2);
} else {
// Process the response
$iso_code = "";
$responseData2 = json_decode($response2, true);
// Check if we have a valid answer
if (isset($responseData2['choices'][0]['message']['content'])) $iso_code = $responseData2['choices'][0]['message']['content'];
// Regular expression pattern to find text inside double quotes
$pattern = '/"([^"]+)"/';
// Use preg_match_all to find all matches
if (preg_match($pattern, $iso_code, $matches)) {
// $matches[0] contains the full matches including the double quotes
// $matches[1] contains the text inside the double quotes
$iso_code_clean = $matches[1];
// We update the database
$jakdb->update("support_tickets", ["lang" => $iso_code_clean], ["id" => $tid]);
}
}
}
} else {
die(json_encode(array('status' => 0, "txt" => $jkl['i2'])));
}
}
die(json_encode(array('status' => 1, "translation" => $translation, "lang" => $iso_code_clean, "txt" => $jkl['g14'])));
} else {
die(json_encode(array('status' => 0, "txt" => $jkl['i2'])));
}
break;
case 'grammar':
if (isset($_POST['tcontent']) && !empty($_POST['tcontent'])) {
// We will check the grammar from the input
$grammar_check = [];
// User Subject
$grammar_check[] = [
"role" => "user",
"content" => "Please correct grammar, and generate a more formal language for the following text, keep the format: ".$_POST['tcontent']
];
// We have no translation so far, let's call the AI service
$jsonData3 = json_encode(array(
"model" => "gpt-3.5-turbo",
"temperature" => 0.3,
"messages" => $grammar_check
));
// cURL initialization
$ch3 = curl_init();
// Set cURL options
curl_setopt($ch3, CURLOPT_URL, 'https://api.openai.com/v1/chat/completions');
curl_setopt($ch3, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch3, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch3, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer ".JAK_OPENAI_APIKEY,
]);
curl_setopt($ch3, CURLOPT_POSTFIELDS, $jsonData3);
// Execute the cURL request
$response3 = curl_exec($ch3);
// Close cURL connection
curl_close($ch3);
// die(print_r($response."<br>". curl_error($ch3)));
// die(json_encode(array('status' => 0, "txt" => print_r($response3."<br>". curl_error($ch3)))));
// Handle the response
if ($response3 === false) {
// Error handling
die(json_encode(array('status' => 0, "txt" => $jkl['i2'])));
// echo 'cURL error: ' . curl_error($ch);
} else {
// Process the response
$grammar_correct = "";
$responseData3 = json_decode($response3, true);
// Check if we have a valid answer
if (isset($responseData3['choices'][0]['message']['content'])) $grammar_correct = html_entity_decode(filter_var($responseData3['choices'][0]['message']['content'], FILTER_SANITIZE_FULL_SPECIAL_CHARS));
}
die(json_encode(array('status' => 2, "grammar_correct" => $grammar_correct, "txt" => $jkl['g14'])));
} else {
die(json_encode(array('status' => 0, "txt" => $jkl['i2'])));
}
break;
case 'translate':
if (isset($_POST['tcontent']) && !empty($_POST['tcontent']) && !empty($_POST['lang'])) {
// We will check the grammar from the input
$translation_go = [];
// User Subject
$translation_go[] = [
"role" => "user",
"content" => "Please translate this text into following language with iso code '".$_POST['lang']."': ".$_POST['tcontent']
];
// We have no translation so far, let's call the AI service
$jsonData4 = json_encode(array(
"model" => "gpt-3.5-turbo",
"temperature" => 0.3,
"messages" => $translation_go
));
// cURL initialization
$ch4 = curl_init();
// Set cURL options
curl_setopt($ch4, CURLOPT_URL, 'https://api.openai.com/v1/chat/completions');
curl_setopt($ch4, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch4, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch4, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer ".JAK_OPENAI_APIKEY,
]);
curl_setopt($ch4, CURLOPT_POSTFIELDS, $jsonData4);
// Execute the cURL request
$response4 = curl_exec($ch4);
// Close cURL connection
curl_close($ch4);
// die(print_r($response."<br>". curl_error($ch4)));
// die(json_encode(array('status' => 0, "txt" => print_r($response4."<br>". curl_error($ch4)))));
// Handle the response
if ($response4 === false) {
// Error handling
die(json_encode(array('status' => 0, "txt" => $jkl['i2'])));
// echo 'cURL error: ' . curl_error($ch);
} else {
// Process the response
$translate_correct = "";
$responseData4 = json_decode($response4, true);
// Check if we have a valid answer
if (isset($responseData4['choices'][0]['message']['content'])) $translate_correct = html_entity_decode(filter_var($responseData4['choices'][0]['message']['content'], FILTER_SANITIZE_FULL_SPECIAL_CHARS));
}
die(json_encode(array('status' => 3, "translate_correct" => $translate_correct, "txt" => $jkl['g14'])));
} else {
die(json_encode(array('status' => 0, "txt" => $jkl['i2'])));
}
break;
}
?>
+29
View File
@@ -0,0 +1,29 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH # ||
|| # ----------------------------------------- # ||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[available.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (is_numeric($_POST['conv'])) {
if ($_POST['status'] == 1) {
$result = $jakdb->update("checkstatus", ["typeo" => 1], ["convid" => $_POST['conv']]);
} else {
$result = $jakdb->update("checkstatus", ["typeo" => 0], ["convid" => $_POST['conv']]);
}
if ($result) die(json_encode(array('tid' => 1)));
} else {
die(json_encode(array('tid' => 0)));
}
?>
+30
View File
@@ -0,0 +1,30 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH # ||
|| # ----------------------------------------- # ||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[available.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
if (!is_numeric($_POST['id'])) die("There is no such user!");
$sendfile = $jakdb->get("checkstatus", "files", ["convid" => $_POST['id']]);
if ($sendfile == 1) {
$jakdb->update("checkstatus", ["files" => 0], ["convid" => $_POST['id']]);
die(json_encode(array('status' => 1)));
} else {
$jakdb->update("checkstatus", ["files" => 1], ["convid" => $_POST['id']]);
die(json_encode(array('status' => 0)));
}
?>
+55
View File
@@ -0,0 +1,55 @@
<?php
/*===============================================*\
|| ############################################# ||
|| # JAKWEB.CH / Version 1.0 # ||
|| # ----------------------------------------- # ||
|| # Copyright 2019 JAKWEB All Rights Reserved # ||
|| ############################################# ||
\*===============================================*/
if (!file_exists('../../config.php')) die('ajax/[available.php] config.php not exist');
require_once '../../config.php';
if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !isset($_SESSION['jak_lcp_idhash'])) die("Nothing to see here");
// Import the user or standard language file
if (isset($_SESSION['jak_lcp_lang']) && file_exists(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php')) {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.$_SESSION['jak_lcp_lang'].'.php');
} else {
include_once(APP_PATH.JAK_OPERATOR_LOC.'/lang/'.JAK_LANG.'.php');
}
if (!is_numeric($_POST['id'])) die(json_encode(array('status' => 1, "html" => $jkl['g79'])));
$responses = '';
$row = $jakdb->get("sessions", ["name", "operatorname", "department"], ["AND" => ["id" => $_POST['id'], "opid" => $opcacheid]]);
if (isset($row) && !empty($row)) {
if (isset($HD_RESPONSES) && is_array($HD_RESPONSES)) {
$responses .= '<option value="0">'.$jkl["g7"].'</option>';
// get the responses from the file specific for this client
foreach($HD_RESPONSES as $r) {
if ($r["department"] == 0 || $r["department"] == $row["department"]) {
$phold = array("%operator%","%client%","%email%");
$replace = array($row['operatorname'], $row["name"], JAK_EMAIL);
$message = str_replace($phold, $replace, $r["message"]);
$responses .= '<option value="'.$message.'">'.$r["title"].'</option>';
}
}
}
die(json_encode(array('status' => 1, 'name' => $row["name"], 'responses' => $responses)));
}
?>