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/baretube.com.new/admin/languages.php
<?php
require "db.php";

if ($_POST['list']) {
    foreach ($_POST['list'] as $i) {
        if (is_numeric($i)) {
            dbQuery("DELETE FROM languages WHERE record_num = '$i'");
        }
    }
}

if (isset($_POST['formSubmit'])) {

    $_POST = array_map_array('trim', $_POST);

    if ($_POST['name'] == '') {
        setMessage('"Language Name" is required!', 'error');
    }

    if ($_POST['iso'] == '') {
        setMessage('"Language ISO Code" is required!', 'error');
    }

    if (is_array(dbRow("SELECT * FROM `languages` WHERE `name` = '" . mysqli_real_escape_string($dbconn, $_POST['name']) . "' OR `iso` = '" . mysqli_real_escape_string($dbconn, $_POST['iso']) . "'"))) {
        setMessage('This language name or ISO code already exists!', 'error');
    }

    if (file_exists("$basepath/admin/scripts/validLanguages.json") && !is_writable("$basepath/admin/scripts/validLanguages.json")) {
        setMessage("File <em>$basepath/admin/scripts/validLanguages.json</em> is not writable! Please chmod this file to 0775!", 'error');
    }

    if (!getMessages(false, 'error')) {
        dbInsert('languages', array(
            'name' => $_POST['name'],
            'iso' => $_POST['iso'],
        ));
        $langs = dbQuery("SELECT `iso` FROM `languages`", false);
        foreach ($langs as $_lang) {
            $out[] = $_lang['iso'];
        }
        if (is_array($out)) {
            file_put_contents("$basepath/admin/scripts/validLanguages.json", json_encode($out));
            @chmod("$basepath/admin/scripts/validLanguages.json", 0777);
        }
        
        $count = 0;
        $meta_collection = dbQuery("SELECT * FROM `metatags` WHERE `language` = '" . mysqli_real_escape_string($dblink, $config['core_language']) . "'", false);
        if (is_array($meta_collection)) {
            foreach ($meta_collection as $_meta_row) {
                unset($_meta_row['record_num']);
                $_meta_row['language'] = $_POST['iso'];
                $insert_id = dbInsert('metatags', $_meta_row, true);
                if (is_numeric($insert_id) && $insert_id > 0) {
                    $count++;
                }
            }
        }
        
        setMessage('New language saved!');
        
        if ($count > 0) {
            setMessage("$count metatags entries saved! <a href=\"$basehttp/admin/metatags.php?filter%5Blanguage%5D=$_POST[iso]\">View \"$_POST[name]\" metatags</a>");
        }
        
        setMessage(shell_exec("cd $basepath/admin/; $php_path cronRescanStrings.php &2>1"), 'alert');
        
        header("Location: $_SERVER[REQUEST_URI]");
        exit();
    }
}
?>

<? require "header.php"; ?>

<div class="content-page">

    <div class="header-area">
        <div class="breadcrumbs">  
            <a href="index.php">Admin Home</a>
            <span><a href="languages.php">Manage Languages</a></span>
        </div>
    </div>

    <div class="content-outer">

        <h2>Manage<strong>Languages</strong></h2>

        <div class="content-inner">

            <?php echo getMessages(); ?>

            <form method="POST" action="" enctype="multipart/form-data" class="form" novalidate autocomplete="off">
                <table class="pagetable"> 
                    <thead>
                        <tr>
                            <th colspan="2">Add Language</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>Language Name</td>
                            <td><input name="name" type="text" placeholder='English' required /></td>
                        </tr>
                        <tr>
                            <td>Language ISO Code <a href="#" title="2-Letter Country Code as per ISO Alpha-2"><i class="ion ion-help-circled"></i></a></td>
                            <td><input name="iso" type="text" placeholder='GB' required /></td>
                        </tr>
                        <tr class="item submit">
                            <td colspan="2">
                                <input type="hidden" name="formSubmit" value="1" />
                                <button type="submit" class="btn action-save">Save</button>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </form>
            
            <form method="POST" action="" enctype="multipart/form-data" class="form" novalidate autocomplete="off">
                <table class="pagetable">
                    <thead>
                        <tr>
                            <th>ISO</th>
                            <th>Name</th>
                            <th class="options"></th>
                            <th style="width:50px">
                                <label for="check-select-all-1" class="checkbox">
                                    <input type="checkbox" name="select_all" value="1" data-items="list[]" id="check-select-all-1">
                                    <i></i>
                                </label>
                            </th>
                        </tr>
                    </thead>
                    <?
                    $page = (isset($_GET['page']) && is_numeric($_GET['page'])) ? (int) $_GET['page'] : 1;
                    $max_results = (isset($_GET['setmax']) && $_GET['setmax'] > 0) ? (int) $_GET['setmax'] : 100;
                    $from = ($page * $max_results) - $max_results;

                    $results = dbQuery("SELECT * FROM `languages` ORDER BY `name` LIMIT $from, $max_results", false);
                    $total_results = dbValue("SELECT COUNT(`record_num`) AS `count` FROM `languages`", 'count');
                    $total_pages = ceil($total_results / $max_results);
                    ?>
                    <tbody>
                        <?php if (!is_array($results)) { ?>
                            <tr><td colspan="4"><div class="notification alert">No entries found</div></td></tr>
                        <?php } else { ?>
                            <?php foreach ($results as $row) { ?>
                                <tr>
                                    <td><?php echo $row['iso']; ?></td>
                                    <td><?php echo $row['name']; ?></td>
                                    <td class="options"><a href="edit_language.php?id=<?php echo $row['record_num']; ?>" class="btn btn-xs btn-orange" title="Edit language"><i class="ion ion-edit icon-edit"></i></a></td>
                                    <td>
                                        <label class="checkbox">
                                            <input type="checkbox" name="list[]" 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 (is_array($results)) { ?>
                                    <button type="submit" class="btn action-delete">Delete Selected</button>
                                <?php } ?>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </form>
            <div id="adminPagination"><?php echo showAdminPagination($total_pages); ?></div>
        </div>
    </div>
</div>
<?php require "footer.php"; ?>