Archive for May, 2007

May 22nd 2007

PHP Timing Script With Average Time

I needed a script that would time some php I wrote to see if using an output buffer would speed it up. I used the php microtime() function to accomplish the timing feature, and combined that with sessions to capture an average execution time. This is the result:
<?php
session_start();
if (isset($_GET['clear'])) session_unset();
else {
$ac = $_SESSION['avg_count']++;
}
$ts = microtime(true);
ob_start(); // this starts to buffer the output, comment this line to test speed with out it.
?>
[[PHP code to test here]]
<?php
ob_end_flush(); // this function flushes the buffer. Comment this line to test without it.
$ts = round(microtime(true)-$ts,3);
$_SESSION['exe_avg'][] = $ts;
$ea = @round(array_sum($_SESSION['exe_avg'])/$_SESSION['avg_count'],4);
print “<p>Page executed in <strong>{$ts}s</strong><br>”;
print “Average execution time: <strong>{$ea}s</strong> ({$_SESSION['avg_count']} attempts)<br>”;
print “<a href=’?clear=1′>Clear Session</a></p>”
?>

As a general rule, using the output buffer can greatly increase the execution speed of php programs.

No Comments yet »

May 18th 2007

Adding a user friendly FREE download to LiteCommerce store

LiteCommerce is a great online storefront to work with. However, while the egoods module offers a great way to sell downloadable files, it really doesn’t offer a good, user friendly way to create a product with a free downloadable file. This situation recently happened where a customer wanted to offer free PDF articles on their site along with for-pay downloads as well.

The default method to do this requires that the user have an account with the correct membership level. This would allow the download to show up on the product details page. However the Buy Now buttons and Add to Cart buttons still show up. This doesn’t make any sense for a completely free product. If the user clicks one of those buttons, whether they are a member or not, the order still needs to be processed in the regular manner before the file can be downloaded. In other words, they have to enter payment information for a free product. This doesn’t make sense and is not user friendly.

Here is how to do it so that a user gets a download link in the product details with no special membership required. In fact, the eGoods module isn’t even required to do this.

  1. Disable Buy Now buttons via General settings.
  2. Change the code in classes/dialog/product.php from:
    function isAvailableForSale()
    {
    return true;
    }

    To

    function isAvailableForSale()
    {
    if ($this->get("product.price") == 0) {
    return false;
    } else {
    return true;
    }
    }

    This removes the Add to Cart button for items with a 0.00 price.

  3. Create a product with a 0.00 price, that is tax free with no shipping costs. In the product details simply add a link to the product you want to download. If you don’t know how to write a link in HTML then you can find out here: http://www.w3schools.com/tags/tag_a.asp

That’s it. I hope this helps some one else since I spent a few hours wrangling with this one.

No Comments yet »

May 14th 2007

How to Become an SEO Professional

How to Become an SEO Professional

I read this article today and it struck me as being great, down-to-earth advice about search engine professionals. It almost felt like I was reading my own story, aside from the fact that I’ve never had really high rankings on any of the the sites I’ve done SEO on for the hard to get keywords….yet. There are some key thoughts on how someone who is a web designer can suddenly turn into an SEO professional.

  • You suddenly realize that you need visitors on your site, not just pretty colors and a swoosh.
  • You learn about something called ROI, and that it’s apparently really important to people who are selling stuff and paying you for a web site.
  • You’ve designed this awesome site…that has no content to fill it out.

Those are just a few of the things that are covered in the article that have been mirrored in my own personal experience. I’ll bookmark this article and hopefully come back in a few years to see if I’m reading my story in full :)

No Comments yet »

« Prev - Next »