HEX
Server: Apache
System: Linux msm5694.mjhst.com 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: camjab_ssh (1000)
PHP: 5.3.29
Disabled: NONE
Upload Files
File: /home/httpd/html/nyloncams.com/public_html/admin/translate.php
<?php require "db.php"; ?>
<?php
$_languages = dbQuery("SELECT * FROM `languages` WHERE `iso` != '" . mysqli_real_escape_string($dblink, $config['core_language']) . "'", false);
$_language = dbRow("SELECT * FROM `languages` WHERE `iso` = '" . mysqli_real_escape_string($dblink, $_GET['language']) . "'");

if ($_language['iso'] === $config['core_language']) {
    setMessage('Core language is not translatable!', 'error');
    unset($_language);
} else {
    if (is_array($_POST['ids']) && ($_POST['action'] != "") && is_array($_language)) {
        foreach ($_POST['ids'] as $i) {
            if (is_numeric($i)) {
                $i = (int) $i;
                if ($_POST['action'] == 'delete') {
                    dbQuery("DELETE FROM `locales_source` WHERE `record_num` = '$i' LIMIT 1");
                    dbQuery("DELETE FROM `locales_target` WHERE `source_id` = '$i' AND `language` = '" . mysqli_real_escape_string($dblink, $_language['iso']) . "' LIMIT 1");
                }
            }
        }
        dbQuery("DELETE FROM `cache` WHERE `key` LIKE 'translations_strings_%'");
        dbQuery("DELETE FROM `cache` WHERE `key` LIKE 'translations_strings_contextual_%'");
    }

    if ($_POST['q'] == '' && is_array($_POST['list']) && is_array($_language)) {
        foreach ($_POST['list'] as $i => $v) {
            if ($_POST['list'][$i]['translated_text'] == "") {
                dbQuery("DELETE FROM `locales_target` WHERE `source_id` = '$i' AND `language` = '" . mysqli_real_escape_string($dblink, $_language['iso']) . "' LIMIT 1");
            } else {
                dbQuery("INSERT INTO `locales_target` (`source_id`, `language`, `translated_text`, `translated_text_contextual`) VALUES('$i', '" . mysqli_real_escape_string($dblink, $_language['iso']) . "', '" . mysqli_real_escape_string($dblink, $_POST['list'][$i]['translated_text']) . "', '" . mysqli_real_escape_string($dblink, $_POST['list'][$i]['translated_text_contextual']) . "') ON DUPLICATE KEY UPDATE `translated_text` = '" . mysqli_real_escape_string($dblink, $_POST['list'][$i]['translated_text']) . "', `translated_text_contextual` = '" . mysqli_real_escape_string($dblink, $_POST['list'][$i]['translated_text_contextual']) . "'");
            }
        }
        dbQuery("DELETE FROM `cache` WHERE `key` LIKE 'translations_strings_%'");
        dbQuery("DELETE FROM `cache` WHERE `key` LIKE 'translations_strings_contextual_%'");
        setMessage('Translations saved');
        header("Location: ".$_SERVER['REQUEST_URI']);
        exit();
    } else {
        setMessage("<div class=\"alert alert-success\">" . shell_exec("cd $basepath/admin/; $php_path cronRescanStrings.php &2>1") . "</div>", 'alert');
        getMessages();
    }
}

$page = (!isset($_GET['page']) || $_GET['page'] == '') ? 1 : (int) $_GET['page'];
$max_results = isset($_GET['setmax']) ? (int) $_GET['setmax'] : 100;
$from = (($page * $max_results) - $max_results);
?>

<?php include "header.php"; ?>

<div class="content-page">

    <div class="header-area">
        <div class="breadcrumbs">  
            <a href="index.php">Admin Home</a>
            <span><a href="translate.php?<?php echo http_build_query(array('language' => is_array($_language) ? $_language['iso'] : null)) ?>">Translate strings</a></span>
        </div>
    </div>
    
    <div class="content-outer">
        
        <h2>Translate<strong>Strings</strong><?php echo is_array($_language) ? " (".$_language['iso']." - ".$_language['name'].")" : ''; ?></h2>

        <div class="content-inner">
        
            <?php echo getMessages(); ?>

            <form method="POST" action="" class="form" novalidate autocomplete="off">
                <table class="pagetable"> 
                    <thead>
                        <tr>
                            <th colspan="2">Search Phrase</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>Phrase</td>
                            <td><input type="text" name="phrase" required /></td>
                        </tr>
                        <tr class="item submit">
                            <td colspan="2">
                                <button type="submit" class="btn action-search">Search</button>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </form>

            <form method="POST" action="" class="form" novalidate autocomplete="off">
                <table class="pagetable">
                    <thead>
                        <tr>
                            <th style="width:400px!important">Original Text</th>
                            <th>Translated Text (Default)</th>
                            <th>Translated Text (Female)</th>
                            <th style="width:50px">
                                <label for="check-select-all-1" class="checkbox">
                                    <input type="checkbox" name="select_all" value="1" data-items="ids[]" id="check-select-all-1">
                                    <i></i>
                                </label>
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td colspan="4" style="padding:10px 0">
                                <ul class="tabs custom">
                                    <?php foreach ($_languages as $l) { ?>
                                        <li><a href="?<?php echo http_build_query(array('language' => $l['iso'])) ?>" class="tab<?php echo $_GET['language'] == $l['iso'] ? ' active' : ''; ?>"><i class="flag-icon flag-icon-<?php echo strtolower($l['iso']); ?>"></i><?php echo $l['iso']; ?></a></li>
                                    <?php } ?>
                                </ul>
                            </td>
                        </tr>
                        <?php if (is_array($_language)) { ?>
                            <?php $where = array('1=1'); ?>
                            <?php if ($_POST['phrase']) { ?>
                                <?php $where[] = "`locales_source`.`text` LIKE '%" . mysqli_real_escape_string($dblink, $_POST['phrase']) . "%'"; ?>
                            <?php } ?>
                            <?php 
							$result_count = dbQuery("SELECT COUNT(*) AS `count` FROM `locales_source` WHERE " . implode(" AND ", $where), false); 
							$result_count = $result_count[0]; ?>
                            <?php $result = dbQuery("SELECT *, (SELECT `translated_text` FROM `locales_target` WHERE `locales_source`.`record_num` = `locales_target`.`source_id` AND `locales_target`.`language` = '" . mysqli_real_escape_string($dblink, $_language['iso']) . "') `translated_text`, (SELECT `translated_text_contextual` FROM `locales_target` WHERE `locales_source`.`record_num` = `locales_target`.`source_id` AND `locales_target`.`language` = '" . mysqli_real_escape_string($dblink, $_language['iso']) . "') `translated_text_contextual` FROM `locales_source` WHERE " . implode(" AND ", $where) . " LIMIT $from, $max_results",false); ?>
                            <?php $total_pages = ceil($result_count['count'] / $max_results); ?>
                            <?php if (count($result) == 0) { ?>
                                <tr><td colspan="4"><div class="notification alert">No strings found</div></td></tr>
                            <?php } else { ?>
                                <?php foreach($result as $row) { ?>
                                    <tr id="record<?php echo $row['record_num']; ?>">
                                        <td style="width:400px!important"><input type="text" name="list[<?php echo $row['record_num'] ?>][text]" value="<?php echo htmlentities($row['text'], ENT_QUOTES, 'UTF-8') ?>" /></td>
                                        <td><input type="text" name="list[<?php echo $row['record_num'] ?>][translated_text]" value="<?php echo htmlentities($row['translated_text'], ENT_QUOTES, 'UTF-8') ?>" /></td>
                                        <td><input type="text" name="list[<?php echo $row['record_num'] ?>][translated_text_contextual]" value="<?php echo htmlentities($row['translated_text_contextual'], ENT_QUOTES, 'UTF-8') ?>" /></td>
                                        <td>
                                            <label class="checkbox">
                                                <input type="checkbox" name="ids[]" value="<?php echo $row['record_num']; ?>" id="ids-<?php echo $row['record_num']; ?>"><i></i>
                                            </label>
                                        </td>
                                    </tr>
                                <?php } ?>
                            <?php } ?>
                            <tr class="item submit">
                                <td colspan="4">
                                    <?php if (count($result) > 0) { ?>
                                        <div class="processing-option short">
                                            <select name="action" class="processing-option short allow-empty">
                                                <option value="">- select action -</option>
                                                <option value="delete">Delete</option>
                                            </select>
                                        </div>
                                        <button type="submit" class="btn action-process">Save / Process Selected</button>
                                    <?php } ?>
                                </td>
                            </tr>
                        <?php } else if (isset($_GET['language'])) { ?>
                            <?php echo setMessage('Language not found', 'error', true); ?>
                        <?php } ?>
                    </tbody>
                </table>
            </form>
            <div id="adminPagination"><?php echo showAdminPagination($total_pages); ?></div>
        </div>
    </div>
</div>

<?php require "footer.php"; ?>