diff --git a/.coveralls.yml b/.coveralls.yml
deleted file mode 100644
index 9160059..0000000
--- a/.coveralls.yml
+++ /dev/null
@@ -1 +0,0 @@
-service_name: travis-ci
diff --git a/.gitignore b/.gitignore
index ef18b8c..f0154bc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,9 +6,7 @@
.*
!.gitignore
!.travis.yml
-!.coveralls.yml
*~
-vendor
# Global/OSX.gitignore #
########################
diff --git a/.travis.yml b/.travis.yml
index ac3f6aa..9cb6122 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,39 +1,3 @@
-language: php
-
-php:
- - 5.4
- - 5.5
- - 5.6
- - hhvm
-
-matrix:
- allow_failures:
- - php: hhvm
-
branches:
only:
- master
- - 2.0
- - 1.9
-
-services:
- - memcache
- - memcached
- - redis
-
-install:
- - composer self-update
- - composer install
-
-before_script:
- - ./tests/travis.sh
- - mysql -e "create database IF NOT EXISTS test;" -u root
- - mysql test < tests/schema.sql -u root
- - mkdir -p build/logs
- - phpenv rehash
-
-script:
- - phpunit --coverage-clover /home/travis/build/joshtronic/pickles/build/logs/clover.xml
-
-after_success:
- - php vendor/bin/coveralls --config ../.coveralls.yml -v
diff --git a/LICENSE b/LICENSE
index ad65074..a6c8f0c 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2007-2014 Josh Sherman
+Copyright (c) 2007-2014 Joshua Sherman
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
diff --git a/README.md b/README.md
index 6bf603c..cdb5324 100644
--- a/README.md
+++ b/README.md
@@ -1,28 +1,48 @@
-# Pickles
+# PHP Interface Collection of Killer Libraries to Enhance Stuff
-[][packagist]
-[][travis]
-[][coveralls]
-[][packagist]
+## What is PICKLES?
-Pickles f/k/a PICKLES (PHP Interface Collection of Killer Libraries to Enhance
-Stuff) is an open source framework for the rapid development of RESTful
-services. The intention of this framework is to allow developers to a means to
-develop service-oriented backend systems that are completely decoupled from the
-front end components. Thus allowing the freedom to build the front end
-implementation(s) using whichever tools they choose, be it Ember.js, Angular.js
-or some cool new system I’ve yet to hear of.
+PICKLES is an open source framework for the rapid development of web applications.
-## Thanks
+## Okay, but why?
-Special thanks to [Geoff Oliver][GeoffOliver] for being a long time user and
-contributor, [Justin Davis][JustinDavis] for romanticizing the v2 reimagining
-and [Dean Jones][DeanJones] for helping to come up with the original PICKLES v1
-acronym.
+I could have went with any number of existing frameworks, but I opted to build my own because I like to code. I've built quite a few sites from the ground up over the years, and I wanted to roll that experience into a single system that I could not only use for my sites, but share with the world.
-[coveralls]: https://coveralls.io/r/joshtronic/pickles
-[packagist]: https://packagist.org/packages/joshtronic/pickles
-[travis]: http://travis-ci.org/joshtronic/pickles
-[DeanJones]: https://github.com/deanproxy
-[GeoffOliver]: https://github.com/geoffoliver
-[JustinDavis]: http://justindavis.co
+## Wait, what, it's not MVC?
+
+PICKLES is in fact not a true MVC system and won't be masquerading around as one (yeah, I know, I borrowed some naming conventions). PICKLES does have a main controller that handles incoming page views. The controller loads a module that contains all of the business logic (optionally interacting with data models) and then execution is passed off to the display layer. The display layer gives the user what they asked for (even if they didn't say please). This is how web pages work, and there has never been a reason for me to force PICKLES into the MVC box just for the hell of it.
+
+## Requirements
+
+### Required Software
+
+* Web server (nginx or Apache with mod_rewrite)
+* PHP 5.3+
+
+Please note that PICKLES can run on 5.0+ (you may need the PECL JSON library for versions below 5.2) but is heavily field tested on servers running the latest LTS release of Ubuntu (12.04 at the moment) running the latest stable version of PHP in the main repository (which is the 5.3.x branch). nginx is the preferred web server at this point, but PICKLES was deployed to and used on Apache 1.3+ for quite sometime.
+
+### Highly Recommended Software
+
+* PHP 5.2.0+ for native JSON support or PECL JSON 1.2.1
+
+### Optional Software
+
+#### Databases
+
+* MySQL with PDO and PDO_MYSQL drivers
+* PostgreSQL with PDO and PDO_PGSQL drivers
+* SQLite 3 with PDO and PDO_SQLITE drivers
+
+#### CSS Pre-processors
+
+* node, npm & lessc to compile LESS files
+* sass to compile SASS files
+
+## Installation
+
+Installation is quite simple as there is no installer to run, and all server configuration options can be set in your index.php for your site.
+
+1. Download the source http://github.com/joshtronic/pickles/zipball/master (or clone the repository)
+2. Place the code anywhere you'd like (that's at least 2 directories up from the root of your website). I recommend using /usr/share/pickles
+3. A starter site can be obtained from http://github.com/joshtronic/pickles-starter. It has everything you need to get a site up and running.
+4. At this point you should have a very rudimentary site up and running.
diff --git a/classes/API/AYAH.php b/classes/API/AYAH.php
new file mode 100644
index 0000000..cd84dc5
--- /dev/null
+++ b/classes/API/AYAH.php
@@ -0,0 +1,34 @@
+api['ayah'])
+ {
+ throw new Exception('Missing API configuration.');
+ }
+
+ $ayah = new AYAH($config->api['ayah']);
+
+ return $ayah->getPublisherHTML();
+ }
+
+ public static function isHuman()
+ {
+ $config = Config::getInstance();
+
+ if (!$config->api['ayah'])
+ {
+ throw new Exception('Missing API configuration.');
+ }
+
+ $ayah = new AYAH($config->api['ayah']);
+
+ return $ayah->scoreResult();
+ }
+}
+
+?>
diff --git a/classes/API/Common.php b/classes/API/Common.php
new file mode 100644
index 0000000..dfc1df6
--- /dev/null
+++ b/classes/API/Common.php
@@ -0,0 +1,43 @@
+
+ * @copyright Copyright 2007-2014, Joshua Sherman
+ * @license http://www.opensource.org/licenses/mit-license.html
+ * @package PICKLES
+ * @link https://github.com/joshtronic/pickles
+ */
+
+/**
+ * Common API Interface
+ *
+ * Parent class that our API interface classes should be extending. Contains
+ * execution of parental functions but may contain more down the road.
+ */
+abstract class API_Common extends Object
+{
+ /**
+ * Constructor
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ }
+
+ /**
+ * Destructor
+ */
+ public function __destruct()
+ {
+ parent::__destruct();
+ }
+}
+
+?>
diff --git a/classes/API/Google/Profanity.php b/classes/API/Google/Profanity.php
new file mode 100644
index 0000000..6ae87e4
--- /dev/null
+++ b/classes/API/Google/Profanity.php
@@ -0,0 +1,47 @@
+
+ * @copyright Copyright 2007-2014, Joshua Sherman
+ * @license http://www.opensource.org/licenses/mit-license.html
+ * @package PICKLES
+ * @link https://github.com/joshtronic/pickles
+ */
+
+/**
+ * Google Profanity API Interface
+ */
+class API_Google_Profanity extends API_Common
+{
+ /**
+ * Check
+ *
+ * Checks if a word is considered profanity.
+ *
+ * @usage API_Google_Profanity::check('fuck'); // returns true
+ * @param string $word word to check
+ * @return boolean whether or not the word is profanity
+ */
+ public static function check($word)
+ {
+ $response = json_decode(file_get_contents('http://www.wdyl.com/profanity?q=' . $word), true);
+
+ if ($response == null || !isset($response['response']) || !in_array($response['response'], array('true', 'false')))
+ {
+ throw new Exception('Invalid response from API.');
+ }
+ else
+ {
+ return $response['response'] == 'true';
+ }
+ }
+}
+
+?>
diff --git a/classes/API/Gravatar.php b/classes/API/Gravatar.php
new file mode 100644
index 0000000..3598c27
--- /dev/null
+++ b/classes/API/Gravatar.php
@@ -0,0 +1,98 @@
+
+ * @copyright Copyright 2007-2014, Joshua Sherman
+ * @license http://www.opensource.org/licenses/mit-license.html
+ * @package PICKLES
+ * @link https://github.com/joshtronic/pickles
+ */
+
+/**
+ * Gravatar API Interface
+ *
+ * @link http://en.gravatar.com/site/implement/
+ */
+class API_Gravatar extends API_Common
+{
+ /**
+ * Hash
+ *
+ * Generates a hash from the passed string that can then be used for
+ * fetching an image or profile from Gravatar.com
+ *
+ * @static
+ * @param string $string string to hash, should be an email address
+ * @return string resulting hash
+ */
+ public static function hash($string)
+ {
+ // Trims whitespace, lowers the case then applies MD5
+ return md5(strtolower(trim($string)));
+ }
+
+ /**
+ * img
+ *
+ * Generates an img tag requesting a Gravatar based on the parameters.
+ *
+ * @static
+ * @param string $email address to use for the hash
+ * @param integer $size optional size of the image requested
+ * @param string $default optional default style or image to generate
+ * @param string $rating optional filter by a certain rating
+ * @param boolean $force optional force the default avatar
+ * @param boolean $secure optional whether to use the SSL URL
+ * @param array $attributes optional any additional parameters to include
+ * @return string an img tag requesting a Gravatar
+ */
+ public static function img($email, $size = 80, $default = 'gravatar', $rating = 'g', $force = false, $secure = false, $attributes = false)
+ {
+ if (!filter_var($email, FILTER_VALIDATE_EMAIL))
+ {
+ throw new Exception('Invalid email address.');
+ }
+ elseif ($size < 1 || $size > 2048)
+ {
+ throw new Exception('Invalid size parameter, expecting an integer between 1 and 2048.');
+ }
+ elseif (!in_array($default, array('gravatar', '404', 'mm', 'identicon', 'monsterid', 'wavatar', 'retro', 'blank')) && !filter_var($default, FILTER_VALIDATE_URL))
+ {
+ throw new Exception('Invalid default parameter, expecting gravatar, 404, mm, identicon, monsterid, wavatar, retro, blank or a valid URL.');
+ }
+ elseif (!in_array($rating, array('g', 'pg', 'r', 'x')))
+ {
+ throw new Exception('Invalid rating perameter, expecting g, pg, r or x.');
+ }
+ else
+ {
+ $default = $default == 'gravatar' ? false : urlencode($default);
+
+ $html = ' $value)
+ {
+ $html .= sprintf(' %s="%s"', $attribute, $value);
+ }
+ }
+
+ $html .= '>';
+
+ return $html;
+ }
+ }
+}
+
+?>
diff --git a/classes/API/Tinychat.php b/classes/API/Tinychat.php
new file mode 100644
index 0000000..38c76b3
--- /dev/null
+++ b/classes/API/Tinychat.php
@@ -0,0 +1,185 @@
+
+ * @copyright Copyright 2007-2014, Joshua Sherman
+ * @license http://www.opensource.org/licenses/mit-license.html
+ * @package PICKLES
+ * @link https://github.com/joshtronic/pickles
+ */
+
+/**
+ * Tinychat API Interface
+ *
+ * @link http://tinychat.com/developer/docs
+ */
+class API_Tinychat extends API_Common
+{
+ /**
+ * Public Key
+ *
+ * @access private
+ * @var string
+ */
+ private $public_key = null;
+
+ /**
+ * Secret Key
+ *
+ * @access private
+ * @var string
+ */
+ private $secret_key = null;
+
+ /**
+ * Constructor
+ *
+ * Assigns our public and secret keys from the configuration.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+
+ if (isset($this->config->api['tinychat'], $this->config->api['tinychat']['public_key'], $this->config->api['tinychat']['secret_key']))
+ {
+ $this->public_key = $this->config->api['tinychat']['public_key'];
+ $this->secret_key = $this->config->api['tinychat']['secret_key'];
+ }
+ else
+ {
+ throw new Exception('Unable to load TinyChat configuration.');
+ }
+ }
+
+ /**
+ * Execute
+ *
+ * Constructs a valid API call, executes it and returns the results.
+ *
+ * @param string $codephrase name of the API call being called
+ * @param string $authentication post-codephrase portion of the auth string
+ * @param array $parameters key / value pairs for additional data
+ * @return array results of the API call
+ */
+ private function execute($codephrase, $authentication, $parameters = null)
+ {
+ // Assembles and hashes the authentication token
+ $authentication = md5($this->secret_key . ':' . $authentication);
+
+ // Assembles any additional parameters
+ $additional = '';
+
+ if ($parameters && is_array($parameters))
+ {
+ foreach ($parameters as $key => $value)
+ {
+ $additional .= '&' . $key . '=' . $value;
+ }
+ }
+
+ // Executes the API call
+ $results = file_get_contents('http://tinychat.apigee.com/' . $codephrase . '?result=json&key=' . $this->public_key . '&auth=' . $authentication . $additional);
+
+ return json_decode($results, true);
+ }
+
+ /**
+ * List Rooms
+ *
+ * Pulls all rooms for the API application.
+ *
+ * @return array API results
+ */
+ public function listRooms()
+ {
+ return $this->execute('roomlist', 'roomlist');
+ }
+
+ /**
+ * Room Info
+ *
+ * Pulls the information for a room.
+ *
+ * @param string $room name of the room
+ * @param boolean $with_ip whether or not to include users IP addresses
+ * @return array API results
+ */
+ public function roomInfo($room, $with_ip = false)
+ {
+ return $this->execute('roominfo', $room . ':roominfo', array('room' => $room, 'with_ip' => ($with_ip ? 1 : 0)));
+ }
+
+ /**
+ * Set Room Password
+ *
+ * Sets the password for the room, only users with the correct password
+ * will be able to enter.
+ *
+ * @param string $room name of the room
+ * @param string $password password to use, blank for no password
+ * @return array API results
+ */
+ public function setRoomPassword($room, $password = '')
+ {
+ return $this->execute('setroompassword', $room . ':setroompassword', array('room' => $room, 'password' => $password));
+ }
+
+ /**
+ * Set Broadcast Password
+ *
+ * Sets the password to allow broadcasting in the room. Only users with the
+ * correct password will be able to broadcast.
+ *
+ * @param string $room name of the room
+ * @param string $password password to use, blank for no password
+ * @return array API results
+ */
+ public function setBroadcastPassword($room, $password = '')
+ {
+ return $this->execute('setbroadcastpassword', $room . ':setbroadcastpassword', array('room' => $room, 'password' => $password));
+ }
+
+ /**
+ * Generate HTML
+ *
+ * Creates the HTML to place a chat on a site.
+ *
+ * @todo List params...
+ * @return array API results
+ */
+ public function generateHTML($room, $join = false, $nick = false, $change = false, $login = false, $oper = false, $owner = false, $bcast = false, $api = false, $colorbk = false, $tcdisplay = false, $autoop = false, $urlsuper = false, $langdefault = false)
+ {
+ return '
+
+
+
$config = new Config($filename);
+ */
+class Config extends Object
+{
+ /**
+ * Config data
+ *
+ * @access private
+ * @var array
+ */
+ private $data = array();
+
+ /**
+ * Constructor
+ *
+ * Calls the parent constructor and loads the passed file.
+ *
+ * @param string $filename optional Filename of the config
+ */
+ public function __construct($filename = null)
+ {
+ parent::__construct();
+
+ // Try to fine the configuration
+ if ($filename == null)
+ {
+ $filename = 'config.php';
+ $loaded = false;
+ $cwd = getcwd();
+
+ while ($loaded == false)
+ {
+ chdir(dirname($filename));
+
+ if (getcwd() == '/')
+ {
+ throw new Exception('Unable to load configuration.');
+ }
+
+ chdir($cwd);
+
+ $filename = '../' . $filename;
+ $loaded = $this->load($filename);
+ }
+ }
+ else
+ {
+ $this->load($filename);
+ }
+ }
+
+ /**
+ * Loads a configuration file
+ *
+ * @param string $filename filename of the config file
+ * @return boolean success of the load process
+ */
+ public function load($filename)
+ {
+ $environments = false;
+ $environment = false;
+
+ // Sanity checks the config file
+ if (file_exists($filename) && is_file($filename) && is_readable($filename))
+ {
+ require_once $filename;
+
+ // Determines the environment
+ if (isset($config['environment']))
+ {
+ $environment = $config['environment'];
+ }
+ else
+ {
+ if (isset($config['environments']) && is_array($config['environments']))
+ {
+ $environments = $config['environments'];
+
+ // If we're on the CLI, check an environment was even passed in
+ if (IS_CLI == true && $_SERVER['argc'] < 2)
+ {
+ throw new Exception('You must pass an environment (e.g. php script.php new Controller($config);
+ */
+class Controller extends Object
+{
+ /**
+ * Pass Thru
+ *
+ * Whether or not the page being loaded is simple a pass thru for an
+ * internal PICKLES file. The point of this variable is to suppress the
+ * profiler report in the destructor.
+ *
+ * @access private
+ * @var boolean
+ */
+ private $passthru = false;
+
+ /**
+ * Constructor
+ *
+ * To make life a bit easier when using PICKLES, the Controller logic is
+ * executed automatically via use of a constructor.
+ */
+ public function __construct()
+ {
+ parent::__construct();
+
+ // Generate a generic "site down" message if the site is set to be disabled
+ if (isset($this->config->pickles['disabled']) && $this->config->pickles['disabled'] == true)
+ {
+ Error::fatal($_SERVER['SERVER_NAME'] . ' is currentlyProfiler::log('some action you want to track');
+ * @usage Profiler::log($object, 'methodName');
+ */
+class Profiler
+{
+ /**
+ * Config
+ *
+ * Profiler configuration
+ *
+ * @static
+ * @access private
+ * @var array
+ */
+ private static $config;
+
+ /**
+ * Profile
+ *
+ * Array of logged events
+ *
+ * @static
+ * @access private
+ * @var array
+ */
+ private static $profile = array();
+
+ /**
+ * Queries
+ *
+ * Number of queries that have been logged
+ *
+ * @static
+ * @access private
+ * @var integer
+ */
+ private static $queries = 0;
+
+ /**
+ * Timers
+ *
+ * Array of active timers
+ *
+ * @static
+ * @access private
+ * @var array
+ */
+ private static $timers = array();
+
+ /**
+ * Constructor
+ *
+ * Private constructor since this class is interfaced wtih statically.
+ *
+ * @access private
+ */
+ private function __construct()
+ {
+
+ }
+
+ /**
+ * Enabled
+ *
+ * Checks if the profiler is set to boolean true or if the passed type is
+ * specified in the profiler configuration value.
+ *
+ * @param array $type type(s) to check
+ * @return boolean whether or not the type is enabled
+ */
+ public static function enabled(/* polymorphic */)
+ {
+ // Grabs the config object if we don't have one yet
+ if (self::$config == null)
+ {
+ $config = Config::getInstance();
+ self::$config = $config->pickles['profiler'];
+ }
+
+ // Checks if we're set to boolean true
+ if (self::$config === true)
+ {
+ return true;
+ }
+ else
+ {
+ $types = func_get_args();
+
+ foreach ($types as $type)
+ {
+ if (stripos(self::$config, $type) !== false)
+ {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Log
+ *
+ * Logs the event to be displayed later on. Due to the nature of how much
+ * of a pain it is to determine which class method called this method I
+ * opted to make the method a passable argument for ease of use. Perhaps
+ * I'll revisit in the future. Handles all elapsed time calculations and
+ * memory usage.
+ *
+ * @static
+ * @param mixed $data data to log
+ * @param string $method name of the class method being logged
+ */
+ public static function log($data, $method = false, $type = false)
+ {
+ $time = microtime(true);
+ $data_type = ($data == 'timer' ? $data : gettype($data));
+
+ // Tidys the data by type
+ switch ($data_type)
+ {
+ case 'array':
+ $log = '' . print_r($data, true) . ''; + break; + + case 'object': + $log = '[' . get_parent_class($data) . '] ' + . '' . get_class($data) . '' + . ($method != '' ? '->' . $method . '()' : ''); + + $data_type = '' . $data_type . ''; + break; + + case 'timer': + $log = $method; + + $data_type = '' . $data_type . ''; + break; + + case 'string': + default: + if ($type != false) + { + $data_type = $type; + } + + $log = $data; + break; + } + + self::$profile[] = array( + 'log' => $log, + 'type' => $data_type, + 'time' => $time, + 'elapsed' => $time - PICKLES_START_TIME, + 'memory' => memory_get_usage(), + ); + } + + /** + * Log Query + * + * Serves as a wrapper to get query data to the log function + * + * @static + * @param string $query the query being executed + * @param array $input_parameters optional prepared statement data + * @param array $explain EXPLAIN data for the query + * @param float $duration the speed of the query + */ + public static function logQuery($query, $input_parameters = false, $explain = false, $duration = false) + { + self::$queries++; + + $log = ''; + + if ($input_parameters != 'false' && is_array($input_parameters)) + { + $log .= '
+ Console + + | ++ Load Time + + | ++ Memory Usage + + | ++ Database + + | ++ Includes + + | +
Console | +Memory | +Time | +|
---|---|---|---|
+ | + | + | ms | +
Security::login(10);
+ * @usage Security::isLevel(SECURITY_LEVEL_ADMIN);
+ */
+class Security
+{
+ /**
+ * Lookup Cache
+ *
+ * Used to minimize database lookups
+ *
+ * @static
+ * @access private
+ * @var array
+ */
+ private static $cache = array();
+
+ /**
+ * Generate Hash
+ *
+ * Generates an SHA1 hash from the provided string. Salt optional.
+ *
+ * @param string $source value to hash
+ * @param mixed $salts optional salt or salts
+ * @return string SHA1 hash
+ */
+ public static function generateHash($source, $salts = null)
+ {
+ // Determines which salt(s) to use
+ if ($salts == null)
+ {
+ $config = Config::getInstance();
+
+ if (isset($config->security['salt']) && $config->security['salt'] != null)
+ {
+ $salts = $config->security['salt'];
+ }
+ else
+ {
+ $salts = array('P1ck73', 'Ju1C3');
+ }
+ }
+
+ // Forces the variable to be an array
+ if (!is_array($salts))
+ {
+ $salts = array($salts);
+ }
+
+ // Loops through the salts, applies them and calculates the hash
+ $hash = $source;
+
+ foreach ($salts as $salt)
+ {
+ $hash = sha1($salt . $hash);
+ }
+
+ return $hash;
+ }
+
+ /**
+ * SHA-256
+ *
+ * Generates an SHA-256 hash from the provided string.
+ *
+ * @param string $source value to hash
+ * @return string SHA1 hash
+ */
+ public static function sha256($source)
+ {
+ return hash('sha256', $source);
+ }
+
+ /**
+ * Generate SHA-256 Hash
+ *
+ * Generates an SHA-256 hash from the provided string and salt. Borrowed the
+ * large iteration logic from fCryptography::hashWithSalt() as, and I quote,
+ * "makes rainbow table attacks infesible".
+ *
+ * @param string $source value to hash
+ * @param mixed $salt value to use as salt
+ * @return string SHA-256 hash
+ * @link https://github.com/flourishlib/flourish-classes/blob/master/fCryptography.php
+ */
+ public static function generateSHA256Hash($source, $salt)
+ {
+ $sha256 = sha1($salt . $source);
+
+ for ($i = 0; $i < 1000; $i++)
+ {
+ $sha256 = Security::sha256($sha256 . (($i % 2 == 0) ? $source : $salt));
+ }
+
+ return $sha256;
+ }
+
+ /**
+ * Check Session
+ *
+ * Checks if sessions are enabled.
+ *
+ * @static
+ * @access private
+ * @return boolean whether or not sessions are enabled
+ */
+ private static function checkSession()
+ {
+ if (session_id() == '')
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+ }
+
+ /**
+ * Check Level
+ *
+ * Checks if a passed level is an integer and/or properly defined in the
+ * site's configuration file.
+ *
+ * @static
+ * @access private
+ * @param mixed access level to validate
+ * @return whether ot not the access level is valid
+ */
+ private static function checkLevel(&$access_level)
+ {
+ if (is_int($access_level))
+ {
+ return true;
+ }
+ else
+ {
+ $config = Config::getInstance();
+
+ // Attempts to validate the string passed
+ if (isset($config->security[$access_level]))
+ {
+ if (is_numeric($config->security[$access_level]))
+ {
+ $access_level = (int)$config->security[$access_level];
+ return true;
+ }
+ else
+ {
+ throw new Exception('Level "' . $access_level . '" is not numeric in config.ini');
+ }
+ }
+ else
+ {
+ throw new Exception('Level "' . $access_level . '" is not defined in config.ini');
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Login
+ *
+ * Creates a session variable containing the user ID and generated token.
+ * The token is also assigned to a cookie to be used when validating the
+ * security level. When the level value is present, the class will by pass
+ * the database look up and simply use that value when validating (the less
+ * paranoid scenario).
+ *
+ * @static
+ * @param integer $user_id ID of the user that's been logged in
+ * @param integer $level optional level for the user being logged in
+ * @param string $role textual representation of the user's level
+ * @return boolean whether or not the login could be completed
+ */
+ public static function login($user_id, $level = null, $role = null)
+ {
+ if (self::checkSession())
+ {
+ $token = sha1(microtime());
+
+ $_SESSION['__pickles']['security'] = array(
+ 'token' => $token,
+ 'user_id' => (int)$user_id,
+ 'level' => $level,
+ 'role' => $role,
+ );
+
+ setcookie('pickles_security_token', $token);
+
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ * Logout
+ *
+ * Clears out the security information in the session and the cookie.
+ *
+ * @static
+ * @return boolean true
+ */
+ public static function logout()
+ {
+ if (isset($_SESSION['__pickles']['security']))
+ {
+ $_SESSION['__pickles']['security'] = null;
+ unset($_SESSION['__pickles']['security']);
+
+ setcookie('pickles_security_token', '', time() - 3600);
+ }
+
+ return true;
+ }
+
+ /**
+ * Get User Level
+ *
+ * Looks up the user level in the database and caches it. Cache is used
+ * for any subsequent look ups for the user. Also validates the session
+ * variable against the cookie to ensure everything is legit. If the user
+ * level is set in the session, that value will take precedence.
+ *
+ * return integer user level or false
+ */
+ private static function getUserLevel()
+ {
+ if (self::checkSession() == true && isset($_SESSION['__pickles']['security']['user_id']))
+ {
+ // Checks the session against the cookie
+ if (isset($_SESSION['__pickles']['security']['token'], $_COOKIE['pickles_security_token'])
+ && $_SESSION['__pickles']['security']['token'] != $_COOKIE['pickles_security_token'])
+ {
+ Security::logout();
+ }
+ elseif (isset($_SESSION['__pickles']['security']['level']) && $_SESSION['__pickles']['security']['level'] != null)
+ {
+ return $_SESSION['__pickles']['security']['level'];
+ }
+ // Hits the database to determine the user's level
+ else
+ {
+ // Checks the session cache instead of hitting the database
+ if (isset($_SESSION['__pickles']['security']['user_id'], self::$cache[(int)$_SESSION['__pickles']['security']['user_id']]))
+ {
+ return self::$cache[(int)$_SESSION['__pickles']['security']['user_id']];
+ }
+ else
+ {
+ // Pulls the config and defaults where necessary
+ $config = Config::getInstance();
+
+ if ($config->security === false)
+ {
+ $config = array();
+ }
+ else
+ {
+ $config = $config->security;
+ }
+
+ $defaults = array('login' => 'login', 'model' => 'User', 'column' => 'level');
+ foreach ($defaults as $variable => $value)
+ {
+ if (!isset($config[$variable]))
+ {
+ $config[$variable] = $value;
+ }
+ }
+
+ // Uses the model to pull the user's access level
+ $class = $config['model'];
+ $model = new $class(array('fields' => $config['column'], 'conditions' => array('id' => (int)$_SESSION['__pickles']['security']['user_id'])));
+
+ if ($model->count() == 0)
+ {
+ Security::logout();
+ }
+ else
+ {
+ $constant = 'SECURITY_LEVEL_' . $model->record[$config['column']];
+
+ if (defined($constant))
+ {
+ $constant = constant($constant);
+
+ self::$cache[(int)$_SESSION['__pickles']['security']['user_id']] = $constant;
+
+ return $constant;
+ }
+ else
+ {
+ throw new Exception('Security level constant is not defined');
+ }
+ }
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Is Level
+ *
+ * Checks the user's access level is exactly the passed level
+ *
+ * @static
+ * @param integer $access_level access level to be checked against
+ * @return boolean whether or not the user is that level
+ */
+ public static function isLevel()
+ {
+ $is_level = false;
+
+ if (self::checkSession())
+ {
+ $arguments = func_get_args();
+ if (is_array($arguments[0]))
+ {
+ $arguments = $arguments[0];
+ }
+
+ foreach ($arguments as $access_level)
+ {
+ if (self::checkLevel($access_level))
+ {
+ if (self::getUserLevel() == $access_level)
+ {
+ $is_level = true;
+ break;
+ }
+ }
+ }
+ }
+
+ return $is_level;
+ }
+
+ /**
+ * Has Level
+ *
+ * Checks the user's access level against the passed level.
+ *
+ * @static
+ * @param integer $access_level access level to be checked against
+ * @return boolean whether or not the user has access
+ */
+ public static function hasLevel()
+ {
+ $has_level = false;
+
+ if (self::checkSession())
+ {
+ $arguments = func_get_args();
+ if (is_array($arguments[0]))
+ {
+ $arguments = $arguments[0];
+ }
+
+ foreach ($arguments as $access_level)
+ {
+ if (self::checkLevel($access_level))
+ {
+ if (self::getUserLevel() >= $access_level)
+ {
+ $has_level = true;
+ break;
+ }
+ }
+ }
+ }
+
+ return $has_level;
+ }
+
+ /**
+ * Between Level
+ *
+ * Checks the user's access level against the passed range.
+ *
+ * @static
+ * @param integer $low access level to be checked against
+ * @param integer $high access level to be checked against
+ * @return boolean whether or not the user has access
+ */
+ public static function betweenLevel($low, $high)
+ {
+ $between_level = false;
+
+ if (self::checkSession())
+ {
+ if (self::checkLevel($low) && self::checkLevel($high))
+ {
+ $user_level = self::getUserLevel();
+
+ if ($user_level >= $low && $user_level <= $high)
+ {
+ $between_level = true;
+ break;
+ }
+ }
+ }
+
+ return $between_level;
+ }
+}
+
+?>
diff --git a/classes/Session.php b/classes/Session.php
new file mode 100644
index 0000000..c3b9d4f
--- /dev/null
+++ b/classes/Session.php
@@ -0,0 +1,345 @@
+
+ * @copyright Copyright 2007-2014, Joshua Sherman
+ * @license http://www.opensource.org/licenses/mit-license.html
+ * @package PICKLES
+ * @link https://github.com/joshtronic/pickles
+ */
+
+/**
+ * Session Class
+ *
+ * Provides session handling via database instead of the file based session
+ * handling built into PHP. Using this class requires an array to be
+ * defined in place of the boolean true/false (on/off). If simply array(),
+ * the datasource will default to the value in
+ * $config['pickles']['datasource'] and if the table will default to
+ * "sessions". The format is as follows:
+ *
+ * $config = array(
+ * 'pickles' => array(
+ * 'session' => array(
+ * 'datasource' => 'mysql',
+ * 'table' => 'sessions',
+ * )
+ * )
+ * );
+ *
+ * In addition to the configuration variables, a table in your database
+ * must be created. The [MySQL] table schema is as follows:
+ *
+ * CREATE TABLE sessions (
+ * id varchar(32) COLLATE utf8_unicode_ci NOT NULL,
+ * session text COLLATE utf8_unicode_ci NOT NULL,
+ * expires_at datetime NOT NULL,
+ * PRIMARY KEY (id),
+ * INDEX (expires_at)
+ * ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+ *
+ * Note: The reason for not using a model class was to avoid a naming
+ * conflict between the Session model and the Session class itself. This
+ * will eventually be resolved when I abandon full 5.x support and migrate
+ * to 5.3+ (assuming that ever happens).
+ */
+class Session extends Object
+{
+ /**
+ * Handler
+ *
+ * What the session is being handled by.
+ *
+ * @access private
+ * @var string
+ */
+ private $handler = false;
+
+ /**
+ * Accessed At
+ *
+ * The UNIX timestamp of when the page was accessed.
+ *
+ * @access private
+ * @var integer
+ */
+ private $accessed_at = null;
+
+ /**
+ * Time to Live
+ *
+ * The number of seconds the session should remain active. Corresponds
+ * to the INI variable session.gc_maxlifetime
+ *
+ * @access private
+ * @var integer
+ */
+ private $time_to_live = null;
+
+ /**
+ * Datasource
+ *
+ * Name of the datasource, defaults to whatever the default datasource
+ * is defined to in config.php
+ *
+ * @access private
+ * @var string
+ */
+ private $datasource = null;
+
+ /**
+ * Table
+ *
+ * Name of the database table in the aforementioned datasource that
+ * holds the session data. The expected schema is defined above.
+ *
+ * @access private
+ * @var string
+ */
+ private $table = null;
+
+ /**
+ * Database
+ *
+ * Our database object to interact with the aforementioned datasource
+ * and table. This object is shared with other PICKLES internals.
+ *
+ * @access private
+ * @var object
+ */
+ private $db = null;
+
+ /**
+ * Constructor
+ *
+ * All of our set up logic for the session in contained here. This
+ * object is initially instantiated from pickles.php and the session
+ * callbacks are established here. All variables are driven from
+ * php.ini and/or the site config. Once configured, the session is
+ * started automatically.
+ */
+ public function __construct()
+ {
+ if (!IS_CLI)
+ {
+ parent::__construct();
+
+ // Sets up our configuration variables
+ if (isset($this->config->pickles['session']))
+ {
+ $session = $this->config->pickles['session'];
+ $version = 1;
+ }
+
+ if (isset($this->config->pickles['sessions']))
+ {
+ $session = $this->config->pickles['sessions'];
+ $version = 2;
+ }
+
+ $datasources = $this->config->datasources;
+
+ $this->handler = 'files';
+ $datasource = false;
+ $table = 'sessions';
+
+ if (isset($datasources[$session]))
+ {
+ $datasource = $datasources[$session];
+ $this->handler = $datasource['type'];
+
+ if (isset($datasource['hostname'], $datasource['port']))
+ {
+ $host = 'tcp://' . $datasource['hostname'] . ':' . $datasource['port'];
+ }
+ }
+
+ switch ($this->handler)
+ {
+ case 'memcache':
+ ini_set('session.save_handler', 'memcache');
+ ini_set('session.save_path', $host . '?persistent=1&weight=1&timeout=1&retry_interval=15');
+ break;
+
+ // @todo memcached
+
+ case 'mysql':
+ // Sets our access time and time to live
+ $this->accessed_at = time();
+ $this->time_to_live = ini_get('session.gc_maxlifetime');
+
+ $this->datasource = $datasource;
+ $this->table = $table;
+
+ // Gets a database instance
+ $this->db = Database::getInstance($this->datasource);
+
+ // Initializes the session
+ $this->initialize();
+ break;
+
+ case 'redis':
+ // Keep in mind that the database value is ignored by phpredis
+ $save_path = $host . '?weight=1'
+ . (isset($datasource['database']) ? '&database=' . $datasource['database'] : '')
+ . (isset($datasource['prefix']) ? '&prefix=' . $datasource['prefix'] : '');
+
+ ini_set('session.save_handler', 'redis');
+ ini_set('session.save_path', $save_path);
+ break;
+
+ default:
+ case 'files':
+ ini_set('session.save_handler', 'files');
+ break;
+ }
+
+ if (isset($_SERVER['HTTP_USER_AGENT'])
+ && !String::isEmpty($_SERVER['HTTP_USER_AGENT'])
+ && !preg_match('/(Baidu|Gigabot|Googlebot|libwww-perl|lwp-trivial|msnbot|SiteUptime|Slurp|WordPress|ZIBB|ZyBorg)/i', $_SERVER['HTTP_USER_AGENT']))
+ {
+ session_start();
+ }
+ }
+ }
+
+ /**
+ * Destructor
+ *
+ * Runs garbage collection and closes the session. I'm not sure if the
+ * garbage collection should stay as it could be accomplished via
+ * php.ini variables. The session_write_close() is present to combat a
+ * chicken and egg scenario in earlier versions of PHP 5.
+ */
+ public function __destruct()
+ {
+ if ($this->handler == 'mysql')
+ {
+ $this->gc($this->time_to_live);
+ session_write_close();
+ }
+ }
+
+ /**
+ * Initializes the Session
+ *
+ * This method exists to combat the fact that calling session_destroy()
+ * also clears out the save handler. Upon destorying a session this
+ * method is called again so the save handler is all set.
+ */
+ public function initialize()
+ {
+ // Sets up the session handler
+ session_set_save_handler(
+ array($this, 'open'),
+ array($this, 'close'),
+ array($this, 'read'),
+ array($this, 'write'),
+ array($this, 'destroy'),
+ array($this, 'gc')
+ );
+
+ register_shutdown_function('session_write_close');
+ }
+
+ /**
+ * Opens the Session
+ *
+ * Since the session is in the database, opens the database connection.
+ * This step isn't really necessary as the Database object is smart
+ * enough to open itself up upon execute.
+ */
+ public function open()
+ {
+ session_regenerate_id();
+
+ return $this->db->open();
+ }
+
+ /**
+ * Closes the Session
+ *
+ * Same as above, but in reverse.
+ */
+ public function close()
+ {
+ return $this->db->close();
+ }
+
+ /**
+ * Reads the Session
+ *
+ * Checks the database for the session ID and returns the session data.
+ *
+ * @param string $id session ID
+ * @return string serialized session data
+ */
+ public function read($id)
+ {
+ $sql = 'SELECT session FROM `' . $this->table . '` WHERE id = ?;';
+
+ $session = $this->db->fetch($sql, array($id));
+
+ return isset($session[0]['session']) ? $session[0]['session'] : '';
+ }
+
+ /**
+ * Writes the Session
+ *
+ * When there's changes to the session, writes the data to the
+ * database.
+ *
+ * @param string $id session ID
+ * @param string $session serialized session data
+ * @return boolean whether the query executed correctly
+ */
+ public function write($id, $session)
+ {
+ $sql = 'REPLACE INTO `' . $this->table . '` VALUES (?, ? ,?);';
+
+ $parameters = array($id, $session, date('Y-m-d H:i:s', strtotime('+' . $this->time_to_live . ' seconds')));
+
+ return $this->db->execute($sql, $parameters);
+ }
+
+ /**
+ * Destroys the Session
+ *
+ * Deletes the session from the database.
+ *
+ * @param string $id session ID
+ * @return boolean whether the query executed correctly
+ */
+ public function destroy($id)
+ {
+ $sql = 'DELETE FROM `' . $this->table . '` WHERE id = ?;';
+
+ return $this->db->execute($sql, array($id));
+ }
+
+ /**
+ * Garbage Collector
+ *
+ * This is who you call when you got trash to be taken out.
+ *
+ * @param integer $time_to_live number of seconds a session is active
+ * @return boolean whether the query executed correctly
+ */
+ public function gc($time_to_live)
+ {
+ $sql = 'DELETE FROM `' . $this->table . '` WHERE expires_at < ?;';
+
+ $parameters = array(date('Y-m-d H:i:s', $this->accessed_at - $time_to_live));
+
+ return $this->db->execute($sql, $parameters);
+ }
+}
+
+?>
diff --git a/classes/Sort.php b/classes/Sort.php
new file mode 100644
index 0000000..134bf0b
--- /dev/null
+++ b/classes/Sort.php
@@ -0,0 +1,72 @@
+
+ * @copyright Copyright 2007-2014, Joshua Sherman
+ * @license http://www.opensource.org/licenses/mit-license.html
+ * @package PICKLES
+ * @link https://github.com/joshtronic/pickles
+ */
+
+/**
+ * Sort Class
+ *
+ * I got tired of writing separate usort functions to sort by different array
+ * keys in the array, this class solves that.
+ */
+class Sort
+{
+ /**
+ * Ascending
+ *
+ * Variable to utilize ascending sort
+ *
+ * @var integer
+ */
+ const ASC = 'ASC';
+
+ /**
+ * Descending
+ *
+ * Variable to utilize descending sort
+ *
+ * @var integer
+ */
+ const DESC = 'DESC';
+
+ /**
+ * Sort By
+ *
+ * Sorts an array by the specified column, optionally in either direction.
+ *
+ * @param string $field field to sort by
+ * @param array $array array to sort
+ * @param string $direction optional direction to sort
+ * @retun boolean true because sorting is done by reference
+ */
+ public static function by($field, &$array, $direction = Sort::ASC)
+ {
+ usort($array, create_function('$a, $b', '
+ $a = $a["' . $field . '"];
+ $b = $b["' . $field . '"];
+
+ if ($a == $b)
+ {
+ return 0;
+ }
+
+ return ($a ' . ($direction == Sort::DESC ? '>' : '<') .' $b) ? -1 : 1;
+ '));
+
+ return true;
+ }
+}
+
+?>
diff --git a/classes/String.php b/classes/String.php
new file mode 100644
index 0000000..bed4359
--- /dev/null
+++ b/classes/String.php
@@ -0,0 +1,267 @@
+
+ * @copyright Copyright 2007-2014, Joshua Sherman
+ * @license http://www.opensource.org/licenses/mit-license.html
+ * @package PICKLES
+ * @link https://github.com/joshtronic/pickles
+ */
+
+/**
+ * String Class
+ *
+ * Just a simple collection of static functions to accomplish some of the
+ * more redundant string related manipulation.
+ */
+class String
+{
+ // {{{ Format Phone Number
+
+ /**
+ * Format Phone Number
+ *
+ * Formats a 10 digit phone number with dashes as ###-###-####.
+ *
+ * @static
+ * @param string $number number to format
+ * @param string $replacement output of the string
+ * @return string formatted phone number
+ */
+ public static function formatPhoneNumber($number, $replacement = '$1-$2-$3')
+ {
+ // Strips characters we don't need
+ $number = str_replace(array('(', ')', ' ', '-', '.', '_'), '', $number);
+
+ // Formats the number
+ return preg_replace('/^(\d{3})(\d{3})(.+)$/', $replacement, $number);
+ }
+
+ // }}}
+ // {{{ Generate Gravatar Hash
+
+ /**
+ * Generate Gravatar Hash
+ *
+ * Generates a hash from the passed string that can then be used for
+ * fetching an avatar from Gravatar.com
+ *
+ * @deprecated
+ * @static
+ * @param string $string string to hash, should be an email address
+ * @return string resulting hash
+ */
+ public static function generateGravatarHash($string)
+ {
+ return API_Gravatar::hash($string);
+ }
+
+ // }}}
+ // {{{ Generate Slug
+
+ /**
+ * Generate Slug
+ *
+ * Generates a slug from the pass string by lowercasing the string,
+ * trimming whitespace and converting non-alphanumeric values to
+ * dashes. Takes care of multiple dashes as well.
+ *
+ * @static
+ * @param string $string to be converted to the slug
+ * @return string resulting slug
+ */
+ public static function generateSlug($string)
+ {
+ $string = strtolower(trim($string));
+ $string = preg_replace('/[^a-z0-9-]/', '-', $string);
+ $string = preg_replace('/-+/', '-', $string);
+ return trim($string, '-');;
+ }
+
+ // }}}
+ // {{{ Is Empty
+
+ /**
+ * Is Empty
+ *
+ * Checks if a string is empty. You can use the PHP function empty()
+ * but that returns true for a string of "0". Last I checked, that's
+ * not an empty string. PHP's function also doesn't apply trim() to the
+ * value to ensure it's not just a bunch of spaces.
+ *
+ * @static
+ * @param string $value string(s) to be checked
+ * @return boolean whether or not the string is empty
+ */
+ public static function isEmpty()
+ {
+ foreach (func_get_args() as $value)
+ {
+ if (trim($value) == '')
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ // }}}
+ // {{{ Pluralize
+
+ /**
+ * Pluralize
+ *
+ * Based on a passed integer, the word will be pluralized. A value of
+ * zero will also pluralize the word (e.g. 0 things not 0 thing).
+ *
+ * @static
+ * @param string $string the word to plurailze
+ * @param integer $count the count to interrogate
+ * @param boolean $both (optional) include count in return
+ * @return string pluralized word
+ */
+ public static function pluralize($string, $count, $both = false)
+ {
+ if ($count != 1)
+ {
+ $string .= 's';
+ }
+
+ if ($both)
+ {
+ $string = $count . ' ' . $string;
+ }
+
+ return $string;
+ }
+
+ // }}}
+ // {{{ Random
+
+ /**
+ * Random
+ *
+ * Generates a pseudo-random string based on the passed parameters.
+ *
+ * Note: Similar characters = 0, O, 1, I (and may be expanded)
+ *
+ * @static
+ * @param integer $length optional length of the generated string
+ * @param boolean $alpha optional include alpha characters
+ * @param boolean $numeric optional include numeric characters
+ * @param boolean $similar optional include similar characters
+ * @return string generated string
+ */
+ public static function random($length = 8, $alpha = true, $numeric = true, $similar = true)
+ {
+ $characters = array();
+ $string = '';
+
+ // Adds alpha characters to the list
+ if ($alpha == true)
+ {
+ if ($similar == true)
+ {
+ $characters = array_merge($characters, range('a', 'z'));
+ }
+ else
+ {
+ $characters = array_merge($characters, range('a', 'h'), range('j', 'n'), range('p', 'z'));
+ }
+ }
+
+ // Adds numeric characters to the list
+ if ($numeric == true)
+ {
+ if ($similar == true)
+ {
+ $characters = array_merge($characters, range('0', '9'));
+ }
+ else
+ {
+ $characters = array_merge($characters, range('2', '9'));
+ }
+ }
+
+ if (count($characters) > 0)
+ {
+ shuffle($characters);
+
+ for ($i = 0; $i < $length; $i++)
+ {
+ $string .= $characters[array_rand($characters)];
+ }
+ }
+
+ return $string;
+ }
+
+ // }}}
+ // {{{ Truncate
+
+ /**
+ * Truncate
+ *
+ * Truncates a string to a specified length and (optionally) adds a
+ * span to provide a rollover to see the expanded text.
+ *
+ * @static
+ * @param string $string string to truncate
+ * @param integer $length length to truncate to
+ * @param boolean $hover (optional) whether or not to add the rollover
+ * @return string truncate string
+ */
+ public static function truncate($string, $length, $hover = true)
+ {
+ if (strlen($string) > $length)
+ {
+ if ($hover == true)
+ {
+ $string = '' . mb_strcut($string, 0, $length, 'UTF-8') . '…';
+ }
+ else
+ {
+ $string = mb_strcut($string, 0, $length, 'UTF-8') . '…';
+ }
+ }
+
+ return $string;
+ }
+
+ // }}}
+ // {{{ Upper Words
+
+ /**
+ * Upper Words
+ *
+ * Applies strtolower() and ucwords() to the passed string. The
+ * exception being email addresses which are not formatted at all.
+ *
+ * @static
+ * @param string $string string to format
+ * @return string formatted string
+ */
+ public static function upperWords($string)
+ {
+ // Only formats non-email addresses
+ if (filter_var($string, FILTER_VALIDATE_EMAIL) == false)
+ {
+ $string = ucwords(strtolower($string));
+ }
+
+ return $string;
+ }
+
+ // }}}
+}
+
+?>
+
diff --git a/classes/Time.php b/classes/Time.php
new file mode 100644
index 0000000..aba170d
--- /dev/null
+++ b/classes/Time.php
@@ -0,0 +1,234 @@
+
+ * @copyright Copyright 2007-2014, Joshua Sherman
+ * @license http://www.opensource.org/licenses/mit-license.html
+ * @package PICKLES
+ * @link https://github.com/joshtronic/pickles
+ */
+
+/**
+ * Time Class
+ *
+ * Just a simple collection of static functions to accomplish some of the more
+ * redundant time and date related manipulation.
+ */
+class Time
+{
+ // {{{ Intervals (in seconds)
+
+ /**
+ * Minute
+ *
+ * Seconds in a minute
+ *
+ * @var integer
+ */
+ const MINUTE = 60;
+
+ /**
+ * Hour
+ *
+ * Seconds in an hour (minute * 60)
+ *
+ * @var integer
+ */
+ const HOUR = 3600;
+
+ /**
+ * Day
+ *
+ * Seconds in a day (hour * 24)
+ *
+ * @var integer
+ */
+ const DAY = 86400;
+
+ /**
+ * Week
+ *
+ * Seconds in a week (day * 7)
+ *
+ * @var integer
+ */
+ const WEEK = 604800;
+
+ /**
+ * Month
+ *
+ * Seconds in a month (day * 30)
+ *
+ * @var integer
+ */
+ const MONTH = 2592000;
+
+ /**
+ * Quarter
+ *
+ * Seconds in a quarter (day * 90)
+ *
+ * @var integer
+ */
+ const QUARTER = 7776000;
+
+ /**
+ * Year
+ *
+ * Seconds in a year (day * 365)
+ *
+ * @var integer
+ */
+ const YEAR = 31536000;
+
+ /**
+ * Decade
+ *
+ * Seconds in a decade (year * 10)
+ *
+ * @var integer
+ */
+ const DECADE = 315360000;
+
+ /**
+ * Century
+ *
+ * Seconds in a decade (decade * 10)
+ *
+ * @var integer
+ */
+ const CENTURY = 3153600000;
+
+ // }}}
+
+ /**
+ * Age
+ *
+ * Calculates age based on the passed date.
+ *
+ * @static
+ * @param string $date birth / inception date
+ * @return integer $age number of years old
+ * @todo Wondering if this really should live in the Date class since it's a Date function. Could flip the aliasing to preserve any older code.
+ */
+ public static function age($date)
+ {
+ if (!preg_match('/\d{4}-\d{2}-\d{2}/', $date))
+ {
+ $date = date('Y-m-d', strtotime($date));
+ }
+
+ list($year, $month, $day) = explode('-', $date, 3);
+
+ $age = date('Y') - $year;
+
+ if (date('md') < $month . $day)
+ {
+ $age--;
+ }
+
+ return $age;
+ }
+
+ /**
+ * Ago
+ *
+ * Generates a relative time (e.g. X minutes ago).
+ *
+ * @static
+ * @param mixed $time timestamp to calculate from
+ * @return string relative time
+ */
+ public static function ago($time)
+ {
+ $current = strtotime(Time::timestamp());
+ $time = preg_match('/^\d+$/', $time) ? $time : strtotime($time);
+
+ if ($current == $time)
+ {
+ $time_ago = 'just now';
+ }
+ else
+ {
+ if ($current > $time)
+ {
+ $difference = $current - $time;
+ $suffix = ' ago';
+ }
+ else
+ {
+ $difference = $time - $current;
+ $suffix = ' from now';
+ }
+
+ // Less than 1 minute ago (seconds ago)
+ if ($difference < 60)
+ {
+ $time_ago = 'seconds';
+ }
+ // Less than 1 hour ago (minutes ago)
+ elseif ($difference < 3600)
+ {
+ $minutes = round($difference / 60);
+ $time_ago = $minutes . ' minute' . ($minutes != 1 ? 's' : '');
+ }
+ // Less than 1 day ago (hours ago)
+ elseif ($difference < 86400)
+ {
+ $hours = round($difference / 3600);
+ $time_ago = $hours . ' hour' . ($hours != 1 ? 's' : '');
+ }
+ // Less than 1 week ago (days ago)
+ elseif ($difference < 604800)
+ {
+ $days = round($difference / 86400);
+ $time_ago = $days . ' day' . ($days != 1 ? 's' : '');
+ }
+ // Less than 1 month ago (weeks ago)
+ elseif ($difference < 2419200)
+ {
+ $weeks = round($difference / 604800);
+ $time_ago = $weeks . ' week' . ($weeks != 1 ? 's' : '');
+ }
+ // Less than 1 year ago (months ago)
+ elseif ($difference < 31449600)
+ {
+ $months = round($difference / 2419200);
+ $time_ago = $months . ' month' . ($months != 1 ? 's' : '');
+ }
+ // Over 1 year ago (years ago)
+ else
+ {
+ $years = round($difference / 31449600);
+ $time_ago = $years . ' year' . ($years != 1 ? 's' : '');
+ }
+
+ $time_ago .= $suffix;
+ }
+
+ return $time_ago;
+ }
+
+ /**
+ * Timestamp
+ *
+ * Current Universal Time in the specified format.
+ *
+ * @static
+ * @param string $format format of the timestamp
+ * @return string $timestamp formatted timestamp
+ */
+ public static function timestamp($format = 'Y-m-d H:i:s')
+ {
+ return gmdate($format);
+ }
+}
+
+?>
diff --git a/classes/Validate.php b/classes/Validate.php
new file mode 100644
index 0000000..467b6fa
--- /dev/null
+++ b/classes/Validate.php
@@ -0,0 +1,157 @@
+
+ * @copyright Copyright 2007-2014, Joshua Sherman
+ * @license http://www.opensource.org/licenses/mit-license.html
+ * @package PICKLES
+ * @link https://github.com/joshtronic/pickles
+ */
+
+/**
+ * Validate Class
+ *
+ * Validation layer that's used by the Modules to validate passed data. Handles
+ * single sanity checks against a variable so the validation itself can be used
+ * in other places in the system
+ */
+class Validate
+{
+ /**
+ * Is Valid?
+ *
+ * Checks if a variable is valid based on the passed rules.
+ *
+ * @param mixed $value the value to be validated
+ * @param array $rules an array of rules (and messages) to validate with
+ * @return mixed boolean true if valid, array of errors if invalid
+ */
+ public static function isValid($value, $rules)
+ {
+ $errors = array();
+
+ if (is_array($rules))
+ {
+ foreach ($rules as $rule => $message)
+ {
+ $rule = explode(':', $rule);
+
+ switch (strtolower($rule[0]))
+ {
+ // @todo case 'alpha':
+ // @todo case 'alphanumeric':
+ // @todo case 'date':
+
+ // {{{ Checks using filter_var()
+
+ case 'filter':
+ if (count($rule) < 2)
+ {
+ throw new Exception('Invalid validation rule, expected: "validate:boolean|email|float|int|ip|regex|url".');
+ }
+ else
+ {
+ switch (strtolower($rule[1]))
+ {
+ case 'boolean':
+ case 'email':
+ case 'float':
+ case 'int':
+ case 'ip':
+ case 'regex':
+ case 'url':
+ $filter = constant('FILTER_VALIDATE_' . strtoupper($rule[1]));
+ break;
+
+ default:
+ throw new Exception('Invalid filter, expecting boolean, email, float, int, ip, regex or url.');
+ break;
+ }
+
+ if (!filter_var($value, $filter))
+ {
+ $errors[] = $message;
+ }
+ }
+
+ break;
+
+ // }}}
+ // {{{ Checks using strlen()
+
+ case 'length':
+ if (count($rule) < 3)
+ {
+ throw new Exception('Invalid validation rule, expected: "length:<|<=|==|!=|>=|>:integer".');
+ }
+ else
+ {
+ if (!filter_var($rule[2], FILTER_VALIDATE_INT))
+ {
+ throw new Exception('Invalid length value, expecting an integer.');
+ }
+ else
+ {
+ $length = strlen($value);
+
+ switch ($rule[1])
+ {
+ case '<': $valid = $length < $rule[2]; break;
+ case '<=': $valid = $length <= $rule[2]; break;
+ case '==': $valid = $length == $rule[2]; break;
+ case '!=': $valid = $length != $rule[2]; break;
+ case '>=': $valid = $length >= $rule[2]; break;
+ case '>': $valid = $length > $rule[2]; break;
+
+ default:
+ throw new Exception('Invalid operator, expecting <, <=, ==, !=, >= or >.');
+ break;
+ }
+
+ if ($valid === true)
+ {
+ $errors[] = $message;
+ }
+ }
+ }
+
+ break;
+
+ // }}}
+
+ // @todo case 'range':
+
+ // {{{ Checks using preg_match()
+
+ case 'regex':
+ if (count($rule) < 3)
+ {
+ throw new Exception('Invalid validation rule, expected: "regex:is|not:string".');
+ }
+ else
+ {
+ if ((strtolower($rule[1]) == 'not' && !preg_match($rule[2], $value)) || preg_match($rule[2], $value))
+ {
+ $errors[] = $message;
+ }
+ }
+ break;
+
+ // }}}
+ }
+
+ }
+ }
+
+ return count($errors) ? $errors : true;
+ }
+}
+
+?>
diff --git a/composer.json b/composer.json
deleted file mode 100644
index 24f7380..0000000
--- a/composer.json
+++ /dev/null
@@ -1,37 +0,0 @@
-{
- "name": "joshtronic/pickles",
- "description": "Pickles is a PHP framework for building kick-ass services",
- "type": "library",
- "keywords": ["framework", "api", "soa", "oauth"],
- "homepage": "http://picklesphp.com",
- "license": "MIT",
- "authors": [
- {
- "name": "Josh Sherman",
- "email": "josh@gravityblvd.com",
- "homepage": "http://joshtronic.com"
- }
- ],
- "support": {
- "issues": "https://github.com/joshtronic/pickles/issues",
- "source": "https://github.com/joshtronic/pickles"
- },
- "minimum-stability" : "dev",
- "require-dev": {
- "phpunit/phpunit": "dev-master",
- "satooshi/php-coveralls": "dev-master"
- },
- "require": {
- "php": ">=5.4",
- "league/oauth2-server": "4.0.x-dev"
- },
- "suggest": {
- "mongodb/mongo-php-driver": "Required to use the Mongo storage engine",
- "predis/predis": "Required to use the Redis storage engine"
- },
- "autoload": {
- "psr-4": {
- "Pickles\\" : "src/"
- }
- }
-}
diff --git a/composer.lock b/composer.lock
deleted file mode 100644
index dfb8338..0000000
--- a/composer.lock
+++ /dev/null
@@ -1,1446 +0,0 @@
-{
- "_readme": [
- "This file locks the dependencies of your project to a known state",
- "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
- "This file is @generated automatically"
- ],
- "hash": "65e330b4eb2873d61093fc36aa624d0f",
- "packages": [
- {
- "name": "league/event",
- "version": "1.0.0",
- "source": {
- "type": "git",
- "url": "https://github.com/thephpleague/event.git",
- "reference": "06adb7ce55b93346be43a3ba677ac613bbf288a2"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/thephpleague/event/zipball/06adb7ce55b93346be43a3ba677ac613bbf288a2",
- "reference": "06adb7ce55b93346be43a3ba677ac613bbf288a2",
- "shasum": ""
- },
- "require": {
- "php": ">=5.4.0"
- },
- "require-dev": {
- "henrikbjorn/phpspec-code-coverage": "1.0.*@dev",
- "phpspec/phpspec": "2.0.*@dev"
- },
- "type": "library",
- "autoload": {
- "psr-4": {
- "League\\Event\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Frank de Jonge",
- "email": "info@frenky.net"
- }
- ],
- "description": "Event package",
- "keywords": [
- "emitter",
- "event",
- "listener"
- ],
- "time": "2014-09-09 14:40:43"
- },
- {
- "name": "league/oauth2-server",
- "version": "dev-develop",
- "source": {
- "type": "git",
- "url": "https://github.com/thephpleague/oauth2-server.git",
- "reference": "6333a975f8fb51111b447a7e85806e4519fb52b9"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/thephpleague/oauth2-server/zipball/6333a975f8fb51111b447a7e85806e4519fb52b9",
- "reference": "6333a975f8fb51111b447a7e85806e4519fb52b9",
- "shasum": ""
- },
- "require": {
- "league/event": "1.0.*",
- "php": ">=5.4.0",
- "symfony/http-foundation": "~2.1"
- },
- "replace": {
- "league/oauth2server": "*",
- "lncd/oauth2": "*"
- },
- "require-dev": {
- "alexbilbie/fizzfuzz": "dev-develop",
- "codeception/codeception": "2.0.*",
- "league/phpunit-coverage-listener": "~1.0",
- "mockery/mockery": "~0.9",
- "phpunit/phpunit": "~4.0",
- "squizlabs/php_codesniffer": "~1.5"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-develop": "4.0.x-dev"
- }
- },
- "autoload": {
- "psr-4": {
- "League\\OAuth2\\Server\\": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Alex Bilbie",
- "email": "hello@alexbilbie.com",
- "homepage": "http://www.alexbilbie.com",
- "role": "Developer"
- }
- ],
- "description": "A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.",
- "homepage": "http://oauth2.thephpleague.com/",
- "keywords": [
- "Authentication",
- "api",
- "auth",
- "authorisation",
- "authorization",
- "oauth",
- "oauth 2",
- "oauth 2.0",
- "oauth2",
- "protect",
- "resource",
- "secure",
- "server"
- ],
- "time": "2014-10-03 13:42:01"
- },
- {
- "name": "symfony/http-foundation",
- "version": "dev-master",
- "target-dir": "Symfony/Component/HttpFoundation",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/HttpFoundation.git",
- "reference": "c24942a7ec2d8409d1f60d02c4460ca8317e885a"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/c24942a7ec2d8409d1f60d02c4460ca8317e885a",
- "reference": "c24942a7ec2d8409d1f60d02c4460ca8317e885a",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "symfony/expression-language": "~2.4"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.6-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "Symfony\\Component\\HttpFoundation\\": ""
- },
- "classmap": [
- "Symfony/Component/HttpFoundation/Resources/stubs"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Symfony Community",
- "homepage": "http://symfony.com/contributors"
- },
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- }
- ],
- "description": "Symfony HttpFoundation Component",
- "homepage": "http://symfony.com",
- "time": "2014-10-07 14:06:18"
- }
- ],
- "packages-dev": [
- {
- "name": "doctrine/instantiator",
- "version": "dev-master",
- "source": {
- "type": "git",
- "url": "https://github.com/doctrine/instantiator.git",
- "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/doctrine/instantiator/zipball/f976e5de371104877ebc89bd8fecb0019ed9c119",
- "reference": "f976e5de371104877ebc89bd8fecb0019ed9c119",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3,<8.0-DEV"
- },
- "require-dev": {
- "athletic/athletic": "~0.1.8",
- "ext-pdo": "*",
- "ext-phar": "*",
- "phpunit/phpunit": "~4.0",
- "squizlabs/php_codesniffer": "2.0.*@ALPHA"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0.x-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "Doctrine\\Instantiator\\": "src"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Marco Pivetta",
- "email": "ocramius@gmail.com",
- "homepage": "http://ocramius.github.com/"
- }
- ],
- "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
- "homepage": "https://github.com/doctrine/instantiator",
- "keywords": [
- "constructor",
- "instantiate"
- ],
- "time": "2014-10-13 12:58:55"
- },
- {
- "name": "guzzle/guzzle",
- "version": "dev-master",
- "source": {
- "type": "git",
- "url": "https://github.com/guzzle/guzzle3.git",
- "reference": "3c0ca2255751631f1dd64eb16bbe3b9440258297"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/3c0ca2255751631f1dd64eb16bbe3b9440258297",
- "reference": "3c0ca2255751631f1dd64eb16bbe3b9440258297",
- "shasum": ""
- },
- "require": {
- "ext-curl": "*",
- "php": ">=5.3.3",
- "symfony/event-dispatcher": "~2.1"
- },
- "replace": {
- "guzzle/batch": "self.version",
- "guzzle/cache": "self.version",
- "guzzle/common": "self.version",
- "guzzle/http": "self.version",
- "guzzle/inflection": "self.version",
- "guzzle/iterator": "self.version",
- "guzzle/log": "self.version",
- "guzzle/parser": "self.version",
- "guzzle/plugin": "self.version",
- "guzzle/plugin-async": "self.version",
- "guzzle/plugin-backoff": "self.version",
- "guzzle/plugin-cache": "self.version",
- "guzzle/plugin-cookie": "self.version",
- "guzzle/plugin-curlauth": "self.version",
- "guzzle/plugin-error-response": "self.version",
- "guzzle/plugin-history": "self.version",
- "guzzle/plugin-log": "self.version",
- "guzzle/plugin-md5": "self.version",
- "guzzle/plugin-mock": "self.version",
- "guzzle/plugin-oauth": "self.version",
- "guzzle/service": "self.version",
- "guzzle/stream": "self.version"
- },
- "require-dev": {
- "doctrine/cache": "~1.3",
- "monolog/monolog": "~1.0",
- "phpunit/phpunit": "3.7.*",
- "psr/log": "~1.0",
- "symfony/class-loader": "~2.1",
- "zendframework/zend-cache": "2.*,<2.3",
- "zendframework/zend-log": "2.*,<2.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "3.9-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "Guzzle": "src/",
- "Guzzle\\Tests": "tests/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Michael Dowling",
- "email": "mtdowling@gmail.com",
- "homepage": "https://github.com/mtdowling"
- },
- {
- "name": "Guzzle Community",
- "homepage": "https://github.com/guzzle/guzzle/contributors"
- }
- ],
- "description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
- "homepage": "http://guzzlephp.org/",
- "keywords": [
- "client",
- "curl",
- "framework",
- "http",
- "http client",
- "rest",
- "web service"
- ],
- "time": "2014-10-15 19:36:56"
- },
- {
- "name": "phpunit/php-code-coverage",
- "version": "dev-master",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
- "reference": "28d21b57c189cb72829056353de603c4d4da55a0"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/28d21b57c189cb72829056353de603c4d4da55a0",
- "reference": "28d21b57c189cb72829056353de603c4d4da55a0",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3",
- "phpunit/php-file-iterator": "~1.3",
- "phpunit/php-text-template": "~1.2",
- "phpunit/php-token-stream": "~1.3",
- "sebastian/environment": "~1.0",
- "sebastian/version": "~1.0"
- },
- "require-dev": {
- "ext-xdebug": ">=2.1.4",
- "phpunit/phpunit": "dev-master"
- },
- "suggest": {
- "ext-dom": "*",
- "ext-xdebug": ">=2.2.1",
- "ext-xmlwriter": "*"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "3.0.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sb@sebastian-bergmann.de",
- "role": "lead"
- }
- ],
- "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
- "homepage": "https://github.com/sebastianbergmann/php-code-coverage",
- "keywords": [
- "coverage",
- "testing",
- "xunit"
- ],
- "time": "2014-10-05 10:46:54"
- },
- {
- "name": "phpunit/php-file-iterator",
- "version": "1.3.4",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-file-iterator.git",
- "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb",
- "reference": "acd690379117b042d1c8af1fafd61bde001bf6bb",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "type": "library",
- "autoload": {
- "classmap": [
- "File/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "include-path": [
- ""
- ],
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sb@sebastian-bergmann.de",
- "role": "lead"
- }
- ],
- "description": "FilterIterator implementation that filters files based on a list of suffixes.",
- "homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
- "keywords": [
- "filesystem",
- "iterator"
- ],
- "time": "2013-10-10 15:34:57"
- },
- {
- "name": "phpunit/php-text-template",
- "version": "1.2.0",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-text-template.git",
- "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
- "reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "type": "library",
- "autoload": {
- "classmap": [
- "Text/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "include-path": [
- ""
- ],
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sb@sebastian-bergmann.de",
- "role": "lead"
- }
- ],
- "description": "Simple template engine.",
- "homepage": "https://github.com/sebastianbergmann/php-text-template/",
- "keywords": [
- "template"
- ],
- "time": "2014-01-30 17:20:04"
- },
- {
- "name": "phpunit/php-timer",
- "version": "1.0.5",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-timer.git",
- "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
- "reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "type": "library",
- "autoload": {
- "classmap": [
- "PHP/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "include-path": [
- ""
- ],
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sb@sebastian-bergmann.de",
- "role": "lead"
- }
- ],
- "description": "Utility class for timing",
- "homepage": "https://github.com/sebastianbergmann/php-timer/",
- "keywords": [
- "timer"
- ],
- "time": "2013-08-02 07:42:54"
- },
- {
- "name": "phpunit/php-token-stream",
- "version": "dev-master",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/php-token-stream.git",
- "reference": "f8d5d08c56de5cfd592b3340424a81733259a876"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/f8d5d08c56de5cfd592b3340424a81733259a876",
- "reference": "f8d5d08c56de5cfd592b3340424a81733259a876",
- "shasum": ""
- },
- "require": {
- "ext-tokenizer": "*",
- "php": ">=5.3.3"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.2"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.3-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Wrapper around PHP's tokenizer extension.",
- "homepage": "https://github.com/sebastianbergmann/php-token-stream/",
- "keywords": [
- "tokenizer"
- ],
- "time": "2014-08-31 06:12:13"
- },
- {
- "name": "phpunit/phpunit",
- "version": "dev-master",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "cd4014775069d7d39d20f617037c2c0f9b4bc25b"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/cd4014775069d7d39d20f617037c2c0f9b4bc25b",
- "reference": "cd4014775069d7d39d20f617037c2c0f9b4bc25b",
- "shasum": ""
- },
- "require": {
- "ext-dom": "*",
- "ext-json": "*",
- "ext-pcre": "*",
- "ext-reflection": "*",
- "ext-spl": "*",
- "php": ">=5.3.3",
- "phpunit/php-code-coverage": "3.0.*@dev",
- "phpunit/php-file-iterator": "~1.3.1",
- "phpunit/php-text-template": "~1.2",
- "phpunit/php-timer": "~1.0.2",
- "phpunit/phpunit-mock-objects": "2.4.*@dev",
- "sebastian/comparator": "~1.0",
- "sebastian/diff": "~1.1",
- "sebastian/environment": "~1.1",
- "sebastian/exporter": "~1.0",
- "sebastian/global-state": "1.0.*@dev",
- "sebastian/version": "~1.0",
- "symfony/yaml": "~2.0"
- },
- "suggest": {
- "phpunit/php-invoker": "~1.1"
- },
- "bin": [
- "phpunit"
- ],
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "4.4.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "The PHP Unit Testing framework.",
- "homepage": "https://phpunit.de/",
- "keywords": [
- "phpunit",
- "testing",
- "xunit"
- ],
- "time": "2014-10-17 09:28:50"
- },
- {
- "name": "phpunit/phpunit-mock-objects",
- "version": "dev-master",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
- "reference": "96c5b81f9842f38fe6c73ad0020306cc4862a9e3"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/96c5b81f9842f38fe6c73ad0020306cc4862a9e3",
- "reference": "96c5b81f9842f38fe6c73ad0020306cc4862a9e3",
- "shasum": ""
- },
- "require": {
- "doctrine/instantiator": "~1.0,>=1.0.2",
- "php": ">=5.3.3",
- "phpunit/php-text-template": "~1.2"
- },
- "require-dev": {
- "phpunit/phpunit": "4.4.*@dev"
- },
- "suggest": {
- "ext-soap": "*"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.4.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sb@sebastian-bergmann.de",
- "role": "lead"
- }
- ],
- "description": "Mock Object library for PHPUnit",
- "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
- "keywords": [
- "mock",
- "xunit"
- ],
- "time": "2014-10-04 10:04:20"
- },
- {
- "name": "psr/log",
- "version": "1.0.0",
- "source": {
- "type": "git",
- "url": "https://github.com/php-fig/log.git",
- "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b",
- "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b",
- "shasum": ""
- },
- "type": "library",
- "autoload": {
- "psr-0": {
- "Psr\\Log\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "PHP-FIG",
- "homepage": "http://www.php-fig.org/"
- }
- ],
- "description": "Common interface for logging libraries",
- "keywords": [
- "log",
- "psr",
- "psr-3"
- ],
- "time": "2012-12-21 11:40:51"
- },
- {
- "name": "satooshi/php-coveralls",
- "version": "dev-master",
- "source": {
- "type": "git",
- "url": "https://github.com/satooshi/php-coveralls.git",
- "reference": "94389a0ebdb64857d6899b5e0254dffa99e5aa96"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/94389a0ebdb64857d6899b5e0254dffa99e5aa96",
- "reference": "94389a0ebdb64857d6899b5e0254dffa99e5aa96",
- "shasum": ""
- },
- "require": {
- "ext-json": "*",
- "ext-simplexml": "*",
- "guzzle/guzzle": ">=2.7",
- "php": ">=5.3",
- "psr/log": "1.0.0",
- "symfony/config": ">=2.0",
- "symfony/console": ">=2.0",
- "symfony/stopwatch": ">=2.2",
- "symfony/yaml": ">=2.0"
- },
- "require-dev": {
- "apigen/apigen": "2.8.*@stable",
- "pdepend/pdepend": "dev-master as 2.0.0",
- "phpmd/phpmd": "dev-master",
- "phpunit/php-invoker": ">=1.1.0,<1.2.0",
- "phpunit/phpunit": "3.7.*@stable",
- "sebastian/finder-facade": "dev-master",
- "sebastian/phpcpd": "1.4.*@stable",
- "squizlabs/php_codesniffer": "1.4.*@stable",
- "theseer/fdomdocument": "dev-master"
- },
- "suggest": {
- "symfony/http-kernel": "Allows Symfony integration"
- },
- "bin": [
- "composer/bin/coveralls"
- ],
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "0.7-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "Satooshi\\Component": "src/",
- "Satooshi\\Bundle": "src/"
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Kitamura Satoshi",
- "email": "with.no.parachute@gmail.com",
- "homepage": "https://www.facebook.com/satooshi.jp"
- }
- ],
- "description": "PHP client library for Coveralls API",
- "homepage": "https://github.com/satooshi/php-coveralls",
- "keywords": [
- "ci",
- "coverage",
- "github",
- "test"
- ],
- "time": "2014-07-09 10:45:38"
- },
- {
- "name": "sebastian/comparator",
- "version": "dev-master",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/comparator.git",
- "reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/e54a01c0da1b87db3c5a3c4c5277ddf331da4aef",
- "reference": "e54a01c0da1b87db3c5a3c4c5277ddf331da4aef",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3",
- "sebastian/diff": "~1.1",
- "sebastian/exporter": "~1.0"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.1"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- },
- {
- "name": "Jeff Welch",
- "email": "whatthejeff@gmail.com"
- },
- {
- "name": "Volker Dusch",
- "email": "github@wallbash.com"
- },
- {
- "name": "Bernhard Schussek",
- "email": "bschussek@2bepublished.at"
- }
- ],
- "description": "Provides the functionality to compare PHP values for equality",
- "homepage": "http://www.github.com/sebastianbergmann/comparator",
- "keywords": [
- "comparator",
- "compare",
- "equality"
- ],
- "time": "2014-05-11 23:00:21"
- },
- {
- "name": "sebastian/diff",
- "version": "dev-master",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/diff.git",
- "reference": "92d423df43b160006907ea4297b916fdf00415d8"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/92d423df43b160006907ea4297b916fdf00415d8",
- "reference": "92d423df43b160006907ea4297b916fdf00415d8",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.2"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.2-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Kore Nordmann",
- "email": "mail@kore-nordmann.de"
- },
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Diff implementation",
- "homepage": "http://www.github.com/sebastianbergmann/diff",
- "keywords": [
- "diff"
- ],
- "time": "2014-10-19 13:19:30"
- },
- {
- "name": "sebastian/environment",
- "version": "dev-master",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/environment.git",
- "reference": "205fcef5998953ec69cb79bc1ea9fee1277c8714"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/205fcef5998953ec69cb79bc1ea9fee1277c8714",
- "reference": "205fcef5998953ec69cb79bc1ea9fee1277c8714",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.1.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Provides functionality to handle HHVM/PHP environments",
- "homepage": "http://www.github.com/sebastianbergmann/environment",
- "keywords": [
- "Xdebug",
- "environment",
- "hhvm"
- ],
- "time": "2014-10-08 05:30:43"
- },
- {
- "name": "sebastian/exporter",
- "version": "dev-master",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/exporter.git",
- "reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/c7d59948d6e82818e1bdff7cadb6c34710eb7dc0",
- "reference": "c7d59948d6e82818e1bdff7cadb6c34710eb7dc0",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.0"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0.x-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Jeff Welch",
- "email": "whatthejeff@gmail.com"
- },
- {
- "name": "Volker Dusch",
- "email": "github@wallbash.com"
- },
- {
- "name": "Bernhard Schussek",
- "email": "bschussek@2bepublished.at"
- },
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- },
- {
- "name": "Adam Harvey",
- "email": "aharvey@php.net"
- }
- ],
- "description": "Provides the functionality to export PHP variables for visualization",
- "homepage": "http://www.github.com/sebastianbergmann/exporter",
- "keywords": [
- "export",
- "exporter"
- ],
- "time": "2014-09-10 00:51:36"
- },
- {
- "name": "sebastian/global-state",
- "version": "dev-master",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/global-state.git",
- "reference": "231d48620efde984fd077ee92916099a3ece9a59"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/231d48620efde984fd077ee92916099a3ece9a59",
- "reference": "231d48620efde984fd077ee92916099a3ece9a59",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "phpunit/phpunit": "~4.2"
- },
- "suggest": {
- "ext-uopz": "*"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "1.0-dev"
- }
- },
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de"
- }
- ],
- "description": "Snapshotting of global state",
- "homepage": "http://www.github.com/sebastianbergmann/global-state",
- "keywords": [
- "global state"
- ],
- "time": "2014-10-06 09:49:11"
- },
- {
- "name": "sebastian/version",
- "version": "1.0.3",
- "source": {
- "type": "git",
- "url": "https://github.com/sebastianbergmann/version.git",
- "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43",
- "reference": "b6e1f0cf6b9e1ec409a0d3e2f2a5fb0998e36b43",
- "shasum": ""
- },
- "type": "library",
- "autoload": {
- "classmap": [
- "src/"
- ]
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "BSD-3-Clause"
- ],
- "authors": [
- {
- "name": "Sebastian Bergmann",
- "email": "sebastian@phpunit.de",
- "role": "lead"
- }
- ],
- "description": "Library that helps with managing the version number of Git-hosted PHP projects",
- "homepage": "https://github.com/sebastianbergmann/version",
- "time": "2014-03-07 15:35:33"
- },
- {
- "name": "symfony/config",
- "version": "dev-master",
- "target-dir": "Symfony/Component/Config",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/Config.git",
- "reference": "b9f7877e02682cb081585c58baf3b9760865b98e"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/Config/zipball/b9f7877e02682cb081585c58baf3b9760865b98e",
- "reference": "b9f7877e02682cb081585c58baf3b9760865b98e",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3",
- "symfony/filesystem": "~2.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.6-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "Symfony\\Component\\Config\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Symfony Community",
- "homepage": "http://symfony.com/contributors"
- },
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- }
- ],
- "description": "Symfony Config Component",
- "homepage": "http://symfony.com",
- "time": "2014-09-25 18:11:49"
- },
- {
- "name": "symfony/console",
- "version": "dev-master",
- "target-dir": "Symfony/Component/Console",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/Console.git",
- "reference": "771649efa94246e63a6ab2726ba908a358bdd403"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/Console/zipball/771649efa94246e63a6ab2726ba908a358bdd403",
- "reference": "771649efa94246e63a6ab2726ba908a358bdd403",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "psr/log": "~1.0",
- "symfony/event-dispatcher": "~2.1",
- "symfony/process": "~2.1"
- },
- "suggest": {
- "psr/log": "For using the console logger",
- "symfony/event-dispatcher": "",
- "symfony/process": ""
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.6-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "Symfony\\Component\\Console\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Symfony Community",
- "homepage": "http://symfony.com/contributors"
- },
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- }
- ],
- "description": "Symfony Console Component",
- "homepage": "http://symfony.com",
- "time": "2014-10-05 13:59:22"
- },
- {
- "name": "symfony/event-dispatcher",
- "version": "dev-master",
- "target-dir": "Symfony/Component/EventDispatcher",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/EventDispatcher.git",
- "reference": "e133748fd9165e24f8e9498ef5862f8bd37004e5"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/e133748fd9165e24f8e9498ef5862f8bd37004e5",
- "reference": "e133748fd9165e24f8e9498ef5862f8bd37004e5",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "require-dev": {
- "psr/log": "~1.0",
- "symfony/config": "~2.0",
- "symfony/dependency-injection": "~2.6",
- "symfony/expression-language": "~2.6",
- "symfony/stopwatch": "~2.2"
- },
- "suggest": {
- "symfony/dependency-injection": "",
- "symfony/http-kernel": ""
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.6-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "Symfony\\Component\\EventDispatcher\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Symfony Community",
- "homepage": "http://symfony.com/contributors"
- },
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- }
- ],
- "description": "Symfony EventDispatcher Component",
- "homepage": "http://symfony.com",
- "time": "2014-10-04 06:08:58"
- },
- {
- "name": "symfony/filesystem",
- "version": "dev-master",
- "target-dir": "Symfony/Component/Filesystem",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/Filesystem.git",
- "reference": "7d97789ea01c3c76ecaa59b954d162777033cbd4"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/Filesystem/zipball/7d97789ea01c3c76ecaa59b954d162777033cbd4",
- "reference": "7d97789ea01c3c76ecaa59b954d162777033cbd4",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.6-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "Symfony\\Component\\Filesystem\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Symfony Community",
- "homepage": "http://symfony.com/contributors"
- },
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- }
- ],
- "description": "Symfony Filesystem Component",
- "homepage": "http://symfony.com",
- "time": "2014-09-22 15:54:44"
- },
- {
- "name": "symfony/stopwatch",
- "version": "dev-master",
- "target-dir": "Symfony/Component/Stopwatch",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/Stopwatch.git",
- "reference": "f7cca9c342ce395d2aa17383d0f9a409d81ca585"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/f7cca9c342ce395d2aa17383d0f9a409d81ca585",
- "reference": "f7cca9c342ce395d2aa17383d0f9a409d81ca585",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.6-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "Symfony\\Component\\Stopwatch\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Symfony Community",
- "homepage": "http://symfony.com/contributors"
- },
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- }
- ],
- "description": "Symfony Stopwatch Component",
- "homepage": "http://symfony.com",
- "time": "2014-09-22 11:59:59"
- },
- {
- "name": "symfony/yaml",
- "version": "dev-master",
- "target-dir": "Symfony/Component/Yaml",
- "source": {
- "type": "git",
- "url": "https://github.com/symfony/Yaml.git",
- "reference": "499f7d7aa96747ad97940089bd7a1fb24ad8182a"
- },
- "dist": {
- "type": "zip",
- "url": "https://api.github.com/repos/symfony/Yaml/zipball/499f7d7aa96747ad97940089bd7a1fb24ad8182a",
- "reference": "499f7d7aa96747ad97940089bd7a1fb24ad8182a",
- "shasum": ""
- },
- "require": {
- "php": ">=5.3.3"
- },
- "type": "library",
- "extra": {
- "branch-alias": {
- "dev-master": "2.6-dev"
- }
- },
- "autoload": {
- "psr-0": {
- "Symfony\\Component\\Yaml\\": ""
- }
- },
- "notification-url": "https://packagist.org/downloads/",
- "license": [
- "MIT"
- ],
- "authors": [
- {
- "name": "Symfony Community",
- "homepage": "http://symfony.com/contributors"
- },
- {
- "name": "Fabien Potencier",
- "email": "fabien@symfony.com"
- }
- ],
- "description": "Symfony Yaml Component",
- "homepage": "http://symfony.com",
- "time": "2014-10-05 13:53:50"
- }
- ],
- "aliases": [],
- "minimum-stability": "dev",
- "stability-flags": {
- "league/oauth2-server": 20,
- "phpunit/phpunit": 20,
- "satooshi/php-coveralls": 20
- },
- "prefer-stable": false,
- "platform": {
- "php": ">=5.4"
- },
- "platform-dev": []
-}
diff --git a/phpunit.xml b/phpunit.xml
deleted file mode 100644
index 2d7ea10..0000000
--- a/phpunit.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-require_once 'pickles.php';
+ */
+
+// {{{ PICKLES Constants
+
+// Grabs the start time in case we're profiling
+define('PICKLES_START_TIME', microtime(true));
+
+// Establishes our PICKLES paths
+define('PICKLES_PATH', dirname(__FILE__) . '/');
+define('PICKLES_CLASS_PATH', PICKLES_PATH . 'classes/');
+define('PICKLES_VENDOR_PATH', PICKLES_PATH . 'vendors/');
+
+// Establishes our site paths
+define('SITE_PATH', getcwd() . '/../');
+
+define('SITE_CLASS_PATH', SITE_PATH . 'classes/');
+define('SITE_MODEL_PATH', SITE_PATH . 'models/');
+define('SITE_MODULE_PATH', SITE_PATH . 'modules/');
+define('SITE_TEMPLATE_PATH', SITE_PATH . 'templates/');
+
+define('PRIVATE_PATH', SITE_PATH . 'private/');
+define('LOG_PATH', PRIVATE_PATH . 'logs/');
+
+// Sets up constants for the Display names
+define('DISPLAY_JSON', 'JSON');
+define('DISPLAY_PHP', 'PHP');
+define('DISPLAY_RSS', 'RSS');
+define('DISPLAY_XML', 'XML');
+
+// Creates a constant as to whether or not we have JSON available
+define('JSON_AVAILABLE', function_exists('json_encode'));
+
+// Creates a variable to flag if we're on the command line
+define('IS_CLI', !isset($_SERVER['REQUEST_METHOD']));
+
+// }}}
+// {{{ Defaults some important configuration options
+
+// Turns on error before the config is loaded to help catch parse errors
+ini_set('display_errors', true);
+error_reporting(-1);
+
+// Sets the error and exception handlers
+// set_error_handler('__handleError');
+// set_exception_handler('__handleException');
+
+// Defaults timezone to UTC if not set
+if (ini_get('date.timezone') == '')
+{
+ ini_set('date.timezone', 'Etc/UTC');
+}
+
+// Sets the session variables
+ini_set('session.cache_expire', 86400);
+ini_set('session.entropy_file', '/dev/urandom');
+ini_set('session.entropy_length', 512);
+ini_set('session.gc_maxlifetime', 86400);
+ini_set('session.gc_probability', 1);
+ini_set('session.gc_divisor', 1000);
+ini_set('session.hash_function', 1);
+
+// }}}
+// {{{ Loads the configuration file and sets any configuration options
+
+// Loads the base config
+$config = Config::getInstance();
+
+// Configures any available PHP configuration options
+if (is_array($config->php) && count($config->php) > 0)
+{
+ foreach ($config->php as $variable => $value)
+ {
+ ini_set($variable, $value);
+ }
+}
+
+// Starts session handling (old)
+if (isset($config->pickles['session']))
+{
+ if (session_id() == '' && $config->pickles['session'] !== false)
+ {
+ new Session();
+ }
+}
+
+// Starts session handling (new)
+if (isset($config->pickles['sessions']))
+{
+ if (session_id() == '' && $config->pickles['sessions'] !== false)
+ {
+ new Session();
+ }
+}
+
+// }}}
+// {{{ Defaults some internals for ease of use
+
+if (!isset($_REQUEST['request']))
+{
+ $_REQUEST['request'] = isset($config->pickles['module']) ? $config->pickles['module'] : '';
+}
+
+// }}}
+// {{{ Auto[magical] Loader
+
+/**
+ * Magic function to automatically load classes
+ *
+ * Attempts to load a core PICKLES class or a site level data model or
+ * module class.
+ *
+ * @param string $class Name of the class to be loaded
+ * @return boolean Return value of require_once() or false (default)
+ */
+function __autoload($class)
+{
+ $loaded = false;
+ $filename = preg_replace('/_/', '/', $class) . '.php';
+
+ if ($class == 'AYAH')
+ {
+ $loaded = require_once PICKLES_VENDOR_PATH . '/ayah/' . strtolower($filename);
+ }
+ else
+ {
+ // Path as the key, boolean value is whether ot not to convert back to hyphenated
+ $paths = array(
+ PICKLES_CLASS_PATH => false,
+ SITE_CLASS_PATH => false,
+ SITE_MODEL_PATH => false,
+ SITE_MODULE_PATH => true,
+ );
+
+ foreach ($paths as $path => $hyphenated)
+ {
+ // Converts the filename back to hypenated
+ if ($hyphenated == true)
+ {
+ $filename = strtolower(preg_replace('/([A-Z]{1})/', '-$1', $filename));;
+ }
+
+ if (file_exists($path . $filename))
+ {
+ $loaded = require_once $path . $filename;
+ break;
+ }
+ }
+ }
+
+ return $loaded;
+}
+
+// }}}
+// {{{ Error Handler
+
+/**
+ * Error handling function that thinks it's magical
+ *
+ * Catches errors (warnings and the like) and throws it back out as an
+ * ErrorException. This really helps trapping complex errors that need a ton of
+ * sanity checks, just try / catch and you're good. Also, this isn't a magic
+ * function, but I opted to use the __ prefix to help avoid a naming collision
+ * since namespace support is 5.3+ and PICKLES strives to be 5.0+ compatible.
+ *
+ * Keep in mind that fatal errors cannot and will not be handled.
+ *
+ * @param integer $errno the level of the error raised
+ * @param string $errstr the error message
+ * @param string $errfile filename that the error was raised in
+ * @param integer $errline line number the error was raised at
+ * @param array $errcontext array of every variable that existed in scope
+ * @return ErrorException not really returned, but worth documenting
+ */
+function __handleError($errno, $errstr, $errfile, $errline, array $errcontext)
+{
+ // Handle hacktastic @ error suppression. Seriously, don't ever use @
+ if (error_reporting() === 0)
+ {
+ return false;
+ }
+
+ throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
+}
+
+// }}}
+// {{{ Exception Handler
+
+/**
+ * Top level exception handling function
+ *
+ * Catches uncaught exceptions and displays them.
+ *
+ * @param object $exception the exception
+ */
+function __handleException($exception)
+{
+ if (IS_CLI == true)
+ {
+ $lines = array();
+ $maxes = array('key' => 0, 'method' => 0, 'file' => 0, 'line' => 4);
+
+ $trace = $exception->getTrace();
+ rsort($trace);
+
+ foreach ($trace as $key => $data)
+ {
+ $method = '';
+
+ if (isset($data['class']))
+ {
+ $method .= $data['class'] . $data['type'];
+ }
+
+ $method .= $data['function'] . '()';
+
+ $line = array(
+ 'key' => $key + 1 . '.',
+ 'method' => $method,
+ 'file' => (isset($data['file']) ? $data['file'] : __FILE__),
+ 'line' => (isset($data['line']) ? $data['line'] : '0')
+ );
+
+ foreach (array_keys($maxes) as $variable)
+ {
+ $length = strlen($line[$variable]);
+
+ if ($length > $maxes[$variable])
+ {
+ $maxes[$variable] = $length;
+ }
+ }
+
+ $lines[] = $line;
+ }
+
+ $max_length = array_sum($maxes) + 11;
+ $horizontal_border = '+' . str_repeat('-', $max_length) . '+' . "\n";
+
+ echo $horizontal_border;
+ echo '|' . str_pad('Uncaught Exception', $max_length, ' ', STR_PAD_BOTH) . '|' . "\n";
+ echo $horizontal_border;
+ echo '|' . str_pad(' ' . $exception->getMessage(), $max_length) . '|' . "\n";
+ echo '|' . str_pad(' in ' . $exception->getFile() . ' on line ' . $exception->getLine(), $max_length) . '|' . "\n";
+
+ echo $horizontal_border;
+ echo '| ' . str_pad('Trace', $maxes['key'] + $maxes['method'] + 3) . ' | ' . str_pad('File', $maxes['file']) . ' | ' . str_pad('Line', $maxes['line']) . ' |' . "\n";
+ echo $horizontal_border;
+
+ foreach ($lines as $line)
+ {
+ echo '| ';
+
+ echo implode(
+ array(
+ str_pad($line['key'], $maxes['key'], ' ', STR_PAD_LEFT),
+ str_pad($line['method'], $maxes['method']),
+ str_pad($line['file'], $maxes['file']),
+ str_pad($line['line'], $maxes['line'], ' ', STR_PAD_LEFT)
+ ),
+ ' | '
+ );
+
+ echo ' |' . "\n";
+ }
+
+ echo $horizontal_border;
+ }
+ else
+ {
+ ?>
+
+
+ getMessage(); ?>
+ |
+ getFile(); ?> on line getLine(); ?>
+ |
Trace | +File | +Line | +|
---|---|---|---|
. | ++ | + | + |
Profiler::log($object, 'methodName');
- */
-class Profiler
-{
- /**
- * Logs
- *
- * Array of logged events
- *
- * @static
- * @access private
- * @var array
- */
- private static $logs = [];
-
- /**
- * Timers
- *
- * Array of active timers
- *
- * @static
- * @access private
- * @var array
- */
- private static $timers = [];
-
- /**
- * Log
- *
- * Logs the event to be displayed later on. Due to the nature of how much
- * of a pain it is to determine which class method called this method I
- * opted to make the method a passable argument for ease of use. Perhaps
- * I'll revisit in the future. Handles all elapsed time calculations and
- * memory usage.
- *
- * @static
- * @param mixed $data data to log
- * @param string $method name of the class method being logged
- */
- public static function log($data, $method = false, $type = false)
- {
- $time = microtime(true);
- $data_type = ($data == 'timer' ? $data : gettype($data));
-
- // Tidys the data by type
- switch ($data_type)
- {
- case 'object':
- $details['class'] = get_class($data);
-
- if ($method != '')
- {
- $details['method'] = $method . '()';
- }
-
- $data_type = $data_type;
- break;
-
- case 'timer':
- $details = $method;
- $data_type = $data_type;
- break;
-
- default:
- if ($type != false)
- {
- $data_type = $type;
- }
-
- $details = $data;
- break;
- }
-
- self::$logs[] = [
- 'type' => $data_type,
- 'timestamp' => $time,
- 'elapsed_time' => $time - $_SERVER['REQUEST_TIME_FLOAT'],
- 'memory_usage' => memory_get_usage(),
- 'details' => $details,
- ];
- }
-
- /**
- * Query
- *
- * Serves as a wrapper to get query data to the log function
- *
- * @static
- * @param string $query the query being executed
- * @param array $input_parameters optional prepared statement data
- * @param array $results optional results of the query
- * @param float $duration the speed of the query
- * @param array $explain EXPLAIN data for the query
- */
- public static function query($query, $input_parameters = false, $results = false, $duration = false, $explain = false)
- {
- $log = [
- 'query' => $query,
- 'parameters' => $input_parameters,
- 'results' => $results,
- 'execution_time' => $duration,
- ];
-
- if ($explain)
- {
- $log['explain'] = $explain;
- }
-
- self::log($log, false, 'database');
- }
-
- /**
- * Timer
- *
- * Logs the start and end of a timer.
- *
- * @param string $timer name of the timer
- * @return boolean whether or not timer profiling is enabled
- */
- public static function timer($timer)
- {
- // Starts the timer
- if (!isset(self::$timers[$timer]))
- {
- self::$timers[$timer] = microtime(true);
-
- self::Log('timer', [
- 'action' => 'start',
- 'name' => $timer
- ]);
- }
- // Ends the timer
- else
- {
- self::Log('timer', [
- 'action' => 'stop',
- 'name' => $timer,
- 'elapsed_time' => (microtime(true) - self::$timers[$timer])
- ]);
-
- unset(self::$timers[$timer]);
- }
- }
-
- /**
- * Report
- *
- * Generates the Profiler report that is displayed by the Controller.
- * Contains all the HTML needed to display the data properly inline on the
- * page. Will generally be displayed after the closing HTML tag.
- */
- public static function report()
- {
- $report = [
- 'request_time' => $_SERVER['REQUEST_TIME_FLOAT'],
- 'execution_time' => self::$logs[count(self::$logs) - 1]['timestamp']
- - $_SERVER['REQUEST_TIME_FLOAT'],
- 'peak_memory_usage' => memory_get_peak_usage(),
- 'max_execution_time' => ini_get('max_execution_time'),
- 'memory_limit' => ini_get('memory_limit'),
- 'included_files' => count(get_included_files()),
- 'logs' => self::$logs,
- ];
-
- self::$logs = [];
- self::$timers = [];
-
- return $report;
- }
-}
-
diff --git a/src/Resource.php b/src/Resource.php
deleted file mode 100644
index fadd62f..0000000
--- a/src/Resource.php
+++ /dev/null
@@ -1,387 +0,0 @@
-uids = $uids;
- $method = $_SERVER['REQUEST_METHOD'];
-
- try
- {
- // Checks if auth flag is explicity true or true for the method
- if ($this->auth === true
- || (isset($this->auth[$method]) && $this->auth[$method]))
- {
- if (isset($this->config['oauth'][$_SERVER['__version']]))
- {
- $server = new ResourceServer(
- new SessionStorage,
- new AccessTokenStorage,
- new ClientStorage,
- new ScopeStorage
- );
-
- $server->isValidRequest();
- }
- else
- {
- throw new \Exception('Authentication is not configured properly.', 401);
- }
- }
-
- // Hacks together some new globals
- if (in_array($method, ['PUT', 'DELETE']))
- {
- $GLOBALS['_' . $method] = [];
-
- // @todo Populate it
- }
-
- $filter = isset($this->filter[$method]);
- $validate = isset($this->validate[$method]);
-
- if ($filter || $validate)
- {
- $global =& $GLOBALS['_' . $method];
-
- // Checks that the required parameters are present
- // @todo Add in support for uid:* variables
- if ($validate)
- {
- $variables = [];
-
- foreach ($this->validate[$method] as $variable => $rules)
- {
- if (!is_array($rules))
- {
- $variable = $rules;
- }
-
- $variables[] = $variable;
- }
-
- $missing_variables = array_diff($variables, array_keys($global));
-
- if ($missing_variables !== array())
- {
- foreach ($missing_variables as $variable)
- {
- $this->errors[$variable][] = 'The ' . $variable . ' parameter is required.';
- }
- }
- }
-
- foreach ($global as $variable => $value)
- {
- // Applies any filters
- if ($filter && isset($this->filter[$method][$variable]))
- {
- $function = $this->filter[$method][$variable];
-
- if ($function == 'password_hash')
- {
- $global[$variable] = password_hash($value, PASSWORD_DEFAULT);
- }
- else
- {
- $global[$variable] = $function($value);
- }
- }
-
- if ($validate && isset($this->validate[$method][$variable]))
- {
- $rules = $this->validate[$method][$variable];
-
- if (is_array($rules))
- {
- if (isset($global[$variable]) && !String::isEmpty($global[$variable]))
- {
- if (is_array($rules))
- {
- foreach ($rules as $rule => $message)
- {
- $rule = explode(':', $rule);
-
- for ($i = 1; $i <= 2; $i++)
- {
- if (!isset($rule[$i]))
- {
- $rule[$i] = false;
- }
- }
-
- switch ($rule[0])
- {
- // {{{ Checks using filter_var()
-
- case 'filter':
- switch ($rule[1])
- {
- case 'boolean':
- case 'email':
- case 'float':
- case 'int':
- case 'ip':
- case 'url':
- $filter = constant('FILTER_VALIDATE_' . strtoupper($rule[1]));
-
- if (!filter_var($value, $filter))
- {
- $this->errors[$variable][] = $message;
- }
- break;
-
- default:
- $this->errors[$variable] = 'Invalid filter, expecting boolean, email, float, int, ip or url.';
- break;
- }
-
- break;
-
- // }}}
- // {{{ Checks using strlen()
-
- case 'length':
- $length = strlen($value);
-
- switch ($rule[1])
- {
- case '<':
- $valid = $length < $rule[2];
- break;
-
- case '<=':
- $valid = $length <= $rule[2];
- break;
-
- case '==':
- $valid = $length == $rule[2];
- break;
-
- case '!=':
- $valid = $length != $rule[2];
- break;
-
- case '>=':
- $valid = $length >= $rule[2];
- break;
-
- case '>':
- $valid = $length > $rule[2];
- break;
-
- default:
- $valid = false;
- $message = 'Invalid operator, expecting <, <=, ==, !=, >= or >.';
- break;
- }
-
- if (!$valid)
- {
- $this->errors[$variable][] = $message;
- }
-
- break;
-
- // }}}
- // {{{ Checks using preg_match()
-
- case 'regex':
- if (preg_match($rule[1], $value))
- {
- $this->errors[$variable][] = $message;
- }
- break;
-
- // }}}
- // @todo case 'alpha':
- // @todo case 'alphanumeric':
- // @todo case 'date':
- // @todo case 'range':
- }
- }
- }
- }
- }
- }
- }
-
- // if PUT or DELETE, need to update the super globals directly as
- // they do not stay in sync. Probably need to make them global in
- // this class method
- //
- // $_PUT = $GLOBALS['_PUT'];
- }
-
- if ($this->errors)
- {
- throw new \Exception('Missing or invalid parameters.', 400);
- }
-
- parent::__construct();
-
- // Checks if the request method has been implemented
- if (get_class($this) != 'Pickles\\Resource')
- {
- if (!method_exists($this, $method))
- {
- throw new \Exception('Method not allowed.', 405);
- }
- else
- {
- // Starts a timer before the resource is executed
- if ($this->config['profiler'])
- {
- $timer = get_class($this) . '->' . $method . '()';
- Profiler::timer($timer);
- }
-
- $this->response = $this->$method();
-
- // Stops the resource timer
- if ($this->config['profiler'])
- {
- Profiler::timer($timer);
- }
- }
- }
- }
- catch (\Exception $e)
- {
- $code = $e->getCode();
-
- // Anything below 200 is probably a PHP error
- if ($code < 200)
- {
- $code = 500;
- }
-
- $this->status = $code;
- $this->message = $e->getMessage();
- }
- }
-
- public function respond()
- {
- http_response_code($this->status);
- header('Content-Type: application/json');
- header('X-Powered-By: Pickles (http://picklesphp.com)');
-
- $meta = [
- 'status' => $this->status,
- 'message' => $this->message,
- ];
-
- // Forces errors to be an array of arrays
- if ($this->errors)
- {
- foreach ($this->errors as $key => $error)
- {
- if (!is_array($error))
- {
- $this->errors[$key] = [$error];
- }
- }
- }
-
- foreach (['echo', 'limit', 'offset', 'errors'] as $variable)
- {
- if ($this->$variable)
- {
- $meta[$variable] = $this->$variable;
- }
- }
-
- $response = ['meta' => $meta];
-
- foreach (['response', 'profiler'] as $variable)
- {
- if ($this->$variable)
- {
- $response[$variable] = $this->$variable;
- }
- }
-
- if ($this->config['profiler'])
- {
- $response['profiler'] = Profiler::report();
- }
-
- $pretty = isset($_REQUEST['pretty']) ? JSON_PRETTY_PRINT : false;
-
- echo json_encode($response, $pretty);
- }
-}
-
diff --git a/src/Router.php b/src/Router.php
deleted file mode 100644
index 2089c90..0000000
--- a/src/Router.php
+++ /dev/null
@@ -1,113 +0,0 @@
-new Pickles\Router;
- */
-class Router extends Object
-{
- /**
- * Constructor
- *
- * To save a few keystrokes, the Controller is executed as part of the
- * constructor instead of via a method. You either want the Controller or
- * you don't.
- */
- public function __construct()
- {
- parent::__construct();
-
- try
- {
- // Secure by default
- if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] == false)
- {
- throw new \Exception('HTTPS is required.', 400);
- }
-
- // Grabs the requested page
- $request = $_REQUEST['request'];
- $components = explode('/', $request);
- $nouns = [];
- $uids = [];
- $version = array_shift($components);
- $_SERVER['__version'] = substr($version, 1);
-
- // Checks if we're trying to rock some OAuth
- if ($components[0] == 'oauth')
- {
- $class = 'Pickles\OAuth2\Resource';
- }
- else
- {
- // Loops through the components to determine nouns and IDs
- foreach ($components as $index => $component)
- {
- if ($index % 2)
- {
- $uids[end($nouns)] = $component;
- }
- else
- {
- $nouns[] = $component;
- }
- }
-
- // Creates our class name
- array_unshift($nouns, '', 'Pickles', 'App', 'Resources', $version);
- $class = implode('\\', $nouns);
- }
-
- // Checks that the file is present and contains our class
- if (!class_exists($class))
- {
- throw new \Exception('Not Found.', 404);
- }
-
- // Instantiates our resource with the UIDs
- $resource = new $class($uids);
- }
- catch (\Exception $e)
- {
- // Creates a resource object if we don't have one
- if (!isset($resource))
- {
- $resource = new Resource;
- }
-
- $code = $e->getCode();
-
- // Anything below 200 is probably a PHP error
- if ($code < 200)
- {
- $code = 500;
- }
-
- $resource->status = $code;
- $resource->message = $e->getMessage();
- }
-
- $resource->respond();
- }
-}
-
diff --git a/src/String.php b/src/String.php
deleted file mode 100644
index 3b8dc8d..0000000
--- a/src/String.php
+++ /dev/null
@@ -1,245 +0,0 @@
- 0)
- {
- shuffle($characters);
-
- for ($i = 0; $i < $length; $i++)
- {
- $string .= $characters[array_rand($characters)];
- }
- }
-
- return $string;
- }
-
- // }}}
- // {{{ Truncate
-
- /**
- * Truncate
- *
- * Truncates a string to a specified length and (optionally) adds a
- * span to provide a rollover to see the expanded text.
- *
- * @static
- * @param string $string string to truncate
- * @param integer $length length to truncate to
- * @param boolean $hover (optional) whether or not to add the rollover
- * @return string truncate string
- */
- public static function truncate($string, $length, $hover = true)
- {
- if (strlen($string) > $length)
- {
- if ($hover == true)
- {
- $string = '' . mb_strcut($string, 0, $length, 'UTF-8') . '…';
- }
- else
- {
- $string = mb_strcut($string, 0, $length, 'UTF-8') . '…';
- }
- }
-
- return $string;
- }
-
- // }}}
- // {{{ Upper Words
-
- /**
- * Upper Words
- *
- * Applies strtolower() and ucwords() to the passed string. The
- * exception being email addresses which are not formatted at all.
- *
- * @static
- * @param string $string string to format
- * @return string formatted string
- */
- public static function upperWords($string)
- {
- // Only formats non-email addresses
- if (filter_var($string, FILTER_VALIDATE_EMAIL) == false)
- {
- $string = ucwords(strtolower($string));
- }
-
- return $string;
- }
-
- // }}}
-}
-
diff --git a/src/Time.php b/src/Time.php
deleted file mode 100644
index 0811d01..0000000
--- a/src/Time.php
+++ /dev/null
@@ -1,271 +0,0 @@
- $time)
- {
- $difference = $current - $time;
- $suffix = ' ago';
- }
- else
- {
- $difference = $time - $current;
- $suffix = ' from now';
- }
-
- // Less than 1 minute ago (seconds ago)
- if ($difference < 60)
- {
- $time_ago = 'seconds';
- }
- // Less than 1 hour ago (minutes ago)
- elseif ($difference < Time::HOUR)
- {
- $minutes = round($difference / 60);
-
- if ($minutes == 60)
- {
- $time_ago = 'an hour';
- }
- else
- {
- $time_ago = ($minutes == 1 ? 'a' : $minutes) . ' minute' . ($minutes != 1 ? 's' : '');
- }
- }
- // Less than 1 day ago (hours ago)
- elseif ($difference < Time::DAY)
- {
- $hours = round($difference / Time::HOUR);
-
- if ($hours == 24)
- {
- $time_ago = 'a day';
- }
- else
- {
- $time_ago = ($hours == 1 ? 'an' : $hours) . ' hour' . ($hours != 1 ? 's' : '');
- }
- }
- // Less than 1 week ago (days ago)
- elseif ($difference < Time::WEEK)
- {
- $days = round($difference / Time::DAY);
-
- if ($days == 7)
- {
- $time_ago = 'a week';
- }
- else
- {
- $time_ago = ($days == 1 ? 'a' : $days) . ' day' . ($days != 1 ? 's' : '');
- }
- }
- // Less than 1 month ago (weeks ago)
- elseif ($difference < Time::MONTH)
- {
- $weeks = round($difference / Time::WEEK);
-
- if ($weeks == 4)
- {
- $time_ago = 'a month';
- }
- else
- {
- $time_ago = ($weeks == 1 ? 'a' : $weeks) . ' week' . ($weeks != 1 ? 's' : '');
- }
- }
- // Less than 1 year ago (months ago)
- elseif ($difference < Time::YEAR)
- {
- $months = round($difference / Time::MONTH);
-
- if ($months == 12)
- {
- $time_ago = 'a year';
- }
- else
- {
- $time_ago = ($months == 1 ? 'a' : $months) . ' month' . ($months != 1 ? 's' : '');
- }
- }
- // Over 1 year ago (years ago)
- else
- {
- $years = round($difference / Time::YEAR);
- $time_ago = ($years == 1 ? 'a' : $years) . ' year' . ($years != 1 ? 's' : '');
- }
-
- $time_ago .= $suffix;
- }
-
- return $time_ago;
- }
-
- /**
- * Timestamp
- *
- * Current Universal Time in the specified format.
- *
- * @static
- * @param string $format format of the timestamp
- * @return string $timestamp formatted timestamp
- */
- public static function timestamp($format = 'Y-m-d H:i:s')
- {
- return gmdate($format);
- }
-}
-
diff --git a/tests/Pickles/ConfigTest.php b/tests/Pickles/ConfigTest.php
deleted file mode 100644
index d7b6607..0000000
--- a/tests/Pickles/ConfigTest.php
+++ /dev/null
@@ -1,174 +0,0 @@
-)
- */
- public function testMissingCLIEnvironment()
- {
- $_SERVER['argc'] = 1;
-
- file_put_contents('/tmp/pickles.php', ' [
- "local" => "127.0.0.1",
- "production" => "123.456.789.0",
- ],
- ];
- ');
-
- new Pickles\Config('/tmp/pickles.php');
- }
-
- /**
- * @expectedException Exception
- * @expectedExceptionMessage You must pass an environment (e.g. php script.php $message
\n"; + } + } + + /** + * Check whether the user is a human + * Wrapper for the scoreGame API call + * + * @return boolean + */ + public function scoreResult() { + $result = false; + if ($this->session_secret) { + $fields = array( + 'session_secret' => urlencode($this->session_secret), + 'scoring_key' => $this->ayah_scoring_key + ); + $resp = $this->doHttpsPostReturnJSONArray($this->ayah_web_service_host, "/ws/scoreGame", $fields); + if ($resp) { + $result = ($resp->status_code == 1); + } + } + else + { + $this->__log("DEBUG", __FUNCTION__, "Unable to score the result. Please check that your ayah_config.php file contains your correct publisher key and scoring key."); + } + + return $result; + } + + /** + * Records a conversion + * Called on the goal page that A and B redirect to + * A/B Testing Specific Function + * + * @return boolean + */ + public function recordConversion() { + // Build the url to the AYAH webservice.. + $url = 'https://'; // The AYAH webservice API requires https. + $url.= $this->ayah_web_service_host; // Add the host. + $url.= "/ws/recordConversion/"; // Add the path to the API script. + $url.= urlencode($this->ayah_publisher_key); // Add the encoded publisher key. + + if( isset( $this->session_secret ) ){ + return ''; + } else { + $this->__log("ERROR", __FUNCTION__, 'AYAH Conversion Error: No Session Secret'); + return FALSE; + } + } + + /** + * Do a HTTPS POST, return some JSON decoded as array (Internal function) + * @param $host hostname + * @param $path path + * @param $fields associative array of fields + * return JSON decoded data structure or empty data structure + */ + protected function doHttpsPostReturnJSONArray($hostname, $path, $fields) { + $result = $this->doHttpsPost($hostname, $path, $fields); + + if ($result) { + $result = $this->doJSONArrayDecode($result); + } else { + $this->__log("ERROR", __FUNCTION__, "Post to https://$hostname$path returned no result."); + $result = array(); + } + + return $result; + } + + // Internal function; does an HTTPS post + protected function doHttpsPost($hostname, $path, $fields) { + $result = ""; + // URLencode the post string + $fields_string = ""; + foreach($fields as $key=>$value) { + if (is_array($value)) { + if ( ! empty($value)) { + foreach ($value as $k => $v) { + $fields_string .= $key . '['. $k .']=' . $v . '&'; + } + } else { + $fields_string .= $key . '=&'; + } + } else { + $fields_string .= $key.'='.$value.'&'; + } + } + rtrim($fields_string,'&'); + + // Use cURL? + if ($this->__use_curl()) + { + // Build the cURL url. + $curl_url = "https://" . $hostname . $path; + + // Log it. + $this->__log("DEBUG", __FUNCTION__, "Using cURl: url='$curl_url', fields='$fields_string'"); + + // Initialize cURL session. + if ($ch = curl_init($curl_url)) + { + // Set the cURL options. + curl_setopt($ch, CURLOPT_POST, count($fields)); + curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); + + // Execute the cURL request. + $result = curl_exec($ch); + + // Close the curl session. + curl_close($ch); + } + else + { + // Log it. + $this->__log("DEBUG", __FUNCTION__, "Unable to initialize cURL: url='$curl_url'"); + } + } + else + { + // Log it. + $this->__log("DEBUG", __FUNCTION__, "Using fsockopen(): fields='$fields_string'"); + + // Build a header + $http_request = "POST $path HTTP/1.1\r\n"; + $http_request .= "Host: $hostname\r\n"; + $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n"; + $http_request .= "Content-Length: " . strlen($fields_string) . "\r\n"; + $http_request .= "User-Agent: AreYouAHuman/PHP " . $this->get_version_number() . "\r\n"; + $http_request .= "Connection: Close\r\n"; + $http_request .= "\r\n"; + $http_request .= $fields_string ."\r\n"; + + $result = ''; + $errno = $errstr = ""; + $fs = fsockopen("ssl://" . $hostname, 443, $errno, $errstr, 10); + if( false == $fs ) { + $this->__log("ERROR", __FUNCTION__, "Could not open socket"); + } else { + fwrite($fs, $http_request); + while (!feof($fs)) { + $result .= fgets($fs, 4096); + } + + $result = explode("\r\n\r\n", $result, 2); + $result = $result[1]; + } + } + + // Log the result. + $this->__log("DEBUG", __FUNCTION__, "result='$result'"); + + // Return the result. + return $result; + } + + // Internal function: does a JSON decode of the string + protected function doJSONArrayDecode($string) { + $result = array(); + + if (function_exists("json_decode")) { + try { + $result = json_decode( $string); + } catch (Exception $e) { + $this->__log("ERROR", __FUNCTION__, "Exception when calling json_decode: " . $e->getMessage()); + $result = null; + } + } elseif (file_Exists("json.php")) { + require_once('json.php'); + $json = new Services_JSON(); + $result = $json->decode($string); + + if (!is_array($result)) { + $this->__log("ERROR", __FUNCTION__, "Expected array; got something else: $result"); + $result = array(); + } + } else { + $this->__log("ERROR", __FUNCTION__, "No JSON decode function available."); + } + + return $result; + } + + /** + * Get the current debug mode (TRUE or FALSE) + * + * @return boolean + */ + public function debug_mode($mode=null) + { + // Set it if the mode is passed. + if (null !== $mode) + { + // Save it. + $this->ayah_debug_mode = $mode; + + // Display a message if debug_mode is TRUE. + if ($mode) + { + $version_number = $this->get_version_number(); + $this->__log("DEBUG", "", "Debug mode is now on. (ayah.php version=$version_number)"); + + // Flush the buffer. + $this->__flush_message_buffer(); + } + } + + // If necessary, set the default. + if ( ! isset($this->ayah_debug_mode) or (null == $this->ayah_debug_mode)) $this->ayah_debug_mode = FALSE; + + // Return TRUE or FALSE. + return ($this->ayah_debug_mode)? TRUE : FALSE; + } + + /** + * Get the current version number + * + * @return string + */ + public function get_version_number() + { + return (isset($this->__version_number))? $this->__version_number : FALSE; + } + + /** + * Determine whether or not cURL is available to use. + * + * @return boolean + */ + private function __use_curl() + { + if (FALSE === $this->ayah_use_curl) + { + return FALSE; + } + elseif (function_exists('curl_init') and function_exists('curl_exec')) + { + return TRUE; + } + return FALSE; + } + + /** + * Load the config file. + * + * @return boolean + */ + private function __load_config_file() + { + // Initialize. + $name = 'ayah_config.php'; + $locations = array( + './', + dirname(__FILE__)."/", + ); + + // Look for the config file in each location. + foreach ($locations as $location) + { + if (file_exists($location.$name)) + { + require_once($location.$name); + return TRUE; + } + } + + // Could not find the config file. + return FALSE; + } + + /** + * Log a message + * + * @return null + */ + protected function __log($type, $function, $message) + { + // Add a prefix to the message. + $message = __CLASS__ . "::$function: " . $message; + + // Is it an error message? + if (FALSE !== stripos($type, "error")) + { + error_log($message); + } + + // Build the full message. + $message_style = "padding: 10px; border: 1px solid #EED3D7; background: #F2DEDE; color: #B94A48;"; + $full_message = "$type: $message
\n"; + + // Output to the screen too? + if ($this->debug_mode()) + { + echo "$full_message"; + } + else + { + // Add the message to the buffer in case we need it later. + $this->__message_buffer[] = $full_message; + } + } + + private function __flush_message_buffer() + { + // Flush the buffer. + if ( ! empty($this->__message_buffer)) + { + foreach ($this->__message_buffer as $buffered_message) + { + // Print the buffered message. + echo "$buffered_message"; + } + } + } +} + +endif; // if ( ! class_exists('AYAH')): diff --git a/vendors/ayah-1.1.7/ayah_config.php b/vendors/ayah-1.1.7/ayah_config.php new file mode 100755 index 0000000..c29c889 --- /dev/null +++ b/vendors/ayah-1.1.7/ayah_config.php @@ -0,0 +1,13 @@ + + * @author Matt Knapp
+ * // create a new instance of Services_JSON
+ * $json = new Services_JSON();
+ *
+ * // convert a complexe value to JSON notation, and send it to the browser
+ * $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
+ * $output = $json->encode($value);
+ *
+ * print($output);
+ * // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
+ *
+ * // accept incoming POST data, assumed to be in JSON notation
+ * $input = file_get_contents('php://input', 1000000);
+ * $value = $json->decode($input);
+ *
+ */
+class Services_JSON
+{
+ /**
+ * constructs a new JSON instance
+ *
+ * @param int $use object behavior flags; combine with boolean-OR
+ *
+ * possible values:
+ * - SERVICES_JSON_LOOSE_TYPE: loose typing.
+ * "{...}" syntax creates associative arrays
+ * instead of objects in decode().
+ * - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
+ * Values which can't be encoded (e.g. resources)
+ * appear as NULL instead of throwing errors.
+ * By default, a deeply-nested resource will
+ * bubble up with an error, so all return values
+ * from encode() should be checked with isError()
+ */
+ function Services_JSON($use = 0)
+ {
+ $this->use = $use;
+ }
+
+ /**
+ * convert a string from one UTF-16 char to one UTF-8 char
+ *
+ * Normally should be handled by mb_convert_encoding, but
+ * provides a slower PHP-only method for installations
+ * that lack the multibye string extension.
+ *
+ * @param string $utf16 UTF-16 character
+ * @return string UTF-8 character
+ * @access private
+ */
+ function utf162utf8($utf16)
+ {
+ // oh please oh please oh please oh please oh please
+ if(function_exists('mb_convert_encoding')) {
+ return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
+ }
+
+ $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
+
+ switch(true) {
+ case ((0x7F & $bytes) == $bytes):
+ // this case should never be reached, because we are in ASCII range
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ return chr(0x7F & $bytes);
+
+ case (0x07FF & $bytes) == $bytes:
+ // return a 2-byte UTF-8 character
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ return chr(0xC0 | (($bytes >> 6) & 0x1F))
+ . chr(0x80 | ($bytes & 0x3F));
+
+ case (0xFFFF & $bytes) == $bytes:
+ // return a 3-byte UTF-8 character
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ return chr(0xE0 | (($bytes >> 12) & 0x0F))
+ . chr(0x80 | (($bytes >> 6) & 0x3F))
+ . chr(0x80 | ($bytes & 0x3F));
+ }
+
+ // ignoring UTF-32 for now, sorry
+ return '';
+ }
+
+ /**
+ * convert a string from one UTF-8 char to one UTF-16 char
+ *
+ * Normally should be handled by mb_convert_encoding, but
+ * provides a slower PHP-only method for installations
+ * that lack the multibye string extension.
+ *
+ * @param string $utf8 UTF-8 character
+ * @return string UTF-16 character
+ * @access private
+ */
+ function utf82utf16($utf8)
+ {
+ // oh please oh please oh please oh please oh please
+ if(function_exists('mb_convert_encoding')) {
+ return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
+ }
+
+ switch(strlen($utf8)) {
+ case 1:
+ // this case should never be reached, because we are in ASCII range
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ return $utf8;
+
+ case 2:
+ // return a UTF-16 character from a 2-byte UTF-8 char
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ return chr(0x07 & (ord($utf8{0}) >> 2))
+ . chr((0xC0 & (ord($utf8{0}) << 6))
+ | (0x3F & ord($utf8{1})));
+
+ case 3:
+ // return a UTF-16 character from a 3-byte UTF-8 char
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ return chr((0xF0 & (ord($utf8{0}) << 4))
+ | (0x0F & (ord($utf8{1}) >> 2)))
+ . chr((0xC0 & (ord($utf8{1}) << 6))
+ | (0x7F & ord($utf8{2})));
+ }
+
+ // ignoring UTF-32 for now, sorry
+ return '';
+ }
+
+ /**
+ * encodes an arbitrary variable into JSON format
+ *
+ * @param mixed $var any number, boolean, string, array, or object to be encoded.
+ * see argument 1 to Services_JSON() above for array-parsing behavior.
+ * if var is a strng, note that encode() always expects it
+ * to be in ASCII or UTF-8 format!
+ *
+ * @return mixed JSON string representation of input var or an error if a problem occurs
+ * @access public
+ */
+ function encode($var)
+ {
+ switch (gettype($var)) {
+ case 'boolean':
+ return $var ? 'true' : 'false';
+
+ case 'NULL':
+ return 'null';
+
+ case 'integer':
+ return (int) $var;
+
+ case 'double':
+ case 'float':
+ return (float) $var;
+
+ case 'string':
+ // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
+ $ascii = '';
+ $strlen_var = strlen($var);
+
+ /*
+ * Iterate over every character in the string,
+ * escaping with a slash or encoding to UTF-8 where necessary
+ */
+ for ($c = 0; $c < $strlen_var; ++$c) {
+
+ $ord_var_c = ord($var{$c});
+
+ switch (true) {
+ case $ord_var_c == 0x08:
+ $ascii .= '\b';
+ break;
+ case $ord_var_c == 0x09:
+ $ascii .= '\t';
+ break;
+ case $ord_var_c == 0x0A:
+ $ascii .= '\n';
+ break;
+ case $ord_var_c == 0x0C:
+ $ascii .= '\f';
+ break;
+ case $ord_var_c == 0x0D:
+ $ascii .= '\r';
+ break;
+
+ case $ord_var_c == 0x22:
+ case $ord_var_c == 0x2F:
+ case $ord_var_c == 0x5C:
+ // double quote, slash, slosh
+ $ascii .= '\\'.$var{$c};
+ break;
+
+ case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
+ // characters U-00000000 - U-0000007F (same as ASCII)
+ $ascii .= $var{$c};
+ break;
+
+ case (($ord_var_c & 0xE0) == 0xC0):
+ // characters U-00000080 - U-000007FF, mask 110XXXXX
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
+ $c += 1;
+ $utf16 = $this->utf82utf16($char);
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
+ break;
+
+ case (($ord_var_c & 0xF0) == 0xE0):
+ // characters U-00000800 - U-0000FFFF, mask 1110XXXX
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ $char = pack('C*', $ord_var_c,
+ ord($var{$c + 1}),
+ ord($var{$c + 2}));
+ $c += 2;
+ $utf16 = $this->utf82utf16($char);
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
+ break;
+
+ case (($ord_var_c & 0xF8) == 0xF0):
+ // characters U-00010000 - U-001FFFFF, mask 11110XXX
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ $char = pack('C*', $ord_var_c,
+ ord($var{$c + 1}),
+ ord($var{$c + 2}),
+ ord($var{$c + 3}));
+ $c += 3;
+ $utf16 = $this->utf82utf16($char);
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
+ break;
+
+ case (($ord_var_c & 0xFC) == 0xF8):
+ // characters U-00200000 - U-03FFFFFF, mask 111110XX
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ $char = pack('C*', $ord_var_c,
+ ord($var{$c + 1}),
+ ord($var{$c + 2}),
+ ord($var{$c + 3}),
+ ord($var{$c + 4}));
+ $c += 4;
+ $utf16 = $this->utf82utf16($char);
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
+ break;
+
+ case (($ord_var_c & 0xFE) == 0xFC):
+ // characters U-04000000 - U-7FFFFFFF, mask 1111110X
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ $char = pack('C*', $ord_var_c,
+ ord($var{$c + 1}),
+ ord($var{$c + 2}),
+ ord($var{$c + 3}),
+ ord($var{$c + 4}),
+ ord($var{$c + 5}));
+ $c += 5;
+ $utf16 = $this->utf82utf16($char);
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
+ break;
+ }
+ }
+
+ return '"'.$ascii.'"';
+
+ case 'array':
+ /*
+ * As per JSON spec if any array key is not an integer
+ * we must treat the the whole array as an object. We
+ * also try to catch a sparsely populated associative
+ * array with numeric keys here because some JS engines
+ * will create an array with empty indexes up to
+ * max_index which can cause memory issues and because
+ * the keys, which may be relevant, will be remapped
+ * otherwise.
+ *
+ * As per the ECMA and JSON specification an object may
+ * have any string as a property. Unfortunately due to
+ * a hole in the ECMA specification if the key is a
+ * ECMA reserved word or starts with a digit the
+ * parameter is only accessible using ECMAScript's
+ * bracket notation.
+ */
+
+ // treat as a JSON object
+ if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
+ $properties = array_map(array($this, 'name_value'),
+ array_keys($var),
+ array_values($var));
+
+ foreach($properties as $property) {
+ if(Services_JSON::isError($property)) {
+ return $property;
+ }
+ }
+
+ return '{' . join(',', $properties) . '}';
+ }
+
+ // treat it like a regular array
+ $elements = array_map(array($this, 'encode'), $var);
+
+ foreach($elements as $element) {
+ if(Services_JSON::isError($element)) {
+ return $element;
+ }
+ }
+
+ return '[' . join(',', $elements) . ']';
+
+ case 'object':
+ $vars = get_object_vars($var);
+
+ $properties = array_map(array($this, 'name_value'),
+ array_keys($vars),
+ array_values($vars));
+
+ foreach($properties as $property) {
+ if(Services_JSON::isError($property)) {
+ return $property;
+ }
+ }
+
+ return '{' . join(',', $properties) . '}';
+
+ default:
+ return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
+ ? 'null'
+ : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
+ }
+ }
+
+ /**
+ * array-walking function for use in generating JSON-formatted name-value pairs
+ *
+ * @param string $name name of key to use
+ * @param mixed $value reference to an array element to be encoded
+ *
+ * @return string JSON-formatted name-value pair, like '"name":value'
+ * @access private
+ */
+ function name_value($name, $value)
+ {
+ $encoded_value = $this->encode($value);
+
+ if(Services_JSON::isError($encoded_value)) {
+ return $encoded_value;
+ }
+
+ return $this->encode(strval($name)) . ':' . $encoded_value;
+ }
+
+ /**
+ * reduce a string by removing leading and trailing comments and whitespace
+ *
+ * @param $str string string value to strip of comments and whitespace
+ *
+ * @return string string value stripped of comments and whitespace
+ * @access private
+ */
+ function reduce_string($str)
+ {
+ $str = preg_replace(array(
+
+ // eliminate single line comments in '// ...' form
+ '#^\s*//(.+)$#m',
+
+ // eliminate multi-line comments in '/* ... */' form, at start of string
+ '#^\s*/\*(.+)\*/#Us',
+
+ // eliminate multi-line comments in '/* ... */' form, at end of string
+ '#/\*(.+)\*/\s*$#Us'
+
+ ), '', $str);
+
+ // eliminate extraneous space
+ return trim($str);
+ }
+
+ /**
+ * decodes a JSON string into appropriate variable
+ *
+ * @param string $str JSON-formatted string
+ *
+ * @return mixed number, boolean, string, array, or object
+ * corresponding to given JSON input string.
+ * See argument 1 to Services_JSON() above for object-output behavior.
+ * Note that decode() always returns strings
+ * in ASCII or UTF-8 format!
+ * @access public
+ */
+ function decode($str)
+ {
+ $str = $this->reduce_string($str);
+
+ switch (strtolower($str)) {
+ case 'true':
+ return true;
+
+ case 'false':
+ return false;
+
+ case 'null':
+ return null;
+
+ default:
+ $m = array();
+
+ if (is_numeric($str)) {
+ // Lookie-loo, it's a number
+
+ // This would work on its own, but I'm trying to be
+ // good about returning integers where appropriate:
+ // return (float)$str;
+
+ // Return float or int, as appropriate
+ return ((float)$str == (integer)$str)
+ ? (integer)$str
+ : (float)$str;
+
+ } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
+ // STRINGS RETURNED IN UTF-8 FORMAT
+ $delim = substr($str, 0, 1);
+ $chrs = substr($str, 1, -1);
+ $utf8 = '';
+ $strlen_chrs = strlen($chrs);
+
+ for ($c = 0; $c < $strlen_chrs; ++$c) {
+
+ $substr_chrs_c_2 = substr($chrs, $c, 2);
+ $ord_chrs_c = ord($chrs{$c});
+
+ switch (true) {
+ case $substr_chrs_c_2 == '\b':
+ $utf8 .= chr(0x08);
+ ++$c;
+ break;
+ case $substr_chrs_c_2 == '\t':
+ $utf8 .= chr(0x09);
+ ++$c;
+ break;
+ case $substr_chrs_c_2 == '\n':
+ $utf8 .= chr(0x0A);
+ ++$c;
+ break;
+ case $substr_chrs_c_2 == '\f':
+ $utf8 .= chr(0x0C);
+ ++$c;
+ break;
+ case $substr_chrs_c_2 == '\r':
+ $utf8 .= chr(0x0D);
+ ++$c;
+ break;
+
+ case $substr_chrs_c_2 == '\\"':
+ case $substr_chrs_c_2 == '\\\'':
+ case $substr_chrs_c_2 == '\\\\':
+ case $substr_chrs_c_2 == '\\/':
+ if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
+ ($delim == "'" && $substr_chrs_c_2 != '\\"')) {
+ $utf8 .= $chrs{++$c};
+ }
+ break;
+
+ case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
+ // single, escaped unicode character
+ $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
+ . chr(hexdec(substr($chrs, ($c + 4), 2)));
+ $utf8 .= $this->utf162utf8($utf16);
+ $c += 5;
+ break;
+
+ case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
+ $utf8 .= $chrs{$c};
+ break;
+
+ case ($ord_chrs_c & 0xE0) == 0xC0:
+ // characters U-00000080 - U-000007FF, mask 110XXXXX
+ //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ $utf8 .= substr($chrs, $c, 2);
+ ++$c;
+ break;
+
+ case ($ord_chrs_c & 0xF0) == 0xE0:
+ // characters U-00000800 - U-0000FFFF, mask 1110XXXX
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ $utf8 .= substr($chrs, $c, 3);
+ $c += 2;
+ break;
+
+ case ($ord_chrs_c & 0xF8) == 0xF0:
+ // characters U-00010000 - U-001FFFFF, mask 11110XXX
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ $utf8 .= substr($chrs, $c, 4);
+ $c += 3;
+ break;
+
+ case ($ord_chrs_c & 0xFC) == 0xF8:
+ // characters U-00200000 - U-03FFFFFF, mask 111110XX
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ $utf8 .= substr($chrs, $c, 5);
+ $c += 4;
+ break;
+
+ case ($ord_chrs_c & 0xFE) == 0xFC:
+ // characters U-04000000 - U-7FFFFFFF, mask 1111110X
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
+ $utf8 .= substr($chrs, $c, 6);
+ $c += 5;
+ break;
+
+ }
+
+ }
+
+ return $utf8;
+
+ } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
+ // array, or object notation
+
+ if ($str{0} == '[') {
+ $stk = array(SERVICES_JSON_IN_ARR);
+ $arr = array();
+ } else {
+ if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
+ $stk = array(SERVICES_JSON_IN_OBJ);
+ $obj = array();
+ } else {
+ $stk = array(SERVICES_JSON_IN_OBJ);
+ $obj = new stdClass();
+ }
+ }
+
+ array_push($stk, array('what' => SERVICES_JSON_SLICE,
+ 'where' => 0,
+ 'delim' => false));
+
+ $chrs = substr($str, 1, -1);
+ $chrs = $this->reduce_string($chrs);
+
+ if ($chrs == '') {
+ if (reset($stk) == SERVICES_JSON_IN_ARR) {
+ return $arr;
+
+ } else {
+ return $obj;
+
+ }
+ }
+
+ //print("\nparsing {$chrs}\n");
+
+ $strlen_chrs = strlen($chrs);
+
+ for ($c = 0; $c <= $strlen_chrs; ++$c) {
+
+ $top = end($stk);
+ $substr_chrs_c_2 = substr($chrs, $c, 2);
+
+ if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
+ // found a comma that is not inside a string, array, etc.,
+ // OR we've reached the end of the character list
+ $slice = substr($chrs, $top['where'], ($c - $top['where']));
+ array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
+ //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
+
+ if (reset($stk) == SERVICES_JSON_IN_ARR) {
+ // we are in an array, so just push an element onto the stack
+ array_push($arr, $this->decode($slice));
+
+ } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
+ // we are in an object, so figure
+ // out the property name and set an
+ // element in an associative array,
+ // for now
+ $parts = array();
+
+ if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
+ // "name":value pair
+ $key = $this->decode($parts[1]);
+ $val = $this->decode($parts[2]);
+
+ if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
+ $obj[$key] = $val;
+ } else {
+ $obj->$key = $val;
+ }
+ } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
+ // name:value pair, where name is unquoted
+ $key = $parts[1];
+ $val = $this->decode($parts[2]);
+
+ if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
+ $obj[$key] = $val;
+ } else {
+ $obj->$key = $val;
+ }
+ }
+
+ }
+
+ } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
+ // found a quote, and we are not inside a string
+ array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
+ //print("Found start of string at {$c}\n");
+
+ } elseif (($chrs{$c} == $top['delim']) &&
+ ($top['what'] == SERVICES_JSON_IN_STR) &&
+ ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
+ // found a quote, we're in a string, and it's not escaped
+ // we know that it's not escaped becase there is _not_ an
+ // odd number of backslashes at the end of the string so far
+ array_pop($stk);
+ //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
+
+ } elseif (($chrs{$c} == '[') &&
+ in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
+ // found a left-bracket, and we are in an array, object, or slice
+ array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
+ //print("Found start of array at {$c}\n");
+
+ } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
+ // found a right-bracket, and we're in an array
+ array_pop($stk);
+ //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
+
+ } elseif (($chrs{$c} == '{') &&
+ in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
+ // found a left-brace, and we are in an array, object, or slice
+ array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
+ //print("Found start of object at {$c}\n");
+
+ } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
+ // found a right-brace, and we're in an object
+ array_pop($stk);
+ //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
+
+ } elseif (($substr_chrs_c_2 == '/*') &&
+ in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
+ // found a comment start, and we are in an array, object, or slice
+ array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
+ $c++;
+ //print("Found start of comment at {$c}\n");
+
+ } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
+ // found a comment end, and we're in one now
+ array_pop($stk);
+ $c++;
+
+ for ($i = $top['where']; $i <= $c; ++$i)
+ $chrs = substr_replace($chrs, ' ', $i, 1);
+
+ //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
+
+ }
+
+ }
+
+ if (reset($stk) == SERVICES_JSON_IN_ARR) {
+ return $arr;
+
+ } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
+ return $obj;
+
+ }
+
+ }
+ }
+ }
+
+ /**
+ * @todo Ultimately, this should just call PEAR::isError()
+ */
+ function isError($data, $code = null)
+ {
+ if (class_exists('pear')) {
+ return PEAR::isError($data, $code);
+ } elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
+ is_subclass_of($data, 'services_json_error'))) {
+ return true;
+ }
+
+ return false;
+ }
+}
+
+if (class_exists('PEAR_Error')) {
+
+ class Services_JSON_Error extends PEAR_Error
+ {
+ function Services_JSON_Error($message = 'unknown error', $code = null,
+ $mode = null, $options = null, $userinfo = null)
+ {
+ parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
+ }
+ }
+
+} else {
+
+ /**
+ * @todo Ultimately, this class shall be descended from PEAR_Error
+ */
+ class Services_JSON_Error
+ {
+ function Services_JSON_Error($message = 'unknown error', $code = null,
+ $mode = null, $options = null, $userinfo = null)
+ {
+
+ }
+ }
+
+}
diff --git a/vendors/ayah-1.1.7/sample.php b/vendors/ayah-1.1.7/sample.php
new file mode 100755
index 0000000..3077428
--- /dev/null
+++ b/vendors/ayah-1.1.7/sample.php
@@ -0,0 +1,64 @@
+
+scoreResult();
+
+ if ($score)
+ {
+ // This happens if the user passes the game. In this case,
+ // we're just displaying a congratulatory message.
+ echo "Congratulations: you are a human!";
+ }
+ else
+ {
+ // This happens if the user does not pass the game.
+ echo "Sorry, but we were not able to verify you as human. Please try again.";
+ }
+}
+?>
+
+
+
diff --git a/vendors/google/closure-compiler/COPYING b/vendors/google/closure-compiler/COPYING
new file mode 100644
index 0000000..d645695
--- /dev/null
+++ b/vendors/google/closure-compiler/COPYING
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/vendors/google/closure-compiler/README b/vendors/google/closure-compiler/README
new file mode 100644
index 0000000..270cfc2
--- /dev/null
+++ b/vendors/google/closure-compiler/README
@@ -0,0 +1,292 @@
+/*
+ * Copyright 2009 The Closure Compiler Authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//
+// Contents
+//
+
+The Closure Compiler performs checking, instrumentation, and
+optimizations on JavaScript code. The purpose of this README is to
+explain how to build and run the Closure Compiler.
+
+The Closure Compiler requires Java 6 or higher.
+http://www.java.com/
+
+
+//
+// Building The Closure Compiler
+//
+
+There are three ways to get a Closure Compiler executable.
+
+1) Use one we built for you.
+
+Pre-built Closure binaries can be found at
+http://code.google.com/p/closure-compiler/downloads/list
+
+
+2) Check out the source and build it with Apache Ant.
+
+First, check out the full source tree of the Closure Compiler. There
+are instructions on how to do this at the project site.
+http://code.google.com/p/closure-compiler/source/checkout
+
+Apache Ant is a cross-platform build tool.
+http://ant.apache.org/
+
+At the root of the source tree, there is an Ant file named
+build.xml. To use it, navigate to the same directory and type the
+command
+
+ant jar
+
+This will produce a jar file called "build/compiler.jar".
+
+
+3) Check out the source and build it with Eclipse.
+
+Eclipse is a cross-platform IDE.
+http://www.eclipse.org/
+
+Under Eclipse's File menu, click "New > Project ..." and create a
+"Java Project." You will see an options screen. Give the project a
+name, select "Create project from existing source," and choose the
+root of the checked-out source tree as the existing directory. Verify
+that you are using JRE version 6 or higher.
+
+Eclipse can use the build.xml file to discover rules. When you
+navigate to the build.xml file, you will see all the build rules in
+the "Outline" pane. Run the "jar" rule to build the compiler in
+build/compiler.jar.
+
+
+//
+// Running The Closure Compiler
+//
+
+Once you have the jar binary, running the Closure Compiler is straightforward.
+
+On the command line, type
+
+java -jar compiler.jar
+
+This starts the compiler in interactive mode. Type
+
+var x = 17 + 25;
+
+then hit "Enter", then hit "Ctrl-Z" (on Windows) or "Ctrl-D" (on Mac or Linux)
+and "Enter" again. The Compiler will respond:
+
+var x=42;
+
+The Closure Compiler has many options for reading input from a file,
+writing output to a file, checking your code, and running
+optimizations. To learn more, type
+
+java -jar compiler.jar --help
+
+You can read more detailed documentation about the many flags at
+http://code.google.com/closure/compiler/docs/gettingstarted_app.html
+
+
+//
+// Compiling Multiple Scripts
+//
+
+If you have multiple scripts, you should compile them all together with
+one compile command.
+
+java -jar compiler.jar --js=in1.js --js=in2.js ... --js_output_file=out.js
+
+The Closure Compiler will concatenate the files in the order they're
+passed at the command line.
+
+If you need to compile many, many scripts together, you may start to
+run into problems with managing dependencies between scripts. You
+should check out the Closure Library. It contains functions for
+enforcing dependencies between scripts, and a tool called calcdeps.py
+that knows how to give scripts to the Closure Compiler in the right
+order.
+
+http://code.google.com/p/closure-library/
+
+//
+// Licensing
+//
+
+Unless otherwise stated, all source files are licensed under
+the Apache License, Version 2.0.
+
+
+-----
+Code under:
+src/com/google/javascript/rhino
+test/com/google/javascript/rhino
+
+URL: http://www.mozilla.org/rhino
+Version: 1.5R3, with heavy modifications
+License: Netscape Public License and MPL / GPL dual license
+
+Description: A partial copy of Mozilla Rhino. Mozilla Rhino is an
+implementation of JavaScript for the JVM. The JavaScript parser and
+the parse tree data structures were extracted and modified
+significantly for use by Google's JavaScript compiler.
+
+Local Modifications: The packages have been renamespaced. All code not
+relevant to parsing has been removed. A JsDoc parser and static typing
+system have been added.
+
+
+-----
+Code in:
+lib/rhino
+
+Rhino
+URL: http://www.mozilla.org/rhino
+Version: Trunk
+License: Netscape Public License and MPL / GPL dual license
+
+Description: Mozilla Rhino is an implementation of JavaScript for the JVM.
+
+Local Modifications: Minor changes to parsing JSDoc that usually get pushed
+up-stream to Rhino trunk.
+
+
+-----
+Code in:
+lib/args4j.jar
+
+Args4j
+URL: https://args4j.dev.java.net/
+Version: 2.0.16
+License: MIT
+
+Description:
+args4j is a small Java class library that makes it easy to parse command line
+options/arguments in your CUI application.
+
+Local Modifications: None.
+
+
+-----
+Code in:
+lib/guava.jar
+
+Guava Libraries
+URL: http://code.google.com/p/guava-libraries/
+Version: 13.0.1
+License: Apache License 2.0
+
+Description: Google's core Java libraries.
+
+Local Modifications: None.
+
+
+-----
+Code in:
+lib/jsr305.jar
+
+Annotations for software defect detection
+URL: http://code.google.com/p/jsr-305/
+Version: svn revision 47
+License: BSD License
+
+Description: Annotations for software defect detection.
+
+Local Modifications: None.
+
+
+-----
+Code in:
+lib/jarjar.jar
+
+Jar Jar Links
+URL: http://jarjar.googlecode.com/
+Version: 1.1
+License: Apache License 2.0
+
+Description:
+A utility for repackaging Java libraries.
+
+Local Modifications: None.
+
+
+----
+Code in:
+lib/junit.jar
+
+JUnit
+URL: http://sourceforge.net/projects/junit/
+Version: 4.10
+License: Common Public License 1.0
+
+Description: A framework for writing and running automated tests in Java.
+
+Local Modifications: None.
+
+
+---
+Code in:
+lib/protobuf-java.jar
+
+Protocol Buffers
+URL: http://code.google.com/p/protobuf/
+Version: 2.4.1
+License: New BSD License
+
+Description: Supporting libraries for protocol buffers,
+an encoding of structured data.
+
+Local Modifications: None
+
+
+---
+Code in:
+lib/ant.jar
+lib/ant-launcher.jar
+
+URL: http://ant.apache.org/bindownload.cgi
+Version: 1.8.1
+License: Apache License 2.0
+Description:
+ Ant is a Java based build tool. In theory it is kind of like "make"
+ without make's wrinkles and with the full portability of pure java code.
+
+Local Modifications: None
+
+
+---
+Code in:
+lib/json.jar
+URL: http://json.org/java/index.html
+Version: JSON version 20090211
+License: MIT license
+Description:
+JSON is a set of java files for use in transmitting data in JSON format.
+
+Local Modifications: None
+
+---
+Code in:
+tools/maven-ant-tasks-2.1.3.jar
+URL: http://maven.apache.org
+Version 2.1.3
+License: Apache License 2.0
+Description:
+ Maven Ant tasks are used to manage dependencies and to install/deploy to
+ maven repositories.
+
+Local Modifications: None
diff --git a/vendors/google/closure-compiler/compiler.jar b/vendors/google/closure-compiler/compiler.jar
new file mode 100644
index 0000000..53037b0
Binary files /dev/null and b/vendors/google/closure-compiler/compiler.jar differ
diff --git a/vendors/google/closure-compiler/grep b/vendors/google/closure-compiler/grep
new file mode 100644
index 0000000..e69de29