| Server IP : 64.202.187.69 / Your IP : 216.73.217.74 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';
require_once('functions.translators.php');
$translators_obj = new Translators();
require_once('functions.suggestions.php');
$suggestions_obj = new Suggestions();
require_once('functions.voting.php');
$voting_obj = new Voting();
if (isset($_POST['sid']) && isset($_POST['suid']) && isset($_SESSION['tm_id'])) {
$sentence_id = base64_decode($_POST['sid']);
$suggestion_id = base64_decode($_POST['suid']);
$user_id = $_SESSION['tm_id'];
$language_id = $_SESSION['tm_language_id'];
//get user current level
$user_level = $translators_obj->getCurrentUserLevelByUserId( $user_id );
//after reached level complete, locked submit suggestion, voting till hours time
$level_completed_locked_in_time_hours = $suggestions_obj->getSettingsValuesByColumnName( 'level_completed_locked_in_time' );
if (is_numeric($sentence_id) && is_numeric($suggestion_id)) {
//get success voting count for sentence
$success_voting_count = $voting_obj->get_success_voting_count_by_sentence_id($sentence_id);
//check success voting count less than maximum voting (11)
if ( $success_voting_count < $global_max_voting_count ) {
//update suggestion pending started at date in tbl_sentence (if not updated yet)
$suggestions_obj->updateSentencePendingAtDate( $sentence_id );
//update voting started at date (if not updated yet)
$suggestions_obj->updateSentenceVotingStartedAtDate( $sentence_id );
//get sentence count which user has not voted for sentence
$user_voting_count = $voting_obj->get_user_empty_vote_count_by_sentence_id_and_user_id($sentence_id, $user_id);
//check if user not voted count is 1
if( $user_voting_count == 1 ) {
//apply user vote. update user vote for sentence suggestion to success
$resultUpdateS = $voting_obj->applySuccessUserVoteForSentenceSuggestion($suggestion_id,$sentence_id,$user_id,$user_level);
if ($resultUpdateS == true) {
//after submit again check success vote count for sentence
$success_voting_count2 = $voting_obj->get_success_voting_count_by_sentence_id($sentence_id);
//get no. of success voting to single suggestion
$no_of_success_voting_to_single_suggestion = $suggestions_obj->getSettingsValuesByColumnName( 'no_of_success_voting_to_single_suggestion' );
//get count - sentence has reached No. of Target Success Voting To a Particular Suggestion
$check_sentence_reached_no_of_success_voting_suggestion = $voting_obj->checkSentenceHasReachedNoOfSuccessVotesForSuggestion($sentence_id, $no_of_success_voting_to_single_suggestion);
//check count greater or equal to maximum voting count (11) or if any sentence suggestion got max no. of success voting (5) then return 1
if( $success_voting_count2 >= $global_max_voting_count || $check_sentence_reached_no_of_success_voting_suggestion >= 1 ) {
// Close Sentence for voting. Voting completed for sentence suggestion
$voting_obj->closeVotingForSentence($sentence_id);
require_once('functions.winning_suggestion_voting_credits.php');
$wsvc_obj = new Winning_Suggestion_Voting_Credits();
//Process winning suggestion user credits and winning suggestion voted user id credits by sentence id
$wsvc_obj->processWinningSuggestionVotingCreditsBySentenceId( $sentence_id );
}
//get user total success suggestion count for current level
$user_success_suggestion_count_for_level = $suggestions_obj->getUserSubmittedSuccessSuggestionCountByUserIdAndLevel( $user_id, $user_level );
//get max no. of suggestion user can submit for current level
$max_submit_suggestions = $suggestions_obj->getMaxSubmitSuggestionCountByLevel( $user_level );
//get user total success voting count for current level
$user_success_voting_count_for_level = $voting_obj->getUserSubmittedSuccessVotingCountByUserIdAndLevel( $user_id, $user_level );
//get max no. of voting user can submit for current level
$max_submit_votings = $voting_obj->getMaxSubmitVotingCountByLevel( $user_level );
if( $user_success_suggestion_count_for_level >= $max_submit_suggestions && $user_success_voting_count_for_level >= $max_submit_votings ) {
//Insert entry in to user level logs
$suggestions_obj->saveUserLevelLogs( $user_id, $user_level, $user_success_suggestion_count_for_level, $user_success_voting_count_for_level, $level_completed_locked_in_time_hours );
}
$data['status'] = 200;
$data['msg'] = "Vote submitted successfully.";
} else {
$data['status'] = 300;
$data['msg'] = "Vote timed out took more than 5 mins";
}
} else {
$data['status'] = 300;
$data['msg'] = "You have already submitted vote for this suggestion.";
}
} else {
//make user vote failed.
$voting_obj->makeUserVoteFailedBySentenceIdAndUserId($sentence_id,$user_id);
$data['status'] = 300;
$data['msg'] = "This sentence has already reached " . $global_max_voting_count . " votes.<br> Please skip this and contribute on a new one.";
}
} else {
$data['status'] = 300;
$data['msg'] = "Something went wrong, Please try again.";
}
} else {
$data['status'] = 300;
$data['msg'] = "Something went wrong, Please try again.";
}
echo json_encode($data);