| 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';
$data = array();
$data['status'] = 300;
$offset = 0;
$user_id = $_SESSION['tm_id'];
if(isset($_POST['skip_id']) && $_POST['skip_id'] != '0') {
// Lock the sentence for other users
$sqlUpdate = 'UPDATE `tbl_sentence` SET is_lock = 0, locked_at = "" where id = "' . base64_decode($_POST['skip_id']) .'"';
$resultUpdate = $mysqli->query($sqlUpdate);
$user_idT = base64_decode($_POST['skip_id']) .",";
// Increment users total votes
$sqlUpdateUS = 'UPDATE `tbl_translators` SET skip_suggestion_sentences = concat(ifnull(skip_suggestion_sentences,""), "' . $user_idT . '") where id = ' . $user_id;
$resultUpdateUS = $mysqli->query($sqlUpdateUS);
}
if (isset($_SESSION['tm_language_id']) && isset($_SESSION['tm_id'])) {
$category_id = $_SESSION['tm_language_id'];
$skippedOld = 0;
$sqlOpenSentence1 = 'select skip_suggestion_sentences from tbl_translators where skip_suggestion_sentences != "" AND id = ' . $user_id;
$resultOpenSentence1 = $mysqli->query($sqlOpenSentence1);
if($resultOpenSentence1->num_rows > 0) {
while ($row1 = $resultOpenSentence1->fetch_object()) {
$skippedOld = rtrim($row1->skip_suggestion_sentences, ',');
$skippedOld = str_replace(',,', ",", $skippedOld);
}
}
if(isset($_POST['offset']))
$offset = $_POST['offset'];
$sql = 'SELECT * FROM tbl_sentence where category_id = ' . $category_id . ' and id NOT IN (SELECT sentence_id FROM `tbl_user_suggestion_mapping` where 1 group by sentence_id HAVING count(sentence_id) >= 3) and id NOT IN (select sentence_id from tbl_user_suggestion_mapping where user_id = ' . $user_id . ') AND id NOT IN ('.$skippedOld.') AND is_lock = 0 ORDER BY suggestion_count DESC LIMIT 1 OFFSET '.$offset;
$result = $mysqli->query($sql);
if ($result->num_rows > 0) {
$data['status'] = 200;
while ($row = $result->fetch_object()) {
$sentence_id = $row->id;
// Lock the sentence for other users
$sqlUpdate = 'UPDATE `tbl_sentence` SET is_lock = 1, locked_at = NOW() where id = ' . $sentence_id;
$resultUpdate = $mysqli->query($sqlUpdate);
// database "Unlock Sentence" event will unlock all the locked sentences after 5 mins
$data['id'] = base64_encode($row->id);
$data['original_message'] = stripslashes($row->original_message);
$data['translated_message'] = stripslashes($row->translated_message);
}
}
}
echo json_encode($data);