Making ugly fonts pretty in Arch Linux

In Arch Linux, fonts may be okay, but in some apps like Google Chrome, they aren’t.

*UPDATE* This works on Debian, Crunchbang, Archbang, OpenSuSE, and probably most distributions.

Here is how to fix the fonts once and for all in Arch. It’s as simple as copy and paste.

Take the following code:

 <?xml version="1.0"?>
   <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
   <match target="font" >
     <edit mode="assign" name="rgba" >
   <match target="font" >
     <edit mode="assign" name="hinting" >
   <match target="font" >
     <edit mode="assign" name="hintstyle" >
   <match target="font" >
     <edit mode="assign" name="antialias" >
   <match target="font">
     <edit mode="assign" name="lcdfilter">

and paste it into a file named .fonts.conf (notice the . before fonts.conf – it needs to be there).

Log out and then log back in and your fonts should be much better – even in Google Chrome.

Php Hit Counter

Tracking traffic is a huge deal to some website critics, being able to check one’s web stats internally to see how many people visit each day, month, year, or overall. In this tutorial I’ll explain and show you how you can accomplish this method and implement it to your own site.

Step 1). Setting up database: You should have 3 tables in your database.


 CREATE TABLE `hits` (
  `count_name` VARCHAR(20) NOT NULL DEFAULT '',
  `count` VARCHAR(255) NOT NULL DEFAULT '',
  `count_id` VARCHAR(30) NOT NULL DEFAULT '',
 PRIMARY KEY (`count_id`) ) TYPE=MyISAM;


 CREATE TABLE `public_hits` (
  `unique` INT(15) NOT NULL DEFAULT '0',
  `total` INT(15) NOT NULL DEFAULT '0',
  `date` DATE NOT NULL DEFAULT '0000-00-00',


 CREATE TABLE `daily_hits` (
  `date` DATE NOT NULL DEFAULT '0000-00-00',
  `unique_hits` INT(255) NOT NULL DEFAULT '0',
  `hits` INT(255) NOT NULL DEFAULT '0',

Use this following code to display the hit counter data on your site. Put it somewhere like at the footer of thepage:

 // hits
 $ha = @mysql_query("select * from hits where count_id='2'");
 // total hits
 $h1 = @mysql_fetch_array($ha);
 $hb = @mysql_query("select * from hits where count_id='1'");
 // unique visits $h2 = @mysql_fetch_array($hb);
 $date = date("Y-m-d");
 $d0 = @mysql_query("select * from daily_hits where date='$date'");
 $d1 = @mysql_fetch_array($d0);

 <!-- Display Stats -->

 <b>Site Stats</b>

 <b>Since DATESITEOPENED!!!!!!:</b>
 <br />
 <?php echo number_format($h1['count']); ?> hits<br />
 <?php echo number_format($h2['count']); ?> unique visitors<br />
 <b>Today's Info:</b><br />
 <?php echo number_format($d1['hits']); ?> hits<br />
 <?php echo number_format($d1['unique_hits']); ?> unique visitors<br />
 <a href="">More Traffic Stats</a>

Php Login/Logout Script

When building a dynamic website, one of the best and most common thing that a webmaster does is store the information of users in a database. But how does the website know who is who? That is where the login page comes in. Here is how a login script works:

1. The user enters their username and password and submits the form
2. The server compares the information that the user entered against the database.
3. If the info matches a row in the database, the row will be returned. If it doesn’t match, the number of rows is 0 and nothing is returned.
4. Assuming that the info matched what was in the database, the website sets a cookie. A cookie is a file that stores the user data for the amount of time that the website specifies (the webmaster sets the parameters for the time).
5. While the cookie is set, the information about the user can be retrieved from the cookie.

This article will show you how to match a user’s info against the info in the MySql database. I will give you instructions that you can try as you read this article.

To start out, you first need a table in the database. I will call the table “users” – if you already have a users table in your database, you may call it something else – but keep in mind I will reference the users table only. Here is the sql code to generate the users table.

CREATE TABLE `users` (
`username` VARCHAR(30) NOT NULL DEFAULT '',
`password` VARCHAR(32) NOT NULL DEFAULT '',
PRIMARY KEY (`user_id`)

INSERT INTO `users` VALUES (1, "john", "johnspassword", "john@void.null");
INSERT INTO `users` VALUES (2, "bob", "bobspassword", "bob@void.null");
INSERT INTO `users` VALUES (3, "suzy", "suzyspassword", "suzy@void.null");
INSERT INTO `users` VALUES (4, "cheryl", "cherylspassword", "cheryl@void.null");
INSERT INTO `users` VALUES (5, "monkey", "monkeyspassword", "monkey@void.null");

Next you will create your page. For info on how to do this, click here.

Now that you have created your users table and are connected to it, we will write some code to execute a query to match a user in it. Here is our script that will do the query:

 // First we set up the query as a variable to make
 // it a little easier to read.
 $set_up_query = "select * from users where username='bob'";
 // Then we execute the query
 $execute_query = @mysql_query($set_up_query);
 // We use the mysql_num_rows() function to see
 // how many rows were returned
 $number_of_rows = @mysql_num_rows($execute_query);
 // Tell php that if the number of rows returned
 // is more than 0 to tell us by echoing it to the
 // screen
 if($number_of_rows > 0){
 echo "There were $number_of_rows matches for bob";
 // if the number of rows was not more than 0 then
 echo "The number of rows was $number_of_rows <-- less than 1";

Now that we know how to compare info with the database using a static name such as bob, we can do the same with variables… like this (I also modified the query structure a bit – read the comments to understand what I did):

 // assign the name bob to a variable called $name
 $name = 'bob';
 // Notice this time that instead of setting up the query
 // and then executing it, I just put the query inside of
 // the mysql_query() function parenthesis. It works the
 // same way
 $execute_query = @mysql_query("select * from users where username='$name'");
 // We use the mysql_num_rows() function to see
 // how many rows were returned
 $number_of_rows = @mysql_num_rows($execute_query);
 // Tell php that if the number of rows returned
 // is more than 0 to tell us by echoing it to the
 // screen
 if($number_of_rows > 0){
 echo "There were $number_of_rows matches for bob";
 // if the number of rows was not more than 0 then
 echo "The number of rows was $number_of_rows <-- less than 1";

I’ll bet that now you are wondering how this works with a form. Now I will just dive in and show you (Keep in mind that anything that is not in the <?php tags ?> but is in between the <!– tags –> is a comment in HTML):

Page: login.php

 <title>Login Script</title>
 Please Sign In<br />
 <!-- For the form action, I use <?php echo $_SERVER['PHP_SELF']; ?>. This is
 a variable for the current page name. For example, if you look at the url for
 this page, it is pages.php. pages.php is equal to <?php echo $_SERVER['PHP_SELF']; ?>.
 If you want to, you can just make the action like this: action="login.php" but I don't
 reccommend it
 // if the form has been posted (or submitted)
 // include the MySql connection script so we can check the database
 // execute the query (this is the shorter version just like above
 // (with shorter variable names))at the end of the query you can
 // see that it says " or die(mysql_error()); "
 // that just means that it will execute the query, or else it will
 //die because there was dome kind
 // of error - it will print the error to tell you what was wrong
 $r = @mysql_query("select * from users where username='{$_POST['username']}' and
) or die(mysql_error());
 // get the number of matching rows from the database
 $n = @mysql_num_rows($r);
 // if the number of matching rows totals more than 0
 if($n > 0){
 // set a cookie with the users posted info
 // uname is the name of the cookie we are setting
 // $_POST['username'] is the data that was posted in the form that the
 // user submitted time()+3600 means that we are setting the cookie for
 // 3600 seconds - starting now '/' is the directory in which the cookie
 // is started at in the website
 // false means that the '/' will be for the whole website -
 // subdirectories and all.
 setcookie("uname", $_POST['username'], time()+36000, '/', false);
 // since the number of matching rows was more than one and the cookie has been set,
 // tell the user what to do next
 echo "You are now logged in. <a href=your_link.php>Click _fcksavedurl="your_link.php>Click" _fcksavedurl="your_link.php>Click" Here to Continue</a>";
 // this else means that the number of rows returned was not greater than
 // 0. No matching rows means that the username and password could not
 // be found in the database.
 echo "Sorry, there was nothing in the database that matched your
 username and password combination"
 <!-- open the form -->
 <form action=" <?php echo $_SERVER['PHP_SELF']; ?> " method="POST">
 <!-- Show the input text box for the username -->
 Username: <input type="text" name="username"><br />
 <!-- Show the input text box for the password -->
 Password: <input type="password" name="password"><br />
 <!-- Show the button to submit the form -->
 <input type="submit" name="submit">
 <!-- Close the form -->

If you want to log the user out, just reverse the cookie process. Instead of a time()+, use a time()- like this:

logout.php (create a link to this page from an already existing page):
setcookie("uname", $_POST['username'], time()-36000, '/', false);
echo "You are now logged out. <a href=your_link.php>Click Here to continue</a>";?>