Google reCaptcha Application In Php Codeigniter


reCAPTCHA is a free CAPTCHA service that helps digitize books, newspapers and radio broadcasts in the past. CAPTCHAs are usually used to avoid bots and spam attacks on a website.

Google inc. The largest internet company has made CAPTCHA services to facilitate the developers to secure / avoid spam attacks on websites built.

On this article we will applicate CAPTCHA into a PHP framework that is CodeIgniter. We only need 2 php files, create a new file named recaptcha.php in folder Application/config and write the following code:

<?php
defined('BASEPATH') OR exit('No direct script access allowed'); 
/*
* Recaptcha configuration settings
*
* recaptcha_sitekey: Recaptcha site key to use in the widget
* ‎
* recaptcha_secretkey: Recaptcha secret key which is used for communicating between your server to Google's
* ‎
* lang: Language code, if blank "en" will be used
* ‎
* recaptcha_sitekey and recaptcha_secretkey can be obtained from https://www.google.com/recaptcha/admin/
* ‎
* ‎ Language code can be obtained from https://developers.google.com/recaptcha/docs/language
* ‎
*/
$config['recaptcha_sitekey'] = "6Le89gYUAAAAAIENtNE52gZXRZbtLAOA7caL2vQY";
$config['recaptcha_secretkey'] = "6Le89gYUAAAAACwspqCQaB17kqgaUd1juP7eURwP"";
$config['lang'] = "id";

At the code on the top have 3 config is :
$config['recaptcha_sitekey'] $config['recaptcha_secretkey'] $config['lang']

To get sitekey and secretkey you can register at following link: https://www.google.com/recaptcha/admin select reCAPTCHA V2, then input your website domain. After that create a new file named Recaptcha.php in folder Application/libraries, write this following code:

<?php 
/*
* CodeIgniter NO Captcha ReCAPTCHA a.k.a reCAPTCHA Version 2.0 library
* ‎
* This library is based on official reCAPTCHA library for PHP
* ‎
* https://github.com/google/ReCAPTCHA *
*/
defined('BASEPATH') OR exit('No direct script access allowed');
class ReCaptcha {
     private $signup_url = "https://www.google.com/recaptcha/admin";
     ‎private $_siteVerifyUrl = "https://www.google.com/recaptcha/api/siteverify?";
     ‎private $_secret, $_sitekey, $_lang;
     ‎private $_version = "php_1.0";
     ‎function __construct() {
     ‎     $this->ci = & get_instance();
     ‎     $this->ci->load->config('recaptcha', TRUE);
          ‎if ($this->ci->config->item('recaptcha_secretkey', 'recaptcha') == NULL || $this->ci->config->item('recaptcha_secretkey', 'recaptcha') == "") {
          ‎die("To use reCAPTCHA you must get an API key from <a href='" . $this->signup_url . "'>" . $this->signup_url . "</a>");
          ‎}
          ‎if ($this->ci->config->item('recaptcha_sitekey', 'recaptcha') == NULL || $this->ci->config->item('recaptcha_sitekey', 'recaptcha') == "") {
          ‎die("To use reCAPTCHA you must get an API key from <a href='" . $this->signup_url . "'>" . $this->signup_url . "</a>");
          ‎}
          ‎$this->_secret = $this->ci->config->item('recaptcha_secretkey', 'recaptcha');
          ‎$this->_sitekey = $this->ci->config->item('recaptcha_sitekey', 'recaptcha');
          ‎if ($this->ci->config->item('lang', 'recaptcha') == NULL || $this->ci->config->item('lang', 'recaptcha') == "") {
          ‎$this->_lang = 'en';
          ‎} else {
          ‎$this->_lang = $this->ci->config->item('lang', 'recaptcha');
          ‎}
}

/*
* Function to convert an array into query string
* ‎
* @param array $data Array of params
* ‎
* @return String query string of parameters
*/
private function _encodeQS($data) {
     $req = "";
     ‎foreach ($data as $key => $value) {
     ‎     $req .= $key . '=' . urlencode(stripslashes($value)) . '&';
     ‎}
     ‎return substr($req, 0, strlen($req) - 1);
}

/**
* HTTP GET to communicate with reCAPTCHA server
* ‎
* @param string $path URL to GET
* ‎
* @param array $data Array of params
*
* ‎ @return string JSON response from reCAPTCHA server
*/
private function _submitHTTPGet($path, $data) {
     $req = $this->_encodeQS($data);
     ‎$response = file_get_contents($path . $req);
     ‎return $response;
‎}

‎ /**
*
* ‎Function for rendering reCAPTCHA widget into views
* ‎
* Call this function in your view * @return string embedded HTML
*/
‎public function render() {
     $return = '<div class="g-recaptcha" data-sitekey="' . $this->_sitekey . '"></div>
     ‎<script src="https://www.google.com/recaptcha/api.js?hl=' . $this->_lang . '" async defer>
     ‎</script>';
     ‎return $return;
}

/**
* Function for verifying user's input
* ‎
* @param string $response User's input
* ‎
* @param string $remoteIp Remote IP you wish to send to reCAPTCHA, if NULL $this->input->ip_address() will be called
* @return array Array of response
*/
public function verifyResponse($response, $remoteIp = NULL) {
     if ($response == null || strlen($response) == 0) {
     ‎// Empty user's input
     ‎$return = array( 'success' => FALSE, 'error_codes' => 'missing-input' );
     ‎}
     ‎$getResponse = $this->_submitHttpGet( $this->_siteVerifyUrl, array( 'secret' => $this->_secret, 'remoteip' => (!is_null($remoteIp)) ? $remoteIp : $this->ci->input->ip_address(), 'v' => $this->_version, 'response' => $response ) );
     ‎$answers = json_decode($getResponse, TRUE);
     ‎if (trim($answers ['success']) == true) {
     ‎// Right captcha!
     ‎$return = array( 'success' => TRUE, 'error_codes' => '' );
     ‎ } else {
     ‎// Wrong captcha!
     ‎$return = array( 'success' => FALSE, 'error_codes' => $answers['error-codes'] );
     ‎‎} return $return;
‎  }
‎}

Then we will running and testing our reCAPTCHA, create a new controller named Contact.php in folder Application/controllers and the following code is below:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Contact extends CI_Controller {
    public function __construct() {
    ‎parent::__construct();
    ‎//load library
    ‎$this->load->library(array('recaptcha','form_validation'));
    ‎}
    ‎public function index() {
    ‎     $data = array( 'recaptcha_html' => $this->recaptcha->render() );
    ‎//set form validation
    ‎$this->form_validation->set_rules('username', 'Username', 'required');
    ‎$this->form_validation->set_rules('password', 'Password', 'required');
    ‎$this->form_validation->set_rules('g-recaptcha-response', '<strong>Captcha</strong>', 'callback_getResponseCaptcha');
    ‎//set message form validation
    ‎$this->form_validation->set_message('required', '{field} is required.');
    ‎$this->form_validation->set_message('callback_getResponseCaptcha', {field} {g-recaptcha-response} must filled. ');
    ‎if($this->form_validation->run() == TRUE) {
    ‎//if valid condition
    ‎}else{
    ‎$this->load->view('recaptcha');
    ‎ }
    ‎} public function getResponseCaptcha($str) {
    ‎$this->load->library('recaptcha');
    ‎$response = $this->recaptcha->verifyResponse($str);
    ‎if ($response['success']) { return true; } else {
    ‎$this->form_validation->set_message('getResponseCaptcha', '%s is required.' );
    ‎return false;
    ‎}
}
}

Create a new file named recaptcha.php in folder Application/views and write the following code:

<div class="container">
<form class="form-signin" accept="utf-8" action="<?php echo base_url() ?>contact">
<h2 class="form-signin-heading">Please sign in</h2>
‎<div class="form-group">
‎<label for="inputEmail" class="sr-only">Username</label>
‎<input type="text" name="nama" class="form-control" id="nama" placeholder="Masukkan Username Anda" value="<?php echo set_value('username') ?>" autocomplete="off">
‎<?php echo form_error('username'); ?>
‎</div>
‎<div class="form-group">
‎<label for="inputPassword" class="sr-only">Password</label>
‎<input type="password" name="nama" class="form-control" id="nama" placeholder="Masukkan Username Anda" value="<?php echo set_value('password') ?>" autocomplete="off">
‎<?php echo form_error('password'); ?>
‎</div>
‎<div class="form-group">
‎<label>Recaptcha</label>
‎<?php echo $recaptcha_html;?>
‎<?php echo form_error('g-recaptcha-response'); ?>
‎</div>
‎<div class="checkbox">
‎<label>
‎<input type="checkbox" value="remember-me"> Remember me
‎</label>
‎</div>
‎<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
‎</form>
‎</div>


Now run and test your project in localhost

Install And Setting Github Desktop At The First Time


GitHub Desktop is a desktop GUI version of Github web, the biggest and the most popular Git repository. What are the features, the following advantages and disadvantages? Check it out!

First, I'm is one of the most people not too much to use GUI for Git becoause already used Visual Studio Code which has a built in Git tool, it is enough for simple use like pull, push, commit etc. However, I also use GUI for repo Git management if needed, have tried SourceTree, Tower, and while it is using GitKraken. All of them is good, although there are have advantages and disadvantages.

And GitHub Desktop 1.0 was just released. Even as a whole, just 3 month this software is built from Beta version by Github. Somewhat late though, because the market is already using another GUI, and some even offer more complete integration  than just Github.

Download

Please download this software on the official website, https://desktop.github.com/ Unfortunately, there is only a version of Windows and Mac OS only. Although many report in the community of users, Github Desktop can run on Linux.


First Time Setting

There is a short wizard when the software is first run, standard like other Git Management GUI software. For example asked user and Git email, or Login to Github account.
Then whether to voluntarily telemetry to Github or not:

The initial appearance is really clean, there are three section menu. Create a new git repo, read an existing one or clone from Github.


Adding local repositories is also easy, just browse and Add Repository

Good interface:



There is a list of stash files that should be committed, following the history.


Advantages and disadvantages

The advantages:
- Free, 
- Native integration to Github platform,
- Net interface, 
- Simple and easy to understand
- Light

Disadvantages:
- Not too native, because using Electron as base
- Just support Github platform, others GUI can be used for Gitlab, Bitbucket etc. 
- Can't make Group Project, if managing much more repo going complicated

Macro Photography With Xiaomi Mi5 Smartphone


As I promised to further review what is in the Xiaomi Mi5 smartphone, more and more I explore the features of the Xiaomi Mi5 camera because of the many cool features of this smartphone should we explore completely. And this time I tried to explore Macro Photography feature. Little explanation of what the macro photography, macro photography is photography at a very close distance to get high detail of a small object but does not require additional magnifying tool.

On Xiaomi Mi5 smartphone has manual focus feature where we can adjust focus distance of the object which we will take just like a DSLR camera, how to enable the manual focus feature only needs to be entered into Modes and then select Manual, then there are four choices: White Balance, Focus, Exposure time, ISO. Select Focus and set the value to the smallest. hold up your smartphone to the object and adjust the distance between the object and the smartphone to get precisely focus.I

I suggest to take more than one photo at different distances between the object and the smartphone to get a good result, select the best and the precise focus and then zoom the photo in 1:1 as original object and see the results. You will be amazed. The opposite of macro photography are Infinity, Infinity is a photography technique used to obtain the focus at far object so that other nearest objects being blurred. I will write the next article about it.

For more details and the steps to do macro photography techniques please look at the following video :



Xiaomi Mi5 Review: Manual Focus Camera Feature


To reduce my thirst and curiosity with the Xiaomi MI5 camera features, a little review and test the Xiaomi MI5 camera will show you why I really wanted to have this one. The first feature that I explore is the manual focus. Manual Focus generally is a featur of DSLR camera, some professional photographer prefer to use the manual focus than auto focus (AF) because is easy to targeting the object focus and only focus on the object.

As I write in Xiaomi Mi5 Purple Unboxing, Xiaomi has bundled a manual focus feature in their MI5 smartphone. Not too difficult to use this feature, You just need to enter modes and choose Manual, on the focus menu, adjust the focus by sliding and snap to object to get the desired focus. I have some examples of the photos and I compare between the original photo and after zooming, the results is incredible.


That picture is the original photo, is the photo of a fly were I take from the top. Unbelievable result when I zoom in the photo, the result You can see at the main picture of this article.

Another photo zooming result is awesome too. To get the best photo You must take more than one snap then choose the best one. I will post another awesome photo in my next article.

Xiaomi Mi5 Purple Unboxing


This is My first Xiaomi smartphone. After searching about the technology and specifications of Xiaomi smartphone I decided to buy a Xiaomi MI5. My reason is first, from the specs smartphone Xiaomi MI5 embedded RAM 3GB with 32GB ROM capacity and My most important reason is it's camera technology has been adopted OIS (Optical Image Stabilization). Second, from the price of Xiaomi MI5 smartphone is very affordable only about $ 230 in Indonesia.

What's in the box?
As before, Xiaomi does not include earphone in any smartphones bundled they sell. There is only the smartphone itself and several manual books, which most surprised me is the charger, Xiaomi MI5 has adopted C-type USB for charger and data cable.

First impressions, slim design and soft purple color with glitter accents make an blink impression when exposed to the light. When I hold it feels very slippery, I guess this is the effect of corning gorilla glass version 4 on the screen and back panel. On the front there is a second camera, speaker phone, a small LED indicator light, MI logo and a home button that also serves as a finger print scanner. On the side there are volume buttons and the power button, on the other side there is a socket for sim cards. On the top there is a 3.5mm port for earphone and infra red sensors and at the bottom there is two speaker holes and C-type USB port. At the back the curved shape on the left and right sides, and there is a main camera lens with double flash nearby, also there is a MI logo on the center-bottom.



First start, As general android smartphones, when first turned on we were asked to follow a few steps initial setting, after that the main display will opens.
The first feature that I discover is the features of the camera, and I amazed when finding the features which have not I see in smartphones under $300 one of which is Manual Focus feature that functions like Digital Camera DSLR/SLR that is to set the focus distance object, also have manual Exposure Time feature, is also have Tilt-shift feature. The front camera like Xiaomi smartphone version ever before there is beautify features that can soften facial of the object and face detection that can show age prediction of the object although not so accurate, anyway I ignore this feature because I do not really like selfie, hahaha. Read Mode is also one of the features found on this smartphone.
As the person using the additional App such Clone App, now I not need to install additional applications because Xiaomi MI5 already provides a similar application in the settings menu.

As a smartphone with a relatively cheap price I was very satisfied with what is on the smartphone, it's normal if Xiaomi smartphone in Indonesia is getting a lot of interest, although not accompanied by commercial advertising as another smartphone brands, users are getting smarter in choosing and knowing the quality offered the producers of smartphones.


PES 2017 Freekick Trick : Knuckle Shot, Panenka Penalty Kick And Curve Freekick


There will be no endless to review Pro Evolution Soccer 2017 games, and this time I will review the characteristics of the world top three famous players in freekick. It's between Cristiano Ronaldo, Francesco Totti, and Lionel Messi. To become masterly in this games we must know the characteristics of each player and in this games each player has a different character. For example, like as many people know Cristiano Ronaldo highly proficient in knuckle shot free kick, Francesco Totti often do Panenka penalty kick in the real world, and Lionel Messi highly proficient at doing curve free kick. But not impossible these three players can not do these three freekick techniques.

First, I did experiment in knuckle shot freekick with all three of these players and it is rather difficult to adjust because of the different character. Cristiano Ronaldo is not too difficult to do this, we just need the right timing in pressing the square button at second time, the direction of the shot is very accurate in accordance with which we are headed. For Francesco Totti, the shoting power value is not very high, the shoting character in knuckle shot is flat and swooping down, to do this technique the arrows should upwards in full. Lionel Messi can indeed do knuckle shot but I suggest not to do so, will be very difficult to adjust the timing because the characteristics of the shoting is curving.

Second, is the Panenka penalty kick experiment, all three players have no difficulty in doing so because it does not require special skills to do, which to be the difference is player gesture. Cristiano Ronaldo and Francesco Totti his movements more natural and normal, but for some reason Lionel Messi motion looks a little strange and not nice.

Third, is the curve free kick. for this techniques Cristiano Ronaldo and francesco Totti is very difficult to do because of two players is using the instep and the ball is very difficult to curving. Different from both players, Lionel Messi is the most good kicker in this curve free kick, I had no trouble to do this technique with Lionel Messi, like David Beckham.

I was tobe a fan of this games since it was named Winning Eleven until now it has turned into Pro Evolution Soccer, this is the excess of this game because of the character of each player in the game such as what is in the real world. My memories go back to an era when Roberto Carlos still playing, because the individual skills above-average such as running speed and shooting power worth 9, I often put this player as a striker. In winning eleven era, the technique that is most feared is the one-two passing, until ther is a unwritten rule in my neighborhood that technique is prohibited to use, even in the winning eleven tournaments, many event organizers who wrote the regulations that one-two passing technique forbidden to use, if used will be disqualified from tournaments.



Available Space

Pasang iklan di sini...
081235172529 (WA Only)

Available Space

Pasang iklan di sini...
081235172529 (WA Only)