×

php up to date

Create tag for website using google tag manager

Create tag for website using google tag manager

1. Visit https://tagmanager.google.com/

  
After this you can get code to attach your website under body opening tag
 2. Create tag using tag button
3. Once created tag publish the tag.
4. You can trigger those tags using trigger menu over there also.


If you have any doubt leave message over here


Custom robots header tags settings in blogger

Custom robots header tags settings in blogger

It is very easy to handle these settings, you just need to follow these steps:
  • Login to blogger.com
  • Select your required blog from the list
  • Click on the Settings button and select Search preferences from the list.
  • Click on the Edit link next to the Custom Robots Header Tags section.
  • Select Yes to enable this option.
  • And follow the image below to solve this multiple choice options.


  

If you have any queries leave here feedback i will touch you soon

Check IP Under spam listed or not using php

Check IP Under spam listed or not using php

 

$host = "156.200.53.65";

$rbl  = 'sbl-xbl.spamhaus.org';
// valid query format is: 156.200.53.65.sbl-xbl.spamhaus.org
$rev = array_reverse(explode('.', $host));

$lookup = implode('.', $rev) . '.' . $rbl;

if ($lookup != gethostbyname($lookup)) {
   ?>
   <span style="color:red;"><?php echo "IP: $host is listed in $rbl\n"; ?></span>
<?php    echo "<br/>";
} else {
    echo "IP: $host NOT listed in $rbl\n";
    echo "<br/>";

 Just pass your ip address and find whether it comes unders spam list or not using spamhaus. If you need to fine bulk ip just post ip in the loop and get bulk result.

Find whois domain

Find whois domain 

 

<?
require("whoisClass.php");
$whois=new Whois;
$domain=$_POST['domain'];
?>

<form class="form-inline" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
                    <button type="submit" class="btn btn-primary rounded">Find</button>
                    <div class="form-group">
                        <input type="text" name="domain" class="form-control rounded" id="exampleInputEmail2" placeholder="Domain Name">
                    </div>
                </form>
<?php if(isset($domain)){echo nl2br($whois->whoislookup($domain));} ?>
Here nl2br   Inserts HTML line breaks before all newlines in a string.

Remove Category from home page osclass

Remove Category from home page  osclass

 

Open theme folder and edit functions.php file,
 find out h1 tag with categories under div with class name row 
remove from there  to closing tab of row div...
that's all categories now removed from your home page completely. 
Eg:
   <h1 class="title"><?php _e('Categories', OSCLASSWIZARDS_THEME_FOLDER);?></h1>
<div class="row">
<?php

    $total_categories   = osc_count_categories();
    $col1_max_cat       = ceil($total_categories/1);
    osc_goto_first_category();
    $catcount    =    0;
    while ( osc_has_categories() ) {
?>
<ul class="col-sm-6 col-md-3 grid_list">
  <li>
   -----
   -----
</li></ul>
<?php } ?>
</div>
It will change based on your theme. Mostly common.some customized themes may different.

Find WHOIS Domain

Find WHOIS Domain


<?
require("whoisClass.php");
$whois=new Whois;
echo $whois->whoislookup("google.com");
?>

Download WhoisClass.php From 
http://99webtools/php-whois-script.php

PHP Question And Answers

PHP Question And Answers



1. What is the importance of "action" attribute in a html form?
ANS: The action attribute determines where to send the form-data in the form submission.

2. Distinguish between urlencode and urldecode?
ANS: This method is best when encode a string to used in a query part of a url. it returns a string in which all non-alphanumeric characters except -_. have replece with a percentege(%) sign . the urldecode->Decodes url to encode string as any %and other symbole are decode by the use of the urldecode() function.

3. what is sql injection ?
ANS: SQL injection is a malicious code injection technique.It exploiting SQL vulnerabilities in Web applications

4. What is the difference between $var and $$var?
ANS: They are both variables. But $var is a variable with a fixed name. $$var is a variable who's name is stored in $var. For example, if $var contains "message", $$var is the same as $message.
EXPLAIN:
  $var is a variable and $$var is a variable of another variable. For example

$var = "YOU";
$you= "Me";

echo $var //Output:- you
echo $$var //output :-Me

$$var allows the developer to change the name of the variable dynamically.

5. Explain how to submit form without a submit button.
ANS: A form data can be posted or submitted without the button in the following ways:

1. On OnClick event of a label in the form, a JavaScript function can be called to submit the form e.g. document.form_name.submit()

2. Using a Hyperlink: On clicking the link, JavaScript function can be called e.g <a.href=” javascript:document.MyForm.submit();">

6. What is Joomla in PHP?
ANS: Joomla is an open source content management system. Joomla can be used in PHP as a framework to publish web contents. Joomla allows the user to manage the content of the web pages with ease.

7. What is difference between developing website using Java and PHP?
ANS: In order to make interactive pages, java uses JSP (Java Server pages). PHP is open source while JSP is not. Libraries are much stronger in Java as compared tp PHP. Huge codes can be managed with ease in Java by making classes.   

8. How can I embed a java programme in php file?
ANS: PHP can be integrated into the servlet environment of java or java support can be integrated with php.the java extension can be used to create and invoke methods on Java objects from PHP.

9. How to get jQuery nth Element?
ANS: //include jQuery file
<script type="text/javascript" src="jquery.js"></script>
<script>
function go_to(id_number){     
     var obj=jQuery('div.mydiv ul li:nth-child('+id_number+') a');      
     alert(obj.html()) 
}
go_to(3);
</script>

10.What is Invoking Client Programs?
ANS: MySQL client programs can be invoked from the command line. For example from a Windows console prompt OR a Unix shell prompt.
EX: shell> mysql -h localhost -p -u myname


11.What is needed to be able to use image function?
ANS: GD library is needed to be able execute image functions.
12. What is the use of the function ‘imagetypes()’?
ANS: imagetypes() gives the image format and types supported by the current version of GD-PHP.
13. What are the functions to be used to get the image’s properties (size, width and height)?
ANS: The functions are getimagesize() for size, imagesx() for width and imagesy() for height.
14. How failures in execution are handled with include() and require() functions?
ANS: If the function require() cannot access to the file then it ends with a fatal error. However, the include() function gives a warning and the PHP script continues to execute.
15. What is the main difference between require() and require_once()?
ANS: require() and require_once() perform the same task except that the second function checks if the PHP script is already included or not before executing it.
(same for include_once() and include())
16. How can we automatically escape incoming data? 
ANS: We have to enable the Magic quotes entry in the configuration file of PHP.
17. How can you pass a variable by reference?
To be able to pass a variable by reference, we use an ampersand in front of it, as follows $var1 = &$var2

Allow or Deny Website Access using IP Address

Allow  Website Access using One IP Address


Restrict website access using .httacess file

order deny,allow
deny from all
allow from 112.221.323.443

Allow  Website Access Except Few IP Address

order deny,allow
deny from 80.52.168.0/23
deny from 181.138.10.153/32
deny from 182.138.78.129/32 
allow from all



Order allow,deny
Allow from all
Deny from 58.14.0.0/15
Deny from 58.16.0.0/16


You can decide ips to add in the bloglist to provide restriction

Open Source Subrion CMS for business

Open Source Subrion CMS for business

 Open Source Subrion CMS for business

You don't need to pay a single penny to start using Subrion CMS. It's not encrypted in any way so you can customize it per your needs.

It's done to focus on the content management process. Start it hassle-free within just a few minutes and take care of the content. It's easy!

Use ready translation or translate the system into your language. It provides all the functionality to become a multilingual solution.

Forget the hours of programming simple things. Use Subrion framework API to add extra stuff using hooks, plugins, & packages.

No need to search. Plugins and templates are available straight from your admin dashboard with one click installation process.  

  For Demo Click here 

PHP File Upload

PHP File Upload

PHP File Upload into Folder

<?php       
     $file_name= $_FILES['attachment']['name']; //Get Name Of the Uploaded File
     $extension = end(explode('.', $file_name)); //Get The Extension
     $imagearray=array('gif','png','jpg');
     if(in_array($extension,$imagearray))
     {
      $folder = "upload/";
     }
     else
     {
      $folder= "files/";
     }
     $filePath = $folder. $file_name;
     $tmpName = $_FILES['attachment']['tmp_name'];
     $allowed =  array('gif','png' ,'jpg', 'pdf', 'txt');  //Allowed File Type
     $ext = pathinfo($file_name, PATHINFO_EXTENSION);
     //$_FILES["attachment"]["size"];
     if(!in_array($ext,$allowed) ) {
     echo 'error';
     exit;
     }
     if($_FILES["attachment"]["size"] < 350000) //Set Upload Limit
     {
       $result = move_uploaded_file($tmpName, $filePath); //Move File to the Folder
     }
     else
     {
        echo 'Only file size under 350kb will be upload';
     }
    ?>

Contact form mail sending using php mailer

Contact form mail sending using php mailer

Contact form mail sending using php mailer



Note: Before copy this code download phpmailer script
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once 'phpmailer/PHPMailerAutoload.php';

if (isset($_POST['inputName']) && isset($_POST['inputEmail']) && isset($_POST['inputPhone']) && isset($_POST['inputMessage'])) {

    //check if any of the inputs are empty
    if (empty($_POST['inputName']) || empty($_POST['inputEmail']) || empty($_POST['inputPhone']) || empty($_POST['inputMessage'])) {
        $data = array('success' => false, 'message' => 'Please fill out the form completely.');
        echo json_encode($data);
        exit;
    }


    //create an instance of PHPMailer
    $mail = new PHPMailer();

    $mail->From = $_POST['inputEmail'];
    $mail->FromName = $_POST['inputName'];
    $mail->AddAddress('info@yourdomin.net'); //recipient 
    $mail->Subject = $_POST['inputPhone'];
    $mail->Body = "Name: " . $_POST['inputName'] . "\r\n\r\nMessage: " . stripslashes($_POST['inputMessage']);

    if (isset($_POST['ref'])) {
        $mail->Body .= "\r\n\r\nRef: " . $_POST['ref'];
    }

    if(!$mail->send()) {
        $data = array('success' => false, 'message' => 'Message could not be sent. Mailer Error: ' . $mail->ErrorInfo);
        echo json_encode($data);
        exit;
    }

    $data = array('success' => true, 'message' => 'Thanks! We have received your message.');
    echo json_encode($data);

} else {

    $data = array('success' => false, 'message' => 'Please fill out the form completely.');
    echo json_encode($data);

}
?>

Angular js contact form example

 Angular js contact form example



Before copy this code download angular js file and mention the path within the script. with bootstrap css. (require basic knowledge of angular js and php to understand)

//Script


Insert script in the header section

<script>
  // define angular module/app
var formApp = angular.module('formApp', []);
// create angular controller and pass in $scope and $http
function formController($scope, $http) {
// create a blank object to hold our form information
// $scope will allow this to pass between controller and view
$scope.formData = {};
// process the form
$scope.processForm = function() {
$http({
       method  : 'POST',
           data    : $.param($scope.formData),  // pass in data as strings
       headers : { 'Content-Type': 'application/x-www-form-urlencoded' }  // set the headers so angular passing info as form data (not request payload)
   })
       .success(function(data) {
           console.log(data);
           if (!data.success) {
            // if not successful, bind errors to error variables
               $scope.errorName = data.errors.name;
               $scope.errorEmail = data.errors.email;
               $scope.errorPhone = data.errors.phone;
               $scope.errorSubject = data.errors.sub;
               $scope.errorMessage = data.errors.msg;
           } else {
            // if successful, bind success message to message
               $scope.message = data.message;
           }
       });
};
}
</script>
           url     : 'process.php',  // process.php handles validation and send mail to  the user


//code segment


Insert this code after body section

 <h2>Contact Us</h2>

            <div id="messages" class="well" ng-show="message">{{ message }}</div>

            <form ng-submit="processForm()">
                <div class="input-prepend" ng-class="{ 'has-error' : errorName }">
                    <span class="add-on"><i class="icon-user"></i></span>
                    <input name="name" class="span4" id="name" size="16" type="text" placeholder="Name" ng-model="formData.name">            
                </div>
                  <span class="help-block" ng-show="errorName">{{ errorName }}</span>
                <div class="input-prepend" ng-class="{ 'has-error' : errorEmail }">
                    <span class="add-on"><i class="icon-envelope"></i></span>
                    <input name="email" class="span4" id="email" size="16" type="email" placeholder="Email Address" ng-model="formData.email">
                </div>
                     <span class="help-block" ng-show="errorEmail">{{ errorEmail }}</span>
               <div class="input-prepend" ng-class="{ 'has-error' : errorPhone }">
                    <span class="add-on"><i class="icon-envelope"></i></span>
                    <input name="phone" class="span4" id="phone" size="16" type="text" placeholder="Mobile Number" ng-model="formData.phone" onkeypress='validate(event)'>
                </div>
                     <span class="help-block" ng-show="errorPhone">{{ errorPhone }}</span>
                <div class="input-prepend" ng-class="{ 'has-error' : errorSubject }">
                    <span class="add-on"><i class="icon-globe"></i></span>
                    <input name="sub" class="span4" id="prependedInput" size="16" type="text" placeholder="Subject" ng-model="formData.sub">
                </div>
                     <span class="help-block" ng-show="errorSubject">{{ errorSubject }}</span>
                <textarea class="span6" name="message" id="message" ng-model="formData.msg"></textarea>
                <span class="help-block" ng-show="errorMessage">{{ errorMessage }}</span>
                <div class="row">
                    <div class="span2">
                        <input id="submit_btn" type="submit" class="btn btn-inverse" value="Send Message" >
                    </div>
                </div>
            </form>
        </div> <!--End page content column-->

//Process.php

<?php

$errors         = array();   // array to hold validation errors
$data    = array();   // array to pass back data
// validate the variables ====================================================== if (empty($_POST['name']))  $errors['name'] = 'Name is required.';
 if (empty($_POST['email']))  $errors['email'] = 'Email address is required.';
 if (empty($_POST['phone']))  $errors['phone'] = 'Phone is required.';
 if (empty($_POST['sub']))  $errors['sub'] = 'Subject is required.';
 if (empty($_POST['msg']))  $errors['msg'] = 'Message is required.';
// return a response ===========================================================
 // response if there are errors if ( ! empty($errors)) {
  // if there are items in our errors array, return those errors  $data['success'] = false;  $data['errors']  = $errors; } else {
  // if there are no errors, return a message  $data['success'] = true;
$to = "infophpuptodate@gmail.com";// use your email address which need to be receive
   $subject = htmlspecialchars(trim($_POST['sub']));   $message = '';   $message .= htmlspecialchars(trim($_POST['msg']));   $message .= "\r\n";   $message .= htmlspecialchars(trim($_POST['name']));   $message .= "\r\n";   $message .= htmlspecialchars(trim($_POST['phone']));   $message .= "\r\n";   $message .= htmlspecialchars($_POST['email']);   $header = "From:info@youremail.com \r\n";   $retval = mail ($to,$subject,$message,$header); if($retval){  $data['message'] = 'Your Mail has been sent successfully...We will contact you soon!';}else{  $data['message'] = 'Mail sent failed!';} }
 // return all our data to an AJAX call echo json_encode($data);
?>

Remove category from url

Remove category from url wordpress 



Method 1

.htaccess
 RewriteRule ^category/(.+)$ http://www.yourblog.com/$1 [R=301,L]

Method 2

Using permalink Select post type custom    /%category%/%postname%/category base put dot(.)

Method 3

 Use plugin to solve this.

  FV Top Level Categories


Blog Template with post thumbnail

Blog Template with post thumbnail


<?php 
/*
Template Name: Blog
*/
?>
<?php get_header(); ?>

<div id="container">
<div id="content" role="main">

<article>

<?php // Display blog posts on any page @ http://m0n.co/l
$temp = $wp_query; $wp_query= null;
$wp_query = new WP_Query(); $wp_query->query('showposts=5' . '&paged='.$paged);
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>

<h2><a href="<?php the_permalink(); ?>" title="Read more"><?php the_title(); ?></a></h2>
              <?php if ( has_post_thumbnail() )
                 {
           the_post_thumbnail('medium');
                 } ?>
<?php the_excerpt(); ?>

<?php endwhile; ?>

<?php if ($paged > 1) { ?>

<nav id="nav-posts">
<div class="prev"><?php next_posts_link('&laquo; Previous Posts'); ?></div>
<div class="next"><?php previous_posts_link('Newer Posts &raquo;'); ?></div>
</nav>

<?php } else { ?>

<nav id="nav-posts">
<div class="prev"><?php next_posts_link('&laquo; Previous Posts'); ?></div>
</nav>

<?php } ?>

<?php wp_reset_postdata(); ?>

</article>
      </div>
    </div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

This template is common for all themes you just rename based on the theme. 
Below is the code for different types of thumbnail display options which very helpful when you create a blog with images.


// thumbnail different size
// without parameter -> Post Thumbnail (as set by theme using set_post_thumbnail_size())
the_post_thumbnail();

the_post_thumbnail('thumbnail');       // Thumbnail (default 150px x 150px max)
the_post_thumbnail('medium');          // Medium resolution (default 300px x 300px max)
the_post_thumbnail('large');           // Large resolution (default 640px x 640px max)
the_post_thumbnail('full');            // Original image resolution (unmodified)

the_post_thumbnail( array(100,100) );  // Other resolutions

What is Angular Js? And Why we use it?

What is Angular Js? And Why we use it?


Angular js is Javascript Framework ( the self-proclaimed “superheroic JavaScript framework” ).
1. Unit Testing is ready
2. Write less code
3. Flexibility with filters
4. Behaviour with directives
5. Data models
6. Mvc Architecture





Next post we see the more details with programming 

subcategory display in serach page

subcategory display in serach page osclass

output



function.php

Add this code into functions.php to get subcategory list based on category selection and display into search.php

if( !function_exists('get_subcategories') ) {
         function get_subcategories( ) {
             $location = Rewrite::newInstance()->get_location() ;
             $section  = Rewrite::newInstance()->get_section() ;
            
             if ( $location != 'search' ) {
                 return false ;
             }
            
             $category_id = osc_search_category_id() ;
            
             if(count($category_id) > 1) {
                 return false ;
             }
            
             $category_id = (int) $category_id[0] ;
            
             $subCategories = Category::newInstance()->findSubcategories($category_id) ;
 
            
             foreach($subCategories as &$category) {
                 $category['url'] = get_category_url($category) ;
             }
            
             return $subCategories ;
         }
     }
     if ( !function_exists('get_category_url') ) {
         function get_category_url( $category ) {
             $path = '';
             if ( osc_rewrite_enabled() ) {
                if ($category != '') {
                    $category = Category::newInstance()->hierarchy($category['pk_i_id']) ;
                    $sanitized_category = "" ;
                    for ($i = count($category); $i > 0; $i--) {
                        $sanitized_category .= $category[$i - 1]['s_slug'] . '/' ;
                    }
                    $path = osc_base_url() . $sanitized_category ;
                }
            } else {
                $path = sprintf( osc_base_url(true) . '?page=search&sCategory=%d', $category['pk_i_id'] ) ;
            }
            
            return $path;
         }
     }
     
     if ( !function_exists('get_category_num_items') ) {
         function get_category_num_items( $category ) {
            $category_stats = CategoryStats::newInstance()->countItemsFromCategory($category['pk_i_id']) ;
            
            if( empty($category_stats) ) {
                return 0 ;
            }
            
            return $category_stats;
         }
     }

?>


//search .php

Add this code into search.php where you want to display your sub category

<ul>
    <li><?php foreach(get_subcategories() as $subcat) { echo "<a href='".$subcat["url"]."'>".$subcat["s_name"]."</a> <span>(".get_category_num_items($subcat).")</span> | " ; } ?>
     </li>
</ul>