| 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;
if (isset($_SESSION['tm_language_id']) && isset($_SESSION['tm_id'])) {
$category_id = $_SESSION['tm_language_id'];
$user_id = $_SESSION['tm_id'];
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) >= 5) and id NOT IN (select sentence_id from tbl_user_suggestion_mapping where user_id = ' . $user_id . ') ORDER BY suggestion_count DESC LIMIT 25 OFFSET '.$offset;
$result = $mysqli->query($sql);
if ($result->num_rows > 0) {
$data['status'] = 200;
$data['sentence'] = array();
while ($row = $result->fetch_object()) {
$temp = array();
$sentence_id = $row->id;
$temp['id'] = base64_encode($row->id);
// $temp['original_message'] = mb_convert_encoding(stripslashes($row->original_message), "HTML-ENTITIES", "UTF-8");
// $temp['translated_message'] = mb_convert_encoding(stripslashes($row->translated_message), "HTML-ENTITIES", "UTF-8");
$temp['original_message'] = stripslashes($row->original_message);
$temp['translated_message'] = stripslashes($row->translated_message);
// add first suggetion as machine translation
$sqlM = 'SELECT * FROM tbl_user_suggestion_mapping where sentence_id = "'.$sentence_id.'" AND user_id = 0';
$resultM = $mysqli->query($sqlM);
if($resultM->num_rows == 0) {
$translated_message = $row->translated_message;
$sqlInsert = 'INSERT INTO `tbl_user_suggestion_mapping`(`sentence_id`, `user_id`, `category_id`, `suggestion`, `credits`, voted_user_id, `created_at`) VALUES '
. '(' . $sentence_id . ',0,' . $row->category_id . ',"' . addslashes($translated_message) . '",0,"" ,"' . date('Y-m-d H:i:s') . '")';
$resultInsert = $mysqli->query($sqlInsert);
}
array_push($data['sentence'], $temp);
}
/*if(!empty($data['sentence'])) {
shuffle($data['sentence']);
}*/
}
}
echo json_encode($data);