Wednesday 24 December 2014

How to Use Javascript or PHP in a Joomla Article

Normally in a Joomla article, code such as Javascript or PHP will not work. This is for good security reasons. People could do a lot of harm if they were free to use these inside your articles. However, many advanced users need to use such code. This link will show you how to do it:

https://www.ostraining.com/blog/joomla/use-javascript-or-php-in-a-joomla-article/

                                                              OR


Go to the Joomla Extensions Directory and find Sourcerer:http://extensions.joomla.org/extensions/edition/custom-code-in-content/5051
Click on the "Download" link and you'll be taken to the developer's website where you can download Sourcerer.





How to create a built-in contact form for your WordPress theme

Many WordPress plugins can add a contact form to your blog, but a plugin is not necessary. In this tutorial, I’m going to show you how you can create a built-in contact form for your WordPress theme.Please visit following link.

http://www.catswhocode.com/blog/how-to-create-a-built-in-contact-form-for-your-wordpress-theme

How to Generate and customize your google map for free.

Google Map Generator enables you to simple create customized Google map. This map can be inserted to your site via javascript or can be accessed via hypertext link. Please click on following link.

Generate and customize your google map for free.

How to add Google maps on Contact us page using javascript.

<link href="/maps/documentation/
javascript/examples/default.css" rel="stylesheet">
    <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
    <script>
function initialize() {
        var myOptions = {
                zoom: 14,
                center: new google.maps.LatLng(26.89730702598253,80.95929462695312),
                mapTypeId: google.maps.MapTypeId.ROADMAP
              };

              var map = new google.maps.Map(document.getElementById('map_canvas'),
                  myOptions);

              /*var marker = new google.maps.Marker({
                position: map.getCenter(),
                map: map,
                title:'Lekhraj Panna Bus Stop, Sector 2, Vikas Nagar, Lucknow, Uttar Pradesh 226022, India'
              });*/
           
    var infowindow = new google.maps.InfoWindow({
    });

    var marker = new google.maps.Marker({
                position: map.getCenter(),
                map: map,
                title:'Lucknow'
              });

    google.maps.event.addListener(marker, 'click', function() {
        infowindow.setContent('<h4>Lucknow India</h4><p>Lekhraj Panna Bus Stop, <br>Sector 2, Vikas Nagar, Lucknow,<br> Uttar Pradesh 226022, India</p><a href="#info.html">See info</a>');
        infowindow.open(map,marker);  
    });
  
              }
             
              google.maps.event.addDomListener(window, 'load', initialize);

    </script>

How To Implement an Instant Payment Notification listener script in PHP - PayPal IPN with PHP

Using PayPal's Instant Payment Notification (IPN) service can be a little complex and difficult to troubleshoot to developers new to PayPal. In this post I will walk you through the entire process using the PHP-PayPal-IPN project to avoid many of the common pitfalls in the back-end PHP code. Visit following link:

http://www.micahcarrick.com/paypal-ipn-with-php.html

CCAvenue Virtuemart Plugin for joomla

This is an open-source plugin developed for the integration of payment gateway for CCAvenue with the VirtueMart E-Commerce component for Joomla.
VirtueMart is an open-source extension component provided in Joomla fr E-Commerce solutions.
VirtueMart has some payment gateway integrations, but integration for CC Avenue payment gateway is not there. This plugin adds CC Avenue payment gateway integration for VirtueMart.
Works with VirtueMart Version - 2.0. Visit following link:

https://github.com/ravirajpatil/Idea_CCAvenue_for_Virtuemart

Download Best Free Joomla Responsive Templates.

The Joomlatemplates is the best for joomla developers.Here joomla developers can easily find joomla templates and download them for their websites or projects. On this site you can see live demo and also download it for their projects for all joomla versions like joomla 2.5, joomla 3.0, joomla 3.1, joomla 3.2. Visit following link
 
Free Joomla Templates for all joomla version

 

How to intigrate chat functionality Joomla, Drupal and Wordpress, download plugins for Joomla, Drupal and Wordpress.

Introducing a live communication system for your website

Allow your website visitors to engage in a real-time conversations and spend more time on your website. Visit following link and download plugin.


https://www.blastchat.com/downloads

AVG key Life time version

AVG life time key.

8MEH-RFOD4-SXWR8-JRTQA-JADCJ-WEMBR-ACED


trial key

4U4AP-Z24UV-BTWWP-QW93F-4NWRE-K

How to add active class in anchor tag when page reload?

Put this script at the footer of the page.

<script>
       jQuery(document).ready(function(){
          var currurl=document.location.href;
           jQuery('#company-widget li').each(function(e){
           var href = jQuery(this).find('a').attr('href');
            if(currurl.indexOf(href)>0){
                jQuery(this).find('a').addClass('active');
            }else{
               jQuery(this).find('a').removeClass('active');
           }
      });
 });
</script>

JQuery star rating plugin with fractional rating support. Bootstrap Star Rating plugin links

Tuesday 23 December 2014

How to extract text from word file .doc,docx,.xlsx,.pptx and txt file using jquery ajax in php script

//create a php file

<?php     
            session_start();//start php session
            $filePath = 'uploads/' . $_FILES['file']['name'];
            $text='';
            if ( 0 < $_FILES['file']['error'] ) {
                echo 'Error: ' . $_FILES['file']['error'] . '<br>';       
            } else {
                     move_uploaded_file($_FILES['file']['tmp_name'], $filePath);
            }
   
        $text = convertToText($filePath);
        //delete file from directory
        unlink($filePath);
        //Set Text variable in session
        $_SESSION['text'] = $text;   
         echo $text;
       // Extract text from files
        function convertToText($filePath) {
             if(isset($filePath) && !file_exists($filePath)) {
                      return "File Not exists";
             }
        $fileArray = pathinfo($filePath);
        $file_ext  = $fileArray['extension'];       
        if($file_ext == "txt" || $file_ext == "doc" || $file_ext == "docx" || $file_ext == "xlsx" || $file_ext == "pptx")
        {
            if($file_ext == "txt") {
                   return read_txt($filePath);
            }elseif($file_ext == "doc") {
                   return read_doc($filePath);
            } elseif($file_ext == "docx") {
                   return read_docx($filePath);
            } elseif($file_ext == "xlsx") {
                   return xlsx_to_text($filePath);
            }elseif($file_ext == "pptx") {
                   return pptx_to_text($filePath);
            }
        } else {
            return "Invalid File Type";
        }
    }
   
    /*************************Extract text from txt files*****************************/
    function read_txt($filePath){
           $txtText='';
           $fh = fopen($filePath,'r');
            while ($line = fgets($fh)) {
                 $txtText.=$line;
            }
          fclose($fh);
         return $txtText;
    }
   
    /*************************Extract text from doc files*****************************/
    function read_doc($filePath) {
        $fileHandle = fopen($filePath, "r");
        $line = @fread($fileHandle, filesize($filePath));  
        $lines = explode(chr(0x0D),$line);
        $docText = "";
        foreach($lines as $thisline)
          {
            $pos = strpos($thisline, chr(0x00));
            if (($pos !== FALSE)||(strlen($thisline)==0)){
              } else {
                   $docText .= $thisline." ";
              }
          }
         $docText = preg_replace("/[^a-zA-Z0-9\s\,\.\-\n\r\t@\/\_\(\)]/","",$docText);
        return $docText;
    }
   
    /*************************Extract text from docx files*****************************/
    function read_docx($filePath){
        $striped_content = '';
        $content = '';
        $zip = zip_open($filePath);
        if (!$zip || is_numeric($zip)) return false;
        while ($zip_entry = zip_read($zip)) {
            if (zip_entry_open($zip, $zip_entry) == FALSE) continue;
            if (zip_entry_name($zip_entry) != "word/document.xml") continue;
            $content .= zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
            zip_entry_close($zip_entry);
        }// end while

        zip_close($zip);

        $content = str_replace('</w:r></w:p></w:tc><w:tc>', " ", $content);
        $content = str_replace('</w:r></w:p>', "\r\n", $content);
        $striped_content = strip_tags($content);
        return $striped_content;
    }
   
   
    /*******Extract text from excel sheet files****/
    function xlsx_to_text($filePath){
    $xml_filename = "xl/sharedStrings.xml"; //content file name
    $zip_handle = new ZipArchive;
    $output_text = "";
    if(true === $zip_handle->open($filePath)){
        if(($xml_index = $zip_handle->locateName($xml_filename)) !== false){
            $xml_datas = $zip_handle->getFromIndex($xml_index);
            $xml_handle = DOMDocument::loadXML($xml_datas, LIBXML_NOENT | LIBXML_XINCLUDE | LIBXML_NOERROR | LIBXML_NOWARNING);
            $output_text = strip_tags($xml_handle->saveXML());
        }else{
            $output_text .="";
        }
        $zip_handle->close();
    }else{
    $output_text .="";
    }
    return $output_text;
}

/*****Extract text from power point files*****/
function pptx_to_text($filePath){
    $zip_handle = new ZipArchive;
    $output_text = "";
    if(true === $zip_handle->open($filePath)){
        $slide_number = 1; //loop through slide files
        while(($xml_index = $zip_handle->locateName("ppt/slides/slide".$slide_number.".xml")) !== false){
            $xml_datas = $zip_handle->getFromIndex($xml_index);
            $xml_handle = DOMDocument::loadXML($xml_datas, LIBXML_NOENT | LIBXML_XINCLUDE | LIBXML_NOERROR | LIBXML_NOWARNING);
            $output_text .= strip_tags($xml_handle->saveXML());
            $slide_number++;
        }
        if($slide_number == 1){
            $output_text .="";
        }
        $zip_handle->close();
    }else{
    $output_text .="";
    }
    return $output_text;
}

?>

//jquery code

/******** Upload a File ******/
            $(function(){
            $('#upload_files').on('change', function() {
                var file_data = $('#upload_files').prop('files')[0];
                var form_data = new FormData();                 
                form_data.append('file', file_data)
                // alert(form_data);                            
                $.ajax({
                            url: "<?php echo home_url('/wp-content/plugins/gust').'/upload_files.php'; ?>", // point to server-side PHP script
                            dataType: 'text',  // what to expect back from the PHP script, if anything
                            cache: false,
                            contentType: false,
                            processData: false,
                            data: form_data,                        
                            type: 'post',
                            success: function(php_script_response){
                            if(php_script_response == '' || php_script_response == null){
                            alert('Invalid File Type!');
                            return false;
                            }else{
                            location.reload();
                            }
                            }
                 });
            });
            });
         
//css file

/***********put it in css file***********/
.fileUpload {
    position: relative;
    overflow: hidden;
      position: relative;
       float: left;
    margin-right: 105px;
       margin-top: 7px;
}
.fileUpload.btn.btn-primary:hover span{color:#fff;}
.fileUpload input.upload {
    position: absolute;
    top: 0;
    right: 0;
    margin: 0;
    padding: 0;
    font-size: 20px;
    cursor: pointer;
    opacity: 0;
    filter: alpha(opacity=0);
    width: 120px;
}

Saturday 20 December 2014

How to add content to the bottom of every post in WordPress?

Add the custom content to the bottom of every post in WordPess. 
Here is the simple plugin which will add content to the bottom 
of every post.
<?php
/*
  Plugin Name: Bottom of every post
  Plugin URI: http://www.umbrellastudio.com/wordpress/bottom-of-every-post/
  Description: Add some content to the bottom of each post.
  Version: 1.0
  Author: Corey Salzano
  Author URI: http://profiles.wordpress.org/users/salzano/
  License: GPL2
*/


/* To avoid a name collision, make sure this function is not
 already defined */

if( !function_exists("bottom_of_every_post")){
 function bottom_of_every_post($content){

 /* there is a text file in the same directory as this script */

  $fileName = dirname(__FILE__) ."/bottom_of_every_post.txt";

 /* we want to change `the_content` of posts, not pages
  and the text file must exist for this to work */

  if( !is_page( ) && file_exists( $fileName )){

  /* open the text file and read its contents */

   $theFile = fopen( $fileName, "r");
   $msg = fread( $theFile, filesize( $fileName ));
   fclose( $theFile );

  /* append the text file contents to the end of `the_content` */
   return $content . stripslashes( $msg );
  } else{

  /* if `the_content` belongs to a page or our file is missing
   the result of this filter is no change to `the_content` */

   return $content;
  }
 }

 /* add our filter function to the hook */

 add_filter('the_content', 'bottom_of_every_post');
}

?>
Reference Link

Friday 19 December 2014

how to Export Mysql database Using php script method-2

<?php
//export database

function export_tables($host,$user,$pass,$name,  $tables=false, $backup_name=false ){
   
    $link = mysqli_connect($host,$user,$pass,$name);
    // Check connection
    if (mysqli_connect_errno())   {
          echo "Failed to connect to MySQL: " . mysqli_connect_error();  
     }
     mysqli_select_db($link,$name);//select database
    mysqli_query($link,"SET NAMES 'utf8'");

    //get all of the tables
    if($tables === false){
        $tables = array();
        $result = mysqli_query($link,'SHOW TABLES');
        while($row = mysqli_fetch_row($result))
        {
            $tables[] = $row[0];
        }
    }else{
        $tables = is_array($tables) ? $tables : explode(',',$tables);
    }
    $return='';
    //cycle through
    foreach($tables as $table)
    {
        $result = mysqli_query($link,'SELECT * FROM '.$table);
        $num_fields = mysqli_num_fields($result);
        $row2 = mysqli_fetch_row(mysqli_query($link, 'SHOW CREATE TABLE '.$table));
        $return.= "\n\n".$row2[1].";\n\n";

        for ($i = 0; $i < $num_fields; $i++){
            $st_counter= 0;
            while($row = mysqli_fetch_row($result)){
                //create new command if when starts and after 100 command cycle
                if ($st_counter%100 == 0 || $st_counter == 0 )  {
                    $return.= "\nINSERT INTO ".$table." VALUES";
                }
                $return.="\n(";
                for($j=0; $j<$num_fields; $j++){
                    $row[$j] = addslashes($row[$j]);
                    $row[$j] = str_replace("\n","\\n",$row[$j]);
                    if (isset($row[$j])) { 
                            $return.= '"'.$row[$j].'"' ; 
                    } else {
                           $return.= '""'; 
                     }
                    if ($j<($num_fields-1)) { 
                           $return.= ','; 
                     }
                }
                $return.=")";
    //create new command if when starts and after 100 command cycle (but detect this 1 cycle earlier !)
     if ( ($st_counter+1)%100 == 0  && $st_counter != 0 )    {   
                      $return.= ";"; 
      }else{  
            $return.= ","; 
      }
          //+++++++
          $st_counter = $st_counter +1 ;
    }
       //as we cant detect WHILE loop end, so, just detect, if last command ends 
       //with comma(,) then replace it with semicolon(;)
       if (substr($return, -1) == ',') {
           $return = substr($return, 0, -1). ';'; 
       }
    }
        $return.="\n\n\n";
    }

    //save file
    $backup_name = $backup_name ? $backup_name : $name."___(".date('H-i-s')."_".date('d-m-Y').")__rand".rand(1,11111111).'.sql';
    file_put_contents($backup_name,$return);
    die('SUCCESS. Download BACKUP file: <a target="_blank" href="'.$backup_name.'">'.$backup_name.'</a> <br/><br/>After download, <a target="_blank" href="?delete_filee='.$backup_name.'">Delete it!</a> ');

}
$username = "s2TWrtD3KehO9R6";
$password = "BROGdzF5tN8qiavu";
$hostname = "repairwirelessca.netfirmsmysql.com";
$dbname="wordpress_cod2hb6526";
export_tables($hostname,$username,$password,$dbname);

?>

How to Export Mysql database Using php script method-1

<?php
function export_database_tables($host,$user,$pass,$name,  $tables=false, $backup_name=false )
{
    $link = mysqli_connect($host,$user,$pass,$name);
      if (mysqli_connect_errno()){
            echo "ConnecttError: " . mysqli_connect_error();
      }
     mysqli_select_db($link,$name);  mysqli_query($link,"SET NAMES 'utf8'");
     $queryTables = mysqli_query($link,'SHOW TABLES');

        while($row = mysqli_fetch_row($queryTables)) {
                 $target_tables[] = $row[0];
         }

       if($tables !== false) {
            $target_tables = array_intersect( $target_tables, explode(',',$tables));
        }

      $content='';    //start cycle
       foreach($target_tables as $table){
           $result = mysqli_query($link,'SELECT * FROM '.$table);
           $fields_amount = mysqli_num_fields($result);
           $rows_num=mysqli_num_rows($result);
           $row2= mysqli_fetch_row(mysqli_query($link, 'SHOW CREATE TABLE '.$table));
           $content    .= "\n\n".$row2[1].";\n\n";
            for ($i = 0; $i < $fields_amount; $i++) {
                     $st_counter= 0;
                     while($row = mysqli_fetch_row($result)) {
                      //when started (and every after 100 command cycle)
                       if ($st_counter%100 == 0 || $st_counter == 0 )  {
                            $content .= "\nINSERT INTO ".$table." VALUES";
                       }
                $content .= "\n(";
                for($j=0; $j<$fields_amount; $j++)  {
                    $row[$j] = str_replace("\n","\\n", addslashes($row[$j]) );
                    if (isset($row[$j])) {
                      $content .= '"'.$row[$j].'"' ;
                    } else {
                           $content .= '""';
                    }
                    if ($j<($fields_amount-1)) {
                          $content.= ',';
                    }
                }
        $content .=")";
        //every after 100 command cycle [or at last line] ....p.s. but should be inserted 1 cycle eariler
        if ( (($st_counter+1)%100==0 && $st_counter!=0) || $st_counter+1==$rows_num) {
                   $content .= ";";
        } else {
                 $content .= ",";
         }
         $st_counter=$st_counter+1;
     }
  }
    $content .="\n\n\n";
}

    //save file
    $backup_name = $backup_name ? $backup_name : $name."___(".date('H-i-s')."_".date('d-m-Y').")__rand".rand(1,11111111).".sql";

      header('Content-Type: application/octet-stream');
      header("Content-Transfer-Encoding: Binary");       
      header("Content-disposition: attachment; filename=\"".$backup_name."\"");
      echo $content; exit;
}

//pass hostname=localhost, username=root, password="",databasename=wpdb
export_database_tables("hostname","username","password","databasename");

?>