$tablename = 'mod_' . $dlgmodname; if (LANGUAGE_LOADED) { require WB_PATH . '/modules/' . $dlgmodname . '/languages/EN.php'; if (file_exists(WB_PATH . '/modules/' . $dlgmodname . '/languages/' . LANGUAGE . '.php')) { require WB_PATH . '/modules/' . $dlgmodname . '/languages/' . LANGUAGE . '.php'; } } // STEP 0: initialize some variables $page_id = (int) $page_id; $section_id = (int) $section_id; // delete empty records $database->query("DELETE FROM `" . TABLE_PREFIX . $tablename . "_files` WHERE `page_id` = '{$page_id}' AND `section_id` = '{$section_id}' AND `title`=''"); $database->query("DELETE FROM `" . TABLE_PREFIX . $tablename . "_groups` WHERE `page_id` = '{$page_id}' AND `section_id` = '{$section_id}' AND `title`=''"); // initialize template data $dir = pathinfo(dirname(__FILE__), PATHINFO_BASENAME); $data = array('FTAN' => method_exists($admin, 'getFTAN') ? $admin->getFTAN() : '', 'heading' => "{$module_name} - " . $TEXT['PAGE'] . " {$page_id}", 'modify_link' => ADMIN_URL . '/pages/modify.php', 'self_link' => WB_URL . '/modules/' . $dir, 'mod_version' => $module_version, 'groups' => array(), 'files' => array(), 'gr2name' => array(), 'ext2img' => dlg_ext2img($section_id), 'grfiles' => array(), 'dlpergroup' => array(), 'dlsum' => dlg_getdlsum($section_id)); // actions // toggle active state if (isset($_GET['status']) && is_numeric($_GET['status'])) { $status = $_GET['status'] == 1 ? 0 : 1; // sanitize input if (isset($_GET['file_id']) && is_numeric($_GET['file_id'])) { $table = 'files'; $field = 'file_id'; $id = $_GET['file_id']; } elseif (isset($_GET['group_id']) && is_numeric($_GET['group_id'])) { $table = 'groups'; $field = 'group_id'; $id = $_GET['group_id']; } else { // do nothing (invalid data)
} } // handle download if (isset($_REQUEST['dl'])) { header_remove(); // remove any output buffers before sending the file while (ob_get_level() > 0) { ob_end_clean(); } // send file and exit dlg_download($_REQUEST['dl'], $section_id); exit; } // initialize template data $dir = pathinfo(dirname(__FILE__), PATHINFO_BASENAME); $data = array('FTAN' => method_exists($admin, 'getFTAN') ? $admin->getFTAN() : '', 'self_link' => $_SERVER['SCRIPT_NAME'], 'mod_version' => $module_version, 'groups' => array(), 'gr2name' => array(), 'ext2img' => dlg_ext2img($section_id), 'filecount' => dlg_getfilescount($section_id), 'num_files' => 0, 'page' => 1, 'prev' => NULL, 'next' => NULL); // get settings $data['settings'] = dlg_getsettings($section_id); // get groups list($data['groups'], $data['gr2name']) = dlg_getgroups($section_id); // Get user's username, display name, email, and id - needed for download info $users = array(); $query_users = $database->query("SELECT `user_id`,`username`,`display_name`,`email` FROM `" . TABLE_PREFIX . "users`"); if ($query_users->numRows() > 0) { while ($user = $query_users->fetchRow()) { // Insert user info into users array $user_id = $user['user_id']; $users[$user_id]['username'] = $user['username']; $users[$user_id]['display_name'] = $user['display_name']; $users[$user_id]['email'] = $user['email']; }