Example #1
0
<?php

include './stuff/inc/mn-start.php';
$auth = user_auth('5');
$admin_tmpl['folders_main'] = true;
$folders = get_unserialized_array('folders');
$files_count = get_files_count('folders');
if (isset($_POST['action']) && $_POST['action'] == 'add') {
    if (isset($_POST['folder_name']) && !empty($_POST['folder_name'])) {
        $auto_id = file_exists($file['id_folders']) ? trim(file_get_contents($file['id_folders'])) : 1;
        $folder_parent = isset($_POST['folder_parent']) ? (int) $_POST['folder_parent'] : 0;
        $folders[$auto_id] = array('name' => check_text($_POST['folder_name'], true), 'parent_id' => $folder_parent);
        if (mn_put_contents($file['folders'], DIE_LINE . serialize($folders))) {
            mn_put_contents($file['id_folders'], $auto_id + 1);
            header('location: ./mn-folders.php?back=added&f=' . $auto_id);
            exit;
        } else {
            overal_header($lang['folders_folders'], $lang['folders_msg_put_contents_error'], 'error');
        }
    } else {
        overall_header($lang['folders_folders'], $lang['folders_msg_empty_folder_name'], 'error');
    }
} elseif (isset($_POST['action']) && $_POST['action'] == 'edit' && isset($_POST['id']) && array_key_exists($_POST['id'], $folders)) {
    if (!empty($_POST['folder_name'])) {
        $folders[$_POST['id']] = array('name' => check_text($_POST['folder_name'], true), 'parent_id' => (int) $_POST['folder_parent']);
        if (mn_put_contents($file['folders'], DIE_LINE . serialize($folders))) {
            header('location: ./mn-folders.php?back=edited&f=' . $_POST['id']);
            exit;
        } else {
            overal_header($lang['folders_folders'], $lang['folders_msg_put_contents_error'], 'error');
        }
Example #2
0
<?php

include './stuff/inc/mn-start.php';
$admin_tmpl['galleries_main'] = true;
$admin_tmpl['code'] = false;
$galleries = file_exists($file['galleries']) ? load_basic_data('galleries') : array();
$files_count = get_files_count();
if (isset($_GET['action']) && $_GET['action'] == 'ajaxcall') {
    if (isset($_GET['gallery_name']) && !empty($_GET['gallery_name']) && !in_array($_GET['gallery_name'], $galleries)) {
        if (file_exists($file['galleries'])) {
            $galleries_file = file($file['galleries']);
            $galleries_file_lines = '';
            foreach ($galleries_file as $single_line) {
                $gallery_data = explode(DELIMITER, $single_line);
                if (substr($gallery_data[0], 0, 2) == '<?') {
                    $auto_increment_id = trim($gallery_data[1]);
                } else {
                    $galleries_file_lines .= $single_line;
                }
            }
        } else {
            $auto_increment_id = 1;
            $galleries_file_lines = '';
        }
        $galleries_file_content = SAFETY_LINE . DELIMITER . ($auto_increment_id + 1) . "\n" . $galleries_file_lines;
        $galleries_file_content .= $auto_increment_id . DELIMITER . $_GET['gallery_name'] . DELIMITER . friendly_url($_GET['gallery_name']) . "\n";
        if (mn_put_contents($file['galleries'], $galleries_file_content)) {
            echo '<li><input type="checkbox" name="galleries[]" id="gallery-' . $auto_increment_id . '" class="input-gallery" value="' . $auto_increment_id . '" checked="checked" /> <label for="gallery-' . $auto_increment_id . '">' . substr($_GET['gallery_name'], 0, 20) . '</label></li>';
            die;
        } else {
            echo 'Error MN#44: cannot write to mn-galleries.php file!';