Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Rob Allen:
Writing PSR-7 middleware
Nov 05, 2015 @ 19:48:58

In this new post to his site Rob Allen talks about PSR-7 compatible middle ware and shows examples of writing it to work with frameworks that support the PSR-7 structure. His examples revolve around Slim 3 but could be used in other supporting frameworks just as easily.

Within Slim 3's Request object, there's a method called getIp() which is determines the client's IP address. However it's rather simplistic and potentially risky as it checks the X-Forwarded-For header with no ability to ignore this header or whitelist whether we trust the final proxy in the chain. Determining the client's IP address is an ideal use-case for middleware as we can inspect the headers in the request and then set an attribute so that middleware further down the chain can use it.

With this goal in mind, he shows how to create the middleware that uses the __invoke method to execute the required logic and call the next middleware in the chain. In his example he makes use of a pseudo-method determineClientIpAddress that does the work of detecting the IP address and then sets the value as a part of the request object (as an attribute). He also shows how to configure the middleware to select an attribute name and how to attach the middleware to a few different framework types.

tagged: pst7 middleware slim3 framework ipaddress tutorial

Link: http://akrabat.com/writing-psr-7-middleware/

Matt Stauffer:
Login Throttling in Laravel 5.1
Aug 03, 2015 @ 13:35:57

Matt Stauffer has posted the eleventh part in his series looking at new features of the latest release of the Laravel framework (well, version 5.1). In this tutorial he shows you how to setup and configure the login throttling for your Laravel-based application with the help of the Laravel Throttle package.

Whether or not you know it, any login forms are likely to get a lot of automated login attempts. Most login forms don't stop an automated attack trying email after email, password after password, and since those aren't being logged, you might not even know it's happening.

The best solution to something like this is to halt a user from attempting logins after a certain number of failed attempts. This is called login throttling, or rate limiting. Graham Campbell wrote a great package called Laravel Throttle to address this in previous versions of Laravel, but in Laravel 5.1 Login throttling comes right out of the box.

He shows how to use the ThrottleTrait in your AuthController to have some of the "behind the scenes" work done for you. He shows you how to update your view to relay the possible error message back to the user (and includes a quick screencast of the result). He ends the post with a quick look at what the throttling functionality is doing under the covers: creating a temporary cache item based on username+IP address as a "lock" indicator. Finally, he points out two properties you can find on the auth controller to give a bit more detail on the current configuration: lockout time and max login attempts.

tagged: laravel login throttle tutorial authcontroller laravelthrottle package cache username ipaddress

Link: https://mattstauffer.co/blog/login-throttling-in-laravel-5.1

Zend Developer Zone:
Create your own widget with PHP-GTK
Aug 19, 2008 @ 14:35:30

A new tutorial on the Zend Developer Zone shows you how to use PHP's "younger cousin" PHP-GTK to make a simple widget.

With PHP's younger cousin PHP-GTK's recent step to maturity with the 2.0 stable release it is a good time to give this project some more attention. In this article I will show you how to create a re-usable IPv4 Entry widget using PHP-GTK's excellent OO structure.

The end result is an interface that lets the user input an IP in a familiar way (blocks of three, automatically advancing to the next block). They talk about the code first, describing how all of the parts fit together before giving you an easily cut-and-pastable block of code (the class) that creates the widget.

tagged: widget phpgtk tutorial ipaddress interface

Link:

Ken Guest's Blog:
Validation in Depth - a retort to using just regular expressions
May 27, 2008 @ 12:58:54

Ken Guest, in a response to another post from a different blogger, has posted some of his own validation replacements for the regular expression method the other blogger chose.

I've noticed that Richard Heyes, who professes himself to be a php guru, deleted my comment on his "Some common regular expressions" posting which simply pointed out his expressions didn't quite do the job and suggested a few PEAR packages that should be used instead of the expressions that he proffered

His examples have the benefit of what he calls "defense in depth" - the functionality to catch a bit more than just a regular expression can alone. His examples include PEAR_Validate for email addresses, Net_CheckIP2 for IP addresses and the Validate_UK package for the sort code and telephone numbers.

tagged: pear package regular expression validate email telephone ipaddress domain

Link:

Derick Rethans' Blog:
Detecting Timezone By IP
May 07, 2008 @ 16:15:24

Derick Rethans has posted a method he's come up with to try to figure out the user's timezone based on the IP address they're using:

Through Planet PHP I found an article on Pre-populating forms with the timezone. I'd normally add a comment instead, but the comment would almost be larger then the original post, so I am instead writing up an entry myself. The post describes several ways to obtain the user's timezone and use that to pre-fill a form. None of them are working properly though.

In Derick's method combines a bit of Javascript with some PHP to correctly find the timezone.

tagged: detect timezone ipaddress maxmind goeonames ip2location

Link:

Joey's Blog:
8 Practical PHP Regular Expressions
Oct 17, 2007 @ 15:27:00

On his web development blog, Joey has posted a new list of eight handy regular expressions you can use in your code for common validations.

Here are eight examples of practical PHP regular expressions and techniques that I've used over the past few years using Perl Compatible Regular Expressions. This guide goes over the eight different validation techniques and describes briefly how they work. Usernames, telephone numbers, email addresses, and more.

Each of the regular expressions comes complete with an explanation of what it is and the kinds of strings it's looking for. Comments on the post have helped even more, finding places where they might break or not catch all possibilities.

tagged: regular expression list practical username phone email zip ipaddress date regular expression list practical username phone email zip ipaddress date

Link:

Joey's Blog:
8 Practical PHP Regular Expressions
Oct 17, 2007 @ 15:27:00

On his web development blog, Joey has posted a new list of eight handy regular expressions you can use in your code for common validations.

Here are eight examples of practical PHP regular expressions and techniques that I've used over the past few years using Perl Compatible Regular Expressions. This guide goes over the eight different validation techniques and describes briefly how they work. Usernames, telephone numbers, email addresses, and more.

Each of the regular expressions comes complete with an explanation of what it is and the kinds of strings it's looking for. Comments on the post have helped even more, finding places where they might break or not catch all possibilities.

tagged: regular expression list practical username phone email zip ipaddress date regular expression list practical username phone email zip ipaddress date

Link:

Nexen.net:
PHP Statistics for April 2007
May 03, 2007 @ 17:04:00

Damien Seguy has kept up the good work and has posted this month's PHP statistics for the past month's data (April 2007).

Here are the PHP stats for March 2007. To learn about methodology, read la section phpversion. 10.1 millions servers hosted on 2.3 millions IP were surveyed during December, and 22.8 were used for stats : domaines without web sites, those unreachable, ISP, shared hosters or domain parkings were not considered.

Highlights for the month:

  • 5.2 is about to be the 3rd most popular version
  • PHP 5 is more often chosen on larger domains
  • In April, web sites are bracing for the next versions
  • Doesn't seem to be much impact from MOPB : have to wait for this month's to see it.

Stats cover a wide range of topics including:

Also, be sure to check out the evolution stats for the past month, showing some of the trends for the past months as compared to April.

tagged: statistic monthly evolution usage country domain ipaddress statistic monthly evolution usage country domain ipaddress

Link:

Nexen.net:
PHP Statistics for April 2007
May 03, 2007 @ 17:04:00

Damien Seguy has kept up the good work and has posted this month's PHP statistics for the past month's data (April 2007).

Here are the PHP stats for March 2007. To learn about methodology, read la section phpversion. 10.1 millions servers hosted on 2.3 millions IP were surveyed during December, and 22.8 were used for stats : domaines without web sites, those unreachable, ISP, shared hosters or domain parkings were not considered.

Highlights for the month:

  • 5.2 is about to be the 3rd most popular version
  • PHP 5 is more often chosen on larger domains
  • In April, web sites are bracing for the next versions
  • Doesn't seem to be much impact from MOPB : have to wait for this month's to see it.

Stats cover a wide range of topics including:

Also, be sure to check out the evolution stats for the past month, showing some of the trends for the past months as compared to April.

tagged: statistic monthly evolution usage country domain ipaddress statistic monthly evolution usage country domain ipaddress

Link:

DynamicWbePages.de:
New PHP Statistics
Feb 05, 2007 @ 14:49:00

DynamicWebPages.de has posted their new statistics for PHP usage in the community for this past month:

After the small decrease in the last month, PHP made it back up easily. For the first time since April 2006, the 20 million mark on the number of domains has been passed. In contrast to the previous month that means a jump of nearly 800,000 domains. The number of IP addresses, on which PHP is installed, also has numbers worth checking out. With 1,332,514 IP addresses on record, this month's numbers are the highest conditions since September 2004.

You can check out the graph and the statistics for the last year in their statistics page of their site.

tagged: statistics february domain ipaddress install record increase statistics february domain ipaddress install record increase

Link:


Trending Topics: