Wednesday, April 20, 2011

How to use PHP code in HTML file

Many places, we feel that we can give better result if it would possible to use PHP code instead of javascript code in HTML page. Below is the way to use php code in the html page.

Html file name is "abc.html" :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Use PHP in HTML file</title>
</head>

<body> 
<!-- We can also pass the parameters to PHP as query string -->
<script src="xyz.php?uid=10&pid=string value"></script>
</body>
</html>
PHP file name is "xyz.php":
<?php
header("application/javascript");
$uid=$_GET['uid'];$pid=$_GET['pid'];
$ip=$_SERVER['REMOTE_ADDR'];
$mytime=date('m-d-Y H:i:s');
echo "document.write('Your IP is <b>$ip</b><br />Server date and time is <b>$mytime</b>');";
echo "document.write('<br />$pid');";
?>

Output :
Your IP is 127.0.0.1
Server date and time is 04-27-2011 01:01:44
string value

 Please feel free to provide your valuable feedback.

Tuesday, April 19, 2011

Enhanced Extravote plugin in joomla

Extravote is a very popular and useful 5 star rating plugin to rate an article. So, if a page contains multiple content items, it will display mulitple times on a page and works great. We can also use this plugin in third party extensions. But, there is a major issue with this plugin which has not been considered by developers.

About the issue : Just click on a star to give your rating for an article. Your vote will be counted and system will display message "Thanks for voting". If you try to vote again, system will display message "You have already voted". But, with this message, total vote will be decreased by 1. It will be corrected only when you refresh the page. If you are the first one to vote an article, you will notice that, after repeating the vote second time, you will get the message "You have already voted" and total vote become 0. I have consider the issue and debug the code. Since, this plugin is using AJAX for whole functionality, value passed to the javascript function don't change. Finally, I have change the way of implementation and it woks without any issue.
I have not only fix this issue, also enhanced its functionality.

Monday, April 4, 2011

Call plugin in third party extension of joomla

global $mainframe;
        include_once('components/com_content/models/article.php');
        include_once('components/com_content/helpers/query.php');
        $dispatcher =& JDispatcher::getInstance();
        $articleObject=new ContentModelArticle();
        $id= JRequest::getVar('content_id');
        $limitstart    = JRequest::getVar('limitstart', 0, '', 'int');
        $articleObject->setId($id);
        $item=new JObject;
        $item->text = $articleObject->getArticle(); 
        $item->params = clone($mainframe->getParams('com_content'));
        JPluginHelper::importPlugin('content');
        $results=$dispatcher->trigger('onBeforeDisplayContent', array (& $item->text, & $item->params, 0));
        echo $results[0];

Saturday, April 2, 2011

FFMPEG - a boon from open source community

FFMPEG an open source software is a product of Google summer of code. It is very useful in the manipulation of video, audio and image. Benefits of FFMPEG are below:
  • Extract n number of thumbnails from video and vice-versa
  • Convert types of video and audio
  • Extract audio and video for specific duration from audio/video
  • Extract audio from video
  • Mix audio and video
  • Extract thumbnails from an image
It is very useful for web applications because in many cases, we need to render light weight images and videos.
Click here to download ffmpeg software
Click here to download ffmpeg help and list of commands
Click here to download ffmpeg FAQ
Click here to download ffmpeg commands with examples
Click here to download supported  file formats and codecs for Audio and video files 


    Important queries based formulas to watch performance of a MySQL based application

    (1) Session Vs global status variables value select G.variable_name,G.variable_value GlobalValue,S.variable_value SessionValue from (selec...