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.