Friday 11 December 2015

count down timer javascript

<span id="countdown" class="timer"></span>
<?php
     
       $days_to_event = get_post_meta( get_the_ID(), 'days_to_event', true );  // days fetched from custom fields
        
       $final = $days_to_event*24*60*60;       
 
?>
<script>
var upgradeTime = <?php echo $final; ?>;
var seconds = upgradeTime;
function timer() {
    var days        = Math.floor(seconds/24/60/60);
    var hoursLeft   = Math.floor((seconds) - (days*86400));
    var hours       = Math.floor(hoursLeft/3600);
    var minutesLeft = Math.floor((hoursLeft) - (hours*3600));
    var minutes     = Math.floor(minutesLeft/60);
    var remainingSeconds = seconds % 60;
    if (remainingSeconds < 10) {
        remainingSeconds = "0" + remainingSeconds;
    }
    document.getElementById('countdown').innerHTML = days + "Days:" + hours + "Hours:" + minutes + "Minutes:" + remainingSeconds;
    if (seconds == 0) {
        clearInterval(countdownTimer);
        document.getElementById('countdown').innerHTML = "Completed";
    } else {
        seconds--;
    }
}
var countdownTimer = setInterval('timer()', 1000);
</script>

Thursday 10 December 2015

woocommerce add to cart button for product variations

//new code added here

function find_valid_variations() {
    global $product;

    $variations = $product->get_available_variations();
    $attributes = $product->get_attributes();
    $new_variants = array();

    // Loop through all variations
    foreach( $variations as $variation ) {

        // Peruse the attributes.

        // 1. If both are explicitly set, this is a valid variation
        // 2. If one is not set, that means any, and we must 'create' the rest.

        $valid = true; // so far
        foreach( $attributes as $slug => $args ) {
            if( array_key_exists("attribute_$slug", $variation['attributes']) && !empty($variation['attributes']["attribute_$slug"]) ) {
                // Exists

            } else {
                // Not exists, create
                $valid = false; // it contains 'anys'
                // loop through all options for the 'ANY' attribute, and add each
                foreach( explode( '|', $attributes[$slug]['value']) as $attribute ) {
                    $attribute = trim( $attribute );
                    $new_variant = $variation;
                    $new_variant['attributes']["attribute_$slug"] = $attribute;
                    $new_variants[] = $new_variant;
                }

            }
        }

        // This contains ALL set attributes, and is itself a 'valid' variation.
        if( $valid )
            $new_variants[] = $variation;

    }

    return $new_variants;
}






function woocommerce_variable_add_to_cart(){
    global $product, $post;

    $variations = find_valid_variations();

    // Check if the special 'price_grid' meta is set, if it is, load the default template:
    if ( get_post_meta($post->ID, 'price_grid', true) ) {
        // Enqueue variation scripts
        wp_enqueue_script( 'wc-add-to-cart-variation' );

        // Load the template
        wc_get_template( 'single-product/add-to-cart/variable.php', array(
                'available_variations'  => $product->get_available_variations(),
                'attributes'            => $product->get_variation_attributes(),
                'selected_attributes'   => $product->get_variation_default_attributes()
            ) );
        return;
    }

    // Cool, lets do our own template!
    ?>
    <table class="variations variations-grid" cellspacing="0">
        <tbody>
            <?php
            foreach ($variations as $key => $value) {
                if( !$value['variation_is_visible'] ) continue;
            ?>
            <tr>
                <td>
                    <?php foreach($value['attributes'] as $key => $val ) {
                        $val = str_replace(array('-','_'), ' ', $val);
                        printf( '<span class="attr attr-%s">%s</span>', $key, ucwords($val) );
                    } ?>
                </td>
                <td>
                    <?php echo $value['price_html'];?>
                </td>
                <td>
                    <?php if( $value['is_in_stock'] ) { ?>
                    <form class="cart" action="<?php echo esc_url( $product->add_to_cart_url() ); ?>" method="post" enctype='multipart/form-data'>
                        <?php woocommerce_quantity_input(); ?>
                        <?php
                        if(!empty($value['attributes'])){
                            foreach ($value['attributes'] as $attr_key => $attr_value) {
                            ?>
                            <input type="hidden" name="<?php echo $attr_key?>" value="<?php echo $attr_value?>">
                            <?php
                            }
                        }
                        ?>
                        <button type="submit" class="single_add_to_cart_button btn btn-primary"><span class="glyphicon glyphicon-tag"></span> Add to cart</button>
                        <input type="hidden" name="variation_id" value="<?php echo $value['variation_id']?>" />
                        <input type="hidden" name="product_id" value="<?php echo esc_attr( $post->ID ); ?>" />
                        <input type="hidden" name="add-to-cart" value="<?php echo esc_attr( $post->ID ); ?>" />
                    </form>
                    <?php } else { ?>
                        <p class="stock out-of-stock"><?php _e( 'This product is currently out of stock and unavailable.', 'woocommerce' ); ?></p>
                    <?php } ?>
                </td>
            </tr>
            <?php } ?>
        </tbody>
    </table>
    <?php
}

add custom field in products page

http://www.themelocation.com/how-to-display-custom-field-value-on-product-page-in-woocommerce/

show all posts in one page code template

<?php
/**
 * Template Name: All Blog Page
 */

get_header(); ?>
<div class="container">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 margbtm">
        <?php
            query_posts( 'cat=1' );
            while ( have_posts() ) : the_post();?>
           
            <div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
                    <img class="video" <?php the_post_thumbnail('medium');?>
                <h4 class="title">
                          <a href="<?php the_permalink(); ?>"><?php the_title();?></a>
                </h4>
                    <h4 class="title"><?php the_content();?></h4>
            </div>
          <?php endwhile; ?>
        <?php wp_reset_query();?>
</div>
</div>
</div>
<?php get_footer(); ?>

Tuesday 17 November 2015

PDF button for a non-public web page

just put this script one button will be generated for password protected pages use this one.
<a href="//FreeHTMLtoPDF.com/?convert&iconsize=32&localhtml=1&formdata=1"><img src="//FreeHTMLtoPDF.com/images/apiicon_32.png" /></a><script type="text/javascript" src="//FreeHTMLtoPDF.com/scripts/api.js" />


link - http://freehtmltopdf.com/

Monday 26 October 2015

pdf to text conversion code


  $text = pdf2text("sample.pdf");
 
  echo $text;


function decodeAsciiHex($input) {
    $output = "";

    $isOdd = true;
    $isComment = false;

    for($i = 0, $codeHigh = -1; $i < strlen($input) && $input[$i] != '>'; $i++) {
        $c = $input[$i];

        if($isComment) {
            if ($c == '\r' || $c == '\n')
                $isComment = false;
            continue;
        }

        switch($c) {
            case '\0': case '\t': case '\r': case '\f': case '\n': case ' ': break;
            case '%':
                $isComment = true;
            break;

            default:
                $code = hexdec($c);
                if($code === 0 && $c != '0')
                    return "";

                if($isOdd)
                    $codeHigh = $code;
                else
                    $output .= chr($codeHigh * 16 + $code);

                $isOdd = !$isOdd;
            break;
        }
    }

    if($input[$i] != '>')
        return "";

    if($isOdd)
        $output .= chr($codeHigh * 16);

    return $output;
}
function decodeAscii85($input) {
    $output = "";

    $isComment = false;
    $ords = array();
   
    for($i = 0, $state = 0; $i < strlen($input) && $input[$i] != '~'; $i++) {
        $c = $input[$i];

        if($isComment) {
            if ($c == '\r' || $c == '\n')
                $isComment = false;
            continue;
        }

        if ($c == '\0' || $c == '\t' || $c == '\r' || $c == '\f' || $c == '\n' || $c == ' ')
            continue;
        if ($c == '%') {
            $isComment = true;
            continue;
        }
        if ($c == 'z' && $state === 0) {
            $output .= str_repeat(chr(0), 4);
            continue;
        }
        if ($c < '!' || $c > 'u')
            return "";

        $code = ord($input[$i]) & 0xff;
        $ords[$state++] = $code - ord('!');

        if ($state == 5) {
            $state = 0;
            for ($sum = 0, $j = 0; $j < 5; $j++)
                $sum = $sum * 85 + $ords[$j];
            for ($j = 3; $j >= 0; $j--)
                $output .= chr($sum >> ($j * 8));
        }
    }
    if ($state === 1)
        return "";
    elseif ($state > 1) {
        for ($i = 0, $sum = 0; $i < $state; $i++)
            $sum += ($ords[$i] + ($i == $state - 1)) * pow(85, 4 - $i);
        for ($i = 0; $i < $state - 1; $i++)
            $ouput .= chr($sum >> ((3 - $i) * 8));
    }

    return $output;
}
function decodeFlate($input) {
    return @gzuncompress($input);
}

function getObjectOptions($object) {
    $options = array();
    if (preg_match("#<<(.*)>>#ismU", $object, $options)) {
        $options = explode("/", $options[1]);
        @array_shift($options);

        $o = array();
        for ($j = 0; $j < @count($options); $j++) {
            $options[$j] = preg_replace("#\s+#", " ", trim($options[$j]));
            if (strpos($options[$j], " ") !== false) {
                $parts = explode(" ", $options[$j]);
                $o[$parts[0]] = $parts[1];
            } else
                $o[$options[$j]] = true;
        }
        $options = $o;
        unset($o);
    }

    return $options;
}
function getDecodedStream($stream, $options) {
    $data = "";
    if (empty($options["Filter"]))
        $data = $stream;
    else {
        $length = !empty($options["Length"]) ? $options["Length"] : strlen($stream);
        $_stream = substr($stream, 0, $length);

        foreach ($options as $key => $value) {
            if ($key == "ASCIIHexDecode")
                $_stream = decodeAsciiHex($_stream);
            if ($key == "ASCII85Decode")
                $_stream = decodeAscii85($_stream);
            if ($key == "FlateDecode")
                $_stream = decodeFlate($_stream);
        }
        $data = $_stream;
    }
    return $data;
}
function getDirtyTexts(&$texts, $textContainers) {
    for ($j = 0; $j < count($textContainers); $j++) {
        if (preg_match_all("#\[(.*)\]\s*TJ#ismU", $textContainers[$j], $parts))
            $texts = array_merge($texts, @$parts[1]);
        elseif(preg_match_all("#Td\s*(\(.*\))\s*Tj#ismU", $textContainers[$j], $parts))
            $texts = array_merge($texts, @$parts[1]);
    }
}
function getCharTransformations(&$transformations, $stream) {
    preg_match_all("#([0-9]+)\s+beginbfchar(.*)endbfchar#ismU", $stream, $chars, PREG_SET_ORDER);
    preg_match_all("#([0-9]+)\s+beginbfrange(.*)endbfrange#ismU", $stream, $ranges, PREG_SET_ORDER);

    for ($j = 0; $j < count($chars); $j++) {
        $count = $chars[$j][1];
        $current = explode("\n", trim($chars[$j][2]));
        for ($k = 0; $k < $count && $k < count($current); $k++) {
            if (preg_match("#<([0-9a-f]{2,4})>\s+<([0-9a-f]{4,512})>#is", trim($current[$k]), $map))
                $transformations[str_pad($map[1], 4, "0")] = $map[2];
        }
    }
    for ($j = 0; $j < count($ranges); $j++) {
        $count = $ranges[$j][1];
        $current = explode("\n", trim($ranges[$j][2]));
        for ($k = 0; $k < $count && $k < count($current); $k++) {
            if (preg_match("#<([0-9a-f]{4})>\s+<([0-9a-f]{4})>\s+<([0-9a-f]{4})>#is", trim($current[$k]), $map)) {
                $from = hexdec($map[1]);
                $to = hexdec($map[2]);
                $_from = hexdec($map[3]);

                for ($m = $from, $n = 0; $m <= $to; $m++, $n++)
                    $transformations[sprintf("%04X", $m)] = sprintf("%04X", $_from + $n);
            } elseif (preg_match("#<([0-9a-f]{4})>\s+<([0-9a-f]{4})>\s+\[(.*)\]#ismU", trim($current[$k]), $map)) {
                $from = hexdec($map[1]);
                $to = hexdec($map[2]);
                $parts = preg_split("#\s+#", trim($map[3]));
               
                for ($m = $from, $n = 0; $m <= $to && $n < count($parts); $m++, $n++)
                    $transformations[sprintf("%04X", $m)] = sprintf("%04X", hexdec($parts[$n]));
            }
        }
    }
}
function getTextUsingTransformations($texts, $transformations) {
    $document = "";
    for ($i = 0; $i < count($texts); $i++) {
        $isHex = false;
        $isPlain = false;

        $hex = "";
        $plain = "";
        for ($j = 0; $j < strlen($texts[$i]); $j++) {
            $c = $texts[$i][$j];
            switch($c) {
                case "<":
                    $hex = "";
                    $isHex = true;
                break;
                case ">":
                    $hexs = str_split($hex, 4);
                    for ($k = 0; $k < count($hexs); $k++) {
                        $chex = str_pad($hexs[$k], 4, "0");
                        if (isset($transformations[$chex]))
                            $chex = $transformations[$chex];
                        $document .= html_entity_decode("&#x".$chex.";");
                    }
                    $isHex = false;
                break;
                case "(":
                    $plain = "";
                    $isPlain = true;
                break;
                case ")":
                    $document .= $plain;
                    $isPlain = false;
                break;
                case "\\":
                    $c2 = $texts[$i][$j + 1];
                    if (in_array($c2, array("\\", "(", ")"))) $plain .= $c2;
                    elseif ($c2 == "n") $plain .= '\n';
                    elseif ($c2 == "r") $plain .= '\r';
                    elseif ($c2 == "t") $plain .= '\t';
                    elseif ($c2 == "b") $plain .= '\b';
                    elseif ($c2 == "f") $plain .= '\f';
                    elseif ($c2 >= '0' && $c2 <= '9') {
                        $oct = preg_replace("#[^0-9]#", "", substr($texts[$i], $j + 1, 3));
                        $j += strlen($oct) - 1;
                        $plain .= html_entity_decode("&#".octdec($oct).";");
                    }
                    $j++;
                break;

                default:
                    if ($isHex)
                        $hex .= $c;
                    if ($isPlain)
                        $plain .= $c;
                break;
            }
        }
        $document .= "\n";
    }

    return $document;
}

function pdf2text($filename) {
    $infile = @file_get_contents($filename, FILE_BINARY);
    if (empty($infile))
        return "";

    $transformations = array();
    $texts = array();

    preg_match_all("#obj(.*)endobj#ismU", $infile, $objects);
    $objects = @$objects[1];

    for ($i = 0; $i < count($objects); $i++) {
        $currentObject = $objects[$i];

        if (preg_match("#stream(.*)endstream#ismU", $currentObject, $stream)) {
            $stream = ltrim($stream[1]);

            $options = getObjectOptions($currentObject);
            if (!(empty($options["Length1"]) && empty($options["Type"]) && empty($options["Subtype"])))
                continue;

            $data = getDecodedStream($stream, $options);
            if (strlen($data)) {
                if (preg_match_all("#BT(.*)ET#ismU", $data, $textContainers)) {
                    $textContainers = @$textContainers[1];
                    getDirtyTexts($texts, $textContainers);
                } else
                    getCharTransformations($transformations, $data);
            }
        }
    }

    return getTextUsingTransformations($texts, $transformations);
}

Thursday 15 October 2015

image upload related

<?
 if($_FILES['file']['name'] != ""){
      //upload the image with what ever you want
      //move_uploaded_file($_FILES['file']['tmp_name'],$target.$image );
      //the SQL query should contain the updating the image column
         if(($_GET['mod']=='edit') && (isset($_POST['hidden'])))
         {   
           echo $_FILES["file"]["name"];
    $allowedExts = array("jpg", "jpeg", "gif", "png");
    $extension = end(explode(".", $images));
    if ((($_FILES["file"]["type"] == "image/gif")  || ($_FILES["file"]["type"]   == "image/jpeg") || ($_FILES["file"]["type"]   == "image/png") || ($_FILES["file"]["type"]   == "image/pjpeg")) && in_array($extension, $allowedExts)){  
    if ($_FILES["file"]["error"] > 0){

               echo $_FILES["file"]["error"] . "<br>";
      }
      else{
        move_uploaded_file($_FILES["file"]["tmp_name"], "upload-images/" . $images);
        $update="UPDATE headline SET headline_title  = '$title',headline_des = '$description',month= '$month_name', day= '$day_name', images = '$images' where id = ".$_GET['id']."";
         $result = mysql_query($update);   

          }
        }
}
else
{
      //SQL update without image
        $update="UPDATE headline SET headline_title  = '$title',   headline_des    = '$description',   headline        = '$headline'   WHERE id        = ".$_GET['id']."";
         $result = mysql_query($update);   

}

Tuesday 6 October 2015

Yii realted information

 steps are as follows -


 1. download yii

 2. go to enviornment variable set path of php folder
    example- C:/xampp/php;
  
 3. now go to command prompt and type - go inside -
    c/xampp/htdocs/yii/framework/ - here yiic.bat exists.

 4. /yiic webapp WebRoot/testapp  now access it - http://hostname/testapp/index.php

 5. To use Gii in Yii. go to My protected/config/main.php and uncomment the code
    for gii.


 controllers\admin\UserController.php
 views\admin\user\index.php
 models\Users.php




Just Custom Fields ----------
 $result_one = get_post_meta($post->ID, '_video_upload', true);
       print_r($result_one);

Sunday 4 October 2015

Latest Projects

website links -
1. Redhillfresh.com.au/
2. http://staineaters.com.au/   - Page builder
3. http://aussieiconsonline.com.au/
4. http://workslocal.com.au/  -- theme page builder
5. albasir.in  - Magento site
6. axtturbo.com.au
7. b-at-home.com.au
8. graffitieaters.com.au
9. memorykeepsake.com.au  - woocommerce work product add on
10.i-imagine.com.au
11.wallpapers.com.au
12.http://goldkeyinsurance.co.in/

Wednesday 9 September 2015

PDO statements



How to query in mysql with PDO concept-
Write a query in a variable.
Pass variable in conn – prepare syntax is - $this->conn->prepare($query)
Then bind variable for where condition using function bundParam(1,$this->id)
Finaly execute statement using function execute.
Procedure as follows –
 1 . $query = “DELETE FROM”.$this->table_name.”WHERE id = ?”;
 2. $stmt = $this->conn->prepare($query);
3.  $stmt->bindParams(1,$this->id)
4.  $stmt->execute()

For  fetching  values –
  $query = "SELECT name, price, description, category_id FROM " . $this->table_name . " WHEREid = ?LIMIT 0,1";
 $stmt = $this->conn->prepare( $query );
 $stmt->bindParam(1, $this->id);
 $stmt->execute();
 $row = $stmt->fetch(PDO::FETCH_ASSOC);
 $this->name = $row['name'];
 extract($row);
  echo "{$name}";

Wednesday 22 July 2015

taking values from jquery data or rel or attribute

<script type="text/javascript">
function find_out_property(){
    var srcimg = jQuery(this).find('.property-info :img').attr('src');
    var title = jQuery(this).find('property-title').val();
    jQuery('.property-img-form').attr('src',srcimg);
    jQuery('.propert-title-form').val(title);
    jQuery('#property-model').modal();
}

    jQuery(document).ready(function(){
        jQuery('.property-slider').bxSlider();
       
        jQuery( ".property_form" ).each(function( index ) {
            console.log( jQuery(this).attr("rel") );
           jQuery("#field_property_detail", jQuery(this)).val(jQuery(this).attr("rel"));
           jQuery("#field_property_link", jQuery(this)).val(jQuery(this).attr("data"));
           jQuery("#field_property_name_detail", jQuery(this)).val(jQuery(this).attr("datainfo"));
           jQuery("#field_property_pdf", jQuery(this)).val(jQuery(this).attr("datainfo2"));
        });
      
       
             jQuery(".prop-images a").on('click', function(e) {
                  e.preventDefault();
                 //alert('#'+jQuery(this).attr('rel'));
                 //alert(jQuery(this).attr('href'));
                 jQuery('.'+jQuery(this).attr('rel')).css('background-image', 'url(' + jQuery(this).attr('href') + ')');
                 jQuery('.prop-images a').removeClass('active');
                 jQuery(this).addClass('active');
                 return false;
            });

    });
                                   
</script>
-----------------------------------------------------------------------------------------------
<div class="col-md-4 property_form" rel="<?php echo $post->ID; ?>" data="<?php echo the_permalink();?>" datainfo="<?php the_title(); the_content();?>" datainfo2="<a href='<?php echo @$file_download[0][image]; ?>'>Subrub report</a>">
                           

applying captcha anywhere in form google captcha

add_action( 'wp_login_failed', 'pippin_login_fail' );  // hook failed login

function pippin_login_fail( $username ) {
      
        global $wbdb;
   
     $userdata = get_user_by( 'login', $username );
   
     $meta = get_user_meta($userdata->ID, 'theme_my_login_security', true );
  
   if ( ! is_array( $meta ) )
           $meta = array();
   
    if(sizeof($meta['failed_login_attempts'] ) > 1){
       
       
    ?>
         <script src="https://www.google.com/recaptcha/api.js" async defer></script>
           <script type="text/javascript">
            jQuery('.g-recaptcha').show();

           </script>
    <?php
         
    }

   
}
add_filter('wp_authenticate_user', 'verify_login_captcha', 10, 2);
       
function verify_login_captcha($user, $password) {

    if (isset($_POST['g-recaptcha-response'])) {
        $recaptcha_secret = '6LfkBpNteuL6rHOViv9';
        echo $_POST['g-recaptcha-response'];
        echo "<br/>";
        $response = wp_remote_get("https://www.google.com/recaptcha/api/siteverify?secret=". $recaptcha_secret ."&response=". $_POST['g-recaptcha-response']);
        print_r($response);
        $response = json_decode($response["body"], true);
       
       
       
       
        if (true == $response["success"]) {
            return $user;
        } else {
            return new WP_Error("Captcha Invalid", __("You are required to check security verification"));
        }
       
    } else {
       
        return $user;
        //return new WP_Error("Captcha Invalid", __("<strong>ERROR</strong>: You are a bot. If not then enable JavaScript"));
    }  
}
---------------------------------------------------------------------
 <div class="clear"></div>
        <div class="g-recaptcha" data-sitekey="6LfkKwoTAAA1r7mO3d67rZnJu3"></div>

Monday 6 July 2015

URL Rewriting in wordpress

Let's say I have a Wordpress blog: www.animals.com I have a certain PHP file in my theme directory: www.animals.com/wp-content/themes/mytheme/db.php Also, I have a custom template for that page, so I create a new page in the Wordpress administration panel to show db.phpwww.animals.com/database So if I want to read something about lions, I just go to: www.animals.com/database/?animal=lion(because that's the way I decided to write the PHP, inserting the value from $_GET['animal'] into the query, using PDO blah blah..)
Now, I would like to access www.animals.com/database/?animal=lion as www.animals.com/lion
Should I use .htaccess or Wordpress Rewrite?
you need to call $wp_query->query_vars['dios'] so i added this to my theme's functions.php
function add_query_vars($new_var) {
$new_var[] = "dios";
return $new_var;
}
add_filter('query_vars', 'add_query_vars');

function add_rewrite_rules($rules) {
$new_rules = array('([^/]+)' => 'index.php?pagename=dios&dios=$matches[1]');
$rules = $new_rules + $rules;
return $rules;
}
add_filter('rewrite_rules_array', 'add_rewrite_rules');

Wednesday 1 July 2015

Multipurpose Plugin Add Edit Enjoy

<?php
ob_start();
/*
Plugin Name:Madhukar
Plugin URI: localhost
Description: Declares a plugin that will create a custom post type displaying movie reviews.
Version: 1.0
Author: a1
Author URI:Localhost
License: GPLv2
*/
?>
<?php
function create_menu() {

add_menu_page('cm panel', 'Resigistration', '',  __FILE__, 'settings_page');

add_submenu_page(  __FILE__, 'New_Resigistration', 'New_Resigistration', 'manage_options', 'my-submenu-handle1','settings_page');

add_submenu_page(  __FILE__, 'User_Details', 'User_Details', 'manage_options', 'my-submenu-handle2','section_1');

add_submenu_page(  __FILE__, '', '', 'manage_options', 'my-submenu-handle3','section_2');

}


function settings_page()
{
include('upload1.php');
}

function section_1()
{
include('floor_image.php');
}


function section_2()
{

   $gid=$_GET['id'];

$a="select * from wp_usersinfo where id=$gid";
$res=mysql_query($a);
?>
<form action="" method="post" class="regty" enctype="multipart/form-data">
<?php
while($row=mysql_fetch_array($res)){
?>
<div class="nn1"><span class="lab1">Name</span> <input type="text" name="name_2" value="<?php echo $row['name'];?>"/></div>
<div class="nn1"><span class="lab1">About us</span><textarea cols="59" rows="5" name="about_us_2"><?php echo $row['aboutus'];?></textarea></div>
<div class="nn1"><span class="lab1">Upload Profile image</span><input type="file" name="Photo2" />
<img src="<?php echo bloginfo('template_url').'/images/'.$row['image_name']; ?>" width="125" height="100">
</div>
<div class="nn1"><input type="submit" name="update" value="Update" class="subtn"></div>
<?php
}
?>
</form>

<?php


if(isset($_POST['update'])){
$uploadDir = get_template_directory().'/images/';
$fileName = $_FILES['Photo2']['name'];
$tmpName = $_FILES['Photo2']['tmp_name'];
$fileSize = $_FILES['Photo2']['size'];
$fileType = $_FILES['Photo2']['type'];
$filePath = $uploadDir.$fileName;
$livepath=bloginfo('template_url').'/images/'.$fileName;
$result = move_uploaded_file($tmpName, $filePath);
$a="UPDATE wp_usersinfo SET name='".$_POST['name_2']."'
,image_name='".$fileName."',
image_path='".$filePath."',
aboutus='".$_POST['about_us_2']."'
where id='$gid'";
mysql_query($a) or die(mysql_error());
$admin = admin_url();
header('location:'.$admin.'admin.php?page=my-submenu-handle2');
         }
    }
?>
<?php

/*
function myplugin_activate()
{
global $wpdb;

global $usersinfo_table;

$usersinfo_table = 'wp_usersinfo';

$sql= "CREATE TABLE $table
(id INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
name VARCHAR(250),
image_name VARCHAR( 250 ) NULL ,
image_path VARCHAR( 250 ) NULL ,
aboutus MEDIUMTEXT NULL ,
 )";

require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);

} */

register_activation_hook( __FILE__, 'myplugin_activate' );
add_action('admin_menu','create_menu');

?>

=============================================================

<style>
.nn1{ float: left;padding: 7px 0; width: 100%;}.nn1 span.lab1 {float: left;width: 14%;}.nn1 input, .nn1 textarea {float: right;margin-right: 2%;width: 80%;}.lab1 input[type="radio"] {float: right; width: auto;}selectorSavingError {
}
</style>
<div class="wrap">
<h2>Registration Form</h2>
</div>
<form action="" method="post" class="regty" enctype="multipart/form-data">
<div class="nn1"><span class="lab1">Name</span> <input type="text" name="name_1" /></div>
<div class="nn1"><span class="lab1">About us</span><textarea cols="59" rows="5" name="about_us_1"></textarea></div>
<div class="nn1"><span class="lab1">Upload Profile image</span><input type="file" name="Photo" /></div>
<div class="nn1"><input type="submit" name="submit" value="submit" class="subtn"></div>
</form>
<?php        
$_POST['Photo'];
$about=$_POST['about_us_1'];
   $name=$_POST['name_1'];

if(isset($_POST['submit']))
{
$imgp=$_POST['Photo'];
$name=$_POST['name_1'];
$url=bloginfo('template_url');
$uploadDir = get_template_directory().'/images/';
$fileName = $_FILES['Photo']['name'];
$tmpName = $_FILES['Photo']['tmp_name'];
$fileSize = $_FILES['Photo']['size'];
$fileType = $_FILES['Photo']['type'];
$filePath = $uploadDir.$fileName;
$livepath=bloginfo('template_url').'/images/'.$fileName;
$result = move_uploaded_file($tmpName, $filePath);


if (!$result) {
echo "Error uploading file";
//exit;
}

if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
$filePath = addslashes($filePath);
}

$table="wp_usersinfo";
echo $a="insert into wp_usersinfo set name='".$name."' ,
image_name='".$fileName."',
image_path='".$filePath."',
aboutus='".$about."'";
mysql_query($a) or die(mysql_error());
$admin = admin_url();

header('location:'.$admin.'admin.php?page=my-submenu-handle2');
}

================================================================

<?php

include('../../../wp-config.php');
$admin = admin_url();
$uid=$_GET['id'];
$table = 'wp_usersinfo';
$del=mysql_query("DELETE FROM $table WHERE id=$uid");
header('location:'.$admin.'admin.php?page=my-submenu-handle2');
?>

====================================================================

<table border="2">
<tr><th>Id</th>
<th>Name</th>
<th>About us</th>
<th>Image</th>
</tr>
<?php
$admin = admin_url();
$url = plugins_url();
$s="select * from wp_usersinfo";
$result=mysql_query($s);
while($row=mysql_fetch_array($result))
{
echo '<tr><td>'.$row['id'].'</td><td>'.$row['name'].'</td><td>'.$row['aboutus'].'</td><td><img  width="100px" height="100px" src="http://localhost:90/wordpress/wp-content/themes/twentyfourteen/images/'.$row['image_name'].'"/>';
?>
<td>
<a href="<?php echo $admin.'admin.php?page=my-submenu-handle3&id='.$row['id'];?>"><input type="button" name="edit" value="Edit"><a></td>
<td>
<a href="<?php echo $url.'/madhukar/delete.php?id='.$row['id'];?>"><input type="button" name="Delete" value="Delete" ></a>
</td>

</tr>
<?php
}
?>
</table>

==================================================================

Thursday 18 June 2015

organize css into proper way online

http://www.styleneat.com/

http://ctrlq.org/beautifier/


http://www.freeformatter.com/html-formatter.html

Tuesday 16 June 2015

fetching data from std class object

stdClass Object
(
    [ABRPayloadSearchResults] => stdClass Object
        (
            [request] => stdClass Object
                (
                    [identifierSearchRequest] => stdClass Object
                        (
                            [identifierType] => ABN
                            [identifierValue] => johnsmith
                            [history] => N
                        )

                )

            [response] => stdClass Object
                (
                    [dateRegisterLastUpdated] => 0001-01-01
                    [dateTimeRetrieved] => 2015-06-16T21:19:38.3159717+10:00
                    [exception] => stdClass Object
                        (
                            [exceptionDescription] => Search text is not a valid ABN or ACN
                            [exceptionCode] => WEBSERVICES
                        )

                )

        )

)
this result coming in variable print_r($results)   so fetching particular values -

 echo $result->ABRPayloadSearchResults->request->identifierSearchRequest->identifierType;

echo $result->ABRPayloadSearchResults->response->exception->exceptionDescription;

Thursday 14 May 2015

Domains related information

ICANN, the Internet Corporation for Assigned Names and

Numbers. It's a consortium (non-profit corporation) that

manages the assignment of domain names and IP address

ranges on behalf of the community.
https://www.icann.org/


When registered, your domain name will be immediately

stored in the public WHOIS database. Some of your details

will become available to the general  public immediately after.


A domain name registrar is an organization or commercial

entity that manages the reservation of Internet domain

names. A domain name registrar must be accredited by a

generic top-level domain (gTLD) registry and/or a country

code top-level domain (ccTLD) registry. The management is

done in accordance with the guidelines of the designated

domain name registries.


The Domain Name System is a distributed database, but there

are central name servers at the core of the system (see How

DNS Works for details). Someone has to maintain these

central name servers to avoid conflicts and duplication.

In 1993, the U.S. Department of Commerce, in conjunction

with several public and private entities, created InterNIC to

maintain a central database that contains all the registered

domain names and the associated IP addresses in the U.S.

(other countries maintain their own NICs (Network Information

Centers) -- there's a link below that discusses Canada's

system, for example). Network Solutions, a member of

InterNIC, was chosen to administer and maintain the growing

number of Internet domain names and IP addresses. This

central database is copied to Top Level Domain (TLD) servers

around the world and creates the primary routing tables used

by every computer that connects to the Internet.

A WHOIS search will provide information regarding a domain

name, such as example.com. It may include information, such

as domain ownership, where and when registered, expiration

date, and the nameservers assigned to the domain.

Wednesday 13 May 2015

Pay pal auto return settings process


    Auto Return is turned off by default. To turn on Auto Return:

 1. Log in to your PayPal account at https://www.paypal.com. The My Account Overview page appears.
 2.  Click the Profile subtab. The Profile Summary page appears.
 3.  Click the My Selling Tools link in the left column.
 4.  Under the Selling Online section, click the Update link in the row for Website Preferences. The Website Payment Preferences page appears
 5. Under Auto Return for Website Payments, click the On radio button to enable Auto Return.
 6.  In the Return URL field, enter the URL to which you want your payers redirected after they complete their payments. NOTE: PayPal checks the Return URL that you enter. If the URL is not properly formatted or cannot be validated, PayPal will not activate Auto Return.
7.    Scroll to the bottom of the page, and click the Save button.

 Pay pal Payment integration complete process -
 Put this form on your payment page - STEP 1 -
        $paypal_url='https://www.paypal.com/cgi-bin/webscr'; // Test Paypal API URL
        $paypal_id='abcd@gmail.com'; // Business email ID

       $paypal_url='https://www.sandbox.paypal.com/cgi-bin/webscr'; // Test Paypal API URL
       $paypal_id='m@snrinfotech.com'; // Business email ID


 <form method="post" action='<?php echo $paypal_url; ?>'>
         <input type='hidden' name='business' value='<?php echo $paypal_id; ?>'>   
        <input type='hidden' name='cmd' value='_xclick'>
          <br/>
         <input type='hidden' name='item_name' value='Tour-package'>
           <input type='hidden' name='item_number' value='001'>
         <input type='hidden' name='amount' value='<?php echo $amount; ?>'>
         <input type='hidden' name='rest_amount' value='<?php echo $rest_amount; ?>'>
         <input type='hidden' name='cancel_return' value='<?php echo $site_url;?>/cancel'>
         <input type='hidden' name='custemail' value='<?php echo $email; ?>'>
         <input type="hidden" name="rm" value="2">
         <input type="submit" class="sbt-btn-book" name="member-submit" class="sub-btn" value="Submit">
       </form>

Paypal returns all your variables in post form so print_r($_POST) and you will get all data required.

STEP - 2 ----
Make success page and cancel page.
//print_r($_POST);   
        $email = $_POST['payer_email'];
        $got_payment = $_POST['mc_gross'];

and message payment successful.

STEP 3.
cancel page
<h1>Your Payment is cancelled.Please Try Again</h1>