is it possible to have fun programming (25)

11 Name: Anonymous Techie : 2021-11-21 09:30 ID:bKAVCz4L

>>10

>That's a pretty good approach actually, if it was one file per thread instead. And even better if it was one file per board/site without any of the new database cancer, and just kept the entire thing in memory for most of the work duration

Yes that seems to be the common flatfile implementation, but I didn't want to create one gigantic single file database.
TinyIB for example allows for both database and flatfile implementations, not sure how they do the flatfile stuff though.
With the separate files I chose if there was ever anything corrupted by a shutdown mid-process instead of the possibility of the entire file becoming fucked later I felt like a safer choice would be to separate it a bit, especially if the database were to grow huge. Main issue with separate files for each post is that you use a crapton of inodes in the long term which is bad especially for cheap shared hosting which usually caps out at 125-250k maximum (and a deleted file still counts!). I think a per thread option would be better in hindsight.

>It could sync memory content with a file once a hour or so.

This would have been a much better idea, yeah. I never considered storing things in memory most of the time lol, I like the thought of that a lot though although it definitely has some downsides like lost posts if server shuts down at an inconvenient time (1min before next backup).
My code sucks a lot to be honest, I'm sure it's filled with exploits too. I know of a couple issues that I haven't fixed and don't care too much about, like mod panel doesn't rely on a separate request token, so a third party website could send a request to the moderator panel using the admins login cookie). I also haven't added captcha to reports, but I don't think there's any incentive to attack my little practice project. All things that could be fixed relatively easily though.
One thing I do like is that the post-buttons work very well without JS. It's a bit wasteful in html data though, every option inside it is added as data in every single post as opposed to generating it with JS.

I have zero intention of ever running an imageboard (I don't want to moderate / feel responsibility over whatever, I prefer being a user on other people's boards, like this one) so don't think I'm advertising "my board" now (I don't actually want users), but you can look at some of the code here, and a demo link included for as long as I can bother to keep it online: https://github.com/ithrts/ImoutoIB/blob/master/post.php (notable as well would be includes/functions.php and main.php)
It's so stupid and messy, haven't done anything in a while though been busy, and I have a couple other things I want to try making for practice, but definitely will use functional programming and just generally more standardization for my other ideas. Need to learn more php and js first, been on a bit of a break. Might consider learning a different language though. Something a bit more nichè could be fun, like Haskell? Not sure! Definitely need to learn more JS, most of my JS functions are pretty similarly written because I don't know much.

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification: