Wednesday 12 December 2018

HOW TO DISABLE PHP EXECUTION TO SECURE YOUR UPLOAD FILE DIRECTORY

To disable PHP execution, you add 5 lines of code to the .htaccess file on your web server. 

RewriteEngine On
<Files *.php>
Order allow,deny
Deny from all

</Files>

Tuesday 19 September 2017

send mail using gmail api use php example

<?php 

// Download the library from GitHub: URL: https://github.com/google/google-api-php-client
OR
Download

require 'vendor/autoload.php';

session_start();

//$youtube_api_key = 'MY_KEY';
$oauth_client_id = 'xxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com';
$oauth_client_secret = 'xxxxxxxxxxxxxxxxxxxxxxx';


define('SCOPES', implode(' ', array(
));

//$client = new \Google_Client();
//$client->setDeveloperKey($youtube_api_key);

$client = new Google_Client();
$client->setClientId($oauth_client_id); 
$client->setClientSecret($oauth_client_secret);
$client->setScopes(SCOPES);
$redirect = filter_var('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'], FILTER_SANITIZE_URL);
$client->setRedirectUri($redirect);
$client->setAccessType('offline');  


$tokenSessionKey = 'token-' . $client->prepareScopes();
if (isset($_GET['code'])) {
  if (strval($_SESSION['state']) !== strval($_GET['state'])) {
    die('The session state did not match.');
  }

  $client->authenticate($_GET['code']);
  $_SESSION[$tokenSessionKey] = $client->getAccessToken();
  header('Location: ' . $redirect);
}

if (isset($_SESSION[$tokenSessionKey])) {
  $client->setAccessToken($_SESSION[$tokenSessionKey]);
}


$message  = "MIME-Version: 1.0\r\n";
$message .= "From: FromName <frommail@gmail.com>\r\n";
$message .= "To: Pavan <pavan9212@gmail.com>\r\n";
$message .= "Subject: =?utf-8?B?".base64_encode('Sample Subject Which Contains Non-Latin Characters'.date(DATE_RFC2822))."?=\r\n";
$message .= "Date: ".date(DATE_RFC2822)."\r\n"; 
$message .= "Content-Type: multipart/alternative; boundary=test\r\n\r\n";
$message .= "--test\r\n";
$message .= "Content-Type: text/plain; charset=UTF-8\r\n";
$message .= "Content-Transfer-Encoding: base64\r\n\r\n";
$message .= base64_encode('Sample email message which contains non-latin chcracters')."\r\n";

// The message needs to be encoded in Base64URL
$mime = rtrim(strtr(base64_encode($message), '+/', '-_'), '=');


$service = new \Google_Service_Gmail($client);

$msg = new \Google_Service_Gmail_Message();
$msg->setRaw($mime);

try {
    if ($client->getAccessToken()) {
        $results = $service->users_messages->send("me", $msg);
print 'Message with ID: ' . $results->id . ' sent.';
    } else {
        // If the user hasn't authorized the app, initiate the OAuth flow
        $state = mt_rand();
        $client->setState($state);
        $_SESSION['state'] = $state;

        $authUrl = $client->createAuthUrl();
        $htmlBody = <<<END
<h3>Authorization Required</h3>
<p>You need to <a href="$authUrl">authorize access</a> before proceeding.<p>
END;
        echo $htmlBody;
    }
} catch (\Google_Service_Exception $e) {
    $gse_errors = $e->getErrors();
    echo '<h1>error!</h1>';
    echo '<pre>'.print_r($gse_errors, true).'</pre>';

Thursday 16 February 2017

angularjs 2.0 tutorial (What you should know)

हेल्लो दोस्तों , मैं पवन सेंगर आज आप को Angular 2.0 के बारे मैं बताने जा रहा हूँ।  Angular 2.0  को सीखना आसान है। सबसे पहले आप को ये जानना जरुरी है की इसको सिखाने से पहले आप को किस टेक्नोलॉजी की बेसिक नॉलेज होनी चाहिए।

  • HTML
  • CSS (अगर आप को CSS आती है तो ठीक है। नहीं भी आती है को कोई बात नहीं है। )
  • Basic Javascript
  • Programming fundamentals (Loops, functions, conditionals, etc)

  1. What is Angular 2?
    • Angular 2 is a JavaScript client site framework to creating a powerful web applications. 
    • Created and maintained by Google.
    • The most popular JavaScript framework to date.
    • what would be if it were created for dynamic web application.
  2. Angular 2 is NOT?
    • A server site technology/framework
    • JavaScript library (jQuery, React, etc)
    • Design Pattern
    • Platform and language (PHP,.NET,JAVA)
    • Plugin or extension
  3. What Angular 2 Offers?
    • Dynamic HTML
    • Form and input handling
    • Event handling
    • Powerful Templates
    • Routing
    • Faster rendering
    • HTTP Services
    • Latest JavaScript standards
    • Components encapsulation
    • Much more...
  4. What's new from Angular 1?
    • No more controller and scopes 
    • Components/Reusable code
    • Reduced learning curve
    • TypeScript & ES2015 / E6
    • Batter Mobile Support
    • RxJS & Observation

Wednesday 18 January 2017

How to use ajax inside bootstrap multiselect dropdown

Create Dropdown:

    <select multiple id="projectList">
                <option value="0" id="liteBlue">Option1</option>
                <option value="1" id="liteBlue">Option2</option>
               <option value="2" id="liteBlue">Option3</option>
               <option value="3" id="liteBlue">Option4</option>
               <option value="4" id="liteBlue">Option5</option>
   </select>


User jQuery Ajax Inside bootstrap multiselect dropdown.

<script>
$(document).ready(function(){

      $('#projectList').multiselect({
numberDisplayed: 1,
maxHeight: 275,
includeSelectAllOption: true,
selectAllText: 'All Projects',
nonSelectedText: 'All Projects',
onSelectAll: function() {
var projectIds = $('#projectList option:selected');
var selected = [];
$(".projectBreadcrumbs").html('');
$(projectIds).each(function(index, brand){
if($(this).val()!="multiselect-all"){
selected.push([$(this).val()]);
}
});
var projectIdString =  selected.join(",");
},
onDeselectAll: function () {
var projectIds = $('#projectList option:selected');
var selected = [];
$(projectIds).each(function(index, brand){
if($(this).val()!="multiselect-all"){
selected.push([$(this).val()]);
}
});
var projectIdString =  selected.join(",");
},
onChange: function(element, checked) {
var projectIds = $('#projectList option:selected');
var selected = [];
$(".projectBreadcrumbs").html('');
$(projectIds).each(function(index, brand){
if($(this).val()!="multiselect-all"){
selected.push([$(this).val()]);
}
});
var projectIdString =  selected.join(",");
                        ajax_load_status_jobs()
}
});


function ajax_load_status_jobs() {
var projectIdString         = $("#projectsIds").val();
var jobStatusIdString = $("#jobStatusIds").val();
var keyword_search = $("#searchJob").val();
$.ajax({
type: "POST",
url: "action_url",
dataType: 'html',
data: {'jobStatusId': jobStatusIdString, 'project_id':projectIdString, 'keyword_search':keyword_search},
cache:false,
beforeSend: function() {
$(this).prop("disabled", true);
$( '.setAjaxData').html('<div style="margin-bottom: 0px; margin-top: 2px;"><center><img src="'+base_url+'images/ajax-loader-bg-white.gif" style="height:50px;"></center></div>');
},
complete: function(){
$(this).prop("disabled", false);
},
success:
function(data){
//alert(data);
$(".setAjaxData").html(data);
},
error:
function(e) {
//alert(e.message);
$('.setAjaxData').html('<div class="jobTrack">No Recrod Found!</div>');
}
});
    }

});
</script>

Internet Security Software

This utility allows you to block unwanted websites from display in Internet Explorer. If a website is blocked the user is forwarded to a blank page or to a "blocked page" and the contents of the original page are not loaded on your PC. Stop your kids from spending hours in chat rooms or remove undesired websites from their view. Prevent your children from having access to certain websites content such as adult sites and gambling. The software includes password protected mode so that other computer users can not modify the list of blocked web sites and password protected uninstall.

Features: 


  • Block websites of your choice.

  • Block Messengers.

  • Block Any Application of PC.

  • Allows to lock and unlock any drive, folder and files.

  • Full Admin Control.
  • (Block Task Manager, Folder Option, Registry, Search, Run, Device Manager, Internet Option and Command Prompt)

  • Use password protected mode so that other users can not change settings.
Click here to download

Update data attribute value using jquery


Set Attribute Value Using Jquery

$('.className img').data('block', 'something');
$('.className img').attr('src', 'something.jpg');


OR


$('.className img[data-id="4"]').attr('data-block', 'something');
$('.className img[data-id="4"]').attr('src', 'something.jpg');


Update many image elements. You want to update the value of specific image by using data-id

$('.className img').each(function(index) {
    if($(this).attr('data-id') == '5')
    {
        $(this).attr('data-block', 'something');
        $(this).attr('src', 'something.jpg');
    }
});

OR

$('.className img[data-id="5"]').attr('data-block', 'something');
$('.className img[data-id="5"]').attr('src', 'something.jpg');