Skip to content

Instantly share code, notes, and snippets.

<?php
class Form extends Validation {
private $action;
private $method;
private $name;
private $validation;
private $vMessage;
public $request = array();
public $inputs = array();
@bshaffer
bshaffer / gist:413344
Created May 25, 2010 16:19 — forked from anonymous/gist:234678
PHP Object Oriented Array class
<?php
class A implements ArrayAccess, Iterator, Countable
{
public function __construct($arr) {
$this->arr = is_array($arr) ? $arr : func_get_args();
}
public function __toString() {
return print_r($this->arr, true);
}
@treffynnon
treffynnon / Config.php
Created September 3, 2010 09:20
A PHP class to access a PHP array via dot notation
<?php
namespace Treffynnon;
/**
* A PHP class to access a PHP array via dot notation
* (Agavi http://www.agavi.org was the inspiration).
*
* This was hacked in to an existing codebase hence the
* global config array variable.
@miguelfrmn
miguelfrmn / simpleimage.php
Last active May 9, 2023 11:23
SimpleImage PHP Class
<?php
/**
* File: SimpleImage.php
* Author: Simon Jarvis
* Modified by: Miguel Fermín
* Based in: http://www.white-hat-web-design.co.uk/articles/php-image-resizing.php
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@jamesvl
jamesvl / gist:910325
Created April 8, 2011 17:32
Web server rewrite rules for using klein PHP router

URL-rewriting for klein PHP router

Why rewrite URLs? Check Wikipedia

Apache

Make sure AllowOverride is on for your directory, or put in httpd.conf

# Apache (.htaccess or httpd.conf)

RewriteEngine On

@xeoncross
xeoncross / o.php
Created April 12, 2011 21:20
Auto Object Loading
<?php
class o
{
private $o;
// Get value
public function __get($k){return isset($this->o[$k])?$this->o[$k]:NULL;}
// Create or Get value
@jeremeamia
jeremeamia / gist:1002974
Created June 1, 2011 18:42
Creating an ORM architecture compatible with dependency injection and unit testing
<?php
// Domain Classes
abstract class Domain { // Provides means to persist models and understand relationships
public function __construct(Database_Interface $database, Domain_Builder_Base $builder) {/* ... */}
public function find($unique_key) {/* ... */}
public function find_all($unique_key) {/* ... */}
public function save(Domain_Model $model) {/* ... */}
public function find_all_related_to(Domain_Model $model) {/* ... */}
/* ... */
@mbijon
mbijon / xss_clean.php
Last active November 1, 2022 03:23
XSS filtering in PHP (cleans various UTF encodings & nested exploits)
<?php
/*
* XSS filter, recursively handles HTML tags & UTF encoding
* Optionally handles base64 encoding
*
* ***DEPRECATION RECOMMENDED*** Not updated or maintained since 2011
* A MAINTAINED & BETTER ALTERNATIVE => kses
* https://github.com/RichardVasquez/kses/
*
* This was built from numerous sources
@xeoncross
xeoncross / slider.html
Created August 31, 2011 03:19 — forked from jsok/slider.html
Simple jquery slider
<!DOCTYPE html>
<html lang="en-GB">
<head>
<title>iTunes slider</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/slider.js"></script>
</head>
@chluehr
chluehr / encode_compress.php
Created November 28, 2011 08:46
PHP encode and compress
<?php
/* by pablo at compuar dot com see http://php.net/manual/de/function.base64-encode.php
*
*
*/
$string = 'Blah';
$encoded = strtr(base64_encode(addslashes(gzcompress(serialize($string),9))), '+/=', '-_,');
$string= unserialize(gzuncompress(stripslashes(base64_decode(strtr($encoded, '-_,', '+/=')))));