', $trace);
+ }
+
+ return sprintf("%s%s", $title, $html);
+ }
+}
diff --git a/api/libs/Slim/Middleware/SessionCookie.php b/api/libs/Slim/Middleware/SessionCookie.php
new file mode 100644
index 0000000..22e211b
--- /dev/null
+++ b/api/libs/Slim/Middleware/SessionCookie.php
@@ -0,0 +1,210 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.3.5
+ * @package Slim
+ *
+ * MIT LICENSE
+ *
+ * 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 the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+namespace Slim\Middleware;
+
+/**
+ * Session Cookie
+ *
+ * This class provides an HTTP cookie storage mechanism
+ * for session data. This class avoids using a PHP session
+ * and instead serializes/unserializes the $_SESSION global
+ * variable to/from an HTTP cookie.
+ *
+ * You should NEVER store sensitive data in a client-side cookie
+ * in any format, encrypted (with cookies.encrypt) or not. If you
+ * need to store sensitive user information in a session, you should
+ * rely on PHP's native session implementation, or use other middleware
+ * to store session data in a database or alternative server-side cache.
+ *
+ * Because this class stores serialized session data in an HTTP cookie,
+ * you are inherently limited to 4 Kb. If you attempt to store
+ * more than this amount, serialization will fail.
+ *
+ * @package Slim
+ * @author Josh Lockhart
+ * @since 1.6.0
+ */
+class SessionCookie extends \Slim\Middleware
+{
+ /**
+ * @var array
+ */
+ protected $settings;
+
+ /**
+ * Constructor
+ *
+ * @param array $settings
+ */
+ public function __construct($settings = array())
+ {
+ $defaults = array(
+ 'expires' => '20 minutes',
+ 'path' => '/',
+ 'domain' => null,
+ 'secure' => false,
+ 'httponly' => false,
+ 'name' => 'slim_session',
+ );
+ $this->settings = array_merge($defaults, $settings);
+ if (is_string($this->settings['expires'])) {
+ $this->settings['expires'] = strtotime($this->settings['expires']);
+ }
+
+ /**
+ * Session
+ *
+ * We must start a native PHP session to initialize the $_SESSION superglobal.
+ * However, we won't be using the native session store for persistence, so we
+ * disable the session cookie and cache limiter. We also set the session
+ * handler to this class instance to avoid PHP's native session file locking.
+ */
+ ini_set('session.use_cookies', 0);
+ session_cache_limiter(false);
+ session_set_save_handler(
+ array($this, 'open'),
+ array($this, 'close'),
+ array($this, 'read'),
+ array($this, 'write'),
+ array($this, 'destroy'),
+ array($this, 'gc')
+ );
+ }
+
+ /**
+ * Call
+ */
+ public function call()
+ {
+ $this->loadSession();
+ $this->next->call();
+ $this->saveSession();
+ }
+
+ /**
+ * Load session
+ */
+ protected function loadSession()
+ {
+ if (session_id() === '') {
+ session_start();
+ }
+
+ $value = $this->app->getCookie($this->settings['name']);
+
+ if ($value) {
+ try {
+ $_SESSION = unserialize($value);
+ } catch (\Exception $e) {
+ $this->app->getLog()->error('Error unserializing session cookie value! ' . $e->getMessage());
+ }
+ } else {
+ $_SESSION = array();
+ }
+ }
+
+ /**
+ * Save session
+ */
+ protected function saveSession()
+ {
+ $value = serialize($_SESSION);
+
+ if (strlen($value) > 4096) {
+ $this->app->getLog()->error('WARNING! Slim\Middleware\SessionCookie data size is larger than 4KB. Content save failed.');
+ } else {
+ $this->app->setCookie(
+ $this->settings['name'],
+ $value,
+ $this->settings['expires'],
+ $this->settings['path'],
+ $this->settings['domain'],
+ $this->settings['secure'],
+ $this->settings['httponly']
+ );
+ }
+ // session_destroy();
+ }
+
+ /********************************************************************************
+ * Session Handler
+ *******************************************************************************/
+
+ /**
+ * @codeCoverageIgnore
+ */
+ public function open($savePath, $sessionName)
+ {
+ return true;
+ }
+
+ /**
+ * @codeCoverageIgnore
+ */
+ public function close()
+ {
+ return true;
+ }
+
+ /**
+ * @codeCoverageIgnore
+ */
+ public function read($id)
+ {
+ return '';
+ }
+
+ /**
+ * @codeCoverageIgnore
+ */
+ public function write($id, $data)
+ {
+ return true;
+ }
+
+ /**
+ * @codeCoverageIgnore
+ */
+ public function destroy($id)
+ {
+ return true;
+ }
+
+ /**
+ * @codeCoverageIgnore
+ */
+ public function gc($maxlifetime)
+ {
+ return true;
+ }
+}
diff --git a/api/libs/Slim/Route.php b/api/libs/Slim/Route.php
new file mode 100644
index 0000000..1136035
--- /dev/null
+++ b/api/libs/Slim/Route.php
@@ -0,0 +1,439 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.3.5
+ * @package Slim
+ *
+ * MIT LICENSE
+ *
+ * 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 the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+namespace Slim;
+
+/**
+ * Route
+ * @package Slim
+ * @author Josh Lockhart, Thomas Bley
+ * @since 1.0.0
+ */
+class Route
+{
+ /**
+ * @var string The route pattern (e.g. "/books/:id")
+ */
+ protected $pattern;
+
+ /**
+ * @var mixed The route callable
+ */
+ protected $callable;
+
+ /**
+ * @var array Conditions for this route's URL parameters
+ */
+ protected $conditions = array();
+
+ /**
+ * @var array Default conditions applied to all route instances
+ */
+ protected static $defaultConditions = array();
+
+ /**
+ * @var string The name of this route (optional)
+ */
+ protected $name;
+
+ /**
+ * @var array Key-value array of URL parameters
+ */
+ protected $params = array();
+
+ /**
+ * @var array value array of URL parameter names
+ */
+ protected $paramNames = array();
+
+ /**
+ * @var array key array of URL parameter names with + at the end
+ */
+ protected $paramNamesPath = array();
+
+ /**
+ * @var array HTTP methods supported by this Route
+ */
+ protected $methods = array();
+
+ /**
+ * @var array[Callable] Middleware to be run before only this route instance
+ */
+ protected $middleware = array();
+
+ /**
+ * Constructor
+ * @param string $pattern The URL pattern (e.g. "/books/:id")
+ * @param mixed $callable Anything that returns TRUE for is_callable()
+ */
+ public function __construct($pattern, $callable)
+ {
+ $this->setPattern($pattern);
+ $this->setCallable($callable);
+ $this->setConditions(self::getDefaultConditions());
+ }
+
+ /**
+ * Set default route conditions for all instances
+ * @param array $defaultConditions
+ */
+ public static function setDefaultConditions(array $defaultConditions)
+ {
+ self::$defaultConditions = $defaultConditions;
+ }
+
+ /**
+ * Get default route conditions for all instances
+ * @return array
+ */
+ public static function getDefaultConditions()
+ {
+ return self::$defaultConditions;
+ }
+
+ /**
+ * Get route pattern
+ * @return string
+ */
+ public function getPattern()
+ {
+ return $this->pattern;
+ }
+
+ /**
+ * Set route pattern
+ * @param string $pattern
+ */
+ public function setPattern($pattern)
+ {
+ $this->pattern = $pattern;
+ }
+
+ /**
+ * Get route callable
+ * @return mixed
+ */
+ public function getCallable()
+ {
+ return $this->callable;
+ }
+
+ /**
+ * Set route callable
+ * @param mixed $callable
+ * @throws \InvalidArgumentException If argument is not callable
+ */
+ public function setCallable($callable)
+ {
+ if (!is_callable($callable)) {
+ throw new \InvalidArgumentException('Route callable must be callable');
+ }
+
+ $this->callable = $callable;
+ }
+
+ /**
+ * Get route conditions
+ * @return array
+ */
+ public function getConditions()
+ {
+ return $this->conditions;
+ }
+
+ /**
+ * Set route conditions
+ * @param array $conditions
+ */
+ public function setConditions(array $conditions)
+ {
+ $this->conditions = $conditions;
+ }
+
+ /**
+ * Get route name
+ * @return string|null
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Set route name
+ * @param string $name
+ */
+ public function setName($name)
+ {
+ $this->name = (string) $name;
+ }
+
+ /**
+ * Get route parameters
+ * @return array
+ */
+ public function getParams()
+ {
+ return $this->params;
+ }
+
+ /**
+ * Set route parameters
+ * @param array $params
+ */
+ public function setParams($params)
+ {
+ $this->params = $params;
+ }
+
+ /**
+ * Get route parameter value
+ * @param string $index Name of URL parameter
+ * @return string
+ * @throws \InvalidArgumentException If route parameter does not exist at index
+ */
+ public function getParam($index)
+ {
+ if (!isset($this->params[$index])) {
+ throw new \InvalidArgumentException('Route parameter does not exist at specified index');
+ }
+
+ return $this->params[$index];
+ }
+
+ /**
+ * Set route parameter value
+ * @param string $index Name of URL parameter
+ * @param mixed $value The new parameter value
+ * @throws \InvalidArgumentException If route parameter does not exist at index
+ */
+ public function setParam($index, $value)
+ {
+ if (!isset($this->params[$index])) {
+ throw new \InvalidArgumentException('Route parameter does not exist at specified index');
+ }
+ $this->params[$index] = $value;
+ }
+
+ /**
+ * Add supported HTTP method(s)
+ */
+ public function setHttpMethods()
+ {
+ $args = func_get_args();
+ $this->methods = $args;
+ }
+
+ /**
+ * Get supported HTTP methods
+ * @return array
+ */
+ public function getHttpMethods()
+ {
+ return $this->methods;
+ }
+
+ /**
+ * Append supported HTTP methods
+ */
+ public function appendHttpMethods()
+ {
+ $args = func_get_args();
+ $this->methods = array_merge($this->methods, $args);
+ }
+
+ /**
+ * Append supported HTTP methods (alias for Route::appendHttpMethods)
+ * @return \Slim\Route
+ */
+ public function via()
+ {
+ $args = func_get_args();
+ $this->methods = array_merge($this->methods, $args);
+
+ return $this;
+ }
+
+ /**
+ * Detect support for an HTTP method
+ * @param string $method
+ * @return bool
+ */
+ public function supportsHttpMethod($method)
+ {
+ return in_array($method, $this->methods);
+ }
+
+ /**
+ * Get middleware
+ * @return array[Callable]
+ */
+ public function getMiddleware()
+ {
+ return $this->middleware;
+ }
+
+ /**
+ * Set middleware
+ *
+ * This method allows middleware to be assigned to a specific Route.
+ * If the method argument `is_callable` (including callable arrays!),
+ * we directly append the argument to `$this->middleware`. Else, we
+ * assume the argument is an array of callables and merge the array
+ * with `$this->middleware`. Each middleware is checked for is_callable()
+ * and an InvalidArgumentException is thrown immediately if it isn't.
+ *
+ * @param Callable|array[Callable]
+ * @return \Slim\Route
+ * @throws \InvalidArgumentException If argument is not callable or not an array of callables.
+ */
+ public function setMiddleware($middleware)
+ {
+ if (is_callable($middleware)) {
+ $this->middleware[] = $middleware;
+ } elseif (is_array($middleware)) {
+ foreach ($middleware as $callable) {
+ if (!is_callable($callable)) {
+ throw new \InvalidArgumentException('All Route middleware must be callable');
+ }
+ }
+ $this->middleware = array_merge($this->middleware, $middleware);
+ } else {
+ throw new \InvalidArgumentException('Route middleware must be callable or an array of callables');
+ }
+
+ return $this;
+ }
+
+ /**
+ * Matches URI?
+ *
+ * Parse this route's pattern, and then compare it to an HTTP resource URI
+ * This method was modeled after the techniques demonstrated by Dan Sosedoff at:
+ *
+ * http://blog.sosedoff.com/2009/09/20/rails-like-php-url-router/
+ *
+ * @param string $resourceUri A Request URI
+ * @return bool
+ */
+ public function matches($resourceUri)
+ {
+ //Convert URL params into regex patterns, construct a regex for this route, init params
+ $patternAsRegex = preg_replace_callback(
+ '#:([\w]+)\+?#',
+ array($this, 'matchesCallback'),
+ str_replace(')', ')?', (string) $this->pattern)
+ );
+ if (substr($this->pattern, -1) === '/') {
+ $patternAsRegex .= '?';
+ }
+
+ //Cache URL params' names and values if this route matches the current HTTP request
+ if (!preg_match('#^' . $patternAsRegex . '$#', $resourceUri, $paramValues)) {
+ return false;
+ }
+ foreach ($this->paramNames as $name) {
+ if (isset($paramValues[$name])) {
+ if (isset($this->paramNamesPath[ $name ])) {
+ $this->params[$name] = explode('/', urldecode($paramValues[$name]));
+ } else {
+ $this->params[$name] = urldecode($paramValues[$name]);
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Convert a URL parameter (e.g. ":id", ":id+") into a regular expression
+ * @param array $m URL parameters
+ * @return string Regular expression for URL parameter
+ */
+ protected function matchesCallback($m)
+ {
+ $this->paramNames[] = $m[1];
+ if (isset($this->conditions[ $m[1] ])) {
+ return '(?P<' . $m[1] . '>' . $this->conditions[ $m[1] ] . ')';
+ }
+ if (substr($m[0], -1) === '+') {
+ $this->paramNamesPath[ $m[1] ] = 1;
+
+ return '(?P<' . $m[1] . '>.+)';
+ }
+
+ return '(?P<' . $m[1] . '>[^/]+)';
+ }
+
+ /**
+ * Set route name
+ * @param string $name The name of the route
+ * @return \Slim\Route
+ */
+ public function name($name)
+ {
+ $this->setName($name);
+
+ return $this;
+ }
+
+ /**
+ * Merge route conditions
+ * @param array $conditions Key-value array of URL parameter conditions
+ * @return \Slim\Route
+ */
+ public function conditions(array $conditions)
+ {
+ $this->conditions = array_merge($this->conditions, $conditions);
+
+ return $this;
+ }
+
+ /**
+ * Dispatch route
+ *
+ * This method invokes the route object's callable. If middleware is
+ * registered for the route, each callable middleware is invoked in
+ * the order specified.
+ *
+ * @return bool
+ */
+ public function dispatch()
+ {
+ foreach ($this->middleware as $mw) {
+ call_user_func_array($mw, array($this));
+ }
+
+ $return = call_user_func_array($this->getCallable(), array_values($this->getParams()));
+ return ($return === false)? false : true;
+ }
+}
diff --git a/api/libs/Slim/Router.php b/api/libs/Slim/Router.php
new file mode 100644
index 0000000..3dcc646
--- /dev/null
+++ b/api/libs/Slim/Router.php
@@ -0,0 +1,257 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.3.5
+ * @package Slim
+ *
+ * MIT LICENSE
+ *
+ * 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 the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+namespace Slim;
+
+/**
+ * Router
+ *
+ * This class organizes, iterates, and dispatches \Slim\Route objects.
+ *
+ * @package Slim
+ * @author Josh Lockhart
+ * @since 1.0.0
+ */
+class Router
+{
+ /**
+ * @var Route The current route (most recently dispatched)
+ */
+ protected $currentRoute;
+
+ /**
+ * @var array Lookup hash of all route objects
+ */
+ protected $routes;
+
+ /**
+ * @var array Lookup hash of named route objects, keyed by route name (lazy-loaded)
+ */
+ protected $namedRoutes;
+
+ /**
+ * @var array Array of route objects that match the request URI (lazy-loaded)
+ */
+ protected $matchedRoutes;
+
+ /**
+ * @var array Array containing all route groups
+ */
+ protected $routeGroups;
+
+ /**
+ * Constructor
+ */
+ public function __construct()
+ {
+ $this->routes = array();
+ $this->routeGroups = array();
+ }
+
+ /**
+ * Get Current Route object or the first matched one if matching has been performed
+ * @return \Slim\Route|null
+ */
+ public function getCurrentRoute()
+ {
+ if ($this->currentRoute !== null) {
+ return $this->currentRoute;
+ }
+
+ if (is_array($this->matchedRoutes) && count($this->matchedRoutes) > 0) {
+ return $this->matchedRoutes[0];
+ }
+
+ return null;
+ }
+
+ /**
+ * Return route objects that match the given HTTP method and URI
+ * @param string $httpMethod The HTTP method to match against
+ * @param string $resourceUri The resource URI to match against
+ * @param bool $reload Should matching routes be re-parsed?
+ * @return array[\Slim\Route]
+ */
+ public function getMatchedRoutes($httpMethod, $resourceUri, $reload = false)
+ {
+ if ($reload || is_null($this->matchedRoutes)) {
+ $this->matchedRoutes = array();
+ foreach ($this->routes as $route) {
+ if (!$route->supportsHttpMethod($httpMethod) && !$route->supportsHttpMethod("ANY")) {
+ continue;
+ }
+
+ if ($route->matches($resourceUri)) {
+ $this->matchedRoutes[] = $route;
+ }
+ }
+ }
+
+ return $this->matchedRoutes;
+ }
+
+ /**
+ * Add a route object to the router
+ * @param \Slim\Route $route The Slim Route
+ */
+ public function map(\Slim\Route $route)
+ {
+ list($groupPattern, $groupMiddleware) = $this->processGroups();
+
+ $route->setPattern($groupPattern . $route->getPattern());
+ $this->routes[] = $route;
+
+
+ foreach ($groupMiddleware as $middleware) {
+ $route->setMiddleware($middleware);
+ }
+ }
+
+ /**
+ * A helper function for processing the group's pattern and middleware
+ * @return array Returns an array with the elements: pattern, middlewareArr
+ */
+ protected function processGroups()
+ {
+ $pattern = "";
+ $middleware = array();
+ foreach ($this->routeGroups as $group) {
+ $k = key($group);
+ $pattern .= $k;
+ if (is_array($group[$k])) {
+ $middleware = array_merge($middleware, $group[$k]);
+ }
+ }
+ return array($pattern, $middleware);
+ }
+
+ /**
+ * Add a route group to the array
+ * @param string $group The group pattern (ie. "/books/:id")
+ * @param array|null $middleware Optional parameter array of middleware
+ * @return int The index of the new group
+ */
+ public function pushGroup($group, $middleware = array())
+ {
+ return array_push($this->routeGroups, array($group => $middleware));
+ }
+
+ /**
+ * Removes the last route group from the array
+ * @return bool True if successful, else False
+ */
+ public function popGroup()
+ {
+ return (array_pop($this->routeGroups) !== null);
+ }
+
+ /**
+ * Get URL for named route
+ * @param string $name The name of the route
+ * @param array $params Associative array of URL parameter names and replacement values
+ * @throws \RuntimeException If named route not found
+ * @return string The URL for the given route populated with provided replacement values
+ */
+ public function urlFor($name, $params = array())
+ {
+ if (!$this->hasNamedRoute($name)) {
+ throw new \RuntimeException('Named route not found for name: ' . $name);
+ }
+ $search = array();
+ foreach ($params as $key => $value) {
+ $search[] = '#:' . preg_quote($key, '#') . '\+?(?!\w)#';
+ }
+ $pattern = preg_replace($search, $params, $this->getNamedRoute($name)->getPattern());
+
+ //Remove remnants of unpopulated, trailing optional pattern segments, escaped special characters
+ return preg_replace('#\(/?:.+\)|\(|\)|\\\\#', '', $pattern);
+ }
+
+ /**
+ * Add named route
+ * @param string $name The route name
+ * @param \Slim\Route $route The route object
+ * @throws \RuntimeException If a named route already exists with the same name
+ */
+ public function addNamedRoute($name, \Slim\Route $route)
+ {
+ if ($this->hasNamedRoute($name)) {
+ throw new \RuntimeException('Named route already exists with name: ' . $name);
+ }
+ $this->namedRoutes[(string) $name] = $route;
+ }
+
+ /**
+ * Has named route
+ * @param string $name The route name
+ * @return bool
+ */
+ public function hasNamedRoute($name)
+ {
+ $this->getNamedRoutes();
+
+ return isset($this->namedRoutes[(string) $name]);
+ }
+
+ /**
+ * Get named route
+ * @param string $name
+ * @return \Slim\Route|null
+ */
+ public function getNamedRoute($name)
+ {
+ $this->getNamedRoutes();
+ if ($this->hasNamedRoute($name)) {
+ return $this->namedRoutes[(string) $name];
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Get named routes
+ * @return \ArrayIterator
+ */
+ public function getNamedRoutes()
+ {
+ if (is_null($this->namedRoutes)) {
+ $this->namedRoutes = array();
+ foreach ($this->routes as $route) {
+ if ($route->getName() !== null) {
+ $this->addNamedRoute($route->getName(), $route);
+ }
+ }
+ }
+
+ return new \ArrayIterator($this->namedRoutes);
+ }
+}
diff --git a/api/libs/Slim/Slim.php b/api/libs/Slim/Slim.php
new file mode 100644
index 0000000..2a68b6c
--- /dev/null
+++ b/api/libs/Slim/Slim.php
@@ -0,0 +1,1394 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.3.5
+ * @package Slim
+ *
+ * MIT LICENSE
+ *
+ * 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 the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+namespace Slim;
+
+// Ensure mcrypt constants are defined even if mcrypt extension is not loaded
+if (!extension_loaded('mcrypt')) {
+ define('MCRYPT_MODE_CBC', 0);
+ define('MCRYPT_RIJNDAEL_256', 0);
+}
+
+/**
+ * Slim
+ * @package Slim
+ * @author Josh Lockhart
+ * @since 1.0.0
+ */
+class Slim
+{
+ /**
+ * @const string
+ */
+ const VERSION = '2.3.5';
+
+ /**
+ * @var \Slim\Helper\Set
+ */
+ public $container;
+
+ /**
+ * @var array[\Slim]
+ */
+ protected static $apps = array();
+
+ /**
+ * @var string
+ */
+ protected $name;
+
+ /**
+ * @var array
+ */
+ protected $middleware;
+
+ /**
+ * @var mixed Callable to be invoked if application error
+ */
+ protected $error;
+
+ /**
+ * @var mixed Callable to be invoked if no matching routes are found
+ */
+ protected $notFound;
+
+ /**
+ * @var array
+ */
+ protected $hooks = array(
+ 'slim.before' => array(array()),
+ 'slim.before.router' => array(array()),
+ 'slim.before.dispatch' => array(array()),
+ 'slim.after.dispatch' => array(array()),
+ 'slim.after.router' => array(array()),
+ 'slim.after' => array(array())
+ );
+
+ /********************************************************************************
+ * PSR-0 Autoloader
+ *
+ * Do not use if you are using Composer to autoload dependencies.
+ *******************************************************************************/
+
+ /**
+ * Slim PSR-0 autoloader
+ */
+ public static function autoload($className)
+ {
+ $thisClass = str_replace(__NAMESPACE__.'\\', '', __CLASS__);
+
+ $baseDir = __DIR__;
+
+ if (substr($baseDir, -strlen($thisClass)) === $thisClass) {
+ $baseDir = substr($baseDir, 0, -strlen($thisClass));
+ }
+
+ $className = ltrim($className, '\\');
+ $fileName = $baseDir;
+ $namespace = '';
+ if ($lastNsPos = strripos($className, '\\')) {
+ $namespace = substr($className, 0, $lastNsPos);
+ $className = substr($className, $lastNsPos + 1);
+ $fileName .= str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR;
+ }
+ $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php';
+
+ if (file_exists($fileName)) {
+ require $fileName;
+ }
+ }
+
+ /**
+ * Register Slim's PSR-0 autoloader
+ */
+ public static function registerAutoloader()
+ {
+ spl_autoload_register(__NAMESPACE__ . "\\Slim::autoload");
+ }
+
+ /********************************************************************************
+ * Instantiation and Configuration
+ *******************************************************************************/
+
+ /**
+ * Constructor
+ * @param array $userSettings Associative array of application settings
+ */
+ public function __construct(array $userSettings = array())
+ {
+ // Setup IoC container
+ $this->container = new \Slim\Helper\Set();
+ $this->container['settings'] = array_merge(static::getDefaultSettings(), $userSettings);
+
+ // Default environment
+ $this->container->singleton('environment', function ($c) {
+ return \Slim\Environment::getInstance();
+ });
+
+ // Default request
+ $this->container->singleton('request', function ($c) {
+ return new \Slim\Http\Request($c['environment']);
+ });
+
+ // Default response
+ $this->container->singleton('response', function ($c) {
+ return new \Slim\Http\Response();
+ });
+
+ // Default router
+ $this->container->singleton('router', function ($c) {
+ return new \Slim\Router();
+ });
+
+ // Default view
+ $this->container->singleton('view', function ($c) {
+ $viewClass = $c['settings']['view'];
+
+ return ($viewClass instanceOf \Slim\View) ? $viewClass : new $viewClass;
+ });
+
+ // Default log writer
+ $this->container->singleton('logWriter', function ($c) {
+ $logWriter = $c['settings']['log.writer'];
+
+ return is_object($logWriter) ? $logWriter : new \Slim\LogWriter($c['environment']['slim.errors']);
+ });
+
+ // Default log
+ $this->container->singleton('log', function ($c) {
+ $log = new \Slim\Log($c['logWriter']);
+ $log->setEnabled($c['settings']['log.enabled']);
+ $log->setLevel($c['settings']['log.level']);
+ $env = $c['environment'];
+ $env['slim.log'] = $log;
+
+ return $log;
+ });
+
+ // Default mode
+ $this->container['mode'] = function ($c) {
+ $mode = $c['settings']['mode'];
+
+ if (isset($_ENV['SLIM_MODE'])) {
+ $mode = $_ENV['SLIM_MODE'];
+ } else {
+ $envMode = getenv('SLIM_MODE');
+ if ($envMode !== false) {
+ $mode = $envMode;
+ }
+ }
+
+ return $mode;
+ };
+
+ // Define default middleware stack
+ $this->middleware = array($this);
+ $this->add(new \Slim\Middleware\Flash());
+ $this->add(new \Slim\Middleware\MethodOverride());
+
+ // Make default if first instance
+ if (is_null(static::getInstance())) {
+ $this->setName('default');
+ }
+ }
+
+ public function __get($name)
+ {
+ return $this->container[$name];
+ }
+
+ public function __set($name, $value)
+ {
+ $this->container[$name] = $value;
+ }
+
+ public function __isset($name)
+ {
+ return isset($this->container[$name]);
+ }
+
+ public function __unset($name)
+ {
+ unset($this->container[$name]);
+ }
+
+ /**
+ * Get application instance by name
+ * @param string $name The name of the Slim application
+ * @return \Slim\Slim|null
+ */
+ public static function getInstance($name = 'default')
+ {
+ return isset(static::$apps[$name]) ? static::$apps[$name] : null;
+ }
+
+ /**
+ * Set Slim application name
+ * @param string $name The name of this Slim application
+ */
+ public function setName($name)
+ {
+ $this->name = $name;
+ static::$apps[$name] = $this;
+ }
+
+ /**
+ * Get Slim application name
+ * @return string|null
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ /**
+ * Get default application settings
+ * @return array
+ */
+ public static function getDefaultSettings()
+ {
+ return array(
+ // Application
+ 'mode' => 'development',
+ // Debugging
+ 'debug' => true,
+ // Logging
+ 'log.writer' => null,
+ 'log.level' => \Slim\Log::DEBUG,
+ 'log.enabled' => true,
+ // View
+ 'templates.path' => './templates',
+ 'view' => '\Slim\View',
+ // Cookies
+ 'cookies.encrypt' => false,
+ 'cookies.lifetime' => '20 minutes',
+ 'cookies.path' => '/',
+ 'cookies.domain' => null,
+ 'cookies.secure' => false,
+ 'cookies.httponly' => false,
+ // Encryption
+ 'cookies.secret_key' => 'CHANGE_ME',
+ 'cookies.cipher' => MCRYPT_RIJNDAEL_256,
+ 'cookies.cipher_mode' => MCRYPT_MODE_CBC,
+ // HTTP
+ 'http.version' => '1.1'
+ );
+ }
+
+ /**
+ * Configure Slim Settings
+ *
+ * This method defines application settings and acts as a setter and a getter.
+ *
+ * If only one argument is specified and that argument is a string, the value
+ * of the setting identified by the first argument will be returned, or NULL if
+ * that setting does not exist.
+ *
+ * If only one argument is specified and that argument is an associative array,
+ * the array will be merged into the existing application settings.
+ *
+ * If two arguments are provided, the first argument is the name of the setting
+ * to be created or updated, and the second argument is the setting value.
+ *
+ * @param string|array $name If a string, the name of the setting to set or retrieve. Else an associated array of setting names and values
+ * @param mixed $value If name is a string, the value of the setting identified by $name
+ * @return mixed The value of a setting if only one argument is a string
+ */
+ public function config($name, $value = null)
+ {
+ if (func_num_args() === 1) {
+ if (is_array($name)) {
+ $this->settings = array_merge($this->settings, $name);
+ } else {
+ return isset($this->settings[$name]) ? $this->settings[$name] : null;
+ }
+ } else {
+ $settings = $this->settings;
+ $settings[$name] = $value;
+ $this->settings = $settings;
+ }
+ }
+
+ /********************************************************************************
+ * Application Modes
+ *******************************************************************************/
+
+ /**
+ * Get application mode
+ *
+ * This method determines the application mode. It first inspects the $_ENV
+ * superglobal for key `SLIM_MODE`. If that is not found, it queries
+ * the `getenv` function. Else, it uses the application `mode` setting.
+ *
+ * @return string
+ */
+ public function getMode()
+ {
+ return $this->mode;
+ }
+
+ /**
+ * Configure Slim for a given mode
+ *
+ * This method will immediately invoke the callable if
+ * the specified mode matches the current application mode.
+ * Otherwise, the callable is ignored. This should be called
+ * only _after_ you initialize your Slim app.
+ *
+ * @param string $mode
+ * @param mixed $callable
+ * @return void
+ */
+ public function configureMode($mode, $callable)
+ {
+ if ($mode === $this->getMode() && is_callable($callable)) {
+ call_user_func($callable);
+ }
+ }
+
+ /********************************************************************************
+ * Logging
+ *******************************************************************************/
+
+ /**
+ * Get application log
+ * @return \Slim\Log
+ */
+ public function getLog()
+ {
+ return $this->log;
+ }
+
+ /********************************************************************************
+ * Routing
+ *******************************************************************************/
+
+ /**
+ * Add GET|POST|PUT|PATCH|DELETE route
+ *
+ * Adds a new route to the router with associated callable. This
+ * route will only be invoked when the HTTP request's method matches
+ * this route's method.
+ *
+ * ARGUMENTS:
+ *
+ * First: string The URL pattern (REQUIRED)
+ * In-Between: mixed Anything that returns TRUE for `is_callable` (OPTIONAL)
+ * Last: mixed Anything that returns TRUE for `is_callable` (REQUIRED)
+ *
+ * The first argument is required and must always be the
+ * route pattern (ie. '/books/:id').
+ *
+ * The last argument is required and must always be the callable object
+ * to be invoked when the route matches an HTTP request.
+ *
+ * You may also provide an unlimited number of in-between arguments;
+ * each interior argument must be callable and will be invoked in the
+ * order specified before the route's callable is invoked.
+ *
+ * USAGE:
+ *
+ * Slim::get('/foo'[, middleware, middleware, ...], callable);
+ *
+ * @param array (See notes above)
+ * @return \Slim\Route
+ */
+ protected function mapRoute($args)
+ {
+ $pattern = array_shift($args);
+ $callable = array_pop($args);
+ $route = new \Slim\Route($pattern, $callable);
+ $this->router->map($route);
+ if (count($args) > 0) {
+ $route->setMiddleware($args);
+ }
+
+ return $route;
+ }
+
+ /**
+ * Add generic route without associated HTTP method
+ * @see mapRoute()
+ * @return \Slim\Route
+ */
+ public function map()
+ {
+ $args = func_get_args();
+
+ return $this->mapRoute($args);
+ }
+
+ /**
+ * Add GET route
+ * @see mapRoute()
+ * @return \Slim\Route
+ */
+ public function get()
+ {
+ $args = func_get_args();
+
+ return $this->mapRoute($args)->via(\Slim\Http\Request::METHOD_GET, \Slim\Http\Request::METHOD_HEAD);
+ }
+
+ /**
+ * Add POST route
+ * @see mapRoute()
+ * @return \Slim\Route
+ */
+ public function post()
+ {
+ $args = func_get_args();
+
+ return $this->mapRoute($args)->via(\Slim\Http\Request::METHOD_POST);
+ }
+
+ /**
+ * Add PUT route
+ * @see mapRoute()
+ * @return \Slim\Route
+ */
+ public function put()
+ {
+ $args = func_get_args();
+
+ return $this->mapRoute($args)->via(\Slim\Http\Request::METHOD_PUT);
+ }
+
+ /**
+ * Add PATCH route
+ * @see mapRoute()
+ * @return \Slim\Route
+ */
+ public function patch()
+ {
+ $args = func_get_args();
+
+ return $this->mapRoute($args)->via(\Slim\Http\Request::METHOD_PATCH);
+ }
+
+ /**
+ * Add DELETE route
+ * @see mapRoute()
+ * @return \Slim\Route
+ */
+ public function delete()
+ {
+ $args = func_get_args();
+
+ return $this->mapRoute($args)->via(\Slim\Http\Request::METHOD_DELETE);
+ }
+
+ /**
+ * Add OPTIONS route
+ * @see mapRoute()
+ * @return \Slim\Route
+ */
+ public function options()
+ {
+ $args = func_get_args();
+
+ return $this->mapRoute($args)->via(\Slim\Http\Request::METHOD_OPTIONS);
+ }
+
+ /**
+ * Route Groups
+ *
+ * This method accepts a route pattern and a callback all Route
+ * declarations in the callback will be prepended by the group(s)
+ * that it is in
+ *
+ * Accepts the same parameters as a standard route so:
+ * (pattern, middleware1, middleware2, ..., $callback)
+ */
+ public function group()
+ {
+ $args = func_get_args();
+ $pattern = array_shift($args);
+ $callable = array_pop($args);
+ $this->router->pushGroup($pattern, $args);
+ if (is_callable($callable)) {
+ call_user_func($callable);
+ }
+ $this->router->popGroup();
+ }
+
+ /*
+ * Add route for any HTTP method
+ * @see mapRoute()
+ * @return \Slim\Route
+ */
+ public function any()
+ {
+ $args = func_get_args();
+
+ return $this->mapRoute($args)->via("ANY");
+ }
+
+ /**
+ * Not Found Handler
+ *
+ * This method defines or invokes the application-wide Not Found handler.
+ * There are two contexts in which this method may be invoked:
+ *
+ * 1. When declaring the handler:
+ *
+ * If the $callable parameter is not null and is callable, this
+ * method will register the callable to be invoked when no
+ * routes match the current HTTP request. It WILL NOT invoke the callable.
+ *
+ * 2. When invoking the handler:
+ *
+ * If the $callable parameter is null, Slim assumes you want
+ * to invoke an already-registered handler. If the handler has been
+ * registered and is callable, it is invoked and sends a 404 HTTP Response
+ * whose body is the output of the Not Found handler.
+ *
+ * @param mixed $callable Anything that returns true for is_callable()
+ */
+ public function notFound ($callable = null)
+ {
+ if (is_callable($callable)) {
+ $this->notFound = $callable;
+ } else {
+ ob_start();
+ if (is_callable($this->notFound)) {
+ call_user_func($this->notFound);
+ } else {
+ call_user_func(array($this, 'defaultNotFound'));
+ }
+ $this->halt(404, ob_get_clean());
+ }
+ }
+
+ /**
+ * Error Handler
+ *
+ * This method defines or invokes the application-wide Error handler.
+ * There are two contexts in which this method may be invoked:
+ *
+ * 1. When declaring the handler:
+ *
+ * If the $argument parameter is callable, this
+ * method will register the callable to be invoked when an uncaught
+ * Exception is detected, or when otherwise explicitly invoked.
+ * The handler WILL NOT be invoked in this context.
+ *
+ * 2. When invoking the handler:
+ *
+ * If the $argument parameter is not callable, Slim assumes you want
+ * to invoke an already-registered handler. If the handler has been
+ * registered and is callable, it is invoked and passed the caught Exception
+ * as its one and only argument. The error handler's output is captured
+ * into an output buffer and sent as the body of a 500 HTTP Response.
+ *
+ * @param mixed $argument Callable|\Exception
+ */
+ public function error($argument = null)
+ {
+ if (is_callable($argument)) {
+ //Register error handler
+ $this->error = $argument;
+ } else {
+ //Invoke error handler
+ $this->response->status(500);
+ $this->response->body('');
+ $this->response->write($this->callErrorHandler($argument));
+ $this->stop();
+ }
+ }
+
+ /**
+ * Call error handler
+ *
+ * This will invoke the custom or default error handler
+ * and RETURN its output.
+ *
+ * @param \Exception|null $argument
+ * @return string
+ */
+ protected function callErrorHandler($argument = null)
+ {
+ ob_start();
+ if (is_callable($this->error)) {
+ call_user_func_array($this->error, array($argument));
+ } else {
+ call_user_func_array(array($this, 'defaultError'), array($argument));
+ }
+
+ return ob_get_clean();
+ }
+
+ /********************************************************************************
+ * Application Accessors
+ *******************************************************************************/
+
+ /**
+ * Get a reference to the Environment object
+ * @return \Slim\Environment
+ */
+ public function environment()
+ {
+ return $this->environment;
+ }
+
+ /**
+ * Get the Request object
+ * @return \Slim\Http\Request
+ */
+ public function request()
+ {
+ return $this->request;
+ }
+
+ /**
+ * Get the Response object
+ * @return \Slim\Http\Response
+ */
+ public function response()
+ {
+ return $this->response;
+ }
+
+ /**
+ * Get the Router object
+ * @return \Slim\Router
+ */
+ public function router()
+ {
+ return $this->router;
+ }
+
+ /**
+ * Get and/or set the View
+ *
+ * This method declares the View to be used by the Slim application.
+ * If the argument is a string, Slim will instantiate a new object
+ * of the same class. If the argument is an instance of View or a subclass
+ * of View, Slim will use the argument as the View.
+ *
+ * If a View already exists and this method is called to create a
+ * new View, data already set in the existing View will be
+ * transferred to the new View.
+ *
+ * @param string|\Slim\View $viewClass The name or instance of a \Slim\View subclass
+ * @return \Slim\View
+ */
+ public function view($viewClass = null)
+ {
+ if (!is_null($viewClass)) {
+ $existingData = is_null($this->view) ? array() : $this->view->getData();
+ if ($viewClass instanceOf \Slim\View) {
+ $this->view = $viewClass;
+ } else {
+ $this->view = new $viewClass();
+ }
+ $this->view->appendData($existingData);
+ $this->view->setTemplatesDirectory($this->config('templates.path'));
+ }
+
+ return $this->view;
+ }
+
+ /********************************************************************************
+ * Rendering
+ *******************************************************************************/
+
+ /**
+ * Render a template
+ *
+ * Call this method within a GET, POST, PUT, PATCH, DELETE, NOT FOUND, or ERROR
+ * callable to render a template whose output is appended to the
+ * current HTTP response body. How the template is rendered is
+ * delegated to the current View.
+ *
+ * @param string $template The name of the template passed into the view's render() method
+ * @param array $data Associative array of data made available to the view
+ * @param int $status The HTTP response status code to use (optional)
+ */
+ public function render($template, $data = array(), $status = null)
+ {
+ if (!is_null($status)) {
+ $this->response->status($status);
+ }
+ $this->view->setTemplatesDirectory($this->config('templates.path'));
+ $this->view->appendData($data);
+ $this->view->display($template);
+ }
+
+ /********************************************************************************
+ * HTTP Caching
+ *******************************************************************************/
+
+ /**
+ * Set Last-Modified HTTP Response Header
+ *
+ * Set the HTTP 'Last-Modified' header and stop if a conditional
+ * GET request's `If-Modified-Since` header matches the last modified time
+ * of the resource. The `time` argument is a UNIX timestamp integer value.
+ * When the current request includes an 'If-Modified-Since' header that
+ * matches the specified last modified time, the application will stop
+ * and send a '304 Not Modified' response to the client.
+ *
+ * @param int $time The last modified UNIX timestamp
+ * @throws \InvalidArgumentException If provided timestamp is not an integer
+ */
+ public function lastModified($time)
+ {
+ if (is_integer($time)) {
+ $this->response->headers->set('Last-Modified', gmdate('D, d M Y H:i:s T', $time));
+ if ($time === strtotime($this->request->headers->get('IF_MODIFIED_SINCE'))) {
+ $this->halt(304);
+ }
+ } else {
+ throw new \InvalidArgumentException('Slim::lastModified only accepts an integer UNIX timestamp value.');
+ }
+ }
+
+ /**
+ * Set ETag HTTP Response Header
+ *
+ * Set the etag header and stop if the conditional GET request matches.
+ * The `value` argument is a unique identifier for the current resource.
+ * The `type` argument indicates whether the etag should be used as a strong or
+ * weak cache validator.
+ *
+ * When the current request includes an 'If-None-Match' header with
+ * a matching etag, execution is immediately stopped. If the request
+ * method is GET or HEAD, a '304 Not Modified' response is sent.
+ *
+ * @param string $value The etag value
+ * @param string $type The type of etag to create; either "strong" or "weak"
+ * @throws \InvalidArgumentException If provided type is invalid
+ */
+ public function etag($value, $type = 'strong')
+ {
+ //Ensure type is correct
+ if (!in_array($type, array('strong', 'weak'))) {
+ throw new \InvalidArgumentException('Invalid Slim::etag type. Expected "strong" or "weak".');
+ }
+
+ //Set etag value
+ $value = '"' . $value . '"';
+ if ($type === 'weak') {
+ $value = 'W/'.$value;
+ }
+ $this->response['ETag'] = $value;
+
+ //Check conditional GET
+ if ($etagsHeader = $this->request->headers->get('IF_NONE_MATCH')) {
+ $etags = preg_split('@\s*,\s*@', $etagsHeader);
+ if (in_array($value, $etags) || in_array('*', $etags)) {
+ $this->halt(304);
+ }
+ }
+ }
+
+ /**
+ * Set Expires HTTP response header
+ *
+ * The `Expires` header tells the HTTP client the time at which
+ * the current resource should be considered stale. At that time the HTTP
+ * client will send a conditional GET request to the server; the server
+ * may return a 200 OK if the resource has changed, else a 304 Not Modified
+ * if the resource has not changed. The `Expires` header should be used in
+ * conjunction with the `etag()` or `lastModified()` methods above.
+ *
+ * @param string|int $time If string, a time to be parsed by `strtotime()`;
+ * If int, a UNIX timestamp;
+ */
+ public function expires($time)
+ {
+ if (is_string($time)) {
+ $time = strtotime($time);
+ }
+ $this->response->headers->set('Expires', gmdate('D, d M Y H:i:s T', $time));
+ }
+
+ /********************************************************************************
+ * HTTP Cookies
+ *******************************************************************************/
+
+ /**
+ * Set HTTP cookie to be sent with the HTTP response
+ *
+ * @param string $name The cookie name
+ * @param string $value The cookie value
+ * @param int|string $time The duration of the cookie;
+ * If integer, should be UNIX timestamp;
+ * If string, converted to UNIX timestamp with `strtotime`;
+ * @param string $path The path on the server in which the cookie will be available on
+ * @param string $domain The domain that the cookie is available to
+ * @param bool $secure Indicates that the cookie should only be transmitted over a secure
+ * HTTPS connection to/from the client
+ * @param bool $httponly When TRUE the cookie will be made accessible only through the HTTP protocol
+ */
+ public function setCookie($name, $value, $time = null, $path = null, $domain = null, $secure = null, $httponly = null)
+ {
+ $settings = array(
+ 'value' => $value,
+ 'expires' => is_null($time) ? $this->config('cookies.lifetime') : $time,
+ 'path' => is_null($path) ? $this->config('cookies.path') : $path,
+ 'domain' => is_null($domain) ? $this->config('cookies.domain') : $domain,
+ 'secure' => is_null($secure) ? $this->config('cookies.secure') : $secure,
+ 'httponly' => is_null($httponly) ? $this->config('cookies.httponly') : $httponly
+ );
+ $this->response->cookies->set($name, $settings);
+ }
+
+ /**
+ * Get value of HTTP cookie from the current HTTP request
+ *
+ * Return the value of a cookie from the current HTTP request,
+ * or return NULL if cookie does not exist. Cookies created during
+ * the current request will not be available until the next request.
+ *
+ * @param string $name
+ * @param bool $deleteIfInvalid
+ * @return string|null
+ */
+ public function getCookie($name, $deleteIfInvalid = true)
+ {
+ // Get cookie value
+ $value = $this->request->cookies->get($name);
+
+ // Decode if encrypted
+ if ($this->config('cookies.encrypt')) {
+ $value = \Slim\Http\Util::decodeSecureCookie(
+ $value,
+ $this->config('cookies.secret_key'),
+ $this->config('cookies.cipher'),
+ $this->config('cookies.cipher_mode')
+ );
+ if ($value === false && $deleteIfInvalid) {
+ $this->deleteCookie($name);
+ }
+ }
+
+ return $value;
+ }
+
+ /**
+ * DEPRECATION WARNING! Use `setCookie` with the `cookies.encrypt` app setting set to `true`.
+ *
+ * Set encrypted HTTP cookie
+ *
+ * @param string $name The cookie name
+ * @param mixed $value The cookie value
+ * @param mixed $expires The duration of the cookie;
+ * If integer, should be UNIX timestamp;
+ * If string, converted to UNIX timestamp with `strtotime`;
+ * @param string $path The path on the server in which the cookie will be available on
+ * @param string $domain The domain that the cookie is available to
+ * @param bool $secure Indicates that the cookie should only be transmitted over a secure
+ * HTTPS connection from the client
+ * @param bool $httponly When TRUE the cookie will be made accessible only through the HTTP protocol
+ */
+ public function setEncryptedCookie($name, $value, $expires = null, $path = null, $domain = null, $secure = false, $httponly = false)
+ {
+ $this->setCookie($name, $value, $expires, $path, $domain, $secure, $httponly);
+ }
+
+ /**
+ * DEPRECATION WARNING! Use `getCookie` with the `cookies.encrypt` app setting set to `true`.
+ *
+ * Get value of encrypted HTTP cookie
+ *
+ * Return the value of an encrypted cookie from the current HTTP request,
+ * or return NULL if cookie does not exist. Encrypted cookies created during
+ * the current request will not be available until the next request.
+ *
+ * @param string $name
+ * @param bool $deleteIfInvalid
+ * @return string|bool
+ */
+ public function getEncryptedCookie($name, $deleteIfInvalid = true)
+ {
+ return $this->getCookie($name, $deleteIfInvalid);
+ }
+
+ /**
+ * Delete HTTP cookie (encrypted or unencrypted)
+ *
+ * Remove a Cookie from the client. This method will overwrite an existing Cookie
+ * with a new, empty, auto-expiring Cookie. This method's arguments must match
+ * the original Cookie's respective arguments for the original Cookie to be
+ * removed. If any of this method's arguments are omitted or set to NULL, the
+ * default Cookie setting values (set during Slim::init) will be used instead.
+ *
+ * @param string $name The cookie name
+ * @param string $path The path on the server in which the cookie will be available on
+ * @param string $domain The domain that the cookie is available to
+ * @param bool $secure Indicates that the cookie should only be transmitted over a secure
+ * HTTPS connection from the client
+ * @param bool $httponly When TRUE the cookie will be made accessible only through the HTTP protocol
+ */
+ public function deleteCookie($name, $path = null, $domain = null, $secure = null, $httponly = null)
+ {
+ $settings = array(
+ 'domain' => is_null($domain) ? $this->config('cookies.domain') : $domain,
+ 'path' => is_null($path) ? $this->config('cookies.path') : $path,
+ 'secure' => is_null($secure) ? $this->config('cookies.secure') : $secure,
+ 'httponly' => is_null($httponly) ? $this->config('cookies.httponly') : $httponly
+ );
+ $this->response->cookies->remove($name, $settings);
+ }
+
+ /********************************************************************************
+ * Helper Methods
+ *******************************************************************************/
+
+ /**
+ * Get the absolute path to this Slim application's root directory
+ *
+ * This method returns the absolute path to the Slim application's
+ * directory. If the Slim application is installed in a public-accessible
+ * sub-directory, the sub-directory path will be included. This method
+ * will always return an absolute path WITH a trailing slash.
+ *
+ * @return string
+ */
+ public function root()
+ {
+ return rtrim($_SERVER['DOCUMENT_ROOT'], '/') . rtrim($this->request->getRootUri(), '/') . '/';
+ }
+
+ /**
+ * Clean current output buffer
+ */
+ protected function cleanBuffer()
+ {
+ if (ob_get_level() !== 0) {
+ ob_clean();
+ }
+ }
+
+ /**
+ * Stop
+ *
+ * The thrown exception will be caught in application's `call()` method
+ * and the response will be sent as is to the HTTP client.
+ *
+ * @throws \Slim\Exception\Stop
+ */
+ public function stop()
+ {
+ throw new \Slim\Exception\Stop();
+ }
+
+ /**
+ * Halt
+ *
+ * Stop the application and immediately send the response with a
+ * specific status and body to the HTTP client. This may send any
+ * type of response: info, success, redirect, client error, or server error.
+ * If you need to render a template AND customize the response status,
+ * use the application's `render()` method instead.
+ *
+ * @param int $status The HTTP response status
+ * @param string $message The HTTP response body
+ */
+ public function halt($status, $message = '')
+ {
+ $this->cleanBuffer();
+ $this->response->status($status);
+ $this->response->body($message);
+ $this->stop();
+ }
+
+ /**
+ * Pass
+ *
+ * The thrown exception is caught in the application's `call()` method causing
+ * the router's current iteration to stop and continue to the subsequent route if available.
+ * If no subsequent matching routes are found, a 404 response will be sent to the client.
+ *
+ * @throws \Slim\Exception\Pass
+ */
+ public function pass()
+ {
+ $this->cleanBuffer();
+ throw new \Slim\Exception\Pass();
+ }
+
+ /**
+ * Set the HTTP response Content-Type
+ * @param string $type The Content-Type for the Response (ie. text/html)
+ */
+ public function contentType($type)
+ {
+ $this->response->headers->set('Content-Type', $type);
+ }
+
+ /**
+ * Set the HTTP response status code
+ * @param int $code The HTTP response status code
+ */
+ public function status($code)
+ {
+ $this->response->setStatus($code);
+ }
+
+ /**
+ * Get the URL for a named route
+ * @param string $name The route name
+ * @param array $params Associative array of URL parameters and replacement values
+ * @throws \RuntimeException If named route does not exist
+ * @return string
+ */
+ public function urlFor($name, $params = array())
+ {
+ return $this->request->getRootUri() . $this->router->urlFor($name, $params);
+ }
+
+ /**
+ * Redirect
+ *
+ * This method immediately redirects to a new URL. By default,
+ * this issues a 302 Found response; this is considered the default
+ * generic redirect response. You may also specify another valid
+ * 3xx status code if you want. This method will automatically set the
+ * HTTP Location header for you using the URL parameter.
+ *
+ * @param string $url The destination URL
+ * @param int $status The HTTP redirect status code (optional)
+ */
+ public function redirect($url, $status = 302)
+ {
+ $this->response->redirect($url, $status);
+ $this->halt($status);
+ }
+
+ /********************************************************************************
+ * Flash Messages
+ *******************************************************************************/
+
+ /**
+ * Set flash message for subsequent request
+ * @param string $key
+ * @param mixed $value
+ */
+ public function flash($key, $value)
+ {
+ if (isset($this->environment['slim.flash'])) {
+ $this->environment['slim.flash']->set($key, $value);
+ }
+ }
+
+ /**
+ * Set flash message for current request
+ * @param string $key
+ * @param mixed $value
+ */
+ public function flashNow($key, $value)
+ {
+ if (isset($this->environment['slim.flash'])) {
+ $this->environment['slim.flash']->now($key, $value);
+ }
+ }
+
+ /**
+ * Keep flash messages from previous request for subsequent request
+ */
+ public function flashKeep()
+ {
+ if (isset($this->environment['slim.flash'])) {
+ $this->environment['slim.flash']->keep();
+ }
+ }
+
+ /********************************************************************************
+ * Hooks
+ *******************************************************************************/
+
+ /**
+ * Assign hook
+ * @param string $name The hook name
+ * @param mixed $callable A callable object
+ * @param int $priority The hook priority; 0 = high, 10 = low
+ */
+ public function hook($name, $callable, $priority = 10)
+ {
+ if (!isset($this->hooks[$name])) {
+ $this->hooks[$name] = array(array());
+ }
+ if (is_callable($callable)) {
+ $this->hooks[$name][(int) $priority][] = $callable;
+ }
+ }
+
+ /**
+ * Invoke hook
+ * @param string $name The hook name
+ * @param mixed $hookArg (Optional) Argument for hooked functions
+ */
+ public function applyHook($name, $hookArg = null)
+ {
+ if (!isset($this->hooks[$name])) {
+ $this->hooks[$name] = array(array());
+ }
+ if (!empty($this->hooks[$name])) {
+ // Sort by priority, low to high, if there's more than one priority
+ if (count($this->hooks[$name]) > 1) {
+ ksort($this->hooks[$name]);
+ }
+ foreach ($this->hooks[$name] as $priority) {
+ if (!empty($priority)) {
+ foreach ($priority as $callable) {
+ call_user_func($callable, $hookArg);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Get hook listeners
+ *
+ * Return an array of registered hooks. If `$name` is a valid
+ * hook name, only the listeners attached to that hook are returned.
+ * Else, all listeners are returned as an associative array whose
+ * keys are hook names and whose values are arrays of listeners.
+ *
+ * @param string $name A hook name (Optional)
+ * @return array|null
+ */
+ public function getHooks($name = null)
+ {
+ if (!is_null($name)) {
+ return isset($this->hooks[(string) $name]) ? $this->hooks[(string) $name] : null;
+ } else {
+ return $this->hooks;
+ }
+ }
+
+ /**
+ * Clear hook listeners
+ *
+ * Clear all listeners for all hooks. If `$name` is
+ * a valid hook name, only the listeners attached
+ * to that hook will be cleared.
+ *
+ * @param string $name A hook name (Optional)
+ */
+ public function clearHooks($name = null)
+ {
+ if (!is_null($name) && isset($this->hooks[(string) $name])) {
+ $this->hooks[(string) $name] = array(array());
+ } else {
+ foreach ($this->hooks as $key => $value) {
+ $this->hooks[$key] = array(array());
+ }
+ }
+ }
+
+ /********************************************************************************
+ * Middleware
+ *******************************************************************************/
+
+ /**
+ * Add middleware
+ *
+ * This method prepends new middleware to the application middleware stack.
+ * The argument must be an instance that subclasses Slim_Middleware.
+ *
+ * @param \Slim\Middleware
+ */
+ public function add(\Slim\Middleware $newMiddleware)
+ {
+ $newMiddleware->setApplication($this);
+ $newMiddleware->setNextMiddleware($this->middleware[0]);
+ array_unshift($this->middleware, $newMiddleware);
+ }
+
+ /********************************************************************************
+ * Runner
+ *******************************************************************************/
+
+ /**
+ * Run
+ *
+ * This method invokes the middleware stack, including the core Slim application;
+ * the result is an array of HTTP status, header, and body. These three items
+ * are returned to the HTTP client.
+ */
+ public function run()
+ {
+ set_error_handler(array('\Slim\Slim', 'handleErrors'));
+
+ //Apply final outer middleware layers
+ if ($this->config('debug')) {
+ //Apply pretty exceptions only in debug to avoid accidental information leakage in production
+ $this->add(new \Slim\Middleware\PrettyExceptions());
+ }
+
+ //Invoke middleware and application stack
+ $this->middleware[0]->call();
+
+ //Fetch status, header, and body
+ list($status, $headers, $body) = $this->response->finalize();
+
+ // Serialize cookies (with optional encryption)
+ \Slim\Http\Util::serializeCookies($headers, $this->response->cookies, $this->settings);
+
+ //Send headers
+ if (headers_sent() === false) {
+ //Send status
+ if (strpos(PHP_SAPI, 'cgi') === 0) {
+ header(sprintf('Status: %s', \Slim\Http\Response::getMessageForCode($status)));
+ } else {
+ header(sprintf('HTTP/%s %s', $this->config('http.version'), \Slim\Http\Response::getMessageForCode($status)));
+ }
+
+ //Send headers
+ foreach ($headers as $name => $value) {
+ $hValues = explode("\n", $value);
+ foreach ($hValues as $hVal) {
+ header("$name: $hVal", false);
+ }
+ }
+ }
+
+ //Send body, but only if it isn't a HEAD request
+ if (!$this->request->isHead()) {
+ echo $body;
+ }
+
+ restore_error_handler();
+ }
+
+ /**
+ * Call
+ *
+ * This method finds and iterates all route objects that match the current request URI.
+ */
+ public function call()
+ {
+ try {
+ if (isset($this->environment['slim.flash'])) {
+ $this->view()->setData('flash', $this->environment['slim.flash']);
+ }
+ $this->applyHook('slim.before');
+ ob_start();
+ $this->applyHook('slim.before.router');
+ $dispatched = false;
+ $matchedRoutes = $this->router->getMatchedRoutes($this->request->getMethod(), $this->request->getResourceUri());
+ foreach ($matchedRoutes as $route) {
+ try {
+ $this->applyHook('slim.before.dispatch');
+ $dispatched = $route->dispatch();
+ $this->applyHook('slim.after.dispatch');
+ if ($dispatched) {
+ break;
+ }
+ } catch (\Slim\Exception\Pass $e) {
+ continue;
+ }
+ }
+ if (!$dispatched) {
+ $this->notFound();
+ }
+ $this->applyHook('slim.after.router');
+ $this->stop();
+ } catch (\Slim\Exception\Stop $e) {
+ $this->response()->write(ob_get_clean());
+ $this->applyHook('slim.after');
+ } catch (\Exception $e) {
+ if ($this->config('debug')) {
+ throw $e;
+ } else {
+ try {
+ $this->error($e);
+ } catch (\Slim\Exception\Stop $e) {
+ // Do nothing
+ }
+ }
+ }
+ }
+
+ /********************************************************************************
+ * Error Handling and Debugging
+ *******************************************************************************/
+
+ /**
+ * Convert errors into ErrorException objects
+ *
+ * This method catches PHP errors and converts them into \ErrorException objects;
+ * these \ErrorException objects are then thrown and caught by Slim's
+ * built-in or custom error handlers.
+ *
+ * @param int $errno The numeric type of the Error
+ * @param string $errstr The error message
+ * @param string $errfile The absolute path to the affected file
+ * @param int $errline The line number of the error in the affected file
+ * @return bool
+ * @throws \ErrorException
+ */
+ public static function handleErrors($errno, $errstr = '', $errfile = '', $errline = '')
+ {
+ if (!($errno & error_reporting())) {
+ return;
+ }
+
+ throw new \ErrorException($errstr, $errno, 0, $errfile, $errline);
+ }
+
+ /**
+ * Generate diagnostic template markup
+ *
+ * This method accepts a title and body content to generate an HTML document layout.
+ *
+ * @param string $title The title of the HTML template
+ * @param string $body The body content of the HTML template
+ * @return string
+ */
+ protected static function generateTemplateMarkup($title, $body)
+ {
+ return sprintf("%s
%s
%s", $title, $title, $body);
+ }
+
+ /**
+ * Default Not Found handler
+ */
+ protected function defaultNotFound()
+ {
+ echo static::generateTemplateMarkup('404 Page Not Found', '
The page you are looking for could not be found. Check the address bar to ensure your URL is spelled correctly. If all else fails, you can visit our home page at the link below.
Visit the Home Page');
+ }
+
+ /**
+ * Default Error handler
+ */
+ protected function defaultError($e)
+ {
+ $this->getLog()->error($e);
+ echo self::generateTemplateMarkup('Error', '
A website error has occurred. The website administrator has been notified of the issue. Sorry for the temporary inconvenience.
');
+ }
+}
diff --git a/api/libs/Slim/View.php b/api/libs/Slim/View.php
new file mode 100644
index 0000000..c6c435a
--- /dev/null
+++ b/api/libs/Slim/View.php
@@ -0,0 +1,276 @@
+
+ * @copyright 2011 Josh Lockhart
+ * @link http://www.slimframework.com
+ * @license http://www.slimframework.com/license
+ * @version 2.3.5
+ * @package Slim
+ *
+ * MIT LICENSE
+ *
+ * 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 the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+namespace Slim;
+
+/**
+ * View
+ *
+ * The view is responsible for rendering a template. The view
+ * should subclass \Slim\View and implement this interface:
+ *
+ * public render(string $template);
+ *
+ * This method should render the specified template and return
+ * the resultant string.
+ *
+ * @package Slim
+ * @author Josh Lockhart
+ * @since 1.0.0
+ */
+class View
+{
+ /**
+ * Data available to the view templates
+ * @var \Slim\Helper\Set
+ */
+ protected $data;
+
+ /**
+ * Path to templates base directory (without trailing slash)
+ * @var string
+ */
+ protected $templatesDirectory;
+
+ /**
+ * Constructor
+ */
+ public function __construct()
+ {
+ $this->data = new \Slim\Helper\Set();
+ }
+
+ /********************************************************************************
+ * Data methods
+ *******************************************************************************/
+
+ /**
+ * Does view data have value with key?
+ * @param string $key
+ * @return boolean
+ */
+ public function has($key)
+ {
+ return $this->data->has($key);
+ }
+
+ /**
+ * Return view data value with key
+ * @param string $key
+ * @return mixed
+ */
+ public function get($key)
+ {
+ return $this->data->get($key);
+ }
+
+ /**
+ * Set view data value with key
+ * @param string $key
+ * @param mixed $value
+ */
+ public function set($key, $value)
+ {
+ $this->data->set($key, $value);
+ }
+
+ /**
+ * Set view data value as Closure with key
+ * @param string $key
+ * @param mixed $value
+ */
+ public function keep($key, Closure $value)
+ {
+ $this->data->keep($key, $value);
+ }
+
+ /**
+ * Return view data
+ * @return array
+ */
+ public function all()
+ {
+ return $this->data->all();
+ }
+
+ /**
+ * Replace view data
+ * @param array $data
+ */
+ public function replace(array $data)
+ {
+ $this->data->replace($data);
+ }
+
+ /**
+ * Clear view data
+ */
+ public function clear()
+ {
+ $this->data->clear();
+ }
+
+ /********************************************************************************
+ * Legacy data methods
+ *******************************************************************************/
+
+ /**
+ * DEPRECATION WARNING! This method will be removed in the next major point release
+ *
+ * Get data from view
+ */
+ public function getData($key = null)
+ {
+ if (!is_null($key)) {
+ return isset($this->data[$key]) ? $this->data[$key] : null;
+ } else {
+ return $this->data->all();
+ }
+ }
+
+ /**
+ * DEPRECATION WARNING! This method will be removed in the next major point release
+ *
+ * Set data for view
+ */
+ public function setData()
+ {
+ $args = func_get_args();
+ if (count($args) === 1 && is_array($args[0])) {
+ $this->data->replace($args[0]);
+ } elseif (count($args) === 2) {
+ // Ensure original behavior is maintained. DO NOT invoke stored Closures.
+ if (is_object($args[1]) && method_exists($args[1], '__invoke')) {
+ $this->data->set($args[0], $this->data->protect($args[1]));
+ } else {
+ $this->data->set($args[0], $args[1]);
+ }
+ } else {
+ throw new \InvalidArgumentException('Cannot set View data with provided arguments. Usage: `View::setData( $key, $value );` or `View::setData([ key => value, ... ]);`');
+ }
+ }
+
+ /**
+ * DEPRECATION WARNING! This method will be removed in the next major point release
+ *
+ * Append data to view
+ * @param array $data
+ */
+ public function appendData($data)
+ {
+ if (!is_array($data)) {
+ throw new \InvalidArgumentException('Cannot append view data. Expected array argument.');
+ }
+ $this->data->replace($data);
+ }
+
+ /********************************************************************************
+ * Resolve template paths
+ *******************************************************************************/
+
+ /**
+ * Set the base directory that contains view templates
+ * @param string $directory
+ * @throws \InvalidArgumentException If directory is not a directory
+ */
+ public function setTemplatesDirectory($directory)
+ {
+ $this->templatesDirectory = rtrim($directory, DIRECTORY_SEPARATOR);
+ }
+
+ /**
+ * Get templates base directory
+ * @return string
+ */
+ public function getTemplatesDirectory()
+ {
+ return $this->templatesDirectory;
+ }
+
+ /**
+ * Get fully qualified path to template file using templates base directory
+ * @param string $file The template file pathname relative to templates base directory
+ * @return string
+ */
+ public function getTemplatePathname($file)
+ {
+ return $this->templatesDirectory . DIRECTORY_SEPARATOR . ltrim($file, DIRECTORY_SEPARATOR);
+ }
+
+ /********************************************************************************
+ * Rendering
+ *******************************************************************************/
+
+ /**
+ * Display template
+ *
+ * This method echoes the rendered template to the current output buffer
+ *
+ * @param string $template Pathname of template file relative to templates directory
+ */
+ public function display($template)
+ {
+ echo $this->fetch($template);
+ }
+
+ /**
+ * Return the contents of a rendered template file
+ * @var string $template The template pathname, relative to the template base directory
+ * @return string The rendered template
+ */
+ public function fetch($template)
+ {
+ return $this->render($template);
+ }
+
+ /**
+ * Render a template file
+ *
+ * NOTE: This method should be overridden by custom view subclasses
+ *
+ * @var string $template The template pathname, relative to the template base directory
+ * @return string The rendered template
+ * @throws \RuntimeException If resolved template pathname is not a valid file
+ */
+ protected function render($template)
+ {
+ $templatePathname = $this->getTemplatePathname($template);
+ if (!is_file($templatePathname)) {
+ throw new \RuntimeException("View cannot render `$template` because the template does not exist");
+ }
+ extract($this->data->all());
+ ob_start();
+ require $templatePathname;
+
+ return ob_get_clean();
+ }
+}
diff --git a/api/passwordHash.php b/api/passwordHash.php
new file mode 100644
index 0000000..747d2b9
--- /dev/null
+++ b/api/passwordHash.php
@@ -0,0 +1,32 @@
+
diff --git a/api/session.php b/api/session.php
new file mode 100644
index 0000000..ada2ae9
--- /dev/null
+++ b/api/session.php
@@ -0,0 +1,48 @@
+
\ No newline at end of file
diff --git a/app/admin/admin-index.html b/app/admin/admin-index.html
new file mode 100644
index 0000000..1ad1e77
--- /dev/null
+++ b/app/admin/admin-index.html
@@ -0,0 +1,69 @@
+
\ No newline at end of file
diff --git a/app/admin/adminMainCtrl.js b/app/admin/adminMainCtrl.js
new file mode 100644
index 0000000..6580a9d
--- /dev/null
+++ b/app/admin/adminMainCtrl.js
@@ -0,0 +1,7 @@
+app.controller('adminMainCtrl', function ($rootScope, $scope, $location, $filter, Data) {
+
+ if(!$rootScope.user.authenticated === true && !$rootScope.user.role == 0){
+ $location.path('/on/start');
+ }
+
+});
\ No newline at end of file
diff --git a/app/admin/blog/admin-blog.html b/app/admin/blog/admin-blog.html
new file mode 100644
index 0000000..3277079
--- /dev/null
+++ b/app/admin/blog/admin-blog.html
@@ -0,0 +1 @@
+
Управление блогом
\ No newline at end of file
diff --git a/app/admin/forum/admin-forum.html b/app/admin/forum/admin-forum.html
new file mode 100644
index 0000000..d1a0f82
--- /dev/null
+++ b/app/admin/forum/admin-forum.html
@@ -0,0 +1 @@
+
Управление форумом
\ No newline at end of file
diff --git a/app/admin/help/admin-help.html b/app/admin/help/admin-help.html
new file mode 100644
index 0000000..63ab9c0
--- /dev/null
+++ b/app/admin/help/admin-help.html
@@ -0,0 +1 @@
+
Тиккеты и письма администрации
\ No newline at end of file
diff --git a/app/admin/products/admin-products.html b/app/admin/products/admin-products.html
new file mode 100644
index 0000000..5e9ec6c
--- /dev/null
+++ b/app/admin/products/admin-products.html
@@ -0,0 +1 @@
+
Товары
\ No newline at end of file
diff --git a/app/admin/start/admin-start.html b/app/admin/start/admin-start.html
new file mode 100644
index 0000000..2384c89
--- /dev/null
+++ b/app/admin/start/admin-start.html
@@ -0,0 +1,3 @@
+
+ Страница настроек сайта.
+
diff --git a/app/admin/start/settings/admin-start-settings.html b/app/admin/start/settings/admin-start-settings.html
new file mode 100644
index 0000000..356bc20
--- /dev/null
+++ b/app/admin/start/settings/admin-start-settings.html
@@ -0,0 +1,10 @@
+
+
+
+ {{v.setting_description}}:
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/admin/start/themes/admin-start-themes.html b/app/admin/start/themes/admin-start-themes.html
new file mode 100644
index 0000000..f3f82e4
--- /dev/null
+++ b/app/admin/start/themes/admin-start-themes.html
@@ -0,0 +1,18 @@
+
+
+
+
+ Тема: "{{t}}"
+ menu
+ person_add
+ add
+ menu
+ person_add
+ add
+ {{t}} primary
+ {{t}} accent
+ {{t}} warn
+ {{t}} flat
+
+
+
\ No newline at end of file
diff --git a/app/admin/users/admin-users.html b/app/admin/users/admin-users.html
new file mode 100644
index 0000000..59f7294
--- /dev/null
+++ b/app/admin/users/admin-users.html
@@ -0,0 +1 @@
+
'
+ };
+
+});
+
+app.directive('onlyNumbers', function() {
+ return function(scope, element, attrs) {
+ var keyCode = [8,9,13,37,39,46,48,49,50,51,52,53,54,55,56,57,96,97,98,99,100,101,102,103,104,105,110,190];
+ element.bind("keydown", function(event) {
+ if($.inArray(event.which,keyCode) == -1) {
+ scope.$apply(function(){
+ scope.$eval(attrs.onlyNum);
+ event.preventDefault();
+ });
+ event.preventDefault();
+ }
+
+ });
+ };
+});
+
+app.directive('focus', function() {
+ return function(scope, element) {
+ element[0].focus();
+ };
+});
+
+app.directive('passwordMatch', [function () {
+ return {
+ restrict: 'A',
+ scope:true,
+ require: 'ngModel',
+ link: function (scope, elem , attrs, control) {
+ var checker = function () {
+
+ //get the value of the first password
+ var e1 = scope.$eval(attrs.ngModel);
+
+ //get the value of the other password
+ var e2 = scope.$eval(attrs.passwordMatch);
+ if(e2!=null)
+ return e1 == e2;
+ };
+ scope.$watch(checker, function (n) {
+
+ //set the form control to valid if both
+ //passwords are the same, else invalid
+ control.$setValidity("passwordNoMatch", n);
+ });
+ }
+ };
+}]);
+
+app.directive('animateOnChange', function($animate) {
+ return function(scope, elem, attr) {
+ scope.$watch(attr.animateOnChange, function(nv,ov) {
+ if (nv!=ov) {
+ var c = 'change-up';
+ $animate.addClass(elem,c, function() {
+ $animate.removeClass(elem,c);
+ });
+ }
+ });
+ };
+});
+
+app.directive('vxEditable', function() {
+ return {
+ restrict: 'E',
+ scope: {
+ vxFn: '&updatefn',
+ data: '='
+ },
+ template: '{{data}}'+
+ ''+
+ '',
+ link: function(scope, element, attrs){
+ scope.data = scope.data || '!';
+ element.css({
+ padding: '0px 10px',
+ width: '100%'
+ });
+ }
+ };
+});
+
+app.directive('fileChange', function(){
+ return {
+ restrict: 'A',
+ link: function(scope, element, attrs){
+ var fileChangeHandler = scope.$eval(attrs.fileChange);
+ element.bind('change', fileChangeHandler);
+ }
+ };
+});
+
+app.directive('vxDraggable', ['$document', function($document) {
+ return {
+ link: function(scope, element, attr) {
+ var startX = 0, startY = 0, x = 0, y = 0;
+
+ element.css({
+ position: 'relative',
+ border: '1px solid red',
+ backgroundColor: 'lightgrey',
+ cursor: 'pointer'
+ });
+
+ element.on('mousedown', function(event) {
+ // Prevent default dragging of selected content
+ event.preventDefault();
+ startX = event.pageX - x;
+ startY = event.pageY - y;
+ $document.on('mousemove', mousemove);
+ $document.on('mouseup', mouseup);
+ });
+
+ function mousemove(event) {
+ y = event.pageY - startY;
+ x = event.pageX - startX;
+ element.css({
+ top: y + 'px',
+ left: x + 'px'
+ });
+ }
+
+ function mouseup() {
+ $document.off('mousemove', mousemove);
+ $document.off('mouseup', mouseup);
+ }
+ }
+ };
+}]);
\ No newline at end of file
diff --git a/app/md-dialog-big.html b/app/md-dialog-big.html
new file mode 100644
index 0000000..8ce5e83
--- /dev/null
+++ b/app/md-dialog-big.html
@@ -0,0 +1,13 @@
+
+
+
+ {{title}}
+
+ close
+
+
+
+
+
{{content}}
+
+
\ No newline at end of file
diff --git a/app/on/blog/client-blog-page.html b/app/on/blog/client-blog-page.html
new file mode 100644
index 0000000..3c13e46
--- /dev/null
+++ b/app/on/blog/client-blog-page.html
@@ -0,0 +1 @@
+
Блог
\ No newline at end of file
diff --git a/app/on/client-index.html b/app/on/client-index.html
new file mode 100644
index 0000000..36f894b
--- /dev/null
+++ b/app/on/client-index.html
@@ -0,0 +1,69 @@
+
\ No newline at end of file
diff --git a/app/on/clientMainCtrl.js b/app/on/clientMainCtrl.js
new file mode 100644
index 0000000..5924828
--- /dev/null
+++ b/app/on/clientMainCtrl.js
@@ -0,0 +1,7 @@
+'use strict';
+
+app.controller('clientMainCtrl', function ($scope, $rootScope, $filter, Data, $route, $routeParams, $location, $mdSidenav) {
+
+
+
+});
\ No newline at end of file
diff --git a/app/on/forum/client-forum-page.html b/app/on/forum/client-forum-page.html
new file mode 100644
index 0000000..b1ff785
--- /dev/null
+++ b/app/on/forum/client-forum-page.html
@@ -0,0 +1 @@
+
Форум
\ No newline at end of file
diff --git a/app/on/help/client-help-page.html b/app/on/help/client-help-page.html
new file mode 100644
index 0000000..14cea9f
--- /dev/null
+++ b/app/on/help/client-help-page.html
@@ -0,0 +1 @@
+
Страница помощи
\ No newline at end of file
diff --git a/app/on/products/client-products-page.html b/app/on/products/client-products-page.html
new file mode 100644
index 0000000..5e9ec6c
--- /dev/null
+++ b/app/on/products/client-products-page.html
@@ -0,0 +1 @@
+
Товары
\ No newline at end of file
diff --git a/app/on/start/about/on-start-about.html b/app/on/start/about/on-start-about.html
new file mode 100644
index 0000000..6bcf662
--- /dev/null
+++ b/app/on/start/about/on-start-about.html
@@ -0,0 +1,4 @@
+
О сайте "{{siteSettings.shortName}}"
+
+ {{siteSettings.description}}
+
\ No newline at end of file
diff --git a/app/on/start/activity/on-start-activity.html b/app/on/start/activity/on-start-activity.html
new file mode 100644
index 0000000..22ffe01
--- /dev/null
+++ b/app/on/start/activity/on-start-activity.html
@@ -0,0 +1,10 @@
+
Последние новости {{siteSettings.shortName['value']}}
\ No newline at end of file
diff --git a/app/on/start/on-start.html b/app/on/start/on-start.html
new file mode 100644
index 0000000..d7c35d5
--- /dev/null
+++ b/app/on/start/on-start.html
@@ -0,0 +1 @@
+
Основная информация
\ No newline at end of file
diff --git a/app/on/user/client-user-page.html b/app/on/user/client-user-page.html
new file mode 100644
index 0000000..884bdf0
--- /dev/null
+++ b/app/on/user/client-user-page.html
@@ -0,0 +1,2 @@
+
+