Skip to content

Instantly share code, notes, and snippets.

@alixaxel
alixaxel / plugin_DatabaseHide.php
Created January 19, 2013 21:39
Collection of Adminer Plugins
<?php
/** plugin_DatabaseHide.php
* @author Alix Axel
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0
*/
class AdminerDatabaseHide {
protected $disabled;
function AdminerDatabaseHide($disabled) {
<?php
function isVATIN($vatin)
{
if (preg_match('~^[125689][0-9]{8}$~', $vatin) > 0)
{
$vatin = str_split($vatin);
foreach (array_slice($vatin, 0, -1) as $key => $value)
{
@alixaxel
alixaxel / Form.php
Last active December 11, 2015 20:59
<?php
/**
* The MIT License
* http://creativecommons.org/licenses/MIT/
*
* Copyright (c) Alix Axel <alix.axel@gmail.com>
**/
class phunction_HTML_Form extends phunction_HTML
<?php
public static function Typography($string, $quotes = true)
{
if ($quotes === true)
{
$string = preg_replace(array("~'([^']+)'~", '~"([^"]+)"~'), array('‘$1’', '“$1”'), $string);
}
return preg_replace(array('~[.]{2,}~', '~--~', '~-~', '~(?<=\d)(st|nd|rd|th)\b~i'), array('…', '—', '–', '<sup>$1</sup>'), $string);
<?php
public static function Dump()
{
foreach (func_get_args() as $argument)
{
switch (gettype($argument))
{
case 'array':
case 'object':
@alixaxel
alixaxel / DB.php
Last active December 11, 2015 22:19
<?php
public static function DB($query = null)
{
static $db = array();
static $result = array();
if (isset($db[self::$id], $query) === true)
{
if (empty($result[self::$id][$hash = md5($query)]) === true)
<?php
public static function Enclose($string, $delimiter = null)
{
if (strlen($string = trim($string)) > 0)
{
$string = sprintf('%2$s%1$s%2$s', trim($string, $delimiter), $delimiter);
}
return $string;
<?php
/*
function Zip($input, $output)
{
if (class_exists('PharData', false) === true)
{
if (is_object($phar = new PharData($output)) === true)
{
if (is_dir($input) === true)
<?php
public static function Highway($path, $throttle = null)
{
if ((count($segments = self::Segment()) > 0) && (preg_match('~/$~', $path = ph()->Disk->Path($path)) > 0))
{
$class = null;
while ((is_null($segment = array_shift($segments)) !== true) && (is_dir($path . $class . $segment . '/') === true))
{
<?php
function RESTful($root, $convention = '_%s')
{
$root = rtrim(str_replace('\\', '/', realpath($root)), '/');
$segments = preg_replace('~/+~', '/', trim(substr($_SERVER['PHP_SELF'], strlen($_SERVER['SCRIPT_NAME'])), '/'));
foreach (range(0, count($segments = explode('/', $segments))) as $i)
{
if (is_file(sprintf('%s/%s.php', $root, $path = implode('/', array_slice($segments, 0, $i)))) === true)