Saturday, 20 January 2018

some projects with website url details





Other Projects :

1.Redhillfresh.com.au/
2. http://staineaters.com.au/
3. http://aussieiconsonline.com.au/
4. http://workslocal.com.au/
5. albasir.in
6. axtturbo.com.au
7. b-at-home.com.au
8. graffitieaters.com.au
9. memorykeepsake.com.au
10.i-imagine.com.au
11.wallpapers.com.au
12.http://goldkeyinsurance.co.in/
13.http://www.mammalena.info/
14. http://hillcrestfarmmarket.com/
15. http://beckyfox.com
16. http://www.swimava.com/
17. https://revyrealty.com/
18. http://www.kelownamartialarts.com/
19. http://www.thepondsbellevue.ca/
20. http://siciliana.it/sicilywine/
21. http://www.talkingimage.co.uk/
22. http://www.cuttingedgeconcepts.ca/
23. http://www.kellyobryans.com/
24. http://www.skiwest.ca/
25. http://www.thecreekskelowna.ca/
26.http://www.missiongroup.ca/
27. http://bettselectric.com/
28. http://www.sports-ville.in/
29. http://outlawsonline.com/
30 . http://christianprisonpenpals.org/

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(); ?>

Monday, 30 November 2015

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');