| 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';
if (isset($_POST['sid']) && isset($_SESSION['tm_id']) && isset($_POST['suggestion'])) {
$sentence_id = base64_decode($_POST['sid']);
$user_id = $_SESSION['tm_id'];
$language_id = $_SESSION['tm_language_id'];
if (is_numeric($sentence_id)) {
$daily_tmn_suggestion_limit = 0;
$tmn_per_suggestion = $tmn_credits = $winning_suggestion_tmn = 0;
/* $sqlSettings = 'SELECT * FROM `settings` WHERE 1 ';
$resultSettings = $mysqli->query($sqlSettings);
while ($row = $resultSettings->fetch_object()) {
$daily_tmn_suggestion_limit = (int) $row->daily_suggestion_tmn_limit;
$tmn_per_suggestion = (int) $row->tmn_per_suggestion;
$winning_suggestion_tmn = (int) $row->winning_suggestion_tmn;
}
$sqlTodaySuggestion = 'SELECT * FROM `tbl_user_suggestion_mapping` WHERE user_id = ' . $user_id;
$resultTodaySuggestion = $mysqli->query($sqlTodaySuggestion);
$todaySuggestionTotal = $resultTodaySuggestion->num_rows;
if ($todaySuggestionTotal < $daily_tmn_suggestion_limit) {
$tmn_credits = $tmn_per_suggestion;
}*/
$sqlSuggestion = 'SELECT * FROM `tbl_user_suggestion_mapping` WHERE sentence_id = ' . $sentence_id . ' and user_id = ' . $user_id;
$resultSuggestion = $mysqli->query($sqlSuggestion);
$sqlSuggestionCount = 'SELECT * FROM `tbl_user_suggestion_mapping` WHERE sentence_id = ' . $sentence_id;
$resultSuggestionCount = $mysqli->query($sqlSuggestionCount);
if ($resultSuggestion->num_rows == 0) {
if ($resultSuggestionCount->num_rows < 3) {
$new_tmn = $_SESSION['tm_credits'] + $tmn_credits;
$_SESSION['tm_credits'] = $new_tmn;
$sqlInsert = 'INSERT INTO `tbl_user_suggestion_mapping`(`sentence_id`, `user_id`, `category_id`, `suggestion`, `credits`,voted_user_id, `created_at`) VALUES '
. '(' . $sentence_id . ',' . $user_id . ',' . $language_id . ',"' . addslashes($_POST['suggestion']) . '",' . $tmn_credits . ',"" ,"' . date('Y-m-d H:i:s') . '")';
$resultInsert = $mysqli->query($sqlInsert);
$suggestion_count = (int) ($resultSuggestionCount->num_rows) + 1;
$sqlUpdate = 'UPDATE `tbl_sentence` SET suggestion_count = ' . $suggestion_count;
if($suggestion_count == 2) {
$sqlUpdate .= ', pending_at = "'. date('Y-m-d H:i:s') .'"';
}
if($suggestion_count == 3) {
$sqlUpdate .= ', voting_at = "'. date('Y-m-d H:i:s') .'"';
}
$sqlUpdate .= ' where id = ' . $sentence_id;
$resultUpdate = $mysqli->query($sqlUpdate);
// Increment users total suggestions
$sqlUpdateUS = 'UPDATE `tbl_translators` SET total_suggestions = total_suggestions + 1 where id = ' . $user_id;
$resultUpdateUS = $mysqli->query($sqlUpdateUS);
// UnLock the sentence for other users
$sqlUpdateS = 'UPDATE `tbl_sentence` SET is_lock = 0, locked_at = "" where id = ' . $sentence_id;
$resultUpdateS = $mysqli->query($sqlUpdateS);
echo json_encode(array("status" => "200", "msg" => "Suggestion submitted successfully"));
} else {
echo json_encode(array("status" => "300", "msg" => "This sentence has already reached 3 suggestions.<br>
Please skip this and contribute on a new one."));
}
} else {
echo json_encode(array("status" => "300", "msg" => "You have already given suggestion for this sentence."));
}
} else {
echo json_encode(array("status" => "300", "msg" => 'Something went wrong, Please try again.'));
}
} else {
echo json_encode(array("status" => "300", "msg" => 'User not found'));
}