The Information Technology Blog

The Information Technology Blog brought to you by 4 Ace Technologies

Tuesday, September 27, 2011

Web, Mobile, and Offshore Development Services Blog

Dear Visitors, we would like to inform you that we plan to post future articles at our new blog from now. Please book mark to stay updated.

Thursday, March 31, 2011

Automated PHP Deployment - Capistrano

Extracted from: http://www.jonmaddox.com/2006/08/16/automated-php-deployment-with-capistrano/

Automated PHP Deployment With Capistrano
Sure, I’d like to spend my days and nights writing Ruby and cap deploy ing it to success, but I have to face the facts.

I Still Have PHP Apps To Maintain.

I have no one to blame but myself. I wrote them. And I still work where they were written. There’s no escape. After using Capistrano more than one time, you’ll be completely spoiled.

But Capistrano is only for crazy Rails apps right? Nope. Its simply a platform for automation. It just so happens that deployment usually requires quite a bit of steps. Hmmm…lots of steps…automation… a match made in heaven. So sure, Capistrano was thought up with Rails in mind, but created openly so you’re able to use it any way you’d like.

Capistrano’s power is in its remoting features. You tell it what to do on that other server, and it does it. Beauty. So, if your PHP deployment process requires an svn export combined with a few other repetitive steps you have to do every time, Capistrano is here to help you too.

Without going into all the details of Capistrano (following the link will give you a nice overview), it uses a deploy script (recipe) to understand your deployment environment and required tasks.

Ok ok ok, Lets Get On With It

So, we have a PHP app that we need to deploy to server X. It needs to be sucked out of its repository, its version symlinked to a doc_root, and then a shared directory symlinked into the site. This is a pretty common deployment scenario, so lets go with this.

First, we need a Capistrano recipe. Currently, it can only be auto generated for a Rails app, so psst, here it is. Download this and create a directory at the root of your PHP app and name it config.

mkdir config
cd config
wget http://maddox.s3.amazonaws.com/sites/deploy.rb
Capistrano wants its recipe to be in the config directory, so do as it likes. Now lets open it up and make it work with us. Once again, a complete description of the Capistrano recipe file is bit out of scope for this little post, so please read up.

We’ll edit all the normal items

set :application, "php_app"
set :repository, "http://code.phpdevelopers.com/#{application}/trunk"
We only deploy to one server, so edit…

role :web, "phpsite.com"
Now you need to add the directory you want to deploy to. Add…

set :deploy_to, "/home/www/#{application}"
Capistrano defaults to checkout when pulling from subversion. I prefer an export, if you do too, then add…

set :checkout, "export"
Ok, so if you’re familiar with Capistrano, you know exactly what we did. If you’re not, the most important thing to know is that Capistrano is going to suck your code from the repository defined, do everything it’s told to do in /home/www/php_app on your deployment server, phpsite.com.

Set’r Up

Believe it or not, we’re half way done. Next, lets let Capistrano get the directory we just defined ready for its magic.

cap setup
If you look on your deployment server, you should see 2 directories that were just created.

drwxrwxr-x 2 user group 4096 Aug 16 01:48 releases
drwxr-sr-x 4 user group 4096 Aug 16 01:48 shared
WOW! We’re already saving time! releases is where your app will be sucked down to. Capistrano exports your PHP app into a directory named after the current date/time. Each version you deploy will be kept in this directory. Shared is where you can keep files like uploaded assets or images that aren’t kept in your repository, but need to be around every time you export from subversion. If your users upload files all day long, and you redeploy your PHP app from subversion, all your uploaded files will be gone. So we keep those in here.

Here’s the deployment rub. Every time you deploy, you have to go symlink these directories from your /shared directory, into your current version of your PHP app. And a small bit of math can calculate the complexity when you start adding 2,3, or 6 asset folders. Yuck.

That’s where Capistrano helps ya out.

Capistrano, Take Me Away

Ok, so our deploy directory is set up and ready to get our files. Now we need to tell Capistrano exactly what to do when we deploy. Get it? Recipe…

Define a new task called deploy

desc "This will deploy the app"
task :deploy do

end
Inside the block we’ll just tell Capistrano exactly what it needs to do in order to deploy our app.

desc "This will deploy the app"
task :deploy do
run "svn --quiet #{checkout} #{repository} #{release_path}"
run "ln -nfs #{release_path} #{current_path}"
run "ln -nfs #{shared_path}/photos #{current_path}/photos"
end
Ok, lets walk through exactly what this does. First, Capistrano uses subversion to suck your app out of the repository and into the releases directory. That releases_path is just a nice convenient variable for /home/www/php_site/releases/200608162012. Next, it will create a current symlink to that version of your app in the releases directory. Then we told it to symlink the directory photos from shared into the current version of the application.

And since you’re hosting a PHP app with Apache (a 99% guess), there’s no need to restart any servers. You’re done. You’re new version will be deployed safely and linked. The IMPORTANT thing to note, is that your new doc_root for your site will be /home/www/php_app/current.

Deploy!

Now, all ya gotta do to redeploy your site is…

cap deploy
Capistrano will go on to do everything you told it to do, on your deployment server. When its done, your directory should look like this…

lrwxrwxrwx 1 user group 42 2006-08-16 01:32 current -> /home/www/php_site_/releases/200608162012
drwxrwxr-x 4 user group 4096 2006-08-16 01:31 releases
drwxr-xr-x 4 user group 4096 2006-06-24 02:08 shared
And there you have it. Automated PHP deployment, with one simple command. Peering inside the current directory, you’ll see where the photos directory has been symlinked into it.

The moral is, Capistrano isn’t just for Rails deployment. Its powerful remote execution can be exploited to do anything you want. While our Rails apps get a lot for free when it comes to recipes, creating your own isn’t complicated. Especially if its replacing repetitive tasks you’ve done over and over and over and over and over again.

Wednesday, November 18, 2009

9 Most Common IE Bugs and How to Fix Them

Author: Siddharth
Original Article is at: http://net.tutsplus.com/tutorials/html-css-techniques/9-most-common-ie-bugs-and-how-to-fix-them/

1. Centering a Layout

Centering an element is probably something every web developer has to do while creating a layout. The easiest and most versatile way to center an element is to just add margin: auto; to the relevant element. The above method will take care of centering the element irrespective of the resolution and/or browser width. IE 6 in quirks mode however decides to handle this in the most unfortunate way possible: by not handling it at all.

Consider the Following Code:

  1. #container{
  2. border: solid 1px #000;
  3. background: #777;
  4. width: 400px;
  5. height: 160px;
  6. margin: 30px 0 0 30px;
  7. }
  8. #element{
  9. background: #95CFEF;
  10. border: solid 1px #36F;
  11. width: 300px;
  12. height: 100px;
  13. margin: 30px auto;
  14. }

The output you'd expect:

Tutorial Image

But what IE actually gives you:

Tutorial Image

This is mainly due to IE6 in quirks mode and below not recognizing the auto value we set to the margin property. Fortunately, this is easily fixed.

The Fix

The easiest and most reliable way to center content for IE6 and below is to apply text-align: center to the parent element and then apply text-align: left to the element to be centered to make sure the text within it is aligned properly.

  1. #container{
  2. border: solid 1px #000;
  3. background: #777;
  4. width: 400px;
  5. height: 160px;
  6. margin: 30px 0 0 30px;
  7. text-align: center;
  8. }
  9. #element{
  10. background: #95CFEF;
  11. border: solid 1px #36F;
  12. width: 300px;
  13. height: 100px;
  14. margin: 30px 0;
  15. text-align: left;
  16. }

2. Staircase Effect

Almost every web developer uses lists to create his navigation. Usually, you create the container element, create some links inside and then float the anchors in the direction he wants and calls it a day. Usually. IE though decides to make it a lot more complicated. Peruse through the following code:

  1. <ul>
  2. <li><a href="#">a>li>
  3. <li><a href="#">a>li>
  4. <li><a href="#">a>li>
  5. ul>
  1. ul {
  2. list-style: none;
  3. }
  4. ul li a {
  5. display: block;
  6. width: 130px;
  7. height: 30px;
  8. text-align: center;
  9. color: #fff;
  10. float: left;
  11. background: #95CFEF;
  12. border: solid 1px #36F;
  13. margin: 30px 5px;
  14. }

A standard compliant browser renders it like so:

Tutorial Image

And the IE screen shot:

Tutorial Image

Not a particularly pleasing navigation if you ask me. Fortunately, there are 2 fixes you can try.

Fix #1

The easiest way to combat this is to float the li elements themselves instead of the anchor elements. Just add this and you should be done.

  1. ul li {
  2. float: left;
  3. }

Fix #2

The second way is to apply display: inline to the enclosing li element. In addition to fixing this bug, it also fixes the double margin bug mentioned below. Purists may not like placing block elements inside inline elements though.

  1. ul li {
  2. display: inline
  3. }

3. Double Margin on Floated Elements

This bug is probably among the first ones a web developer starting out will run into and is specific to Internet Explorer 6 and below. Triggering it is as simple as floating an element and then applying a margin in the direction it has been floated. And voila! The margin will be doubled in the rendered output. Not really something you'd look forward to while creating a pixel perfect layout.

Consider this code:

  1. #element{
  2. background: #95CFEF;
  3. width: 300px;
  4. height: 100px;
  5. float: left;
  6. margin: 30px 0 0 30px;
  7. border: solid 1px #36F;
  8. }

On standards compliant browsers, this is how it looks:

Tutorial Image

But here is how IE 6 decides to render it:

Tutorial Image

The Fix

The fix for this specific bug is to apply display: inline to the floated element and everything works as it is supposed to. Our previous code now changes to:

  1. #element{
  2. background: #95CFEF;
  3. width: 300px;
  4. height: 100px;
  5. float: left;
  6. margin: 30px 0 0 30px;
  7. border: solid 1px #36F;
  8. display: inline;
  9. }

4. Inability to Have Elements with Small Heights

As part of creating a layout, you may need to create elements with very small heights as custom borders for elements. Usually, you'll just have to add height: XXpx to the style's declarations and you should be done. Or so you thought. Check the page in IE and you'll probably do a double take.

As an example, look at the following code:

  1. #element{
  2. background: #95CFEF;
  3. border: solid 1px #36F;
  4. width: 300px;
  5. height: 2px;
  6. margin: 30px 0;
  7. }

And the output is just as expected: A 2 px element with a 1 px border.

Tutorial Image

And in IE:

Tutorial Image

Fix #1

The cause of this bug is pretty simple: IE simply refuses to size an element smaller than the set font size. Simply setting the font size to 0 lets you have an element as small and short as you like.

  1. #element{
  2. background: #95CFEF;
  3. border: solid 1px #36F;
  4. width: 300px;
  5. height: 2px;
  6. margin: 30px 0;
  7. font-size: 0;
  8. }

Fix #2

The next best way to deal with this bug is to apply overflow: hidden to the element so it collapses to the intended height.

  1. #element{
  2. background: #95CFEF;
  3. border: solid 1px #36F;
  4. width: 300px;
  5. height: 2px;
  6. margin: 30px 0;
  7. overflow: hidden
  8. }

5. Auto Overflow and Relatively Positioned Items

This bug rears its ugly head when in a layout you set the parent container's overflow property to auto and place a relatively positioned item inside it. The relatively positioned item violates its parent element's boundaries and overflows outside. Let me demonstrate. Look the following code:

  1. <div id="element"><div id="anotherelement">div>div>
  1. #element{
  2. background: #95CFEF;
  3. border: solid 1px #36F;
  4. width: 300px;
  5. height: 150px;
  6. margin: 30px 0;
  7. overflow: auto;
  8. }
  9. #anotherelement{
  10. background: #555;
  11. width: 150px;
  12. height: 175px;
  13. position: relative;
  14. margin: 30px;
  15. }

And the expected output:

Tutorial Image

And IE's output:

Tutorial Image

The Fix

The easiest way to fix this annoying bug is to just position the parent element relatively too.

  1. #element{
  2. background: #95CFEF;
  3. border: solid 1px #36F;
  4. width: 300px;
  5. height: 150px;
  6. margin: 30px 0;
  7. overflow: auto;
  8. position: relative;
  9. }

6. Fixing the Broken Box Model

Internet Explorer's misinterpretation of the box model is perhaps its unforgivable mistake. IE 6 in semi-standards compliant mode sidesteps this but this issue can still be triggered by quirks mode.

Two div elements. One with the fix applied and one without. The difference in the width and height is the sum of the paddings applied on each side.

Tutorial Image

The Fix

I am sure the quandary with the box model needs neither explanation nor demonstration so I'll just give you the fix.

The trick is to set the width normally for all standards compliant browsers, target IE5/6 alone and then feed it the corrected width. This is how you'd usually go on about:

  1. #element{
  2. width: 400px;
  3. height: 150px;
  4. padding: 50px;
  5. }

This now changes to:

  1. #element {
  2. width: 400px;
  3. height: 150px;
  4. \height: 250px;
  5. \width: 500px
  6. }

Essentially, you add the padding to the original width and feed it to IE 6. The fix targets IE 6 in quirks mode alone so you need not worry about IE 6 in normal mode messing things up.

7. Setting a Minimum Width and Height

Setting an minimum height to an element is absolutely imperative when trying to convert a beautiful design into a pixel perfect design. Unfortunately, IE completely ignores the min-height property instead taking the height declared as the minimum height.

Fix #1

The fix is a hack created by Dustin Diaz. It utilizes the !important declaration to make it work. The snippet looks like so:

  1. #element {
  2. min-height:150px;
  3. height:auto !important;
  4. height:150px;
  5. }

Fix #2

The second way is to take advantage of the fact that IE can't parse child selectors.

  1. #element {
  2. min-height: 150px;
  3. height: 150px;
  4. }
  5. html>body #element {
  6. height: auto;
  7. }

8. Floated Layout Misbehaving

One of the important concepts of building table-less layouts using CSS is floating elements. In most cases, IE6 handles this with aplomb but in certain cases it fumbles. When faced with unbreakable content or elements whose width exceeds its parent's width, it causes havoc with the layouts. Let me show you.

Consider this piece of code:

  1. <div id="container">
  2. <div id="element">http://net.tutsplus.com/div>
  3. <div id="anotherelement">div>
  4. div>
  1. #element, #anotherelement{
  2. background: #95CFEF;
  3. border: solid 1px #36F;
  4. width: 100px;
  5. height: 150px;
  6. margin: 30px;
  7. padding: 10px;
  8. float: left;
  9. }
  10. #container{
  11. background: #C2DFEF;
  12. border: solid 1px #36F;
  13. width: 365px;
  14. margin: 30px;
  15. padding: 5px;
  16. overflow: auto;
  17. }

The expected output as viewed on a standards compliant browser:

Tutorial Image

In IE:

Tutorial Image

As you can see, the first div expands itself to fit the content which ultimately breaks the layout.

The Fix

There is no elegant fix for this bug. The only way to save the layout is to apply overflow: hidden to the element but at the cost of clipping the unbreakable content. The layout will be saved but the extra content won't.

  1. #element{
  2. background: #C2DFEF;
  3. border: solid 1px #36F;
  4. width: 365px;
  5. margin: 30px;
  6. padding: 5px;
  7. overflow: hidden;
  8. }

9. Space Between List Items

IE 6 adds vertical spacing even none is specified in specific cases. Let's look at the code first.

  1. <ul>
  2. <li><a href="#">Link 1a>li>
  3. <li><a href="#">Link 2a>li>
  4. <li><a href="#">Link 3a>li>
  5. ul>
  1. ul {
  2. margin:0;
  3. padding:0;
  4. list-style:none;
  5. }
  6. li a {
  7. background: #95CFEF;
  8. display: block;
  9. }

What it should look like:

Tutorial Image

What IE gives us:

Tutorial Image

Fortunately, there are a plethora of fixes you could try.

Fix #1

The easiest way out is to just define a width for the anchor tags and voila! everything renders as it should. Declaring a width triggers the element's IE specific hasLayout property. You could instead define a height if you want to.

  1. li a {
  2. background: #95CFEF;
  3. display: block;
  4. width: 200px;
  5. }

Fix #2

The next method is to just float the anchor left and then clearing it.

  1. li a {
  2. background: #95CFEF;
  3. float: left;
  4. clear: left;
  5. }

Fix #3

The third method is to add display: inline to the enclosing li element. This also fixes the double margin bug as noted above.

  1. li {
  2. display: inline;
  3. }

Conclusion

And there you have it: the nine most common IE rendering bugs, and how to squash them. Hopefully this has saved you some blood, sweat and tears while debugging your next creation. I'll be watching the comments section frequently; so chime in here if you are having difficulties implementing the fixes noted here.

Monday, November 9, 2009

Installing PHP on IIS 6 (Windows 2003)

We had a customer who was paying good money for a Dedicated Server of Windows 2003, and had his site hosted. We had to develop a newer version of the site on PHP/MySQL, and then consolidate both sites, the old one and new one. When we came to the stage of Consolidation, we needed a separate PHP enabled server, and that would have costed the customer, so on mutual understanding with customer we had to finally take this challenge of enabling PHP with Windows 2003 server IIS 6.0

I spent lot of time on browsing over the internet and knowing how to install PHP on IIS, and found good solutions, but none were actually working for me. So I hope my solution will be a very brief one, and would help somebody save lot of time.

What I prefer, and did, was as below:
  1. Download Web Developer Suite
  2. Install Web Developer Suite
  3. Open the Web Developer Suite after installation, and click on Disable Startup for Apache. You should see the MySQL and IIS W3 as Running
  4. Then you should be able to run the php files on your IIS wwwroot folder. However, if any error such as "Service Unavailable" or Page not able to be displayed occurs, then check the Application Pool if it is running or stopped. Also make sure you add .php extension from Home Directory, and select the file "php5isapi.dll". Also go to "Web services" and add a new web service as "PHP" and select the file php5isapi.dll from your php directory, and save.
  5. You have PHP installed in few steps, Restart IIS, and you should have it working.
Hope it helps...

Tuesday, November 3, 2009

phplist - Opensource Newsletter Management Script

Newsletter Management

phplist Features

  • phplist is a one-way email announcement delivery system. It is great for newsletters, publicity lists, notifications, and many other uses. (It is different from group mailing list systems like mailman.)
  • The Web Interface lets you write and send messages, and manage phplist over the internet.
  • phplist keeps sending messages from your web server, even after you shut down your computer.
  • 100 000 + subscribers. phplist is designed to manage mailing lists with hundreds of thousands of subscribers. phplist is excellent with smaller lists too!
  • No duplicate messages. No 'forgotten' messages. phplist manages message delivery with a message queue, ensuring that every subscriber gets the email message, and that no subscribers receive two copies, even if they're subscribed to more than one list!
  • Open/View Tracking tells you how many users opened your email message. This provides a minimum statistic, as many email clients with privacy or security policies block images (gmail, thunderbird, and others).
  • Click Tracking tracks links and URLs. Statistics can be viewed by message, URL or subscriber.
  • Multiple Subscribe Pages allow you to choose many different combinations of templates, languages, user attributes and lists.
  • Templates are completely customizable, and make site integration a breeze.
  • Multiple Templates on different subscribe pages can integrate phplist with several different web sites.
  • Subscriber Attributes like 'name', 'country', and other personal information, are completely customizable. You can specify what information you need to get from users when they subscribe.
  • User Specific Content. You can use Subscriber Attributes in message content to make each and every email message personalized with the subscribers name, country, or any other attribute.
  • HTML email messages. Subscribers can be given the choice between text or html email messages. You decide whether subscribers can choose, what the default choice is, and what format a message is sent in: text only, html only, or both!
  • The HTML Editor allows you to edit html messages from phplist using FCKeditor. TinyMCE is also available.
  • Internationalization. phplist is available in English, French, German, Spanish, Portuguese, Traditional Chinese, Dutch, Vietname and Japanese and translation work is in progress for other languages.
  • Easy Install via Fantastico, FTP upload, or SSH.
  • Multiple List Administrators. The super-admin can assign lists to List Managers, who can manage their users and lists. The super-admin user can 'prepare' messages that can be sent by list managers to their lists.
  • Subscriber Preferences. Every email message contains personalized URLs for subscribers to update their preferences or unsubscribe. Subscribers can update their own information and keep your database up to date. Unlike most other mailing list managers, in phplist subscribers can change their email address.
  • The User Management tools are excellent to manage and maintain large databases of subscribers.
  • Bounce Processing keeps your database clean of unused and non-existent email addresses.
  • Advanced Bounce handling let's you teach phplist to distinguish between permanent and temporary message-delivery errors. You can define automated actions on receipt of bounce messages according to matches with your regular expressions.
  • CSV Import and Export. Use CSV and tab delimited files to import your existing list of users or to export the users on the phplist system for use in your in-house database. phplist's database has a 'foreign key' to help keep multiple copies of databases synchronized without duplicating users.
  • Attachments can be uploaded and included in messages for download.
  • Send a Web page. Tell phplist the URL of a web page you want to send to your users, and phplist will fetch it and send it. You can even put subscriber-specific parameters in the URL.
  • RSS feeds can be automatically sent to a mailing list weekly, daily, or monthly.
  • PDF messages can be automatically created and sent as attachments to ensure that your message is seen the way it was designed by all your subscribers, regardless of their email message reader.
  • Batch Processing is useful in shared hosting environments. Set the maximum number of sent messages in a given time period.
  • Throttling can limit the load on your server so it doesn't overload.
  • Domain Throttling limits the number of emails to specific domains to keep on the friendly side of their system administrators.
  • Scheduled Sending let's you tell phplist when the message is to be sent.
  • Repetition. A message can be repeated automatically to send updated dynamic content and attachments.
  • Text from HTML. Text email messages are managed fluently in phplist. phplist will automatically create a text version of an html message. Optionally the message composer can create it manually.
  • PGP signing and encrypting (soon).
    Send your message digitally signed or encrypted, or both.
  • Email to Fax (soon).
    Configure the details of your favourite email 2 fax gateway and phplist will send the HTML version of the message as a PDF attachment to your fax gateway. The fax will include the images in the HTML.
  • Integration with other tools. Several systems exist on the internet that integrate phplist with your favourite CMS or blogging tool. Check out the Documentation for a list.

Download phplist

Version

phplist version 2.10.10 is the latest stable release. It was released on May 5th, 2009.

License

phplist is licensed under the GPL v2. Please make sure that you understand this license before downloading.

Thursday, October 29, 2009

Convert any website layout or template into a Drupal theme - easily!



Theming for Drupal is not actually as hard as you may think. Certainly there are more advanced areas of theming possible with Drupal, which may or may not be necessary depending on the needs of your site or whether there are subtle defaults which you wish to change (and which you can learn about if and when they become necessary for your site). Creating the "overall theme" for your site though is very simple.

A Drupal theme is nothing more than a standard website layout, with a few bits of PHP code added in certain places, which you can simply copy/paste into place in order to call up Drupal's "dynamic" content and features in those spots.

If you learn better visually, a video is available which covers much of the same information that will be illustrated here: Static Theme Conversion.

Contributed/downloaded themes are more complex than "your" theme needs to be

You may have looked at various pre-made themes that either come with Drupal core or are available for download, and sighed with frustration upon seeing their code. To some, the code looks very confusing.

Read Full Article Here

Flash with Drupal Modules and References

Having trouble integrating Flash with Drupal? The following links might help:

http://drupal.org/project/Services
http://drupal.org/project/amfphp
http://www.amfphp.org/