Skip to content

Instantly share code, notes, and snippets.

@david4worx
david4worx / gist:1a991a705a52d8f9b16b
Last active April 27, 2020 01:42
array_filter_recursive
<?php
/**
* @param mixed $input
* @param null|callable $callback
* @return array
*/
function array_filter_recursive($input, $callback = null) {
if (!is_array($input)) {
return $input;
}
<?php
$keys = array_filter(array_keys($_SERVER), function($v) { return 0 === strpos($v, 'HTTP_'); });
$keys = array_combine($keys, $keys);
$headers = array_intersect_key($_SERVER, $keys);
var_dump($headers);
@david4worx
david4worx / .htaccess
Created December 5, 2012 19:59
.htaccess basic auth
RewriteEngine On
RewriteBase /
# DO match the following url(s)
SetEnvIf Request_URI ^(?!<insertYourUrlHere>$) noauth=1
# the auth block
AuthName "Please login."
AuthType Basic
AuthUserFile <insertYourPasswordFileHere>
@david4worx
david4worx / Easy.php
Created January 24, 2012 14:17
Adapters
<?php
interface FilterAdapter
{
public function filter($value);
}
class FilterBase
{
protected $_adapter;
@david4worx
david4worx / Html5.php
Created December 15, 2010 17:16
More extended Glitch form element and logic
<?php
class Application_Model_Form_Html5 extends Zend_Form
{
public function init()
{
$email = new Glitch_Form_Element_Text_Email('email');
$email->setLabel('Email');
$url = new Glitch_Form_Element_Text_Url('url');
$url->setLabel('Url');
@david4worx
david4worx / Color.php
Created December 15, 2010 17:14
Extended Glitch form elements
<?php
/**
* Glitch
*
* Copyright (c) 2010, Enrise BV (www.enrise.com).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@david4worx
david4worx / Datalist.php
Created December 15, 2010 17:09
Glitch basic form elements
<?php
/**
* Glitch
*
* Copyright (c) 2010, Enrise BV (www.enrise.com).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@david4worx
david4worx / Datalist.php
Created December 15, 2010 17:06
Gists of all Glitch View Helpers
<?php
/**
* Glitch
*
* Copyright (c) 2010, Enrise BV (www.enrise.com).
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met: