It became a total mess when I selected the entire root directory of my project and accidentally clicked Source > Format in Zend Eclipse PDT. All the files were instantly re-formatted and saved in a manner I wasn’t comfortable with and there didn’t seem any easy way to undo these changes that had been applied across nearly a hundred files in different folders.

They definitely should have prompted up a dialog box asking the developer’s confirmation. They probably will in future but for now, I need to do something to prevent this from happening again.

Disable Source > Format

First we will disable / hide this menu item or we will probably accidentally click on it again. Without any prompt nor confirmation, PDT simply goes on formatting the selected items silently. When you are in a single file that would be fine cause’ you just use Ctrl + Z to undo the change, however if you are selecting an entire directory or the entire project, this command would go ahead and format ALL the files under it and automatically SAVE THEM all onto the hard drive. The next thing you find yourself doing is opening and reverting each and every one of the files one by one.

Enough talk. To disable this menu item:

Window > Customize Perspective > Menu Visibility > “Source” > “Format” (disable this) > OK

Disable Ctrl + Shift + F

We should also disable this short cut keys combination which can also be inadvertently treaded on. Go to:

Window > Preferences > General > Keys > Select all “Format” entries and click “Unbind Command”

Done. Now the only way to format a page or a selected portion or a resource / item in PHP Explorer is to right click on the target and select Source > Format.

{ Comments on this entry are closed }

When you copy and paste code into Zend Eclipse PDT they will probably be automatically indented and not in the original manner. It may be annoying sometimes. To disable this behavior:

Window > Preferences > PHP > Editor > Typing > When pasting “Adjust indentation”

Just disable the option.

{ Comments on this entry are closed }

The common practice of rounding, namely the round() function in PHP, is to round to the nearest decimal point, that is, 1.0, 2.0, 3.0, etc. or, 10, 20, 30, etc. For example,

echo round(4.25, 0);		// 4
echo round(3.1415926, 2);	// 3.14
echo round(299792, -3);		// 300000

When I’m trying to aggregate all the customer ratings for a specific provider in one of my web hosting reviews community, I want to round the average rating to the nearest 0.5 (half the decimal) so that a half star would be correctly displayed.

This is more of a mathematical problem than a PHP one. After some thinking and testing, I came up with a slightly more sophisticated solution than but the round() function:

echo round(1.7 * 2) / 2;		// 1.5
echo round(2.74 * 2) / 2;		// 2.5
echo round(2.75 * 2) / 2;		// 3.0
echo round(3.1 * 2) / 2;		// 3.0

Just as easy as that.

{ Comments on this entry are closed }

<Files *.php>
    Order Deny,Allow
    Deny from all
    #Allow from 127.0.0.1
</Files>

<Files index.php>
    Order Allow,Deny
    Allow from all
</Files>

The 2 <Files> directives must be in the exact same order as above.

{ Comments on this entry are closed }

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\/(\?.*)?$ $1$2 [R=301,L]

Yeah, that’s it. So:

  1. /path/dir/ is redirected to /path/dir
  2. /path/dir/?a=1&b=2 is redirected to /path/dir?a=1&b=2

{ Comments on this entry are closed }

At any time, press:

Ctrl + Shift + L

For a list of available shortcut keys defined in your Zend Eclipse PDT.

Go:

Window > Preferences > General > Keys

To edit the shortcut keys. Or simply press Ctrl + Shift + L twice.

For Zend Eclipse PDT to instantly show a tool tip hint of what the parameters of a function / method are so you don’t have to look up the original definition, just place the cursor in the parameters parenthesis and press one of them:

Alt + ?

Alt + Shift + /

Ctrl + Shift + Space

Which is defined under the title “Context Information” when you press Ctrl + Shift + L.

If a function or method name is elusive to you, type the beginning part of it and press:

Alt + /

Ctrl + Alt + /

And PDT would try and auto-complete it for you. It is defined under the title “Word Completion” when you press Ctrl + Shift + L.

{ Comments on this entry are closed }

The default array() indentation of Eclipse for PHP Developers when you create an array seems to be 2 tabs which I think are too much. To reduce it to just 1 tab:

Window => Preferences => PHP => Editor => Typing => formatter preference page => Edit… => Indentation => Default indentation of array initializers

Or

Window => Preferences => PHP => Code Style => Formatter => Edit… => Indentation => Default indentation of array initializers

To change the default indentation for wrapped lines:

Window => Preferences => PHP => Code Style => Formatter => Edit… => Line Wrapping => Default indentation for wrapped lines

{ Comments on this entry are closed }

Many’s the time after you have uploaded some PHP script to your server and point the web browser to the address it gives 500 Internet Server Error. If you have suPHP installed this is very likely because the uploaded PHP script (files and directories) have wrong permissions set to them.

With regards to Linux permissions, suPHP requires all directories to be at least 755 and all files to be at least 644 for any PHP script to run. If the directory or the PHP script has the wrong permissions set to them, suPHP would give out 500 Internet Server Error until you have corrected them. In addition, the directory and the PHP script must be owned by the current user and group or they wouldn’t run either.

To fix this is very easy, just perform the following command after you have uploaded the PHP script:

chown -R youruser /home/youruser/public_html/*
chgrp -R youruser /home/youruser/public_html/*
find /home/youruser/public_html/* -type f -exec chmod 644 {} \;
find /home/youruser/public_html/* -type d -exec chmod 755 {} \;

The 1st line sets everything (files and directories) under /home/youruser/public_html/ to be owned by user youruser.

The 2nd line sets everything (files and directories) under /home/youruser/public_html/ to be owned by group youruser.

The 3rd line sets all files under /home/youruser/public_html/ to be 644 in permissions.

The 4th line sets all directories under /home/youruser/public_html/ to be 755 in permissions.

{ Comments on this entry are closed }

How Does Your Brand Measure Up?

by Yang Yang on September 17, 2012

Did you read the recent Yahoo finance news article about 2013’s Top 10 Best Brands and Worst Brands in America? A company called “CoreBrand” conducts an annual survey to determine the most and least respected corporate brands based on the company’s “Familiarity and Favorability data.” This goes beyond the most well known, the most heavily advertised or the highest profit making companies. This measures people’s perceptions of a company’s trustworthiness and respect among consumers. Most of these major brands have an international presence, but the survey results are based on American sentiments.

According to the study results released August 20, these are the 2013 Top 10 Most Respected Brands:

  1. PepsiCo and Coca-Cola (tied)
  2. Hershey’s
  3. Harley-Davidson
  4. Bayer
  5. Johnson & Johnson
  6. Kellogg’s
  7. Campbell’s Soup Company
  8. Colgate-Palmolive
  9. Estee Lauder

And, according to the same study, these are the Top 10 Least Respected Brands in 2013:

  1. Delta
  2. Philip Morris
  3. H&R Block
  4. Denny’s
  5. Big Lots
  6. Best Buy
  7. J.C. Penney
  8. Capital One
  9. Rite Aid
  10. Foot Locker

Some of these results may surprise you, as your own personal experience with an individual company may have been excellent and you consider yourself a loyal customer. In some cases, you might have issues with their competition or there is no convenient alternative, so you must use their products or services regardless of whether you like the company or not.

The point is, if you are a business in today’s world and your customers were to be asked how satisfied they are with your products or services, how would your brand measure up? Most people want to believe that every customer is happy and consider complaints to be a reflection on the disgruntled customer themselves, not something that the company has actually done wrong or needs improvement. A smart manager realizes that a complaint is an opportunity to not only make things right for the customer, but a warning flag that something in your operations is not delivering up to expectations and needs to be fixed.

In my post about Amazon’s affiliate program, I mentioned how easy it is to earn money as an affiliate with Amazon because:

  1. Amazon itself is a globally recognized brand with a good reputation
  2. Amazon carries popular brands already familiar to people and rarely has products returned
  3. Although Amazon started out selling books, they have evolved and grown into a company that sells just about anything

Not only does Amazon do an excellent job of meeting each customer’s needs, they are constantly asking for reviews and have top notch customer service. Even if the product you sold didn’t meet your customer’s expectation, if you handle complaints well, in most cases you can keep that customer’s respect and rebuild their trust.

Safeguard all that hard work building your business and creating a brand. If your customer service is lacking, people no longer hesitate to take their complaints to the internet and warn their friends on sites like Facebook, YELP, TripAdvisor.com and Angie’s List. Bad reviews do scare away new business and cost you customers. Brand.com reviews the best ways to optimize search listings and protect brands for small business as well as large corporations.

The U.S. government’s Small Business Administration also has some excellent advice about managing a company’s online reputation and other business issues. Even companies that do not have a web site must be concerned with their online reputation and monitor the most popular sites regularly to protect their brand from negative reviews in directories and social media.

{ Comments on this entry are closed }

vBulletin: Paid Subscription Not Showing Up

by Yang Yang on September 14, 2012

I was trying to start a premium membership for Kavoir Backyard and after I have created a Paid Subscription profile, nothing shows up in user control panel nor at /backyard/payments.php.

As you can see from the thread I started in the official vBulletin forum for help, I have done everything necessary to create the subscription profile and it’s definitely active. But somehow, it simply doesn’t show up at all.

Subscription Manager

Paid Subscription profile

I see no “Paid Subscription” link in user control panel left sidebar nor any subscription order forms. The payments.php page says “Kavoir Backyard Webmaster Forum does not have any paid subscriptions available to which you can subscribe.”.

What’s wrong? What did I leave out? The solution!

Turned out it’s because I didn’t specify the payment details for Paid Subscriptions. You should use Payment API Manager to specify the payment API: Paid Subscriptions –> Payment API Manager.

paid subscription payment API

By default there’s NO active payment API and you have to explicitly select one such as PayPal and enter the details. Once it’s all configured and active, Paid Subscriptions link and premium membership order forms are correctly displayed to the registered users in the control panel.

Disappeared again after upgrade?

After upgrade, the paid subscription is disappearing again. To make it show up, just de-activate the payment method in Payment API Manager and re-activate it again by first setting Active to No and then back to Yes again (click Update twice).

Weird how things work in the world, huh.

{ Comments on this entry are closed }