| Server IP : 64.202.187.69 / Your IP : 216.73.216.192 Web Server : Apache System : Linux 69.187.202.64.host.secureserver.net 3.10.0-1160.144.1.el7.tuxcare.els6.x86_64 #1 SMP Fri May 29 16:22:24 UTC 2026 x86_64 User : transmarket ( 1001) PHP Version : 7.2.34 Disable Function : exec,passthru,shell_exec,system MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/transmarket/translator/controllers/ |
Upload File : |
<?php
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
include 'connection.php';
$requestData = $_REQUEST;
$columns = array(
0 => 'T2.original_message',
);
$user_id = $_SESSION['tm_id'];
$sql = 'select T2.id as sentence_id, T1.suggestion, T2.original_message, T2.suggestion_count, SUM(IFNULL((CHAR_LENGTH(T1.voted_user_id) - CHAR_LENGTH(REPLACE(T1.voted_user_id, ",", ""))),0)) as TotalVotes from tbl_sentence_marketing as T2
LEFT JOIN tbl_user_suggestion_marketing_mapping as T1 on T1.sentence_id = T2.id
LEFT JOIN languages T3 ON T1.category_id = T3.id
LEFT JOIN tbl_translators T4 ON T1.user_id = T4.id
where T2.is_open_for_voting = 1';
if (isset($_POST['category_id']) && $_POST['category_id'] > 0) {
$sql.= ' AND T1.category_id = ' . $_POST['category_id'];
}
$sql.= ' AND T2.paragraph_id = "'.$_POST['id'].'"';
if (!empty($requestData['search']['value'])) { // if there is a search parameter, $requestData['search']['value'] contains search parameter
$sql .=" AND (T2.original_message LIKE '%" . $requestData['search']['value'] . "%') ";
}
$sql .= ' AND T2.suggestion_count = 3 AND T2.id NOT IN (select sentence_id from tbl_user_suggestion_marketing_mapping where user_id = "' . $user_id . '" or FIND_IN_SET("' . $user_id . '",voted_user_id)) AND T2.id NOT IN (select sentence_id from tbl_skipped_voting_sentences_marketing where status = 1 AND user_id = "' . $user_id . '")';
$sql .= ' GROUP BY T2.id';
$result = $mysqli->query($sql);
$totalData = $result->num_rows;
$totalFiltered = $totalData;
$sql.= " ORDER BY TotalVotes DESC ". " LIMIT " . $requestData['start'] . " ," . $requestData['length'] . " ";
$result = $mysqli->query($sql);
$data = array();
if($result->num_rows > 0) {
while ($row = $result->fetch_object()) {
$vote_str = '';
$sql1 = 'SELECT GROUP_CONCAT(user_id) as user_idT FROM `tbl_user_suggestion_marketing_mapping` WHERE sentence_id = "'.$row->sentence_id.'"';
$result1 = $mysqli->query($sql1);
if($result1->num_rows > 0) {
while ($row1 = $result1->fetch_object()) {
$vote_str = $row1->user_idT;
}
}
$nestedData = array();
$winning_credits = 0;
$nestedData['id'] = $row->sentence_id;
$nestedData['original_message'] = '<span id="ossentence_id'.$row->sentence_id.'">'.mb_convert_encoding(stripslashes($row->original_message), "HTML-ENTITIES", "UTF-8").'</span>';
$nestedData['translated_suggestion'] = mb_convert_encoding(stripslashes($row->suggestion), "HTML-ENTITIES", "UTF-8");
$sqlSuggestion = 'SELECT * FROM `tbl_user_suggestion_marketing_mapping` WHERE sentence_id = ' . $row->sentence_id . ' and user_id != "' . $user_id .'" ORDER BY user_id';
$resultSuggestion = $mysqli->query($sqlSuggestion);
$str_suggestion = '';
if($resultSuggestion->num_rows > 0) {
$str_suggestion .= '<div class="slider">
<label><strong>Select the best translated sentence</strong></label>
<div class="form-group suggestion-list">';
$count = 0;
while ($rowSuggestion = $resultSuggestion->fetch_object()) {
$node_class = $count%2==0 ? " odd":" even";
$str_suggestion .= '<div class="custom-control custom-radio'.$node_class.'" data-id="'.$row->sentence_id.'">
<input class="custom-control-input custom-control-input1'. $row->sentence_id. '" type="radio" value="' . base64_encode($rowSuggestion->id) . '" id="customRadio'. $row->sentence_id.$count. '" name="suggestionRadio'.$row->sentence_id.'">
<label for="customRadio' .$row->sentence_id.$count. '" class="custom-control-label">' .stripslashes($rowSuggestion->suggestion). '</label>
</div>';
$count++;
}
$str_suggestion .= '</div>';
$str_suggestion .= '<div class="display-flex mobile-justify-center">
<button type="button" data-uids="'.$vote_str.'" data-id="'.$row->sentence_id.'" class="btn btn-sm sh-skip btn-primary waves-effect waves-light">Skip</button>
<button type="button" disabled data-id="'.$row->sentence_id.'" class="btn btn-sm btn-save btn-save'.$row->sentence_id.' btn-success waves-effect waves-light">Save</button>
</div>';
$str_suggestion .= '</div>';
}
$nestedData['suggestion'] = $str_suggestion;
$data[] = $nestedData;
}
}
$json_data = array(
"draw" => intval($requestData['draw']), // for every request/draw by clientside , they send a number as a parameter, when they recieve a response/data they first check the draw number, so we are sending same number in draw.
"recordsTotal" => intval($totalData), // total number of records
"recordsFiltered" => intval($totalFiltered), // total number of records after searching, if there is no searching then totalFiltered = totalData
"data" => $data, // total data array
"data1" => $requestData['start'], // total data array
"data2" => $requestData['length'], // total data array
// "data3" => $draw // total data array
);
echo json_encode($json_data); // send data as json format