Posted in tutorials, web | July 27th, 2010 | Comments: 0

Although Flash is reaching more and more devices every day and expects to be on 50% of all mobile devices by 2012, it is always a good idea to have alternative content for older devices that can not support Flash, or users that choose to disable it.

Here are a few quick ways for web designers/developers to display alternative content for devices without Flash.

1) Embed Code


	
	
		
	
	Alternative content
	
		
	

2) SWFObject

http://code.google.com/p/swfobject/

You can display the alternative content in the <div> that you are writting the Flash object to. If you wish to do other things (redirects or content changes) you can detect if Flash is installed with the JavaScript below.

     var flashSupported = document.getElementById('myContent');
     // if flash is not supported then go to a HTML page
     if( flashSupported.innerHTML.indexOf('embed') == -1 )
          document.location.href="noFlash.html";

3) Flash Player Detection Kit

The Flash® Player Detection Kit helps developers implement robust player detection for a variety of deployment environments by providing a set of templates and techniques to successfully detect the version of Flash Player installed on a user’s computer, and, if needed, to then install the latest version of Flash Player. The kit also includes a detailed explanation and sample files for implementing the new, player-based Flash Player Express Install experience.

http://www.adobe.com/products/flashplayer/download/detection_kit/

4) User Agent

If you have some programming knowledge you can check the User Agent sent from the browser. If you know the agents that do not have Flash support or you would like to show alternative content this is easily done.

List of User Agents

http://www.user-agents.org/

C#

Request.UserAgent

PHP

$_SERVER['HTTP_USER_AGENT']

JavaScript

http://www.quirksmode.org/js/detect.html

Posted by Beau Durrant

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Ping This!
Posted in new technology, web | February 8th, 2010 | Comments: 0

Facebook has recently undergone a transformation that may not be apparent at first but will speed up the overall use of the popular social media website.

This technology is called HipHop for PHP. Using this has allowed Facebook developers to reduce the CPU usage on their Web servers on average by about fifty percent. How is this done you ask?

HipHop helps the PHP programmers to overcome some shortfalls of scripted languages like PHP, such as less efficient CPU and memory usage. They do this by transforming the PHP code into C++ code with HipHop and then compiling it with g++ (an open source compiler for c++ code that can be found here… http://gcc.gnu.org ).

To help, certain parts of your code can be written in c++ to begin with but the magic of this system is obviously for sites like Facebook that employ PHP experts and need to find an interoperability between languages. This way, the same developers can work on both sets of code without having to be experts in both.

Facebook has also released this system as open source software so that other sites facing similar problems may use their system to speed up their sites as well.

Facebook has reported that they are using HipHop on 90% of all their traffic so it is a great testing ground for such software.  As such, from Facebook come the following statistics:

  • More than 400 million active users
  • 50% of our active users log on to Facebook in any given day
  • More than 35 million users update their status each day
  • More than 60 million status updates posted each day
  • More than 3 billion photos uploaded to the site each month
  • More than 5 billion pieces of content (web links, news stories, blog posts, notes, photo albums, etc.) shared each week
  • More than 3.5 million events created each month
  • More than 3 million active Pages on Facebook
  • More than 1.5 million local businesses have active Pages on Facebook
  • More than 20 million people become fans of Pages each day
  • Pages have created more than 5.3 billion fans

Source: http://www.facebook.com/press/info.php?statistics

This adds up to a site that serves serves nearly 400 billion PHP-based page views every month.

If you would like more information on this project:

Developer Mailing List: http://groups.google.com/group/hiphop-php-dev

Posted by Jeff Johnston

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Ping This!
Posted in new technology, web | January 27th, 2010 | Comments: 0

What is Open Source?

“Open source is a development method for software that harnesses the power of distributed peer review and transparency of process. The promise of open source is better quality, higher reliability, more flexibility, lower cost, and an end to predatory vendor lock-in.”

read more


Why Open Source?

Merchant Services Inc. (our merchant account) does not supply code to interact with their API (application programming interface) and process transactions online, so we wrote our own. To help other customers with merchant accounts through Merchant Services Inc. we have posted our code under the MIT license. This will help others as a starting point and save them money for development.

We frequently use Open Source Projects and like to contribute back when we can.

Source Code (svn)
Download (zip)

Posted by Beau Durrant

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Ping This!
Posted in tutorials, web | January 19th, 2010 | Comments: 1

If you have tried to run Zend Framework on IIS 6 you may have run into a few problems. I will be covering how to get Zend Framework running once you have PHP installed. I am assuming that you have a clear understanding on how to set up Zend Framework and how it works.

1) ISAPI Redirect

You will need to install an ISAPI Redirect to simulate a .htaccess file on IIS.

There are a couple options you can use:
ISAPI_Rewrite ($99)
IIRF (Free)

2) Custom Controller

I always extend the Zend_Controller_Action, then all the controllers in the /application/controller directory will extend my custom controller not the Zend_Controller_Action. This is a good place to put $_GLOBALS in the Zend registry, set up database connections and site configuration options.

To get Zend Framework running with IIS 6 you will need to extend the Zend_Controller_Action, override the _redirect function and modify some server variables.

class Zoom_Controller_Action extends Zend_Controller_Action
{ 

	public function _redirect($string)
	{
		if( !stristr($string, "http://") ) $string = "http://" . $_SERVER['SERVER_NAME'] . $string;
		header("location: $string");
	}	

	public function init()
	{
		$_SERVER['REQUEST_URI'] = $_SERVER['HTTP_X_REWRITE_URL'];
		$_SERVER['QUERY_STRING'] = substr( $_SERVER['REQUEST_URI'] , strrpos( $_SERVER['REQUEST_URI'] , '?') + 1);
		// LOOP THROUGH THE QUERYSTRING TO POPULATE THE $_REQUEST and $_GET arrays
		$queryStringVariables = split('&', $_SERVER['QUERY_STRING']);
		foreach( $queryStringVariables as $variable )
		{
			list($key, $value) = split('=', $variable);
			$value = urldecode($value);
			if( strpos($key, '[') )
			{
				$key = substr( $key, 0, strpos($key, '[') );
				if( !is_array($_REQUEST[$key]) ) $_REQUEST[$key] = array();
				$_REQUEST[$key][] = $value;
			}
			else
			{
				$_REQUEST[$key] = $value;
				$_GET[$key] = $value;
			}
		}
	}

}

3) Controllers

Now all the controllers in the /application/controller directory can extend the Zoom_Controller_Action. You must also call the parent::init() from all controllers extending the Zoom_Controller_Action to be sure to modify the server variables.

class ErrorController extends Zoom_Controller_Action
{ 

	public function init()
	{
		parent::init();
	}

}

Posted by Beau Durrant

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Ping This!
Posted in tutorials, web | January 19th, 2010 | Comments: 0

I have written a simple function to generate a random string in PHP. It was made to generate a string with uppercase, lowercase and numeric values. It can be modified to accept any ASCII characters and can generate a string of any length.

This function may also help understanding passing variables by reference and recursion.

Function

function generateRandomString( $length, &$string )
{
	// RANDOM TO CHOOSE 1. UPPERCASE / 2. LOWERCASE / 3. NUMBER
	$which = mt_rand( 1, 3 );
	switch( $which )
	{
		case 1:
			$min = 65; $max = 90;
			break;
		case 2:
			$min = 97; $max = 122;
			break;
		case 3:
			$min = 48; $max = 57;
			break;
	}

	// GET RANDOM NUMBER FOR CHARACTER
	$rand = mt_rand( $min, $max );

	// CONVERT ASCII TO CHAR AND APPEND TO STRING
	$string .= chr( $rand );

	// IF EQUAL TO OR GREATER THAN LENGTH THEN RETURN
	if( strlen($string) >= $length ) return;

	// RECURSION - BUILD THE STRING
	generateRandomString( $length, $string );
}

Usage

Posted by Beau Durrant

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
Ping This!