Wednesday, 29 July 2015

Xampp Apache and Visual Studio Port 80 conflict

If you already install Xampp Apache running into your PC and later install the Visual Studio 2015, then there will port conflicts. Normally, Visual Studio overtake the default IIS HTTP port 80 and use it.

However, if you want both to be working by running one at a time.
To do that,
Type Services.msc from the run command prompt > scroll down to World Wide Web Publishing service.
OR go to Control Panel > Administrative Tools > Services.msc > World Wide Web Publishing service.

Then, Right click  the Web Publishing and 'Stop' it, also, Go the same Properties and set a Startup type: 'Manual'.

Then, try to restart the apache. It should be working.

On the other hand, when you need to start the Visual Studio part of service, you can do same thing manually and later disable it.


Hope that helps;

Friday, 17 July 2015

Get the input array variable in Joomla 3+

In Joomla 3+ or Joomla 3.4, To get/filter the INPUT or POST variable whose value is in array, please use the below script to pull the values:

JFactory::getApplication()->input->get('cid', null, 'array');


Thursday, 14 May 2015

Deleting all large size files from all directories using Bash in Linux

If you are looking to delete all the files in Linux Web Server by specifing File Name and File Size,
then follow steps below:

1. Login into your server Terminal via root login.
2. Create a new bash file called clean_up.sh in one of the location
e.g. /home/my_script/

3. Then Copy and the below code and Paste into that file and Save it.
clear
echo ' -------------------------------------------------------------------------'
echo '  Cleaning all large size error_log files from all directories.'
echo ' -------------------------------------------------------------------------'

filename="error_log"
filesize="50000"

echo " Deleting all files (including subfolders) having Filename:'$filename', Size: greater than $filesize Kb only."
echo ' '
echo ' Listing all the files which are greater than 50MB'
find / -type f -size +50M -exec du -h {} \; | sort -n

echo ' Deleting all the "error_log" files which are greater than 50MB'
#find -name "error_log" -size +30000k #-delete
find -name "$filename" -size +"$filesize"k -delete

echo ' Listing again all the files which are greater than 50MB'
find / -type f -size +50M -exec du -h {} \; | sort -n

4. Then go to your specified directory where you want to Search and Delete the files by specifying the File Name and File Size as below;

5. Then run the below command
sh  /home/my_script/clean_up.sh

Tuesday, 12 May 2015

To change the default port 8069 to 80 or any other port in Odoo/OpenERP 8+

Whilst installing Odoo/OpenERP into your local server, please download directly from Odoo website.

PS: please do not use Bitnami Odoo version as its bit outdated (unless they have released the latest Odoo updated version for 8.0+). You may use install it from them but it runs very slowly and takes a lot of memory than the version directly from Odoo.

Once you have downloaded the latest Odoo 8.0 plus directly from Odoo website, just run the .exe file.

By default, it runs under the 8069 port number. However, you can change to any other port as you like, for eg. to port 80.
  • First, copy a the root/server/openerp-server.conf file into the desktop and open it on editor, goto Line number => 60 (root/ folder is a location where Odoo has been installed).

    Modify the Line number => 60 from xmlrpc_port = 8069 to xmlrpc_port = 80 (or any other numer as you required) and save a file. 

  • Then COPY that file from destktop and PASTE it into the root/server/ location.
  • Secondly, copy a the root/server/openerp/tools/config.py file into the desktop and open it on editor, goto Line number => 155 (root/ folder is a location where Odoo has been installed).

    Modify the Line number => 155 from my_default=8069, to my_default = 80 (or any other numer as required) and save a file. 

  • Then COPY that file from destktop and PASTE it into the root/server/openerp/tools/ location. 
  • Lastly, RESTART the machine and it should work.

Please comment here if you have further information or if you have any issue.

Hope that helps!

Tuesday, 5 May 2015

Print the HTML contents via Element Id or Class Name via Javascript/jQuery

Please use the below function to print the HTML contents via Element Id or Class Name via Javascript/jQuery.
PS: You would require jQuery library to link.
/* 
* Function to print the HTML contents via element Id or Class 
* elem This can be Name of the tag ID or Class 
*/
function PrintMe(elem) {
 
 var pageHeaderTitle = 'Enter you Page Header Title here';
 var bodyTitle = 'Enter you Page Title here';  
 var bodySubTitle = 'Enter you Page Sub Title here'; // (optional) 
 var pageData = jQuery(elem).html();
 
 var siteLogoCaption = 'Your Site Name';
 var site_logo_alt = '/images/logo/logo.jpg';
 
 var css_bootstrap_file_url = 'http://www.yourdomain.com/css/bootstrap.min.css';
 var css_custom_file_url = 'http://www.yourdomain.com/css/custom.css';
 
 var mywindow = window.open('', 'my div', 'height=600,width=800,scrollbars=yes');
 mywindow.document.write('< html>' + pageHeaderTitle + ' - <?php echo $site_name; ?>');
 mywindow.document.write('< link href="' + css_bootstrap_file_url + '" rel="stylesheet" type="text/css">');
 mywindow.document.write('< link href="' + css_custom_file_url + '" rel="stylesheet" type="text/css">');
 mywindow.document.write('< img alt="' + siteLogoCaption + '" height="auto" src="' + site_logo_url + '" style="float: left; margin-left: 40px;" width="100" />');
 mywindow.document.write('< div class="container" id="print_form" >< h3>'+ bodyTitle +'< /h3>');
 mywindow.document.write('< h4>' + bodySubTitle + '< /h4>< hr />');
 mywindow.document.write(pageData);
 mywindow.document.write('< p>---< /p>');
 mywindow.document.write('< /div>< /body>< /head>< /html>');
 mywindow.print();
 mywindow.document.close();
}

/** Invoking the printing function **/
< button class="btn btn-primary" onclick="PrintMe('#divContainerToPrint'); return false;" >Print< /button>

Wednesday, 22 April 2015

To setup up lastest CiviCRM on Joomla 3 plus version

If you are trying to install the latest CiviCRM on Joomla 3+, sometime you may stuck whilst installing the CRM component. In such instance, please add the below code on project .htaccess file and try to install again.

php_value upload_max_filesize 20M
php_value post_max_size 256M
php_value max_input_time 200

php_value memory_limit 128M
php_value register_globals off
php_value max_execution_time 600

Hope that helps! :-)

Tuesday, 21 April 2015

Error Handling on Joomla 3+

On latest version of Joomla (version 3+), the JError class has been depreciated and force to use the default PHP Exception which can be used as below:

/**
 * Function to verify the user access permission.
 * @return bool Return 'TRUE' if user has access, else throw an error.
 * @throws Exception
 */
protected function hasAccessPermission()
{    
 // Fetch the any user session.
 $user = JFactory::getUser(); 
 
 try {        
  /* if not logged in, prompt error. */
  if (!$user->get('guest')) 
  {
   /* Write your code here.. */
            return true;
  } 
  else {
   throw new Exception("You don't have permission to access this page. Please click here to Login for access.");
  }
 } 
 // Catch any exception
 catch (Exception $e) {
  // Display the message and exit;
  jexit($e->getMessage());
 }
}