add

Wednesday, November 27, 2013

URL Rewriting apache


I have a better solution. I’ve decided to go a bit in details for those who need it. Take a look and read on.

# Apache Rewrite Rules
 <IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine On
  RewriteBase /

# Add trailing slash to url
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
  RewriteRule ^(.*)$ $1/
Read more

Wednesday, October 2, 2013

Magento – Can’t Retrieve Entity Config Solution



After a recent update of MAMP on my system, I was no longer able to load Magento sites on my localhost. The problem seems to be a PHP compatibilty issue and the solution is pretty simple.

Loading up Magento sites on my local development server, I found myself greeted with a page saying:

Can’t retrieve entity config: core/store_group, followed by a long trace: message and

I found the solution online here: dltr.org and I’m posting it on my blog to make it easier for me to find later on!

Download a new copy of Magento from the Magento Commerce site and unzip the file.

Open Magento > lib > Varien and copy the Simplexml directory, then navigate through your sites on your localhost to the same location and replace the directory by pasting and overwriting.

Restart MAMP (or XAMP, LAMP, WAMP etc) and reload your sites.

Thanks to Damodar Bashyal for this!




Tags: , ,


 














Wednesday, September 4, 2013

Wordpress Plugins


Some Important Wordpress plugin:
  • User Management

    • User Access Manager
    • Capability Manager Enhanced
    • Role Scoper (best combination to use with Capability Manager Enhanced)
  • Excerpt

    • Advanced Excerpt
  • Security

    • Better WP Security
    • Really Simple CAPTCHA
  • PDF

    • BSK PDF Manager
    • Print Friendly and PDF
  • Custom Post

    • Custom Post Type UI
    • Post Types Order
    • Simple add pages or posts => http://wordpress.org/plugins/simple-add-pages-or-posts/
  • Forms

    • Contact Form 7
    • Ninja form
    • Front End Login Form => http://wordpress.org/plugins/front-end-login-form/
  • Site Down/Maintenance

    • Maintenance Mode
  • Cross Platform/Cross CMS

    • Joomla/Mambo to WP Migrator
  • Social Media

    • Recent Tweets Widget
  • Slider/Carousel/Lightbox

    • Revolution Slider(Best known)
    • FlexSlider
    • WP Video Lightbox => http://wordpress.org/plugins/wp-video-lightbox/
      Description : youtube and vimeo videos in lightbox

Friday, August 30, 2013

Increase Max Upload File Size in WordPress


Sometimes, you need to upload a large file to your site, and the default 8mb limit in WordPress isn’t enough. I attempted to change my limit directly on my server, then in the .htaccess file and then in wp-config.php but neither change worked for me. Then I came across this little snippet by Word Impressed which actually worked and allowed me to increase my max upload file size limit...
Read more

Thursday, June 13, 2013

First Wordpress plugin

First Wordpress plugin

/* Plugin Name: crud operation
 * Plugin URI: www.datum.com
 * description: a plugin for performing basic crud operations
 * Vesion: 1.0
 * Author URI: www.datum.com
 * license: GP2
 */
function crud_setUserCaps($param) {
    $editor = get_role(strtolower($param));
    $editor->add_cap('edit_download_item');
    $editor->add_cap('read_download_item');
    $editor->add_cap('delete_download_item');
    $editor->add_cap('edit_download_items');
    $editor->add_cap('delete_download_items');
    $editor->add_cap('read_download_items');
}
function crud_unsetUserCaps($param) {
    $editor = get_role(strtolower($param));
    $editor->remove_cap('edit_download_item');
    $editor->remove_cap('read_download_item');
    $editor->remove_cap('delete_download_item');
    $editor->remove_cap('edit_download_items');
    $editor->remove_cap('delete_download_items');
    $editor->remove_cap('read_download_items');
}
function set_caps() {
    //author,subscriber,contributor
    crud_setUserCaps('editor');
    crud_setUserCaps('administrator');
}
function crud_activationFun($param) {
    set_caps();
    crud_createDBTable();
    crud_installData();
    // Then flush them
    flush_rewrite_rules();
}
register_activation_hook(__FILE__, 'crud_activationFun');
function crud_deactivationFun($param) {
    crud_dropTable();
    crud_unsetUserCaps('editor');
    crud_unsetUserCaps('administrator');
    flush_rewrite_rules();
}
register_deactivation_hook(__FILE__, 'crud_deactivation_fun');
add_action('wp_enqueue_scripts', 'crud_loadScripts');
function crud_loadScripts($param) {
    wp_enqueue_script('jquery');
    wp_register_script('docready', plugins_url('js/docready.js', __FILE__));
    wp_enqueue_script('docready');
}
add_action('wp_enques_styles', 'crud_loadStyles');
function crud_loadStyles($param) {
    wp_register_style('baseStyle', plugins_url('css/style.css', __FILE__));
    wp_enqueue_style('baseStyle');
}
add_action('init', 'crud_addRewriteRules');
function crud_addRewriteRules() {
    add_rewrite_rule("download_items/^([^/]*)/?", 'index.php?post_type=download_items=$matches[1]', 'top');
}
add_action('init', 'crud_registerDownloadItems');
function crud_registerDownloadItems() {
    $labels = array(
        'menu_name' => _x('download_items', 'Download Items'),
        'name' => 'Download Items',
        'singular_name' => 'Download Item',
        'add_new' => 'Add New',
        'add_new_item' => 'Add New Download Item',
        'edit_item' => 'Edit Download Item',
        'new_item' => 'New Download Item',
        'all_items' => 'All Download Items',
        'view_item' => 'View Download Item',
        'search_items' => 'Search Download Items',
        'not_found' => 'No Download Items found',
        'not_found_in_trash' => 'No Download Items found in Trash',
        'parent_item_colon' => '',
        'menu_name' => 'Download Items'
    );
    $args = array(
        'labels' => $labels,
        'hierarchical' => true,
        'description' => 'Slideshows',
        'supports' => array('title', 'editor'),
        'public' => true,
        'show_ui' => true,
        'show_in_menu' => true,
        'show_in_nav_menus' => true,
        'publicly_queryable' => true,
        'exclude_from_search' => false,
        'has_archive' => true,
        'query_var' => true,
        'can_export' => true,
        'rewrite' => array(
            'slug' => 'download_items',
            'with_front' => false,
            'feed' => true,
            'pages' => true
        ),
        'capabilities' => array(
            // Meta capabilities
            'edit_post' => 'edit_download_item',
            'read_post' => 'read_download_item',
            'delete_post' => 'delete_download_item',
            // Primitive capabilities
            'edit_posts' => 'edit_download_items',
            'delete_post' => 'delete_download_items',
            'read_posts' => 'read_download_items',
        ),
        'capability_type' => 'post'
    );
    register_post_type('download_items', $args);
}

add_action('add_meta_boxes', 'crud_addMetaBoxes');
function crud_addMetaBoxes() {
    //add_meta_box($id, $title, $callback, $page, $context, $priority);
    add_meta_box("crud_custom_fields", "Other Information", 'crud_viewFields', "download_items", "normal");
}
function crud_viewFields() {
    global $post, $wpdb;
    $table_name = $wpdb->prefix . "categories";
    $checked_status = '';
    $download_price = get_post_meta($post->ID, 'download_price');
    $crud_category = get_post_meta($post->ID, 'crud_category');
    $myrows = $wpdb->get_results( "SELECT category_name, category_Label FROM {$table_name}" );
   
    $html = '';
    $html .= '';
    $html .= "
               
               
             
             
               
               
             
           
";
    $html .= '
    ';
       
        foreach ($myrows as $key => $value) {
            if (stristr($crud_category[0], $value->category_name) == true) {
                $checked_status = ' checked="checked" ';
                $html .= '

  •                    
                   
  • ';
            } else {
                $html .= '

  •                    
                   
  • ';
            }
        }

        $html .= "
";
    echo $html;
}
/* Save Slider Options to database */
add_action('save_post', 'crud_saveDownloadInfo');
function crud_saveDownloadInfo($post_id) {

    // verify nonce
    if (!wp_verify_nonce($_POST['crud_custom_fields_nonce'], basename(__FILE__))) {
        return $post_id;
    }
    // check autosave
    if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return $post_id;
    }
    // check permissions
    if ('download_items' == $_POST['post_type'] && current_user_can('edit_download_items', $post_id)) {
        $download_price = (isset($_POST['crud_download_price']) ? $_POST['crud_download_price'] : '');
        $categories = (isset($_POST['crud_category']) ? $_POST['crud_category'] : '');
        $categories = strip_tags(json_encode($categories));
        update_post_meta($post_id, "download_price", $download_price);
        update_post_meta($post_id, "crud_category", $categories);
    } else {
        return $post_id;
    }
}
// Callback function to show fields in meta box
add_filter('map_meta_cap', 'crud_downloadItemMetaCap', 10, 4);
function crud_downloadItemMetaCap($primitive_caps, $meta_cap, $user_id, $args) {
    // If meta-capability is not download_item based do nothing.
    if (!in_array($meta_cap, array('edit_download_item', 'delete_download_item', 'read_download_item'))) {
        return $primitive_caps;
    }
    // Check post is of post type.
    $post = get_post($args[0]);
    $post_type = get_post_type_object($post->post_type);
    if ('download_items' != $post_type) {
        return $primitive_caps;
    }
    $primitive_caps = array();
    switch ($meta_cap):
        case 'edit_download_item':
            if ($post->post_author == $user_id) {
                // User is post author
                if ('publish' == $post->post_status) {
                    // download_item is published: require 'edit_published_download_items' capability
                    $primitive_caps[] = $post_type->cap->edit_published_posts;
                } elseif ('trash' == $post->post_status) {
                    if ('publish' == get_post_meta($post->ID, '_wp_trash_meta_status', true)) {
                        // download_item is a trashed published post require 'edit_published_download_items' capability
                        $primitive_caps[] = $post_type->cap->edit_published_posts;
                    }
                } else {
                    $primitive_caps[] = $post_type->cap->edit_posts;
                }
            } else {
                // The user is trying to edit a post belonging to someone else.
                $primitive_caps[] = $post_type->cap->edit_others_posts;
                // If the post is published or private, extra caps are required.
                if ('publish' == $post->post_status) {
                    $primitive_caps[] = $post_type->cap->edit_published_posts;
                } elseif ('private' == $post->post_status) {
                    $primitive_caps[] = $post_type->cap->edit_private_posts;
                }
            }
            break;
        case 'read_download_item':
            if ('private' != $post->post_status) {
                // If the post is not private, just require read capability
                $primitive_caps[] = $post_type->cap->read;
            } elseif ($post->post_author == $user_id) {
                // Post is private, but current user is author
                $primitive_caps[] = $post_type->cap->read;
            } else {
                // Post is private, and current user is not the author
                $primitive_caps[] = $post_type->cap->read_private_post;
            }
            break;
        case 'delete_download_item':
            if ($post->post_author == $user_id) {
                // Current user is author, require delete_download_items capability
                $primitive_caps[] = $post_type->cap->delete_posts;
            } else {
                // Current user is no the author, require delete_others_download_items capability
                $primitive_caps[] = $post_type->cap->delete_others_posts;
            }
            // If post is published, require delete_published_posts capability too
            if ('publish' == $post->post_status) {
                $primitive_caps[] = $post_type->cap->delete_published_posts;
            }
            break;
    endswitch;
    return $primitive_caps;
}
function crud_frontendDeleteLink() {
    if (!current_user_can('delete_download_items')) {
        echo '    ';
        return;
    }
    $url = add_query_arg(
            array(
                'action' => 'frontend_delete',
                'post' => get_the_ID()
            )
    );
    echo "Delete";
}
if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'frontend_delete') {
    add_action('init', 'crud_FrontendDeletePost');
}
function crud_FrontendDeletePost() {
    if (!current_user_can('delete_download_items'))
        return;
    $post_id = (isset($_REQUEST['post']) ? (int) $_REQUEST['post'] : 0);
    if (empty($post_id))
        return;
    wp_trash_post($post_id);
}
add_shortcode('downloadItem', crud_downloadItemFun);
function crud_downloadItemFun() {
    set_caps();
    global $post ;
   $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    $args = array(
      'posts_per_page' => 10,
      'post_type' => 'download_items',
      'paged' => $paged
    );
    $newsObj = new WP_Query($args);
    if ($newsObj->have_posts()):    ?>
       
           
               
               
               
               
               
           
           
                while ($newsObj->have_posts()): $newsObj->the_post();
        $curr_id = get_the_ID();
        $meta = get_post_meta( $curr_id,'crud_category' );
        $meta = preg_replace('/[^a-zA-Z0-9\,]/', '', $meta);
        $download_price = get_post_meta( $curr_id,'download_price' );
        ?>
           
               
               
               
               
               
           
                endwhile;?>
       
TitleCategoriesPriceEditDelete
0 ) {echo $meta[0] ;} ?>0 ) echo implode(',', $download_price); ?>">Edit

            endif;
    wp_reset_query();
}
add_action('admin_menu','crud_pluginSetting');
function crud_pluginSetting() {
    add_menu_page('Crud Plugin Settings', 'Crud Settings', 'administrator', 'crud_settings', 'crud_settingFunction');
}
if (isset($_REQUEST['category_label']) && (!empty ($_REQUEST['category_label']) || '' != 'frontend_delete')) {
    crud_installData($_REQUEST['category_name'], $_REQUEST['category_label']);
}
function crud_settingFunction() {
    $category_label = (get_option('category_label') != '') ? get_option('category_label') : 'category_label100';
    $category_name = (get_option('category_name') != '') ? get_option('category_name') : 'category_name100';
    $html = '

       

       

Select Your Settings


        ' . wp_nonce_field('update-options') . '
           
           
               
                   
               
               
                   
               
           
           

                       
                   

                       
                   

           
 

           
';
    echo $html;
}
function crud_createDBTable() {
    global $wpdb;
    $table_name = $wpdb->prefix . "categories";
    $sql = "CREATE TABLE $table_name (
  id mediumint(9) NOT NULL AUTO_INCREMENT,
  category_name text NOT NULL,
  category_label text NOT NULL,
  UNIQUE KEY id (id)
    );";
    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    dbDelta($sql);
}
function crud_dropTable() {
    global $wpdb;
    $table_name = $wpdb->prefix . "categories";
    $sql = "DROP TABLE $table_name";
}
function crud_installData($category_name = "News",$category_Label = "News") {
   global $wpdb;
   $table_name = $wpdb->prefix . "categories";
   //$category_name = "News";
   //$category_Label = "News";
   $rows_affected = $wpdb->insert( $table_name, array( 'category_name' => $category_name, 'category_Label' => $category_Label) );
}
//Debug Errors if there are any
add_action('activated_plugin','save_error');
function save_error(){
    file_put_contents(ABSPATH. 'wp-content/uploads/2013/error_activation.html', ob_get_contents());
}
?>


Friday, May 31, 2013

PHP N-tier: Introduction N-Tier Strategy


PHP N-tier: Introduction N-Tier Strategy
PHP N-Tier Strategy Step By Step Tutorial - Part 1: May be you face complicated situation in your client's architecture. They use many technology for solve their complicated business process. If it happen, n-tier may be possible one solution you can choice. It this post, we begin to understanding possible N-Tier architecture.
General principle that we must consider if wants to build N-tier application:
  • Every layer must be independent physically. It doesn't mean every layer have to exist in separated computer. But, every layer can be distributed every where (separated computer or not).
  • Each layer must transfer information only to/from previous/next layer.
  • You can change technology used in every layer without change entire system. Example, - you want to change database layer- from mySql to PostgreSQL.
Following sample architecture design use 5-tier:
  • Presentation GUI, do parse HTML, XHTML, WML.
  • Presentation Logic do rendering process HTML, XHTML to send using HTTP to browser. It accepts data from business logic and tie to HTML. This process run at php at web server.
  • Business Logic, manipulate and transform data. Simple, task of this layer is fetch data from data access tier and prepare before send to presentation logic. This process run at server that utilize XML.
  • Data access tier have task to connect and retrieve data from database.
  • Data tier is aplication database such as mySQL, PostGreSQL, and others.

PHP N-tier: Possible n-tier Application Use PHP

PHP N-Tier Strategy Step By Step Tutorial - Part 2: In this post, we will try to design n-tier application use PHP. This is my 5-tier design:
  • Presentation GUI: Using smarty template to generate HTML.
  • Presentation Logic: PHP.
  • Business Logic: Use NuSOAP.
  • Data Access Tier: Using ADOdb.
  • Data tier: Using mySQL.
We ever talked about nusoap, adodb, and mysql. If you still understand about them, please read posts about them.

PHP N-tier: Database Layer Using MySQL

PHP N-Tier Strategy Step By Step Tutorial - Part 3: For practice, we will build simple application to show 5-tier design. We will begin from database layer. At the database layer, we use MySQL.
Create a database, for example "test". Then create table. This is the query:
“CREATE TABLE `books` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,`title` VARCHAR( 255 ) NOT NULL ,`author` VARCHAR( 60 ) NOT NULL) ENGINE = MYISAM ;
Next, try to insert sample data, such as:
“INSERT INTO `test`.`books` (
`id` ,
`title` ,
`author`
)
VALUES (
NULL , 'PHP Undercover', 'Wiwit Siswoutomo'
), (
NULL , 'PHP Enterprise', 'Wiwit Siswoutomo'
);
Ok, next post we will try how to connect database use PHP ADOdb as data access tier.

PHP N-tier: Data Access Tier Using PHP ADOdb

PHP N-Tier Strategy Step By Step Tutorial - Part 4: In this post, we will build data access tier. We use PHP Adodb. About PHP Adodb, you can read at here.
For this practice, create a folder named "ntier" within www/test. Place your all PHP ADOdb folder at here. Thus, you have www/test/ntier/adodb.
Then create a file named "dataaccess.php" within www/test/ntier. Enter following code
include('adodb/adodb.inc.php');
 $databasetype = 'mysql';
$server = 'localhost';
$user   = 'root';
$password = 'admin';
$database = 'test';
 $db = ADONewConnection($databasetype);
$db->debug = false;
$db->Connect($server, $user, $password, $database);
 $recordSet = &$db->Execute('select * from books');
 if (!$recordSet)
  print $conn->ErrorMsg();
else
  while (!$recordSet->EOF) {
    print $recordSet->fields[0].' '.$recordSet->fields[1].' '.$recordSet->fields[2].'
';
  $recordSet->MoveNext();     
}  
 $recordSet->Close(); # optional
             
$db->Close();
 ?>
Test it. Open your browser. point to http://localhost/test/ntier/dataacces.php.

PHP N-tier: Building Business Logic

PHP N-Tier Strategy Step By Step Tutorial - Part 5: After create connection to database at this post, we will process this data. We prepare this data in order to can to send using webservices. We named this: business logic layer.
This practice only work well for php 4. In php 5, we will talk next serial post. Because there is embedded function in php 5. First, copy library of nusoap within www/test/ntier/lib. If you don't understant to place nusoap, please read this post.
Open again file dataacces.php within www/test/ntier. Update like following:
// call library
require_once ( './lib/nusoap.php' ); //nusoap
require_once ('adodb/adodb.inc.php');//adodb
 // create instance
$server = new soap_server();
 // initialize WSDL support
$server->configureWSDL( 'hello' , 'urn:hellowsdl' );
 // place schema at namespace with prefix tns
$server->wsdl->schemaTargetNamespace = 'urn:hellowsdl';
 // register method
$server->register('books',  // method name
array(), // input parameter
array('return'=>'xsd:array'),
'urn:hellowsdl' , // namespace
'urn:hellowsdl#hello', // soapaction
'rpc', // style
'encoded', // use
'Load list of book to the caller' // documentation
);
 // configuration database
define(__databasetype__,'mysql');
define(__server__,'localhost');
define(__user__,'root');
define(__password__,'admin');
define(__database__,'test');
  // method
function books(){
  $db = ADONewConnection(__databasetype__);
  $db->debug = false;
  $db->Connect(__server__, __user__, __password__, __database__);
   $recordSet = &$db->Execute('select * from books');
   if (!$recordSet){
        return new soap_fault('Server','',$conn->ErrorMsg());
  } else {
    while (!$recordSet->EOF) {
          $books[] = array('id'=>$recordSet->fields[0],
                           'title'=>$recordSet->fields[1],
                                         'author'=>$recordSet->fields[2]
                          );
      $recordSet->MoveNext();     
    }  
     $recordSet->Close();       #optional    
    $db->Close();
  }

  // return value to client
  $obj = new soapval('return','array',$books);
  return $obj->serialize();
 
}
  $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
$server->service($HTTP_RAW_POST_DATA);
?>
Then, test it. Open your browser. Point to http://localhost/test/ntier/dataacces.php. You will get like this:

PHP N-tier: Building Presentation Logic


PHP N-Tier Strategy Step By Step Tutorial - Part 6: After create business logic, now we try to catch the data. We called this: presentation logic layer. We still use nusoap to do this job.
Just for practice, we will create client same folder/location with server function. Create a file named "client_book.php" within www/test/ntier. Enter following code:
require_once ('lib/nusoap.php');
 $client = new soapclient('http://localhost/test/ntier/dataacces.php');
 $response = $client->call('books');
 if($client->fault)
{
  echo "FAULT: Code: (".$client->faultcode.")
";
  echo "String: ".$client->faultstring;
}
else
{
  $r = $response[0];
  $count = count($r);
?>
 
   
     
            
      
   
        for($i=0;$i<=$count-1;$i++){
        ?>
   
     
     
     
   
            }
        ?>
 
IdTitleAuthor

    }
?>
Now, open your browser and point to http://localhost/test/ntier/client_book.php.

PHP N-tier: Building Presentation GUI

PHP N-Tier Strategy Step By Step Tutorial - Part 7: We have grabbed data from server at presentation logic. And we tie data to html at previous post. It will give us more flexible if we you template system. So, we can change any layout without change all. for this job, we use smarty template.
Exactly, what is smarty template? I rewrite from their readme: Smarty is a template engine for PHP. Many other template engines for PHP provide basic variable substitution and dynamic block functionality. Smarty takes a step further to be a "smart" template engine, adding features such as configuration files, template functions, and variable modifiers, and making all of this functionality as easy as possible to use for both programmers and template designers.
First, please download smarty template at smarty.php.net. Extract compressed file to www/test/ntier. You will get folder named like "smarty-2.6.xx". Rename, for simply, become: "smarty".
Then, create folders named "templates" and "templates_c" within www/test/ntier.
Open again your client_book.php, rewrite with this code:
// call library
require_once ('./lib/nusoap.php');
require_once ('./smarty/libs/smarty.class.php');
 // retrieve data from server
// use webservice by nusoap
$client = new soapclient('http://localhost:8048/test/ntier/dataacces.php');
$response = $client->call('books');
 if($client->fault)
{
  echo "FAULT: Code: (".$client->faultcode.")
";
  echo "String: ".$client->faultstring;
  die();
}
else
{
  // start using smarty
  $smarty = new Smarty;

  // assign parameters
  $smarty->assign("title","Books Collection");
  $smarty->assign("books",$response[0]);

  //load template
  $smarty->display('template.tpl');
}
?>
Now, you can see. Your code be more clean. No html tag over there. All html tag will be place at template.
Create a file named "template.tpl" within www/test/ntier/templates. Then enter following code:


{$title}

 
   
     
            
      
   
{foreach key=key item=item from=$books}
   
  {foreach key=key item=item from=$item}
   
  {/foreach}
    
{/foreach}
 
IdTitleAuthor
{$item}
Congrat! you have understand how to build 5-tier use php. You can expand this tutorial as you need.

Friday, May 17, 2013

Regex in PHP

1. 1 Character 1 number and string length
^\S*(?=\S{8,})(?=\S*[a-z])(?=\S*[A-Z])(?=\S*[\d])\S*$

  • ^: anchored to beginning of string
  • \S*: any set of characters
  • (?=\S{8,}): of at least length 8
  • (?=\S*[a-z]): containing at least one lowercase letter
  • (?=\S*[A-Z]): and at least one uppercase letter
  • (?=\S*[\d]): and at least one number
  • $: anchored to the end of the string
To include special characters, just add (?=\S*[\W]), which is non-word characters

OR

(?=^.{8,}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$
   * contain at least (1) upper case letter
   * contain at least (1) lower case letter
   * contain at least (1) number or special character
   * contain at least (8) characters in length



References
1. http://www.autohotkey.com/docs/misc/RegEx-QuickRef.htm
2. http://www.regular-expressions.info/index.html