| 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';
$total_votes_given = 0;
$total_suggestions_given = 0;
$closed_sentences = 0;
$open_sentences = 0;
$closed_voted_sentences = 0;
$open_voted_sentences = 0;
$winning_suggestion_sentence = 0;
$winning_suggestion_vote = 0;
$lost_sentences = 0;
$lost_voted_sentences = 0;
$total_votes_givenM = 0;
$total_suggestions_givenM = 0;
$closed_sentencesM = 0;
$open_sentencesM = 0;
$closed_voted_sentencesM = 0;
$open_voted_sentencesM = 0;
$winning_suggestion_sentenceM = 0;
$winning_suggestion_voteM = 0;
$lost_sentencesM = 0;
$lost_voted_sentencesM = 0;
//Reputation Suggestion Start
//Total suggestions given by a user
$sql_total_suggestions = "SELECT * FROM `sentence_suggestion_map` WHERE is_locked = 1 and is_success = 1 AND user_id = " . $_SESSION['tm_id'];
$result_total_suggestions = $mysqli->query( $sql_total_suggestions );
$total_suggestions_given = $result_total_suggestions->num_rows;
//Total suggestions given by a user and are closed sentences
$sql_closed_sentences = "SELECT t1.id FROM `tbl_sentence` t1 INNER JOIN sentence_suggestion_map t2 ON t1.id = t2.sentence_id WHERE t1.is_lock = 1 AND t1.suggestion_started_pending_at IS NOT NULL AND t1.voting_started_at IS NOT NULL AND t1.voting_closed_at IS NOT NULL AND t2.is_locked = 1 AND t2.is_success = 1 AND t2.user_id = " . $_SESSION['tm_id'];
$result_closed_sentences = $mysqli->query( $sql_closed_sentences );
$closed_sentences = $result_closed_sentences->num_rows;
//Total winning suggestions of a user, winning sentences
$sql_winning_suggestions = "SELECT id FROM winning_suggestion_voting_credits WHERE user_id = " . $_SESSION['tm_id'] . " AND credit_purpose = 1";
$result_winning_suggestions = $mysqli->query( $sql_winning_suggestions );
$winning_suggestion_sentence = $result_winning_suggestions->num_rows;
if( $total_suggestions_given > 0 ) {
//pending suggestions
$open_sentences = $total_suggestions_given - $closed_sentences;
}
if ($closed_sentences > 0) {
$lost_sentences = $closed_sentences - $winning_suggestion_sentence;
}
//Reputation Suggestion End
//Reputation Voting Start
//Total voted suggestion by a user
$sql_total_voting = "SELECT * FROM `sentence_suggestion_voting_map` WHERE is_success = 1 AND user_id = " . $_SESSION['tm_id'];
$result_total_voting = $mysqli->query( $sql_total_voting );
$total_votes_given = $result_total_voting->num_rows;
//Total votes given by a user and are closed sentences
$sql_closed_voting_sentences = "SELECT t1.id FROM `tbl_sentence` t1 INNER JOIN sentence_suggestion_voting_map t2 ON t1.id = t2.sentence_id WHERE t1.is_lock = 1 AND t1.suggestion_started_pending_at IS NOT NULL AND t1.voting_started_at IS NOT NULL AND t1.voting_closed_at IS NOT NULL AND t2.is_success = 1 AND t2.user_id = " . $_SESSION['tm_id'];
$result_closed_voting_sentences = $mysqli->query( $sql_closed_voting_sentences );
$closed_voted_sentences = $result_closed_voting_sentences->num_rows;
//Total winning votes of a user, winning voted sentences
$sql_winning_voting = "SELECT id FROM winning_suggestion_voting_credits WHERE user_id = " . $_SESSION['tm_id'] . " AND credit_purpose = 2";
$result_winning_voting = $mysqli->query( $sql_winning_voting );
$winning_suggestion_vote = $result_winning_voting->num_rows;
if( $total_votes_given > 0 ) {
//pending voting
$open_voted_sentences = $total_votes_given - $closed_voted_sentences;
}
if ($closed_voted_sentences > 0) {
$lost_voted_sentences = $closed_voted_sentences - $winning_suggestion_vote;
}
// Reputation Voting End
//Total suggestions given by a user marketing
$sql = 'select T1.id, T1.winning_credits, T2.is_open_for_voting from tbl_user_suggestion_marketing_mapping as T1 LEFT JOIN tbl_sentence_marketing as T2 on T1.sentence_id = T2.id where T1.user_id = ' . $_SESSION['tm_id'];
$result = $mysqli->query($sql);
while ($row = $result->fetch_object()) {
$total_suggestions_givenM++;
if ($row->winning_credits > 0) {
$winning_suggestion_sentenceM++;
}
if (!$row->is_open_for_voting) {
$closed_sentencesM++;
} else {
$open_sentencesM++;
}
}
if ($closed_sentencesM > 0)
$lost_sentencesM = $closed_sentencesM - $winning_suggestion_sentenceM;
// Total winning suggestions voted by a user marketing
$sqlSuggestionVote = 'select T1.id, T1.winning_credits, T2.is_open_for_voting from tbl_user_votes_marketing_tmn as T1 LEFT JOIN tbl_user_suggestion_marketing_mapping as T3 on T3.id = T1.suggestion_id LEFT JOIN tbl_sentence_marketing as T2 on T3.sentence_id = T2.id where T1.user_id = ' . $_SESSION['tm_id'];
$resultSuggestionVote = $mysqli->query($sqlSuggestionVote);
while ($rowSuggestion = $resultSuggestionVote->fetch_object()) {
$total_votes_givenM++;
if ($rowSuggestion->winning_credits > 0)
$winning_suggestion_voteM++;
if (!$rowSuggestion->is_open_for_voting) {
$closed_voted_sentencesM++;
} else {
$open_voted_sentencesM++;
}
}
if ($closed_voted_sentencesM > 0)
$lost_voted_sentencesM = $closed_voted_sentencesM - $winning_suggestion_voteM;
$data['total_suggestions_given'] = $total_suggestions_given;
$data['winning_suggestion_sentence'] = $winning_suggestion_sentence;
$data['pending_suggestion_sentence'] = $open_sentences;
$data['lost_suggestion_sentence'] = $lost_sentences;
$data['total_votes_given'] = $total_votes_given;
$data['winning_suggestion_vote'] = $winning_suggestion_vote;
$data['pending_suggestion_vote'] = $open_voted_sentences;
$data['lost_suggestion_vote'] = $lost_voted_sentences;
$data['total_suggestions_givenM'] = $total_suggestions_givenM;
$data['winning_suggestion_sentenceM'] = $winning_suggestion_sentenceM;
$data['pending_suggestion_sentenceM'] = $open_sentencesM;
$data['lost_suggestion_sentenceM'] = $lost_sentencesM;
$data['total_votes_givenM'] = $total_votes_givenM;
$data['winning_suggestion_voteM'] = $winning_suggestion_voteM;
$data['pending_suggestion_voteM'] = $open_voted_sentencesM;
$data['lost_suggestion_voteM'] = $lost_voted_sentencesM;
echo json_encode($data);