| 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
include 'connection.php';
if (isset($_POST['content'])) {
$category_id = $_SESSION['tm_language_id'];
$paragraph = $_POST['content'];
$sqlP = 'INSERT INTO `tbl_paragraphs_original`(`user_id`, `content`, `category_id`, `created_at`) VALUES '
. '("' . addslashes($_SESSION['tm_id']) . '","' . addslashes($_POST['content']) . '",' . $category_id . ', "' . date('Y-m-d H:i:s') . '")';
$resultP = $mysqli->query($sqlP);
$main_paragraph_id = mysqli_insert_id($mysqli);
$sentenceArray = preg_split('/(?<=[.?!])\s+/', $paragraph, -1, PREG_SPLIT_NO_EMPTY);
$has_text = 0;
$sentence_ids = array();
if(!empty($sentenceArray)) {
$count = 1;
$sentence_count = 1;
$sub_count = 1;
$sub_para_content = '';
for ($i=0;$i<count($sentenceArray);$i++) {
if(strip_tags(trim($sentenceArray[$i])) != '') {
$original_message1 = strip_tags(trim($sentenceArray[$i]));
$sub_para_content .= strip_tags(trim($sentenceArray[$i])) . ' ';
$sqlInsert = 'INSERT INTO `tbl_sentence_marketing`(`original_message`, `translated_message`, `category_id` , `created_at`, `sequence` ) VALUES '
. '("' . addslashes(trim($original_message1)) . '","' . addslashes($original_message1) . '",' . $category_id . ' , "' . date('Y-m-d H:i:s') . '",' . $count . ')';
$resultInsert = $mysqli->query($sqlInsert);
$sentence_id = mysqli_insert_id($mysqli);
$sentence_ids[] = $sentence_id;
$count++;
$sentence_count++;
if(($count % 10 == 1 && $count > 10) || $count == count($sentenceArray)+1) {
$ids = '';
if(!empty($sentence_ids)) {
$ids = implode(",", $sentence_ids);
$sentences = count($sentence_ids);
}
$sqlP = 'INSERT INTO `tbl_paragraphs`(`user_id`, `content`, `category_id`, `sentence_ids`, `sentences`, `sequence`, `main_paragraph_id`, `created_at`) VALUES '
. '("' . addslashes($_SESSION['tm_id']) . '","' . addslashes($sub_para_content) . '",' . $category_id . ',"'.addslashes($ids).'","'.$sentences.'",' . $sub_count . ', ' . $main_paragraph_id . ', "' . date('Y-m-d H:i:s') . '")';
$resultP = $mysqli->query($sqlP);
$paragraph_id = mysqli_insert_id($mysqli);
$sqlUpdate = 'UPDATE `tbl_sentence_marketing` SET paragraph_id = "'.$paragraph_id.'" where id IN('.$ids.')';
$resultUpdate = $mysqli->query($sqlUpdate);
// Append paragraph_id to paragraph_ids
$user_idT = $paragraph_id . ',';
$sqlInsert = 'UPDATE `tbl_paragraphs_original` SET paragraphs = paragraphs + 1, paragraph_ids = concat(ifnull(paragraph_ids,""), "' . $user_idT . '") where id = ' . $main_paragraph_id;
$resultInsert = $mysqli->query($sqlInsert);
$sentence_count = 1;
$sub_count++;
$sub_para_content = '';
$sentence_ids = array();
}
}
}
$has_text = 1;
}
echo json_encode(array("status" => "200", "message" => "Sentences saved successfully"));
} else {
echo json_encode(array("status" => "300", "message" => 'Please enter content'));
}
?>