About Me

It's me, Arif N. In this blog I'll write about my adventure related to computer, programming, and anything that I found interesting. I wish you a happy reading.. :D

Category: PHP

Howdy.

One day, when I surfed the web, I found an interesting site. This site has function like a normal blog, but the post written there was posted from various blog sources. Later, I knew that this blog is called aggregator. How this blog aggregator works? It works by collecting RSS Feeds from various blogs registered. The feeds then posted as normal posts in the aggregator. One of the differences is the article title linked to the “real” blog source.

Ilkomerz 41 Blog Aggregator

Ilkomerz 41 Blog Aggregator

When I knew that some of my friends also have their own blogs, I started to thinking about building this aggregator. The site that I found earlier is powered by Planet, a Phyton-based feed reader. I tried it, and ended up with failure. I just couldn’t configure and tested it properly. I didn’t have Internet connection and didn’t familiar with Phyton at that time. So, I tried to find alternative. I found WP-o-Matic plugins for WordPress. So I installed, asked my friends permission to grab their feeds, and hosted it. I called it Ilkomerz 41 Blog Aggregator.

Another problem arose. This plugin will automatically read and parse feeds from its registered blogs every amount of time. To make this fetching run automatically, it uses cron job. The WP-o-Matic has two options of cron job. The first one is UNIX cron job run by web hosting. Free hosting, like the one I use, doesn’t give cron job feature. So I go to the next option, web cron. It will automatically calling fetching script on the hosting.

I use the web cron option for some months until suddenly the aggregator was down. Well, it worked again when I send a support ticket to the hosting provider. I know that maybe it’s not because of the web cron spending too much resource. I suspected that because of the multi-user nature of the aggregator, the blog automatically sending email to the blog writer. The hosting may called it spam. So I killed the auto-email feature. I also shut down WP-o-Matic and switched it to manual fetching. I know that maybe it’s not because of the WP-o-Matic’s web cron, but I don’t wanna take the risk losing this blog for the second time.

Manual fetching was a pain. I must open my Google Reader, find if my friends have new post, and then login to the aggregator, fetching the post, and the post will showed up. I was thinking, there must be a better way to do this. Accidently, I found out that there are some webs that provide free cron job. One of them is SetCronJob. This site can calls the cron script url of the aggregator. So, I tried it yesterday. I registered the aggregator to the site. And now, my aggregator works well automatically. I don’t know what will come in the future, but I have a high hope for SetCronJob.

Do you have another opinions or experience? Feel free to share it.

CodeIgniter (CI) is one of the MVC frameworks available. Unlike legacy PHP technique, This framework use different URI format for sending and receive parameters. For example: if we use usual PHP technique, we will use URI like:

localhost/index.php?id=2

But in CI, the URI would be look like this:

localhost/index.php/welcome/2

Where index.php is the router, welcome is the controller, and 2 is the parameter given to the welcome controller. It’s because of its design pattern, the MVC (Model-View Controller).

After some reads, there were a lot of discussion on removing the “index.php” in CI forum. And I’ve been spending my time just to figure it out. I found some good resources at CodeIgniter Wikis, and after some trial-and-error, finally it works for me. This is how I do it:

  1. I created .htaccess file and put it on my CI installation folder. If you used Windows, you could use Save As… menu from Notepad to create this file.
    My CI installation folder was www/igniter, so I put the .htaccess file on this folder. And this is my .htaccess file:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /igniter
    
    #Removes access to the system folder by users.
    #Additionally this will allow you to create a System.php controller,
    #previously this would not have been possible.
    #‘system’ can be replaced if you have renamed your system folder.
    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]
    
    #Checks to see if the user is attempting to access a valid file,
    #such as an image or css document, if this isn’t true it sends the
    #request to index.php
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    #This last condition enables access to the images and css folders, and the robots.txt file
    #Submitted by Michael Radlmaier (mradlmaier)
    RewriteCond $1 !^(index\.php|images|robots\.txt|css)
    RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>
    
    <IfModule !mod_rewrite.c>
    # If we don’t have mod_rewrite installed, all 404’s
    # can be sent to index.php, and everything works as normal.
    # Submitted by: ElliotHaughin
    
    ErrorDocument 404 /index.php
    </IfModule>

    I just copy-paste the code from CI’s Wiki and modified the RewriteBase into my CI installation folder (in my case: igniter)

  2. Then, I opened the system/application/config/config.php file. I modified the $config['index_page'] from
    $config['index_page'] = "index.php";

    into

    $config['index_page'] = '';
  3. I activated mod_rewrite on the Apache. I opened the httpd.conf file and delete the # character in front of:
    LoadModule rewrite_module modules/mod_rewrite.so
  4. I didn’t need to modified the directory section of httpd.conf file. Maybe it had been already configured by the Apache.

And it works for me. The URI now without the index.php segment. I implemented all of the configuration above on Windows using Wamp. I tried it on Linux too, but so far It didn’t work. I’ll tell you later if I make it.

Most of the WordPress users place the blogroll on the sidebar. But with the increasing number of links added, the sidebar won’t look so good anymore. This problem finally falls into me. So I wanna find a way to list the blogroll on a separate page.

Google brought me to a plugin (for WordPress) called Blogroll Page. I downloaded and tried it. It was easy-to-configure and works fine. But it only lists the links from my blogroll without its category. So then, I read the code and checked the databases, and I said, “I think I could do something about it”.

Minutes later, I modified the code (luckily, it’s GPL). It took some times after finally the plugin could show categories and links inside it. Now, you could download it for free. You could see it works on my class’s aggregator links page.

Here are the installation instruction:

  1. Download the blogroll-page-with categories
  2. Extract it and place it on your plugins folder
  3. Create new post or page for your links and write in its content:

    <!--blogroll-page-->

  4. You could change the Open links on a new window and the Support links options on the Settings > Blogroll Page. I didn’t change it.
  5. That’s all folks!

Hope this plugin will help you. As usual comments are welcome.