requireUser(WEB_ROOT . '/login.' . SITE_CONFIG_PAGE_EXTENSION); /* load file */ if (isset($_REQUEST['u'])) { $file = file::loadById($_REQUEST['u']); if (!$file) { // failed lookup of file coreFunctions::redirect(WEB_ROOT . '/account_home.' . SITE_CONFIG_PAGE_EXTENSION); } // check current user has permission to edit file if ($file->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")); /* handle submission */ if ((int) $_REQUEST['submitme']) { // validation $filename = trim($_REQUEST['filename']); $filename = strip_tags($filename); $filename = str_replace(array("'", "\""), "", $filename); $reset_stats = (int) trim($_REQUEST['reset_stats']); $folder = (int) trim($_REQUEST['folder']); $enablePassword = false; if (isset($_REQUEST['enablePassword'])) { $enablePassword = true; $password = trim($_REQUEST['password']); } if (!strlen($filename)) { notification::setError(t("please_enter_the_filename", "Please enter the filename")); } elseif (_CONFIG_DEMO_MODE == true) { notification::setError(t("no_changes_in_demo_mode")); } else { // check for files in same folder $foundExistingFile = (int) $db->getValue('SELECT COUNT(id) FROM file WHERE originalFilename = ' . $db->quote($filename . '.' . $file->extension) . ' AND statusId = 1 AND folderId ' . ($folder === 0 ? 'IS NULL' : ('= ' . $folder))); if ($foundExistingFile) { notification::setError(t("active_file_with_same_name_found", "Active file with same name found in the same folder. Please ensure the file name is unique.")); } } // no errors if (!notification::isErrors()) { if ($folder == 0) { $folder = null; } // update file $db = Database::getDatabase(true); $rs = $db->query('UPDATE file SET originalFilename = :originalFilename, folderId = :folderId WHERE id = :id', array('originalFilename' => $filename . '.' . $file->extension, 'folderId' => $folder, 'id' => $file->id)); if ($rs) { // clean stats if needed if ($reset_stats == 1) { $db->query('UPDATE file SET visits = 0 WHERE id = :id', array('id' => $file->id)); $db->query("DELETE FROM stats WHERE file_id = :id", array('id' => $file->id)); } // update password $passwordHash = ''; if ($enablePassword == true) { if (strlen($password)) { $passwordHash = MD5($password); } } if ((strlen($passwordHash)) || ((strlen($passwordHash) == 0) && (strlen($file->accessPassword)))) { $db->query('UPDATE file SET accessPassword = :accessPassword WHERE id = :id', array('accessPassword' => $passwordHash, 'id' => $file->id)); } // redirect coreFunctions::redirect(WEB_ROOT . "/account_home." . SITE_CONFIG_PAGE_EXTENSION . '?s=' . urlencode(t('file_item_updated', 'File updated.'))); } else { notification::setError(t("problem_updating_item", "There was a problem updating the item, please try again later.")); } } } // load folders $folders = fileFolder::loadAllForSelect($Auth->id); // include header require_once(SITE_TEMPLATES_PATH . '/partial/_header.inc.php'); ?>



  • accessPassword) ? 'CHECKED' : ''; ?>/>
      
  • " class="submitInput" />