|Tech||:||C#, AlphaFS, Json.NET, 7z, PHP, omines/directadmin|
After university, I started working part-time as a programmer. I usually worked with websites, and they were mostly made with WordPress. This meant that there were a lot of themes and plugins. In other words, possible causes for trouble.
These websites were hosted on a few rented private servers, all managed through DirectAdmin. From time to time, we needed to move one website from one (physical) server to another, and doing this was tedious. While DirectAdmin offered basic backup and restore functions, it was not enough. DirectAdmin handled the packing/unpacking of the website files and exporting/importing the DirectAdmin configuration, but there were other things that needed to be dealt with, i.e. modifying database credentials (in
wp-config.php) and modifying the SQL dump. If there was any change (there usually was) in the DirectAdmin config or in website files (different user name, path, URL, etc.), the related files needed to be modified.
These modifications were not as simple as doing a find-and-replace. Firstly, there were encoded versions of the strings that needed to be replaced. Secondly, there were versions with slight variations. Thirdly, and the one that gave me the most headache, there were serialized strings (in the sql dump) that needed to be replaced. One can't do a simple find-and-replace on a serialized string (see PHP - serialize), because one needs to replace two things: the string and the string length. For example, here's a serialized string:
s:2:"hi";. If one changes the
hello, but don't change
5, this will break things when the string is unserialized.
I built a small tool to do all these find-and-replace operations for me, but this was not the actual problem that I was having. It was going back-and-forth among the servers. I decided to build a native app to solve this. The goal was to enable the following actions in one place:
- list the websites on a server
- create and delete user/website
- backup, download, modify, upload, and restore a website
Although I had previously done some small things in C#, this was the first major app that I've built using C#. I can easily say that this decreased the time and effort it took to do these actions significantly, probably up to 70-80%. More importantly, it enabled anyone to do these actions, not requiring much technical knowledge.