Category Archives: Computer Science

Mostly programming and coding work related to PHP, HTML, Java, C#, Python and any other that I come across. May also include consumer level articles.

Adding an IP log code to PHP files

A lot of people want to keep track of who visit their site. There are several ways to collect user data and the most easiest method would be to collect data using a third party company that logs IPs, page visited and other information such as web browser, data, time, etc. Then then data can be modify to create data on demographics and Internet service providers by extrapolating the IP addresses. However, what is fun of having a third party do your code for you? The fun part comes win when we can make our own code such as the one posted below:

<!--ip log-->
<?php
$v_ip = $_SERVER['REMOTE_ADDR'];
$v_date = date("l d F H:i:s");
$v_page = $_SERVER['REQUEST_URI'];
$u_ref = $_SERVER['HTTP_REFERER'];
$fp = fopen("sanuja.com-ip_log.php", "a");
if ($v_ip != "192.168.1.1") {
fputs($fp, "<strong>IP: $v_ip - </strong><strong>PAGE:</strong> $v_page - <strong>DATE:</strong> $v_date - <strong>REFERER:</strong> $u_refn
");
}
fclose($fp);
?>

Continue reading Adding an IP log code to PHP files

Update on my servers

Fist of all OMG! My marks for exams roll out and I did some what poor… However, it is possible to pull up a good grade if I study well for the final.

Anyway, I am still working on rather upgrading and updating my servers. I am looking in to buying another server specifically for file storage. My current system has limited space for data storage with RAID 5 low capacity high RPM drives. However, there are servers sale online for very cheap with over 8TB storage with RAID 5 configuration.

I will save some money down the road and will buy a new server for media files with may be FreeNAS operating system. I know it is a waste of money, but then again this is my hobby and somewhat it makes sense to spend my own money on that. I wonder if I will work on development of severs when I am 70 or 80 years old. LOL I don’t want to live that long anyway.

Not many people read my blog anyway, but in case any one who came across my blog, I am sorry that I didn’t updated the system in a long time.

I hope a lot of students across Canada and rest of the world who wrote exam did well. All the best for all of you.

RAID cannot be trusted for safe data storage

Many people think that RAID configuration can protect their data for sure. This is not the case because even RAID 1 have its own problems. The most common problem that many server operators face is that after a drive fail, the rebuilding process take the other functional hard drives to the maximum limits sometimes causing one of them to fail. This is often true in RAID 5 and when you end up with two failed drives, all the data will be lost on the array.

Another common cause of RAID failure would be the RAID controller failure. If the RAID controller failed and you are unable to find the exact same controller with exact same specifications and/or the RAID controller you have now do not have a the capability to recover data in case of a controller failure without losing the data, (MOST controllers rebuilt the RAID array when a new controller is added) you will lose all the data on your system.

The lesson here is that we should always backup important data on more than one computer. If you have important data such as company information or any mission critical data, then you should also back up in more than one physical location. For example, if you have data that must be protected at all cost, it should be back up outside of the house that the main server is located. This will safe guard the data in case of a fire or massive failure in electrical system causing a power surge that didn’t suppressed by the UPS.

Server RAID rebuilt…

This is actually the continuation my previous update on the server. As I noted in that previous post setting up a RAID 5 with six 146 GB drives and two 72 GB drives was very stupid. But I never explained why this is a stupid idea on my first post. Today we will look at the best way to mix and match different types of harddrives on a RAID system for optimum performance and the highest storage output.

The the RAID 5 system works by taking all the hard drives with even different sizes and strip the data on all of them to provide one drive fail backup support for the system. In other words, on a RAID 5 system, you an tolerate one drive failure without loosing data. In this method, the RAID controller will take the lowest capacity of all the drives on the array and multiply that lowest capacity by the number for drives regardless of the capacities of the larger drives. For example, if we have two 72 GB drives and six 146 GB drives, the RAID controller will see all the eight drives as 72 GB drives. By doing the math for the RAID 5 system: (72 GB * 8)-72GB = 567 GB in total. Considering 146 GB *6 itself is 876 GB, this creates a a lot of wasted space. In addition to this reduced space, the 72 GB HDs are running at 15K RPM while the 146 GB HDs are running at 10 K causing the RAID to operate at the lowest RPM value of 10 K even with the six 15 K drives have the capability to Continue reading Server RAID rebuilt…

I had to rebuild the software side due to an error in judgement

Yesterday I had to rebuild my entire server because I made an error in how I created the RIAD system. When I initially setup the server, I placed all my 146 GB and 76 GB units of harddrives in one RAID 5 cause a huge loss of data space. When you add different sizes of HDs to a RAID 5 array, the controller takes the multiples of the smallest and the slowest RPM for the maximum output causing a huge limitation on the RAID. I dismount the entire RAID 5 and mounted the 146 GB at 10 K on RAID 5 and an independent RAID 1 for the two 76 GB units at 15 K. Then I installed the OS in the 76 GB faster drives giving me a faster boot time while the six 146 GB on RAID 5 provided a maximum yield of storage space.

This is the best configuration for the hardware I have right now.  Unless I upgrade the 76 GB units with new 146 GB units which I don’t think I will go for right now. Let’s compare what I had previously to what I have now in my next post!!