Monday, April 29, 2013

PHP Script to sent email with attachments.

sentemail-attachment.zip

PHP Script to create cache

1). Create Folder Name "cache";
2).
ob_start();
$strUrl = "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

if(file_exists("cache/".basename($strUrl)))
{
require_once("cache/".basename($strUrl));
}
else
{
echo "This is home page content......................";
}
$fp = fopen("cache/".basename($strUrl),"w");
fwrite($fp, ob_get_contents());
fclose($fp);
ob_end_flush();

FFMPEG Library for windows php script

FFMPEG Library for windows

How to Print a part of webpage using Javascript


<div dir="ltr" style="text-align: left;" trbidi="on">
<script type="text/javascript">
function printDiv()
{
   var divToPrint=document.getEelementById('areaToPrint');
  newWin= window.open("");
  newWin.document.write(divToPrint.outerHTML);
  newWin.print();
  newWin.close();
}
</script>

<div id="areaToPrint">
The text you want to print or the content you want to print
</div>
</div>

How to add a Bookmark to the Browser using Javascript


<div dir="ltr" style="text-align: left;" trbidi="on">
<script type="text/javascript">
function Add_Bookmark_Favorite(url,title)
{
 if (window.sidebar)
 { // Mozilla Firefox Bookmark
  //Make sure "Load this bookmark in the sidebar is deselected
  window.sidebar.addPanel(title, url,"");
  return false;
 }
 else if( window.external )
 { // IE Favorites
  window.external.AddFavorite( url, title);
  return false;
 }
 else if(window.opera && window.print)
 { // Opera Bookmark
  return !addToFav(url,title)
 }
}
</script>
<a href="" onclick="Add_Bookmark_Favorite('http://www.google.com/','Google')">Bookmark this link</a>

</div>

Check whether site is down or good using php


function VisitSite($url)
{
    //$agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
    $ch = curl_init();
    curl_setopt ($ch, CURLOPT_URL,$url );
    //curl_setopt($ch, CURLOPT_USERAGENT, $agent);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt ($ch,CURLOPT_VERBOSE,false);
    curl_setopt($ch, CURLOPT_TIMEOUT, 5);
    $page=curl_exec($ch);
    //echo curl_error($ch);
    $httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    if($httpcode >= 200 && $httpcode < 300){
        return true;
    }
    else {
        return false;
    }
}
if(VisitSite('http://www.google.co.in'))
{
       echo "Website looks Good<br />";
}else
{
      echo "Website looks Down<br />";
}

Limit the text area using Javascript

Compress & decrease the page loading time using HTACCESS

mod_gzip_on Yes mod_gzip_dechunk Yes mod_gzip_item_include file \.(html?|txt|css|js|php|pl)$ mod_gzip_item_include handler ^cgi-script$ mod_gzip_item_include mime ^text/.* mod_gzip_item_include mime ^application/x-javascript.* mod_gzip_item_include mime ^image/.* mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*

Upgrade Phpmyadmin in XAMPP

Just download the latest version of Phpmyadmin from phpmyadmin or download from the link below. http://www.phpmyadmin.net/home_page/downloads.php First take a copy of Phpmyadmin folder in XAMPP or else just rename it in XAMPP then extract the downloaded files into XAMPP folder. And now, take the config.inc.php file from the renamed folder & place it in the new folder, thats it & just check the latest version is running successfully.

Friday, April 19, 2013

Get the post / page ID in functions.php

Usually the global variable $post will give the user all the information of the current post / page. This global variable is not available in functions.php (if the code is not in a function) so you can use the following code snippet to get the ID of the post/page ID based on current URL.

$currenturl = explode('?', 'http://'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]);
$curpostId = url_to_postid($currenturl [0]);


$curpostId value will be zero if the current page is not a post / page.

Disable Author page in wordpress

Disable Author page in wordpress

SKYPE and WAMP server conflicting

Skype Tools->Options->Advanced->Connection->UNCHECK "use port 80 and 443 as alternative incomming ports".

Manage Cron Job using Putty

Login to SSH via Putty
Type crontab –e
Use “I” for insert
Make the necessary changes
Press Escape
Type :q (to quit without any changes)
Type :wq (to save changes and quit)

Get first Image from Post content in Wordpress

Get first Image from Post content in Wordpress

Payment Gateways and Extensions for Indian Rupee Currency

EBS Payment Gateway India:
WebSite: http://ebs.in/
Downloads:https://support.ebs.in/app/index.php?/default_import/Knowledgebase/List/Index/9

Magento Extension:
https://support.ebs.in/app/index.php?/default_import/Knowledgebase/Article/View/366/0/magento-16-ebs-integration-kit-ver-25

CC Avenue:
WebSite: http://www.ccavenue.com/
Signup Link: https://mars.ccavenue.com/mer_register/mer_register_form_ccav.jsp
Sample Code: Available in merchant account

Magento Extension: http://bluezeal.in/ccavenue4magento/ccavenue-payment-module-for-magento
CC Avenue Integration Scripts:
http://opensourceprogrammer.in/php-script-for-integration-of-ccavenue-payment-gateway
http://world.ccavenue.com/downloads/CCAVenueWorldIntegrationManual.pdf

Face detection using PHP

We need to install Facedetection, OpenCV PHPextensions to use these functions to find the coordinates of the faces. Go through the following resouces for more information.
http://corpocrat.com/2009/08/18/automatic-face-detection-with-php-in-linux/
https://github.com/infusion/PHP-Facedetect/
http://www.xarg.org/project/php-facedetect/


You can detect face without any PHP extension using below Script:
http://devlup.com/programming/php/face-detection-using-php/1140/
http://www.emanueleferonato.com/2010/07/06/php-face-detection-class/


http://www.codediesel.com/algorithms/face-detection-in-images-using-php/


http://svay.com/blog/face-detection-in-pure-php-without-opencv/

Magento: Display Currency Switcher in Header

Magento: Display Currency Switcher in Header

Magento Create Basic Custom Payment Gateway

Magento Create Basic Custom Paument Gateway

Frequently used Putty commands

Database Dump:
mysqldump -u username -h localhost -p dbname > filename.sql

Import Database Dump:
mysql -u username -p -h localhost DATA-BASE-NAME < data.sql

Tar a folder:
tar -cv foldername > foldername.tar

GZip the tar file:
gzip foldername.tar

Extract tar.gz file:
tar -zxvf yourfile.tar.gz

Extract .bz2 file:
bunzip2 yourfile.bz2

Extract tar.bz2file:
tar jxf backup.tar.bz2

Copy files from source to destination: scp local.xml username@hostnameORipaddress:FullFolderTargetPath

Save Core Config data prgramatically

$coreConfig = new Mage_Core_Model_Config(); $coreConfig ->saveConfig($path, $value, $scope = 'default', $scopeId = 0); Mage::app()->getConfig()->reinit(); Mage::app()->reinitStores();

Redirect to My Downloads page in checkout success

Redirect to My Downloads page in checkout success

Get and Set Config data

$lastUpdatedDate = Mage::getStoreConfig('test/newarrivals/updateddate'); Mage::getModel('core/config')->saveConfig('test/newarrivals/updateddate', $lastUpdatedDate );

Required Extensions for new Magento instance


Banner Slider:

Order Eraser:

Featured Products:
 

Installing Magento via SSH

Magento SSH

Magento script to clean logs

Clear logs

Display date in specified format in Magento

Display date in specified format in Magento Mage::helper('core')->formatDate($date, $format, $showTime=false) Argument 1: Date that you want change the format (This may be database driven or manual) Argument 2: Date format: short, long, medium, full Argument 3: Show Time: True to display time and false to not display time