if (F_createMediaDir($dir . $_REQUEST['newdirname'])) { $dir = $dir . $_REQUEST['newdirname'] . '/'; F_print_error('MESSAGE', $l['m_directory_created']); } else { F_print_error('ERROR', $l['m_directory_create_error']); } } break; case 'deldir': F_stripslashes_formfields(); // Delete if ($_SESSION['session_user_level'] < K_AUTH_ADMIN_DIRS) { F_print_error('WARNING', $l['m_authorization_denied']); break; } if (!F_isAuthorizedDir($dir, $root_dir, $authdirs)) { F_print_error('WARNING', $l['m_authorization_denied']); break; } if (F_deleteMediaDir($dir)) { $dir = $root_dir; F_print_error('MESSAGE', $l['m_deleted']); } else { F_print_error('ERROR', $l['m_delete_file_error']); } break; default: break; } //end of switch echo '<div class="container">' . K_NEWLINE;
/** * Get an associative array of directories and folder inside the specified dir. * @author Nicola Asuni * @param $dir (string) the starting directory path * @param $rootdir (string) the user root dir. * @param $authdirs (string) regular expression containing the authorized dirs. * @return an associative array containing sorted 'dirs' and 'files' */ function F_getDirFiles($dir, $rootdir = K_PATH_CACHE, $authdirs = '') { $data['dirs'] = array(); $data['files'] = array(); // open dir $dirhdl = @opendir($dir); if ($dirhdl === false) { return $data; } while ($file = readdir($dirhdl)) { if ($file != '.' and $file != '..') { $filename = $dir . $file; if (F_isAuthorizedDir($filename . '/', $rootdir, $authdirs)) { if (is_dir($filename)) { if (strpos($filename . '/', K_PATH_LANG_CACHE) === false and strpos($filename . '/', K_PATH_BACKUP) === false) { $data['dirs'][] = $filename; } } else { $data['files'][] = $filename; } } } } // sort files alphabetically natcasesort($data['dirs']); natcasesort($data['files']); return $data; }