AngularJs 1 (vs) AngularJs 2

First thing to be clear is AngularJs 2is not an upgrade of Angular, it is completely different from Angular Js 1


Angular JS 1.X
Angular 2
Setting up application is very easy, need to just add the reference of angular.js Setting up application is quite complex, and it takes lot of work because it’s dependent on Gulp or Grunt.
Angular JS is not built with mobile support in mind. Whereas Angular2 was built for specially taking care of mobile support, so it’s mobile oriented.
Angular JS core concept was $scope, without scope we can’t communicate between views and controller. Angular2 is using Zone.js for detecting changes made in the DOM.
For communicating with views/templates it require controllers. It’s build with components.
Template Directives + controllers =    components
Performance is less when compared to angular2. Unidirectional tree based change detection increases its performance. As per ng-conf angular 2 is five times faster than angular1.
Angular1.X has ES5, ES6 and Dart Whereas angular2 has more choice, it can use any of the languages from ES5, ES6, and typescript/dart.
Ng-repeat is used for iterating through list of objects. Structural directives syntax is completely changed. Ng-repeat is replaced with *ngFor
Mostly built-in directives are used for events and element properties. Ex: ng-src, ng-href, ng-click etc. It directly uses the HTML DOM element properties. Ex: (click)
Ng-bind is used for one-way binding Whereas ng-bind is replaced with [property], where property is HTML DOM element property.
It has two ways to bootstrap the application, one is automatic bootstrapping (ng-app) and manual bootstrapping. It has only one way which is manual bootstrapping.
For routing it uses $routeProvider.when() It uses @RouteConfig {{…}}

Angular4 - Introduction

      What is Angular?
      AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML's syntax to express your application's components clearly and succinctly. AngularJS's data binding and dependency injection eliminate much of the code you would otherwise have to write. And it handles all of the DOM and AJAX code you once wrote by hand and puts it in a well-defined structure.

  • History: AJAX -> jQuery / Prototype -> MVC Frameworks (Knockout / Backbone) -> AngularJS
  • AngularJS is a very powerful open source and absolutely free JavaScript library distributed as   Angular.js file. 
  • It's majorly used for developing Single Page Applications (SPA). 
  • It's based on Model View Controller design pattern.
  • It's an extension of HTML DOM and has additional attributes which reduces code and makes it easy to program dynamic and responsive applications.
  • Its features include everything we need to build a CRUD app: data-binding, basic templating, directives, form validation, routing, deep-linking, reusable components, dependency injection.
  • Angular is built around the belief that declarative code is better than imperative when it comes to building UIs and wiring software components together, while imperative code is excellent for expressing business logic.
  • In AngularJS, views are pure html pages, and controllers written in JavaScript do the business processing.
  • AngularJS applications can run on all major browsers and smart phones, including Android and IOS based phones/tablets.




WHAT IS RANSOMWARE?






Ransomware is a malicious software that encrypts files and locks devices, such as a computer, tablet or smartphone and then demands a ransom to unlock it. Recently, a dangerous ransomware named ‘Wannacry’ has been affecting devices worldwide creating the biggest ransomware attack the world has ever seen.



WHAT IS WANNACRY RANSOMWARE?

WannaCry ransomware attacks windows based machines. It also goes by the name WannaCrypt, WannaCry, WanaCrypt0r, WCrypt, WCRY. It leverages SMB exploit in Windows machines called EternalBlue to attack and inject the malware. All versions of windows before Windows 10 are vulnerable to this attack if not patched for MS-17-010. After a system is affected, it encrypts files and shows a pop up with a countdown and instructions on how to pay the 300$ in bitcoins to decrypt and get back the original files. If the ransom is not paid in 3 days, the ransom amount increases to 600$ and threatens the user to wipe off all the data. It also installs DOUBLEPULSAR backdoor in the machine.



HOW IT SPREADS?

It uses EternalBlue MS17-010 to propagate. The ransomware spreads by clicking on links and downloading malicious files over internet and email. It is also capable of automatically spreading itself in a network by means of a vulnerability in Windows SMB. It scans the network for specific ports, searches for the vulnerability and then exploits it to inject the malware in the new machine and thus it spreads widely across the network.



WHAT CAN YOU DO TO PREVENT INFECTION?

– Microsoft has released a Windows security patch MS17-010 for Windows machines. This needs to be applied immediately and urgently.

– Remove Windows NT4, Windows 2000 and Windows XP-2003 from production environments.

– Block ports 139, 445 and 3389 in firewall.

– Avoid clicking on links or opening attachments or emails from people you don’t know or companies you don’t do business with.

– SMB is enabled by default on Windows. Disable smb service on the machine by going to Settings > uncheck the settings > OK

– Make sure your software is up-to-date.

– Have a pop-up blocker running on your web browser.

– Regularly backup your files.

– Install a good antivirus and a good anti-ransomware product for better security.



WHAT ARE WE DOING ON OUR WINDOWS SHARED SERVERS?

We are already in the phase of applying Windows updates on all our shared hosting Windows servers. However we need to reboot servers in-order to apply those security patches. We shall announce the schedule for server reboot in this thread shortly.



WHAT YOU NEED TO DO IN CASE OF OUR WINDOWS DEDICATED SERVERS?

You need to patch the Windows dedicated server immediately using the steps mentioned in the link : https://goo.gl/PYIEis



You can also refer to the following links to apply the necessary fix:

https://technet.microsoft.com/library/security/MS17-010

https://technet.microsoft.com/en-us/library/security/ms17-010.aspx

https://support.microsoft.com/en-in/help/4013389/title



For dedicated servers, once you have applied necessary changes, you need to reboot the server.

Contact Form 7 Custom Validations - Wordpress




If you wanted to add custom Validations for Contact from 7 fields, here is the code
 But the name we use in Wordpress back-end should match with $name in the below code. I added validations for URL, Zip and Phone number

 For Custom URL use "url" - [text* url]
 For Zip Code use "ZipCode" - [text* ZipCode]
 For Phone Number we can use "'PhoneNumber1', 'PhoneNumber2', 'PhoneNumber3', 'PhoneNumber4', 'PhoneNumber5', 'PhoneNumber6', 'PhoneNumber7'"  - [text* PhoneNumber1]



<?php

// URL Validations
function get_valid_url( $url ) {

    $reg_cond = "((https?|ftp)\:\/\/)?";
$reg_cond .= "(\?[a-z+&\$_.-][a-z0-9;:@&%=+\/\$_.-]*)?";
$reg_cond .= "(\:[0-9]{2,5})?";
    $reg_cond .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)?@)?";
    $reg_cond .= "([a-z0-9-.]*)\.([a-z]{2,3})";
    $reg_cond .= "(\/([a-z0-9+\$_-]\.?)+)*\/?";
    $reg_cond .= "(#[a-z_.-][a-z0-9+\$_.-]*)?";

    return preg_match("/^$reg_cond$/", $url);
}

function contact7_validations($result,$tag) {
$type = $tag['type'];
$name = $tag['name'];


if($type == 'text*' && $_POST[$name] == ''){
$result['valid'] = false;
$result['reason'][$name] = wpcf7_get_message( 'invalid_required' );
}



// Custom URL Validation
if($name == 'url') {
$url = $_POST['url'];

if($url != '') {
if(get_valid_url($url)){
$result['valid'] = true;
} else {
$result['valid'] = false;
$result['reason'][$name] = 'URL Entered is invalid.';
}
}
}


// Custom Zip Code Validation
if($name == 'ZipCode') {
$ZipCode = $_POST['ZipCode'];

if($ZipCode != '') {
if(!preg_match('/^[ABCEGHJKLMNPRSTVXY]{1}\d{1}[A-Z]{1} *\d{1}[A-Z]{1}\d{1}$/', $ZipCode)) {
if(!preg_match('/^\d{5}(-\d{4})?$/', $ZipCode)) {
$result['valid'] = false;
$result['reason'][$name] = 'Zipcode Entered is Invalid';
}
}
}
}

// Phone Validation

$PhoneNumber = array('PhoneNumber1', 'PhoneNumber2', 'PhoneNumber3', 'PhoneNumber4', 'PhoneNumber5', 'PhoneNumber6', 'PhoneNumber7');

foreach($PhoneNumber as $phoneValid) {
if($name == $phoneValid) {
$validPhone = $_POST[$phoneValid];

if($validPhone != '') {
if(preg_match('/^(?:1(?:[. -])?)?(?:\((?=\d{3}\)))?([2-9]\d{2})(?:(?<=\(\d{3})\))? ?(?:(?<=\d{3})[.-])?([2-9]\d{2})[. -]?(\d{4})(?: (?i:ext)\.? ?(\d{1,5}))?$/', $validPhone)
|| preg_match('/^([\+][0-9]{1,3}[\ \.\-])?([\(]{1}[0-9]{2,6}[\)])?([0-9\ \.\-\/]{3,20})((x|ext|extension)[\ ]?[0-9]{1,4})?$/', $validPhone)
&& strlen($validPhone) > 9
&& strlen($validPhone) < 30
&& (int)($validPhone)) {
} else {
$result['valid'] = false;
$result['reason'][$name] = 'Phone Number Entered is Invalid';
}
}
}
}


return $result;
}

//Filter For Text Field
add_filter('wpcf7_validate_text','contact7_validations', 10, 2);
add_filter('wpcf7_validate_text*', 'contact7_validations', 10, 2);
 ?>

Tunoff JSON Rest API - Wordpress





Wordpress has introduced REST API Future from 4.4 version, this addition will makes it possible to access our content using JSON API, Which is good for other user to access your content easily.

To disable the REST API and don't want to use REST API

Add the code beloe to your theme ->  functions.php

add_filter('json_enabled', '__return_false');
add_filter('json_jsonp_enabled', '__return_false');