| 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';
pflog( "=========================================================================== paragraph id ====".$_POST['paragraph_id']."==== user id =====".$_SESSION['tm_id']);
pflog( "Response:\n". print_r( $_POST, true ) );
if (isset($_SESSION['tm_id'])) {
if (isset($_POST['specials'])) {
$specialsArray = json_decode($_POST['specials']);
if(!empty($specialsArray)) {
foreach($specialsArray as $key=>$value) {
$sentence_id = $key;
$user_id = $_SESSION['tm_id'];
$language_id = $_SESSION['tm_language_id'];
$sqlSuggestion = 'SELECT * FROM `tbl_user_suggestion_marketing_mapping` WHERE sentence_id = ' . $sentence_id . ' and user_id = ' . $user_id;
$resultSuggestion = $mysqli->query($sqlSuggestion);
if ($resultSuggestion->num_rows == 0) {
$sqlSuggestionCount = 'SELECT * FROM `tbl_user_suggestion_marketing_mapping` WHERE sentence_id = ' . $sentence_id;
$resultSuggestionCount = $mysqli->query($sqlSuggestionCount);
if($resultSuggestionCount < 3) {
$suggestion = $value;
$tmn_credits = 0;
/*$new_tmn = $_SESSION['tm_credits'] + $tmn_credits;
$_SESSION['tm_credits'] = $new_tmn;*/
$sqlInsert = 'INSERT INTO `tbl_user_suggestion_marketing_mapping`(`sentence_id`, `user_id`, `category_id`, `suggestion`, `credits`, `voted_user_id`, `paragraph_id`, `created_at`) VALUES '
. '(' . $sentence_id . ',' . $user_id . ',' . $language_id . ',"' . addslashes($suggestion) . '",' . $tmn_credits . ',"" , "'.$_POST['paragraph_id'].'", "' . date('Y-m-d H:i:s') . '")';
$resultInsert = $mysqli->query($sqlInsert);
pflog($sqlInsert);
$suggestion_count = (int) ($resultSuggestionCount->num_rows) + 1;
$sqlUpdate = 'UPDATE `tbl_sentence_marketing` SET suggestion_count = ' . $suggestion_count . ' where id = ' . $sentence_id;
$resultUpdate = $mysqli->query($sqlUpdate);
// Increment users total suggestions
$sqlUpdateUS = 'UPDATE `tbl_translators` SET total_suggestions_marketing = total_suggestions_marketing + 1 where id = ' . $user_id;
$resultUpdateUS = $mysqli->query($sqlUpdateUS);
}
}
}
// UnLock the paragraph for other users
$sqlUpdateS = 'UPDATE `tbl_paragraphs` SET is_lock = 0, locked_user_id = 0, locked_at = "" where id = "' . $_POST['paragraph_id'].'"';
$resultUpdateS = $mysqli->query($sqlUpdateS);
echo json_encode(array("status" => "200", "msg" => "Suggestions submitted successfully"));
} else {
echo json_encode(array("status" => "300", "msg" => 'Something went wrong, Please try again.'));
}
} else {
echo json_encode(array("status" => "300", "msg" => 'Something went wrong, Please try again.'));
}
} else {
echo json_encode(array("status" => "700"));
}
function pflog( $msg = '', $close = false ) {
static $fh = 0;
global $module;
// Only log if debugging is enabled
if( true )
{
if( $close )
{
fclose( $fh );
}
else
{
// If file doesn't exist, create it
if( !$fh )
{
$pathinfo = pathinfo( __FILE__ );
$fh = fopen( $pathinfo['dirname'] .'/market_logs.log', 'a+' );
}
// If file was successfully created
if( $fh )
{
$line = date( 'Y-m-d H:i:s' ) .' : '. $msg ."\n";
fwrite( $fh, $line );
}
}
}
}