| 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'];
//ini_set('display_errors',1);
//error_reporting(E_ALL);
require_once('functions.suggestions.php');
$suggestions_obj = new Suggestions();
/*require_once('functions.suggestions_pdo.php');
$suggestions_obj = new Suggestions_pdo();
$result_next = $suggestions_obj->getNextSentenceForTranslation();
$row_next = $result_next->fetchObject();
$sentence_id = $row_next->id;
echo "sentence id: " . $sentence_id;
exit;*/
//skip sentence
if(isset($_POST['skip_id']) && $_POST['skip_id'] != '0') {
$skip_id_arr = explode( '~', base64_decode($_POST['skip_id']) ) ;
$sentence_id = $skip_id_arr[0];
//insert skipped sentence record in to skipped_sentence_suggestion table
$suggestions_obj->saveSkippedSentenceSuggestion( $sentence_id, $user_id );
}
if (isset($_SESSION['tm_language_id']) && isset($_SESSION['tm_id'])) {
$category_id = $_SESSION['tm_language_id'];
if(isset($_POST['offset']))
$offset = $_POST['offset'];
// SQL for marking the suggestion sentence failed if time more than 5 mins of submission STARTS
$suggestions_obj->makeSuggestionsFailedOverMaxTime();
//Code for fetching all the sentence ID those are having
$suggestions_obj->update_all_previous_non_submited_to_sucess0();
//checking currently suggested sentence
$not_in_id_str = $suggestions_obj->getCurrentlyAssignedSuggestionsSentenceIds();
//get user skipped sentence ids
$skipped_ids = $suggestions_obj->getSkippedSentenceIdsByUserID( $user_id );
//fetching the sentence for suggestion
$result = $suggestions_obj->getSentenceForSuggestion( $user_id, $not_in_id_str, $skipped_ids, $category_id );
if ($result->num_rows > 0) {
$data['status'] = 200;
while ($row = $result->fetch_object()) {
$sentence_id = $row->id;
//Code for checking active suggestions
$sentence_suggestion_map_count = $suggestions_obj->getActiveSuggestionsCountBySentenceId( $sentence_id );
//Code for checking if user is refreshing the page in 5 minutes
$result2 = $suggestions_obj->checkIsUserRefreshedPage( $sentence_id, $user_id );
if ($result2->num_rows == 0 && $sentence_suggestion_map_count < 3) {
//Initial assign sentence to user for translation
$last_inserted_id = $suggestions_obj->insertInitialSentenceSuggestionMapAndGetId($sentence_id,$user_id,$global_time_mins);
} elseif( $result2->num_rows >= 1 ){
$row2 = $result2->fetch_object();
$last_inserted_id = $row2->id;
} elseif( $sentence_suggestion_map_count >= 3 ) {
//get next sentence
$result_next = $suggestions_obj->getNextSentenceForTranslation();
$row_next = $result_next->fetch_object();
$sentence_id = $row_next->id;
//Initial assign sentence to user for translation
$last_inserted_id = $suggestions_obj->insertInitialSentenceSuggestionMapAndGetId($sentence_id,$user_id,$global_time_mins);
}
// database "Unlock Sentence" event will unlock all the locked sentences after 5 mins
$sent = $row->id.'~'.$last_inserted_id;
$data['id'] = base64_encode($sent);
$data['original_message'] = stripslashes($row->original_message);
$data['translated_message'] = stripslashes($row->translated_message);
}
}
}
echo json_encode($data);