Browse .txt files on the server?

I want my admins to be able to browse through the data/exsto/logs/ directory and read all the text files in a window while in-game.
Where can I start? Will a DFileBrowser work to browse the server side logs?

  1. Send a net message to the server requesting a list of files in the directory.
  2. When you receive the file list back from the server, add all entries to a DListView.
  3. When a line is (right)clicked in the dlist, send a net message with the filename to the server
  4. When the server receives the message, read the file and send it to the client. You may need to split it up into smaller chunks if it’s a larger file.
  5. When the client receives this list, add it to a dscrollpanel as a dlabel or richtext or the console or something

you get the idea

You’d have to send the file structure of the server’s directories as a table using the net library.
You can get the structure by using the file library, for example, serverside:
[lua]-- messages for sending/receiving lists
util.AddNetworkString( “logs_SendList” )
util.AddNetworkString( “logs_RequestList” )

– messages for sending/receiving files
util.AddNetworkString( “logs_SendFile” )
util.AddNetworkString( “logs_RequestFile” )

– This function will get a list of all files in the directory
local function FileList()

local files = {}

for k, v in pairs( file.Find( "exsto/logs/*.txt", "DATA" ) ) do
	table.insert( files, v )


return files


– You can do this to open the players menu, when they request it
net.Receive( “logs_RequestList”, function( len, ply )
– I recommend you do a usergroup check here to make sure that “ply”
– has permission to request this, else return end

net.Start( "logs_SendList" )
	net.WriteTable( FileList() )
net.Send( ply )

end )

– This can receive requests for a file, given a file name
net.Receive( “logs_RequestFile”, function( len, ply )
– Once again I recommend you do a permission check

local filename = net.ReadString()

net.Start( "logs_SendFile" )
	net.WriteString( file.Read( "exsto/logs/"..filename, "DATA" ) )
net.Send( ply )

end )[/lua]

Clientside, you should use a DListView, because then you can have once column showing a sanitised date/time made using the file’s name, then the second, invisible (set width to 0) column which contains the file’s raw name so that you can send it to the server in a request.