requireUser(WEB_ROOT . '/login.' . SITE_CONFIG_PAGE_EXTENSION); /* load the fileFolder */ if (isset($_REQUEST['u'])) { $fileFolder = fileFolder::loadById($_REQUEST['u']); if (!$fileFolder) { // failed lookup of the fileFolder coreFunctions::redirect(WEB_ROOT . '/account_home.' . SITE_CONFIG_PAGE_EXTENSION); } // check current user has permission to edit the fileFolder if ($fileFolder->userId != $Auth->id) { coreFunctions::redirect(WEB_ROOT . '/account_home.' . SITE_CONFIG_PAGE_EXTENSION); } } else { coreFunctions::redirect(WEB_ROOT . '/account_home.' . 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")); // load folder structure as array $folderListing = fileFolder::loadAllForSelect($Auth->id); /* handle submission */ if ((int) $_REQUEST['submitme']) { // validation $folderName = trim($_REQUEST['folderName']); $isPublic = (int) trim($_REQUEST['isPublic']); $accessPassword = trim($_REQUEST['accessPassword']); $parentId = (int) $_REQUEST['parentId']; if (!strlen($folderName)) { notification::setError(t("please_enter_the_filename", "Please enter the folder name")); } elseif (_CONFIG_DEMO_MODE == true) { notification::setError(t("no_changes_in_demo_mode")); } else { // check for existing folder $rs = $db->getRow('SELECT id FROM file_folder WHERE folderName = ' . $db->quote($folderName) . ' AND userId = ' . (int) $Auth->id . ' AND id != ' . $fileFolder->id); if ($rs) { if (COUNT($rs)) { notification::setError(t("already_a_folder_with_that_name", "You already have a folder with that name, please use another")); } } } if ($isPublic == 0) { $accessPassword = ''; } // create the account if (!notification::isErrors()) { // make sure the user owns the parent folder to stop tampering if (!isset($folderListing[$parentId])) { $parentId = 0; } // prepare password if (strlen($accessPassword)) { $accessPassword = MD5($accessPassword); } if ($parentId == 0) { $parentId = NULL; } // update folder $db = Database::getDatabase(true); if ((strlen($accessPassword)) || ($isPublic == 0)) { $rs = $db->query('UPDATE file_folder SET folderName = :folderName, isPublic = :isPublic, parentId = :parentId, accessPassword = :accessPassword WHERE id = :id', array('folderName' => $folderName, 'isPublic' => $isPublic, 'parentId' => $parentId, 'id' => $fileFolder->id, 'accessPassword' => $accessPassword)); } else { $rs = $db->query('UPDATE file_folder SET folderName = :folderName, parentId = :parentId, isPublic = :isPublic WHERE id = :id', array('folderName' => $folderName, 'isPublic' => $isPublic, 'parentId' => $parentId, 'id' => $fileFolder->id)); } if ($rs) { // redirect coreFunctions::redirect(WEB_ROOT . "/account_home." . SITE_CONFIG_PAGE_EXTENSION); } else { notification::setError(t("problem_updating_item", "There was a problem updating the item, please try again later.")); } } } // include header require_once(SITE_TEMPLATES_PATH . '/partial/_header.inc.php'); ?>



  • " class="submitInput" />