Tuesday, December 6, 2011

Joomla 1.7 - Create a Hello World Simple Module

  1. Create a folder called mod_helloworld in modules
  2. Create a mod_helloworld.php file
  3. Create a mod_helloworld.xml file
  4. Create a helper.php file
  5. Create a template file tmpl/default.php
  6. Discover new modules by going to “Extension Manager” -> “Discover”

The code for mod_helloworld.php

<?php
defined('_JEXEC') or die; // no direct access allowed
 
require_once dirname(__FILE__).DS.'helper.php'; // get helper files
 
$hello = modHelloWorldHelper::getHello($params);
require JModuleHelper::getLayoutPath('mod_helloworld');
?>

The helper.php file

<?php
 class modHelloWorldHelper
 {
     /**
      * Retrieves the hello message
      *
      * @param array $params An object containing the module parameters
      * @access public
      */    
     function getHello( $params )
     {
         return 'Hello, World!';
     }
 }
?>

Include the template file for the default view

<?php
defined('_JEXEC') or die;
echo $hello; 
?>

The mod_helloworld.xml file

 <?xml version="1.0" encoding="utf-8"?>
 <extension type="module" version="1.7.0" client="site" method="upgrade">
     <name>Hello World!</name>
     <author>Harshal Shah </author>
     <version>1.7.0</version>
     <description>Reinholds simple Hello World module.</description>
     <files>
    <filename module="mod_helloworld">mod_helloworld.php</filename>
         <filename>mod_helloworld.xml</filename>
         <filename>index.html</filename>
         <filename>helper.php</filename>
         <filename>tmpl/default.php</filename>
         <filename>tmpl/index.html</filename>
     </files>
     <params>
     </params>
 </extension>

Create both index.html files to prevent direct directory browsing

<html><body></body></html>

Sunday, September 18, 2011

Connect two Amazon EC2 using ssh

1.Make sure you have the rightscript Managessh private key ssh installed.
2. Make sure both the instance install same ssh key.
3. It works like a cream

Wednesday, July 20, 2011

Amazon HAPROXY haproxy[12490]: proxy test has no server available!

This happens when haproxy is trying to find a status file on the server mentioned in rightscale_lb.cfg
If there is no file it does not recognize the server and errors out

haproxy proxy test has no server available!




server srv3.0  ip-xx-xx-xx-xxx.ec2.internal:80 cookie srv03.0 check inter 2000 rise 2 fall 3


Fix
comment out the contents from cookie something like this and restart the server service haproxy restart
server srv3.0  ip-xx-xx-xx-xx.ec2.internal:80 
#cookie srv03.0 check inter 2000 rise 2 fall 3