My Writings. My Thoughts.
postgresql: 8.4 now released
// July 2nd, 2009 // No Comments » // General
postgresql 8.4 now released http://www.postgresql.org/about/news.1108
download: http://www.postgresql.org/download
magento: displaying SKU in the catalog
// June 25th, 2009 // No Comments » // ecommerce, php
If you like your customers to keep track the product that they ordered, SKU can be used instead of product names or product url pages. One way is to show in the catalog the SKUs of the products.
Note: I am using the default template of magento.
the following files are to be modified:
app/design/frontend/default/(YOUR SKIN)/template/catalog/product/list.phtml
app/design/frontend/default/(YOUR SKIN)/template/catalog/product/view.phtml
Find “// Grid Mode” in list.phtml and add the line below inside the condition. You can apply any css style to this line.
SKU: <?php echo $this->htmlEscape($_product->getSKU()) ?>
There are two types of views for the catalog list, one is for grid and anothe is for list. Look for the string “// List mode” and add this line inside the condition.
SKU: <?php echo $this->htmlEscape($_product->getSKU()) ?>
They basically are the same line but they must exist in the list and grid condition. Well, depending on your desire.
Now, for the product view page.(view.phtml)
Look for this container, ‘ div class=”product-shop” ‘ and add the same line anywhere inside the div container.
SKU: <?php echo $this->htmlEscape($_product->getSKU()) ?>
Please comment if you have questions.
magento: upgrading magento using magento downloader
// June 25th, 2009 // No Comments » // ecommerce, php
for my record keeping. don’t mind this.
- extension key to install/upgrade: “magento-core/Mage_All_Latest”
ROR: Installing Ruby on Rails in Ubuntu Hardy Heron 8.04
// June 22nd, 2009 // No Comments » // ruby
I just feel like writing a tutorial about installing Ruby on Rails in Ubuntu, specifically in Hardy Heron 8.04. I hope this simple tutorial can help you get to where you want to be in Ruby on Rails.
1. First is you gotta upgrade your apt and make sure that your Heron is up to date.
$>sudo apt-get update $>sudo apt-get dist-upgrade
2. Your Heron should have all the requirements needed to be able to compile or simply all the essential softwares for your system.
$>sudo apt-get install build-essential
3. Install in your heron all the ruby, mysql and other stuffs you might need. You might also want to install other plugins, so, just append them on this line.
$>sudo apt-get install ruby ri rdoc mysql-server libmysql-ruby ruby1.8-dev irb1.8 libdbd-mysql-perl libdbi-perl libmysql-ruby1.8 libmysqlclient15off libnet-daemon-perl libplrpc-perl libreadline-ruby1.8 libruby1.8 mysql-client-5.0 mysql-common mysql-server-5.0 rdoc1.8 ri1.8 ruby1.8 irb libopenssl-ruby libopenssl-ruby1.8 psmisc
4.Download and install the latest rubygem. You will need in to install rails. In the example below, i downloaded rubygems-1.3.4.zip.
$>wget http://rubyforge.org/frs/?group_id=126 $>unzip rubygems-1.3.4.zip $>cd rubygems-1.3.4
5. Install the gem.
$>ruby setup.rb
6. Here’s order! Install the Rails! Now that you have rubygem installed, use gem to install rails.
$>sudo gem install rails
7. You’re done.
More ruby post coming! HTH!
code igniter: securing your form using token strings
// June 18th, 2009 // 2 Comments » // General
There are many ways to post information to your site without using your forms. There is curl, or even a home-made HTML code hosted in your local machine.
This tutorial is just a short and quick implementation of using dynamically created token strings to secure your form submission in Code Igniter.
1. Let’s get the ball rolling. Let’s start from the controller. Let’s use a sample controller titled “Home”. Load the session library in the function home() or inside any function in this class.
class Home extends Controller {
function Home()
{
parent::Controller();
$this->load->library('session');
}
function index()
{
$data['token'] = md5(uniqid(mt_rand(), true));
$this->session->set_userdata('token', $data['token']);
$this->load->view('index', $data);
}
}2. Generate a 32-bit random character. This will serve as your form token and save it to session for future use.
$data['token'] = md5(uniqid(mt_rand(), true));
$this->session->set_userdata('token', $data['token']);3. Create a form in the VIEWS and add a hidden element called “token” with the value that you generated in the controller. How can we assign the value to the hidden element? This hidden element should belong in the same form that you are going to secure.
<input name="token" type="hidden" value=><?php echo $token?>" />
4. In the action controller that you posted your data to, check if session token is the same as the posted token hidden variable. From there, you can now put your block of code.
function login()
{
if($this->session->userdata('token') == $_POST['name']){
//below is where you put your codes
}
}













