<?php

/* setup includes */
require_once 'includes/master.inc.php';
/* require login */
$Auth->requireUser('login.php');
/* load the fileFolder */
if (isset($_REQUEST['u'])) {
    $fileFolder = fileFolder::loadById($_REQUEST['u']);
    if (!$fileFolder) {
        // failed lookup of the fileFolder
        redirect('http://' . _CONFIG_SITE_FULL_URL . '/account_folders.' . SITE_CONFIG_PAGE_EXTENSION);
    }
    // check current user has permission to edit the fileFolder
    if ($fileFolder->userId != $Auth->id) {
        redirect('http://' . _CONFIG_SITE_FULL_URL . '/account_folders.' . SITE_CONFIG_PAGE_EXTENSION);
    }
} else {
    redirect('http://' . _CONFIG_SITE_FULL_URL . '/account_folders.' . SITE_CONFIG_PAGE_EXTENSION);
}
/* setup page */
define("PAGE_NAME", t("edit_page_name", "Edit"));
define("PAGE_DESCRIPTION", t("edit_meta_description", "Edit existing item"));
define("PAGE_KEYWORDS", t("edit_meta_keywords", "edit, existing, item"));
/* handle submission */
if ((int) $_REQUEST['submitme']) {
    // validation
    $folderName = trim($_REQUEST['folderName']);
    $isPublic = (int) trim($_REQUEST['isPublic']);
    $accessPassword = trim($_REQUEST['accessPassword']);
    if (!strlen($folderName)) {
<?php

/* setup includes */
require_once 'includes/master.inc.php';
// initial checks
$folderId = $_REQUEST['f'];
$folderExp = explode('~', $folderId);
$folderId = (int) $folderExp[0];
// make sure it's a public folder or the owner is logged in
if ($folderId) {
    $fileFolder = fileFolder::loadById($folderId);
    if (!$fileFolder) {
        // failed lookup of the fileFolder
        redirect('http://' . _CONFIG_SITE_FULL_URL . '/index.' . SITE_CONFIG_PAGE_EXTENSION);
    }
    // check the folder is public
    if ($fileFolder->isPublic == 0 && $fileFolder->userId != $Auth->id) {
        redirect('http://' . _CONFIG_SITE_FULL_URL . '/index.' . SITE_CONFIG_PAGE_EXTENSION);
    }
} else {
    redirect('http://' . _CONFIG_SITE_FULL_URL . '/account_folders.' . SITE_CONFIG_PAGE_EXTENSION);
}
// check for password if we need it
$showFolder = true;
if (strlen($fileFolder->accessPassword) > 0) {
    /* check folder password */
    if ((int) $_REQUEST['passwordSubmit']) {
        // check password
        $folderPassword = trim($_REQUEST['folderPassword']);
        if (!strlen($folderPassword)) {
            setError(t("please_enter_the_folder_password", "Please enter the folder password"));