vince's blog

This is my blog. I post pieces here about programming, systems, hardware, IT, music, or whatever else I want to talk about.

[#2] Build Log: Ivy

Now that I can upload images to my blog, I can show off my new computer build!

Although I have experience in CentOS and have used other distros like Ubuntu, OpenSUSE, and Manjaro, I wanted to build a dedicated machine to learn Arch on, and to eventually become comfortable enough for personal use. I will talk about the Arch installation process in the next entry.

CPU: Intel i7-6700 (purchased used from friend)
Motherboard: ASUS H110M-A micro-ATX
RAM: G.SKILL Ripjaws V Series 8GB (2x4GB) DDR4 2133
PSU: EVGA 450 B3, 450W fully modular
SSD: SanDisk 250GB Ultra 3D 2.5"
Case: DIYPC Cuboid-G Black Micro-ATX Mid Tower
Total cost: ~$500

First of all, the Cuboid-G case looks really cool. I don't have enough good things to say about this case. It managed to fit everything well with room to spare for airflow, even as a micro-ATX case. I added an extra 120mm green LED fan almost solely for the extra brightness. I loved it so much that I bought it despite getting a micro-ATX included with the CPU.

I bought the i7-6700 along with a Gigabyte GA-H110M-A motherboard and a Thermaltake micro-ATX case used, but unfortunately when powered on, the motherboard had a beep code of 5 short beeps, which normally means CPU error. I tested out the CPU on my brother's motherboard, since he has a LGA 1151 socket motherboard, and his PC booted with no issues. When testing his i5-6500 in my Gigabyte motherboard, I got the same beep code. Therefore, I figured it was the board. Although I haven't figured out the issue with the Gigabyte board, I believe it is a bent capacitor attached near the CPU socket. Sadly I do not have the know-how to fix that. I was going to Micro Center that day to pick up a new network switch and an optical drive for the new build, so I purchased the new ASUS board and thankfully the build ran smoothly.

With both motherboards, I forgot to fit the I/O panel in before assembling, so I had to re-assemble the entire build both times to fit the panel in, much to my frustration.

I only bought a 250GB SSD because I do not plan on storing much on the computer. Vanilla Arch Linux is less than 1 GB, and most desktop environments are less than 10 GB. This gives plenty of room for document and program storage.

I bought an HDMI switch to share my lower main display between the new build and my main PC, but I have a 1600x900 display to my right that is also connected via DVI in case my two main displays are in use.

The new computer is named 'ivy' due to its bright green LEDs and the side panels which make the build look like a terrarium for wires. Check out pictures of the build below, and stay tuned for my next post: Installing Arch.

Side note: PLEASE clean out your CPU coolers. The same day I built ivy, I noticed my CPU temps were getting up to 60 degrees Celsius on my main computer. I cleaned the CPU cooler with rubbing alcohol and a knife, and my CPU runs about 20 degrees cooler now. The dust formed a thick sheet I peeled off almost entirely in one piece.

[ 5 images hidden. Click here to view ]
build log ivy hardware motherboard Linux
watercolour | 17 May 2018 10:01:36

[#1] Creating a blog

Welcome to my new blog! I spent about a week working on this whenever I had some spare time. I hope to add commenting and image functionality soon, but for the time being this blog will just be rambling articles by yours truly.

I set up a MySQL database with four tables: entries, users, comments, and img. Then I did some bare-bones HTML/CSS to lay out the beautiful masterpiece you're looking at now. I used PHP prepared statements to store and retrieve blog posts, added register and login forms and some PHP functions to handle those, and password + salt SHA-1 encryption. Upon registration, I check that the username/email is unique before handling the password and encrypting. Both login and register forms also have a captcha, provided by Securimage. It is a very simple script that I easily implemented in my error checking section. Bonus points for not being provided by Google! The captcha error will print before and instead of any username/email/password errors, so bots cannot phish for valid usernames or emails through those error messages. After validating all information, the site then stores the session in a $_SESSION['user'] associative array, with all of the information retrievable using, for example, $_SESSION['user']['username'] to display the logged in user's username. I obviously only store relevant and non-confidential information in the session.

Pagination was a bit tricky, since I wanted posts to display in descending order. Of course, an SQL select statement can be appended by DESC to retrieve values in descending order, but I needed to calculate $first_index and $last_index to only retrieve the posts needed for that page. I figured this would be faster than retrieving all posts and only displaying the quantity $posts_per_page. After some scratch work here's what I came up with:

$post_count is the result of SELECT COUNT(id)
$posts_per_page is set to 5 currently.
$page is $_GET['page'], default 1

$first_index = $post_count - ($page * $posts_per_page) + 1
$last_index = $first_index + $posts_per_page

In the query, the first index is inclusive while the last index is not.

Lastly, I wanted to have a functional and helpful tagging system, to make topics easier to read about and to show similar posts on a certain topic. I did this by making five tag columns, tag1...tag5. They can be NULL, and if $_GET['tag'] is set, a different select query is used. It does not use $first_index and $last_index and instead has a condition `WHERE (tag1=$_GET['tag']) OR ... OR (tag5=$_GET['tag'])`. Unfortunately this means that tag filter results are not paginated, but I hope to incorporate this soon!

I hope this quick piece was informative to anyone looking for the basic steps to setting up a blog like this. This will be the general format of most posts to come, and as mentioned before I will hopefully have commenting and image (upload) support soon to build a more detailed and interactive platform to talk about tech on! Thanks for reading :)
blog php mysql captcha encryption
watercolour | 09 May 2018 07:48:33