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/edit_block.php
<?
require "db.php";

if (!is_numeric($_GET['id'])) {
    exit();
}

$id = (int) $_GET['id'];

$row = dbRow("SELECT * FROM `blocks` WHERE `record_num` = '$id'");
if (!is_array($row)) {
    setMessage("Block ID $id does not exist!", 'error');
    pageNotFound(true);
}

if (isset($_POST['formSubmit'])) {
    $_POST = array_map_array('trim', $_POST);

    if ($_POST['body'] == "") {
        setMessage('Block content cannot be empty!', 'error');
    }

    if (!getMessages(false, 'error')) {
        $data = array(
            'title' => ($_POST['title'] == "") ? "Block $id" : $_POST['title'],
            'subject' => $_POST['subject'],
            'body' => $_POST['body'],
            'status' => (int) $_POST['status'],
            'record_num' => $id,
        );
        dbUpdate('blocks', $data);
        if (is_array($_POST['lang'])) {
            foreach ($_POST['lang'] as $k => $v) {
                $_POST['lang'][$k]['body'] = base64_encode(substr($_POST['lang'][$k]['body'], 0, -4));
                dbInsert('blocks_languages', array(
                    'block_id' => $id,
                    'language' => $k,
                    'data' => serialize($_POST['lang'][$k]),
                        ), false, true);
            }
        }
        setMessage('Custom block updated. To display this block, paste this code: <b>' . htmlentities('<?php displayBlock(' . $id . '); ?>', ENT_QUOTES, 'UTF-8') . '</b> in the desired location inside your template.');
        setMessage('<a href="' . $basehttp . '/admin/blocks.php"><b>Click here to return to Custom Blocks</b></a>');
        header("Location: ".$_SERVER['REQUEST_URI']);
        exit;
    } else {
        if (is_array($_POST['lang'])) {
            foreach ($_POST['lang'] as $k => $v) {
                $_POST['lang'][$k]['body'] = base64_encode(substr($_POST['lang'][$k]['body'], 0, -4));
            }
        }
    }
}

$langInfo = array();
$langData = dbQuery("SELECT * FROM `blocks_languages` WHERE `block_id` = '$id'", false);
foreach ($langData as $langRow) {
    $langInfo[$langRow['language']] = unserialize($langRow['data']);
}

$_POST += $row;
$_POST['lang'] = array();
$_POST['lang'] += $langInfo;

entities_walk($_POST);
?>

<? require "header.php"; ?>

<script>
    $().ready(function () {
        $('.lang-selection a').on('click', function (e) {
            e.preventDefault();
            $('.lang-selection').find('a.active').removeClass('active');
            $(this).addClass('active');
            var activeItems = $(this).attr('href').replace("#", "");
            $('#languages').find('.langInput').hide();
            $('#languages').find('.' + activeItems).show();
            return false;
        });
    });
</script>

<div class="content-page">
    <div class="header-area">

        <div class="breadcrumbs">  
            <a href="index.php">Admin Home</a>
            <a href="blocks.php">Blocks</a>
            <span><a href="edit_block.php?id=<? echo $id; ?>">Edit Block</a></span>
        </div>
    </div>
    <div class="content-outer">  

        <h2>Edit<strong>Block</strong>: <? echo $_POST['title']; ?></h2>

        <div class="notification info">Custom blocks can be displayed in your template using PHP code: <b><? echo htmlentities('<?php displayBlock(BLOCK_ID); ?>', ENT_QUOTES, 'UTF-8'); ?></b>, where BLOCK_ID is the ID of the block in the system (visible in blocks list in first column).</div>

        <div class="content-inner">

            <? echo getMessages(); ?>

            <form method="POST" action="" enctype="multipart/form-data" class="form" novalidate autocomplete="off">
                <table class="pagetable" id="languages">
                    <thead>
                        <tr>
                            <th colspan="2">Edit Block</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td colspan="2" class="lang-selection">
                                <ul class="tabs custom">
                                    <li><a href="#baseLang" class="tab active">Default</a></li>
                                    <? foreach ($languages as $l) { ?>
                                        <li><a href="#<? echo $l['iso']; ?>" class="tab"><i class="flag-icon flag-icon-<? echo strtolower($l['iso']); ?>"></i><? echo $l['iso']; ?></a></li>
                                    <? } ?>
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <td>Administrative Title</td>
                            <td><input type="text" name="title" value="<? echo $_POST['title']; ?>" required /></td>
                        </tr>
                        <tr class="baseLang langInput">
                            <td>Block Title</td>
                            <td><input type="text" name="subject" value="<? echo $_POST['subject']; ?>" required /></td>
                        </tr>
                        <? foreach ($languages as $l) { ?>
                            <tr class="<? echo $l['iso']; ?> langInput" style="display: none;">
                                <td><i class="flag-icon flag-icon-<? echo strtolower($l['iso']); ?>"></i>Block Title (<? echo $l['name']; ?>/<? echo $l['iso']; ?>)</td>
                                <td><input type="text" name="lang[<? echo $l['iso']; ?>][subject]" value="<? echo $_POST['lang'][$l['iso']]['subject']; ?>" /></td>
                            </tr>
                        <? } ?>
                        <tr class="baseLang langInput">
                            <td>Block Content</td>
                            <td><textarea name="body" class="large editor-enabled" required><? echo $_POST['body']; ?></textarea></td>
                        </tr>
                        <? foreach ($languages as $l) { ?>
                            <tr class="<? echo $l['iso']; ?> langInput" style="display: none;">
                                <td><i class="flag-icon flag-icon-<? echo strtolower($l['iso']); ?>"></i>Block Content (<? echo $l['name']; ?>/<? echo $l['iso']; ?>)</td>
                                <td><textarea name="lang[<? echo $l['iso']; ?>][body]" class="large editor-enabled"><? echo base64_decode($_POST['lang'][$l['iso']]['body']); ?></textarea></td>
                            </tr>
                        <? } ?>
                        <tr>
                            <td>Status</td>
                            <td>
                                <select name="status">
                                    <option<? echo ($row['status'] == '1') ? ' selected' : ''; ?> value="1">Enabled</option>
                                    <option<? echo ($row['status'] == '0') ? ' selected' : ''; ?> value="0">Disabled</option>
                                </select>
                            </td>
                        </tr>
                        <tr class="item submit">
                            <td colspan="2">
                                <input type="hidden" name="id" value="<? echo $row['record_num']; ?>" />
                                <input type="hidden" name="formSubmit" value="1" />
                                <button type="submit" class="btn action-save">Save</button>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </form>
        </div>
    </div>
</div>



<? require "footer.php"; ?>