Skip to content

Instantly share code, notes, and snippets.

View MisterHouse's full-sized avatar

Alex MisterHouse

View GitHub Profile
@MisterHouse
MisterHouse / js-task-1.md
Created March 1, 2017 22:45 — forked from codedokode/js-task-1.md
Задания на яваскрипт (простые)
@MisterHouse
MisterHouse / Print an associative array as an ASCII table
Created January 25, 2016 14:59 — forked from jan-j/Print an associative array as an ASCII table
My solution to the task "Print an associative array as an ASCII table". More info can be found on task author page: http://phpixie.com/blog/test-tasks-for-php-interviews-that-developers-will-enjoy-solving/
<?php
const SPACING_X = 1;
const SPACING_Y = 0;
const JOINT_CHAR = '+';
const LINE_X_CHAR = '-';
const LINE_Y_CHAR = '|';
$table = array(
array(
@MisterHouse
MisterHouse / where_visitor_came_from.php
Created January 25, 2016 14:56
where_visitor_came_from simple script to find out where a visitor came from given subnet (ip...)
<?php
$ip = $_SERVER["REMOTE_ADRR"];
$subnet = getenv(HTTP_X_FORWARDED_FOR);
if(($subnet != NULL) && ($subnet != $_SERVER["REMOTE_ADDR"]))
$_SERVER["REMOTE_ADRR"] = $_SERVER["REMOTE_ADRR"]."/".$subnet;
echo "Страницу $_SERVER[PHP_SELF] посетил пользователь с ip адресом ".$_SERVER["REMOTE_ADDR"];
?>
<?php
function get_all_ip() {
$ip_pattern="#(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)#";