diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..36a4a78 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.idea/ diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..4d5bc8f --- /dev/null +++ b/.htaccess @@ -0,0 +1,10 @@ +# Enable rewrite engine and route requests to framework +RewriteEngine On + +RewriteCond %{REQUEST_URI} \.ini$ +RewriteRule \.ini$ - [R=404] + +RewriteCond %{REQUEST_FILENAME} !-l +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule .* index.php [L,QSA] diff --git a/app/layout/model.php b/app/layout/model.php new file mode 100644 index 0000000..7072b5d --- /dev/null +++ b/app/layout/model.php @@ -0,0 +1,16 @@ +f3 = \Base::instance(); + parent::__construct($this->f3->get('DB'), 'layout.json'); + } + +} \ No newline at end of file diff --git a/app/navigation/model.php b/app/navigation/model.php new file mode 100644 index 0000000..baf58a3 --- /dev/null +++ b/app/navigation/model.php @@ -0,0 +1,41 @@ +f3 = \Base::instance(); + parent::__construct($this->f3->get('DB'),'navigation.json'); + } + + /** + * return a set of pages that belongs to a given menu + * @param $menu + * @return array + */ + public function getPages($menu) { + $this->load(array('@name = ?', $menu)); + if(!$this->dry()) { + $page = new \Page\Model(); + $pages = array(); + foreach ($this->pages as $item) { +// $page->load(array('@_id = ? AND ( isset(@deleted) && @deleted = 0)', $item)); + $page->load(array('@_id = ?', $item)); + if (!$page->dry()) + $pages[] = array('title' => $page->title, 'slug' => $page->slug); + $page->reset(); + } + } else { + trigger_error('menu not found'); + } + $this->reset(); + return $pages; + } +} diff --git a/app/navigation/view.php b/app/navigation/view.php new file mode 100644 index 0000000..8357a9c --- /dev/null +++ b/app/navigation/view.php @@ -0,0 +1,35 @@ +set('menu', $nav->getPages($menu)); + $f3->set('current_page_path',$f3->get('PARAMS.page')); + $content = \Template::instance()->render($f3->get('TMPL').$tmpl); + $f3->clear('menu'); + return $content; + } + + static public function renderTag($args) + { + $attr = $args['@attrib']; + $tmp = \Template::instance(); + foreach ($attr as &$att) + $att = $tmp->token($att); + if (array_key_exists('menu', $attr)) { + $nav_code = '\Navigation\View::render(\''.$attr['menu'].'\');'; + if (array_key_exists('tmpl', $attr)) + $nav_code = "\Navigation\View::render('".$attr['menu']."','".$attr['tmpl']."');"; + return ''; + } + } + + +} diff --git a/app/page/controller.php b/app/page/controller.php new file mode 100644 index 0000000..a9ca7a6 --- /dev/null +++ b/app/page/controller.php @@ -0,0 +1,256 @@ +data = array ( + 'title' => '', + 'template' => '' + ); + $this->include = ''; + $this->displayEdit = false; + } + + /* + * check if we run this from our own dev machine + * this wiki is not intended to be edited on the live server + */ + protected function checkEnviroment($f3,$params) + { + if(strtolower($f3->get('HOST')) == $f3->get('DOMAIN')) { + + if( array_key_exists('marker',$params) && !empty($params['marker'])) { + $edit_link = $f3->get('REPO').'/edit/master/'. + $f3->get('MDCONTENT').$params['page'].'/'.$params['marker'].'.md'; + } else { + $edit_link = $f3->get('REPO').'/'.$f3->get('MDCONTENT').$params['page']; + } + $f3->set('edit_link',$edit_link); + $this->include = $f3->get('TMPL').'fork.html'; + return false; + } + return true; + } + + /** + * display page form + * @param $f3 + * @param $params + */ + public function edit($f3, $params) + { + $page = ''; + if(array_key_exists('page',$params) && !empty($params['page'])) { + $page = $params['page']; + } + + if(!$this->checkEnviroment($f3,$params)) + return; + + $layout = new \Layout\Model(); + $model = new Model(); + + if(!empty($page)) { + $model->loadExistingPage($page); + if(!$model->dry()) { + $this->data = $model->cast(); + + $layout->load(array('@file = ?', $model->template)); + if (!$layout->dry()) { + // set markdown file paths + $marker = array(); + foreach ($layout->marker as $mk) { + $path = $f3->get('MDCONTENT').$page.'/'.$mk.'.md'; + $marker[$mk] = (file_exists($path)) ? $f3->read($path) : ''; + } + $f3->mset(array('layout' => $marker)); + } else { + $f3->error('500', 'Layout not found'); + } + + } + } + $title = (array_key_exists('title',$this->data)) ? $this->data['title'] : ''; + $this->data['title'] = 'Edit Page'.(($title)?': '.$title:''); + + $f3->set('FORM_title', $title); + $f3->set('ACTION','edit/'.$page); + if(!$model->dry()) { + $f3->set('backend_layout',$f3->get('TMPL').'backend/'.$model->template); + $f3->set('REQUEST.template', $model->template); + } + $layout->reset(); + // load template list + $templates = array(); + foreach($layout->find() as $item) + $templates[$item->file] = $item->name; + $f3->set('templates', $templates); + + $this->include = $f3->get('TMPL').'edit.html'; + } + + /** + * save submitted page data + * @param $f3 + * @param $params + * @return bool + */ + public function save($f3, $params) + { + if(!$this->checkEnviroment($f3,$params)) + return; + + $web = \Web::instance(); + $model = new Model(); + $new = true; + if (empty($params['page'])) { + $slug = $web->slug($f3->get('POST.title')); + $model->load(array('@slug = ?', $slug)); + if (!$model->dry()) + $f3->error(500, 'Another page with same title already exists.'); + } else { + $slug = $web->slug($params['page']); + $model->load(array('@slug = ?', $slug)); + if (!$model->dry()) { + $new = false; + if ($model->slug != $web->slug($f3->get('POST.title'))) { + if (!$this->rename()) + return false; + } + } + } + + // find layout marker + $layout = new \Layout\Model(); + $layout->load(array('@file = ?', $f3->get('POST.template'))); + if (!$layout->dry()) { + // write markdown files + if (!is_writable($path = $f3->get('MDCONTENT'))) + trigger_error('data folder is not writable: '.$f3->get('MDCONTENT')); + @mkdir($f3->get('MDCONTENT').$slug.'/'); + $marker = array(); + foreach ($layout->marker as $mk) { + $path = $f3->get('MDCONTENT').$params['page'].'/'.$mk.'.md'; + $val = $f3->get('POST.'.$mk); + if ($f3->exists('POST.'.$mk) && !empty($val)) + $f3->write($path, $val); + } + } else { + $f3->error('500', 'Layout not found'); + } + + // save page config + $model->title = $f3->get('POST.title'); + $model->template = $f3->get('POST.template'); + $model->slug = $slug; + $model->lang = 'en'; // TODO: support multilanguage + $model->save(); + + $this->data['title'] = 'page saved successfully'; + $this->include = $f3->get('TMPL').'saved.html'; + } + + /** + * display page content + * @param $f3 + * @param $params + */ + public function view($f3, $params) + { + $model = new \Page\Model(); + $model->loadExistingPage($params['page']); + + if ($model->dry()) + $f3->error('404', 'The requested Page does not exist.'); + + $this->data = $model->cast(); + // sub-template / page layout + if ( + array_key_exists('template', $this->data) && + !empty($this->data['template']) + ) { + $layout = new \Layout\Model(); + $layout->load(array('@file = ?', $model->template)); + if(!$layout->dry()) { + // set markdown file paths + $marker = array(); + foreach ($layout->marker as $mk) + $marker[$mk] = $f3->get('MDCONTENT').$params['page'].'/'.$mk.'.md'; + $f3->mset(array('layout'=>$marker)); + } else { + $f3->error('500', 'Layout not found'); + } + $this->include = $f3->get('TMPL').'layout/'.$model->template; + } else { + $f3->error('500', 'No page layout template selected'); + } + } + + /** + * rename a page + */ + public function rename() + { + if(!$this->checkEnviroment($f3,$params)) + return; + + // TODO: check if page could be renamed + // check if new name has already been taken + // scan all other pages for links, that should be repaired and do it + + // extra points: make it possible to remain a page + // that redirects with a 301 Error (Moved Permanently) to the new URI + \Base::instance()->error('501','renaming a page is not available.'); + return false; + } + + /** + * delete a page + */ + public function delete($f3,$params) + { + if(!$this->checkEnviroment($f3,$params)) + return; + + $model = new Model(); + $model->loadExistingPage($params['page']); + if(!$model->dry()) { + $model->erase(); + // TODO: delete directory contents + } + $this->content = '
Page has been deleted
'; + $this->data['title'] = 'Deleting page '.$params['page']; + } + + /** + * render view + */ + public function afterroute() + { + $f3 = \Base::instance(); + $data['page'] = $this->data; + + if (!empty($this->include)) + $data['include'] = $this->include; + if (!empty($this->content)) + $data['content'] = $this->content; + + $view = new View(); + echo $view->render($data, $f3->get('TMPL').'layout.html'); + } + +} diff --git a/app/page/model.php b/app/page/model.php new file mode 100644 index 0000000..a7250e0 --- /dev/null +++ b/app/page/model.php @@ -0,0 +1,28 @@ +get('DB'), 'pages.json'); + } + + public function loadExistingPage($slug) { +// $this->load(array('@slug = ? AND (isset(@deleted) && @deleted = ?)', $slug, 0)); + $this->load(array('@slug = ?', $slug)); + } + +} diff --git a/app/page/view.php b/app/page/view.php new file mode 100644 index 0000000..b4d85cc --- /dev/null +++ b/app/page/view.php @@ -0,0 +1,27 @@ +mset($data); + return \Template::instance()->render($file); + } + +} diff --git a/content/api-reference/main.md b/content/api-reference/main.md new file mode 100644 index 0000000..88d9b58 --- /dev/null +++ b/content/api-reference/main.md @@ -0,0 +1,29 @@ +# examples +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. + +## Headline 2 + +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. + +### Headline 3 + +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. + +#### Headline 4 + +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. + +##### Headline 5 + +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. + +###### Headline 6 + +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. + + +``` html +
+

this is a test

+
+``` \ No newline at end of file diff --git a/content/contribute/left.md b/content/contribute/left.md new file mode 100644 index 0000000..7f00408 --- /dev/null +++ b/content/contribute/left.md @@ -0,0 +1,2 @@ +## ober fett +das ist echt cool \ No newline at end of file diff --git a/content/contribute/main.md b/content/contribute/main.md new file mode 100644 index 0000000..dd3e4f6 --- /dev/null +++ b/content/contribute/main.md @@ -0,0 +1,4 @@ +# soo cool2 + +lorem ipsun +q12312 \ No newline at end of file diff --git a/content/examples/main.md b/content/examples/main.md new file mode 100644 index 0000000..88d9b58 --- /dev/null +++ b/content/examples/main.md @@ -0,0 +1,29 @@ +# examples +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. + +## Headline 2 + +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. + +### Headline 3 + +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. + +#### Headline 4 + +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. + +##### Headline 5 + +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. + +###### Headline 6 + +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. + + +``` html +
+

this is a test

+
+``` \ No newline at end of file diff --git a/content/getting-started/main.md b/content/getting-started/main.md new file mode 100644 index 0000000..6409f04 --- /dev/null +++ b/content/getting-started/main.md @@ -0,0 +1,117 @@ +
+

Getting Started

+

+ A designer knows he has achieved perfection not when there is nothing + left to add, but when there is nothing left to take away. - Antoine de + Saint-Exupéry +

+
+ +Fat-Free Framework makes it easy to build entire Web sites in a jiffy. +With the same power and brevity as modern Javascript toolkits and libraries, +F3 helps you write better-looking and more reliable PHP programs. One glance +at your PHP source code and anyone will find it easy to understand, how +much you can accomplish in so few lines of code, and how powerful the results +are. + +F3 is one of the best documented frameworks around. Learning it costs +next to nothing. No strict set of difficult-to-navigate directory structures +and obtrusive programming steps. No truck load of configuration options +just to display `Hello, World` in your browser. Fat-Free gives you a lot of freedom +- and style - to get more work done with ease and in less time. + +F3's declarative approach to programming makes it easy for novices and +experts alike to understand PHP code. If you're familiar with the programming +language Ruby, you'll notice the resemblance between Fat-Free and Sinatra +micro-framework because they both employ a simple Domain-Specific Language +for ReSTful Web services. But unlike Sinatra and its PHP incarnations (Fitzgerald, +Limonade, Glue - to name a few), Fat-Free goes beyond just handling routes +and requests. Views can be in any form, such as plain text, HTML, XML or +an e-mail message. The framework comes with a fast and easy-to-use template +engine. F3 also works seamlessly with other template engines, including +Twig, Smarty, and PHP itself. Models communicate with F3's data mappers +and the SQL helper for more complex interactions with various database +engines. Other plug-ins extend the base functionality even more. It's a +total Web development framework - with a lot of muscle! + +## Enough Said - See For Yourself + +Unzip the contents of the distribution package anywhere in your hard drive. +By default, the framework file and optional plug-ins are located in the +`lib/` path. Organize your directory structures any way you want. +You may move the default folders to a path that's not Web-accessible for +better security. Delete the plug-ins that you don't need. You can always +restore them later and F3 will detect their presence automatically. + +**Important:** If your application uses APC, Memcached, WinCache, XCache, or a filesystem cache, + clear all cache entries first before overwriting an older version of the framework with a new one. + +Make sure you're running the right version of PHP. F3 does not support versions earlier than PHP +5.3. You'll be getting syntax errors (false positives) all over the place because new language +constructs and closures/anonymous functions are not supported by outdated PHP versions. To find +out, open your console (`bash` shell on Linux, or `cmd.exe` on Windows):- + +``` +/path/to/php -v +``` + +PHP will let you know which particular version you're running and you should get something that +looks similar to this:- + +``` +PHP 5.3.15 (cli) (built: Jul 20 2012 00:20:38) +Copyright (c) 1997-2012 The PHP Group +Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies +``` + +Upgrade if necessary and come back here if you've made the jump to PHP 5.3 or a later release. +If you need a PHP 5.3+ hosting service provider, try one of these services: + +* [A2 Hosting](http://www.a2hosting.com/2461-15-1-72.html) +* [DreamHost](http://www.dreamhost.com/r.cgi?665472) +* [Hostek](http://hostek.com/aff.php?aff=364&plat=L) +* [SiteGround](http://www.siteground.com/index.htm?referrerid=155694) + +## Hello, World: The Less-Than-A-Minute Fat-Free Recipe + +Time to start writing our first application:- + +``` php +$f3=require('path/to/base.php'); +$f3->route('GET /', + function() { + echo 'Hello, world!'; + } +); +$f3->run(); +``` + +Prepend `base.php` on the first line with the appropriate path. Save the above code fragment as +`index.php` in your Web root folder. We've written our first Web page. + +The first command tells the PHP interpreter that you want the framework's functions and features +available to your application. The `$f3->route()` method informs Fat-Free that a Web page is +available at the relative URL indicated by the slash (`/`). Anyone visiting your site located +at `http://www.example.com/` will see the `'Hello, world!'` message because the URL `/` is +equivalent to the root page. To create a route that branches out from the root page, +like `http://www.example.com/inside/`, you can define another route with a simple `GET /inside` +string. + +The route described above tells the framework to render the page only when it receives a URL +request using the HTTP `GET` method. More complex Web sites containing forms use other HTTP +methods like `POST`, and you can also implement that as part of a `$f3->route()` specification. + +If the framework sees an incoming request for your Web page located at the root URL `/`, +it will automatically route the request to the callback function, +which contains the code necessary to process the request and render the appropriate HTML stuff. +In this example, we just send the string `'Hello, world!'` to the user's Web browser. + +So we've established our first route. But that won't do much, except to let F3 know that there's +a process that will handle it and there's some text to display on the user's Web browser. If +you have a lot more pages on your site, you need to set up different routes for each group. +For now, let's keep it simple. To instruct the framework to start waiting for requests, +we issue the `$f3->run()` command. + +**Can't Get the Example Running?** If you're having trouble getting this simple program to run +on your server, you may have to tweak your Web server settings a bit. Take a look at the sample +Apache configuration in the following section (along with the Nginx and Lighttpd equivalents). diff --git a/content/home/download.md b/content/home/download.md new file mode 100644 index 0000000..373d7ee --- /dev/null +++ b/content/home/download.md @@ -0,0 +1,23 @@ +#### Start Now + +There's no better time to start developing Web applications the easy way than right now! + + + + Download the latest release + + +or grab the [nightly build](https://github.com/bcosca/fatfree/archive/dev.zip). See the version +[changelog](https://github.com/bcosca/fatfree/blob/master/lib/changelog.txt) and +[system requirements](system-requirements/) for additional information. + + +#### Contribute + +Join us on [GitHub](https://github.com/bcosca/fatfree) to make F3 even better. + + +#### Communicate + +Do you need some help for getting started? Or just want to share some thoughts? Meet other users +at the [F3 Google Groups](https://groups.google.com/forum/#!forum/f3-framework). \ No newline at end of file diff --git a/content/home/header.md b/content/home/header.md new file mode 100644 index 0000000..40fc215 --- /dev/null +++ b/content/home/header.md @@ -0,0 +1,6 @@ +# Fat-Free Framework +## A powerfull yet easy-to-use PHP micro-framework designed to help you build dynamic and robust web applications - fast! + +* full-featured toolkit +* super lightweight code base with just ~55kb +* easy to learn, use and extend \ No newline at end of file diff --git a/content/home/main.md b/content/home/main.md new file mode 100644 index 0000000..f5638db --- /dev/null +++ b/content/home/main.md @@ -0,0 +1,26 @@ +F3 supports both SQL and NoSQL databases off-the-shelf: MySQL, SQLite, MSSQL/Sybase, PostgreSQL and MongoDB. It also comes with powerful object-relational mappers for data abstraction and modeling that are just as lightweight as the framework. No configuration needed. +![supported DBS](gui/img/supported_dbs.jpg) + +That's not all. F3 is packaged with other optional plug-ins that extend its capabilities: + +* Fast and clean template engine +* Unit testing toolkit +* Database-managed sessions +* Markdown-to-HTML converter +* Atom/RSS feed reader +* Image processor +* Geodata handler +* On-the-fly Javascript/CSS compressor +* OpenID (consumer) +* Custom logger +* Basket/Shopping cart +* Pingback server/consumer +* Unicode-aware string functions +* SMTP over SSL/TLS +* Tools for communicating with other servers + +--- + +Unlike other frameworks, F3 aims to be usable - not usual. + +The philosophy behind the framework and its approach to software architecture is towards minimalism in structural components, avoiding application complexity and striking a balance between code elegance, application performance and programmer productivity. \ No newline at end of file diff --git a/content/home/teaser_1_1.md b/content/home/teaser_1_1.md new file mode 100644 index 0000000..ba24c13 --- /dev/null +++ b/content/home/teaser_1_1.md @@ -0,0 +1,5 @@ +### Create Powerful Apps + +![gears](gui/img/gears.png) + +Take advantage of the build-in features, to build Apps that really rocks. F3 gives you solid foundation, a mature code base, and a no-nonsense approach to writing Web applications. \ No newline at end of file diff --git a/content/home/teaser_1_2.md b/content/home/teaser_1_2.md new file mode 100644 index 0000000..d2303f9 --- /dev/null +++ b/content/home/teaser_1_2.md @@ -0,0 +1,5 @@ +### Blazing Fast Kickstart + +![lightning](gui/img/lightning.png) + +Whether you're a novice or an expert PHP programmer, F3 will get you up and running in no time. No unnecessary and painstaking installation procedures. No complex configuration required. No convoluted directory structures. \ No newline at end of file diff --git a/content/home/teaser_2_1.md b/content/home/teaser_2_1.md new file mode 100644 index 0000000..da4b9e3 --- /dev/null +++ b/content/home/teaser_2_1.md @@ -0,0 +1,5 @@ +### Write Less code + +![code](gui/img/code.png) + +F3 gives you a useful toolkit, that’ll speed up your development process. It's lightweight, easy-to-use, and fast. Most of all, it doesn't get in your way. Unlike other frameworks, F3 aims to be usable, not usual. \ No newline at end of file diff --git a/content/home/teaser_2_2.md b/content/home/teaser_2_2.md new file mode 100644 index 0000000..9d8f0cc --- /dev/null +++ b/content/home/teaser_2_2.md @@ -0,0 +1,5 @@ +### Rocket Science Included + +![rocket](gui/img/rocket.png) + +Under the hood is an easy-to-use Web development tool kit, a high-performance URL routing and multi-protocol cache engine, built-in code highlighting, and support for multilingual applications. \ No newline at end of file diff --git a/content/routing-engine/main.md b/content/routing-engine/main.md new file mode 100644 index 0000000..221b355 --- /dev/null +++ b/content/routing-engine/main.md @@ -0,0 +1,435 @@ +# Routing Engine + +## Overview + +Our first example wasn't too hard to swallow, was it? If you like a little more flavor in your +Fat-Free soup, insert another route before the `$f3->run()` command: + +``` php +$f3->route('GET /about', + function() { + echo 'Donations go to a local charity... us!'; + } +); +``` + +You don't want to clutter the global namespace with function names? Fat-Free recognizes +different ways of mapping route handlers to OOP classes and methods: + +``` php +class WebPage { + function display() { + echo 'I cannot object to an object'; + } +} + +$f3->route('GET /about','WebPage->display'); +``` + +HTTP requests can also be routed to static class methods: + +``` php +$f3->route('GET /login','Auth::login'); +``` + +## Routes and Tokens + +As a demonstration of Fat-Free's powerful domain-specific language (DSL), +you can specify a single route to handle different possibilities: + +``` php +$f3->route('GET /brew/@count', + function($f3) { + echo $f3->get('PARAMS.count').' bottles of beer on the wall.'; + } +); +``` + +This example shows how we can specify a token `@count` to represent part of a URL. The framework +will serve any request URL that matches the `/brew/` prefix, like `/brew/99`, `/brew/98`, +etc. This will display `'99 bottles of beer on the wall'` and +`'98 bottles of beer on the wall'`, respectively. Fat-Free will also accept a page request for +`/brew/unbreakable`. (Expect this to display `'unbreakable bottles of beer on the wall'`.) When +such a dynamic route is specified, Fat-Free automagically populates the global `PARAMS` array +variable with the value of the captured strings in the URL. The `$f3->get()` call inside the +callback function retrieves the value of a framework variable. You can certainly apply this +method in your code as part of the presentation or business logic. But we'll discuss that in +greater detail later. + +Notice that Fat-Free understands array dot-notation. You can certainly use `@PARAMS['count']` +regular notation, which is prone to typo errors and unbalanced braces. The framework also +permits `@PARAMS.count` which is somehow similar to Javascript. This feature is limited to +arrays in F3 templates. Take note that `@foo.@bar` is a string concatenation, +whereas `@foo.bar` translates to `@foo['bar']`. + +Here's another way to access tokens in a request pattern: + +``` php +$f3->route('GET /brew/@count', + function($f3,$params) { + echo $params['count'].' bottles of beer on the wall.'; + } +); +``` + +You can use the asterisk (`*`) to accept any URL after the `/brew` route - if you don't really +care about the rest of the path: + +``` php +$f3->route('GET /brew/*', + function() { + echo 'Enough beer! We always end up here.'; + } +); +``` + +An important point to consider: You will get Fat-Free (and yourself) confused if you have both +`GET /brew/@count` and `GET /brew/*` together in the same application. Use one or the other. +Another thing: Fat-Free sees `GET /brew` as separate and distinct from the route +`GET /brew/@count`. Each can have different route handlers. + +## Dynamic Web Sites + +Wait a second - in all the previous examples, we never really created any directory in our hard +drive to store these routes. The short answer: we don't have to. All F3 routes are virtual. They +don't mirror our hard disk folder structure. If you have programs or static files (images, CSS, +etc.) that do not use the framework - as long as the paths to these files do not conflict with +any route defined in your application - your Web server software will deliver them to the +user's browser, provided the server is configured properly. + +### PHP 5.4's Built-In Web Server + +PHP's latest stable version has its own built-in Web server. Start it up using the following +configuration: + +``` +php -S localhost:80 -t /var/www/ +``` + +The above command will start routing all requests to the Web root `/var/www`. If an incoming +HTTP request for a file or folder is received, PHP will look for it inside the Web root and send +it over to the browser if found. Otherwise, PHP will load the default `index.php` (containing +your F3-enabled code). + +### Sample Apache Configuration + +If you're using Apache, make sure you activate the URL rewriting module (mod_rewrite) in your +apache.conf (or httpd.conf) file. You should also create a .htaccess file containing the following: + +``` apache +RewriteEngine On +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{REQUEST_FILENAME} !-l +RewriteRule .* index.php [L,QSA] +``` + +The script tells Apache that whenever an HTTP request arrives and if no physical file (`!-f`) or +path (`!-d`) or symbolic link (`!-l`) can be found, it should transfer control to `index.php`, +which contains our main/front controller, and which in turn, invokes the framework. + +The `.htaccess file` containing the Apache directives stated above should always be in the same +folder as `index.php`. + +You also need to set up Apache so it knows the physical location of `index.php` in your hard +drive. A typical configuration is: + +``` apache +DocumentRoot "/var/www/html" + + Options -Indexes FollowSymLinks Includes + AllowOverride All + Order allow,deny + Allow from All + +``` + +If you're developing several applications simultaneously, a virtual host configuration is easier +to manage: + +``` apache +NameVirtualHost * + + ServerName site1.com + DocumentRoot "/var/www/site1" + + Options -Indexes FollowSymLinks Includes + AllowOverride All + Order allow,deny + Allow from All + + + + ServerName site2.com + DocumentRoot "/var/www/site2" + + Options -Indexes FollowSymLinks Includes + AllowOverride All + Order allow,deny + Allow from All + + +``` + +Each `ServerName` (`site1.com` and `site2.com` in our example) must be listed in your +`/etc/hosts` file. On Windows, you should edit `C:/WINDOWS/system32/drivers/etc/hosts`. A reboot +might be necessary to effect the changes. You can then point your Web browser to the address +`http://site1.com` or `http://site2.com`. Virtual hosts make your applications a lot easier to +deploy. + +### Sample Nginx Configuration + +For Nginx servers, here's the recommended configuration (replace ip_address:port with your +environment's FastCGI PHP settings): + +``` nginx +server { + root /var/www/html; + location / { + index index.php index.html index.htm; + try_files $uri /index.php; + } + location ~ \.php$ { + fastcgi_pass ip_address:port; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; + include fastcgi_params; + } +} +``` + +### Sample Lighttpd Configuration + +Lighttpd servers are configured in a similar manner: + +``` +$HTTP["host"] =~ "www\.example\.com$" { + url.rewrite-once = ( "^/(.*?)(\?.+)?$"=>"/index.php/$1?$2" ) + server.error-handler-404 = "/index.php" +} +``` + +## Rerouting + +So let's get back to coding. You can declare a page obsolete and redirect your visitors to +another site: + +``` php +$f3->route('GET|HEAD /obsoletepage', + function($f3) { + $f3->reroute('/newpage'); + } +); +``` + +If someone tries to access the URL `http://www.example.com/obsoletepage` using either HTTP GET +or HEAD request, the framework redirects the user to the URL: `http://www.example.com/newpage` +as shown in the above example. You can also redirect the user to another site, +like `$f3->reroute('http://www.anotherexample.org/');`. + +Rerouting can be particularly useful when you need to do some maintenance work on your site. You +can have a route handler that informs your visitors that your site is offline for a short period. + +HTTP redirects are indispensable but they can also be expensive. As much as possible, +refrain from using `$f3->reroute()` to send a user to another page on the same Web site if you +can direct the flow of your application by invoking the function or method that handles the +target route. However, this approach will not change the URL on the address bar of the user's +Web browser. If this is not the behavior you want and you really need to send a user to another +page, in instances like successful submission of a form or after a user has been authenticated, +Fat-Free sends an `HTTP 303 See Other` header. For all other attempts to reroute to another +page or site, the framework sends an `HTTP 301 Moved Permanently` header. + +## Triggering a 404 + +At runtime, Fat-Free automatically generates an HTTP 404 error whenever it sees that an incoming +HTTP request does not match any of the routes defined in your application. However, +there are instances when you need to trigger it yourself. + +Take for instance a route defined as `GET /dogs/@breed`. Your application logic may involve +searching a database and attempting to retrieve the record corresponding to the value of +`@breed` in the incoming HTTP request. Since Fat-Free will accept any value after the `/dogs/` +prefix because of the presence of the `@breed` token, displaying an `HTTP 404 Not Found` +message programmatically becomes necessary when the program doesn't find any match in our +database. To do that, use the following command: + +``` php +$f3->error(404); +``` + +## Representational State Transfer (ReST) + +Fat-Free's architecture is based on the concept that HTTP URIs represent abstract Web resources +(not limited to HTML) and each resource can move from one application state to another. For this +reason, F3 does not have any restrictions on the way you structure your application. If you +prefer to use the [Model-View-Controller](http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller) +pattern, F3 can help you compartmentalize your application components to stick to this paradigm. +On the other hand, the framework also supports the +[Resource-Method-Representation](http://www.peej.co.uk/articles/rmr-architecture.html) pattern, +and implementing it is more straightforward. + +Here's an example of a ReST interface: + +``` php +class Item { + function get() {} + function post() {} + function put() {} + function delete() {} +} + +$f3=require('lib/base.php'); +$f3->map('/cart/@item','Item'); +$f3->run(); +``` + +Fat-Free's `$f3->map()` method provides a ReST interface by mapping HTTP methods in routes to +the equivalent methods of an object or a PHP class. If your application receives an incoming +HTTP request like `GET /cart/123`, Fat-Free will automatically transfer control to the object's +or class' `get()` method. On the other hand, a `POST /cart/123` request will be routed to the +`Item` class' `post()` method. + +**Note:** Browsers do not implement the HTTP `PUT` and `DELETE` methods in regular HTML forms. +These and other ReST methods (`HEAD`, and `CONNECT`) are accessible only via AJAX calls to the +server. + +If the framework receives an HTTP method that's not implemented by a class, +it generates an `HTTP 405 Method Not Allowed` error. F3 automatically responds with the +appropriate headers to HTTP `OPTIONS` method requests. The framework will not map this request +to a class. + +## The F3 Autoloader + +Fat-Free has a way of loading classes only at the time you need them, +so they don't gobble up more memory than a particular segment of your application needs. And +you don't have to write a long list of `include` or `require` statements just to load PHP +classes saved in different files and different locations. The framework can do this +automatically for you. Just save your files (one class per file) in a folder and tell the +framework to automatically load the appropriate file once you invoke a method in the class: + +``` php +$f3->set('AUTOLOAD','autoload/'); +``` + +You can assign a different location for your autoloaded classes by changing the value of the +`AUTOLOAD` global variable. You can also have multiple autoload paths. If you have your classes +organized and in different folders, you can instruct the framework to autoload the appropriate +class when a static method is called or when an object is instantiated. Modify the `AUTOLOAD` +variable this way: + +``` php +$f3->set('AUTOLOAD','admin/autoload/; user/autoload/; default/'); +``` + +**Important:** Except for the .php extension, the class name and file name must be identical, +for the framework to autoload your class properly. The basename of this file must be identical +to your class invocation, e.g. F3 will look for either `Foo/BarBaz.php` or `foo/barbaz.php` when +it detects a `new Foo\BarBaz` statement in your application. + +## Working with Namespaces + +`AUTOLOAD` allows class hierarchies to reside in similarly-named subfolders, +so if you want the framework to autoload a PHP 5.3 namespaced class that's invoked in the +following manner: + +``` php +$f3->set('AUTOLOAD','autoload/'); +$obj=new Gadgets\iPad; +``` + +You can create a folder hierarchy that follows the same structure. Assuming `/var/www/html/` is +your Web root, then F3 will look for the class in `/var/www/html/autoload/gadgets/ipad.php`. The +file `ipad.php` should have the following minimum code: + +``` php +namespace Gadgets; +class iPad {} +``` + +Remember: All directory names in Fat-Free must end with a slash. You can assign a search path +for the autoloader as follows: + +``` php +$f3->set('AUTOLOAD','main/;aux/'); +``` + +## Routing to a Namespaced Class + +F3, being a namespace-aware framework, allows you to use a method in namespaced class as a route + handler, and there are several ways of doing it. To call a static method: + +``` php +$f3->set('AUTOLOAD','classes/'); +$f3->route('GET|POST /','Main\Home::show'); +``` + +The above code will invoke the static `show()` method of the class `Home` within the `Main` +namespace. The `Home` class must be saved in the folder `classes/main/home.php` for it to be +loaded automatically. + +If you prefer to work with objects: + +``` php +$f3->route('GET|POST /','Main\Home->show'); +``` + +will instantiate the `Home` class at runtime and call the `show()` method thereafter. + +## Event Handlers + +F3 has a couple of routing event listeners that might help you improve the flow and structure of +controller classes. Say you have a route defined as follows: + +``` php +$f3->route('GET /','Main->home'); +``` + +If the application receives an HTTP request matching the above route, F3 instantiates `Main`, +but before executing the `home()` method, the framework looks for a method in this class named +`beforeRoute()`. In case it's found, F3 runs the code contained in the `beforeRoute()` event +handler before transferring control to the `home()` method. Once this is accomplished, +the framework looks for an `afterRoute()` event handler. Like `beforeRoute()`, +the method gets executed if it's defined. + +## Dynamic Route Handlers + +Here's another F3 goodie: + +``` php +$f3->route('GET /products/@action','Products->@action'); +``` + +If your application receives a request for, say, `/products/itemize`, +F3 will extract the `'itemize'` string from the URL and pass it on to the `@action` token in the +route handler. F3 will then look for a class named `Products` and execute the `itemize()` method. + +Dynamic route handlers may have various forms: + +``` php +// static method +$f3->route('GET /public/@genre','Main::@genre'); +// object mode +$f3->route('GET /public/@controller/@action','@controller->@action'); +``` + +F3 triggers an `HTTP 404 Not Found` error at runtime if it cannot transfer control to the class +or method associated with the current route, i.e. an undefined class or method. + +## AJAX and Synchronous Requests + +Routing patterns may contain modifiers that direct the framework to base its routing decision on +the type of HTTP request: + +``` php +$f3->route('GET /example [ajax]','Page->getFragment'); +$f3->route('GET /example [sync]','Page->getFull'); +``` + +The first statement will route the HTTP request to the `Page->getFragment()` callback only if an +`X-Requested-With: XMLHttpRequest` header (AJAX object) is received by the server. If an +ordinary (synchronous) request is detected, F3 will simply drop down to the next matching +pattern, and in this case it executes the `Page->getFull()` callback. + +If no modifiers are defined in a routing pattern, then both AJAX and synchronous request types +are routed to the specified handler. + +Route pattern modifiers are also recognized by `$f3->map()`. \ No newline at end of file diff --git a/content/system-requirements/main.md b/content/system-requirements/main.md new file mode 100644 index 0000000..0c40c8b --- /dev/null +++ b/content/system-requirements/main.md @@ -0,0 +1,3 @@ +# System Requirements + +lorem ipsun \ No newline at end of file diff --git a/content/user-guide/main.md b/content/user-guide/main.md new file mode 100644 index 0000000..9fa75d5 --- /dev/null +++ b/content/user-guide/main.md @@ -0,0 +1,6 @@ +# User Guide + +To give you an optimal kickstart with F3, please read the guide carefully. + +* [Getting Started](getting-started) +* [Routing Engine](routing-engine) diff --git a/db/layout.json b/db/layout.json new file mode 100644 index 0000000..5f00dfa --- /dev/null +++ b/db/layout.json @@ -0,0 +1,37 @@ +{ + "514ba5277fab7": { + "name": "Full Page", + "file": "fullpage.html", + "marker": [ + "main" + ] + }, + "514ba5278011d": { + "name": "Home", + "file": "home.html", + "marker": [ + "header", + "teaser_1_1", + "teaser_1_2", + "teaser_2_1", + "teaser_2_2", + "download", + "main" + ] + }, + "514ba52780690": { + "name": "Table of Content Sidemenu", + "file": "toc-sidemenu.html", + "marker": [ + "main" + ] + }, + "514ba52780bae": { + "name": "Left-Main", + "file": "left-main.html", + "marker": [ + "main", + "left" + ] + } +} \ No newline at end of file diff --git a/db/navigation.json b/db/navigation.json new file mode 100644 index 0000000..ea7ad7b --- /dev/null +++ b/db/navigation.json @@ -0,0 +1,11 @@ +{ + "512e93361d5d7": { + "name": "main", + "pages": [ + "512e893d09ff9", + "512e893d0a922", + "512e893d0a427", + "512e893d0adbd" + ] + } +} \ No newline at end of file diff --git a/db/pages.json b/db/pages.json new file mode 100644 index 0000000..21c0e1c --- /dev/null +++ b/db/pages.json @@ -0,0 +1,46 @@ +{ + "512e893d09ff9": { + "title": "Home", + "slug": "home", + "lang": "en", + "template": "home.html" + }, + "512e893d0a427": { + "title": "API Reference", + "slug": "api-reference", + "lang": "en", + "template": "toc-sidemenu.html" + }, + "512e893d0a922": { + "title": "User Guide", + "slug": "user-guide", + "lang": "en", + "template": "left-main.html" + }, + "512e893d0adbd": { + "title": "Contribute", + "slug": "contribute", + "lang": "en", + "template": "left-main.html", + "_id": "512e893d0adbd" + }, + "512feae5673be": { + "title": "Routing Engine", + "slug": "routing-engine", + "lang": "en", + "template": "toc-sidemenu.html" + }, + "514a54128acde": { + "title": "Getting Started", + "slug": "getting-started", + "lang": "en", + "template": "toc-sidemenu.html" + }, + "514bc021eca80": { + "title": "System Requirements", + "template": "left-main.html", + "slug": "system-requirements", + "lang": "en", + "_id": "514bc021eca80" + } +} \ No newline at end of file diff --git a/gui/css/bootstrap-responsive.min.css b/gui/css/bootstrap-responsive.min.css new file mode 100644 index 0000000..d1b7f4b --- /dev/null +++ b/gui/css/bootstrap-responsive.min.css @@ -0,0 +1,9 @@ +/*! + * Bootstrap Responsive v2.3.1 + * + * Copyright 2012 Twitter, Inc + * Licensed under the Apache License v2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Designed and built with all the love in the world @twitter by @mdo and @fat. + */.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}@-ms-viewport{width:device-width}.hidden{display:none;visibility:hidden}.visible-phone{display:none!important}.visible-tablet{display:none!important}.hidden-desktop{display:none!important}.visible-desktop{display:inherit!important}@media(min-width:768px) and (max-width:979px){.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}.visible-tablet{display:inherit!important}.hidden-tablet{display:none!important}}@media(max-width:767px){.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}.visible-phone{display:inherit!important}.hidden-phone{display:none!important}}.visible-print{display:none!important}@media print{.visible-print{display:inherit!important}.hidden-print{display:none!important}}@media(min-width:1200px){.row{margin-left:-30px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:30px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:1170px}.span12{width:1170px}.span11{width:1070px}.span10{width:970px}.span9{width:870px}.span8{width:770px}.span7{width:670px}.span6{width:570px}.span5{width:470px}.span4{width:370px}.span3{width:270px}.span2{width:170px}.span1{width:70px}.offset12{margin-left:1230px}.offset11{margin-left:1130px}.offset10{margin-left:1030px}.offset9{margin-left:930px}.offset8{margin-left:830px}.offset7{margin-left:730px}.offset6{margin-left:630px}.offset5{margin-left:530px}.offset4{margin-left:430px}.offset3{margin-left:330px}.offset2{margin-left:230px}.offset1{margin-left:130px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.564102564102564%;*margin-left:2.5109110747408616%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .controls-row [class*="span"]+[class*="span"]{margin-left:2.564102564102564%}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.45299145299145%;*width:91.39979996362975%}.row-fluid .span10{width:82.90598290598291%;*width:82.8527914166212%}.row-fluid .span9{width:74.35897435897436%;*width:74.30578286961266%}.row-fluid .span8{width:65.81196581196582%;*width:65.75877432260411%}.row-fluid .span7{width:57.26495726495726%;*width:57.21176577559556%}.row-fluid .span6{width:48.717948717948715%;*width:48.664757228587014%}.row-fluid .span5{width:40.17094017094017%;*width:40.11774868157847%}.row-fluid .span4{width:31.623931623931625%;*width:31.570740134569924%}.row-fluid .span3{width:23.076923076923077%;*width:23.023731587561375%}.row-fluid .span2{width:14.52991452991453%;*width:14.476723040552828%}.row-fluid .span1{width:5.982905982905983%;*width:5.929714493544281%}.row-fluid .offset12{margin-left:105.12820512820512%;*margin-left:105.02182214948171%}.row-fluid .offset12:first-child{margin-left:102.56410256410257%;*margin-left:102.45771958537915%}.row-fluid .offset11{margin-left:96.58119658119658%;*margin-left:96.47481360247316%}.row-fluid .offset11:first-child{margin-left:94.01709401709402%;*margin-left:93.91071103837061%}.row-fluid .offset10{margin-left:88.03418803418803%;*margin-left:87.92780505546462%}.row-fluid .offset10:first-child{margin-left:85.47008547008548%;*margin-left:85.36370249136206%}.row-fluid .offset9{margin-left:79.48717948717949%;*margin-left:79.38079650845607%}.row-fluid .offset9:first-child{margin-left:76.92307692307693%;*margin-left:76.81669394435352%}.row-fluid .offset8{margin-left:70.94017094017094%;*margin-left:70.83378796144753%}.row-fluid .offset8:first-child{margin-left:68.37606837606839%;*margin-left:68.26968539734497%}.row-fluid .offset7{margin-left:62.393162393162385%;*margin-left:62.28677941443899%}.row-fluid .offset7:first-child{margin-left:59.82905982905982%;*margin-left:59.72267685033642%}.row-fluid .offset6{margin-left:53.84615384615384%;*margin-left:53.739770867430444%}.row-fluid .offset6:first-child{margin-left:51.28205128205128%;*margin-left:51.175668303327875%}.row-fluid .offset5{margin-left:45.299145299145295%;*margin-left:45.1927623204219%}.row-fluid .offset5:first-child{margin-left:42.73504273504273%;*margin-left:42.62865975631933%}.row-fluid .offset4{margin-left:36.75213675213675%;*margin-left:36.645753773413354%}.row-fluid .offset4:first-child{margin-left:34.18803418803419%;*margin-left:34.081651209310785%}.row-fluid .offset3{margin-left:28.205128205128204%;*margin-left:28.0987452264048%}.row-fluid .offset3:first-child{margin-left:25.641025641025642%;*margin-left:25.53464266230224%}.row-fluid .offset2{margin-left:19.65811965811966%;*margin-left:19.551736679396257%}.row-fluid .offset2:first-child{margin-left:17.094017094017094%;*margin-left:16.98763411529369%}.row-fluid .offset1{margin-left:11.11111111111111%;*margin-left:11.004728132387708%}.row-fluid .offset1:first-child{margin-left:8.547008547008547%;*margin-left:8.440625568285142%}input,textarea,.uneditable-input{margin-left:0}.controls-row [class*="span"]+[class*="span"]{margin-left:30px}input.span12,textarea.span12,.uneditable-input.span12{width:1156px}input.span11,textarea.span11,.uneditable-input.span11{width:1056px}input.span10,textarea.span10,.uneditable-input.span10{width:956px}input.span9,textarea.span9,.uneditable-input.span9{width:856px}input.span8,textarea.span8,.uneditable-input.span8{width:756px}input.span7,textarea.span7,.uneditable-input.span7{width:656px}input.span6,textarea.span6,.uneditable-input.span6{width:556px}input.span5,textarea.span5,.uneditable-input.span5{width:456px}input.span4,textarea.span4,.uneditable-input.span4{width:356px}input.span3,textarea.span3,.uneditable-input.span3{width:256px}input.span2,textarea.span2,.uneditable-input.span2{width:156px}input.span1,textarea.span1,.uneditable-input.span1{width:56px}.thumbnails{margin-left:-30px}.thumbnails>li{margin-left:30px}.row-fluid .thumbnails{margin-left:0}}@media(min-width:768px) and (max-width:979px){.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:20px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:724px}.span12{width:724px}.span11{width:662px}.span10{width:600px}.span9{width:538px}.span8{width:476px}.span7{width:414px}.span6{width:352px}.span5{width:290px}.span4{width:228px}.span3{width:166px}.span2{width:104px}.span1{width:42px}.offset12{margin-left:764px}.offset11{margin-left:702px}.offset10{margin-left:640px}.offset9{margin-left:578px}.offset8{margin-left:516px}.offset7{margin-left:454px}.offset6{margin-left:392px}.offset5{margin-left:330px}.offset4{margin-left:268px}.offset3{margin-left:206px}.offset2{margin-left:144px}.offset1{margin-left:82px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.7624309392265194%;*margin-left:2.709239449864817%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .controls-row [class*="span"]+[class*="span"]{margin-left:2.7624309392265194%}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.43646408839778%;*width:91.38327259903608%}.row-fluid .span10{width:82.87292817679558%;*width:82.81973668743387%}.row-fluid .span9{width:74.30939226519337%;*width:74.25620077583166%}.row-fluid .span8{width:65.74585635359117%;*width:65.69266486422946%}.row-fluid .span7{width:57.18232044198895%;*width:57.12912895262725%}.row-fluid .span6{width:48.61878453038674%;*width:48.56559304102504%}.row-fluid .span5{width:40.05524861878453%;*width:40.00205712942283%}.row-fluid .span4{width:31.491712707182323%;*width:31.43852121782062%}.row-fluid .span3{width:22.92817679558011%;*width:22.87498530621841%}.row-fluid .span2{width:14.3646408839779%;*width:14.311449394616199%}.row-fluid .span1{width:5.801104972375691%;*width:5.747913483013988%}.row-fluid .offset12{margin-left:105.52486187845304%;*margin-left:105.41847889972962%}.row-fluid .offset12:first-child{margin-left:102.76243093922652%;*margin-left:102.6560479605031%}.row-fluid .offset11{margin-left:96.96132596685082%;*margin-left:96.8549429881274%}.row-fluid .offset11:first-child{margin-left:94.1988950276243%;*margin-left:94.09251204890089%}.row-fluid .offset10{margin-left:88.39779005524862%;*margin-left:88.2914070765252%}.row-fluid .offset10:first-child{margin-left:85.6353591160221%;*margin-left:85.52897613729868%}.row-fluid .offset9{margin-left:79.8342541436464%;*margin-left:79.72787116492299%}.row-fluid .offset9:first-child{margin-left:77.07182320441989%;*margin-left:76.96544022569647%}.row-fluid .offset8{margin-left:71.2707182320442%;*margin-left:71.16433525332079%}.row-fluid .offset8:first-child{margin-left:68.50828729281768%;*margin-left:68.40190431409427%}.row-fluid .offset7{margin-left:62.70718232044199%;*margin-left:62.600799341718584%}.row-fluid .offset7:first-child{margin-left:59.94475138121547%;*margin-left:59.838368402492065%}.row-fluid .offset6{margin-left:54.14364640883978%;*margin-left:54.037263430116376%}.row-fluid .offset6:first-child{margin-left:51.38121546961326%;*margin-left:51.27483249088986%}.row-fluid .offset5{margin-left:45.58011049723757%;*margin-left:45.47372751851417%}.row-fluid .offset5:first-child{margin-left:42.81767955801105%;*margin-left:42.71129657928765%}.row-fluid .offset4{margin-left:37.01657458563536%;*margin-left:36.91019160691196%}.row-fluid .offset4:first-child{margin-left:34.25414364640884%;*margin-left:34.14776066768544%}.row-fluid .offset3{margin-left:28.45303867403315%;*margin-left:28.346655695309746%}.row-fluid .offset3:first-child{margin-left:25.69060773480663%;*margin-left:25.584224756083227%}.row-fluid .offset2{margin-left:19.88950276243094%;*margin-left:19.783119783707537%}.row-fluid .offset2:first-child{margin-left:17.12707182320442%;*margin-left:17.02068884448102%}.row-fluid .offset1{margin-left:11.32596685082873%;*margin-left:11.219583872105325%}.row-fluid .offset1:first-child{margin-left:8.56353591160221%;*margin-left:8.457152932878806%}input,textarea,.uneditable-input{margin-left:0}.controls-row [class*="span"]+[class*="span"]{margin-left:20px}input.span12,textarea.span12,.uneditable-input.span12{width:710px}input.span11,textarea.span11,.uneditable-input.span11{width:648px}input.span10,textarea.span10,.uneditable-input.span10{width:586px}input.span9,textarea.span9,.uneditable-input.span9{width:524px}input.span8,textarea.span8,.uneditable-input.span8{width:462px}input.span7,textarea.span7,.uneditable-input.span7{width:400px}input.span6,textarea.span6,.uneditable-input.span6{width:338px}input.span5,textarea.span5,.uneditable-input.span5{width:276px}input.span4,textarea.span4,.uneditable-input.span4{width:214px}input.span3,textarea.span3,.uneditable-input.span3{width:152px}input.span2,textarea.span2,.uneditable-input.span2{width:90px}input.span1,textarea.span1,.uneditable-input.span1{width:28px}}@media(max-width:767px){body{padding-right:20px;padding-left:20px}.navbar-fixed-top,.navbar-fixed-bottom,.navbar-static-top{margin-right:-20px;margin-left:-20px}.container-fluid{padding:0}.dl-horizontal dt{float:none;width:auto;clear:none;text-align:left}.dl-horizontal dd{margin-left:0}.container{width:auto}.row-fluid{width:100%}.row,.thumbnails{margin-left:0}.thumbnails>li{float:none;margin-left:0}[class*="span"],.uneditable-input[class*="span"],.row-fluid [class*="span"]{display:block;float:none;width:100%;margin-left:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.span12,.row-fluid .span12{width:100%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="offset"]:first-child{margin-left:0}.input-large,.input-xlarge,.input-xxlarge,input[class*="span"],select[class*="span"],textarea[class*="span"],.uneditable-input{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.input-prepend input,.input-append input,.input-prepend input[class*="span"],.input-append input[class*="span"]{display:inline-block;width:auto}.controls-row [class*="span"]+[class*="span"]{margin-left:0}.modal{position:fixed;top:20px;right:20px;left:20px;width:auto;margin:0}.modal.fade{top:-100px}.modal.fade.in{top:20px}}@media(max-width:480px){.nav-collapse{-webkit-transform:translate3d(0,0,0)}.page-header h1 small{display:block;line-height:20px}input[type="checkbox"],input[type="radio"]{border:1px solid #ccc}.form-horizontal .control-label{float:none;width:auto;padding-top:0;text-align:left}.form-horizontal .controls{margin-left:0}.form-horizontal .control-list{padding-top:0}.form-horizontal .form-actions{padding-right:10px;padding-left:10px}.media .pull-left,.media .pull-right{display:block;float:none;margin-bottom:10px}.media-object{margin-right:0;margin-left:0}.modal{top:10px;right:10px;left:10px}.modal-header .close{padding:10px;margin:-10px}.carousel-caption{position:static}}@media(max-width:979px){body{padding-top:0}.navbar-fixed-top,.navbar-fixed-bottom{position:static}.navbar-fixed-top{margin-bottom:20px}.navbar-fixed-bottom{margin-top:20px}.navbar-fixed-top .navbar-inner,.navbar-fixed-bottom .navbar-inner{padding:5px}.navbar .container{width:auto;padding:0}.navbar .brand{padding-right:10px;padding-left:10px;margin:0 0 0 -5px}.nav-collapse{clear:both}.nav-collapse .nav{float:none;margin:0 0 10px}.nav-collapse .nav>li{float:none}.nav-collapse .nav>li>a{margin-bottom:2px}.nav-collapse .nav>.divider-vertical{display:none}.nav-collapse .nav .nav-header{color:#777;text-shadow:none}.nav-collapse .nav>li>a,.nav-collapse .dropdown-menu a{padding:9px 15px;font-weight:bold;color:#777;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.nav-collapse .btn{padding:4px 10px 4px;font-weight:normal;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.nav-collapse .dropdown-menu li+li a{margin-bottom:2px}.nav-collapse .nav>li>a:hover,.nav-collapse .nav>li>a:focus,.nav-collapse .dropdown-menu a:hover,.nav-collapse .dropdown-menu a:focus{background-color:#f2f2f2}.navbar-inverse .nav-collapse .nav>li>a,.navbar-inverse .nav-collapse .dropdown-menu a{color:#999}.navbar-inverse .nav-collapse .nav>li>a:hover,.navbar-inverse .nav-collapse .nav>li>a:focus,.navbar-inverse .nav-collapse .dropdown-menu a:hover,.navbar-inverse .nav-collapse .dropdown-menu a:focus{background-color:#111}.nav-collapse.in .btn-group{padding:0;margin-top:5px}.nav-collapse .dropdown-menu{position:static;top:auto;left:auto;display:none;float:none;max-width:none;padding:0;margin:0 15px;background-color:transparent;border:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.nav-collapse .open>.dropdown-menu{display:block}.nav-collapse .dropdown-menu:before,.nav-collapse .dropdown-menu:after{display:none}.nav-collapse .dropdown-menu .divider{display:none}.nav-collapse .nav>li>.dropdown-menu:before,.nav-collapse .nav>li>.dropdown-menu:after{display:none}.nav-collapse .navbar-form,.nav-collapse .navbar-search{float:none;padding:10px 15px;margin:10px 0;border-top:1px solid #f2f2f2;border-bottom:1px solid #f2f2f2;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1)}.navbar-inverse .nav-collapse .navbar-form,.navbar-inverse .nav-collapse .navbar-search{border-top-color:#111;border-bottom-color:#111}.navbar .nav-collapse .nav.pull-right{float:none;margin-left:0}.nav-collapse,.nav-collapse.collapse{height:0;overflow:hidden}.navbar .btn-navbar{display:block}.navbar-static .navbar-inner{padding-right:10px;padding-left:10px}}@media(min-width:980px){.nav-collapse.collapse{height:auto!important;overflow:visible!important}} diff --git a/gui/css/bootstrap.min.css b/gui/css/bootstrap.min.css new file mode 100644 index 0000000..c10c7f4 --- /dev/null +++ b/gui/css/bootstrap.min.css @@ -0,0 +1,9 @@ +/*! + * Bootstrap v2.3.1 + * + * Copyright 2012 Twitter, Inc + * Licensed under the Apache License v2.0 + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Designed and built with all the love in the world @twitter by @mdo and @fat. + */.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:hover,a:active{outline:0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{width:auto\9;height:auto;max-width:100%;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}#map_canvas img,.google-maps img{max-width:none}button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle}button,input{*overflow:visible;line-height:normal}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}button,html input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}label,select,button,input[type="button"],input[type="reset"],input[type="submit"],input[type="radio"],input[type="checkbox"]{cursor:pointer}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none}textarea{overflow:auto;vertical-align:top}@media print{*{color:#000!important;text-shadow:none!important;background:transparent!important;box-shadow:none!important}a,a:visited{text-decoration:underline}a[href]:after{content:" (" attr(href) ")"}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100%!important}@page{margin:.5cm}p,h2,h3{orphans:3;widows:3}h2,h3{page-break-after:avoid}}body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:20px;color:#333;background-color:#fff}a{color:#08c;text-decoration:none}a:hover,a:focus{color:#005580;text-decoration:underline}.img-rounded{-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.img-polaroid{padding:4px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.1);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.1);box-shadow:0 1px 3px rgba(0,0,0,0.1)}.img-circle{-webkit-border-radius:500px;-moz-border-radius:500px;border-radius:500px}.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:20px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.span12{width:940px}.span11{width:860px}.span10{width:780px}.span9{width:700px}.span8{width:620px}.span7{width:540px}.span6{width:460px}.span5{width:380px}.span4{width:300px}.span3{width:220px}.span2{width:140px}.span1{width:60px}.offset12{margin-left:980px}.offset11{margin-left:900px}.offset10{margin-left:820px}.offset9{margin-left:740px}.offset8{margin-left:660px}.offset7{margin-left:580px}.offset6{margin-left:500px}.offset5{margin-left:420px}.offset4{margin-left:340px}.offset3{margin-left:260px}.offset2{margin-left:180px}.offset1{margin-left:100px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.127659574468085%;*margin-left:2.074468085106383%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .controls-row [class*="span"]+[class*="span"]{margin-left:2.127659574468085%}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.48936170212765%;*width:91.43617021276594%}.row-fluid .span10{width:82.97872340425532%;*width:82.92553191489361%}.row-fluid .span9{width:74.46808510638297%;*width:74.41489361702126%}.row-fluid .span8{width:65.95744680851064%;*width:65.90425531914893%}.row-fluid .span7{width:57.44680851063829%;*width:57.39361702127659%}.row-fluid .span6{width:48.93617021276595%;*width:48.88297872340425%}.row-fluid .span5{width:40.42553191489362%;*width:40.37234042553192%}.row-fluid .span4{width:31.914893617021278%;*width:31.861702127659576%}.row-fluid .span3{width:23.404255319148934%;*width:23.351063829787233%}.row-fluid .span2{width:14.893617021276595%;*width:14.840425531914894%}.row-fluid .span1{width:6.382978723404255%;*width:6.329787234042553%}.row-fluid .offset12{margin-left:104.25531914893617%;*margin-left:104.14893617021275%}.row-fluid .offset12:first-child{margin-left:102.12765957446808%;*margin-left:102.02127659574467%}.row-fluid .offset11{margin-left:95.74468085106382%;*margin-left:95.6382978723404%}.row-fluid .offset11:first-child{margin-left:93.61702127659574%;*margin-left:93.51063829787232%}.row-fluid .offset10{margin-left:87.23404255319149%;*margin-left:87.12765957446807%}.row-fluid .offset10:first-child{margin-left:85.1063829787234%;*margin-left:84.99999999999999%}.row-fluid .offset9{margin-left:78.72340425531914%;*margin-left:78.61702127659572%}.row-fluid .offset9:first-child{margin-left:76.59574468085106%;*margin-left:76.48936170212764%}.row-fluid .offset8{margin-left:70.2127659574468%;*margin-left:70.10638297872339%}.row-fluid .offset8:first-child{margin-left:68.08510638297872%;*margin-left:67.9787234042553%}.row-fluid .offset7{margin-left:61.70212765957446%;*margin-left:61.59574468085106%}.row-fluid .offset7:first-child{margin-left:59.574468085106375%;*margin-left:59.46808510638297%}.row-fluid .offset6{margin-left:53.191489361702125%;*margin-left:53.085106382978715%}.row-fluid .offset6:first-child{margin-left:51.063829787234035%;*margin-left:50.95744680851063%}.row-fluid .offset5{margin-left:44.68085106382979%;*margin-left:44.57446808510638%}.row-fluid .offset5:first-child{margin-left:42.5531914893617%;*margin-left:42.4468085106383%}.row-fluid .offset4{margin-left:36.170212765957444%;*margin-left:36.06382978723405%}.row-fluid .offset4:first-child{margin-left:34.04255319148936%;*margin-left:33.93617021276596%}.row-fluid .offset3{margin-left:27.659574468085104%;*margin-left:27.5531914893617%}.row-fluid .offset3:first-child{margin-left:25.53191489361702%;*margin-left:25.425531914893618%}.row-fluid .offset2{margin-left:19.148936170212764%;*margin-left:19.04255319148936%}.row-fluid .offset2:first-child{margin-left:17.02127659574468%;*margin-left:16.914893617021278%}.row-fluid .offset1{margin-left:10.638297872340425%;*margin-left:10.53191489361702%}.row-fluid .offset1:first-child{margin-left:8.51063829787234%;*margin-left:8.404255319148938%}[class*="span"].hide,.row-fluid [class*="span"].hide{display:none}[class*="span"].pull-right,.row-fluid [class*="span"].pull-right{float:right}.container{margin-right:auto;margin-left:auto;*zoom:1}.container:before,.container:after{display:table;line-height:0;content:""}.container:after{clear:both}.container-fluid{padding-right:20px;padding-left:20px;*zoom:1}.container-fluid:before,.container-fluid:after{display:table;line-height:0;content:""}.container-fluid:after{clear:both}p{margin:0 0 10px}.lead{margin-bottom:20px;font-size:21px;font-weight:200;line-height:30px}small{font-size:85%}strong{font-weight:bold}em{font-style:italic}cite{font-style:normal}.muted{color:#999}a.muted:hover,a.muted:focus{color:#808080}.text-warning{color:#c09853}a.text-warning:hover,a.text-warning:focus{color:#a47e3c}.text-error{color:#b94a48}a.text-error:hover,a.text-error:focus{color:#953b39}.text-info{color:#3a87ad}a.text-info:hover,a.text-info:focus{color:#2d6987}.text-success{color:#468847}a.text-success:hover,a.text-success:focus{color:#356635}.text-left{text-align:left}.text-right{text-align:right}.text-center{text-align:center}h1,h2,h3,h4,h5,h6{margin:10px 0;font-family:inherit;font-weight:bold;line-height:20px;color:inherit;text-rendering:optimizelegibility}h1 small,h2 small,h3 small,h4 small,h5 small,h6 small{font-weight:normal;line-height:1;color:#999}h1,h2,h3{line-height:40px}h1{font-size:38.5px}h2{font-size:31.5px}h3{font-size:24.5px}h4{font-size:17.5px}h5{font-size:14px}h6{font-size:11.9px}h1 small{font-size:24.5px}h2 small{font-size:17.5px}h3 small{font-size:14px}h4 small{font-size:14px}.page-header{padding-bottom:9px;margin:20px 0 30px;border-bottom:1px solid #eee}ul,ol{padding:0;margin:0 0 10px 25px}ul ul,ul ol,ol ol,ol ul{margin-bottom:0}li{line-height:20px}ul.unstyled,ol.unstyled{margin-left:0;list-style:none}ul.inline,ol.inline{margin-left:0;list-style:none}ul.inline>li,ol.inline>li{display:inline-block;*display:inline;padding-right:5px;padding-left:5px;*zoom:1}dl{margin-bottom:20px}dt,dd{line-height:20px}dt{font-weight:bold}dd{margin-left:10px}.dl-horizontal{*zoom:1}.dl-horizontal:before,.dl-horizontal:after{display:table;line-height:0;content:""}.dl-horizontal:after{clear:both}.dl-horizontal dt{float:left;width:160px;overflow:hidden;clear:left;text-align:right;text-overflow:ellipsis;white-space:nowrap}.dl-horizontal dd{margin-left:180px}hr{margin:20px 0;border:0;border-top:1px solid #eee;border-bottom:1px solid #fff}abbr[title],abbr[data-original-title]{cursor:help;border-bottom:1px dotted #999}abbr.initialism{font-size:90%;text-transform:uppercase}blockquote{padding:0 0 0 15px;margin:0 0 20px;border-left:5px solid #eee}blockquote p{margin-bottom:0;font-size:17.5px;font-weight:300;line-height:1.25}blockquote small{display:block;line-height:20px;color:#999}blockquote small:before{content:'\2014 \00A0'}blockquote.pull-right{float:right;padding-right:15px;padding-left:0;border-right:5px solid #eee;border-left:0}blockquote.pull-right p,blockquote.pull-right small{text-align:right}blockquote.pull-right small:before{content:''}blockquote.pull-right small:after{content:'\00A0 \2014'}q:before,q:after,blockquote:before,blockquote:after{content:""}address{display:block;margin-bottom:20px;font-style:normal;line-height:20px}code,pre{padding:0 3px 2px;font-family:Monaco,Menlo,Consolas,"Courier New",monospace;font-size:12px;color:#333;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}code{padding:2px 4px;color:#d14;white-space:nowrap;background-color:#f7f7f9;border:1px solid #e1e1e8}pre{display:block;padding:9.5px;margin:0 0 10px;font-size:13px;line-height:20px;word-break:break-all;word-wrap:break-word;white-space:pre;white-space:pre-wrap;background-color:#f5f5f5;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.15);-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}pre.prettyprint{margin-bottom:20px}pre code{padding:0;color:inherit;white-space:pre;white-space:pre-wrap;background-color:transparent;border:0}.pre-scrollable{max-height:340px;overflow-y:scroll}form{margin:0 0 20px}fieldset{padding:0;margin:0;border:0}legend{display:block;width:100%;padding:0;margin-bottom:20px;font-size:21px;line-height:40px;color:#333;border:0;border-bottom:1px solid #e5e5e5}legend small{font-size:15px;color:#999}label,input,button,select,textarea{font-size:14px;font-weight:normal;line-height:20px}input,button,select,textarea{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif}label{display:block;margin-bottom:5px}select,textarea,input[type="text"],input[type="password"],input[type="datetime"],input[type="datetime-local"],input[type="date"],input[type="month"],input[type="time"],input[type="week"],input[type="number"],input[type="email"],input[type="url"],input[type="search"],input[type="tel"],input[type="color"],.uneditable-input{display:inline-block;height:20px;padding:4px 6px;margin-bottom:10px;font-size:14px;line-height:20px;color:#555;vertical-align:middle;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}input,textarea,.uneditable-input{width:206px}textarea{height:auto}textarea,input[type="text"],input[type="password"],input[type="datetime"],input[type="datetime-local"],input[type="date"],input[type="month"],input[type="time"],input[type="week"],input[type="number"],input[type="email"],input[type="url"],input[type="search"],input[type="tel"],input[type="color"],.uneditable-input{background-color:#fff;border:1px solid #ccc;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-webkit-transition:border linear .2s,box-shadow linear .2s;-moz-transition:border linear .2s,box-shadow linear .2s;-o-transition:border linear .2s,box-shadow linear .2s;transition:border linear .2s,box-shadow linear .2s}textarea:focus,input[type="text"]:focus,input[type="password"]:focus,input[type="datetime"]:focus,input[type="datetime-local"]:focus,input[type="date"]:focus,input[type="month"]:focus,input[type="time"]:focus,input[type="week"]:focus,input[type="number"]:focus,input[type="email"]:focus,input[type="url"]:focus,input[type="search"]:focus,input[type="tel"]:focus,input[type="color"]:focus,.uneditable-input:focus{border-color:rgba(82,168,236,0.8);outline:0;outline:thin dotted \9;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 8px rgba(82,168,236,0.6)}input[type="radio"],input[type="checkbox"]{margin:4px 0 0;margin-top:1px \9;*margin-top:0;line-height:normal}input[type="file"],input[type="image"],input[type="submit"],input[type="reset"],input[type="button"],input[type="radio"],input[type="checkbox"]{width:auto}select,input[type="file"]{height:30px;*margin-top:4px;line-height:30px}select{width:220px;background-color:#fff;border:1px solid #ccc}select[multiple],select[size]{height:auto}select:focus,input[type="file"]:focus,input[type="radio"]:focus,input[type="checkbox"]:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.uneditable-input,.uneditable-textarea{color:#999;cursor:not-allowed;background-color:#fcfcfc;border-color:#ccc;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.025);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.025);box-shadow:inset 0 1px 2px rgba(0,0,0,0.025)}.uneditable-input{overflow:hidden;white-space:nowrap}.uneditable-textarea{width:auto;height:auto}input:-moz-placeholder,textarea:-moz-placeholder{color:#999}input:-ms-input-placeholder,textarea:-ms-input-placeholder{color:#999}input::-webkit-input-placeholder,textarea::-webkit-input-placeholder{color:#999}.radio,.checkbox{min-height:20px;padding-left:20px}.radio input[type="radio"],.checkbox input[type="checkbox"]{float:left;margin-left:-20px}.controls>.radio:first-child,.controls>.checkbox:first-child{padding-top:5px}.radio.inline,.checkbox.inline{display:inline-block;padding-top:5px;margin-bottom:0;vertical-align:middle}.radio.inline+.radio.inline,.checkbox.inline+.checkbox.inline{margin-left:10px}.input-mini{width:60px}.input-small{width:90px}.input-medium{width:150px}.input-large{width:210px}.input-xlarge{width:270px}.input-xxlarge{width:530px}input[class*="span"],select[class*="span"],textarea[class*="span"],.uneditable-input[class*="span"],.row-fluid input[class*="span"],.row-fluid select[class*="span"],.row-fluid textarea[class*="span"],.row-fluid .uneditable-input[class*="span"]{float:none;margin-left:0}.input-append input[class*="span"],.input-append .uneditable-input[class*="span"],.input-prepend input[class*="span"],.input-prepend .uneditable-input[class*="span"],.row-fluid input[class*="span"],.row-fluid select[class*="span"],.row-fluid textarea[class*="span"],.row-fluid .uneditable-input[class*="span"],.row-fluid .input-prepend [class*="span"],.row-fluid .input-append [class*="span"]{display:inline-block}input,textarea,.uneditable-input{margin-left:0}.controls-row [class*="span"]+[class*="span"]{margin-left:20px}input.span12,textarea.span12,.uneditable-input.span12{width:926px}input.span11,textarea.span11,.uneditable-input.span11{width:846px}input.span10,textarea.span10,.uneditable-input.span10{width:766px}input.span9,textarea.span9,.uneditable-input.span9{width:686px}input.span8,textarea.span8,.uneditable-input.span8{width:606px}input.span7,textarea.span7,.uneditable-input.span7{width:526px}input.span6,textarea.span6,.uneditable-input.span6{width:446px}input.span5,textarea.span5,.uneditable-input.span5{width:366px}input.span4,textarea.span4,.uneditable-input.span4{width:286px}input.span3,textarea.span3,.uneditable-input.span3{width:206px}input.span2,textarea.span2,.uneditable-input.span2{width:126px}input.span1,textarea.span1,.uneditable-input.span1{width:46px}.controls-row{*zoom:1}.controls-row:before,.controls-row:after{display:table;line-height:0;content:""}.controls-row:after{clear:both}.controls-row [class*="span"],.row-fluid .controls-row [class*="span"]{float:left}.controls-row .checkbox[class*="span"],.controls-row .radio[class*="span"]{padding-top:5px}input[disabled],select[disabled],textarea[disabled],input[readonly],select[readonly],textarea[readonly]{cursor:not-allowed;background-color:#eee}input[type="radio"][disabled],input[type="checkbox"][disabled],input[type="radio"][readonly],input[type="checkbox"][readonly]{background-color:transparent}.control-group.warning .control-label,.control-group.warning .help-block,.control-group.warning .help-inline{color:#c09853}.control-group.warning .checkbox,.control-group.warning .radio,.control-group.warning input,.control-group.warning select,.control-group.warning textarea{color:#c09853}.control-group.warning input,.control-group.warning select,.control-group.warning textarea{border-color:#c09853;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.control-group.warning input:focus,.control-group.warning select:focus,.control-group.warning textarea:focus{border-color:#a47e3c;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e;-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #dbc59e}.control-group.warning .input-prepend .add-on,.control-group.warning .input-append .add-on{color:#c09853;background-color:#fcf8e3;border-color:#c09853}.control-group.error .control-label,.control-group.error .help-block,.control-group.error .help-inline{color:#b94a48}.control-group.error .checkbox,.control-group.error .radio,.control-group.error input,.control-group.error select,.control-group.error textarea{color:#b94a48}.control-group.error input,.control-group.error select,.control-group.error textarea{border-color:#b94a48;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.control-group.error input:focus,.control-group.error select:focus,.control-group.error textarea:focus{border-color:#953b39;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #d59392;-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #d59392;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #d59392}.control-group.error .input-prepend .add-on,.control-group.error .input-append .add-on{color:#b94a48;background-color:#f2dede;border-color:#b94a48}.control-group.success .control-label,.control-group.success .help-block,.control-group.success .help-inline{color:#468847}.control-group.success .checkbox,.control-group.success .radio,.control-group.success input,.control-group.success select,.control-group.success textarea{color:#468847}.control-group.success input,.control-group.success select,.control-group.success textarea{border-color:#468847;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.control-group.success input:focus,.control-group.success select:focus,.control-group.success textarea:focus{border-color:#356635;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7aba7b;-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7aba7b;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7aba7b}.control-group.success .input-prepend .add-on,.control-group.success .input-append .add-on{color:#468847;background-color:#dff0d8;border-color:#468847}.control-group.info .control-label,.control-group.info .help-block,.control-group.info .help-inline{color:#3a87ad}.control-group.info .checkbox,.control-group.info .radio,.control-group.info input,.control-group.info select,.control-group.info textarea{color:#3a87ad}.control-group.info input,.control-group.info select,.control-group.info textarea{border-color:#3a87ad;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075);box-shadow:inset 0 1px 1px rgba(0,0,0,0.075)}.control-group.info input:focus,.control-group.info select:focus,.control-group.info textarea:focus{border-color:#2d6987;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7ab5d3;-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7ab5d3;box-shadow:inset 0 1px 1px rgba(0,0,0,0.075),0 0 6px #7ab5d3}.control-group.info .input-prepend .add-on,.control-group.info .input-append .add-on{color:#3a87ad;background-color:#d9edf7;border-color:#3a87ad}input:focus:invalid,textarea:focus:invalid,select:focus:invalid{color:#b94a48;border-color:#ee5f5b}input:focus:invalid:focus,textarea:focus:invalid:focus,select:focus:invalid:focus{border-color:#e9322d;-webkit-box-shadow:0 0 6px #f8b9b7;-moz-box-shadow:0 0 6px #f8b9b7;box-shadow:0 0 6px #f8b9b7}.form-actions{padding:19px 20px 20px;margin-top:20px;margin-bottom:20px;background-color:#f5f5f5;border-top:1px solid #e5e5e5;*zoom:1}.form-actions:before,.form-actions:after{display:table;line-height:0;content:""}.form-actions:after{clear:both}.help-block,.help-inline{color:#595959}.help-block{display:block;margin-bottom:10px}.help-inline{display:inline-block;*display:inline;padding-left:5px;vertical-align:middle;*zoom:1}.input-append,.input-prepend{display:inline-block;margin-bottom:10px;font-size:0;white-space:nowrap;vertical-align:middle}.input-append input,.input-prepend input,.input-append select,.input-prepend select,.input-append .uneditable-input,.input-prepend .uneditable-input,.input-append .dropdown-menu,.input-prepend .dropdown-menu,.input-append .popover,.input-prepend .popover{font-size:14px}.input-append input,.input-prepend input,.input-append select,.input-prepend select,.input-append .uneditable-input,.input-prepend .uneditable-input{position:relative;margin-bottom:0;*margin-left:0;vertical-align:top;-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.input-append input:focus,.input-prepend input:focus,.input-append select:focus,.input-prepend select:focus,.input-append .uneditable-input:focus,.input-prepend .uneditable-input:focus{z-index:2}.input-append .add-on,.input-prepend .add-on{display:inline-block;width:auto;height:20px;min-width:16px;padding:4px 5px;font-size:14px;font-weight:normal;line-height:20px;text-align:center;text-shadow:0 1px 0 #fff;background-color:#eee;border:1px solid #ccc}.input-append .add-on,.input-prepend .add-on,.input-append .btn,.input-prepend .btn,.input-append .btn-group>.dropdown-toggle,.input-prepend .btn-group>.dropdown-toggle{vertical-align:top;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.input-append .active,.input-prepend .active{background-color:#a9dba9;border-color:#46a546}.input-prepend .add-on,.input-prepend .btn{margin-right:-1px}.input-prepend .add-on:first-child,.input-prepend .btn:first-child{-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.input-append input,.input-append select,.input-append .uneditable-input{-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.input-append input+.btn-group .btn:last-child,.input-append select+.btn-group .btn:last-child,.input-append .uneditable-input+.btn-group .btn:last-child{-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.input-append .add-on,.input-append .btn,.input-append .btn-group{margin-left:-1px}.input-append .add-on:last-child,.input-append .btn:last-child,.input-append .btn-group:last-child>.dropdown-toggle{-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.input-prepend.input-append input,.input-prepend.input-append select,.input-prepend.input-append .uneditable-input{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.input-prepend.input-append input+.btn-group .btn,.input-prepend.input-append select+.btn-group .btn,.input-prepend.input-append .uneditable-input+.btn-group .btn{-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.input-prepend.input-append .add-on:first-child,.input-prepend.input-append .btn:first-child{margin-right:-1px;-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.input-prepend.input-append .add-on:last-child,.input-prepend.input-append .btn:last-child{margin-left:-1px;-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.input-prepend.input-append .btn-group:first-child{margin-left:0}input.search-query{padding-right:14px;padding-right:4px \9;padding-left:14px;padding-left:4px \9;margin-bottom:0;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:15px}.form-search .input-append .search-query,.form-search .input-prepend .search-query{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.form-search .input-append .search-query{-webkit-border-radius:14px 0 0 14px;-moz-border-radius:14px 0 0 14px;border-radius:14px 0 0 14px}.form-search .input-append .btn{-webkit-border-radius:0 14px 14px 0;-moz-border-radius:0 14px 14px 0;border-radius:0 14px 14px 0}.form-search .input-prepend .search-query{-webkit-border-radius:0 14px 14px 0;-moz-border-radius:0 14px 14px 0;border-radius:0 14px 14px 0}.form-search .input-prepend .btn{-webkit-border-radius:14px 0 0 14px;-moz-border-radius:14px 0 0 14px;border-radius:14px 0 0 14px}.form-search input,.form-inline input,.form-horizontal input,.form-search textarea,.form-inline textarea,.form-horizontal textarea,.form-search select,.form-inline select,.form-horizontal select,.form-search .help-inline,.form-inline .help-inline,.form-horizontal .help-inline,.form-search .uneditable-input,.form-inline .uneditable-input,.form-horizontal .uneditable-input,.form-search .input-prepend,.form-inline .input-prepend,.form-horizontal .input-prepend,.form-search .input-append,.form-inline .input-append,.form-horizontal .input-append{display:inline-block;*display:inline;margin-bottom:0;vertical-align:middle;*zoom:1}.form-search .hide,.form-inline .hide,.form-horizontal .hide{display:none}.form-search label,.form-inline label,.form-search .btn-group,.form-inline .btn-group{display:inline-block}.form-search .input-append,.form-inline .input-append,.form-search .input-prepend,.form-inline .input-prepend{margin-bottom:0}.form-search .radio,.form-search .checkbox,.form-inline .radio,.form-inline .checkbox{padding-left:0;margin-bottom:0;vertical-align:middle}.form-search .radio input[type="radio"],.form-search .checkbox input[type="checkbox"],.form-inline .radio input[type="radio"],.form-inline .checkbox input[type="checkbox"]{float:left;margin-right:3px;margin-left:0}.control-group{margin-bottom:10px}legend+.control-group{margin-top:20px;-webkit-margin-top-collapse:separate}.form-horizontal .control-group{margin-bottom:20px;*zoom:1}.form-horizontal .control-group:before,.form-horizontal .control-group:after{display:table;line-height:0;content:""}.form-horizontal .control-group:after{clear:both}.form-horizontal .control-label{float:left;width:160px;padding-top:5px;text-align:right}.form-horizontal .controls{*display:inline-block;*padding-left:20px;margin-left:180px;*margin-left:0}.form-horizontal .controls:first-child{*padding-left:180px}.form-horizontal .help-block{margin-bottom:0}.form-horizontal input+.help-block,.form-horizontal select+.help-block,.form-horizontal textarea+.help-block,.form-horizontal .uneditable-input+.help-block,.form-horizontal .input-prepend+.help-block,.form-horizontal .input-append+.help-block{margin-top:10px}.form-horizontal .form-actions{padding-left:180px}table{max-width:100%;background-color:transparent;border-collapse:collapse;border-spacing:0}.table{width:100%;margin-bottom:20px}.table th,.table td{padding:8px;line-height:20px;text-align:left;vertical-align:top;border-top:1px solid #ddd}.table th{font-weight:bold}.table thead th{vertical-align:bottom}.table caption+thead tr:first-child th,.table caption+thead tr:first-child td,.table colgroup+thead tr:first-child th,.table colgroup+thead tr:first-child td,.table thead:first-child tr:first-child th,.table thead:first-child tr:first-child td{border-top:0}.table tbody+tbody{border-top:2px solid #ddd}.table .table{background-color:#fff}.table-condensed th,.table-condensed td{padding:4px 5px}.table-bordered{border:1px solid #ddd;border-collapse:separate;*border-collapse:collapse;border-left:0;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.table-bordered th,.table-bordered td{border-left:1px solid #ddd}.table-bordered caption+thead tr:first-child th,.table-bordered caption+tbody tr:first-child th,.table-bordered caption+tbody tr:first-child td,.table-bordered colgroup+thead tr:first-child th,.table-bordered colgroup+tbody tr:first-child th,.table-bordered colgroup+tbody tr:first-child td,.table-bordered thead:first-child tr:first-child th,.table-bordered tbody:first-child tr:first-child th,.table-bordered tbody:first-child tr:first-child td{border-top:0}.table-bordered thead:first-child tr:first-child>th:first-child,.table-bordered tbody:first-child tr:first-child>td:first-child,.table-bordered tbody:first-child tr:first-child>th:first-child{-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topleft:4px}.table-bordered thead:first-child tr:first-child>th:last-child,.table-bordered tbody:first-child tr:first-child>td:last-child,.table-bordered tbody:first-child tr:first-child>th:last-child{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-moz-border-radius-topright:4px}.table-bordered thead:last-child tr:last-child>th:first-child,.table-bordered tbody:last-child tr:last-child>td:first-child,.table-bordered tbody:last-child tr:last-child>th:first-child,.table-bordered tfoot:last-child tr:last-child>td:first-child,.table-bordered tfoot:last-child tr:last-child>th:first-child{-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-bottomleft:4px}.table-bordered thead:last-child tr:last-child>th:last-child,.table-bordered tbody:last-child tr:last-child>td:last-child,.table-bordered tbody:last-child tr:last-child>th:last-child,.table-bordered tfoot:last-child tr:last-child>td:last-child,.table-bordered tfoot:last-child tr:last-child>th:last-child{-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-border-radius-bottomright:4px}.table-bordered tfoot+tbody:last-child tr:last-child td:first-child{-webkit-border-bottom-left-radius:0;border-bottom-left-radius:0;-moz-border-radius-bottomleft:0}.table-bordered tfoot+tbody:last-child tr:last-child td:last-child{-webkit-border-bottom-right-radius:0;border-bottom-right-radius:0;-moz-border-radius-bottomright:0}.table-bordered caption+thead tr:first-child th:first-child,.table-bordered caption+tbody tr:first-child td:first-child,.table-bordered colgroup+thead tr:first-child th:first-child,.table-bordered colgroup+tbody tr:first-child td:first-child{-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topleft:4px}.table-bordered caption+thead tr:first-child th:last-child,.table-bordered caption+tbody tr:first-child td:last-child,.table-bordered colgroup+thead tr:first-child th:last-child,.table-bordered colgroup+tbody tr:first-child td:last-child{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-moz-border-radius-topright:4px}.table-striped tbody>tr:nth-child(odd)>td,.table-striped tbody>tr:nth-child(odd)>th{background-color:#f9f9f9}.table-hover tbody tr:hover>td,.table-hover tbody tr:hover>th{background-color:#f5f5f5}table td[class*="span"],table th[class*="span"],.row-fluid table td[class*="span"],.row-fluid table th[class*="span"]{display:table-cell;float:none;margin-left:0}.table td.span1,.table th.span1{float:none;width:44px;margin-left:0}.table td.span2,.table th.span2{float:none;width:124px;margin-left:0}.table td.span3,.table th.span3{float:none;width:204px;margin-left:0}.table td.span4,.table th.span4{float:none;width:284px;margin-left:0}.table td.span5,.table th.span5{float:none;width:364px;margin-left:0}.table td.span6,.table th.span6{float:none;width:444px;margin-left:0}.table td.span7,.table th.span7{float:none;width:524px;margin-left:0}.table td.span8,.table th.span8{float:none;width:604px;margin-left:0}.table td.span9,.table th.span9{float:none;width:684px;margin-left:0}.table td.span10,.table th.span10{float:none;width:764px;margin-left:0}.table td.span11,.table th.span11{float:none;width:844px;margin-left:0}.table td.span12,.table th.span12{float:none;width:924px;margin-left:0}.table tbody tr.success>td{background-color:#dff0d8}.table tbody tr.error>td{background-color:#f2dede}.table tbody tr.warning>td{background-color:#fcf8e3}.table tbody tr.info>td{background-color:#d9edf7}.table-hover tbody tr.success:hover>td{background-color:#d0e9c6}.table-hover tbody tr.error:hover>td{background-color:#ebcccc}.table-hover tbody tr.warning:hover>td{background-color:#faf2cc}.table-hover tbody tr.info:hover>td{background-color:#c4e3f3}[class^="icon-"],[class*=" icon-"]{display:inline-block;width:14px;height:14px;margin-top:1px;*margin-right:.3em;line-height:14px;vertical-align:text-top;background-image:url("../img/glyphicons-halflings.png");background-position:14px 14px;background-repeat:no-repeat}.icon-white,.nav-pills>.active>a>[class^="icon-"],.nav-pills>.active>a>[class*=" icon-"],.nav-list>.active>a>[class^="icon-"],.nav-list>.active>a>[class*=" icon-"],.navbar-inverse .nav>.active>a>[class^="icon-"],.navbar-inverse .nav>.active>a>[class*=" icon-"],.dropdown-menu>li>a:hover>[class^="icon-"],.dropdown-menu>li>a:focus>[class^="icon-"],.dropdown-menu>li>a:hover>[class*=" icon-"],.dropdown-menu>li>a:focus>[class*=" icon-"],.dropdown-menu>.active>a>[class^="icon-"],.dropdown-menu>.active>a>[class*=" icon-"],.dropdown-submenu:hover>a>[class^="icon-"],.dropdown-submenu:focus>a>[class^="icon-"],.dropdown-submenu:hover>a>[class*=" icon-"],.dropdown-submenu:focus>a>[class*=" icon-"]{background-image:url("../img/glyphicons-halflings-white.png")}.icon-glass{background-position:0 0}.icon-music{background-position:-24px 0}.icon-search{background-position:-48px 0}.icon-envelope{background-position:-72px 0}.icon-heart{background-position:-96px 0}.icon-star{background-position:-120px 0}.icon-star-empty{background-position:-144px 0}.icon-user{background-position:-168px 0}.icon-film{background-position:-192px 0}.icon-th-large{background-position:-216px 0}.icon-th{background-position:-240px 0}.icon-th-list{background-position:-264px 0}.icon-ok{background-position:-288px 0}.icon-remove{background-position:-312px 0}.icon-zoom-in{background-position:-336px 0}.icon-zoom-out{background-position:-360px 0}.icon-off{background-position:-384px 0}.icon-signal{background-position:-408px 0}.icon-cog{background-position:-432px 0}.icon-trash{background-position:-456px 0}.icon-home{background-position:0 -24px}.icon-file{background-position:-24px -24px}.icon-time{background-position:-48px -24px}.icon-road{background-position:-72px -24px}.icon-download-alt{background-position:-96px -24px}.icon-download{background-position:-120px -24px}.icon-upload{background-position:-144px -24px}.icon-inbox{background-position:-168px -24px}.icon-play-circle{background-position:-192px -24px}.icon-repeat{background-position:-216px -24px}.icon-refresh{background-position:-240px -24px}.icon-list-alt{background-position:-264px -24px}.icon-lock{background-position:-287px -24px}.icon-flag{background-position:-312px -24px}.icon-headphones{background-position:-336px -24px}.icon-volume-off{background-position:-360px -24px}.icon-volume-down{background-position:-384px -24px}.icon-volume-up{background-position:-408px -24px}.icon-qrcode{background-position:-432px -24px}.icon-barcode{background-position:-456px -24px}.icon-tag{background-position:0 -48px}.icon-tags{background-position:-25px -48px}.icon-book{background-position:-48px -48px}.icon-bookmark{background-position:-72px -48px}.icon-print{background-position:-96px -48px}.icon-camera{background-position:-120px -48px}.icon-font{background-position:-144px -48px}.icon-bold{background-position:-167px -48px}.icon-italic{background-position:-192px -48px}.icon-text-height{background-position:-216px -48px}.icon-text-width{background-position:-240px -48px}.icon-align-left{background-position:-264px -48px}.icon-align-center{background-position:-288px -48px}.icon-align-right{background-position:-312px -48px}.icon-align-justify{background-position:-336px -48px}.icon-list{background-position:-360px -48px}.icon-indent-left{background-position:-384px -48px}.icon-indent-right{background-position:-408px -48px}.icon-facetime-video{background-position:-432px -48px}.icon-picture{background-position:-456px -48px}.icon-pencil{background-position:0 -72px}.icon-map-marker{background-position:-24px -72px}.icon-adjust{background-position:-48px -72px}.icon-tint{background-position:-72px -72px}.icon-edit{background-position:-96px -72px}.icon-share{background-position:-120px -72px}.icon-check{background-position:-144px -72px}.icon-move{background-position:-168px -72px}.icon-step-backward{background-position:-192px -72px}.icon-fast-backward{background-position:-216px -72px}.icon-backward{background-position:-240px -72px}.icon-play{background-position:-264px -72px}.icon-pause{background-position:-288px -72px}.icon-stop{background-position:-312px -72px}.icon-forward{background-position:-336px -72px}.icon-fast-forward{background-position:-360px -72px}.icon-step-forward{background-position:-384px -72px}.icon-eject{background-position:-408px -72px}.icon-chevron-left{background-position:-432px -72px}.icon-chevron-right{background-position:-456px -72px}.icon-plus-sign{background-position:0 -96px}.icon-minus-sign{background-position:-24px -96px}.icon-remove-sign{background-position:-48px -96px}.icon-ok-sign{background-position:-72px -96px}.icon-question-sign{background-position:-96px -96px}.icon-info-sign{background-position:-120px -96px}.icon-screenshot{background-position:-144px -96px}.icon-remove-circle{background-position:-168px -96px}.icon-ok-circle{background-position:-192px -96px}.icon-ban-circle{background-position:-216px -96px}.icon-arrow-left{background-position:-240px -96px}.icon-arrow-right{background-position:-264px -96px}.icon-arrow-up{background-position:-289px -96px}.icon-arrow-down{background-position:-312px -96px}.icon-share-alt{background-position:-336px -96px}.icon-resize-full{background-position:-360px -96px}.icon-resize-small{background-position:-384px -96px}.icon-plus{background-position:-408px -96px}.icon-minus{background-position:-433px -96px}.icon-asterisk{background-position:-456px -96px}.icon-exclamation-sign{background-position:0 -120px}.icon-gift{background-position:-24px -120px}.icon-leaf{background-position:-48px -120px}.icon-fire{background-position:-72px -120px}.icon-eye-open{background-position:-96px -120px}.icon-eye-close{background-position:-120px -120px}.icon-warning-sign{background-position:-144px -120px}.icon-plane{background-position:-168px -120px}.icon-calendar{background-position:-192px -120px}.icon-random{width:16px;background-position:-216px -120px}.icon-comment{background-position:-240px -120px}.icon-magnet{background-position:-264px -120px}.icon-chevron-up{background-position:-288px -120px}.icon-chevron-down{background-position:-313px -119px}.icon-retweet{background-position:-336px -120px}.icon-shopping-cart{background-position:-360px -120px}.icon-folder-close{width:16px;background-position:-384px -120px}.icon-folder-open{width:16px;background-position:-408px -120px}.icon-resize-vertical{background-position:-432px -119px}.icon-resize-horizontal{background-position:-456px -118px}.icon-hdd{background-position:0 -144px}.icon-bullhorn{background-position:-24px -144px}.icon-bell{background-position:-48px -144px}.icon-certificate{background-position:-72px -144px}.icon-thumbs-up{background-position:-96px -144px}.icon-thumbs-down{background-position:-120px -144px}.icon-hand-right{background-position:-144px -144px}.icon-hand-left{background-position:-168px -144px}.icon-hand-up{background-position:-192px -144px}.icon-hand-down{background-position:-216px -144px}.icon-circle-arrow-right{background-position:-240px -144px}.icon-circle-arrow-left{background-position:-264px -144px}.icon-circle-arrow-up{background-position:-288px -144px}.icon-circle-arrow-down{background-position:-312px -144px}.icon-globe{background-position:-336px -144px}.icon-wrench{background-position:-360px -144px}.icon-tasks{background-position:-384px -144px}.icon-filter{background-position:-408px -144px}.icon-briefcase{background-position:-432px -144px}.icon-fullscreen{background-position:-456px -144px}.dropup,.dropdown{position:relative}.dropdown-toggle{*margin-bottom:-3px}.dropdown-toggle:active,.open .dropdown-toggle{outline:0}.caret{display:inline-block;width:0;height:0;vertical-align:top;border-top:4px solid #000;border-right:4px solid transparent;border-left:4px solid transparent;content:""}.dropdown .caret{margin-top:8px;margin-left:2px}.dropdown-menu{position:absolute;top:100%;left:0;z-index:1000;display:none;float:left;min-width:160px;padding:5px 0;margin:2px 0 0;list-style:none;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);*border-right-width:2px;*border-bottom-width:2px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box}.dropdown-menu.pull-right{right:0;left:auto}.dropdown-menu .divider{*width:100%;height:1px;margin:9px 1px;*margin:-5px 0 5px;overflow:hidden;background-color:#e5e5e5;border-bottom:1px solid #fff}.dropdown-menu>li>a{display:block;padding:3px 20px;clear:both;font-weight:normal;line-height:20px;color:#333;white-space:nowrap}.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus,.dropdown-submenu:hover>a,.dropdown-submenu:focus>a{color:#fff;text-decoration:none;background-color:#0081c2;background-image:-moz-linear-gradient(top,#08c,#0077b3);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#0077b3));background-image:-webkit-linear-gradient(top,#08c,#0077b3);background-image:-o-linear-gradient(top,#08c,#0077b3);background-image:linear-gradient(to bottom,#08c,#0077b3);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0077b3',GradientType=0)}.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus{color:#fff;text-decoration:none;background-color:#0081c2;background-image:-moz-linear-gradient(top,#08c,#0077b3);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#0077b3));background-image:-webkit-linear-gradient(top,#08c,#0077b3);background-image:-o-linear-gradient(top,#08c,#0077b3);background-image:linear-gradient(to bottom,#08c,#0077b3);background-repeat:repeat-x;outline:0;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0077b3',GradientType=0)}.dropdown-menu>.disabled>a,.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{color:#999}.dropdown-menu>.disabled>a:hover,.dropdown-menu>.disabled>a:focus{text-decoration:none;cursor:default;background-color:transparent;background-image:none;filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.open{*z-index:1000}.open>.dropdown-menu{display:block}.pull-right>.dropdown-menu{right:0;left:auto}.dropup .caret,.navbar-fixed-bottom .dropdown .caret{border-top:0;border-bottom:4px solid #000;content:""}.dropup .dropdown-menu,.navbar-fixed-bottom .dropdown .dropdown-menu{top:auto;bottom:100%;margin-bottom:1px}.dropdown-submenu{position:relative}.dropdown-submenu>.dropdown-menu{top:0;left:100%;margin-top:-6px;margin-left:-1px;-webkit-border-radius:0 6px 6px 6px;-moz-border-radius:0 6px 6px 6px;border-radius:0 6px 6px 6px}.dropdown-submenu:hover>.dropdown-menu{display:block}.dropup .dropdown-submenu>.dropdown-menu{top:auto;bottom:0;margin-top:0;margin-bottom:-2px;-webkit-border-radius:5px 5px 5px 0;-moz-border-radius:5px 5px 5px 0;border-radius:5px 5px 5px 0}.dropdown-submenu>a:after{display:block;float:right;width:0;height:0;margin-top:5px;margin-right:-10px;border-color:transparent;border-left-color:#ccc;border-style:solid;border-width:5px 0 5px 5px;content:" "}.dropdown-submenu:hover>a:after{border-left-color:#fff}.dropdown-submenu.pull-left{float:none}.dropdown-submenu.pull-left>.dropdown-menu{left:-100%;margin-left:10px;-webkit-border-radius:6px 0 6px 6px;-moz-border-radius:6px 0 6px 6px;border-radius:6px 0 6px 6px}.dropdown .dropdown-menu .nav-header{padding-right:20px;padding-left:20px}.typeahead{z-index:1051;margin-top:2px;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.well{min-height:20px;padding:19px;margin-bottom:20px;background-color:#f5f5f5;border:1px solid #e3e3e3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 1px rgba(0,0,0,0.05);box-shadow:inset 0 1px 1px rgba(0,0,0,0.05)}.well blockquote{border-color:#ddd;border-color:rgba(0,0,0,0.15)}.well-large{padding:24px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.well-small{padding:9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.fade{opacity:0;-webkit-transition:opacity .15s linear;-moz-transition:opacity .15s linear;-o-transition:opacity .15s linear;transition:opacity .15s linear}.fade.in{opacity:1}.collapse{position:relative;height:0;overflow:hidden;-webkit-transition:height .35s ease;-moz-transition:height .35s ease;-o-transition:height .35s ease;transition:height .35s ease}.collapse.in{height:auto}.close{float:right;font-size:20px;font-weight:bold;line-height:20px;color:#000;text-shadow:0 1px 0 #fff;opacity:.2;filter:alpha(opacity=20)}.close:hover,.close:focus{color:#000;text-decoration:none;cursor:pointer;opacity:.4;filter:alpha(opacity=40)}button.close{padding:0;cursor:pointer;background:transparent;border:0;-webkit-appearance:none}.btn{display:inline-block;*display:inline;padding:4px 12px;margin-bottom:0;*margin-left:.3em;font-size:14px;line-height:20px;color:#333;text-align:center;text-shadow:0 1px 1px rgba(255,255,255,0.75);vertical-align:middle;cursor:pointer;background-color:#f5f5f5;*background-color:#e6e6e6;background-image:-moz-linear-gradient(top,#fff,#e6e6e6);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#e6e6e6));background-image:-webkit-linear-gradient(top,#fff,#e6e6e6);background-image:-o-linear-gradient(top,#fff,#e6e6e6);background-image:linear-gradient(to bottom,#fff,#e6e6e6);background-repeat:repeat-x;border:1px solid #ccc;*border:0;border-color:#e6e6e6 #e6e6e6 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);border-bottom-color:#b3b3b3;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',endColorstr='#ffe6e6e6',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);*zoom:1;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05)}.btn:hover,.btn:focus,.btn:active,.btn.active,.btn.disabled,.btn[disabled]{color:#333;background-color:#e6e6e6;*background-color:#d9d9d9}.btn:active,.btn.active{background-color:#ccc \9}.btn:first-child{*margin-left:0}.btn:hover,.btn:focus{color:#333;text-decoration:none;background-position:0 -15px;-webkit-transition:background-position .1s linear;-moz-transition:background-position .1s linear;-o-transition:background-position .1s linear;transition:background-position .1s linear}.btn:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.btn.active,.btn:active{background-image:none;outline:0;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05)}.btn.disabled,.btn[disabled]{cursor:default;background-image:none;opacity:.65;filter:alpha(opacity=65);-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-large{padding:11px 19px;font-size:17.5px;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.btn-large [class^="icon-"],.btn-large [class*=" icon-"]{margin-top:4px}.btn-small{padding:2px 10px;font-size:11.9px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-small [class^="icon-"],.btn-small [class*=" icon-"]{margin-top:0}.btn-mini [class^="icon-"],.btn-mini [class*=" icon-"]{margin-top:-1px}.btn-mini{padding:0 6px;font-size:10.5px;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.btn-block{display:block;width:100%;padding-right:0;padding-left:0;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.btn-block+.btn-block{margin-top:5px}input[type="submit"].btn-block,input[type="reset"].btn-block,input[type="button"].btn-block{width:100%}.btn-primary.active,.btn-warning.active,.btn-danger.active,.btn-success.active,.btn-info.active,.btn-inverse.active{color:rgba(255,255,255,0.75)}.btn-primary{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#006dcc;*background-color:#04c;background-image:-moz-linear-gradient(top,#08c,#04c);background-image:-webkit-gradient(linear,0 0,0 100%,from(#08c),to(#04c));background-image:-webkit-linear-gradient(top,#08c,#04c);background-image:-o-linear-gradient(top,#08c,#04c);background-image:linear-gradient(to bottom,#08c,#04c);background-repeat:repeat-x;border-color:#04c #04c #002a80;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc',endColorstr='#ff0044cc',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-primary:hover,.btn-primary:focus,.btn-primary:active,.btn-primary.active,.btn-primary.disabled,.btn-primary[disabled]{color:#fff;background-color:#04c;*background-color:#003bb3}.btn-primary:active,.btn-primary.active{background-color:#039 \9}.btn-warning{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#faa732;*background-color:#f89406;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;border-color:#f89406 #f89406 #ad6704;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450',endColorstr='#fff89406',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-warning:hover,.btn-warning:focus,.btn-warning:active,.btn-warning.active,.btn-warning.disabled,.btn-warning[disabled]{color:#fff;background-color:#f89406;*background-color:#df8505}.btn-warning:active,.btn-warning.active{background-color:#c67605 \9}.btn-danger{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#da4f49;*background-color:#bd362f;background-image:-moz-linear-gradient(top,#ee5f5b,#bd362f);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#bd362f));background-image:-webkit-linear-gradient(top,#ee5f5b,#bd362f);background-image:-o-linear-gradient(top,#ee5f5b,#bd362f);background-image:linear-gradient(to bottom,#ee5f5b,#bd362f);background-repeat:repeat-x;border-color:#bd362f #bd362f #802420;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffee5f5b',endColorstr='#ffbd362f',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-danger:hover,.btn-danger:focus,.btn-danger:active,.btn-danger.active,.btn-danger.disabled,.btn-danger[disabled]{color:#fff;background-color:#bd362f;*background-color:#a9302a}.btn-danger:active,.btn-danger.active{background-color:#942a25 \9}.btn-success{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#5bb75b;*background-color:#51a351;background-image:-moz-linear-gradient(top,#62c462,#51a351);background-image:-webkit-gradient(linear,0 0,0 100%,from(#62c462),to(#51a351));background-image:-webkit-linear-gradient(top,#62c462,#51a351);background-image:-o-linear-gradient(top,#62c462,#51a351);background-image:linear-gradient(to bottom,#62c462,#51a351);background-repeat:repeat-x;border-color:#51a351 #51a351 #387038;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff62c462',endColorstr='#ff51a351',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-success:hover,.btn-success:focus,.btn-success:active,.btn-success.active,.btn-success.disabled,.btn-success[disabled]{color:#fff;background-color:#51a351;*background-color:#499249}.btn-success:active,.btn-success.active{background-color:#408140 \9}.btn-info{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#49afcd;*background-color:#2f96b4;background-image:-moz-linear-gradient(top,#5bc0de,#2f96b4);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5bc0de),to(#2f96b4));background-image:-webkit-linear-gradient(top,#5bc0de,#2f96b4);background-image:-o-linear-gradient(top,#5bc0de,#2f96b4);background-image:linear-gradient(to bottom,#5bc0de,#2f96b4);background-repeat:repeat-x;border-color:#2f96b4 #2f96b4 #1f6377;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de',endColorstr='#ff2f96b4',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-info:hover,.btn-info:focus,.btn-info:active,.btn-info.active,.btn-info.disabled,.btn-info[disabled]{color:#fff;background-color:#2f96b4;*background-color:#2a85a0}.btn-info:active,.btn-info.active{background-color:#24748c \9}.btn-inverse{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#363636;*background-color:#222;background-image:-moz-linear-gradient(top,#444,#222);background-image:-webkit-gradient(linear,0 0,0 100%,from(#444),to(#222));background-image:-webkit-linear-gradient(top,#444,#222);background-image:-o-linear-gradient(top,#444,#222);background-image:linear-gradient(to bottom,#444,#222);background-repeat:repeat-x;border-color:#222 #222 #000;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff444444',endColorstr='#ff222222',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.btn-inverse:hover,.btn-inverse:focus,.btn-inverse:active,.btn-inverse.active,.btn-inverse.disabled,.btn-inverse[disabled]{color:#fff;background-color:#222;*background-color:#151515}.btn-inverse:active,.btn-inverse.active{background-color:#080808 \9}button.btn,input[type="submit"].btn{*padding-top:3px;*padding-bottom:3px}button.btn::-moz-focus-inner,input[type="submit"].btn::-moz-focus-inner{padding:0;border:0}button.btn.btn-large,input[type="submit"].btn.btn-large{*padding-top:7px;*padding-bottom:7px}button.btn.btn-small,input[type="submit"].btn.btn-small{*padding-top:3px;*padding-bottom:3px}button.btn.btn-mini,input[type="submit"].btn.btn-mini{*padding-top:1px;*padding-bottom:1px}.btn-link,.btn-link:active,.btn-link[disabled]{background-color:transparent;background-image:none;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.btn-link{color:#08c;cursor:pointer;border-color:transparent;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.btn-link:hover,.btn-link:focus{color:#005580;text-decoration:underline;background-color:transparent}.btn-link[disabled]:hover,.btn-link[disabled]:focus{color:#333;text-decoration:none}.btn-group{position:relative;display:inline-block;*display:inline;*margin-left:.3em;font-size:0;white-space:nowrap;vertical-align:middle;*zoom:1}.btn-group:first-child{*margin-left:0}.btn-group+.btn-group{margin-left:5px}.btn-toolbar{margin-top:10px;margin-bottom:10px;font-size:0}.btn-toolbar>.btn+.btn,.btn-toolbar>.btn-group+.btn,.btn-toolbar>.btn+.btn-group{margin-left:5px}.btn-group>.btn{position:relative;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.btn-group>.btn+.btn{margin-left:-1px}.btn-group>.btn,.btn-group>.dropdown-menu,.btn-group>.popover{font-size:14px}.btn-group>.btn-mini{font-size:10.5px}.btn-group>.btn-small{font-size:11.9px}.btn-group>.btn-large{font-size:17.5px}.btn-group>.btn:first-child{margin-left:0;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-bottomleft:4px;-moz-border-radius-topleft:4px}.btn-group>.btn:last-child,.btn-group>.dropdown-toggle{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-border-radius-topright:4px;-moz-border-radius-bottomright:4px}.btn-group>.btn.large:first-child{margin-left:0;-webkit-border-bottom-left-radius:6px;border-bottom-left-radius:6px;-webkit-border-top-left-radius:6px;border-top-left-radius:6px;-moz-border-radius-bottomleft:6px;-moz-border-radius-topleft:6px}.btn-group>.btn.large:last-child,.btn-group>.large.dropdown-toggle{-webkit-border-top-right-radius:6px;border-top-right-radius:6px;-webkit-border-bottom-right-radius:6px;border-bottom-right-radius:6px;-moz-border-radius-topright:6px;-moz-border-radius-bottomright:6px}.btn-group>.btn:hover,.btn-group>.btn:focus,.btn-group>.btn:active,.btn-group>.btn.active{z-index:2}.btn-group .dropdown-toggle:active,.btn-group.open .dropdown-toggle{outline:0}.btn-group>.btn+.dropdown-toggle{*padding-top:5px;padding-right:8px;*padding-bottom:5px;padding-left:8px;-webkit-box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 1px 0 0 rgba(255,255,255,0.125),inset 0 1px 0 rgba(255,255,255,0.2),0 1px 2px rgba(0,0,0,0.05)}.btn-group>.btn-mini+.dropdown-toggle{*padding-top:2px;padding-right:5px;*padding-bottom:2px;padding-left:5px}.btn-group>.btn-small+.dropdown-toggle{*padding-top:5px;*padding-bottom:4px}.btn-group>.btn-large+.dropdown-toggle{*padding-top:7px;padding-right:12px;*padding-bottom:7px;padding-left:12px}.btn-group.open .dropdown-toggle{background-image:none;-webkit-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05);box-shadow:inset 0 2px 4px rgba(0,0,0,0.15),0 1px 2px rgba(0,0,0,0.05)}.btn-group.open .btn.dropdown-toggle{background-color:#e6e6e6}.btn-group.open .btn-primary.dropdown-toggle{background-color:#04c}.btn-group.open .btn-warning.dropdown-toggle{background-color:#f89406}.btn-group.open .btn-danger.dropdown-toggle{background-color:#bd362f}.btn-group.open .btn-success.dropdown-toggle{background-color:#51a351}.btn-group.open .btn-info.dropdown-toggle{background-color:#2f96b4}.btn-group.open .btn-inverse.dropdown-toggle{background-color:#222}.btn .caret{margin-top:8px;margin-left:0}.btn-large .caret{margin-top:6px}.btn-large .caret{border-top-width:5px;border-right-width:5px;border-left-width:5px}.btn-mini .caret,.btn-small .caret{margin-top:8px}.dropup .btn-large .caret{border-bottom-width:5px}.btn-primary .caret,.btn-warning .caret,.btn-danger .caret,.btn-info .caret,.btn-success .caret,.btn-inverse .caret{border-top-color:#fff;border-bottom-color:#fff}.btn-group-vertical{display:inline-block;*display:inline;*zoom:1}.btn-group-vertical>.btn{display:block;float:none;max-width:100%;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.btn-group-vertical>.btn+.btn{margin-top:-1px;margin-left:0}.btn-group-vertical>.btn:first-child{-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.btn-group-vertical>.btn:last-child{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px}.btn-group-vertical>.btn-large:first-child{-webkit-border-radius:6px 6px 0 0;-moz-border-radius:6px 6px 0 0;border-radius:6px 6px 0 0}.btn-group-vertical>.btn-large:last-child{-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px}.alert{padding:8px 35px 8px 14px;margin-bottom:20px;text-shadow:0 1px 0 rgba(255,255,255,0.5);background-color:#fcf8e3;border:1px solid #fbeed5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.alert,.alert h4{color:#c09853}.alert h4{margin:0}.alert .close{position:relative;top:-2px;right:-21px;line-height:20px}.alert-success{color:#468847;background-color:#dff0d8;border-color:#d6e9c6}.alert-success h4{color:#468847}.alert-danger,.alert-error{color:#b94a48;background-color:#f2dede;border-color:#eed3d7}.alert-danger h4,.alert-error h4{color:#b94a48}.alert-info{color:#3a87ad;background-color:#d9edf7;border-color:#bce8f1}.alert-info h4{color:#3a87ad}.alert-block{padding-top:14px;padding-bottom:14px}.alert-block>p,.alert-block>ul{margin-bottom:0}.alert-block p+p{margin-top:5px}.nav{margin-bottom:20px;margin-left:0;list-style:none}.nav>li>a{display:block}.nav>li>a:hover,.nav>li>a:focus{text-decoration:none;background-color:#eee}.nav>li>a>img{max-width:none}.nav>.pull-right{float:right}.nav-header{display:block;padding:3px 15px;font-size:11px;font-weight:bold;line-height:20px;color:#999;text-shadow:0 1px 0 rgba(255,255,255,0.5);text-transform:uppercase}.nav li+.nav-header{margin-top:9px}.nav-list{padding-right:15px;padding-left:15px;margin-bottom:0}.nav-list>li>a,.nav-list .nav-header{margin-right:-15px;margin-left:-15px;text-shadow:0 1px 0 rgba(255,255,255,0.5)}.nav-list>li>a{padding:3px 15px}.nav-list>.active>a,.nav-list>.active>a:hover,.nav-list>.active>a:focus{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.2);background-color:#08c}.nav-list [class^="icon-"],.nav-list [class*=" icon-"]{margin-right:2px}.nav-list .divider{*width:100%;height:1px;margin:9px 1px;*margin:-5px 0 5px;overflow:hidden;background-color:#e5e5e5;border-bottom:1px solid #fff}.nav-tabs,.nav-pills{*zoom:1}.nav-tabs:before,.nav-pills:before,.nav-tabs:after,.nav-pills:after{display:table;line-height:0;content:""}.nav-tabs:after,.nav-pills:after{clear:both}.nav-tabs>li,.nav-pills>li{float:left}.nav-tabs>li>a,.nav-pills>li>a{padding-right:12px;padding-left:12px;margin-right:2px;line-height:14px}.nav-tabs{border-bottom:1px solid #ddd}.nav-tabs>li{margin-bottom:-1px}.nav-tabs>li>a{padding-top:8px;padding-bottom:8px;line-height:20px;border:1px solid transparent;-webkit-border-radius:4px 4px 0 0;-moz-border-radius:4px 4px 0 0;border-radius:4px 4px 0 0}.nav-tabs>li>a:hover,.nav-tabs>li>a:focus{border-color:#eee #eee #ddd}.nav-tabs>.active>a,.nav-tabs>.active>a:hover,.nav-tabs>.active>a:focus{color:#555;cursor:default;background-color:#fff;border:1px solid #ddd;border-bottom-color:transparent}.nav-pills>li>a{padding-top:8px;padding-bottom:8px;margin-top:2px;margin-bottom:2px;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.nav-pills>.active>a,.nav-pills>.active>a:hover,.nav-pills>.active>a:focus{color:#fff;background-color:#08c}.nav-stacked>li{float:none}.nav-stacked>li>a{margin-right:0}.nav-tabs.nav-stacked{border-bottom:0}.nav-tabs.nav-stacked>li>a{border:1px solid #ddd;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.nav-tabs.nav-stacked>li:first-child>a{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-topright:4px;-moz-border-radius-topleft:4px}.nav-tabs.nav-stacked>li:last-child>a{-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-moz-border-radius-bottomright:4px;-moz-border-radius-bottomleft:4px}.nav-tabs.nav-stacked>li>a:hover,.nav-tabs.nav-stacked>li>a:focus{z-index:2;border-color:#ddd}.nav-pills.nav-stacked>li>a{margin-bottom:3px}.nav-pills.nav-stacked>li:last-child>a{margin-bottom:1px}.nav-tabs .dropdown-menu{-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px}.nav-pills .dropdown-menu{-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.nav .dropdown-toggle .caret{margin-top:6px;border-top-color:#08c;border-bottom-color:#08c}.nav .dropdown-toggle:hover .caret,.nav .dropdown-toggle:focus .caret{border-top-color:#005580;border-bottom-color:#005580}.nav-tabs .dropdown-toggle .caret{margin-top:8px}.nav .active .dropdown-toggle .caret{border-top-color:#fff;border-bottom-color:#fff}.nav-tabs .active .dropdown-toggle .caret{border-top-color:#555;border-bottom-color:#555}.nav>.dropdown.active>a:hover,.nav>.dropdown.active>a:focus{cursor:pointer}.nav-tabs .open .dropdown-toggle,.nav-pills .open .dropdown-toggle,.nav>li.dropdown.open.active>a:hover,.nav>li.dropdown.open.active>a:focus{color:#fff;background-color:#999;border-color:#999}.nav li.dropdown.open .caret,.nav li.dropdown.open.active .caret,.nav li.dropdown.open a:hover .caret,.nav li.dropdown.open a:focus .caret{border-top-color:#fff;border-bottom-color:#fff;opacity:1;filter:alpha(opacity=100)}.tabs-stacked .open>a:hover,.tabs-stacked .open>a:focus{border-color:#999}.tabbable{*zoom:1}.tabbable:before,.tabbable:after{display:table;line-height:0;content:""}.tabbable:after{clear:both}.tab-content{overflow:auto}.tabs-below>.nav-tabs,.tabs-right>.nav-tabs,.tabs-left>.nav-tabs{border-bottom:0}.tab-content>.tab-pane,.pill-content>.pill-pane{display:none}.tab-content>.active,.pill-content>.active{display:block}.tabs-below>.nav-tabs{border-top:1px solid #ddd}.tabs-below>.nav-tabs>li{margin-top:-1px;margin-bottom:0}.tabs-below>.nav-tabs>li>a{-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px}.tabs-below>.nav-tabs>li>a:hover,.tabs-below>.nav-tabs>li>a:focus{border-top-color:#ddd;border-bottom-color:transparent}.tabs-below>.nav-tabs>.active>a,.tabs-below>.nav-tabs>.active>a:hover,.tabs-below>.nav-tabs>.active>a:focus{border-color:transparent #ddd #ddd #ddd}.tabs-left>.nav-tabs>li,.tabs-right>.nav-tabs>li{float:none}.tabs-left>.nav-tabs>li>a,.tabs-right>.nav-tabs>li>a{min-width:74px;margin-right:0;margin-bottom:3px}.tabs-left>.nav-tabs{float:left;margin-right:19px;border-right:1px solid #ddd}.tabs-left>.nav-tabs>li>a{margin-right:-1px;-webkit-border-radius:4px 0 0 4px;-moz-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.tabs-left>.nav-tabs>li>a:hover,.tabs-left>.nav-tabs>li>a:focus{border-color:#eee #ddd #eee #eee}.tabs-left>.nav-tabs .active>a,.tabs-left>.nav-tabs .active>a:hover,.tabs-left>.nav-tabs .active>a:focus{border-color:#ddd transparent #ddd #ddd;*border-right-color:#fff}.tabs-right>.nav-tabs{float:right;margin-left:19px;border-left:1px solid #ddd}.tabs-right>.nav-tabs>li>a{margin-left:-1px;-webkit-border-radius:0 4px 4px 0;-moz-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.tabs-right>.nav-tabs>li>a:hover,.tabs-right>.nav-tabs>li>a:focus{border-color:#eee #eee #eee #ddd}.tabs-right>.nav-tabs .active>a,.tabs-right>.nav-tabs .active>a:hover,.tabs-right>.nav-tabs .active>a:focus{border-color:#ddd #ddd #ddd transparent;*border-left-color:#fff}.nav>.disabled>a{color:#999}.nav>.disabled>a:hover,.nav>.disabled>a:focus{text-decoration:none;cursor:default;background-color:transparent}.navbar{*position:relative;*z-index:2;margin-bottom:20px;overflow:visible}.navbar-inner{min-height:40px;padding-right:20px;padding-left:20px;background-color:#fafafa;background-image:-moz-linear-gradient(top,#fff,#f2f2f2);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fff),to(#f2f2f2));background-image:-webkit-linear-gradient(top,#fff,#f2f2f2);background-image:-o-linear-gradient(top,#fff,#f2f2f2);background-image:linear-gradient(to bottom,#fff,#f2f2f2);background-repeat:repeat-x;border:1px solid #d4d4d4;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff',endColorstr='#fff2f2f2',GradientType=0);*zoom:1;-webkit-box-shadow:0 1px 4px rgba(0,0,0,0.065);-moz-box-shadow:0 1px 4px rgba(0,0,0,0.065);box-shadow:0 1px 4px rgba(0,0,0,0.065)}.navbar-inner:before,.navbar-inner:after{display:table;line-height:0;content:""}.navbar-inner:after{clear:both}.navbar .container{width:auto}.nav-collapse.collapse{height:auto;overflow:visible}.navbar .brand{display:block;float:left;padding:10px 20px 10px;margin-left:-20px;font-size:20px;font-weight:200;color:#777;text-shadow:0 1px 0 #fff}.navbar .brand:hover,.navbar .brand:focus{text-decoration:none}.navbar-text{margin-bottom:0;line-height:40px;color:#777}.navbar-link{color:#777}.navbar-link:hover,.navbar-link:focus{color:#333}.navbar .divider-vertical{height:40px;margin:0 9px;border-right:1px solid #fff;border-left:1px solid #f2f2f2}.navbar .btn,.navbar .btn-group{margin-top:5px}.navbar .btn-group .btn,.navbar .input-prepend .btn,.navbar .input-append .btn,.navbar .input-prepend .btn-group,.navbar .input-append .btn-group{margin-top:0}.navbar-form{margin-bottom:0;*zoom:1}.navbar-form:before,.navbar-form:after{display:table;line-height:0;content:""}.navbar-form:after{clear:both}.navbar-form input,.navbar-form select,.navbar-form .radio,.navbar-form .checkbox{margin-top:5px}.navbar-form input,.navbar-form select,.navbar-form .btn{display:inline-block;margin-bottom:0}.navbar-form input[type="image"],.navbar-form input[type="checkbox"],.navbar-form input[type="radio"]{margin-top:3px}.navbar-form .input-append,.navbar-form .input-prepend{margin-top:5px;white-space:nowrap}.navbar-form .input-append input,.navbar-form .input-prepend input{margin-top:0}.navbar-search{position:relative;float:left;margin-top:5px;margin-bottom:0}.navbar-search .search-query{padding:4px 14px;margin-bottom:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:13px;font-weight:normal;line-height:1;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:15px}.navbar-static-top{position:static;margin-bottom:0}.navbar-static-top .navbar-inner{-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.navbar-fixed-top,.navbar-fixed-bottom{position:fixed;right:0;left:0;z-index:1030;margin-bottom:0}.navbar-fixed-top .navbar-inner,.navbar-static-top .navbar-inner{border-width:0 0 1px}.navbar-fixed-bottom .navbar-inner{border-width:1px 0 0}.navbar-fixed-top .navbar-inner,.navbar-fixed-bottom .navbar-inner{padding-right:0;padding-left:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0}.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.navbar-fixed-top{top:0}.navbar-fixed-top .navbar-inner,.navbar-static-top .navbar-inner{-webkit-box-shadow:0 1px 10px rgba(0,0,0,0.1);-moz-box-shadow:0 1px 10px rgba(0,0,0,0.1);box-shadow:0 1px 10px rgba(0,0,0,0.1)}.navbar-fixed-bottom{bottom:0}.navbar-fixed-bottom .navbar-inner{-webkit-box-shadow:0 -1px 10px rgba(0,0,0,0.1);-moz-box-shadow:0 -1px 10px rgba(0,0,0,0.1);box-shadow:0 -1px 10px rgba(0,0,0,0.1)}.navbar .nav{position:relative;left:0;display:block;float:left;margin:0 10px 0 0}.navbar .nav.pull-right{float:right;margin-right:0}.navbar .nav>li{float:left}.navbar .nav>li>a{float:none;padding:10px 15px 10px;color:#777;text-decoration:none;text-shadow:0 1px 0 #fff}.navbar .nav .dropdown-toggle .caret{margin-top:8px}.navbar .nav>li>a:focus,.navbar .nav>li>a:hover{color:#333;text-decoration:none;background-color:transparent}.navbar .nav>.active>a,.navbar .nav>.active>a:hover,.navbar .nav>.active>a:focus{color:#555;text-decoration:none;background-color:#e5e5e5;-webkit-box-shadow:inset 0 3px 8px rgba(0,0,0,0.125);-moz-box-shadow:inset 0 3px 8px rgba(0,0,0,0.125);box-shadow:inset 0 3px 8px rgba(0,0,0,0.125)}.navbar .btn-navbar{display:none;float:right;padding:7px 10px;margin-right:5px;margin-left:5px;color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#ededed;*background-color:#e5e5e5;background-image:-moz-linear-gradient(top,#f2f2f2,#e5e5e5);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f2f2f2),to(#e5e5e5));background-image:-webkit-linear-gradient(top,#f2f2f2,#e5e5e5);background-image:-o-linear-gradient(top,#f2f2f2,#e5e5e5);background-image:linear-gradient(to bottom,#f2f2f2,#e5e5e5);background-repeat:repeat-x;border-color:#e5e5e5 #e5e5e5 #bfbfbf;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff2f2f2',endColorstr='#ffe5e5e5',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false);-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.075)}.navbar .btn-navbar:hover,.navbar .btn-navbar:focus,.navbar .btn-navbar:active,.navbar .btn-navbar.active,.navbar .btn-navbar.disabled,.navbar .btn-navbar[disabled]{color:#fff;background-color:#e5e5e5;*background-color:#d9d9d9}.navbar .btn-navbar:active,.navbar .btn-navbar.active{background-color:#ccc \9}.navbar .btn-navbar .icon-bar{display:block;width:18px;height:2px;background-color:#f5f5f5;-webkit-border-radius:1px;-moz-border-radius:1px;border-radius:1px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.25);-moz-box-shadow:0 1px 0 rgba(0,0,0,0.25);box-shadow:0 1px 0 rgba(0,0,0,0.25)}.btn-navbar .icon-bar+.icon-bar{margin-top:3px}.navbar .nav>li>.dropdown-menu:before{position:absolute;top:-7px;left:9px;display:inline-block;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-left:7px solid transparent;border-bottom-color:rgba(0,0,0,0.2);content:''}.navbar .nav>li>.dropdown-menu:after{position:absolute;top:-6px;left:10px;display:inline-block;border-right:6px solid transparent;border-bottom:6px solid #fff;border-left:6px solid transparent;content:''}.navbar-fixed-bottom .nav>li>.dropdown-menu:before{top:auto;bottom:-7px;border-top:7px solid #ccc;border-bottom:0;border-top-color:rgba(0,0,0,0.2)}.navbar-fixed-bottom .nav>li>.dropdown-menu:after{top:auto;bottom:-6px;border-top:6px solid #fff;border-bottom:0}.navbar .nav li.dropdown>a:hover .caret,.navbar .nav li.dropdown>a:focus .caret{border-top-color:#333;border-bottom-color:#333}.navbar .nav li.dropdown.open>.dropdown-toggle,.navbar .nav li.dropdown.active>.dropdown-toggle,.navbar .nav li.dropdown.open.active>.dropdown-toggle{color:#555;background-color:#e5e5e5}.navbar .nav li.dropdown>.dropdown-toggle .caret{border-top-color:#777;border-bottom-color:#777}.navbar .nav li.dropdown.open>.dropdown-toggle .caret,.navbar .nav li.dropdown.active>.dropdown-toggle .caret,.navbar .nav li.dropdown.open.active>.dropdown-toggle .caret{border-top-color:#555;border-bottom-color:#555}.navbar .pull-right>li>.dropdown-menu,.navbar .nav>li>.dropdown-menu.pull-right{right:0;left:auto}.navbar .pull-right>li>.dropdown-menu:before,.navbar .nav>li>.dropdown-menu.pull-right:before{right:12px;left:auto}.navbar .pull-right>li>.dropdown-menu:after,.navbar .nav>li>.dropdown-menu.pull-right:after{right:13px;left:auto}.navbar .pull-right>li>.dropdown-menu .dropdown-menu,.navbar .nav>li>.dropdown-menu.pull-right .dropdown-menu{right:100%;left:auto;margin-right:-1px;margin-left:0;-webkit-border-radius:6px 0 6px 6px;-moz-border-radius:6px 0 6px 6px;border-radius:6px 0 6px 6px}.navbar-inverse .navbar-inner{background-color:#1b1b1b;background-image:-moz-linear-gradient(top,#222,#111);background-image:-webkit-gradient(linear,0 0,0 100%,from(#222),to(#111));background-image:-webkit-linear-gradient(top,#222,#111);background-image:-o-linear-gradient(top,#222,#111);background-image:linear-gradient(to bottom,#222,#111);background-repeat:repeat-x;border-color:#252525;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff222222',endColorstr='#ff111111',GradientType=0)}.navbar-inverse .brand,.navbar-inverse .nav>li>a{color:#999;text-shadow:0 -1px 0 rgba(0,0,0,0.25)}.navbar-inverse .brand:hover,.navbar-inverse .nav>li>a:hover,.navbar-inverse .brand:focus,.navbar-inverse .nav>li>a:focus{color:#fff}.navbar-inverse .brand{color:#999}.navbar-inverse .navbar-text{color:#999}.navbar-inverse .nav>li>a:focus,.navbar-inverse .nav>li>a:hover{color:#fff;background-color:transparent}.navbar-inverse .nav .active>a,.navbar-inverse .nav .active>a:hover,.navbar-inverse .nav .active>a:focus{color:#fff;background-color:#111}.navbar-inverse .navbar-link{color:#999}.navbar-inverse .navbar-link:hover,.navbar-inverse .navbar-link:focus{color:#fff}.navbar-inverse .divider-vertical{border-right-color:#222;border-left-color:#111}.navbar-inverse .nav li.dropdown.open>.dropdown-toggle,.navbar-inverse .nav li.dropdown.active>.dropdown-toggle,.navbar-inverse .nav li.dropdown.open.active>.dropdown-toggle{color:#fff;background-color:#111}.navbar-inverse .nav li.dropdown>a:hover .caret,.navbar-inverse .nav li.dropdown>a:focus .caret{border-top-color:#fff;border-bottom-color:#fff}.navbar-inverse .nav li.dropdown>.dropdown-toggle .caret{border-top-color:#999;border-bottom-color:#999}.navbar-inverse .nav li.dropdown.open>.dropdown-toggle .caret,.navbar-inverse .nav li.dropdown.active>.dropdown-toggle .caret,.navbar-inverse .nav li.dropdown.open.active>.dropdown-toggle .caret{border-top-color:#fff;border-bottom-color:#fff}.navbar-inverse .navbar-search .search-query{color:#fff;background-color:#515151;border-color:#111;-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1),0 1px 0 rgba(255,255,255,0.15);-webkit-transition:none;-moz-transition:none;-o-transition:none;transition:none}.navbar-inverse .navbar-search .search-query:-moz-placeholder{color:#ccc}.navbar-inverse .navbar-search .search-query:-ms-input-placeholder{color:#ccc}.navbar-inverse .navbar-search .search-query::-webkit-input-placeholder{color:#ccc}.navbar-inverse .navbar-search .search-query:focus,.navbar-inverse .navbar-search .search-query.focused{padding:5px 15px;color:#333;text-shadow:0 1px 0 #fff;background-color:#fff;border:0;outline:0;-webkit-box-shadow:0 0 3px rgba(0,0,0,0.15);-moz-box-shadow:0 0 3px rgba(0,0,0,0.15);box-shadow:0 0 3px rgba(0,0,0,0.15)}.navbar-inverse .btn-navbar{color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#0e0e0e;*background-color:#040404;background-image:-moz-linear-gradient(top,#151515,#040404);background-image:-webkit-gradient(linear,0 0,0 100%,from(#151515),to(#040404));background-image:-webkit-linear-gradient(top,#151515,#040404);background-image:-o-linear-gradient(top,#151515,#040404);background-image:linear-gradient(to bottom,#151515,#040404);background-repeat:repeat-x;border-color:#040404 #040404 #000;border-color:rgba(0,0,0,0.1) rgba(0,0,0,0.1) rgba(0,0,0,0.25);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff151515',endColorstr='#ff040404',GradientType=0);filter:progid:DXImageTransform.Microsoft.gradient(enabled=false)}.navbar-inverse .btn-navbar:hover,.navbar-inverse .btn-navbar:focus,.navbar-inverse .btn-navbar:active,.navbar-inverse .btn-navbar.active,.navbar-inverse .btn-navbar.disabled,.navbar-inverse .btn-navbar[disabled]{color:#fff;background-color:#040404;*background-color:#000}.navbar-inverse .btn-navbar:active,.navbar-inverse .btn-navbar.active{background-color:#000 \9}.breadcrumb{padding:8px 15px;margin:0 0 20px;list-style:none;background-color:#f5f5f5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.breadcrumb>li{display:inline-block;*display:inline;text-shadow:0 1px 0 #fff;*zoom:1}.breadcrumb>li>.divider{padding:0 5px;color:#ccc}.breadcrumb>.active{color:#999}.pagination{margin:20px 0}.pagination ul{display:inline-block;*display:inline;margin-bottom:0;margin-left:0;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;*zoom:1;-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.05);-moz-box-shadow:0 1px 2px rgba(0,0,0,0.05);box-shadow:0 1px 2px rgba(0,0,0,0.05)}.pagination ul>li{display:inline}.pagination ul>li>a,.pagination ul>li>span{float:left;padding:4px 12px;line-height:20px;text-decoration:none;background-color:#fff;border:1px solid #ddd;border-left-width:0}.pagination ul>li>a:hover,.pagination ul>li>a:focus,.pagination ul>.active>a,.pagination ul>.active>span{background-color:#f5f5f5}.pagination ul>.active>a,.pagination ul>.active>span{color:#999;cursor:default}.pagination ul>.disabled>span,.pagination ul>.disabled>a,.pagination ul>.disabled>a:hover,.pagination ul>.disabled>a:focus{color:#999;cursor:default;background-color:transparent}.pagination ul>li:first-child>a,.pagination ul>li:first-child>span{border-left-width:1px;-webkit-border-bottom-left-radius:4px;border-bottom-left-radius:4px;-webkit-border-top-left-radius:4px;border-top-left-radius:4px;-moz-border-radius-bottomleft:4px;-moz-border-radius-topleft:4px}.pagination ul>li:last-child>a,.pagination ul>li:last-child>span{-webkit-border-top-right-radius:4px;border-top-right-radius:4px;-webkit-border-bottom-right-radius:4px;border-bottom-right-radius:4px;-moz-border-radius-topright:4px;-moz-border-radius-bottomright:4px}.pagination-centered{text-align:center}.pagination-right{text-align:right}.pagination-large ul>li>a,.pagination-large ul>li>span{padding:11px 19px;font-size:17.5px}.pagination-large ul>li:first-child>a,.pagination-large ul>li:first-child>span{-webkit-border-bottom-left-radius:6px;border-bottom-left-radius:6px;-webkit-border-top-left-radius:6px;border-top-left-radius:6px;-moz-border-radius-bottomleft:6px;-moz-border-radius-topleft:6px}.pagination-large ul>li:last-child>a,.pagination-large ul>li:last-child>span{-webkit-border-top-right-radius:6px;border-top-right-radius:6px;-webkit-border-bottom-right-radius:6px;border-bottom-right-radius:6px;-moz-border-radius-topright:6px;-moz-border-radius-bottomright:6px}.pagination-mini ul>li:first-child>a,.pagination-small ul>li:first-child>a,.pagination-mini ul>li:first-child>span,.pagination-small ul>li:first-child>span{-webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px;-webkit-border-top-left-radius:3px;border-top-left-radius:3px;-moz-border-radius-bottomleft:3px;-moz-border-radius-topleft:3px}.pagination-mini ul>li:last-child>a,.pagination-small ul>li:last-child>a,.pagination-mini ul>li:last-child>span,.pagination-small ul>li:last-child>span{-webkit-border-top-right-radius:3px;border-top-right-radius:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px;-moz-border-radius-topright:3px;-moz-border-radius-bottomright:3px}.pagination-small ul>li>a,.pagination-small ul>li>span{padding:2px 10px;font-size:11.9px}.pagination-mini ul>li>a,.pagination-mini ul>li>span{padding:0 6px;font-size:10.5px}.pager{margin:20px 0;text-align:center;list-style:none;*zoom:1}.pager:before,.pager:after{display:table;line-height:0;content:""}.pager:after{clear:both}.pager li{display:inline}.pager li>a,.pager li>span{display:inline-block;padding:5px 14px;background-color:#fff;border:1px solid #ddd;-webkit-border-radius:15px;-moz-border-radius:15px;border-radius:15px}.pager li>a:hover,.pager li>a:focus{text-decoration:none;background-color:#f5f5f5}.pager .next>a,.pager .next>span{float:right}.pager .previous>a,.pager .previous>span{float:left}.pager .disabled>a,.pager .disabled>a:hover,.pager .disabled>a:focus,.pager .disabled>span{color:#999;cursor:default;background-color:#fff}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;background-color:#000}.modal-backdrop.fade{opacity:0}.modal-backdrop,.modal-backdrop.fade.in{opacity:.8;filter:alpha(opacity=80)}.modal{position:fixed;top:10%;left:50%;z-index:1050;width:560px;margin-left:-280px;background-color:#fff;border:1px solid #999;border:1px solid rgba(0,0,0,0.3);*border:1px solid #999;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;outline:0;-webkit-box-shadow:0 3px 7px rgba(0,0,0,0.3);-moz-box-shadow:0 3px 7px rgba(0,0,0,0.3);box-shadow:0 3px 7px rgba(0,0,0,0.3);-webkit-background-clip:padding-box;-moz-background-clip:padding-box;background-clip:padding-box}.modal.fade{top:-25%;-webkit-transition:opacity .3s linear,top .3s ease-out;-moz-transition:opacity .3s linear,top .3s ease-out;-o-transition:opacity .3s linear,top .3s ease-out;transition:opacity .3s linear,top .3s ease-out}.modal.fade.in{top:10%}.modal-header{padding:9px 15px;border-bottom:1px solid #eee}.modal-header .close{margin-top:2px}.modal-header h3{margin:0;line-height:30px}.modal-body{position:relative;max-height:400px;padding:15px;overflow-y:auto}.modal-form{margin-bottom:0}.modal-footer{padding:14px 15px 15px;margin-bottom:0;text-align:right;background-color:#f5f5f5;border-top:1px solid #ddd;-webkit-border-radius:0 0 6px 6px;-moz-border-radius:0 0 6px 6px;border-radius:0 0 6px 6px;*zoom:1;-webkit-box-shadow:inset 0 1px 0 #fff;-moz-box-shadow:inset 0 1px 0 #fff;box-shadow:inset 0 1px 0 #fff}.modal-footer:before,.modal-footer:after{display:table;line-height:0;content:""}.modal-footer:after{clear:both}.modal-footer .btn+.btn{margin-bottom:0;margin-left:5px}.modal-footer .btn-group .btn+.btn{margin-left:-1px}.modal-footer .btn-block+.btn-block{margin-left:0}.tooltip{position:absolute;z-index:1030;display:block;font-size:11px;line-height:1.4;opacity:0;filter:alpha(opacity=0);visibility:visible}.tooltip.in{opacity:.8;filter:alpha(opacity=80)}.tooltip.top{padding:5px 0;margin-top:-3px}.tooltip.right{padding:0 5px;margin-left:3px}.tooltip.bottom{padding:5px 0;margin-top:3px}.tooltip.left{padding:0 5px;margin-left:-3px}.tooltip-inner{max-width:200px;padding:8px;color:#fff;text-align:center;text-decoration:none;background-color:#000;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.tooltip-arrow{position:absolute;width:0;height:0;border-color:transparent;border-style:solid}.tooltip.top .tooltip-arrow{bottom:0;left:50%;margin-left:-5px;border-top-color:#000;border-width:5px 5px 0}.tooltip.right .tooltip-arrow{top:50%;left:0;margin-top:-5px;border-right-color:#000;border-width:5px 5px 5px 0}.tooltip.left .tooltip-arrow{top:50%;right:0;margin-top:-5px;border-left-color:#000;border-width:5px 0 5px 5px}.tooltip.bottom .tooltip-arrow{top:0;left:50%;margin-left:-5px;border-bottom-color:#000;border-width:0 5px 5px}.popover{position:absolute;top:0;left:0;z-index:1010;display:none;max-width:276px;padding:1px;text-align:left;white-space:normal;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);-moz-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2);-webkit-background-clip:padding-box;-moz-background-clip:padding;background-clip:padding-box}.popover.top{margin-top:-10px}.popover.right{margin-left:10px}.popover.bottom{margin-top:10px}.popover.left{margin-left:-10px}.popover-title{padding:8px 14px;margin:0;font-size:14px;font-weight:normal;line-height:18px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;-webkit-border-radius:5px 5px 0 0;-moz-border-radius:5px 5px 0 0;border-radius:5px 5px 0 0}.popover-title:empty{display:none}.popover-content{padding:9px 14px}.popover .arrow,.popover .arrow:after{position:absolute;display:block;width:0;height:0;border-color:transparent;border-style:solid}.popover .arrow{border-width:11px}.popover .arrow:after{border-width:10px;content:""}.popover.top .arrow{bottom:-11px;left:50%;margin-left:-11px;border-top-color:#999;border-top-color:rgba(0,0,0,0.25);border-bottom-width:0}.popover.top .arrow:after{bottom:1px;margin-left:-10px;border-top-color:#fff;border-bottom-width:0}.popover.right .arrow{top:50%;left:-11px;margin-top:-11px;border-right-color:#999;border-right-color:rgba(0,0,0,0.25);border-left-width:0}.popover.right .arrow:after{bottom:-10px;left:1px;border-right-color:#fff;border-left-width:0}.popover.bottom .arrow{top:-11px;left:50%;margin-left:-11px;border-bottom-color:#999;border-bottom-color:rgba(0,0,0,0.25);border-top-width:0}.popover.bottom .arrow:after{top:1px;margin-left:-10px;border-bottom-color:#fff;border-top-width:0}.popover.left .arrow{top:50%;right:-11px;margin-top:-11px;border-left-color:#999;border-left-color:rgba(0,0,0,0.25);border-right-width:0}.popover.left .arrow:after{right:1px;bottom:-10px;border-left-color:#fff;border-right-width:0}.thumbnails{margin-left:-20px;list-style:none;*zoom:1}.thumbnails:before,.thumbnails:after{display:table;line-height:0;content:""}.thumbnails:after{clear:both}.row-fluid .thumbnails{margin-left:0}.thumbnails>li{float:left;margin-bottom:20px;margin-left:20px}.thumbnail{display:block;padding:4px;line-height:20px;border:1px solid #ddd;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.055);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.055);box-shadow:0 1px 3px rgba(0,0,0,0.055);-webkit-transition:all .2s ease-in-out;-moz-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out}a.thumbnail:hover,a.thumbnail:focus{border-color:#08c;-webkit-box-shadow:0 1px 4px rgba(0,105,214,0.25);-moz-box-shadow:0 1px 4px rgba(0,105,214,0.25);box-shadow:0 1px 4px rgba(0,105,214,0.25)}.thumbnail>img{display:block;max-width:100%;margin-right:auto;margin-left:auto}.thumbnail .caption{padding:9px;color:#555}.media,.media-body{overflow:hidden;*overflow:visible;zoom:1}.media,.media .media{margin-top:15px}.media:first-child{margin-top:0}.media-object{display:block}.media-heading{margin:0 0 5px}.media>.pull-left{margin-right:10px}.media>.pull-right{margin-left:10px}.media-list{margin-left:0;list-style:none}.label,.badge{display:inline-block;padding:2px 4px;font-size:11.844px;font-weight:bold;line-height:14px;color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,0.25);white-space:nowrap;vertical-align:baseline;background-color:#999}.label{-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.badge{padding-right:9px;padding-left:9px;-webkit-border-radius:9px;-moz-border-radius:9px;border-radius:9px}.label:empty,.badge:empty{display:none}a.label:hover,a.label:focus,a.badge:hover,a.badge:focus{color:#fff;text-decoration:none;cursor:pointer}.label-important,.badge-important{background-color:#b94a48}.label-important[href],.badge-important[href]{background-color:#953b39}.label-warning,.badge-warning{background-color:#f89406}.label-warning[href],.badge-warning[href]{background-color:#c67605}.label-success,.badge-success{background-color:#468847}.label-success[href],.badge-success[href]{background-color:#356635}.label-info,.badge-info{background-color:#3a87ad}.label-info[href],.badge-info[href]{background-color:#2d6987}.label-inverse,.badge-inverse{background-color:#333}.label-inverse[href],.badge-inverse[href]{background-color:#1a1a1a}.btn .label,.btn .badge{position:relative;top:-1px}.btn-mini .label,.btn-mini .badge{top:0}@-webkit-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-moz-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-ms-keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}@-o-keyframes progress-bar-stripes{from{background-position:0 0}to{background-position:40px 0}}@keyframes progress-bar-stripes{from{background-position:40px 0}to{background-position:0 0}}.progress{height:20px;margin-bottom:20px;overflow:hidden;background-color:#f7f7f7;background-image:-moz-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:-webkit-gradient(linear,0 0,0 100%,from(#f5f5f5),to(#f9f9f9));background-image:-webkit-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:-o-linear-gradient(top,#f5f5f5,#f9f9f9);background-image:linear-gradient(to bottom,#f5f5f5,#f9f9f9);background-repeat:repeat-x;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fff5f5f5',endColorstr='#fff9f9f9',GradientType=0);-webkit-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);-moz-box-shadow:inset 0 1px 2px rgba(0,0,0,0.1);box-shadow:inset 0 1px 2px rgba(0,0,0,0.1)}.progress .bar{float:left;width:0;height:100%;font-size:12px;color:#fff;text-align:center;text-shadow:0 -1px 0 rgba(0,0,0,0.25);background-color:#0e90d2;background-image:-moz-linear-gradient(top,#149bdf,#0480be);background-image:-webkit-gradient(linear,0 0,0 100%,from(#149bdf),to(#0480be));background-image:-webkit-linear-gradient(top,#149bdf,#0480be);background-image:-o-linear-gradient(top,#149bdf,#0480be);background-image:linear-gradient(to bottom,#149bdf,#0480be);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff149bdf',endColorstr='#ff0480be',GradientType=0);-webkit-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-moz-box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 0 -1px 0 rgba(0,0,0,0.15);-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;-webkit-transition:width .6s ease;-moz-transition:width .6s ease;-o-transition:width .6s ease;transition:width .6s ease}.progress .bar+.bar{-webkit-box-shadow:inset 1px 0 0 rgba(0,0,0,0.15),inset 0 -1px 0 rgba(0,0,0,0.15);-moz-box-shadow:inset 1px 0 0 rgba(0,0,0,0.15),inset 0 -1px 0 rgba(0,0,0,0.15);box-shadow:inset 1px 0 0 rgba(0,0,0,0.15),inset 0 -1px 0 rgba(0,0,0,0.15)}.progress-striped .bar{background-color:#149bdf;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);-webkit-background-size:40px 40px;-moz-background-size:40px 40px;-o-background-size:40px 40px;background-size:40px 40px}.progress.active .bar{-webkit-animation:progress-bar-stripes 2s linear infinite;-moz-animation:progress-bar-stripes 2s linear infinite;-ms-animation:progress-bar-stripes 2s linear infinite;-o-animation:progress-bar-stripes 2s linear infinite;animation:progress-bar-stripes 2s linear infinite}.progress-danger .bar,.progress .bar-danger{background-color:#dd514c;background-image:-moz-linear-gradient(top,#ee5f5b,#c43c35);background-image:-webkit-gradient(linear,0 0,0 100%,from(#ee5f5b),to(#c43c35));background-image:-webkit-linear-gradient(top,#ee5f5b,#c43c35);background-image:-o-linear-gradient(top,#ee5f5b,#c43c35);background-image:linear-gradient(to bottom,#ee5f5b,#c43c35);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffee5f5b',endColorstr='#ffc43c35',GradientType=0)}.progress-danger.progress-striped .bar,.progress-striped .bar-danger{background-color:#ee5f5b;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-success .bar,.progress .bar-success{background-color:#5eb95e;background-image:-moz-linear-gradient(top,#62c462,#57a957);background-image:-webkit-gradient(linear,0 0,0 100%,from(#62c462),to(#57a957));background-image:-webkit-linear-gradient(top,#62c462,#57a957);background-image:-o-linear-gradient(top,#62c462,#57a957);background-image:linear-gradient(to bottom,#62c462,#57a957);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff62c462',endColorstr='#ff57a957',GradientType=0)}.progress-success.progress-striped .bar,.progress-striped .bar-success{background-color:#62c462;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-info .bar,.progress .bar-info{background-color:#4bb1cf;background-image:-moz-linear-gradient(top,#5bc0de,#339bb9);background-image:-webkit-gradient(linear,0 0,0 100%,from(#5bc0de),to(#339bb9));background-image:-webkit-linear-gradient(top,#5bc0de,#339bb9);background-image:-o-linear-gradient(top,#5bc0de,#339bb9);background-image:linear-gradient(to bottom,#5bc0de,#339bb9);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff5bc0de',endColorstr='#ff339bb9',GradientType=0)}.progress-info.progress-striped .bar,.progress-striped .bar-info{background-color:#5bc0de;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.progress-warning .bar,.progress .bar-warning{background-color:#faa732;background-image:-moz-linear-gradient(top,#fbb450,#f89406);background-image:-webkit-gradient(linear,0 0,0 100%,from(#fbb450),to(#f89406));background-image:-webkit-linear-gradient(top,#fbb450,#f89406);background-image:-o-linear-gradient(top,#fbb450,#f89406);background-image:linear-gradient(to bottom,#fbb450,#f89406);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffbb450',endColorstr='#fff89406',GradientType=0)}.progress-warning.progress-striped .bar,.progress-striped .bar-warning{background-color:#fbb450;background-image:-webkit-gradient(linear,0 100%,100% 0,color-stop(0.25,rgba(255,255,255,0.15)),color-stop(0.25,transparent),color-stop(0.5,transparent),color-stop(0.5,rgba(255,255,255,0.15)),color-stop(0.75,rgba(255,255,255,0.15)),color-stop(0.75,transparent),to(transparent));background-image:-webkit-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-moz-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:-o-linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent);background-image:linear-gradient(45deg,rgba(255,255,255,0.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,0.15) 50%,rgba(255,255,255,0.15) 75%,transparent 75%,transparent)}.accordion{margin-bottom:20px}.accordion-group{margin-bottom:2px;border:1px solid #e5e5e5;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.accordion-heading{border-bottom:0}.accordion-heading .accordion-toggle{display:block;padding:8px 15px}.accordion-toggle{cursor:pointer}.accordion-inner{padding:9px 15px;border-top:1px solid #e5e5e5}.carousel{position:relative;margin-bottom:20px;line-height:1}.carousel-inner{position:relative;width:100%;overflow:hidden}.carousel-inner>.item{position:relative;display:none;-webkit-transition:.6s ease-in-out left;-moz-transition:.6s ease-in-out left;-o-transition:.6s ease-in-out left;transition:.6s ease-in-out left}.carousel-inner>.item>img,.carousel-inner>.item>a>img{display:block;line-height:1}.carousel-inner>.active,.carousel-inner>.next,.carousel-inner>.prev{display:block}.carousel-inner>.active{left:0}.carousel-inner>.next,.carousel-inner>.prev{position:absolute;top:0;width:100%}.carousel-inner>.next{left:100%}.carousel-inner>.prev{left:-100%}.carousel-inner>.next.left,.carousel-inner>.prev.right{left:0}.carousel-inner>.active.left{left:-100%}.carousel-inner>.active.right{left:100%}.carousel-control{position:absolute;top:40%;left:15px;width:40px;height:40px;margin-top:-20px;font-size:60px;font-weight:100;line-height:30px;color:#fff;text-align:center;background:#222;border:3px solid #fff;-webkit-border-radius:23px;-moz-border-radius:23px;border-radius:23px;opacity:.5;filter:alpha(opacity=50)}.carousel-control.right{right:15px;left:auto}.carousel-control:hover,.carousel-control:focus{color:#fff;text-decoration:none;opacity:.9;filter:alpha(opacity=90)}.carousel-indicators{position:absolute;top:15px;right:15px;z-index:5;margin:0;list-style:none}.carousel-indicators li{display:block;float:left;width:10px;height:10px;margin-left:5px;text-indent:-999px;background-color:#ccc;background-color:rgba(255,255,255,0.25);border-radius:5px}.carousel-indicators .active{background-color:#fff}.carousel-caption{position:absolute;right:0;bottom:0;left:0;padding:15px;background:#333;background:rgba(0,0,0,0.75)}.carousel-caption h4,.carousel-caption p{line-height:20px;color:#fff}.carousel-caption h4{margin:0 0 5px}.carousel-caption p{margin-bottom:0}.hero-unit{padding:60px;margin-bottom:30px;font-size:18px;font-weight:200;line-height:30px;color:inherit;background-color:#eee;-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.hero-unit h1{margin-bottom:0;font-size:60px;line-height:1;letter-spacing:-1px;color:inherit}.hero-unit li{line-height:30px}.pull-right{float:right}.pull-left{float:left}.hide{display:none}.show{display:block}.invisible{visibility:hidden}.affix{position:fixed} diff --git a/gui/css/code.css b/gui/css/code.css new file mode 100644 index 0000000..40e40fe --- /dev/null +++ b/gui/css/code.css @@ -0,0 +1 @@ +code{word-wrap:break-word;color:black}.comment,.doc_comment,.ml_comment{color:orange}.variable{color:blueviolet;font-style:italic}.const,.constant_encapsed_string,.class_c,.dir,.file,.func_c,.halt_compiler,.line,.method_c,.ns_c,.ns_separator,.lnumber,.dnumber{color:crimson}.string,.and_equal,.boolean_and,.boolean_or,.concat_equal,.dec,.div_equal,.inc,.is_equal,.is_greater_or_equal,.is_identical,.is_not_equal,.is_not_identical,.is_smaller_or_equal,.logical_and,.logical_or,.logical_xor,.minus_equal,.mod_equal,.mul_equal,.or_equal,.plus_equal,.sl,.sl_equal,.sr,.sr_equal,.xor_equal,.start_heredoc,.end_heredoc,.object_operator,.paamayim_nekudotayim{color:black}.abstract,.array,.array_cast,.as,.break,.case,.catch,.class,.clone,.continue,.declare,.default,.do,.echo,.else,.elseif,.empty.enddeclare,.endfor,.endforach,.endif,.endswitch,.endwhile,.eval,.exit,.extends,.final,.for,.foreach,.function,.global,.goto,.if,.implements,.include,.include_once,.instanceof,.interface,.isset,.list,.namespace,.new,.print,.private,.public,.protected,.require,.require_once,.return,.static,.switch,.throw,.try,.unset,.use,.var,.while{color:royalblue}.open_tag,.open_tag_with_echo,.close_tag{color:orange}.ini_section{color:black}.ini_key{color:royalblue}.ini_value{color:crimson}.xml_tag{color:dodgerblue}.xml_attr{color:blueviolet}.xml_data{color:red}.section{color:black}.directive{color:blue}.data{color:dimgray} diff --git a/gui/css/flexslider.css b/gui/css/flexslider.css new file mode 100644 index 0000000..7e0066a --- /dev/null +++ b/gui/css/flexslider.css @@ -0,0 +1,101 @@ +/* + * jQuery FlexSlider v2.0 + * http://www.woothemes.com/flexslider/ + * + * Copyright 2012 WooThemes + * Free to use under the GPLv2 license. + * http://www.gnu.org/licenses/gpl-2.0.html + * + * Contributing author: Tyler Smith (@mbmufffin) + */ + + +/* Browser Resets */ +.flex-container a:active, +.flexslider a:active, +.flex-container a:focus, +.flexslider a:focus {outline: none;} +.slides, +.flex-control-nav, +.flex-direction-nav {margin: 0; padding: 0; list-style: none;} + +/* FlexSlider Necessary Styles +*********************************/ +.flexslider {margin: 0; padding: 0;} +.flexslider .slides > li {display: none; -webkit-backface-visibility: hidden; position: relative;} /* Hide the slides before the JS is loaded. Avoids image jumping */ +.flexslider .slides img {width: 100%; display: block;} +.flex-pauseplay span {text-transform: capitalize;} + +/* Clearfix for the .slides element */ +.slides:after {content: "."; display: block; clear: both; visibility: hidden; line-height: 0; height: 0;} +html[xmlns] .slides {display: block;} +* html .slides {height: 1%;} + +/* No JavaScript Fallback */ +/* If you are not using another script, such as Modernizr, make sure you + * include js that eliminates this class on page load */ +.no-js .slides > li:first-child {display: block;} + + +/* FlexSlider Default Theme +*********************************/ +.flexslider {margin: 0 0 60px; background: #fff; position: relative; zoom: 1;} +.flex-viewport {max-height: 2000px; -webkit-transition: all 1s ease; -moz-transition: all 1s ease; transition: all 1s ease;} +.loading .flex-viewport {max-height: 300px;} +.flexslider .slides {zoom: 1;} + +.carousel li {margin-right: 5px} + + +/* Direction Nav */ +.flex-direction-nav {*height: 0;} +.flex-direction-nav a {width: 30px; height: 29px; display: block; background: url(../img/slider_arrows.png) no-repeat 0 0; position: absolute; top: 48%; cursor: pointer; text-indent: -9999px;} +.flex-direction-nav .flex-next {background-position: 100% 0; right: 20px; } +.flex-direction-nav .flex-prev {left: 20px; background-position: 0 0;} +.flexslider .flex-next:hover {background-position: -30px -29px;} +.flexslider .flex-prev:hover {background-position: 0 -29px;} +.flex-direction-nav .flex-disabled {opacity: .3!important; filter:alpha(opacity=30); cursor: default;} + +/* Control Nav */ +.flex-control-nav {width: 100%; position: absolute; bottom: -40px; text-align: center;} +.flex-control-nav li {margin: 0 6px; display: inline-block; zoom: 1; *display: inline;} +.flex-control-paging li a {width: 11px; height: 11px; display: block; background: #666; background: rgba(0,0,0,0.5); cursor: pointer; text-indent: -9999px; -webkit-border-radius: 20px; -moz-border-radius: 20px; -o-border-radius: 20px; border-radius: 20px; box-shadow: inset 0 0 3px rgba(0,0,0,0.3);} +.flex-control-paging li a:hover { background: #333; background: rgba(0,0,0,0.7); } +.flex-control-paging li a.flex-active { background: #000; background: rgba(0,0,0,0.9); cursor: default; } + +.flex-control-thumbs {margin: 5px 0 0; position: static; overflow: hidden;} +.flex-control-thumbs li {width: 25%; float: left; margin: 0;} +.flex-control-thumbs img {width: 100%; display: block; opacity: .7; cursor: pointer;} +.flex-control-thumbs img:hover {opacity: 1;} +.flex-control-thumbs .flex-active {opacity: 1; cursor: default;} + +@media screen and (max-width: 860px) { + .flex-direction-nav .flex-prev {opacity: 1; left: 0;} + .flex-direction-nav .flex-next {opacity: 1; right: 0;} +} + +.slide-info { + width: 380px; + height: 85px; + position: absolute; + background: transparent url('../img/slide_info_bg.png') top left repeat; + bottom: 20px; + right: 30px; + padding: 15px 20px; +} +.slide-info h2 { + padding-bottom: 10px; +} +.slide-info h2 a { + font-size: 24px; + color: #2773ae; + text-decoration: none; + font-weight: normal; +} +.slide-info h2 a:hover { + text-decoration: underline; +} +.slide-info p { + color: #ffffff; + font-size: 14px; +} \ No newline at end of file diff --git a/gui/css/jquery.tocify.css b/gui/css/jquery.tocify.css new file mode 100644 index 0000000..c7d504e --- /dev/null +++ b/gui/css/jquery.tocify.css @@ -0,0 +1,61 @@ +/* + * jquery.tocify.css 1.3.0 + * Author: @gregfranko + */ + +/* The Table of Contents container element */ +#toc { + max-height: 90%; + overflow: auto; + position: fixed; + border: 1px solid #ccc; + webkit-border-radius: 6px; + moz-border-radius: 6px; + border-radius: 6px; + margin-left: 0; +} +#toc.bottom { + position:absolute; + bottom: 0; +} + +/* The Table of Contents is composed of multiple nested unordered lists. These styles remove the default styling of an unordered list because it is ugly. */ +#toc ul, #toc li { + list-style: none; + margin: 0; + padding: 0; + border: none; + line-height: 30px; +} + +/* Top level subheader elements. These are the first nested items underneath a header element. */ +.sub-header { + text-indent: 20px; + display: none; +} + +/* Makes the font smaller for all subheader elements. */ +.sub-header li { + font-size: 12px; +} + +/* Further indents second level subheader elements. */ +.sub-header .sub-header { + text-indent: 30px; +} + +/* Further indents third level subheader elements. You can continue this pattern if you have more nested elements. */ +.sub-header .sub-header .sub-header { + text-indent: 40px; +} + +/* Twitter Bootstrap Override Style */ +.nav-list > li > a, .nav-list .nav-header { + margin: 0px; +} + +/* Twitter Bootstrap Override Style */ +.nav-list > li > a { + line-height: 1.5em; + padding: 7px 5px 7px 15px; +} \ No newline at end of file diff --git a/gui/css/main.css b/gui/css/main.css new file mode 100644 index 0000000..776dba1 --- /dev/null +++ b/gui/css/main.css @@ -0,0 +1,506 @@ +/* font config */ +@import url(http://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic,700italic&subset=latin,latin-ext); + +body, p, input, button, select, textarea, .navbar-search .search-query { + font-family: 'Ubuntu', sans-serif; +} + +/* bootstrap override */ + +body { + padding-top: 80px; + color: #4d5357; +} + +td.center { + text-align: center; +} + +.btn:focus { + outline: none; +} + +.navbar-fixed-top .navbar-inner, +.navbar-static-top .navbar-inner { + box-shadow: none; + -webkit-box-shadow: none; + -moz-box-shadow: none; +} + +.navbar-inner { + min-height: 81px; + border: 2px solid #49a3dd; /* stroke */ + background-color: #3293d7; /* layer fill content */ + background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEwMCAxMDAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjxsaW5lYXJHcmFkaWVudCBpZD0iaGF0MCIgZ3JhZGllbnRVbml0cz0ib2JqZWN0Qm91bmRpbmdCb3giIHgxPSI1MCUiIHkxPSIxMDAlIiB4Mj0iNTAlIiB5Mj0iLTEuNDIxMDg1NDcxNTIwMmUtMTQlIj4KPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzIxNzdjNyIgc3RvcC1vcGFjaXR5PSIxIi8+CjxzdG9wIG9mZnNldD0iNjglIiBzdG9wLWNvbG9yPSIjNDU5ZmRkIiBzdG9wLW9wYWNpdHk9IjEiLz4KPHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjNGRhN2RmIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgPC9saW5lYXJHcmFkaWVudD4KCjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIiBmaWxsPSJ1cmwoI2hhdDApIiAvPgo8L3N2Zz4=); /* gradient overlay */ + background-image: -moz-linear-gradient(bottom, #2177c7 0%, #459fdd 68.04%, #4da7df 100%); /* gradient overlay */ + background-image: -o-linear-gradient(bottom, #2177c7 0%, #459fdd 68.04%, #4da7df 100%); /* gradient overlay */ + background-image: -webkit-linear-gradient(bottom, #2177c7 0%, #459fdd 68.04%, #4da7df 100%); /* gradient overlay */ + background-image: linear-gradient(bottom, #2177c7 0%, #459fdd 68.04%, #4da7df 100%); /* gradient overlay */ +} + .navbar-fixed-top .navbar-inner, .navbar-static-top .navbar-inner { + border-width: 0 0 2px; + } + +.navbar .nav > li { + line-height: 61px; +} + + .navbar .nav > li > a { + padding: 20px 15px 0px; + font-size: 1.3em; + color: #FFF; + font-weight: bold; + text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.4); + } + + .navbar .nav > .active > a, + .navbar .nav > .active > a:hover, + .navbar .nav > .active > a:focus { + font-family: Ubuntu, sans-serif; + color: #FFF; + background: url(../img/nav_active.png) repeat-x bottom left; + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; + } + + .navbar .nav > li > a:focus, + .navbar .nav > li > a:hover { + color: #FFF; + } + +/* app styles */ +.masthead { + background: url(../img/masthead_bg.png) center top repeat-x; + width: 100%; + height: 323px; + overflow: hidden; + color: #FFF; + margin-bottom: 40px; + box-sizing: border-box; +} +.masthead:after { + background: url("../img/hr.png") no-repeat scroll center top transparent; + content: ''; + height: 34px; + width: 100%; + position: absolute; + margin-top: 2px; +} + .masthead .container { + background: url(../img/header.png) center top no-repeat; + height: 323px; + } + + .masthead h1 { + font-size: 4em; + } + + .masthead h2 { + font-size: 1.4em; + line-height: 1.5em; + } + +.headTxt { + left: 165px; + margin: 0 auto; + position: relative; + top: 45px; + width: 600px; +} + + .headTxt ul { + list-style: none; + margin-left: 40px; + margin-top: 25px; + } + + .headTxt ul li { + color: #d2e1f1; + font-size: 1.4em; + line-height: 1.6em; + } + + .teaser { + padding-left: 70px; + min-height: 320px; + margin-bottom: 30px; + } + #main .teaser h3 { + margin-top: 5px; + color: #2F6185; + font-size: 1.8em; + line-height: 1.4em; + font-weight: bold; + margin-bottom: 10px; + border: none; + } + + .teaser img { + float: left; + margin-left: -70px; + } + + #main h2 { + color: #2F6185; + font-size: 1.8em; + line-height: 1.4em; + font-weight: bold; + margin-top: 40px; + margin-bottom: 15px; + } + + #main h3 { + border-bottom: 2px dotted #CCCCCC; + color: #4D5357; + font-size: 1.4em; + font-weight: bold; + line-height: 1.2em; + margin-top: 30px; + padding-bottom: 3px; + } + + #main h4 { + color: #2F6185; + font-size: 1.3em; + font-weight: normal; + line-height: 1.2em; + margin-bottom: 6px; + margin-top: 20px; + } + #main h5, + #main h6 { + font-size: 1.1em; + line-height: 1.2em; + margin-bottom: 6px; + margin-top: 16px; + } + #main h6 { + font-weight: normal; + } + + .ml10 { margin-left: 10px; } + .mr10 { margin-right: 10px; } + .mt10 { margin-top: 10px; } + .mb10 { margin-bottom: 10px; } + + hr { + height: 34px; + background: url(../img/hr.png) center top no-repeat; + border: none; + } + + #main { + min-height: 450px; + } + + #main p { + font-size: 1.125em; + line-height: 1.4em; + } + + .home .padded ul { + margin-top: 30px; + -moz-column-count: 2; + -webkit-column-count: 2; + column-count: 2; + -moz-column-gap: 40px; + -webkit-column-gap: 40px; + column-gap: 40px; + max-width: 800px; + } + + .home li { + font-size: 1.2em; + line-height: 1.6em; + color: #2e6085; + font-weight: bold; + } + + .home .padded { + padding: 0 70px; + } + +footer { + background: #252528 url(../img/footer_bg2.png); + height: 246px; + width: 100%; + color: #BBB; +} + + footer h3 { + font-size: 1.3em; + } + +/* fix scroll position on anchor links, when top nav bar is fixed */ +h1[id]:before, +h2[id]:before, +h3[id]:before, +h4[id]:before, +h5[id]:before, +h6[id]:before { + content: ""; + display: block; + height: 100px; + margin: -100px 0 0; +} + +/* wait for Javascript to show things it powers */ +#search-query, button.more { + display: none; +} + +/* code prettify */ + +div.highlight { + margin-bottom: 3ex; +} + +/* filesystem hierarchy prettify */ +ul.tree, ul.tree ul { + list-style-type: none; + background: #f5f5f5 url(../img/vline.png) repeat-y 0.5ex 0; + margin: 0; + padding: 0 0 0 0.5ex; +} + +ul.tree { + background-position: 1em 0; + padding-left: 1em; + border: 1px solid #ccc; + border: 1px solid rgba(0, 0, 0, 0.15); + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; +} + +ul.tree li { + margin: 0 4px 0 0; + padding: 0 12px; + line-height: 20px; + background: url(../img/node.png) no-repeat; +} + + ul.tree li:last-child, + ul.tree li.last { + background: #f5f5f5 url(../img/lastnode.png) no-repeat; + padding-bottom: 0.5ex; + } + +/* twitter */ +.tweets { + margin-top: 40px; + background-color: #2E6085; + padding: 20px 0 10px; + -webkit-box-shadow: 0 0 4px 2px rgba(0,0,0,0.4); + box-shadow: 0 0 4px 2px rgba(0,0,0,0.4); + min-height: 50px; +} + .twitter-wrapper { + position: relative; + padding: 10px 0 10px 0; + } + #tweetnav { + float: left; + height: auto; + position: absolute; + width: 11px; + } + #tweetnav .flex-prev { + background: url("../img/tw_arrow.png") no-repeat 0 0; + display: block; + height: 6px; + left: 0; + margin-bottom: 7px; + width: 11px; + } + #tweetnav .flex-next { + background: url("../img/tw_arrow.png") no-repeat 0 -6px; + display: block; + height: 6px; + left: 0; + width: 11px; + } + #tweetnav .flex-direction-nav a { + position: inherit; + } + + #follow_img { + position: absolute; + right: 0; + top: 16%; + } + #prev_t, + #next_t { + display: block; + color: #fff; + } + .tweets-slide { + display: block; + color: #fff; + overflow: hidden; + padding-left: 20px; + padding-right: 180px; + } + .tweets-slide li { + min-height: auto + } + +#toc.affix-bottom { + bottom: 270px; + position: absolute; + top: auto; +} + +/* Large desktop */ +@media (min-width: 1200px) { + .teaser { + min-height: 280px; + } +} + +/* Portrait tablet to landscape and desktop */ +@media (min-width: 768px) and (max-width: 979px) { + + .navbar-fixed-top { + margin-bottom: 0px !important; + } + + .masthead .container { + width: 100%; + } + + .headTxt { + font-size: 0.8em; + width: 500px; + left: 115px; + } + + .headTxt ul { + list-style: none; + margin-left: 40px; + margin-top: 40px; + } + + .headTxt ul li { + color: #d2e1f1; + font-size: 1.5em; + line-height: 1.8em; + } + + + .teaser { + padding-left: 0; + min-height: 340px; + margin-bottom: 30px; + } + + .teaser img { + float: left; + margin-left: 0; + margin-right: 10px; + } + + #main .teaser h3 { + font-size: 1.6em; + line-height: 1.2em; + } + + .home .padded { padding: 0; } +} + +/* Landscape phone to portrait tablet */ +@media (max-width: 767px) { + + .navbar-fixed-top { + margin-bottom: 0px !important; + } + + .masthead, + footer, + .tweets { + margin-left: -20px; + margin-right: -20px; + width: auto; + } + + .masthead .container { + background: url(../img/header_phone.png) center top no-repeat; + } + + footer .container { + padding: 0 20px; + } + + .headTxt { + position: static; + width: 80%; + font-size: 0.8em; + margin-top: 40px; + padding-left: 10%; + } + + .headTxt ul { + list-style: disc; + margin-left: 40px; + margin-top: 25px; + } + + .headTxt ul li { + color: #d2e1f1; + font-size: 1.4em; + line-height: 1.6em; + } + + .navbar .nav > li > a { + font-size: 1.1em; + } + + .teaser { + padding-left: 0; + min-height: 0; + margin-bottom: 20px; + } + + .teaser img { + float: left; + margin-left: 0; + margin-right: 10px; + } + + .home .padded { + padding: 0; + } + +} + +/* Landscape phones and down */ +@media (max-width: 480px) { + + .headTxt { + position: static; + width: 90%; + font-size: 0.7em; + margin-top: 40px; + padding-left: 0; + } + + .headTxt ul { + list-style: disc; + margin-left: 20px; + margin-top: 25px; + } + + .navbar .nav > li { + line-height: 40px; + } + .navbar .nav > li > a { + font-size: 0.9em; + padding: 0 5px 0; + } + + .home .padded { + padding: 0; + } + +} \ No newline at end of file diff --git a/gui/img/code.png b/gui/img/code.png new file mode 100644 index 0000000..a57bb9a Binary files /dev/null and b/gui/img/code.png differ diff --git a/gui/img/f3_fav.psd b/gui/img/f3_fav.psd new file mode 100644 index 0000000..a4ea846 Binary files /dev/null and b/gui/img/f3_fav.psd differ diff --git a/gui/img/f3_fav_144_precomposed.png b/gui/img/f3_fav_144_precomposed.png new file mode 100644 index 0000000..f05975c Binary files /dev/null and b/gui/img/f3_fav_144_precomposed.png differ diff --git a/gui/img/f3_fav_32.ico b/gui/img/f3_fav_32.ico new file mode 100644 index 0000000..6860022 Binary files /dev/null and b/gui/img/f3_fav_32.ico differ diff --git a/gui/img/f3_fav_57_precomposed.png b/gui/img/f3_fav_57_precomposed.png new file mode 100644 index 0000000..325c7cc Binary files /dev/null and b/gui/img/f3_fav_57_precomposed.png differ diff --git a/gui/img/f3_logo_ribbon.jpg b/gui/img/f3_logo_ribbon.jpg new file mode 100644 index 0000000..741182f Binary files /dev/null and b/gui/img/f3_logo_ribbon.jpg differ diff --git a/gui/img/f3_logo_ribbon2.jpg b/gui/img/f3_logo_ribbon2.jpg new file mode 100644 index 0000000..791860d Binary files /dev/null and b/gui/img/f3_logo_ribbon2.jpg differ diff --git a/gui/img/f3com_header.png b/gui/img/f3com_header.png new file mode 100644 index 0000000..bb9439c Binary files /dev/null and b/gui/img/f3com_header.png differ diff --git a/gui/img/f3com_header_smaller.png b/gui/img/f3com_header_smaller.png new file mode 100644 index 0000000..b3d6019 Binary files /dev/null and b/gui/img/f3com_header_smaller.png differ diff --git a/gui/img/f3com_header_smaller2.png b/gui/img/f3com_header_smaller2.png new file mode 100644 index 0000000..9035f0b Binary files /dev/null and b/gui/img/f3com_header_smaller2.png differ diff --git a/gui/img/f3f_icon.psd b/gui/img/f3f_icon.psd new file mode 100644 index 0000000..75136f1 Binary files /dev/null and b/gui/img/f3f_icon.psd differ diff --git a/gui/img/f3f_icon_32.ico b/gui/img/f3f_icon_32.ico new file mode 100644 index 0000000..23c8434 Binary files /dev/null and b/gui/img/f3f_icon_32.ico differ diff --git a/gui/img/f3f_icon_57.png b/gui/img/f3f_icon_57.png new file mode 100644 index 0000000..d917e63 Binary files /dev/null and b/gui/img/f3f_icon_57.png differ diff --git a/gui/img/fatfreefridge_logo.png b/gui/img/fatfreefridge_logo.png new file mode 100644 index 0000000..0aa05bf Binary files /dev/null and b/gui/img/fatfreefridge_logo.png differ diff --git a/gui/img/fatfreefridge_logo.psd b/gui/img/fatfreefridge_logo.psd new file mode 100644 index 0000000..e522c8d Binary files /dev/null and b/gui/img/fatfreefridge_logo.psd differ diff --git a/gui/img/follow.png b/gui/img/follow.png new file mode 100644 index 0000000..e7e7566 Binary files /dev/null and b/gui/img/follow.png differ diff --git a/gui/img/footer_bg.png b/gui/img/footer_bg.png new file mode 100644 index 0000000..56769d7 Binary files /dev/null and b/gui/img/footer_bg.png differ diff --git a/gui/img/footer_bg2.png b/gui/img/footer_bg2.png new file mode 100644 index 0000000..e5363ed Binary files /dev/null and b/gui/img/footer_bg2.png differ diff --git a/gui/img/gears.png b/gui/img/gears.png new file mode 100644 index 0000000..f0108f9 Binary files /dev/null and b/gui/img/gears.png differ diff --git a/gui/img/glyphicons-halflings-white.png b/gui/img/glyphicons-halflings-white.png new file mode 100644 index 0000000..3bf6484 Binary files /dev/null and b/gui/img/glyphicons-halflings-white.png differ diff --git a/gui/img/glyphicons-halflings.png b/gui/img/glyphicons-halflings.png new file mode 100644 index 0000000..a996999 Binary files /dev/null and b/gui/img/glyphicons-halflings.png differ diff --git a/gui/img/header.png b/gui/img/header.png new file mode 100644 index 0000000..ac01bfd Binary files /dev/null and b/gui/img/header.png differ diff --git a/gui/img/header_2.png b/gui/img/header_2.png new file mode 100644 index 0000000..ac01bfd Binary files /dev/null and b/gui/img/header_2.png differ diff --git a/gui/img/header_phone.png b/gui/img/header_phone.png new file mode 100644 index 0000000..462b3ff Binary files /dev/null and b/gui/img/header_phone.png differ diff --git a/gui/img/hr.png b/gui/img/hr.png new file mode 100644 index 0000000..e0a657b Binary files /dev/null and b/gui/img/hr.png differ diff --git a/gui/img/jcopy.png b/gui/img/jcopy.png new file mode 100644 index 0000000..a9f31a2 Binary files /dev/null and b/gui/img/jcopy.png differ diff --git a/gui/img/lastnode.png b/gui/img/lastnode.png new file mode 100644 index 0000000..f8809f8 Binary files /dev/null and b/gui/img/lastnode.png differ diff --git a/gui/img/lightning.png b/gui/img/lightning.png new file mode 100644 index 0000000..f4cf73f Binary files /dev/null and b/gui/img/lightning.png differ diff --git a/gui/img/logo-dark.png b/gui/img/logo-dark.png new file mode 100644 index 0000000..13d6a57 Binary files /dev/null and b/gui/img/logo-dark.png differ diff --git a/gui/img/masthead_bg.png b/gui/img/masthead_bg.png new file mode 100644 index 0000000..c36e571 Binary files /dev/null and b/gui/img/masthead_bg.png differ diff --git a/gui/img/masthead_bg2.png b/gui/img/masthead_bg2.png new file mode 100644 index 0000000..4108e7a Binary files /dev/null and b/gui/img/masthead_bg2.png differ diff --git a/gui/img/masthead_bg3.png b/gui/img/masthead_bg3.png new file mode 100644 index 0000000..c36e571 Binary files /dev/null and b/gui/img/masthead_bg3.png differ diff --git a/gui/img/nav_active.png b/gui/img/nav_active.png new file mode 100644 index 0000000..bbf23f3 Binary files /dev/null and b/gui/img/nav_active.png differ diff --git a/gui/img/nav_bg.png b/gui/img/nav_bg.png new file mode 100644 index 0000000..140a912 Binary files /dev/null and b/gui/img/nav_bg.png differ diff --git a/gui/img/node.png b/gui/img/node.png new file mode 100644 index 0000000..29f6c44 Binary files /dev/null and b/gui/img/node.png differ diff --git a/gui/img/rocket.png b/gui/img/rocket.png new file mode 100644 index 0000000..9a87c54 Binary files /dev/null and b/gui/img/rocket.png differ diff --git a/gui/img/supported_dbs.jpg b/gui/img/supported_dbs.jpg new file mode 100644 index 0000000..c0bc8df Binary files /dev/null and b/gui/img/supported_dbs.jpg differ diff --git a/gui/img/tw_arrow.png b/gui/img/tw_arrow.png new file mode 100644 index 0000000..ad8ce50 Binary files /dev/null and b/gui/img/tw_arrow.png differ diff --git a/gui/img/vline.png b/gui/img/vline.png new file mode 100644 index 0000000..4c9bc6d Binary files /dev/null and b/gui/img/vline.png differ diff --git a/gui/inc/ZeroClipboard.swf b/gui/inc/ZeroClipboard.swf new file mode 100644 index 0000000..13bf8e3 Binary files /dev/null and b/gui/inc/ZeroClipboard.swf differ diff --git a/gui/js/bootstrap.min.js b/gui/js/bootstrap.min.js new file mode 100644 index 0000000..95c5ac5 --- /dev/null +++ b/gui/js/bootstrap.min.js @@ -0,0 +1,6 @@ +/*! +* Bootstrap.js by @fat & @mdo +* Copyright 2012 Twitter, Inc. +* http://www.apache.org/licenses/LICENSE-2.0.txt +*/ +!function(e){"use strict";e(function(){e.support.transition=function(){var e=function(){var e=document.createElement("bootstrap"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},n;for(n in t)if(e.style[n]!==undefined)return t[n]}();return e&&{end:e}}()})}(window.jQuery),!function(e){"use strict";var t='[data-dismiss="alert"]',n=function(n){e(n).on("click",t,this.close)};n.prototype.close=function(t){function s(){i.trigger("closed").remove()}var n=e(this),r=n.attr("data-target"),i;r||(r=n.attr("href"),r=r&&r.replace(/.*(?=#[^\s]*$)/,"")),i=e(r),t&&t.preventDefault(),i.length||(i=n.hasClass("alert")?n:n.parent()),i.trigger(t=e.Event("close"));if(t.isDefaultPrevented())return;i.removeClass("in"),e.support.transition&&i.hasClass("fade")?i.on(e.support.transition.end,s):s()};var r=e.fn.alert;e.fn.alert=function(t){return this.each(function(){var r=e(this),i=r.data("alert");i||r.data("alert",i=new n(this)),typeof t=="string"&&i[t].call(r)})},e.fn.alert.Constructor=n,e.fn.alert.noConflict=function(){return e.fn.alert=r,this},e(document).on("click.alert.data-api",t,n.prototype.close)}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.button.defaults,n)};t.prototype.setState=function(e){var t="disabled",n=this.$element,r=n.data(),i=n.is("input")?"val":"html";e+="Text",r.resetText||n.data("resetText",n[i]()),n[i](r[e]||this.options[e]),setTimeout(function(){e=="loadingText"?n.addClass(t).attr(t,t):n.removeClass(t).removeAttr(t)},0)},t.prototype.toggle=function(){var e=this.$element.closest('[data-toggle="buttons-radio"]');e&&e.find(".active").removeClass("active"),this.$element.toggleClass("active")};var n=e.fn.button;e.fn.button=function(n){return this.each(function(){var r=e(this),i=r.data("button"),s=typeof n=="object"&&n;i||r.data("button",i=new t(this,s)),n=="toggle"?i.toggle():n&&i.setState(n)})},e.fn.button.defaults={loadingText:"loading..."},e.fn.button.Constructor=t,e.fn.button.noConflict=function(){return e.fn.button=n,this},e(document).on("click.button.data-api","[data-toggle^=button]",function(t){var n=e(t.target);n.hasClass("btn")||(n=n.closest(".btn")),n.button("toggle")})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.$indicators=this.$element.find(".carousel-indicators"),this.options=n,this.options.pause=="hover"&&this.$element.on("mouseenter",e.proxy(this.pause,this)).on("mouseleave",e.proxy(this.cycle,this))};t.prototype={cycle:function(t){return t||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(e.proxy(this.next,this),this.options.interval)),this},getActiveIndex:function(){return this.$active=this.$element.find(".item.active"),this.$items=this.$active.parent().children(),this.$items.index(this.$active)},to:function(t){var n=this.getActiveIndex(),r=this;if(t>this.$items.length-1||t<0)return;return this.sliding?this.$element.one("slid",function(){r.to(t)}):n==t?this.pause().cycle():this.slide(t>n?"next":"prev",e(this.$items[t]))},pause:function(t){return t||(this.paused=!0),this.$element.find(".next, .prev").length&&e.support.transition.end&&(this.$element.trigger(e.support.transition.end),this.cycle(!0)),clearInterval(this.interval),this.interval=null,this},next:function(){if(this.sliding)return;return this.slide("next")},prev:function(){if(this.sliding)return;return this.slide("prev")},slide:function(t,n){var r=this.$element.find(".item.active"),i=n||r[t](),s=this.interval,o=t=="next"?"left":"right",u=t=="next"?"first":"last",a=this,f;this.sliding=!0,s&&this.pause(),i=i.length?i:this.$element.find(".item")[u](),f=e.Event("slide",{relatedTarget:i[0],direction:o});if(i.hasClass("active"))return;this.$indicators.length&&(this.$indicators.find(".active").removeClass("active"),this.$element.one("slid",function(){var t=e(a.$indicators.children()[a.getActiveIndex()]);t&&t.addClass("active")}));if(e.support.transition&&this.$element.hasClass("slide")){this.$element.trigger(f);if(f.isDefaultPrevented())return;i.addClass(t),i[0].offsetWidth,r.addClass(o),i.addClass(o),this.$element.one(e.support.transition.end,function(){i.removeClass([t,o].join(" ")).addClass("active"),r.removeClass(["active",o].join(" ")),a.sliding=!1,setTimeout(function(){a.$element.trigger("slid")},0)})}else{this.$element.trigger(f);if(f.isDefaultPrevented())return;r.removeClass("active"),i.addClass("active"),this.sliding=!1,this.$element.trigger("slid")}return s&&this.cycle(),this}};var n=e.fn.carousel;e.fn.carousel=function(n){return this.each(function(){var r=e(this),i=r.data("carousel"),s=e.extend({},e.fn.carousel.defaults,typeof n=="object"&&n),o=typeof n=="string"?n:s.slide;i||r.data("carousel",i=new t(this,s)),typeof n=="number"?i.to(n):o?i[o]():s.interval&&i.pause().cycle()})},e.fn.carousel.defaults={interval:5e3,pause:"hover"},e.fn.carousel.Constructor=t,e.fn.carousel.noConflict=function(){return e.fn.carousel=n,this},e(document).on("click.carousel.data-api","[data-slide], [data-slide-to]",function(t){var n=e(this),r,i=e(n.attr("data-target")||(r=n.attr("href"))&&r.replace(/.*(?=#[^\s]+$)/,"")),s=e.extend({},i.data(),n.data()),o;i.carousel(s),(o=n.attr("data-slide-to"))&&i.data("carousel").pause().to(o).cycle(),t.preventDefault()})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.collapse.defaults,n),this.options.parent&&(this.$parent=e(this.options.parent)),this.options.toggle&&this.toggle()};t.prototype={constructor:t,dimension:function(){var e=this.$element.hasClass("width");return e?"width":"height"},show:function(){var t,n,r,i;if(this.transitioning||this.$element.hasClass("in"))return;t=this.dimension(),n=e.camelCase(["scroll",t].join("-")),r=this.$parent&&this.$parent.find("> .accordion-group > .in");if(r&&r.length){i=r.data("collapse");if(i&&i.transitioning)return;r.collapse("hide"),i||r.data("collapse",null)}this.$element[t](0),this.transition("addClass",e.Event("show"),"shown"),e.support.transition&&this.$element[t](this.$element[0][n])},hide:function(){var t;if(this.transitioning||!this.$element.hasClass("in"))return;t=this.dimension(),this.reset(this.$element[t]()),this.transition("removeClass",e.Event("hide"),"hidden"),this.$element[t](0)},reset:function(e){var t=this.dimension();return this.$element.removeClass("collapse")[t](e||"auto")[0].offsetWidth,this.$element[e!==null?"addClass":"removeClass"]("collapse"),this},transition:function(t,n,r){var i=this,s=function(){n.type=="show"&&i.reset(),i.transitioning=0,i.$element.trigger(r)};this.$element.trigger(n);if(n.isDefaultPrevented())return;this.transitioning=1,this.$element[t]("in"),e.support.transition&&this.$element.hasClass("collapse")?this.$element.one(e.support.transition.end,s):s()},toggle:function(){this[this.$element.hasClass("in")?"hide":"show"]()}};var n=e.fn.collapse;e.fn.collapse=function(n){return this.each(function(){var r=e(this),i=r.data("collapse"),s=e.extend({},e.fn.collapse.defaults,r.data(),typeof n=="object"&&n);i||r.data("collapse",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.collapse.defaults={toggle:!0},e.fn.collapse.Constructor=t,e.fn.collapse.noConflict=function(){return e.fn.collapse=n,this},e(document).on("click.collapse.data-api","[data-toggle=collapse]",function(t){var n=e(this),r,i=n.attr("data-target")||t.preventDefault()||(r=n.attr("href"))&&r.replace(/.*(?=#[^\s]+$)/,""),s=e(i).data("collapse")?"toggle":n.data();n[e(i).hasClass("in")?"addClass":"removeClass"]("collapsed"),e(i).collapse(s)})}(window.jQuery),!function(e){"use strict";function r(){e(t).each(function(){i(e(this)).removeClass("open")})}function i(t){var n=t.attr("data-target"),r;n||(n=t.attr("href"),n=n&&/#/.test(n)&&n.replace(/.*(?=#[^\s]*$)/,"")),r=n&&e(n);if(!r||!r.length)r=t.parent();return r}var t="[data-toggle=dropdown]",n=function(t){var n=e(t).on("click.dropdown.data-api",this.toggle);e("html").on("click.dropdown.data-api",function(){n.parent().removeClass("open")})};n.prototype={constructor:n,toggle:function(t){var n=e(this),s,o;if(n.is(".disabled, :disabled"))return;return s=i(n),o=s.hasClass("open"),r(),o||s.toggleClass("open"),n.focus(),!1},keydown:function(n){var r,s,o,u,a,f;if(!/(38|40|27)/.test(n.keyCode))return;r=e(this),n.preventDefault(),n.stopPropagation();if(r.is(".disabled, :disabled"))return;u=i(r),a=u.hasClass("open");if(!a||a&&n.keyCode==27)return n.which==27&&u.find(t).focus(),r.click();s=e("[role=menu] li:not(.divider):visible a",u);if(!s.length)return;f=s.index(s.filter(":focus")),n.keyCode==38&&f>0&&f--,n.keyCode==40&&f').appendTo(document.body),this.$backdrop.click(this.options.backdrop=="static"?e.proxy(this.$element[0].focus,this.$element[0]):e.proxy(this.hide,this)),i&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in");if(!t)return;i?this.$backdrop.one(e.support.transition.end,t):t()}else!this.isShown&&this.$backdrop?(this.$backdrop.removeClass("in"),e.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one(e.support.transition.end,t):t()):t&&t()}};var n=e.fn.modal;e.fn.modal=function(n){return this.each(function(){var r=e(this),i=r.data("modal"),s=e.extend({},e.fn.modal.defaults,r.data(),typeof n=="object"&&n);i||r.data("modal",i=new t(this,s)),typeof n=="string"?i[n]():s.show&&i.show()})},e.fn.modal.defaults={backdrop:!0,keyboard:!0,show:!0},e.fn.modal.Constructor=t,e.fn.modal.noConflict=function(){return e.fn.modal=n,this},e(document).on("click.modal.data-api",'[data-toggle="modal"]',function(t){var n=e(this),r=n.attr("href"),i=e(n.attr("data-target")||r&&r.replace(/.*(?=#[^\s]+$)/,"")),s=i.data("modal")?"toggle":e.extend({remote:!/#/.test(r)&&r},i.data(),n.data());t.preventDefault(),i.modal(s).one("hide",function(){n.focus()})})}(window.jQuery),!function(e){"use strict";var t=function(e,t){this.init("tooltip",e,t)};t.prototype={constructor:t,init:function(t,n,r){var i,s,o,u,a;this.type=t,this.$element=e(n),this.options=this.getOptions(r),this.enabled=!0,o=this.options.trigger.split(" ");for(a=o.length;a--;)u=o[a],u=="click"?this.$element.on("click."+this.type,this.options.selector,e.proxy(this.toggle,this)):u!="manual"&&(i=u=="hover"?"mouseenter":"focus",s=u=="hover"?"mouseleave":"blur",this.$element.on(i+"."+this.type,this.options.selector,e.proxy(this.enter,this)),this.$element.on(s+"."+this.type,this.options.selector,e.proxy(this.leave,this)));this.options.selector?this._options=e.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},getOptions:function(t){return t=e.extend({},e.fn[this.type].defaults,this.$element.data(),t),t.delay&&typeof t.delay=="number"&&(t.delay={show:t.delay,hide:t.delay}),t},enter:function(t){var n=e.fn[this.type].defaults,r={},i;this._options&&e.each(this._options,function(e,t){n[e]!=t&&(r[e]=t)},this),i=e(t.currentTarget)[this.type](r).data(this.type);if(!i.options.delay||!i.options.delay.show)return i.show();clearTimeout(this.timeout),i.hoverState="in",this.timeout=setTimeout(function(){i.hoverState=="in"&&i.show()},i.options.delay.show)},leave:function(t){var n=e(t.currentTarget)[this.type](this._options).data(this.type);this.timeout&&clearTimeout(this.timeout);if(!n.options.delay||!n.options.delay.hide)return n.hide();n.hoverState="out",this.timeout=setTimeout(function(){n.hoverState=="out"&&n.hide()},n.options.delay.hide)},show:function(){var t,n,r,i,s,o,u=e.Event("show");if(this.hasContent()&&this.enabled){this.$element.trigger(u);if(u.isDefaultPrevented())return;t=this.tip(),this.setContent(),this.options.animation&&t.addClass("fade"),s=typeof this.options.placement=="function"?this.options.placement.call(this,t[0],this.$element[0]):this.options.placement,t.detach().css({top:0,left:0,display:"block"}),this.options.container?t.appendTo(this.options.container):t.insertAfter(this.$element),n=this.getPosition(),r=t[0].offsetWidth,i=t[0].offsetHeight;switch(s){case"bottom":o={top:n.top+n.height,left:n.left+n.width/2-r/2};break;case"top":o={top:n.top-i,left:n.left+n.width/2-r/2};break;case"left":o={top:n.top+n.height/2-i/2,left:n.left-r};break;case"right":o={top:n.top+n.height/2-i/2,left:n.left+n.width}}this.applyPlacement(o,s),this.$element.trigger("shown")}},applyPlacement:function(e,t){var n=this.tip(),r=n[0].offsetWidth,i=n[0].offsetHeight,s,o,u,a;n.offset(e).addClass(t).addClass("in"),s=n[0].offsetWidth,o=n[0].offsetHeight,t=="top"&&o!=i&&(e.top=e.top+i-o,a=!0),t=="bottom"||t=="top"?(u=0,e.left<0&&(u=e.left*-2,e.left=0,n.offset(e),s=n[0].offsetWidth,o=n[0].offsetHeight),this.replaceArrow(u-r+s,s,"left")):this.replaceArrow(o-i,o,"top"),a&&n.offset(e)},replaceArrow:function(e,t,n){this.arrow().css(n,e?50*(1-e/t)+"%":"")},setContent:function(){var e=this.tip(),t=this.getTitle();e.find(".tooltip-inner")[this.options.html?"html":"text"](t),e.removeClass("fade in top bottom left right")},hide:function(){function i(){var t=setTimeout(function(){n.off(e.support.transition.end).detach()},500);n.one(e.support.transition.end,function(){clearTimeout(t),n.detach()})}var t=this,n=this.tip(),r=e.Event("hide");this.$element.trigger(r);if(r.isDefaultPrevented())return;return n.removeClass("in"),e.support.transition&&this.$tip.hasClass("fade")?i():n.detach(),this.$element.trigger("hidden"),this},fixTitle:function(){var e=this.$element;(e.attr("title")||typeof e.attr("data-original-title")!="string")&&e.attr("data-original-title",e.attr("title")||"").attr("title","")},hasContent:function(){return this.getTitle()},getPosition:function(){var t=this.$element[0];return e.extend({},typeof t.getBoundingClientRect=="function"?t.getBoundingClientRect():{width:t.offsetWidth,height:t.offsetHeight},this.$element.offset())},getTitle:function(){var e,t=this.$element,n=this.options;return e=t.attr("data-original-title")||(typeof n.title=="function"?n.title.call(t[0]):n.title),e},tip:function(){return this.$tip=this.$tip||e(this.options.template)},arrow:function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},validate:function(){this.$element[0].parentNode||(this.hide(),this.$element=null,this.options=null)},enable:function(){this.enabled=!0},disable:function(){this.enabled=!1},toggleEnabled:function(){this.enabled=!this.enabled},toggle:function(t){var n=t?e(t.currentTarget)[this.type](this._options).data(this.type):this;n.tip().hasClass("in")?n.hide():n.show()},destroy:function(){this.hide().$element.off("."+this.type).removeData(this.type)}};var n=e.fn.tooltip;e.fn.tooltip=function(n){return this.each(function(){var r=e(this),i=r.data("tooltip"),s=typeof n=="object"&&n;i||r.data("tooltip",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.tooltip.Constructor=t,e.fn.tooltip.defaults={animation:!0,placement:"top",selector:!1,template:'
',trigger:"hover focus",title:"",delay:0,html:!1,container:!1},e.fn.tooltip.noConflict=function(){return e.fn.tooltip=n,this}}(window.jQuery),!function(e){"use strict";var t=function(e,t){this.init("popover",e,t)};t.prototype=e.extend({},e.fn.tooltip.Constructor.prototype,{constructor:t,setContent:function(){var e=this.tip(),t=this.getTitle(),n=this.getContent();e.find(".popover-title")[this.options.html?"html":"text"](t),e.find(".popover-content")[this.options.html?"html":"text"](n),e.removeClass("fade top bottom left right in")},hasContent:function(){return this.getTitle()||this.getContent()},getContent:function(){var e,t=this.$element,n=this.options;return e=(typeof n.content=="function"?n.content.call(t[0]):n.content)||t.attr("data-content"),e},tip:function(){return this.$tip||(this.$tip=e(this.options.template)),this.$tip},destroy:function(){this.hide().$element.off("."+this.type).removeData(this.type)}});var n=e.fn.popover;e.fn.popover=function(n){return this.each(function(){var r=e(this),i=r.data("popover"),s=typeof n=="object"&&n;i||r.data("popover",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.popover.Constructor=t,e.fn.popover.defaults=e.extend({},e.fn.tooltip.defaults,{placement:"right",trigger:"click",content:"",template:'

'}),e.fn.popover.noConflict=function(){return e.fn.popover=n,this}}(window.jQuery),!function(e){"use strict";function t(t,n){var r=e.proxy(this.process,this),i=e(t).is("body")?e(window):e(t),s;this.options=e.extend({},e.fn.scrollspy.defaults,n),this.$scrollElement=i.on("scroll.scroll-spy.data-api",r),this.selector=(this.options.target||(s=e(t).attr("href"))&&s.replace(/.*(?=#[^\s]+$)/,"")||"")+" .nav li > a",this.$body=e("body"),this.refresh(),this.process()}t.prototype={constructor:t,refresh:function(){var t=this,n;this.offsets=e([]),this.targets=e([]),n=this.$body.find(this.selector).map(function(){var n=e(this),r=n.data("target")||n.attr("href"),i=/^#\w/.test(r)&&e(r);return i&&i.length&&[[i.position().top+(!e.isWindow(t.$scrollElement.get(0))&&t.$scrollElement.scrollTop()),r]]||null}).sort(function(e,t){return e[0]-t[0]}).each(function(){t.offsets.push(this[0]),t.targets.push(this[1])})},process:function(){var e=this.$scrollElement.scrollTop()+this.options.offset,t=this.$scrollElement[0].scrollHeight||this.$body[0].scrollHeight,n=t-this.$scrollElement.height(),r=this.offsets,i=this.targets,s=this.activeTarget,o;if(e>=n)return s!=(o=i.last()[0])&&this.activate(o);for(o=r.length;o--;)s!=i[o]&&e>=r[o]&&(!r[o+1]||e<=r[o+1])&&this.activate(i[o])},activate:function(t){var n,r;this.activeTarget=t,e(this.selector).parent(".active").removeClass("active"),r=this.selector+'[data-target="'+t+'"],'+this.selector+'[href="'+t+'"]',n=e(r).parent("li").addClass("active"),n.parent(".dropdown-menu").length&&(n=n.closest("li.dropdown").addClass("active")),n.trigger("activate")}};var n=e.fn.scrollspy;e.fn.scrollspy=function(n){return this.each(function(){var r=e(this),i=r.data("scrollspy"),s=typeof n=="object"&&n;i||r.data("scrollspy",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.scrollspy.Constructor=t,e.fn.scrollspy.defaults={offset:10},e.fn.scrollspy.noConflict=function(){return e.fn.scrollspy=n,this},e(window).on("load",function(){e('[data-spy="scroll"]').each(function(){var t=e(this);t.scrollspy(t.data())})})}(window.jQuery),!function(e){"use strict";var t=function(t){this.element=e(t)};t.prototype={constructor:t,show:function(){var t=this.element,n=t.closest("ul:not(.dropdown-menu)"),r=t.attr("data-target"),i,s,o;r||(r=t.attr("href"),r=r&&r.replace(/.*(?=#[^\s]*$)/,""));if(t.parent("li").hasClass("active"))return;i=n.find(".active:last a")[0],o=e.Event("show",{relatedTarget:i}),t.trigger(o);if(o.isDefaultPrevented())return;s=e(r),this.activate(t.parent("li"),n),this.activate(s,s.parent(),function(){t.trigger({type:"shown",relatedTarget:i})})},activate:function(t,n,r){function o(){i.removeClass("active").find("> .dropdown-menu > .active").removeClass("active"),t.addClass("active"),s?(t[0].offsetWidth,t.addClass("in")):t.removeClass("fade"),t.parent(".dropdown-menu")&&t.closest("li.dropdown").addClass("active"),r&&r()}var i=n.find("> .active"),s=r&&e.support.transition&&i.hasClass("fade");s?i.one(e.support.transition.end,o):o(),i.removeClass("in")}};var n=e.fn.tab;e.fn.tab=function(n){return this.each(function(){var r=e(this),i=r.data("tab");i||r.data("tab",i=new t(this)),typeof n=="string"&&i[n]()})},e.fn.tab.Constructor=t,e.fn.tab.noConflict=function(){return e.fn.tab=n,this},e(document).on("click.tab.data-api",'[data-toggle="tab"], [data-toggle="pill"]',function(t){t.preventDefault(),e(this).tab("show")})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.typeahead.defaults,n),this.matcher=this.options.matcher||this.matcher,this.sorter=this.options.sorter||this.sorter,this.highlighter=this.options.highlighter||this.highlighter,this.updater=this.options.updater||this.updater,this.source=this.options.source,this.$menu=e(this.options.menu),this.shown=!1,this.listen()};t.prototype={constructor:t,select:function(){var e=this.$menu.find(".active").attr("data-value");return this.$element.val(this.updater(e)).change(),this.hide()},updater:function(e){return e},show:function(){var t=e.extend({},this.$element.position(),{height:this.$element[0].offsetHeight});return this.$menu.insertAfter(this.$element).css({top:t.top+t.height,left:t.left}).show(),this.shown=!0,this},hide:function(){return this.$menu.hide(),this.shown=!1,this},lookup:function(t){var n;return this.query=this.$element.val(),!this.query||this.query.length"+t+""})},render:function(t){var n=this;return t=e(t).map(function(t,r){return t=e(n.options.item).attr("data-value",r),t.find("a").html(n.highlighter(r)),t[0]}),t.first().addClass("active"),this.$menu.html(t),this},next:function(t){var n=this.$menu.find(".active").removeClass("active"),r=n.next();r.length||(r=e(this.$menu.find("li")[0])),r.addClass("active")},prev:function(e){var t=this.$menu.find(".active").removeClass("active"),n=t.prev();n.length||(n=this.$menu.find("li").last()),n.addClass("active")},listen:function(){this.$element.on("focus",e.proxy(this.focus,this)).on("blur",e.proxy(this.blur,this)).on("keypress",e.proxy(this.keypress,this)).on("keyup",e.proxy(this.keyup,this)),this.eventSupported("keydown")&&this.$element.on("keydown",e.proxy(this.keydown,this)),this.$menu.on("click",e.proxy(this.click,this)).on("mouseenter","li",e.proxy(this.mouseenter,this)).on("mouseleave","li",e.proxy(this.mouseleave,this))},eventSupported:function(e){var t=e in this.$element;return t||(this.$element.setAttribute(e,"return;"),t=typeof this.$element[e]=="function"),t},move:function(e){if(!this.shown)return;switch(e.keyCode){case 9:case 13:case 27:e.preventDefault();break;case 38:e.preventDefault(),this.prev();break;case 40:e.preventDefault(),this.next()}e.stopPropagation()},keydown:function(t){this.suppressKeyPressRepeat=~e.inArray(t.keyCode,[40,38,9,13,27]),this.move(t)},keypress:function(e){if(this.suppressKeyPressRepeat)return;this.move(e)},keyup:function(e){switch(e.keyCode){case 40:case 38:case 16:case 17:case 18:break;case 9:case 13:if(!this.shown)return;this.select();break;case 27:if(!this.shown)return;this.hide();break;default:this.lookup()}e.stopPropagation(),e.preventDefault()},focus:function(e){this.focused=!0},blur:function(e){this.focused=!1,!this.mousedover&&this.shown&&this.hide()},click:function(e){e.stopPropagation(),e.preventDefault(),this.select(),this.$element.focus()},mouseenter:function(t){this.mousedover=!0,this.$menu.find(".active").removeClass("active"),e(t.currentTarget).addClass("active")},mouseleave:function(e){this.mousedover=!1,!this.focused&&this.shown&&this.hide()}};var n=e.fn.typeahead;e.fn.typeahead=function(n){return this.each(function(){var r=e(this),i=r.data("typeahead"),s=typeof n=="object"&&n;i||r.data("typeahead",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.typeahead.defaults={source:[],items:8,menu:'',item:'
  • ',minLength:1},e.fn.typeahead.Constructor=t,e.fn.typeahead.noConflict=function(){return e.fn.typeahead=n,this},e(document).on("focus.typeahead.data-api",'[data-provide="typeahead"]',function(t){var n=e(this);if(n.data("typeahead"))return;n.typeahead(n.data())})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.options=e.extend({},e.fn.affix.defaults,n),this.$window=e(window).on("scroll.affix.data-api",e.proxy(this.checkPosition,this)).on("click.affix.data-api",e.proxy(function(){setTimeout(e.proxy(this.checkPosition,this),1)},this)),this.$element=e(t),this.checkPosition()};t.prototype.checkPosition=function(){if(!this.$element.is(":visible"))return;var t=e(document).height(),n=this.$window.scrollTop(),r=this.$element.offset(),i=this.options.offset,s=i.bottom,o=i.top,u="affix affix-top affix-bottom",a;typeof i!="object"&&(s=o=i),typeof o=="function"&&(o=i.top()),typeof s=="function"&&(s=i.bottom()),a=this.unpin!=null&&n+this.unpin<=r.top?!1:s!=null&&r.top+this.$element.height()>=t-s?"bottom":o!=null&&n<=o?"top":!1;if(this.affixed===a)return;this.affixed=a,this.unpin=a=="bottom"?r.top-n:null,this.$element.removeClass(u).addClass("affix"+(a?"-"+a:""))};var n=e.fn.affix;e.fn.affix=function(n){return this.each(function(){var r=e(this),i=r.data("affix"),s=typeof n=="object"&&n;i||r.data("affix",i=new t(this,s)),typeof n=="string"&&i[n]()})},e.fn.affix.Constructor=t,e.fn.affix.defaults={offset:0},e.fn.affix.noConflict=function(){return e.fn.affix=n,this},e(window).on("load",function(){e('[data-spy="affix"]').each(function(){var t=e(this),n=t.data();n.offset=n.offset||{},n.offsetBottom&&(n.offset.bottom=n.offsetBottom),n.offsetTop&&(n.offset.top=n.offsetTop),t.affix(n)})})}(window.jQuery); \ No newline at end of file diff --git a/gui/js/jquery-1.7.1.min.js b/gui/js/jquery-1.7.1.min.js new file mode 100644 index 0000000..8305ef3 --- /dev/null +++ b/gui/js/jquery-1.7.1.min.js @@ -0,0 +1,4 @@ +/*! jQuery v1.7.1 jquery.com | jquery.org/license */ +(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!ck[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cl||(cl=c.createElement("iframe"),cl.frameBorder=cl.width=cl.height=0),b.appendChild(cl);if(!cm||!cl.createElement)cm=(cl.contentWindow||cl.contentDocument).document,cm.write((c.compatMode==="CSS1Compat"?"":"")+""),cm.close();d=cm.createElement(a),cm.body.appendChild(d),e=f.css(d,"display"),b.removeChild(cl)}ck[a]=e}return ck[a]}function cu(a,b){var c={};f.each(cq.concat.apply([],cq.slice(0,b)),function(){c[this]=a});return c}function ct(){cr=b}function cs(){setTimeout(ct,0);return cr=f.now()}function cj(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ci(){try{return new a.XMLHttpRequest}catch(b){}}function cc(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;g=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?parseFloat(d):j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.1",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c
    a",d=q.getElementsByTagName("*"),e=q.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=q.getElementsByTagName("input")[0],b={leadingWhitespace:q.firstChild.nodeType===3,tbody:!q.getElementsByTagName("tbody").length,htmlSerialize:!!q.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:q.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete q.test}catch(s){b.deleteExpando=!1}!q.addEventListener&&q.attachEvent&&q.fireEvent&&(q.attachEvent("onclick",function(){b.noCloneEvent=!1}),q.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),q.appendChild(i),k=c.createDocumentFragment(),k.appendChild(q.lastChild),b.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,k.removeChild(i),k.appendChild(q),q.innerHTML="",a.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",q.style.width="2px",q.appendChild(j),b.reliableMarginRight=(parseInt((a.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0);if(q.attachEvent)for(o in{submit:1,change:1,focusin:1})n="on"+o,p=n in q,p||(q.setAttribute(n,"return;"),p=typeof q[n]=="function"),b[o+"Bubbles"]=p;k.removeChild(q),k=g=h=j=q=i=null,f(function(){var a,d,e,g,h,i,j,k,m,n,o,r=c.getElementsByTagName("body")[0];!r||(j=1,k="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",m="visibility:hidden;border:0;",n="style='"+k+"border:5px solid #000;padding:0;'",o="
    "+""+"
    ",a=c.createElement("div"),a.style.cssText=m+"width:0;height:0;position:static;top:0;margin-top:"+j+"px",r.insertBefore(a,r.firstChild),q=c.createElement("div"),a.appendChild(q),q.innerHTML="
    t
    ",l=q.getElementsByTagName("td"),p=l[0].offsetHeight===0,l[0].style.display="",l[1].style.display="none",b.reliableHiddenOffsets=p&&l[0].offsetHeight===0,q.innerHTML="",q.style.width=q.style.paddingLeft="1px",f.boxModel=b.boxModel=q.offsetWidth===2,typeof q.style.zoom!="undefined"&&(q.style.display="inline",q.style.zoom=1,b.inlineBlockNeedsLayout=q.offsetWidth===2,q.style.display="",q.innerHTML="
    ",b.shrinkWrapBlocks=q.offsetWidth!==2),q.style.cssText=k+m,q.innerHTML=o,d=q.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,i={doesNotAddBorder:e.offsetTop!==5,doesAddBorderForTableAndCells:h.offsetTop===5},e.style.position="fixed",e.style.top="20px",i.fixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",i.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,i.doesNotIncludeMarginInBodyOffset=r.offsetTop!==j,r.removeChild(a),q=a=null,f.extend(b,i))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.nodeName.toLowerCase()]||f.valHooks[g.type];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;h=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/\bhover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")}; +f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&i.push({elem:this,matches:d.slice(e)});for(j=0;j0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

    ";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
    ";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/",""],legend:[1,"
    ","
    "],thead:[1,"","
    "],tr:[2,"","
    "],td:[3,"","
    "],col:[2,"","
    "],area:[1,"",""],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
    ","
    "]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function() +{for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||!bc.test("<"+a.nodeName)?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");b===c?bh.appendChild(o):U(b).appendChild(o),o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return br.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bq,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bq.test(g)?g.replace(bq,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bz(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bA=function(a,b){var c,d,e;b=b.replace(bs,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b)));return c}),c.documentElement.currentStyle&&(bB=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f===null&&g&&(e=g[b])&&(f=e),!bt.test(f)&&bu.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f||0,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),bz=bA||bB,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bD=/%20/g,bE=/\[\]$/,bF=/\r?\n/g,bG=/#.*$/,bH=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bI=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bJ=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bK=/^(?:GET|HEAD)$/,bL=/^\/\//,bM=/\?/,bN=/)<[^<]*)*<\/script>/gi,bO=/^(?:select|textarea)/i,bP=/\s+/,bQ=/([?&])_=[^&]*/,bR=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bS=f.fn.load,bT={},bU={},bV,bW,bX=["*/"]+["*"];try{bV=e.href}catch(bY){bV=c.createElement("a"),bV.href="",bV=bV.href}bW=bR.exec(bV.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bS)return bS.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
    ").append(c.replace(bN,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bO.test(this.nodeName)||bI.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bF,"\r\n")}}):{name:b.name,value:c.replace(bF,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b_(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b_(a,b);return a},ajaxSettings:{url:bV,isLocal:bJ.test(bW[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bX},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bZ(bT),ajaxTransport:bZ(bU),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?cb(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cc(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bH.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bG,"").replace(bL,bW[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bP),d.crossDomain==null&&(r=bR.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bW[1]&&r[2]==bW[2]&&(r[3]||(r[1]==="http:"?80:443))==(bW[3]||(bW[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),b$(bT,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bK.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bM.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bQ,"$1_="+x);d.url=y+(y===d.url?(bM.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bX+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=b$(bU,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)ca(g,a[g],c,e);return d.join("&").replace(bD,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cd=f.now(),ce=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cd++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ce.test(b.url)||e&&ce.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ce,l),b.url===j&&(e&&(k=k.replace(ce,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cf=a.ActiveXObject?function(){for(var a in ch)ch[a](0,1)}:!1,cg=0,ch;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ci()||cj()}:ci,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cf&&delete ch[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cg,cf&&(ch||(ch={},f(a).unload(cf)),ch[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var ck={},cl,cm,cn=/^(?:toggle|show|hide)$/,co=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cp,cq=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cr;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cu("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cy(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cy(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,d,"padding")):this[d]():null},f.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,d,a?"margin":"border")):this[d]():null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNumeric(j)?j:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window); \ No newline at end of file diff --git a/gui/js/jquery-ui-1.9.2.custom.min.js b/gui/js/jquery-ui-1.9.2.custom.min.js new file mode 100644 index 0000000..9813224 --- /dev/null +++ b/gui/js/jquery-ui-1.9.2.custom.min.js @@ -0,0 +1,6 @@ +/*! jQuery UI - v1.9.2 - 2013-03-20 +* http://jqueryui.com +* Includes: jquery.ui.widget.js +* Copyright 2013 jQuery Foundation and other contributors Licensed MIT */ + +(function(e,t){var n=0,r=Array.prototype.slice,i=e.cleanData;e.cleanData=function(t){for(var n=0,r;(r=t[n])!=null;n++)try{e(r).triggerHandler("remove")}catch(s){}i(t)},e.widget=function(t,n,r){var i,s,o,u,a=t.split(".")[0];t=t.split(".")[1],i=a+"-"+t,r||(r=n,n=e.Widget),e.expr[":"][i.toLowerCase()]=function(t){return!!e.data(t,i)},e[a]=e[a]||{},s=e[a][t],o=e[a][t]=function(e,t){if(!this._createWidget)return new o(e,t);arguments.length&&this._createWidget(e,t)},e.extend(o,s,{version:r.version,_proto:e.extend({},r),_childConstructors:[]}),u=new n,u.options=e.widget.extend({},u.options),e.each(r,function(t,i){e.isFunction(i)&&(r[t]=function(){var e=function(){return n.prototype[t].apply(this,arguments)},r=function(e){return n.prototype[t].apply(this,e)};return function(){var t=this._super,n=this._superApply,s;return this._super=e,this._superApply=r,s=i.apply(this,arguments),this._super=t,this._superApply=n,s}}())}),o.prototype=e.widget.extend(u,{widgetEventPrefix:s?u.widgetEventPrefix:t},r,{constructor:o,namespace:a,widgetName:t,widgetBaseClass:i,widgetFullName:i}),s?(e.each(s._childConstructors,function(t,n){var r=n.prototype;e.widget(r.namespace+"."+r.widgetName,o,n._proto)}),delete s._childConstructors):n._childConstructors.push(o),e.widget.bridge(t,o)},e.widget.extend=function(n){var i=r.call(arguments,1),s=0,o=i.length,u,a;for(;s",options:{disabled:!1,create:null},_createWidget:function(t,r){r=e(r||this.defaultElement||this)[0],this.element=e(r),this.uuid=n++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this.bindings=e(),this.hoverable=e(),this.focusable=e(),r!==this&&(e.data(r,this.widgetName,this),e.data(r,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===r&&this.destroy()}}),this.document=e(r.style?r.ownerDocument:r.document||r),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled "+"ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(n,r){var i=n,s,o,u;if(arguments.length===0)return e.widget.extend({},this.options);if(typeof n=="string"){i={},s=n.split("."),n=s.shift();if(s.length){o=i[n]=e.widget.extend({},this.options[n]);for(u=0;u');if(1':""+b+"",a.controlNavScaffold.append("
  • "+g+"
  • "),b++;a.controlsContainer?d(a.controlsContainer).append(a.controlNavScaffold):a.append(a.controlNavScaffold);f.controlNav.set();f.controlNav.active();a.controlNavScaffold.delegate("a, img",s,function(b){b.preventDefault();var b=d(this),g=a.controlNav.index(b);b.hasClass(e+"active")||(a.direction=g>a.currentSlide?"next":"prev",a.flexAnimate(g,c.pauseOnAction))});r&&a.controlNavScaffold.delegate("a", + "click touchstart",function(a){a.preventDefault()})},setupManual:function(){a.controlNav=a.manualControls;f.controlNav.active();a.controlNav.live(s,function(b){b.preventDefault();var b=d(this),g=a.controlNav.index(b);b.hasClass(e+"active")||(g>a.currentSlide?a.direction="next":a.direction="prev",a.flexAnimate(g,c.pauseOnAction))});r&&a.controlNav.live("click touchstart",function(a){a.preventDefault()})},set:function(){a.controlNav=d("."+e+"control-nav li "+("thumbnails"===c.controlNav?"img":"a"), + a.controlsContainer?a.controlsContainer:a)},active:function(){a.controlNav.removeClass(e+"active").eq(a.animatingTo).addClass(e+"active")},update:function(b,c){1"+a.count+"")):1===a.pagingCount?a.controlNavScaffold.find("li").remove():a.controlNav.eq(c).closest("li").remove();f.controlNav.set();1
  • '+c.prevText+'
  • '+c.nextText+"
  • ");a.controlsContainer?(d(a.controlsContainer).append(b),a.directionNav=d("."+e+"direction-nav li a",a.controlsContainer)):(a.append(b),a.directionNav=d("."+e+"direction-nav li a",a));f.directionNav.update();a.directionNav.bind(s,function(b){b.preventDefault();b=d(this).hasClass(e+"next")?a.getTarget("next"):a.getTarget("prev");a.flexAnimate(b,c.pauseOnAction)}); + r&&a.directionNav.bind("click touchstart",function(a){a.preventDefault()})},update:function(){var b=e+"disabled";1===a.pagingCount?a.directionNav.addClass(b):c.animationLoop?a.directionNav.removeClass(b):0===a.animatingTo?a.directionNav.removeClass(b).filter("."+e+"prev").addClass(b):a.animatingTo===a.last?a.directionNav.removeClass(b).filter("."+e+"next").addClass(b):a.directionNav.removeClass(b)}},pausePlay:{setup:function(){var b=d('
    ');a.controlsContainer? + (a.controlsContainer.append(b),a.pausePlay=d("."+e+"pauseplay a",a.controlsContainer)):(a.append(b),a.pausePlay=d("."+e+"pauseplay a",a));f.pausePlay.update(c.slideshow?e+"pause":e+"play");a.pausePlay.bind(s,function(b){b.preventDefault();if(d(this).hasClass(e+"pause")){a.manualPause=true;a.manualPlay=false;a.pause()}else{a.manualPause=false;a.manualPlay=true;a.play()}});r&&a.pausePlay.bind("click touchstart",function(a){a.preventDefault()})},update:function(b){"play"===b?a.pausePlay.removeClass(e+ + "pause").addClass(e+"play").text(c.playText):a.pausePlay.removeClass(e+"play").addClass(e+"pause").text(c.pauseText)}},touch:function(){function b(b){j=l?d-b.touches[0].pageY:d-b.touches[0].pageX;p=l?Math.abs(j)j||a.currentSlide===a.last&&0Number(new Date)-k&&50o/2)?a.flexAnimate(l,c.pauseOnAction):a.flexAnimate(a.currentSlide,c.pauseOnAction,!0)}i.removeEventListener("touchmove",b,!1);i.removeEventListener("touchend",g,!1);f=j=e=d=null}var d,e,f,o,j,k,p=!1;i.addEventListener("touchstart",function(j){a.animating?j.preventDefault():1===j.touches.length&&(a.pause(),o=l?a.h:a.w,k=Number(new Date),f=h&& + m&&a.animatingTo===a.last?0:h&&m?a.limit-(a.itemW+c.itemMargin)*a.move*a.animatingTo:h&&a.currentSlide===a.last?a.limit:h?(a.itemW+c.itemMargin)*a.move*a.currentSlide:m?(a.last-a.currentSlide+a.cloneOffset)*o:(a.currentSlide+a.cloneOffset)*o,d=l?j.touches[0].pageY:j.touches[0].pageX,e=l?j.touches[0].pageX:j.touches[0].pageY,i.addEventListener("touchmove",b,!1),i.addEventListener("touchend",g,!1))},!1)},resize:function(){!a.animating&&a.is(":visible")&&(h||a.doMath(),q?f.smoothHeight():h?(a.slides.width(a.computedW), + a.update(a.pagingCount),a.setProps()):l?(a.viewport.height(a.h),a.setProps(a.h,"setTotal")):(c.smoothHeight&&f.smoothHeight(),a.newSlides.width(a.computedW),a.setProps(a.computedW,"setTotal")))},smoothHeight:function(b){if(!l||q){var c=q?a:a.viewport;b?c.animate({height:a.slides.eq(a.animatingTo).height()},b):c.height(a.slides.eq(a.animatingTo).height())}},sync:function(b){var g=d(c.sync).data("flexslider"),e=a.animatingTo;switch(b){case "animate":g.flexAnimate(e,c.pauseOnAction,!1,!0);break;case "play":!g.playing&& + !g.asNav&&g.play();break;case "pause":g.pause()}}};a.flexAnimate=function(b,g,n,i,k){p&&1===a.pagingCount&&(a.direction=a.currentItema.w?2*c.itemMargin:c.itemMargin,b=(a.itemW+b)*a.move*a.animatingTo,b=b>a.limit&&1!==a.visible?a.limit:b):b=0===a.currentSlide&&b===a.count-1&&c.animationLoop&&"next"!==a.direction?m?(a.count+a.cloneOffset)*o:0:a.currentSlide===a.last&&0===b&&c.animationLoop&&"prev"!==a.direction?m?0:(a.count+1)*o:m?(a.count-1-b+a.cloneOffset)*o:(b+a.cloneOffset)*o;a.setProps(b, + "",c.animationSpeed);if(a.transitions){if(!c.animationLoop||!a.atEnd)a.animating=!1,a.currentSlide=a.animatingTo;a.container.unbind("webkitTransitionEnd transitionend");a.container.bind("webkitTransitionEnd transitionend",function(){a.wrapup(o)})}else a.container.animate(a.args,c.animationSpeed,c.easing,function(){a.wrapup(o)})}c.smoothHeight&&f.smoothHeight(c.animationSpeed)}};a.wrapup=function(b){!q&&!h&&(0===a.currentSlide&&a.animatingTo===a.last&&c.animationLoop?a.setProps(b,"jumpEnd"):a.currentSlide=== + a.last&&(0===a.animatingTo&&c.animationLoop)&&a.setProps(b,"jumpStart"));a.animating=!1;a.currentSlide=a.animatingTo;c.after(a)};a.animateSlides=function(){a.animating||a.flexAnimate(a.getTarget("next"))};a.pause=function(){clearInterval(a.animatedSlides);a.playing=!1;c.pausePlay&&f.pausePlay.update("play");a.syncExists&&f.sync("pause")};a.play=function(){a.animatedSlides=setInterval(a.animateSlides,c.slideshowSpeed);a.playing=!0;c.pausePlay&&f.pausePlay.update("pause");a.syncExists&&f.sync("play")}; + a.canAdvance=function(b,g){var d=p?a.pagingCount-1:a.last;return g?!0:p&&a.currentItem===a.count-1&&0===b&&"prev"===a.direction?!0:p&&0===a.currentItem&&b===a.pagingCount-1&&"next"!==a.direction?!1:b===a.currentSlide&&!p?!1:c.animationLoop?!0:a.atEnd&&0===a.currentSlide&&b===d&&"next"!==a.direction?!1:a.atEnd&&a.currentSlide===d&&0===b&&"next"===a.direction?!1:!0};a.getTarget=function(b){a.direction=b;return"next"===b?a.currentSlide===a.last?0:a.currentSlide+1:0===a.currentSlide?a.last:a.currentSlide- + 1};a.setProps=function(b,g,d){var e,f=b?b:(a.itemW+c.itemMargin)*a.move*a.animatingTo;e=-1*function(){if(h)return"setTouch"===g?b:m&&a.animatingTo===a.last?0:m?a.limit-(a.itemW+c.itemMargin)*a.move*a.animatingTo:a.animatingTo===a.last?a.limit:f;switch(g){case "setTotal":return m?(a.count-1-a.currentSlide+a.cloneOffset)*b:(a.currentSlide+a.cloneOffset)*b;case "setTouch":return b;case "jumpEnd":return m?b:a.count*b;case "jumpStart":return m?a.count*b:b;default:return b}}()+"px";a.transitions&&(e=l? + "translate3d(0,"+e+",0)":"translate3d("+e+",0,0)",d=void 0!==d?d/1E3+"s":"0s",a.container.css("-"+a.pfx+"-transition-duration",d));a.args[a.prop]=e;(a.transitions||void 0===d)&&a.container.css(a.args)};a.setup=function(b){if(q)a.slides.css({width:"100%","float":"left",marginRight:"-100%",position:"relative"}),"init"===b&&a.slides.eq(a.currentSlide).fadeIn(c.animationSpeed,c.easing),c.smoothHeight&&f.smoothHeight();else{var g,n;"init"===b&&(a.viewport=d('
    ').css({overflow:"hidden", + position:"relative"}).appendTo(a).append(a.container),a.cloneCount=0,a.cloneOffset=0,m&&(n=d.makeArray(a.slides).reverse(),a.slides=d(n),a.container.empty().append(a.slides)));c.animationLoop&&!h&&(a.cloneCount=2,a.cloneOffset=1,"init"!==b&&a.container.find(".clone").remove(),a.container.append(a.slides.first().clone().addClass("clone")).prepend(a.slides.last().clone().addClass("clone")));a.newSlides=d(c.selector,a);g=m?a.count-1-a.currentSlide+a.cloneOffset:a.currentSlide+a.cloneOffset;l&&!h?(a.container.height(200* + (a.count+a.cloneCount)+"%").css("position","absolute").width("100%"),setTimeout(function(){a.newSlides.css({display:"block"});a.doMath();a.viewport.height(a.h);a.setProps(g*a.h,"init")},"init"===b?100:0)):(a.container.width(200*(a.count+a.cloneCount)+"%"),a.setProps(g*a.computedW,"init"),setTimeout(function(){a.doMath();a.newSlides.css({width:a.computedW,"float":"left",display:"block"});c.smoothHeight&&f.smoothHeight()},"init"===b?100:0))}h||a.slides.removeClass(e+"active-slide").eq(a.currentSlide).addClass(e+ + "active-slide")};a.doMath=function(){var b=a.slides.first(),d=c.itemMargin,e=c.minItems,f=c.maxItems;a.w=a.width();a.h=b.height();a.boxPadding=b.outerWidth()-b.width();h?(a.itemT=c.itemWidth+d,a.minW=e?e*a.itemT:a.w,a.maxW=f?f*a.itemT:a.w,a.itemW=a.minW>a.w?(a.w-d*e)/e:a.maxWa.w?a.w:c.itemWidth,a.visible=Math.floor(a.w/(a.itemW+d)),a.move=0a.w?(a.itemW+2*d)*a.count-a.w-d:(a.itemW+d)*a.count-a.w-d):(a.itemW=a.w,a.pagingCount=a.count,a.last=a.count-1);a.computedW=a.itemW-a.boxPadding};a.update=function(b,d){a.doMath();h||(ba.controlNav.length)f.controlNav.update("add");else if("remove"===d&&!h||a.pagingCount + a.last&&(a.currentSlide-=1,a.animatingTo-=1),f.controlNav.update("remove",a.last);c.directionNav&&f.directionNav.update()};a.addSlide=function(b,e){var f=d(b);a.count+=1;a.last=a.count-1;l&&m?void 0!==e?a.slides.eq(a.count-e).after(f):a.container.prepend(f):void 0!==e?a.slides.eq(e).before(f):a.container.append(f);a.update(e,"add");a.slides=d(c.selector+":not(.clone)",a);a.setup();c.added(a)};a.removeSlide=function(b){var e=isNaN(b)?a.slides.index(d(b)):b;a.count-=1;a.last=a.count-1;isNaN(b)?d(b, + a.slides).remove():l&&m?a.slides.eq(a.last).remove():a.slides.eq(b).remove();a.doMath();a.update(e,"remove");a.slides=d(c.selector+":not(.clone)",a);a.setup();c.removed(a)};f.init()};d.flexslider.defaults={namespace:"flex-",selector:".slides > li",animation:"fade",easing:"swing",direction:"horizontal",reverse:!1,animationLoop:!0,smoothHeight:!1,startAt:0,slideshow:!0,slideshowSpeed:7E3,animationSpeed:600,initDelay:0,randomize:!1,pauseOnAction:!0,pauseOnHover:!1,useCSS:!0,touch:!0,video:!1,controlNav:!0, + directionNav:!0,prevText:"Previous",nextText:"Next",keyboard:!0,multipleKeyboard:!1,mousewheel:!1,pausePlay:!1,pauseText:"Pause",playText:"Play",controlsContainer:"",manualControls:"",sync:"",asNavFor:"",itemWidth:0,itemMargin:0,minItems:0,maxItems:0,move:0,start:function(){},before:function(){},after:function(){},end:function(){},added:function(){},removed:function(){}};d.fn.flexslider=function(i){void 0===i&&(i={});if("object"===typeof i)return this.each(function(){var a=d(this),c=a.find(i.selector? + i.selector:".slides > li");1===c.length?(c.fadeIn(400),i.start&&i.start(a)):void 0===a.data("flexslider")&&new d.flexslider(this,i)});var k=d(this).data("flexslider");switch(i){case "play":k.play();break;case "pause":k.pause();break;case "next":k.flexAnimate(k.getTarget("next"),!0);break;case "prev":case "previous":k.flexAnimate(k.getTarget("prev"),!0);break;default:"number"===typeof i&&k.flexAnimate(i,!0)}}})(jQuery); \ No newline at end of file diff --git a/gui/js/jquery.quicksearch.js b/gui/js/jquery.quicksearch.js new file mode 100644 index 0000000..cba8770 --- /dev/null +++ b/gui/js/jquery.quicksearch.js @@ -0,0 +1,181 @@ +(function($, window, document, undefined) { + $.fn.quicksearch = function (target, opt) { + + var timeout, cache, rowcache, jq_results, val = '', e = this, options = $.extend({ + delay: 100, + selector: null, + stripeRows: null, + loader: null, + noResults: '', + matchedResultsCount: 0, + bind: 'keyup', + onBefore: function () { + return; + }, + onAfter: function () { + return; + }, + show: function () { + this.style.display = ""; + }, + hide: function () { + this.style.display = "none"; + }, + prepareQuery: function (val) { + return val.toLowerCase().split(' '); + }, + testQuery: function (query, txt, _row) { + for (var i = 0; i < query.length; i += 1) { + if (txt.indexOf(query[i]) === -1) { + return false; + } + } + return true; + } + }, opt); + + this.go = function () { + + var i = 0, + numMatchedRows = 0, + noresults = true, + query = options.prepareQuery(val), + val_empty = (val.replace(' ', '').length === 0); + + for (var i = 0, len = rowcache.length; i < len; i++) { + if (val_empty || options.testQuery(query, cache[i], rowcache[i])) { + options.show.apply(rowcache[i]); + noresults = false; + numMatchedRows++; + } else { + options.hide.apply(rowcache[i]); + } + } + + if (noresults) { + this.results(false); + } else { + this.results(true); + this.stripe(); + } + + this.matchedResultsCount = numMatchedRows; + this.loader(false); + options.onAfter(); + + return this; + }; + + /* + * External API so that users can perform search programatically. + * */ + this.search = function (submittedVal) { + val = submittedVal; + e.trigger(); + }; + + /* + * External API to get the number of matched results as seen in + * https://github.com/ruiz107/quicksearch/commit/f78dc440b42d95ce9caed1d087174dd4359982d6 + * */ + this.currentMatchedResults = function() { + return this.matchedResultsCount; + }; + + this.stripe = function () { + + if (typeof options.stripeRows === "object" && options.stripeRows !== null) + { + var joined = options.stripeRows.join(' '); + var stripeRows_length = options.stripeRows.length; + + jq_results.not(':hidden').each(function (i) { + $(this).removeClass(joined).addClass(options.stripeRows[i % stripeRows_length]); + }); + } + + return this; + }; + + this.strip_html = function (input) { + var output = input.replace(new RegExp('<[^<]+\>', 'g'), ""); + output = $.trim(output.toLowerCase()); + return output; + }; + + this.results = function (bool) { + if (typeof options.noResults === "string" && options.noResults !== "") { + if (bool) { + $(options.noResults).hide(); + } else { + $(options.noResults).show(); + } + } + return this; + }; + + this.loader = function (bool) { + if (typeof options.loader === "string" && options.loader !== "") { + (bool) ? $(options.loader).show() : $(options.loader).hide(); + } + return this; + }; + + this.cache = function () { + + jq_results = $(target); + + if (typeof options.noResults === "string" && options.noResults !== "") { + jq_results = jq_results.not(options.noResults); + } + + var t = (typeof options.selector === "string") ? jq_results.find(options.selector) : $(target).not(options.noResults); + cache = t.map(function () { + return e.strip_html(this.innerHTML); + }); + + rowcache = jq_results.map(function () { + return this; + }); + + /* + * Modified fix for sync-ing "val". + * Original fix https://github.com/michaellwest/quicksearch/commit/4ace4008d079298a01f97f885ba8fa956a9703d1 + * */ + val = val || this.val() || ""; + + return this.go(); + }; + + this.trigger = function () { + this.loader(true); + options.onBefore(); + + window.clearTimeout(timeout); + timeout = window.setTimeout(function () { + e.go(); + }, options.delay); + + return this; + }; + + this.cache(); + this.results(true); + this.stripe(); + this.loader(false); + + return this.each(function () { + + /* + * Changed from .bind to .on. + * */ + $(this).on(options.bind, function () { + + val = $(this).val(); + e.trigger(); + }); + }); + + }; + +}(jQuery, this, document)); diff --git a/gui/js/jquery.tocify.min.js b/gui/js/jquery.tocify.min.js new file mode 100644 index 0000000..4bc3b21 --- /dev/null +++ b/gui/js/jquery.tocify.min.js @@ -0,0 +1,3 @@ +/*! jquery Tocify - v1.3.0 - 2013-02-23 +* Copyright (c) 2013 Greg Franko; Licensed MIT */ +(function(e){"use strict";e(window.jQuery,window,document)})(function(e,t,n,r){"use strict";e.widget("toc.tocify",{version:"1.3.0",options:{context:"body",selectors:"h1, h2, h3",showAndHide:!0,showEffect:"slideDown",showEffectSpeed:"medium",hideEffect:"slideUp",hideEffectSpeed:"medium",smoothScroll:!0,smoothScrollSpeed:"medium",scrollTo:0,showAndHideOnScroll:!0,highlightOnScroll:!0,highlightOffset:40,theme:"twitterBootstrap",extendPage:!0,extendPageOffset:!0,history:!0,hashGenerator:"compact"},_create:function(){var n=this;n.items=[],n._generateToc(),n._addCSSClasses(),n.webkit=function(){for(var e in t)if(e&&e.toLowerCase().indexOf("webkit")!==-1)return!0;return!1}(),n._setEventHandlers(),e(t).load(function(){n._setActiveElement(),n.element.bind("extend.tocify",function(){n._setActiveElement()})})},_generateToc:function(){var t=this,n,r;this.options.selectors.indexOf(",")!==-1?n=e(this.options.context).find(this.options.selectors.replace(/ /g,"").substr(0,this.options.selectors.indexOf(","))):n=e(this.options.context).find(this.options.selectors.replace(/ /g,"")),n.each(function(n){r=e("
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameAuthorDescription
    AxonRESTSteven BredenbergA plugin that handles PUT/POST/GET/DELETE operations against a named Axon model.view
    CurrencySteven BredenbergA simple plugin that converts a money value from one currency to another.view
    FileUnitChristian KnuthThis plugin offers a bunch of file system methods.view
    PaginationChristian KnuthCreate quick and easy Pagination for your F3 application.view
    System ProfileSteven BredenbergA plugin for grabbing system information like online users and load levels. Also supports basic interpretation of load levels, which allows for adaptive throttling.view
    TableBuilderSteven BredenbergAn HTML table builder with basic support for paging.view
    URLSteven BredenbergAllows for easy building and manipulation of complicated URLs.view
    +

    Projects around F3

    +

    Some projects that might help you.

    +
    + + + + + + + + + + + + + + + + + + + + + + + +
    NameAuthorDescription
    CarbJason GilmoreA PHP command line tool for the automated generation of a new F3 project structure.view
    f3ldapNurettin SenyerLDAP integration. Unfortunately based on v1.3 and turkish language.view
    + + + + diff --git a/gui/tmpl/saved.html b/gui/tmpl/saved.html new file mode 100644 index 0000000..bc559c0 --- /dev/null +++ b/gui/tmpl/saved.html @@ -0,0 +1,9 @@ +
    +
    +
    +
    page successfully saved
    + View page + Edit page +
    +
    +
    diff --git a/inc/common.php b/inc/common.php new file mode 100644 index 0000000..9d9014f --- /dev/null +++ b/inc/common.php @@ -0,0 +1,101 @@ +set('headline', $f3->get('ERROR.code').' - '.$f3->get('ERROR.text')); + + if ($f3->get('ERROR.code') == 500) { + // show highlighted strack trace, code was taken from Base->error, + // maybe there's an easier way to include this in a custom error handler? + $trace = $f3->get('ERROR.trace'); + $highlight = PHP_SAPI != 'cli' && + $f3->get('HIGHLIGHT') && is_file($css = $f3->get('UI').'css/'.$f3::CSS); + $out = ''; + $eol = "\n"; + foreach ($trace as $frame) { + $line = ''; + if (isset($frame['class'])) + $line .= $frame['class'].$frame['type']; + if (isset($frame['function'])) + $line .= $frame['function'].'('.(isset($frame['args']) ? + $f3->csv($frame['args']) : '').')'; + $src = $f3->fixslashes($frame['file']).':'.$frame['line'].' '; + error_log('- '.$src.$line); + $out .= '• '.($highlight ? + ($f3->highlight($src).' '.$f3->highlight($line)) : + ($src.$line)).$eol; + } + $f3->set('trace', ($highlight ? ('') : ''). + ($f3->get('DEBUG') ? ('
    '.$out.'
    '.$eol) : '')); + } else { + $f3->set('trace', ''); + } + + if ($f3->get('ERROR.code') == 404) { + $f3->set('text', ''. + ' Create this page now.'); + } else { + $f3->set('text', ''); + } + $content = \Template::instance()->render($f3->get('TMPL').'404.html'); + $f3->set('content', $content); + $f3->set('page.title', 'Error '.$f3->get('ERROR.code')); + echo \Template::instance()->render($f3->get('TMPL').'layout.html'); + } + + + public function installJIG() + { + $f3 = \Base::instance(); + $db = $f3->get('DB'); + + if (!file_exists('db/pages.json')) { + // adding basic data + $f3->set('pages', array( + array( + 'title' => 'Home', + 'slug' => 'home', + 'lang' => 'en', + 'deleted' => 0, + ), + array( + 'title' => 'Examples', + 'slug' => 'examples', + 'lang' => 'en', + 'deleted' => 0, + ), + array( + 'title' => 'Documentation', + 'slug' => 'documentation', + 'lang' => 'en', + 'deleted' => 0, + ), + array( + 'title' => 'Plugins', + 'slug' => 'plugins', + 'lang' => 'en', + 'deleted' => 0, + ) + )); + $pages = new \DB\Jig\Mapper($db, 'pages.json'); + for ($i = 0; $i < count($f3->get('pages')); $i++) { + $pages->copyfrom('pages.'.$i); + $pages->save(); + $pages->reset(); + } + echo "SUCCESS: pages table created
    "; + + } else { + echo "pages table already created
    "; + } + } + +} diff --git a/inc/viewhelper.php b/inc/viewhelper.php new file mode 100644 index 0000000..d00af47 --- /dev/null +++ b/inc/viewhelper.php @@ -0,0 +1,76 @@ +get('BASE').'/'); + } + + + static function renderMarkdown($args) + { + $tmp = \Template::instance(); + $md_string = (isset($args[0])) ? '"'.addslashes($args[0]).'"' : ''; + if (array_key_exists('@attrib', $args)) { + $attr = $args['@attrib']; + foreach ($attr as &$att) { + if (is_int(strpos($att, '@'))) + $att = $tmp->token($att); + else + $att = "'".$att."'"; + } + if (array_key_exists('src', $attr)) + $md_string = 'file_exists('.$attr['src'].') ? \Base::instance()->read('.$attr['src'].') : ""'; + } + $md = 'convert($md_content);'. + ' ?>'; + return $md; + } + + /** + * sweetens '; + } + +} diff --git a/index.php b/index.php new file mode 100644 index 0000000..88e42de --- /dev/null +++ b/index.php @@ -0,0 +1,68 @@ +set('AUTOLOAD', 'inc/;app/'); +$f3->set('DEBUG', 1); +$f3->set('TZ', 'Europe/Berlin'); +$f3->set('CACHE', FALSE); + +// set paths +$f3->set('UI', 'gui/'); +$f3->set('LOCALES', 'dict/'); +$f3->set('TEMP', 'temp/'); +$f3->set('TMPL', 'tmpl/'); +// markdown content data +$f3->set('MDCONTENT', 'content/'); + +// extend Template Engine +\Template::instance()->extend('navigation', '\Navigation\View::renderTag'); +\Template::instance()->extend('select', '\ViewHelper::renderSelect'); +\Template::instance()->extend('markdown', '\ViewHelper::renderMarkdown'); + +// init DB +$f3->set('DB',new DB\Jig('db/')); + +// app vars + +$f3->set('REPO', 'https://github.com/ikkez/F3com'); +$f3->set('DOMAIN', 'vircuit.net'); + +// ROUTING + +// default page +$f3->route('GET /', function($f3) { $f3->reroute('/home'); }); + +// view page +$f3->route('GET /@page', '\Page\Controller->view'); +// get edit form +$f3->route('GET /create', '\Page\Controller->edit'); +$f3->route('GET /edit/@page', '\Page\Controller->edit'); +$f3->route('GET /edit/@page/@marker', '\Page\Controller->edit'); +// save page +$f3->route('POST /edit', '\Page\Controller->save'); +$f3->route('POST /edit/@page', '\Page\Controller->save'); +// delete page +$f3->route('GET /delete/@page', '\Page\Controller->delete'); + +// misc +$f3->route('GET /install', '\Common->installJIG'); +//$f3->set('ONERROR','\Common->error'); + + +// kick start +$f3->run(); diff --git a/lib/api.chm b/lib/api.chm new file mode 100644 index 0000000..dd8c6ad Binary files /dev/null and b/lib/api.chm differ diff --git a/lib/audit.php b/lib/audit.php new file mode 100644 index 0000000..d83d004 --- /dev/null +++ b/lib/audit.php @@ -0,0 +1,129 @@ +4)*-4+$id[$i]%5); + return !($sum%10); + } + + /** + Return credit card type if number is valid + @return string|FALSE + @param $id string + **/ + function card($id) { + $id=preg_replace('/[^\d]/','',$id); + if ($this->mod10($id)) { + if (preg_match('/^3[47][0-9]{13}$/',$id)) + return 'American Express'; + if (preg_match('/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/',$id)) + return 'Diners Club'; + if (preg_match('/^6(?:011|5[0-9][0-9])[0-9]{12}$/',$id)) + return 'Discover'; + if (preg_match('/^(?:2131|1800|35\d{3})\d{11}$/',$id)) + return 'JCB'; + if (preg_match('/^5[1-5][0-9]{14}$/',$id)) + return 'MasterCard'; + if (preg_match('/^4[0-9]{12}(?:[0-9]{3})?$/',$id)) + return 'Visa'; + } + return FALSE; + } + +} diff --git a/lib/auth.php b/lib/auth.php new file mode 100644 index 0000000..a43d7b5 --- /dev/null +++ b/lib/auth.php @@ -0,0 +1,228 @@ +mapper,'findone'), + array( + array_merge( + array( + '@'.$this->args['id'].'==? AND '. + '@'.$this->args['pw'].'==?'. + (isset($this->args['realm'])? + (' AND @'.$this->args['realm'].'==?'):''), + $id,$pw + ), + (isset($this->args['realm'])?array($realm):array()) + ) + ) + ); + } + + /** + MongoDB storage handler + @return bool + @param $id string + @param $pw string + @param $realm string + **/ + protected function _mongo($id,$pw,$realm) { + return (bool) + $this->mapper->findone( + array( + $this->args['id']=>$id, + $this->args['pw']=>$pw + )+ + (isset($this->args['realm'])? + array($this->args['realm']=>$realm):array()) + ); + } + + /** + SQL storage handler + @return bool + @param $id string + @param $pw string + @param $realm string + **/ + protected function _sql($id,$pw,$realm) { + return (bool) + call_user_func_array( + array($this->mapper,'findone'), + array( + array_merge( + array( + $this->args['id'].'=? AND '. + $this->args['pw'].'=?'. + (isset($this->args['realm'])? + (' AND '.$this->args['realm'].'=?'):''), + $id,$pw + ), + (isset($this->args['realm'])?array($realm):array()) + ) + ) + ); + } + + /** + LDAP storage handler + @return bool + @param $id string + @param $pw string + **/ + protected function _ldap($id,$pw) { + $dc=@ldap_connect($this->args['dc']); + if ($dc && + ldap_set_option($dc,LDAP_OPT_PROTOCOL_VERSION,3) && + ldap_set_option($dc,LDAP_OPT_REFERRALS,0) && + ldap_bind($dc,$this->args['rdn'],$this->args['pw']) && + ($result=ldap_search($dc,$this->args['base_dn'], + 'uid='.$id)) && + ldap_count_entries($dc,$result) && + ($info=ldap_get_entries($dc,$result)) && + @ldap_bind($dc,$info[0]['dn'],$pw) && + @ldap_close($dc)) { + return $info[0]['uid'][0]==$id; + } + user_error(self::E_LDAP); + } + + /** + SMTP storage handler + @return bool + @param $id string + @param $pw string + **/ + protected function _smtp($id,$pw) { + $socket=@fsockopen( + (strtolower($this->args['scheme'])=='ssl'? + 'ssl://':'').$this->args['host'], + $this->args['port']); + $dialog=function($cmd=NULL) use($socket) { + if (!is_null($cmd)) + fputs($socket,$cmd."\r\n"); + $reply=''; + while (!feof($socket) && + ($info=stream_get_meta_data($socket)) && + !$info['timed_out'] && $str=fgets($socket,4096)) { + $reply.=$str; + if (preg_match('/(?:^|\n)\d{3} .+\r\n/s', + $reply)) + break; + } + return $reply; + }; + if ($socket) { + stream_set_blocking($socket,TRUE); + $dialog(); + $fw=Base::instance(); + $dialog('EHLO '.$fw->get('HOST')); + if (strtolower($this->args['scheme'])=='tls') { + $dialog('STARTTLS'); + stream_socket_enable_crypto( + $socket,TRUE,STREAM_CRYPTO_METHOD_TLS_CLIENT); + $dialog('EHLO '.$fw->get('HOST')); + } + // Authenticate + $dialog('AUTH LOGIN'); + $dialog(base64_encode($id)); + $reply=$dialog(base64_encode($pw)); + $dialog('QUIT'); + fclose($socket); + return (bool)preg_match('/^235 /',$reply); + } + user_error(self::E_SMTP); + } + + /** + Login auth mechanism + @return bool + @param $id string + @param $pw string + @param $realm string + **/ + function login($id,$pw,$realm=NULL) { + return $this->{'_'.$this->storage}($id,$pw,$realm); + } + + /** + HTTP basic auth mechanism + @return bool + @param $func callback + @param $halt bool + **/ + function basic($func=NULL,$halt=TRUE) { + $fw=Base::instance(); + $realm=$fw->get('REALM'); + if (isset($_SERVER['PHP_AUTH_USER'],$_SERVER['PHP_AUTH_PW']) && + $this->login( + $_SERVER['PHP_AUTH_USER'], + $func? + $func($_SERVER['PHP_AUTH_PW']): + $_SERVER['PHP_AUTH_PW'], + $realm + )) + return TRUE; + if (PHP_SAPI!='cli') + header('WWW-Authenticate: Basic realm="'.$realm.'"'); + if ($halt) + $fw->error(401); + return FALSE; + } + + /** + Instantiate class + @return object + @param $storage string|object + @param $args array + **/ + function __construct($storage,array $args=NULL) { + if (is_object($storage) && is_a($storage,'DB\Cursor')) { + $ref=new ReflectionClass(get_class($storage)); + $this->storage=basename(dirname($ref->getfilename())); + $this->mapper=$storage; + unset($ref); + } + else + $this->storage=$storage; + $this->args=$args; + } + +} diff --git a/lib/base.php b/lib/base.php new file mode 100644 index 0000000..eae28fa --- /dev/null +++ b/lib/base.php @@ -0,0 +1,2264 @@ +hive[$key]=&$GLOBALS['_'.$key]; + } + + /** + Return the parts of specified hive key + @return array + @param $key string + **/ + private function cut($key) { + return preg_split('/\[\h*[\'"]?(.+?)[\'"]?\h*\]|(->)|\./', + $key,NULL,PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE); + } + + /** + Get hive key reference/contents; Add non-existent hive keys, + array elements, and object properties by default + @return mixed + @param $key string + @param $add bool + **/ + function &ref($key,$add=TRUE) { + $parts=$this->cut($key); + if ($parts[0]=='SESSION') { + @session_start(); + $this->sync('SESSION'); + } + if ($add) + $var=&$this->hive; + else + $var=$this->hive; + $obj=FALSE; + foreach ($parts as $part) + if ($part=='->') + $obj=TRUE; + elseif ($obj) { + $obj=FALSE; + if ($add) { + if (!is_object($var)) + $var=new stdclass; + $var=&$var->$part; + } + elseif (isset($var->$part)) + $var=$var->$part; + else + return $this->null; + } + elseif ($add) { + if (!is_array($var)) + $var=array(); + $var=&$var[$part]; + } + elseif (isset($var[$part])) + $var=$var[$part]; + else + return $this->null; + return $var; + } + + /** + Return TRUE if hive key is not empty + @return bool + @param $key string + **/ + function exists($key) { + $ref=&$this->ref($key,FALSE); + return isset($ref)? + TRUE: + Cache::instance()->exists($this->hash($key).'.var'); + } + + /** + Bind value to hive key + @return mixed + @param $key string + @param $val mixed + @param $ttl int + **/ + function set($key,$val,$ttl=0) { + if (preg_match('/^(GET|POST|COOKIE)\b(.+)/',$key,$expr)) { + $this->set('REQUEST'.$expr[2],$val); + if ($expr[1]=='COOKIE') { + $parts=$this->cut($key); + call_user_func_array('setcookie', + array_merge(array($parts[1],$val),$this->hive['JAR'])); + } + } + else switch ($key) { + case 'CACHE': + $val=Cache::instance()->load($val); + break; + case 'ENCODING': + $val=ini_set('default_charset',$val); + break; + case 'FALLBACK': + $this->fallback=$val; + $lang=$this->language($this->hive['LANGUAGE']); + case 'LANGUAGE': + if (isset($lang) || $lang=$this->language($val)) + $val=$this->language($val); + $lex=$this->lexicon($this->hive['LOCALES']); + case 'LOCALES': + if (isset($lex) || $lex=$this->lexicon($val)) + $this->mset($lex,NULL,$ttl); + break; + case 'TZ': + date_default_timezone_set($val); + break; + } + $ref=&$this->ref($key); + $ref=$val; + if (preg_match('/^JAR\b/',$key)) + call_user_func_array( + 'session_set_cookie_params',$this->hive['JAR']); + if ($ttl) + // Persist the key-value pair + Cache::instance()->set($this->hash($key).'.var',$val,$ttl); + return $ref; + } + + /** + Retrieve contents of hive key + @return mixed + @param $key string + @param $args string|array + **/ + function get($key,$args=NULL) { + if (is_string($val=$this->ref($key,FALSE)) && !is_null($args)) + return call_user_func_array( + array($this,'format'), + array_merge(array($val),is_array($args)?$args:array($args)) + ); + if (is_null($val)) { + // Attempt to retrieve from cache + if (Cache::instance()->exists($this->hash($key).'.var',$data)) + return $data; + } + return $val; + } + + /** + Unset hive key + @return NULL + @param $key string + **/ + function clear($key) { + // Normalize array literal + $cache=Cache::instance(); + $parts=$this->cut($key); + if ($key=='CACHE') + // Clear cache contents + $cache->reset(); + elseif (preg_match('/^(GET|POST|COOKIE)\b(.+)/',$key,$expr)) { + $this->clear('REQUEST'.$expr[2]); + if ($expr[1]=='COOKIE') { + $parts=$this->cut($key); + $jar=$this->hive['JAR']; + $jar['expire']=strtotime('-1 year'); + call_user_func_array('setcookie', + array_merge(array($parts[1],''),$jar)); + } + } + elseif ($parts[0]=='SESSION') { + @session_start(); + if (empty($parts[1])) { + // End session + session_unset(); + session_destroy(); + unset($_COOKIE[session_name()]); + header_remove('Set-Cookie'); + } + $this->sync('SESSION'); + } + if (!isset($parts[1]) && array_key_exists($parts[0],$this->init)) + // Reset global to default value + $this->hive[$parts[0]]=$this->init[$parts[0]]; + else { + $out=''; + $obj=FALSE; + foreach ($parts as $part) + if ($part=='->') + $obj=TRUE; + elseif ($obj) { + $obj=FALSE; + $out.='->'.$out; + } + else + $out.='['.$this->stringify($part).']'; + // PHP can't unset a referenced variable + eval('unset($this->hive'.$out.');'); + if ($cache->exists($hash=$this->hash($key).'.var')) + // Remove from cache + $cache->clear($hash); + } + } + + /** + Multi-variable assignment using associative array + @return NULL + @param $vars array + @param $prefix string + @param $ttl int + **/ + function mset(array $vars,$prefix='',$ttl=0) { + foreach ($vars as $key=>$val) + $this->set($prefix.$key,$val,$ttl); + } + + /** + Publish hive contents + @return array + **/ + function hive() { + return $this->hive; + } + + /** + Copy contents of hive variable to another + @return mixed + @param $src string + @param $dst string + **/ + function copy($src,$dst) { + $ref=&$this->ref($dst); + return $ref=$this->ref($src); + } + + /** + Concatenate string to hive string variable + @return string + @param $key string + @param $val string + **/ + function concat($key,$val) { + $ref=&$this->ref($key); + $ref.=$val; + return $ref; + } + + /** + Swap keys and values of hive array variable + @return array + @param $key string + @public + **/ + function flip($key) { + $ref=&$this->ref($key); + return $ref=array_combine(array_values($ref),array_keys($ref)); + } + + /** + Add element to the end of hive array variable + @return mixed + @param $key string + @param $val mixed + **/ + function push($key,$val) { + $ref=&$this->ref($key); + array_push($ref,$val); + return $val; + } + + /** + Remove last element of hive array variable + @return mixed + @param $key string + **/ + function pop($key) { + $ref=&$this->ref($key); + return array_pop($ref); + } + + /** + Add element to the beginning of hive array variable + @return mixed + @param $key string + @param $val mixed + **/ + function unshift($key,$val) { + $ref=&$this->ref($key); + array_unshift($ref,$val); + return $val; + } + + /** + Remove first element of hive array variable + @return mixed + @param $key string + **/ + function shift($key) { + $ref=&$this->ref($key); + return array_shift($ref); + } + + /** + Convert backslashes to slashes + @return string + @param $str string + **/ + function fixslashes($str) { + return $str?strtr($str,'\\','/'):$str; + } + + /** + Split comma-, semi-colon, or pipe-separated string + @return array + @param $str string + **/ + function split($str) { + return array_map('trim', + preg_split('/[,;|]/',$str,0,PREG_SPLIT_NO_EMPTY)); + } + + /** + Convert PHP expression/value to compressed exportable string + @return string + @param $arg mixed + **/ + function stringify($arg) { + switch (gettype($arg)) { + case 'object': + $str=''; + if ($this->hive['DEBUG']>2 && get_class($arg)!='Closure') + foreach ((array)$arg as $key=>$val) { + $str.=($str?',':'').$this->stringify( + preg_replace('/[\x00].+?[\x00]/','',$key)).'=>'. + $this->stringify($val); + } + return addslashes(get_class($arg)).'::__set_state('.$str.')'; + case 'array': + $str=''; + $num=isset($arg[0]) && + ctype_digit(implode('',array_keys($arg))); + foreach ($arg as $key=>$val) { + $str.=($str?',':''). + ($num?'':($this->stringify($key).'=>')). + ($arg==$val?'*RECURSION*':$this->stringify($val)); + } + return 'array('.$str.')'; + default: + return var_export( + is_string($arg)?addcslashes($arg,'\''):$arg,TRUE); + } + } + + /** + Flatten array values and return as CSV string + @return string + @param $args array + **/ + function csv(array $args) { + return implode(',',array_map('stripcslashes', + array_map(array($this,'stringify'),$args))); + } + + /** + Convert snakecase string to camelcase + @return string + @param $str string + **/ + function camelcase($str) { + return preg_replace_callback( + '/_(\w)/', + function($match) { + return strtoupper($match[1]); + }, + $str + ); + } + + /** + Convert camelcase string to snakecase + @return string + @param $str string + **/ + function snakecase($str) { + return strtolower(preg_replace('/[[:upper:]]/','_\0',$str)); + } + + /** + Return -1 if specified number is negative, 0 if zero, + or 1 if the number is positive + @return int + @param $num mixed + **/ + function sign($num) { + return $num?($num/abs($num)):0; + } + + /** + Generate 64bit/base36 hash + @return string + @param $str + **/ + function hash($str) { + return str_pad(base_convert( + hexdec(substr(sha1($str),-16)),10,36),11,'0',STR_PAD_LEFT); + } + + /** + Return Base64-encoded equivalent + @return string + @param $data string + @param $mime string + **/ + function base64($data,$mime) { + return 'data:'.$mime.';base64,'.base64_encode($data); + } + + /** + Convert special characters to HTML entities + @return string + @param $str string + **/ + function encode($str) { + return @htmlentities($str,ENT_COMPAT,$this->hive['ENCODING'],FALSE)?: + $this->scrub($str); + } + + /** + Convert HTML entities back to characters + @return string + @param $str string + **/ + function decode($str) { + return html_entity_decode($str,ENT_COMPAT,$this->hive['ENCODING']); + } + + /** + Remove HTML tags (except those enumerated) and non-printable + characters to mitigate XSS/code injection attacks + @return mixed + @param $var mixed + @param $tags string + **/ + function scrub(&$var,$tags=NULL) { + if (is_string($var) && strlen($var)) { + if ($tags!='*') + $var=strip_tags($var, + '<'.implode('><',$this->split($tags)).'>'); + $var=trim(preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F]/','',$var)); + } + elseif (is_array($var)) + foreach ($var as &$val) { + $this->scrub($val,$tags); + unset($val); + } + return $var; + } + + /** + Encode characters to equivalent HTML entities + @return string + @param $arg mixed + **/ + function esc($arg) { + if (is_string($arg)) + return $this->encode($arg); + if (is_array($arg) || is_a($arg,'ArrayAccess')) + foreach ($arg as &$val) { + $val=$this->esc($val); + unset($val); + } + if (is_object($arg)) + foreach (get_object_vars($arg) as $key=>$val) + $arg->$key=$this->esc($val); + return $arg; + } + + /** + Decode HTML entities to equivalent characters + @return string + @param $arg mixed + **/ + function raw($arg) { + if (is_string($arg)) + return $this->decode($arg); + if (is_array($arg) || is_a($arg,'ArrayAccess')) + foreach ($arg as &$val) { + $val=$this->raw($val); + unset($val); + } + if (is_object($arg)) + foreach (get_object_vars($arg) as $key=>$val) + $arg->$key=$this->raw($val); + return $arg; + } + + /** + Return locale-aware formatted string + @return string + **/ + function format() { + $args=func_get_args(); + $val=array_shift($args); + setlocale(LC_ALL,$this->locales); + // Get formatting rules + $conv=localeconv(); + $out=preg_replace_callback( + '/\{(?P\d+)\s*(?:,\s*(?P\w+)\s*'. + '(?:,(?P(?:\s*\w+(?:\s+\{.+?\}\s*,?)?)*))?)?\}/', + function($expr) use($args,$conv) { + extract($expr); + if (!array_key_exists($pos,$args)) + return $expr[0]; + if (isset($type)) + switch ($type) { + case 'plural': + preg_match_all('/(?\w+)'. + '(?:\s+\{(?.+?)\})/', + $mod,$matches,PREG_SET_ORDER); + $ord=array('zero','one','two'); + foreach ($matches as $match) { + extract($match); + if (isset($ord[$args[$pos]]) && + $tag==$ord[$args[$pos]] || $tag=='other') + return str_replace('#',$args[$pos],$data); + } + case 'number': + if (isset($mod)) + switch ($mod) { + case 'integer': + return + number_format( + $args[$pos],0,'', + $conv['thousands_sep']); + case 'currency': + return + $conv['currency_symbol']. + number_format( + $args[$pos], + $conv['frac_digits'], + $conv['decimal_point'], + $conv['thousands_sep']); + case 'percent': + return + number_format( + $args[$pos]*100,0, + $conv['decimal_point'], + $conv['thousands_sep']).'%'; + } + break; + case 'date': + return strftime(empty($mod) || + $mod=='short'?'%x':'%A, %d %B %Y', + $args[$pos]); + case 'time': + return strftime('%X',$args[$pos]); + default: + return $expr[0]; + } + return $args[$pos]; + }, + $val + ); + return preg_match('/^win/i',PHP_OS)? + iconv('Windows-1252',$this->hive['ENCODING'],$out):$out; + } + + /** + Assign/auto-detect language + @return string + @param $code string + **/ + function language($code=NULL) { + if (!$code) { + $headers=$this->hive['HEADERS']; + if (isset($headers['Accept-Language'])) + $code=$headers['Accept-Language']; + } + $code=str_replace('-','_',preg_replace('/;q=.+?(?=,|$)/','',$code)); + $code.=($code?',':'').$this->fallback; + $this->languages=array(); + foreach (array_reverse(explode(',',$code)) as $lang) { + if (preg_match('/^(\w{2})(?:_(\w{2}))?\b/i',$lang,$parts)) { + // Generic language + array_unshift($this->languages,$parts[1]); + if (isset($parts[2])) { + // Specific language + $parts[0]=$parts[1].'_'.($parts[2]=strtoupper($parts[2])); + array_unshift($this->languages,$parts[0]); + } + } + } + $this->languages=array_unique($this->languages); + $this->locales=array(); + $windows=preg_match('/^win/i',PHP_OS); + foreach ($this->languages as $locale) { + if ($windows) { + $parts=explode('_',$locale); + $locale=@constant('ISO::LC_'.$parts[0]); + if (isset($parts[1]) && + $country=@constant('ISO::CC_'.$parts[1])) + $locale.='_'.$country; + } + $this->locales[]=$locale; + $this->locales[]=$locale.'.'.$this->hive['ENCODING']; + } + return implode(',',$this->languages); + } + + /** + Transfer lexicon entries to hive + @return NULL + @param $path string + **/ + function lexicon($path) { + $lex=array(); + foreach ($this->languages?:array($this->fallback) as $lang) { + if ((is_file($file=($base=$path.$lang).'.php') || + is_file($file=$base.'.php')) && + is_array($dict=require($file))) + $lex+=$dict; + elseif (is_file($file=$base.'.ini')) { + preg_match_all( + '/(?<=^|\n)(?:'. + '(?:;[^\n]*)|(?:<\?php.+?\?>?)|'. + '(.+?)\h*=\h*'. + '((?:\\\\\h*\r?\n|.+?)*)'. + ')(?=\r?\n|$)/', + file_get_contents($file),$matches,PREG_SET_ORDER); + if ($matches) + foreach ($matches as $match) + if (isset($match[1]) && + !array_key_exists($match[1],$lex)) + $lex[$match[1]]=preg_replace( + '/\\\\\h*\r?\n/','',$match[2]); + } + } + return $lex; + } + + /** + Return string representation of PHP value + @return string + @param $arg mixed + **/ + function serialize($arg) { + switch (strtolower($this->hive['SERIALIZER'])) { + case 'igbinary': + return igbinary_serialize($arg); + case 'json': + return json_encode($arg); + default: + return serialize($arg); + } + } + + /** + Return PHP value derived from string + @return string + @param $arg mixed + **/ + function unserialize($arg) { + switch (strtolower($this->hive['SERIALIZER'])) { + case 'igbinary': + return igbinary_unserialize($arg); + case 'json': + return json_decode($arg); + default: + return unserialize($arg); + } + } + + /** + Send HTTP/1.1 status header; Return text equivalent of status code + @return string + @param $code int + **/ + function status($code) { + if (PHP_SAPI!='cli') + header('HTTP/1.1 '.$code); + return @constant('self::HTTP_'.$code); + } + + /** + Send cache metadata to HTTP client + @return NULL + @param $secs int + **/ + function expire($secs=0) { + if (PHP_SAPI!='cli') { + header('X-Powered-By: '.$this->hive['PACKAGE']); + if ($secs) { + $time=microtime(TRUE); + header_remove('Pragma'); + header('Expires: '.gmdate('r',$time+$secs)); + header('Cache-Control: max-age='.$secs); + header('Last-Modified: '.gmdate('r')); + $headers=$this->hive['HEADERS']; + if (isset($headers['If-Modified-Since']) && + strtotime($headers['If-Modified-Since'])+$secs>$time) { + $this->status(304); + die; + } + } + else + header('Cache-Control: no-cache, no-store, must-revalidate'); + } + } + + /** + Log error; Execute ONERROR handler if defined, else display + default error page (HTML for synchronous requests, JSON string + for AJAX requests) + @return NULL + @param $code int + @param $text string + @param $trace array + **/ + function error($code,$text='',array $trace=NULL) { + $prior=$this->hive['ERROR']; + $header=$this->status($code); + $req=$this->hive['VERB'].' '.$this->hive['URI']; + if (!$text) + $text='HTTP '.$code.' ('.$req.')'; + error_log($text); + if (!$trace) + $trace=array_slice(debug_backtrace(FALSE),1); + $debug=$this->hive['DEBUG']; + $trace=array_filter( + $trace, + function($frame) use($debug) { + return $debug && isset($frame['file']) && + ($frame['file']!=__FILE__ || $debug>1) && + (empty($frame['function']) || + !preg_match('/^(?:(?:trigger|user)_error|'. + '__call|call_user_func)/',$frame['function'])); + } + ); + $highlight=PHP_SAPI!='cli' && + $this->hive['HIGHLIGHT'] && is_file($css=__DIR__.'/'.self::CSS); + $out=''; + $eol="\n"; + // Analyze stack trace + foreach ($trace as $frame) { + $line=''; + if (isset($frame['class'])) + $line.=$frame['class'].$frame['type']; + if (isset($frame['function'])) + $line.=$frame['function'].'('.(isset($frame['args'])? + $this->csv($frame['args']):'').')'; + $src=$this->fixslashes($frame['file']).':'.$frame['line'].' '; + error_log('- '.$src.$line); + $out.='• '.($highlight? + ($this->highlight($src).' '.$this->highlight($line)): + ($src.$line)).$eol; + } + $this->hive['ERROR']=array( + 'code'=>$code, + 'text'=>$text, + 'trace'=>$trace + ); + if (ob_get_level()) + ob_end_clean(); + if ($this->hive['ONERROR']) + // Execute custom error handler + $this->call($this->hive['ONERROR'],$this); + elseif (!$prior && PHP_SAPI!='cli' && !$this->hive['QUIET']) + echo $this->hive['AJAX']? + json_encode($this->hive['ERROR']): + (''.$eol. + ''.$eol. + ''. + ''.$code.' '.$header.''. + ($highlight? + (''):''). + ''.$eol. + ''.$eol. + '

    '.$header.'

    '.$eol. + '

    '.$this->encode($text?:$req).'

    '.$eol. + ($debug?('
    '.$out.'
    '.$eol):''). + ''.$eol. + ''); + die; + } + + /** + Mock HTTP request + @return NULL + @param $pattern string + @param $args array + @param $headers array + @param $body string + **/ + function mock($pattern,array $args=NULL,array $headers=NULL,$body=NULL) { + $types=array('sync','ajax'); + preg_match('/([\|\w]+)\h+([^\h]+)'. + '(?:\h+\[('.implode('|',$types).')\])?/',$pattern,$parts); + if (empty($parts[2])) + user_error(sprintf(self::E_Pattern,$pattern)); + $verb=strtoupper($parts[1]); + $url=parse_url($parts[2]); + $query=''; + if ($args) + $query.=http_build_query($args); + $query.=isset($url['query'])?(($query?'&':'').$url['query']):''; + if ($query && preg_match('/GET|POST/',$verb)) { + parse_str($query,$GLOBALS['_'.$verb]); + parse_str($query,$GLOBALS['_REQUEST']); + } + foreach ($headers?:array() as $key=>$val) + $_SERVER['HTTP_'.str_replace('-','_',strtoupper($key))]=$val; + $this->hive['VERB']=$verb; + $this->hive['URI']=$this->hive['BASE'].$url['path']; + $this->hive['AJAX']=isset($parts[3]) && + preg_match('/ajax/i',$parts[3]); + if (preg_match('/GET|HEAD/',$verb) && $query) + $this->hive['URI'].='?'.$query; + else + $this->hive['BODY']=$body?:$query; + $this->run(); + } + + /** + Bind handler to route pattern + @return NULL + @param $pattern string + @param $handler callback + @param $ttl int + @param $kbps int + **/ + function route($pattern,$handler,$ttl=0,$kbps=0) { + $types=array('sync','ajax'); + preg_match('/([\|\w]+)\h+([^\h]+)'. + '(?:\h+\[('.implode('|',$types).')\])?/',$pattern,$parts); + if (empty($parts[2])) + user_error(sprintf(self::E_Pattern,$pattern)); + $type=empty($parts[3])? + self::REQ_SYNC|self::REQ_AJAX: + constant('self::REQ_'.strtoupper($parts[3])); + foreach ($this->split($parts[1]) as $verb) { + if (!preg_match('/'.self::VERBS.'/',$verb)) + $this->error(501,$verb.' '.$this->hive['URI']); + $this->hive['ROUTES'][$parts[2]][$type] + [strtoupper($verb)]=array($handler,$ttl,$kbps); + } + } + + /** + Reroute to specified URI + @return NULL + @param $uri string + **/ + function reroute($uri) { + if (PHP_SAPI!='cli') { + @session_commit(); + header('Location: '.(preg_match('/^https?:\/\//',$uri)? + $uri:($this->hive['BASE'].$uri))); + $this->status($this->hive['VERB']=='GET'?301:303); + die; + } + $this->mock('GET '.$uri); + } + + /** + Provide ReST interface by mapping HTTP verb to class method + @param $url string + @param $class string + @param $ttl int + @param $kbps int + **/ + function map($url,$class,$ttl=0,$kbps=0) { + $fluid=preg_match('/@\w+/',$url); + foreach (explode('|',self::VERBS) as $method) + if ($fluid || + method_exists($class,$method) || + method_exists($class,'__call')) + $this->route($method.' '. + $url,$class.'->'.strtolower($method),$ttl,$kbps); + } + + /** + Return TRUE if IPv4 address exists in DNSBL + @return bool + @param $ip string + **/ + function blacklisted($ip) { + if ($this->hive['DNSBL'] && + !in_array($ip, + is_array($this->hive['EXEMPT'])? + $this->hive['EXEMPT']: + $this->split($this->hive['EXEMPT']))) { + // Reverse IPv4 dotted quad + $rev=implode('.',array_reverse(explode('.',$ip))); + foreach (is_array($this->hive['DNSBL'])? + $this->hive['DNSBL']: + $this->split($this->hive['DNSBL']) as $server) + // DNSBL lookup + if (checkdnsrr($rev.'.'.$server,'A')) + return TRUE; + } + return FALSE; + } + + /** + Match routes against incoming URI + @return NULL + **/ + function run() { + if ($this->blacklisted($this->hive['IP'])) + // Spammer detected + $this->error(403); + if (!$this->hive['ROUTES']) + // No routes defined + user_error(self::E_Routes); + // Match specific routes first + krsort($this->hive['ROUTES']); + // Convert to BASE-relative URL + $req=preg_replace( + '/^'.preg_quote($this->hive['BASE'],'/').'\b(.*)/','\1', + $this->hive['URI'] + ); + $allowed=array(); + $case=$this->hive['CASELESS']?'i':''; + foreach ($this->hive['ROUTES'] as $url=>$types) { + if (!preg_match('/^'. + preg_replace('/@(\w+\b)/','(?P<\1>[^\/\?]+)', + str_replace('\*','(.*)',preg_quote($url,'/'))). + '\/?(?:\?.*)?$/'.$case.'um',$req,$args)) + continue; + $route=NULL; + if (isset($types[$this->hive['AJAX']+1])) + $route=$types[$this->hive['AJAX']+1]; + elseif (isset($types[self::REQ_SYNC|self::REQ_AJAX])) + $route=$types[self::REQ_SYNC|self::REQ_AJAX]; + if (!$route) + continue; + if (isset($route[$this->hive['VERB']])) { + $parts=parse_url($req); + if ($this->hive['VERB']=='GET' && + preg_match('/.+\/$/',$parts['path'])) + $this->reroute(substr($parts['path'],0,-1). + (isset($parts['query'])?('?'.$parts['query']):'')); + list($handler,$ttl,$kbps)=$route[$this->hive['VERB']]; + if (is_bool(strpos($url,'/*'))) + foreach (array_keys($args) as $key) + if (is_numeric($key) && $key) + unset($args[$key]); + if (is_string($handler)) + // Replace route pattern tokens in handler if any + $handler=preg_replace_callback('/@(\w+\b)/', + function($id) use($args) { + return isset($args[$id[1]])?$args[$id[1]]:$id[0]; + }, + $handler + ); + // Capture values of route pattern tokens + $this->hive['PARAMS']=$args=array_map('urldecode',$args); + // Save matching route + $this->hive['PATTERN']=$url; + // Process request + $body=''; + $now=microtime(TRUE); + if (preg_match('/GET|HEAD/',$this->hive['VERB']) && + isset($ttl)) { + // Only GET and HEAD requests are cacheable + $headers=$this->hive['HEADERS']; + $cache=Cache::instance(); + $cached=$cache->exists( + $hash=$this->hash($this->hive['VERB'].' '. + $this->hive['URI']).'.url',$data); + if ($cached && $cached+$ttl>$now) { + // Retrieve from cache backend + list($headers,$body)=$data; + if (PHP_SAPI!='cli') + array_walk($headers,'header'); + $this->expire($cached+$ttl-$now); + } + else + // Expire HTTP client-cached page + $this->expire($ttl); + } + else + $this->expire(0); + if (!strlen($body)) { + ob_start(); + // Call route handler + $this->call($handler,array($this,$args), + 'beforeroute,afterroute'); + $body=ob_get_clean(); + if ($ttl && !error_get_last()) + // Save to cache backend + $cache->set($hash,array(headers_list(),$body),$ttl); + } + $this->hive['RESPONSE']=$body; + if (!$this->hive['QUIET']) { + if ($kbps) { + $ctr=0; + foreach (str_split($body,1024) as $part) { + // Throttle output + $ctr++; + if ($ctr/$kbps>$elapsed=microtime(TRUE)-$now && + !connection_aborted()) + usleep(1e6*($ctr/$kbps-$elapsed)); + echo $part; + } + } + else + echo $body; + } + return; + } + $allowed=array_keys($route); + break; + } + if (!$allowed) + // URL doesn't match any route + $this->error(404); + elseif (PHP_SAPI!='cli') { + // Unhandled HTTP method + header('Allow: '.implode(',',$allowed)); + if ($this->hive['VERB']!='OPTIONS') + $this->error(405); + } + } + + /** + Execute callback/hooks (supports 'class->method' format) + @return mixed|FALSE + @param $func callback + @param $args mixed + @param $hooks string + **/ + function call($func,$args=NULL,$hooks='') { + if (!is_array($args)) + $args=array($args); + // Execute function; abort if callback/hook returns FALSE + if (is_string($func) && + preg_match('/(.+)\h*(->|::)\h*(.+)/s',$func,$parts)) { + // Convert string to executable PHP callback + if (!class_exists($parts[1])) + $this->error(404); + if ($parts[2]=='->') + $parts[1]=is_subclass_of($parts[1],'Prefab')? + call_user_func($parts[1].'::instance'): + new $parts[1]; + $func=array($parts[1],$parts[3]); + } + if (!is_callable($func) && $hooks=='beforeroute,afterroute') + // No route handler + $this->error(404); + $obj=FALSE; + if (is_array($func)) { + $hooks=$this->split($hooks); + $obj=TRUE; + } + // Execute pre-route hook if any + if ($obj && $hooks && in_array($hook='beforeroute',$hooks) && + method_exists($func[0],$hook) && + call_user_func_array(array($func[0],$hook),$args)===FALSE) + return FALSE; + // Execute callback + $out=call_user_func_array($func,$args?:array()); + if ($out===FALSE) + return FALSE; + // Execute post-route hook if any + if ($obj && $hooks && in_array($hook='afterroute',$hooks) && + method_exists($func[0],$hook) && + call_user_func_array(array($func[0],$hook),$args)===FALSE) + return FALSE; + return $out; + } + + /** + Execute specified callbacks in succession; Apply same arguments + to all callbacks + @return array + @param $funcs array|string + @param $args mixed + **/ + function chain($funcs,$args=NULL) { + $out=array(); + foreach (is_array($funcs)?$funcs:$this->split($funcs) as $func) + $out[]=$this->call($func,$args); + return $out; + } + + /** + Execute specified callbacks in succession; Relay result of + previous callback as argument to the next callback + @return array + @param $funcs array|string + @param $args mixed + **/ + function relay($funcs,$args=NULL) { + foreach (is_array($funcs)?$funcs:$this->split($funcs) as $func) + $args=array($this->call($func,$args)); + return array_shift($args); + } + + /** + Configure framework according to .ini-style file settings + @return NULL + @param $file string + **/ + function config($file) { + preg_match_all( + '/(?<=^|\n)(?:'. + '(?:;[^\n]*)|(?:<\?php.+?\?>?)|'. + '(?:\[(.+?)\])|'. + '(.+?)\h*=\h*'. + '((?:\\\\\h*\r?\n|.+?)*)'. + ')(?=\r?\n|$)/', + file_get_contents($file),$matches,PREG_SET_ORDER); + if ($matches) { + $sec='globals'; + foreach ($matches as $match) { + if (count($match)<2) + continue; + if ($match[1]) + $sec=$match[1]; + elseif (in_array($sec,array('routes','maps'))) { + call_user_func_array( + array($this,rtrim($sec,'s')), + array_merge(array($match[2]),str_getcsv($match[3]))); + } + else { + $args=array_map( + function($val) { + $quote=(isset($val[0]) && $val[0]=="\x00"); + $val=trim($val); + if (!$quote && is_numeric($val)) + return $val+0; + if (preg_match('/^\w+$/i',$val) && defined($val)) + return constant($val); + return preg_replace( + '/\\\\\h*\r?\n/','',$val); + }, + // Mark quoted strings with 0x00 whitespace + str_getcsv(preg_replace( + '/(")(.+?)\1/',"\\1\x00\\2\\1",$match[3])) + ); + call_user_func_array(array($this,'set'), + array_merge( + array($match[2]), + count($args)>1?array($args):$args)); + } + } + } + } + + /** + Create mutex, invoke callback then drop ownership when done + @return mixed + @param $id string + @param $func callback + @param $args mixed + **/ + function mutex($id,$func,$args=NULL) { + if (!is_dir($tmp=$this->hive['TEMP'])) + mkdir($tmp,self::MODE,TRUE); + // Use filesystem lock + if (is_file($lock=$tmp. + $this->hash($this->hive['ROOT'].$this->hive['BASE']).'.'. + $this->hash($id).'.lock') && + filemtime($lock)+ini_get('max_execution_time')call($func,$args); + fclose($handle); + @unlink($lock); + return $out; + } + + /** + Read file (with option to apply Unix LF as standard line ending) + @return string + @param $file string + @param $lf bool + **/ + function read($file,$lf=FALSE) { + $out=file_get_contents($file); + return $lf?preg_replace('/\r\n|\r/',"\n",$out):$out; + } + + /** + Exclusive file write + @return int|FALSE + @param $file string + @param $data mixed + @param $append bool + **/ + function write($file,$data,$append=FALSE) { + return file_put_contents($file,$data,LOCK_EX|($append?FILE_APPEND:0)); + } + + /** + Apply syntax highlighting + @return string + @param $text string + **/ + function highlight($text) { + $out=''; + $pre=FALSE; + $text=trim($text); + if (!preg_match('/^<\?php/',$text)) { + $text=''. + $this->encode($token[1]).''): + ('>'.$this->encode($token))). + ''; + return $out?(''.$out.''):$text; + } + + /** + Dump expression with syntax highlighting + @return NULL + @param $expr mixed + **/ + function dump($expr) { + echo $this->highlight($this->stringify($expr)); + } + + /** + Namespace-aware class autoloader + @return mixed + @param $class string + **/ + protected function autoload($class) { + $class=$this->fixslashes(ltrim($class,'\\')); + foreach ($this->split($this->hive['PLUGINS'].';'. + $this->hive['AUTOLOAD']) as $auto) + if (is_file($file=$auto.$class.'.php') || + is_file($file=$auto.strtolower($class).'.php')) + return require($file); + } + + /** + Execute framework/application shutdown sequence + @return NULL + **/ + function unload() { + if (($error=error_get_last()) && + in_array($error['type'], + array(E_ERROR,E_PARSE,E_CORE_ERROR,E_COMPILE_ERROR))) + // Fatal error detected + $this->error(500,sprintf(self::E_Fatal,$error['message']), + array($error)); + if (isset($this->hive['UNLOAD'])) + $this->hive['UNLOAD']($this); + } + + /** + Return class instance + @return object + **/ + static function instance() { + if (!Registry::exists($class=__CLASS__)) + Registry::set($class,new $class); + return Registry::get($class); + } + + //! Prohibit cloning + private function __clone() { + } + + //! Bootstrap + private function __construct() { + // Managed directives + ini_set('default_charset',$charset='UTF-8'); + ini_set('display_errors',0); + // Deprecated directives + @ini_set('magic_quotes_gpc',0); + @ini_set('register_globals',0); + // Abort on startup error + // Intercept errors/exceptions; PHP5.3-compatible + error_reporting(E_ALL|E_STRICT); + $fw=$this; + set_exception_handler( + function($obj) use($fw) { + $fw->error(500,$obj->getmessage(),$obj->gettrace()); + } + ); + set_error_handler( + function($code,$text) use($fw) { + if (error_reporting()) + throw new ErrorException($text,$code); + } + ); + if (!isset($_SERVER['SERVER_NAME'])) + $_SERVER['SERVER_NAME']=gethostname(); + if (PHP_SAPI=='cli') { + // Emulate HTTP request + if (isset($_SERVER['argc']) && $_SERVER['argc']<2) { + $_SERVER['argc']++; + $_SERVER['argv'][1]='/'; + } + $_SERVER['REQUEST_METHOD']='GET'; + $_SERVER['REQUEST_URI']=$_SERVER['argv'][1]; + } + $headers=array(); + if (PHP_SAPI!='cli') + foreach (array_keys($_SERVER) as $key) + if (substr($key,0,5)=='HTTP_') + $headers[strtr(ucwords(strtolower(strtr( + substr($key,5),'_',' '))),' ','-')]=&$_SERVER[$key]; + if (isset($headers['X-HTTP-Method-Override'])) + $_SERVER['REQUEST_METHOD']=$headers['X-HTTP-Method-Override']; + $scheme=isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on' || + isset($headers['X-Forwarded-Proto']) && + $headers['X-Forwarded-Proto']=='https'?'https':'http'; + $base=implode('/',array_map('urlencode', + explode('/',$this->fixslashes( + preg_replace('/\/[^\/]+$/','',$_SERVER['SCRIPT_NAME']))))); + call_user_func_array('session_set_cookie_params', + $jar=array( + 'expire'=>0, + 'path'=>$base?:'/', + 'domain'=>is_int(strpos($_SERVER['SERVER_NAME'],'.')) && + !filter_var($_SERVER['SERVER_NAME'],FILTER_VALIDATE_IP)? + $_SERVER['SERVER_NAME']:'', + 'secure'=>($scheme=='https'), + 'httponly'=>TRUE + ) + ); + // Default configuration + $this->hive=array( + 'AJAX'=>isset($headers['X-Requested-With']) && + $headers['X-Requested-With']=='XMLHttpRequest', + 'AUTOLOAD'=>'./', + 'BASE'=>$base, + 'BODY'=>file_get_contents('php://input'), + 'CACHE'=>FALSE, + 'CASELESS'=>TRUE, + 'DEBUG'=>0, + 'DIACRITICS'=>array(), + 'DNSBL'=>'', + 'ENCODING'=>$charset, + 'ERROR'=>NULL, + 'ESCAPE'=>TRUE, + 'EXEMPT'=>NULL, + 'FALLBACK'=>$this->fallback, + 'HEADERS'=>$headers, + 'HIGHLIGHT'=>TRUE, + 'HOST'=>$_SERVER['SERVER_NAME'], + 'IP'=>isset($headers['Client-IP'])? + $headers['Client-IP']: + (isset($headers['X-Forwarded-For']) && + ($ip=strstr($headers['X-Forwarded-For'],',',TRUE))? + $ip: + (isset($_SERVER['REMOTE_ADDR'])? + $_SERVER['REMOTE_ADDR']:'')), + 'JAR'=>$jar, + 'LANGUAGE'=>isset($headers['Accept-Language'])? + $this->language($headers['Accept-Language']):$this->fallback, + 'LOCALES'=>'./', + 'LOGS'=>'./', + 'ONERROR'=>NULL, + 'PACKAGE'=>self::PACKAGE, + 'PARAMS'=>array(), + 'PATTERN'=>NULL, + 'PLUGINS'=>$this->fixslashes(__DIR__).'/', + 'PORT'=>isset($_SERVER['SERVER_PORT'])? + $_SERVER['SERVER_PORT']:NULL, + 'QUIET'=>FALSE, + 'REALM'=>$scheme.'://'. + $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'], + 'RESPONSE'=>'', + 'ROOT'=>$_SERVER['DOCUMENT_ROOT'], + 'ROUTES'=>array(), + 'SCHEME'=>$scheme, + 'SERIALIZER'=>extension_loaded($ext='igbinary')?$ext:'php', + 'TEMP'=>'tmp/', + 'TIME'=>microtime(TRUE), + 'TZ'=>ini_get('date.timezone'), + 'UI'=>'./', + 'UNLOAD'=>NULL, + 'UPLOADS'=>'./', + 'URI'=>&$_SERVER['REQUEST_URI'], + 'VERB'=>&$_SERVER['REQUEST_METHOD'], + 'VERSION'=>self::VERSION + ); + if (PHP_SAPI=='cli-server' && + preg_match('/^'.preg_quote($base,'/').'$/',$this->hive['URI'])) + $this->reroute('/'); + if (ini_get('auto_globals_jit')) + // Override setting + $GLOBALS+=array('_ENV'=>$_ENV,'_REQUEST'=>$_REQUEST); + // Sync PHP globals with corresponding hive keys + $this->init=$this->hive; + foreach (explode('|',self::GLOBALS) as $global) { + $sync=$this->sync($global); + $this->init+=array( + $global=>preg_match('/SERVER|ENV/',$global)?$sync:array() + ); + } + if ($error=error_get_last()) + // Error detected + $this->error(500,sprintf(self::E_Fatal,$error['message']), + array($error)); + // Register framework autoloader + spl_autoload_register(array($this,'autoload')); + // Register shutdown handler + register_shutdown_function(array($this,'unload')); + } + + /** + Wrap-up + @return NULL + **/ + function __destruct() { + Registry::clear(__CLASS__); + } + +} + +//! Cache engine +final class Cache { + + private + //! Cache DSN + $dsn, + //! Prefix for cache entries + $prefix, + //! MemCache object + $ref; + + /** + Return timestamp of cache entry or FALSE if not found + @return float|FALSE + @param $key string + @param $val mixed + **/ + function exists($key,&$val=NULL) { + $fw=Base::instance(); + if (!$this->dsn) + return FALSE; + $ndx=$this->prefix.'.'.$key; + $parts=explode('=',$this->dsn,2); + switch ($parts[0]) { + case 'apc': + $raw=apc_fetch($ndx); + break; + case 'memcache': + $raw=memcache_get($this->ref,$ndx); + break; + case 'wincache': + $raw=wincache_ucache_get($ndx); + break; + case 'xcache': + $raw=xcache_get($ndx); + break; + case 'folder': + if (is_file($file=$parts[1].$ndx)) + $raw=$fw->read($file); + break; + } + if (isset($raw)) { + list($val,$time,$ttl)=$fw->unserialize($raw); + if (!$ttl || $time+$ttl>microtime(TRUE)) + return $time; + $this->clear($key); + } + return FALSE; + } + + /** + Store value in cache + @return mixed|FALSE + @param $key string + @param $val mixed + @param $ttl int + **/ + function set($key,$val,$ttl=0) { + $fw=Base::instance(); + if (!$this->dsn) + return TRUE; + $ndx=$this->prefix.'.'.$key; + $data=$fw->serialize(array($val,microtime(TRUE),$ttl)); + $parts=explode('=',$this->dsn,2); + switch ($parts[0]) { + case 'apc': + return apc_store($ndx,$data,$ttl); + case 'memcache': + return memcache_set($this->ref,$ndx,$data,0,$ttl); + case 'wincache': + return wincache_ucache_set($ndx,$data,$ttl); + case 'xcache': + return xcache_set($ndx,$data,$ttl); + case 'folder': + return $fw->write($parts[1].$ndx,$data); + } + return FALSE; + } + + /** + Retrieve value of cache entry + @return mixed|FALSE + @param $key string + **/ + function get($key) { + return $this->dsn && $this->exists($key,$data)?$data:FALSE; + } + + /** + Delete cache entry + @return bool + @param $key string + **/ + function clear($key) { + if (!$this->dsn) + return; + $ndx=$this->prefix.'.'.$key; + $parts=explode('=',$this->dsn,2); + switch ($parts[0]) { + case 'apc': + return apc_delete($ndx); + case 'memcache': + return memcache_delete($this->ref,$ndx); + case 'wincache': + return wincache_ucache_delete($ndx); + case 'xcache': + return xcache_unset($ndx); + case 'folder': + return is_file($file=$parts[1].$ndx) && @unlink($file); + } + return FALSE; + } + + /** + Clear contents of cache backend + @return bool + @param $suffix string + @param $lifetime int + **/ + function reset($suffix=NULL,$lifetime=0) { + if (!$this->dsn) + return TRUE; + $regex='/'.preg_quote($this->prefix.'.','/').'.+?'. + preg_quote($suffix,'/').'/'; + $parts=explode('=',$this->dsn,2); + switch ($parts[0]) { + case 'apc': + $info=apc_cache_info('user'); + foreach ($info['cache_list'] as $item) + if (preg_match($regex,$item['info']) && + $item['mtime']+$lifetimeref,'slabs') as $slabs) + foreach (array_filter(array_keys($slabs),'is_numeric') + as $id) + foreach (memcache_get_extended_stats( + $this->ref,'cachedump',$id) as $data) + if (is_array($data)) + foreach ($data as $key=>$val) + if (preg_match($regex,$key) && + $val[1]+$lifetimeref,$key); + return TRUE; + case 'wincache': + $info=wincache_ucache_info(); + foreach ($info['ucache_entries'] as $item) + if (preg_match($regex,$item['key_name']) && + $item['use_time']+$lifetimesplit($parts[1]) as $server) { + $port=11211; + $parts=explode(':',$server,2); + if (count($parts)>1) + list($host,$port)=$parts; + else + $host=$parts[0]; + if (empty($this->ref)) + $this->ref=@memcache_connect($host,$port)?:NULL; + else + memcache_add_server($this->ref,$host,$port); + } + if (empty($this->ref) && !preg_match('/^folder\h*=/',$dsn)) + $dsn=($grep=preg_grep('/^(apc|wincache|xcache)/', + array_map('strtolower',get_loaded_extensions())))? + // Auto-detect + current($grep): + // Use filesystem as fallback + ('folder='.$fw->get('TEMP').'cache/'); + if (preg_match('/^folder\h*=\h*(.+)/',$dsn,$parts) && + !is_dir($parts[1])) + mkdir($parts[1],Base::MODE,TRUE); + } + return $this->dsn=$dsn; + } + + /** + Return class instance + @return object + **/ + static function instance() { + if (!Registry::exists($class=__CLASS__)) + Registry::set($class,new $class); + return Registry::get($class); + } + + //! Prohibit cloning + private function __clone() { + } + + //! Prohibit instantiation + private function __construct() { + $fw=Base::instance(); + $this->prefix=$fw->hash($fw->get('ROOT').$fw->get('BASE')); + } + + /** + Wrap-up + @return NULL + **/ + function __destruct() { + Registry::clear(__CLASS__); + } + +} + +//! Prefab for classes with constructors and static factory methods +abstract class Prefab { + + /** + Return class instance + @return object + **/ + static function instance() { + if (!Registry::exists($class=get_called_class())) + Registry::set($class,new $class); + return Registry::get($class); + } + + /** + Wrap-up + @return NULL + **/ + function __destruct() { + Registry::clear(get_called_class()); + } + +} + +//! View handler +class View extends Prefab { + + protected + //! Template file + $view, + //! Local hive + $hive; + + /** + Create sandbox for template execution + @return string + **/ + protected function sandbox() { + extract($this->hive); + ob_start(); + require($this->view); + return ob_get_clean(); + } + + /** + Render template + @return string + @param $file string + @param $mime string + @param $hive array + **/ + function render($file,$mime='text/html',array $hive=NULL) { + $fw=Base::instance(); + foreach ($fw->split($fw->get('UI')) as $dir) + if (is_file($this->view=$fw->fixslashes($dir.$file))) { + if (isset($_COOKIE[session_name()])) + @session_start(); + $fw->sync('SESSION'); + if (!$hive) + $hive=$fw->hive(); + $this->hive=$fw->get('ESCAPE')?$hive=$fw->esc($hive):$hive; + if (PHP_SAPI!='cli') + header('Content-Type: '.$mime.'; '. + 'charset='.$fw->get('ENCODING')); + return $this->sandbox(); + } + user_error(sprintf(Base::E_Open,$file)); + } + +} + +//! ISO language/country codes +class ISO extends Prefab { + + //@{ ISO 3166-1 country codes + const + CC_af='Afghanistan', + CC_ax='Åland Islands', + CC_al='Albania', + CC_dz='Algeria', + CC_as='American Samoa', + CC_ad='Andorra', + CC_ao='Angola', + CC_ai='Anguilla', + CC_aq='Antarctica', + CC_ag='Antigua and Barbuda', + CC_ar='Argentina', + CC_am='Armenia', + CC_aw='Aruba', + CC_au='Australia', + CC_at='Austria', + CC_az='Azerbaijan', + CC_bs='Bahamas', + CC_bh='Bahrain', + CC_bd='Bangladesh', + CC_bb='Barbados', + CC_by='Belarus', + CC_be='Belgium', + CC_bz='Belize', + CC_bj='Benin', + CC_bm='Bermuda', + CC_bt='Bhutan', + CC_bo='Bolivia', + CC_bq='Bonaire, Sint Eustatius and Saba', + CC_ba='Bosnia and Herzegovina', + CC_bw='Botswana', + CC_bv='Bouvet Island', + CC_br='Brazil', + CC_io='British Indian Ocean Territory', + CC_bn='Brunei Darussalam', + CC_bg='Bulgaria', + CC_bf='Burkina Faso', + CC_bi='Burundi', + CC_kh='Cambodia', + CC_cm='Cameroon', + CC_ca='Canada', + CC_cv='Cape Verde', + CC_ky='Cayman Islands', + CC_cf='Central African Republic', + CC_td='Chad', + CC_cl='Chile', + CC_cn='China', + CC_cx='Christmas Island', + CC_cc='Cocos (Keeling) Islands', + CC_co='Colombia', + CC_km='Comoros', + CC_cg='Congo', + CC_cd='Congo, The Democratic Republic of', + CC_ck='Cook Islands', + CC_cr='Costa Rica', + CC_ci='Côte d\'ivoire', + CC_hr='Croatia', + CC_cu='Cuba', + CC_cw='Curaçao', + CC_cy='Cyprus', + CC_cz='Czech Republic', + CC_dk='Denmark', + CC_dj='Djibouti', + CC_dm='Dominica', + CC_do='Dominican Republic', + CC_ec='Ecuador', + CC_eg='Egypt', + CC_sv='El Salvador', + CC_gq='Equatorial Guinea', + CC_er='Eritrea', + CC_ee='Estonia', + CC_et='Ethiopia', + CC_fk='Falkland Islands (Malvinas)', + CC_fo='Faroe Islands', + CC_fj='Fiji', + CC_fi='Finland', + CC_fr='France', + CC_gf='French Guiana', + CC_pf='French Polynesia', + CC_tf='French Southern Territories', + CC_ga='Gabon', + CC_gm='Gambia', + CC_ge='Georgia', + CC_de='Germany', + CC_gh='Ghana', + CC_gi='Gibraltar', + CC_gr='Greece', + CC_gl='Greenland', + CC_gd='Grenada', + CC_gp='Guadeloupe', + CC_gu='Guam', + CC_gt='Guatemala', + CC_gg='Guernsey', + CC_gn='Guinea', + CC_gw='Guinea-Bissau', + CC_gy='Guyana', + CC_ht='Haiti', + CC_hm='Heard Island and McDonald Islands', + CC_va='Holy See (Vatican City State)', + CC_hn='Honduras', + CC_hk='Hong Kong', + CC_hu='Hungary', + CC_is='Iceland', + CC_in='India', + CC_id='Indonesia', + CC_ir='Iran, Islamic Republic of', + CC_iq='Iraq', + CC_ie='Ireland', + CC_im='Isle of Man', + CC_il='Israel', + CC_it='Italy', + CC_jm='Jamaica', + CC_jp='Japan', + CC_je='Jersey', + CC_jo='Jordan', + CC_kz='Kazakhstan', + CC_ke='Kenya', + CC_ki='Kiribati', + CC_kp='Korea, Democratic People\'s Republic of', + CC_kr='Korea, Republic of', + CC_kw='Kuwait', + CC_kg='Kyrgyzstan', + CC_la='Lao People\'s Democratic Republic', + CC_lv='Latvia', + CC_lb='Lebanon', + CC_ls='Lesotho', + CC_lr='Liberia', + CC_ly='Libya', + CC_li='Liechtenstein', + CC_lt='Lithuania', + CC_lu='Luxembourg', + CC_mo='Macao', + CC_mk='Macedonia, The Former Yugoslav Republic of', + CC_mg='Madagascar', + CC_mw='Malawi', + CC_my='Malaysia', + CC_mv='Maldives', + CC_ml='Mali', + CC_mt='Malta', + CC_mh='Marshall Islands', + CC_mq='Martinique', + CC_mr='Mauritania', + CC_mu='Mauritius', + CC_yt='Mayotte', + CC_mx='Mexico', + CC_fm='Micronesia, Federated States of', + CC_md='Moldova, Republic of', + CC_mc='Monaco', + CC_mn='Mongolia', + CC_me='Montenegro', + CC_ms='Montserrat', + CC_ma='Morocco', + CC_mz='Mozambique', + CC_mm='Myanmar', + CC_na='Namibia', + CC_nr='Nauru', + CC_np='Nepal', + CC_nl='Netherlands', + CC_nc='New Caledonia', + CC_nz='New Zealand', + CC_ni='Nicaragua', + CC_ne='Niger', + CC_ng='Nigeria', + CC_nu='Niue', + CC_nf='Norfolk Island', + CC_mp='Northern Mariana Islands', + CC_no='Norway', + CC_om='Oman', + CC_pk='Pakistan', + CC_pw='Palau', + CC_ps='Palestinian Territory, Occupied', + CC_pa='Panama', + CC_pg='Papua New Guinea', + CC_py='Paraguay', + CC_pe='Peru', + CC_ph='Philippines', + CC_pn='Pitcairn', + CC_pl='Poland', + CC_pt='Portugal', + CC_pr='Puerto Rico', + CC_qa='Qatar', + CC_re='Réunion', + CC_ro='Romania', + CC_ru='Russian Federation', + CC_rw='Rwanda', + CC_bl='Saint Barthélemy', + CC_sh='Saint Helena, Ascension and Tristan da Cunha', + CC_kn='Saint Kitts and Nevis', + CC_lc='Saint Lucia', + CC_mf='Saint Martin (French Part)', + CC_pm='Saint Pierre and Miquelon', + CC_vc='Saint Vincent and The Grenadines', + CC_ws='Samoa', + CC_sm='San Marino', + CC_st='Sao Tome and Principe', + CC_sa='Saudi Arabia', + CC_sn='Senegal', + CC_rs='Serbia', + CC_sc='Seychelles', + CC_sl='Sierra Leone', + CC_sg='Singapore', + CC_sk='Slovakia', + CC_sx='Sint Maarten (Dutch Part)', + CC_si='Slovenia', + CC_sb='Solomon Islands', + CC_so='Somalia', + CC_za='South Africa', + CC_gs='South Georgia and The South Sandwich Islands', + CC_ss='South Sudan', + CC_es='Spain', + CC_lk='Sri Lanka', + CC_sd='Sudan', + CC_sr='Suriname', + CC_sj='Svalbard and Jan Mayen', + CC_sz='Swaziland', + CC_se='Sweden', + CC_ch='Switzerland', + CC_sy='Syrian Arab Republic', + CC_tw='Taiwan, Province of China', + CC_tj='Tajikistan', + CC_tz='Tanzania, United Republic of', + CC_th='Thailand', + CC_tl='Timor-Leste', + CC_tg='Togo', + CC_tk='Tokelau', + CC_to='Tonga', + CC_tt='Trinidad and Tobago', + CC_tn='Tunisia', + CC_tr='Turkey', + CC_tm='Turkmenistan', + CC_tc='Turks and Caicos Islands', + CC_tv='Tuvalu', + CC_ug='Uganda', + CC_ua='Ukraine', + CC_ae='United Arab Emirates', + CC_gb='United Kingdom', + CC_us='United States', + CC_um='United States Minor Outlying Islands', + CC_uy='Uruguay', + CC_uz='Uzbekistan', + CC_vu='Vanuatu', + CC_ve='Venezuela', + CC_vn='Viet Nam', + CC_vg='Virgin Islands, British', + CC_vi='Virgin Islands, U.S.', + CC_wf='Wallis and Futuna', + CC_eh='Western Sahara', + CC_ye='Yemen', + CC_zm='Zambia', + CC_zw='Zimbabwe'; + //@} + + //@{ ISO 639-1 language codes (Windows-compatibility subset) + const + LC_af='Afrikaans', + LC_am='Amharic', + LC_ar='Arabic', + LC_as='Assamese', + LC_ba='Bashkir', + LC_be='Belarusian', + LC_bg='Bulgarian', + LC_bn='Bengali', + LC_bo='Tibetan', + LC_br='Breton', + LC_ca='Catalan', + LC_co='Corsican', + LC_cs='Czech', + LC_cy='Welsh', + LC_da='Danish', + LC_de='German', + LC_dv='Divehi', + LC_el='Greek', + LC_en='English', + LC_es='Spanish', + LC_et='Estonian', + LC_eu='Basque', + LC_fa='Persian', + LC_fi='Finnish', + LC_fo='Faroese', + LC_fr='French', + LC_gd='Scottish Gaelic', + LC_gl='Galician', + LC_gu='Gujarati', + LC_he='Hebrew', + LC_hi='Hindi', + LC_hr='Croatian', + LC_hu='Hungarian', + LC_hy='Armenian', + LC_id='Indonesian', + LC_ig='Igbo', + LC_is='Icelandic', + LC_it='Italian', + LC_ja='Japanese', + LC_ka='Georgian', + LC_kk='Kazakh', + LC_km='Khmer', + LC_kn='Kannada', + LC_ko='Korean', + LC_lb='Luxembourgish', + LC_lo='Lao', + LC_lt='Lithuanian', + LC_lv='Latvian', + LC_mi='Maori', + LC_ml='Malayalam', + LC_mr='Marathi', + LC_ms='Malay', + LC_mt='Maltese', + LC_ne='Nepali', + LC_nl='Dutch', + LC_no='Norwegian', + LC_oc='Occitan', + LC_or='Oriya', + LC_pl='Polish', + LC_ps='Pashto', + LC_pt='Portuguese', + LC_qu='Quechua', + LC_ro='Romanian', + LC_ru='Russian', + LC_rw='Kinyarwanda', + LC_sa='Sanskrit', + LC_si='Sinhala', + LC_sk='Slovak', + LC_sl='Slovenian', + LC_sq='Albanian', + LC_sv='Swedish', + LC_ta='Tamil', + LC_te='Telugu', + LC_th='Thai', + LC_tk='Turkmen', + LC_tr='Turkish', + LC_tt='Tatar', + LC_uk='Ukrainian', + LC_ur='Urdu', + LC_vi='Vietnamese', + LC_wo='Wolof', + LC_yo='Yoruba', + LC_zh='Chinese'; + //@} + + /** + Convert class constants to array + @return array + @param $prefix string + **/ + protected function constants($prefix) { + $ref=new ReflectionClass($this); + $out=array(); + foreach (preg_grep('/^'.$prefix.'/',array_keys($ref->getconstants())) + as $val) { + $out[$key=substr($val,strlen($prefix))]= + constant('self::'.$prefix.$key); + } + unset($ref); + return $out; + } + + /** + Return list of languages indexed by ISO 639-1 language code + @return array + **/ + function languages() { + return $this->constants('LC_'); + } + + /** + Return list of countries indexed by ISO 3166-1 country code + @return array + **/ + function countries() { + return $this->constants('CC_'); + } + +} + +//! Container for singular object instances +final class Registry { + + private static + //! Object catalog + $table; + + /** + Return TRUE if object exists in catalog + @return bool + @param $key string + **/ + static function exists($key) { + return isset(self::$table[$key]); + } + + /** + Add object to catalog + @return object + @param $key string + @param $obj object + **/ + static function set($key,$obj) { + return self::$table[$key]=$obj; + } + + /** + Retrieve object from catalog + @return object + @param $key string + **/ + static function get($key) { + return self::$table[$key]; + } + + /** + Remove object from catalog + @return NULL + @param $key string + **/ + static function clear($key) { + unset(self::$table[$key]); + } + + //! Prohibit cloning + private function __clone() { + } + + //! Prohibit instantiation + private function __construct() { + } + +} + +return Base::instance(); diff --git a/lib/basket.php b/lib/basket.php new file mode 100644 index 0000000..0be3e3a --- /dev/null +++ b/lib/basket.php @@ -0,0 +1,207 @@ +item); + } + + /** + Assign value to field + @return scalar|FALSE + @param $key string + @param $val scalar + **/ + function set($key,$val) { + return ($key=='_id')?FALSE:($this->item[$key]=$val); + } + + /** + Retrieve value of field + @return scalar|FALSE + @param $key string + **/ + function get($key) { + if ($key=='_id') + return $this->id; + if (array_key_exists($key,$this->item)) + return $this->item[$key]; + user_error(sprintf(self::E_Field,$key)); + return FALSE; + } + + /** + Delete field + @return NULL + @param $key string + **/ + function clear($key) { + unset($this->item[$key]); + } + + /** + Return item that matches key/value pair + @return object|FALSE + @param $key string + @param $val mixed + **/ + function find($key,$val) { + if (isset($_SESSION[$this->key])) + foreach ($_SESSION[$this->key] as $id=>$item) + if ($item[$key]==$val) { + $obj=clone($this); + $obj->id=$id; + $obj->item=$item; + return $obj; + } + return FALSE; + } + + /** + Map current item to matching key/value pair + @return array + @param $key string + @param $val mixed + **/ + function load($key,$val) { + if ($found=$this->find($key,$val)) { + $this->id=$found->id; + return $this->item=$found->item; + } + $this->reset(); + return array(); + } + + /** + Return TRUE if current item is empty/undefined + @return bool + **/ + function dry() { + return !$this->item; + } + + /** + Return number of items in basket + @return int + **/ + function count() { + return isset($_SESSION[$this->key])?count($_SESSION[$this->key]):0; + } + + /** + Save current item + @return array + **/ + function save() { + if (!$this->id) + $this->id=uniqid(); + return $_SESSION[$this->key][$this->id]=$this->item; + } + + /** + Erase item matching key/value pair + @return bool + @param $key string + @param $val mixed + **/ + function erase($key,$val) { + if ($id=$this->find($key,$val)->id) { + unset($_SESSION[$this->key][$id]); + if ($id==$this->id) + $this->reset(); + return TRUE; + } + return FALSE; + } + + /** + Reset cursor + @return NULL + **/ + function reset() { + $this->id=NULL; + $this->item=array(); + } + + /** + Empty basket + @return NULL + **/ + function drop() { + unset($_SESSION[$this->key]); + } + + /** + Hydrate item using hive array variable + @return NULL + @param $key string + **/ + function copyfrom($key) { + foreach (\Base::instance()->get($key) as $key=>$val) + $this->item[$key]=$val; + } + + /** + Populate hive array variable with item contents + @return NULL + @param $key string + **/ + function copyto($key) { + $var=&\Base::instance()->ref($key); + foreach ($this->item as $key=>$field) + $var[$key]=$field; + } + + /** + Check out basket contents + @return array + **/ + function checkout() { + if (isset($_SESSION[$this->key])) { + $out=$_SESSION[$this->key]; + unset($_SESSION[$this->key]); + return $out; + } + return array(); + } + + /** + Instantiate class + @return void + @param $key string + **/ + function __construct($key='basket') { + $this->key=$key; + @session_start(); + Base::instance()->sync('SESSION'); + $this->reset(); + } + +} diff --git a/lib/changelog.txt b/lib/changelog.txt new file mode 100644 index 0000000..b9202c6 --- /dev/null +++ b/lib/changelog.txt @@ -0,0 +1,125 @@ +CHANGELOG + +3.0.5 (16 Feb 2013) +* NEW: Markdown class with PHP, HTML, and .ini syntax highlighting support +* NEW: Options for caching of select() and find() results +* NEW: Web->acceptable() +* Add send() argument for forcing downloads +* Provide read() option for applying Unix LF as standard line ending +* Bypass lexicon() call if LANGUAGE is undefined +* Load fallback language dictionary if LANGUAGE is undefined +* map() now checks existence of class/methods for non-tokenized URLs +* Improve error reporting of non-existent Template methods +* Address output buffer issues on some servers +* Bug fix: Setting DEBUG to 0 won't suppress the stack trace when the + content type is application/json (Issue #257) +* Bug fix: Image dump/render additional arguments shifted +* Bug fix: ob_clean() causes buffer issues with zlib compression +* Bug fix: minify() fails when commenting CSS @ rules (Issue #251) +* Bug fix: Handling of commas inside quoted strings +* Bug fix: Glitch in stringify() handling of closures +* Bug fix: dry() in mappers returns TRUE despite being hydrated by + factory() (Issue #265) +* Bug fix: expect() not handling flags correctly +* Bug fix: weather() fails when server is unreachable + +3.0.4 (29 Jan 2013) +* NEW: Support for ICU/CLDR pluralization +* NEW: User-defined FALLBACK language +* NEW: minify() now recognizes CSS @import directives +* NEW: UTF->bom() returns byte order mark for UTF-8 encoding +* Expose SQL\Mapper->schema() +* Change in behavior: Send error response as JSON string if AJAX request is + detected +* Deprecated: afind*() methods +* Discard output buffer in favor of debug output +* Make _id available to Jig queries +* Magic class now implements ArrayAccess +* Abort execution on startup errors +* Suppress stack trace on DEBUG level 0 +* Allow single = as equality operator in Jig query expressions +* Abort OpenID discovery if Web->request() fails +* Mimic PHP *RECURSION* in stringify() +* Modify Jig parser to allow wildcard-search using preg_match() +* Abort execution after error() execution +* Concatenate cached/uncached minify() iterations; Prevent spillover + caching of previous minify() result +* Work around obscure PHP session id regeneration bug +* Revise algorithm for Jig filter involving undefined fields (Issue #230) +* Use checkdnsrr() instead of gethostbyname() in DNSBL check +* Auto-adjust pagination to cursor boundaries +* Add Romanian diacritics +* Bug fix: Root namespace reference and sorting with undefined Jig fields +* Bug fix: Greedy receive() regex +* Bug fix: Default LANGUAGE always 'en' +* Bug fix: minify() hammers cache backend +* Bug fix: Previous values of primary keys not saved during factory() + instantiation +* Bug fix: Jig find() fails when search key is not present in all records +* Bug fix: Jig SORT_DESC (Issue #233) +* Bug fix: Error reporting (Issue #225) +* Bug fix: language() return value + +3.0.3 (29 Dec 2013) +* NEW: [ajax] and [sync] routing pattern modifiers +* NEW: Basket class (session-based pseudo-mapper, shopping cart, etc.) +* NEW: Test->message() method +* NEW: DB profiling via DB->log() +* NEW: Matrix->calendar() +* NEW: Audit->card() and Audit->mod10() for credit card verification +* NEW: Geo->weather() +* NEW: Base->relay() accepts comma-separated callbacks; but unlike + Base->chain(), result of previous callback becomes argument of the next +* Numerous performance tweaks +* Interoperability with new MongoClient class +* Web->request() now recognizes gzip and deflate encoding +* Differences in behavior of Web->request() engines rectified +* mutex() now uses an ID as argument (instead of filename to make it clear + that specified file is not the target being locked, but a primitive + cross-platform semaphore) +* DB\SQL\Mapper field _id now returned even in the absence of any + auto-increment field +* Magic class spinned off as a separate file +* ISO 3166-1 alpha-2 table updated +* Apache redirect emulation for PHP 5.4 CLI server mode +* Framework instance now passed as argument to any user-defined shutdown + function +* Cache engine now used as storage for Web->minify() output +* Flag added for enabling/disabling Image class filter history +* Bug fix: Trailing routing token consumes HTTP query +* Bug fix: LANGUAGE spills over to LOCALES setting +* Bug fix: Inconsistent dry() return value +* Bug fix: URL-decoding + +3.0.2 (23 Dec 2013) +* NEW: Syntax-highlighted stack traces via Base->highlight(); boolean + HIGHLIGHT global variable can be used to enable/disable this feature +* NEW: Template engine tag +* NEW: Image->captcha() +* NEW: DNSBL-based spammer detection (ported from 2.x) +* NEW: paginate(), first(), and last() methods for data mappers +* NEW: X-HTTP-Method-Override header now recognized +* NEW: Base->chain() method for executing callbacks in succession +* NEW: HOST global variable; derived from either $_SERVER['SERVER_NAME'] or + gethostname() +* NEW: REALM global variable representing full canonical URI +* NEW: Auth plug-in +* NEW: Pingback plug-in (implements both Pingback 1.0 protocol client and + server) +* NEW: DEBUG verbosity can now reach up to level 3; Base->stringify() drills + down to object properties at this setting +* NEW: HTTP PATCH method added to recognized HTTP ReST methods +* Web->slug() now trims trailing dashes +* Web->request() now allows relative local URLs as argument +* Use of PARAMS in route handlers now unnecessary; framework now passes two + arguments to route handlers: the framework object instance and an array + containing the captured values of tokens in route patterns +* Standardized timeout settings among Web->request() backends +* Session IDs regenerated for additional security +* Automatic HTTP 404 responses by Base->call() now restricted to route + handlers +* Empty comments in ini-style files now parsed properly +* Use file_get_contents() in methods that don't involve high concurrency + +3.0.1 (14 Dec 2013) +* Major rewrite of much of the framework's core features diff --git a/lib/db/cursor.php b/lib/db/cursor.php new file mode 100644 index 0000000..6afbde0 --- /dev/null +++ b/lib/db/cursor.php @@ -0,0 +1,176 @@ +query[$this->ptr]); + } + + /** + Return first record (mapper object) that matches criteria + @return object|FALSE + @param $filter string|array + @param $options array + @param $ttl int + **/ + function findone($filter=NULL,array $options=NULL,$ttl=0) { + return ($data=$this->find($filter,$options,$ttl))?$data[0]:FALSE; + } + + /** + Return array containing subset of records matching criteria, + number of subsets available, and actual subset position + @return array + @param $pos int + @param $size int + @param $filter string|array + @param $options array + **/ + function paginate($pos=0,$size=10,$filter=NULL,array $options=NULL) { + $count=ceil($this->count($filter,$options)/$size); + $pos=max(0,min($pos,$count-1)); + return array( + 'subset'=>$this->find($filter, + array_merge( + $options?:array(), + array('limit'=>$size,'offset'=>$pos*$size) + ) + ), + 'count'=>$count, + 'pos'=>$pos<$count?$pos:0 + ); + } + + /** + Map to first record that matches criteria + @return array|FALSE + @param $filter string|array + @param $options array + **/ + function load($filter=NULL,array $options=NULL) { + return ($this->query=$this->find($filter,$options)) && + $this->skip(0)?$this->query[$this->ptr=0]:FALSE; + } + + /** + Move pointer to first record in cursor + @return mixed + **/ + function first() { + return $this->query[$this->ptr=0]; + } + + /** + Move pointer to last record in cursor + @return mixed + **/ + function last() { + return $this->query[$this->ptr=($ctr=count($this->query))?$ctr-1:0]; + } + + /** + Map to nth record relative to current cursor position + @return mixed + @param $ofs int + **/ + function skip($ofs=1) { + $this->ptr+=$ofs; + return $this->ptr>-1 && $this->ptrquery)? + $this->query[$this->ptr]:FALSE; + } + + /** + Map next record + @return mixed + **/ + function next() { + return $this->skip(); + } + + /** + Map previous record + @return mixed + **/ + function prev() { + return $this->skip(-1); + } + + /** + Save mapped record + @return mixed + **/ + function save() { + return $this->query?$this->update():$this->insert(); + } + + /** + Delete current record + @return int|bool + **/ + function erase() { + $this->query=array_slice($this->query,0,$this->ptr,TRUE)+ + array_slice($this->query,$this->ptr,NULL,TRUE); + $this->ptr=0; + } + + /** + Reset cursor + @return NULL + **/ + function reset() { + $this->query=array(); + $this->ptr=0; + } + +} diff --git a/lib/db/jig.php b/lib/db/jig.php new file mode 100644 index 0000000..ceab2bc --- /dev/null +++ b/lib/db/jig.php @@ -0,0 +1,115 @@ +dir.$file)) + return array(); + $raw=$fw->read($dst); + switch ($this->format) { + case self::FORMAT_JSON: + $data=json_decode($raw,TRUE); + break; + case self::FORMAT_Serialized: + $data=$fw->unserialize($raw); + break; + } + return $data; + } + + /** + Write data to file + @return int + @param $file string + @param $data array + **/ + function write($file,array $data=NULL) { + $fw=\Base::instance(); + switch ($this->format) { + case self::FORMAT_JSON: + $out=json_encode($data,@constant('JSON_PRETTY_PRINT')); + break; + case self::FORMAT_Serialized: + $out=$fw->serialize($data); + break; + } + $out=$fw->write($this->dir.$file,$out); + return $out; + } + + /** + Return SQL profiler results + @return string + **/ + function log() { + return $this->log; + } + + /** + Jot down log entry + @return NULL + @param $frame string + **/ + function jot($frame) { + if ($frame) + $this->log.=date('r').' '.$frame.PHP_EOL; + } + + /** + Clean storage + @return NULL + **/ + function drop() { + foreach (glob($this->dir.'/*',GLOB_NOSORT) as $file) + @unlink($file); + } + + /** + Instantiate class + @param $dir string + @param $format int + **/ + function __construct($dir,$format=self::FORMAT_JSON) { + if (!is_dir($dir)) + mkdir($dir,\Base::MODE,TRUE); + $this->dir=$dir; + $this->format=$format; + } + +} diff --git a/lib/db/jig/mapper.php b/lib/db/jig/mapper.php new file mode 100644 index 0000000..b06ea6d --- /dev/null +++ b/lib/db/jig/mapper.php @@ -0,0 +1,409 @@ +document); + } + + /** + Assign value to field + @return scalar|FALSE + @param $key string + @param $val scalar + **/ + function set($key,$val) { + return ($key=='_id')?FALSE:($this->document[$key]=$val); + } + + /** + Retrieve value of field + @return scalar|FALSE + @param $key string + **/ + function get($key) { + if ($key=='_id') + return $this->id; + if (array_key_exists($key,$this->document)) + return $this->document[$key]; + user_error(sprintf(self::E_Field,$key)); + return FALSE; + } + + /** + Delete field + @return NULL + @param $key string + **/ + function clear($key) { + unset($this->document[$key]); + } + + /** + Convert array to mapper object + @return object + @param $id string + @param $row array + **/ + protected function factory($id,$row) { + $mapper=clone($this); + $mapper->reset(); + foreach ($row as $field=>$val) { + $mapper->id=$id; + $mapper->document[$field]=$val; + } + $mapper->query=array($row); + $mapper->ptr=0; + return $mapper; + } + + /** + Return fields of mapper object as an associative array + @return array + @param $obj object + **/ + function cast($obj=NULL) { + if (!$obj) + $obj=$this; + return $obj->document; + } + + /** + Convert tokens in string expression to variable names + @return string + @param $str string + **/ + function token($str) { + $self=$this; + $str=preg_replace_callback( + '/(?stringify(substr($expr[1],1)): + (preg_match('/^\w+/', + $mix=$self->token($expr[2]))? + $fw->stringify($mix): + $mix)). + ']'; + }, + $token[1] + ); + }, + $str + ); + return trim($str); + } + + /** + Return records that match criteria + @return array|FALSE + @param $filter array + @param $options array + @param $ttl int + @param $log bool + **/ + function find($filter=NULL,array $options=NULL,$ttl=0,$log=TRUE) { + if (!$options) + $options=array(); + $options+=array( + 'order'=>NULL, + 'limit'=>0, + 'offset'=>0 + ); + $fw=\Base::instance(); + $cache=\Cache::instance(); + $db=$this->db; + $now=microtime(TRUE); + if (!$fw->get('CACHE') || !$ttl || !($cached=$cache->exists( + $hash=$fw->hash($fw->stringify(array($filter,$options))).'.jig', + $data)) || $cached+$ttlread($this->file); + foreach ($data as $key=>&$val) { + $val['_id']=$key; + unset($val); + } + if ($filter) { + if (!is_array($filter)) + return FALSE; + // Normalize equality operator + $expr=preg_replace('/(?<=[^<>!=])=(?!=)/','==',$filter[0]); + // Prepare query arguments + $args=isset($filter[1]) && is_array($filter[1])? + $filter[1]: + array_slice($filter,1,NULL,TRUE); + $args=is_array($args)?$args:array(1=>$args); + $keys=$vals=array(); + $tokens=array_slice( + token_get_all('token($expr)),1); + $data=array_filter($data, + function($_row) use($fw,$args,$tokens) { + $_expr=''; + $ctr=0; + $named=FALSE; + foreach ($tokens as $token) { + if (is_string($token)) + if ($token=='?') { + // Positional + $ctr++; + $key=$ctr; + } + else { + if ($token==':') + $named=TRUE; + else + $_expr.=$token; + continue; + } + elseif ($named && + token_name($token[0])=='T_STRING') { + $key=':'.$token[1]; + $named=FALSE; + } + else { + $_expr.=$token[1]; + continue; + } + $_expr.=$fw->stringify( + is_string($args[$key])? + addcslashes($args[$key],'\''): + $args[$key]); + } + // Avoid conflict with user code + unset($fw,$tokens,$args,$ctr,$token,$key,$named); + extract($_row); + // Evaluate pseudo-SQL expression + return eval('return '.$_expr.';'); + } + ); + } + if (isset($options['order'])) { + $cols=$fw->split($options['order']); + uasort( + $data, + function($val1,$val2) use($cols) { + foreach ($cols as $col) { + $parts=explode(' ',$col,2); + $order=empty($parts[1])? + SORT_ASC: + constant($parts[1]); + $col=$parts[0]; + if (!array_key_exists($col,$val1)) + $val1[$col]=NULL; + if (!array_key_exists($col,$val2)) + $val2[$col]=NULL; + list($v1,$v2)=array($val1[$col],$val2[$col]); + if ($out=strnatcmp($v1,$v2)* + (($order==SORT_ASC)*2-1)) + return $out; + } + return 0; + } + ); + } + $data=array_slice($data, + $options['offset'],$options['limit']?:NULL,TRUE); + if ($fw->get('CACHE') && $ttl) + // Save to cache backend + $cache->set($hash,$data,$ttl); + } + $out=array(); + foreach ($data as $id=>$doc) + $out[]=$this->factory($id,$doc); + if ($log) { + if ($filter) + foreach ($args as $key=>$val) { + $vals[]=$fw->stringify(is_array($val)?$val[0]:$val); + $keys[]='/'.(is_numeric($key)?'\?':preg_quote($key)).'/'; + } + $db->jot('('.sprintf('%.1f',1e3*(microtime(TRUE)-$now)).'ms) '. + $this->file.' [find] '. + ($filter?preg_replace($keys,$vals,$filter[0],1):'')); + } + return $out; + } + + /** + Count records that match criteria + @return int + @param $filter array + **/ + function count($filter=NULL) { + $now=microtime(TRUE); + $out=count($this->find($filter,NULL,FALSE)); + $this->db->jot('('.sprintf('%.1f',1e3*(microtime(TRUE)-$now)).'ms) '. + $this->file.' [count] '.($filter?json_encode($filter):'')); + return $out; + } + + /** + Return record at specified offset using criteria of previous + load() call and make it active + @return array + @param $ofs int + **/ + function skip($ofs=1) { + $this->document=($out=parent::skip($ofs))?$out->document:array(); + $this->id=$out?$out->id:NULL; + return $out; + } + + /** + Insert new record + @return array + **/ + function insert() { + if ($this->id) + return $this->update(); + $db=$this->db; + $now=microtime(TRUE); + while (($id=uniqid()) && + ($data=$db->read($this->file)) && isset($data[$id]) && + !connection_aborted()) + usleep(mt_rand(0,100)); + $this->id=$id; + $data[$id]=$this->document; + $db->write($this->file,$data); + parent::reset(); + $db->jot('('.sprintf('%.1f',1e3*(microtime(TRUE)-$now)).'ms) '. + $this->file.' [insert] '. + json_encode(array('_id'=>$this->id)+$this->document)); + return $this->document; + } + + /** + Update current record + @return array + **/ + function update() { + $db=$this->db; + $now=microtime(TRUE); + $data=$db->read($this->file); + $data[$this->id]=$this->document; + $db->write($this->file,$data); + $db->jot('('.sprintf('%.1f',1e3*(microtime(TRUE)-$now)).'ms) '. + $this->file.' [update] '. + json_encode(array('_id'=>$this->id)+$this->document)); + return $this->document; + } + + /** + Delete current record + @return bool + @param $filter array + **/ + function erase($filter=NULL) { + $db=$this->db; + $now=microtime(TRUE); + $data=$db->read($this->file); + if ($filter) { + $data=$this->find($filter,NULL,FALSE); + foreach (array_keys(array_reverse($data)) as $id) + unset($data[$id]); + } + elseif (isset($this->id)) { + unset($data[$this->id]); + parent::erase(); + $this->skip(0); + } + else + return FALSE; + $db->write($this->file,$data); + if ($filter) { + $args=isset($filter[1]) && is_array($filter[1])? + $filter[1]: + array_slice($filter,1,NULL,TRUE); + $args=is_array($args)?$args:array(1=>$args); + foreach ($args as $key=>$val) { + $vals[]=\Base::instance()-> + stringify(is_array($val)?$val[0]:$val); + $keys[]='/'.(is_numeric($key)?'\?':preg_quote($key)).'/'; + } + } + $db->jot('('.sprintf('%.1f',1e3*(microtime(TRUE)-$now)).'ms) '. + $this->file.' [erase] '. + ($filter?preg_replace($keys,$vals,$filter[0],1):'')); + return TRUE; + } + + /** + Reset cursor + @return NULL + **/ + function reset() { + $this->id=NULL; + $this->document=array(); + parent::reset(); + } + + /** + Hydrate mapper object using hive array variable + @return NULL + @param $key string + **/ + function copyfrom($key) { + foreach (\Base::instance()->get($key) as $key=>$val) + $this->document[$key]=$val; + } + + /** + Populate hive array variable with mapper fields + @return NULL + @param $key string + **/ + function copyto($key) { + $var=&\Base::instance()->ref($key); + foreach ($this->document as $key=>$field) + $var[$key]=$field; + } + + /** + Instantiate class + @return void + @param $db object + @param $file string + **/ + function __construct(\DB\Jig $db,$file) { + $this->db=$db; + $this->file=$file; + $this->reset(); + } + +} diff --git a/lib/db/jig/session.php b/lib/db/jig/session.php new file mode 100644 index 0000000..180c5a1 --- /dev/null +++ b/lib/db/jig/session.php @@ -0,0 +1,137 @@ +load(array('@session_id==?',$id)); + return $this->dry()?FALSE:$this->get('data'); + } + + /** + Write session data + @return TRUE + @param $id string + @param $data string + **/ + function write($id,$data) { + $fw=\Base::instance(); + $headers=$fw->get('HEADERS'); + $this->load(array('@session_id==?',$id)); + $this->set('session_id',$id); + $this->set('data',$data); + $this->set('ip',$fw->get('IP')); + $this->set('agent', + isset($headers['User-Agent'])?$headers['User-Agent']:''); + $this->set('stamp',time()); + $this->save(); + return TRUE; + } + + /** + Destroy session + @return TRUE + @param $id string + **/ + function destroy($id) { + $this->erase(array('@session_id==?',$id)); + return TRUE; + } + + /** + Garbage collector + @return TRUE + @param $max int + **/ + function cleanup($max) { + $this->erase(array('@stamp+?load(array('@session_id==?',$id?:session_id())); + return $this->dry()?FALSE:$this->get('ip'); + } + + /** + Return Unix timestamp associated with specified session ID + @return string|FALSE + @param $id string + **/ + function stamp($id=NULL) { + $this->load(array('@session_id==?',$id?:session_id())); + return $this->dry()?FALSE:$this->get('stamp'); + } + + /** + Return HTTP user agent associated with specified session ID + @return string|FALSE + @param $id string + **/ + function agent($id=NULL) { + $this->load(array('@session_id==?',$id?:session_id())); + return $this->dry()?FALSE:$this->get('agent'); + } + + /** + Instantiate class + @param $db object + @param $table string + **/ + function __construct(\DB\Jig $db,$table='sessions') { + parent::__construct($db,'sessions'); + session_set_save_handler( + array($this,'open'), + array($this,'close'), + array($this,'read'), + array($this,'write'), + array($this,'destroy'), + array($this,'cleanup') + ); + register_shutdown_function('session_commit'); + } + +} diff --git a/lib/db/mongo.php b/lib/db/mongo.php new file mode 100644 index 0000000..061a9b8 --- /dev/null +++ b/lib/db/mongo.php @@ -0,0 +1,71 @@ +selectcollection('system.profile')->find(); + foreach (iterator_to_array($cursor) as $frame) + if (!preg_match('/\.system\..+$/',$frame['ns'])) + $this->log.=date('r',$frame['ts']->sec).' ('. + sprintf('%.1f',$frame['millis']).'ms) '. + $frame['ns'].' ['.$frame['op'].'] '. + (empty($frame['query'])? + '':json_encode($frame['query'])). + (empty($frame['command'])? + '':json_encode($frame['command'])). + PHP_EOL; + return $this->log; + } + + /** + Intercept native call to re-enable profiler + @return int + **/ + function drop() { + $out=parent::drop(); + $this->setprofilinglevel(2); + return $out; + } + + /** + Instantiate class + @param $dsn string + @param $dbname string + @param $options array + **/ + function __construct($dsn,$dbname,array $options=NULL) { + $class=class_exists('\MongoClient')?'\MongoClient':'\Mongo'; + parent::__construct(new $class($dsn,$options?:array()),$dbname); + $this->setprofilinglevel(2); + } + +} diff --git a/lib/db/mongo/mapper.php b/lib/db/mongo/mapper.php new file mode 100644 index 0000000..d8f0d4c --- /dev/null +++ b/lib/db/mongo/mapper.php @@ -0,0 +1,286 @@ +document); + } + + /** + Assign value to field + @return scalar|FALSE + @param $key string + @param $val scalar + **/ + function set($key,$val) { + return $this->document[$key]=$val; + } + + /** + Retrieve value of field + @return scalar|FALSE + @param $key string + **/ + function get($key) { + if ($this->exists($key)) + return $this->document[$key]; + user_error(sprintf(self::E_Field,$key)); + return FALSE; + } + + /** + Delete field + @return NULL + @param $key string + **/ + function clear($key) { + unset($this->document[$key]); + } + + /** + Convert array to mapper object + @return object + @param $row array + **/ + protected function factory($row) { + $mapper=clone($this); + $mapper->reset(); + foreach ($row as $key=>$val) + $mapper->document[$key]=$val; + $mapper->query=array($row); + $mapper->ptr=0; + return $mapper; + } + + /** + Return fields of mapper object as an associative array + @return array + @param $obj object + **/ + function cast($obj=NULL) { + if (!$obj) + $obj=$this; + return $obj->document; + } + + /** + Build query and execute + @return array + @param $fields string + @param $filter array + @param $options array + @param $ttl int + **/ + function select($fields=NULL,$filter=NULL,array $options=NULL,$ttl=0) { + if (!$options) + $options=array(); + $options+=array( + 'group'=>NULL, + 'order'=>NULL, + 'limit'=>0, + 'offset'=>0 + ); + $fw=\Base::instance(); + $cache=\Cache::instance(); + if (!$fw->get('CACHE') || !$ttl || !($cached=$cache->exists( + $hash=$fw->hash($fw->stringify(array($fields,$filter,$options))). + '.mongo',$result)) || $cached+$ttldb->selectcollection( + $fw->get('HOST').'.'.$fw->get('BASE').'.'.uniqid().'.tmp' + ); + $tmp->batchinsert( + $this->collection->group( + $options['group']['keys'], + $options['group']['initial'], + $options['group']['reduce'], + array( + 'condition'=>array( + $filter, + $options['group']['finalize'] + ) + ) + ), + array('safe'=>TRUE) + ); + $filter=array(); + $collection=$tmp; + } + else { + $filter=$filter?:array(); + $collection=$this->collection; + } + $cursor=$collection->find($filter,$fields?:array()); + if ($options['order']) + $cursor=$cursor->sort($options['order']); + if ($options['limit']) + $cursor=$cursor->limit($options['limit']); + if ($options['offset']) + $cursor=$cursor->skip($options['offset']); + if ($options['group']) + $tmp->drop(); + $result=iterator_to_array($cursor,FALSE); + if ($fw->get('CACHE') && $ttl) + // Save to cache backend + $cache->set($hash,$result,$ttl); + } + $out=array(); + foreach ($result as &$doc) { + foreach ($doc as &$val) { + if (is_array($val)) + $val=json_decode(json_encode($val)); + unset($val); + } + $out[]=$this->factory($doc); + unset($doc); + } + return $out; + } + + /** + Return records that match criteria + @return array + @param $filter array + @param $options array + @param $ttl int + **/ + function find($filter=NULL,array $options=NULL,$ttl=0) { + if (!$options) + $options=array(); + $options+=array( + 'group'=>NULL, + 'order'=>NULL, + 'limit'=>0, + 'offset'=>0 + ); + return $this->select(NULL,$filter,$options,$ttl); + } + + /** + Count records that match criteria + @return int + @param $filter array + **/ + function count($filter=NULL) { + return $this->collection->count($filter); + } + + /** + Return record at specified offset using criteria of previous + load() call and make it active + @return array + @param $ofs int + **/ + function skip($ofs=1) { + $this->document=($out=parent::skip($ofs))?$out->document:array(); + return $out; + } + + /** + Insert new record + @return array + **/ + function insert() { + if (isset($this->document['_id'])) + return $this->update(); + $this->collection->insert($this->document); + return $this->document; + } + + /** + Update current record + @return array + **/ + function update() { + $this->collection->update( + array('_id'=>$this->document['_id']),$this->document); + return $this->document; + } + + /** + Delete current record + @return bool + @param $filter array + **/ + function erase($filter=NULL) { + if ($filter) + return $this->collection->remove($filter); + $result=$this->collection-> + remove(array('_id'=>$this->document['_id'])); + parent::erase(); + $this->skip(0); + return $result; + } + + /** + Reset cursor + @return NULL + **/ + function reset() { + $this->document=array(); + parent::reset(); + } + + /** + Hydrate mapper object using hive array variable + @return NULL + @param $key string + **/ + function copyfrom($key) { + foreach (\Base::instance()->get($key) as $key=>$val) + $this->document[$key]=$val; + } + + /** + Populate hive array variable with mapper fields + @return NULL + @param $key string + **/ + function copyto($key) { + $var=&\Base::instance()->ref($key); + foreach ($this->document as $key=>$field) + $var[$key]=$field; + } + + /** + Instantiate class + @return void + @param $db object + @param $collection string + **/ + function __construct(\DB\Mongo $db,$collection) { + $this->db=$db; + $this->collection=$db->{$collection}; + $this->reset(); + } + +} diff --git a/lib/db/mongo/session.php b/lib/db/mongo/session.php new file mode 100644 index 0000000..986ea82 --- /dev/null +++ b/lib/db/mongo/session.php @@ -0,0 +1,137 @@ +load(array('session_id'=>$id)); + return $this->dry()?FALSE:$this->get('data'); + } + + /** + Write session data + @return TRUE + @param $id string + @param $data string + **/ + function write($id,$data) { + $fw=\Base::instance(); + $headers=$fw->get('HEADERS'); + $this->load(array('session_id'=>$id)); + $this->set('session_id',$id); + $this->set('data',$data); + $this->set('ip',$fw->get('IP')); + $this->set('agent', + isset($headers['User-Agent'])?$headers['User-Agent']:''); + $this->set('stamp',time()); + $this->save(); + return TRUE; + } + + /** + Destroy session + @return TRUE + @param $id string + **/ + function destroy($id) { + $this->erase(array('session_id'=>$id)); + return TRUE; + } + + /** + Garbage collector + @return TRUE + @param $max int + **/ + function cleanup($max) { + $this->erase(array('$where'=>'this.stamp+'.$max.'<'.time())); + return TRUE; + } + + /** + Return IP address associated with specified session ID + @return string|FALSE + @param $id string + **/ + function ip($id=NULL) { + $this->load(array('session_id'=>$id?:session_id())); + return $this->dry()?FALSE:$this->get('ip'); + } + + /** + Return Unix timestamp associated with specified session ID + @return string|FALSE + @param $id string + **/ + function stamp($id=NULL) { + $this->load(array('session_id'=>$id?:session_id())); + return $this->dry()?FALSE:$this->get('stamp'); + } + + /** + Return HTTP user agent associated with specified session ID + @return string|FALSE + @param $id string + **/ + function agent($id=NULL) { + $this->load(array('session_id'=>$id?:session_id())); + return $this->dry()?FALSE:$this->get('agent'); + } + + /** + Instantiate class + @param $db object + @param $table string + **/ + function __construct(\DB\Mongo $db,$table='sessions') { + parent::__construct($db,$table); + session_set_save_handler( + array($this,'open'), + array($this,'close'), + array($this,'read'), + array($this,'write'), + array($this,'destroy'), + array($this,'cleanup') + ); + register_shutdown_function('session_commit'); + } + +} diff --git a/lib/db/sql.php b/lib/db/sql.php new file mode 100644 index 0000000..eb0f520 --- /dev/null +++ b/lib/db/sql.php @@ -0,0 +1,305 @@ +trans=TRUE; + } + + /** + Rollback SQL transaction + @return NULL + **/ + function rollback() { + parent::rollback(); + $this->trans=FALSE; + } + + /** + Commit SQL transaction + @return NULL + **/ + function commit() { + parent::commit(); + $this->trans=FALSE; + } + + /** + Map data type of argument to a PDO constant + @return int + @param $val scalar + **/ + function type($val) { + switch (gettype($val)) { + case 'NULL': + return \PDO::PARAM_NULL; + case 'boolean': + return \PDO::PARAM_BOOL; + case 'integer': + return \PDO::PARAM_INT; + default: + return \PDO::PARAM_STR; + } + } + + + /** + Execute SQL statement(s) + @return array|int|FALSE + @param $cmds string|array + @param $args string|array + @param $ttl int + **/ + function exec($cmds,$args=NULL,$ttl=0) { + $auto=FALSE; + if (is_null($args)) + $args=array(); + elseif (is_scalar($args)) + $args=array(1=>$args); + if (is_array($cmds)) { + if (count($args)<($count=count($cmds))) + // Apply arguments to SQL commands + $args=array_fill(0,$count,$args); + if (!$this->trans) { + $this->begin(); + $auto=TRUE; + } + } + else { + $cmds=array($cmds); + $args=array($args); + } + $fw=\Base::instance(); + $cache=\Cache::instance(); + foreach (array_combine($cmds,$args) as $cmd=>$arg) { + $now=microtime(TRUE); + $keys=$vals=array(); + if ($fw->get('CACHE') && $ttl && ($cached=$cache->exists( + $hash=$fw->hash($cmd.$fw->stringify($arg)).'.sql', + $result)) && $cached+$ttl>microtime(TRUE)) { + foreach ($arg as $key=>$val) { + $vals[]=$fw->stringify(is_array($val)?$val[0]:$val); + $keys[]='/'.(is_numeric($key)?'\?':preg_quote($key)).'/'; + } + } + elseif (is_object($query=$this->prepare($cmd))) { + foreach ($arg as $key=>$val) { + if (is_array($val)) { + // User-specified data type + $query->bindvalue($key,$val[0],$val[1]); + $vals[]=$fw->stringify($val[0]); + } + else { + // Convert to PDO data type + $query->bindvalue($key,$val,$this->type($val)); + $vals[]=$fw->stringify($val); + } + $keys[]='/'.(is_numeric($key)?'\?':preg_quote($key)).'/'; + } + $query->execute(); + $error=$query->errorinfo(); + if ($error[0]!=\PDO::ERR_NONE) { + // Statement-level error occurred + if ($this->trans) + $this->rollback(); + user_error('PDOStatement: '.$error[2]); + } + if (preg_match( + '/\b(?:CALL|EXPLAIN|SELECT|PRAGMA|SHOW)\b/i',$cmd)) { + $result=$query->fetchall(\PDO::FETCH_ASSOC); + $this->rows=count($result); + if ($fw->get('CACHE') && $ttl) + // Save to cache backend + $cache->set($hash,$result,$ttl); + } + else + $this->rows=$result=$query->rowcount(); + $query->closecursor(); + unset($query); + } + else { + $error=$this->errorinfo(); + if ($error[0]!=\PDO::ERR_NONE) { + // PDO-level error occurred + if ($this->trans) + $this->rollback(); + user_error('PDO: '.$error[2]); + } + } + $this->log.=date('r').' ('. + sprintf('%.1f',1e3*(microtime(TRUE)-$now)).'ms) '. + preg_replace($keys,$vals,$cmd,1).PHP_EOL; + } + if ($this->trans && $auto) + $this->commit(); + return $result; + } + + /** + Return number of rows affected by last query + @return int + **/ + function count() { + return $this->rows; + } + + /** + Return SQL profiler results + @return string + **/ + function log() { + return $this->log; + } + + /** + Retrieve schema of SQL table + @return array|FALSE + @param $table string + @param $ttl int + **/ + function schema($table,$ttl=0) { + // Supported engines + $cmd=array( + 'sqlite2?'=>array( + 'PRAGMA table_info('.$table.');', + 'name','type','dflt_value','notnull',0,'pk',1), + 'mysql'=>array( + 'SHOW columns FROM `'.$this->dbname.'`.'.$table.';', + 'Field','Type','Default','Null','YES','Key','PRI'), + 'mssql|sqlsrv|sybase|dblib|pgsql|odbc'=>array( + 'SELECT '. + 'c.column_name AS field,'. + 'c.data_type AS type,'. + 'c.column_default AS defval,'. + 'c.is_nullable AS nullable,'. + 't.constraint_type AS pkey '. + 'FROM information_schema.columns AS c '. + 'LEFT OUTER JOIN '. + 'information_schema.key_column_usage AS k '. + 'ON '. + 'c.table_name=k.table_name AND '. + 'c.column_name=k.column_name '. + ($this->dbname? + ('AND '. + ($this->engine=='pgsql'? + 'c.table_catalog=k.table_catalog': + 'c.table_schema=k.table_schema').' '):''). + 'LEFT OUTER JOIN '. + 'information_schema.table_constraints AS t ON '. + 'k.table_name=t.table_name AND '. + 'k.constraint_name=t.constraint_name '. + ($this->dbname? + ('AND '. + ($this->engine=='pgsql'? + 'k.table_catalog=t.table_catalog': + 'k.table_schema=t.table_schema').' '):''). + 'WHERE '. + 'c.table_name='. + ($this->quote($table)?:('"'.$table.'"')).' '. + ($this->dbname? + ('AND '. + ($this->engine=='pgsql'? + 'c.table_catalog':'c.table_schema'). + '='.($this->quote($this->dbname)?: + ('"'.$this->dbname.'"'))):''). + ';', + 'field','type','defval','nullable','YES','pkey','PRIMARY KEY') + ); + foreach ($cmd as $key=>$val) + if (preg_match('/'.$key.'/',$this->engine)) { + $rows=array(); + foreach ($this->exec($val[0],NULL,$ttl) as $row) + $rows[$row[$val[1]]]=array( + 'type'=>$row[$val[2]], + 'pdo_type'=> + preg_match('/int|bool/i',$row[$val[2]],$parts)? + constant('\PDO::PARAM_'.strtoupper($parts[0])): + \PDO::PARAM_STR, + 'default'=>$row[$val[3]], + 'nullable'=>$row[$val[4]]==$val[5], + 'pkey'=>$row[$val[6]]==$val[7] + ); + return $rows; + } + return FALSE; + } + + /** + Return database engine + @return string + **/ + function driver() { + return $this->engine; + } + + /** + Return server version + @return string + **/ + function version() { + return parent::getattribute(parent::ATTR_SERVER_VERSION); + } + + /** + Return database name + @return string + **/ + function name() { + return $this->dbname; + } + + /** + Instantiate class + @param $dsn string + @param $user string + @param $pw string + @param $options array + **/ + function __construct($dsn,$user=NULL,$pw=NULL,array $options=NULL) { + if (preg_match('/^.+?(?:dbname|database)=(.+?)(?=;|$)/i',$dsn,$parts)) + $this->dbname=$parts[1]; + if (!$options) + $options=array(); + $options+=array(\PDO::ATTR_EMULATE_PREPARES=>FALSE); + if (isset($parts[0]) && strstr($parts[0],':',TRUE)=='mysql') + $options+=array(\PDO::MYSQL_ATTR_INIT_COMMAND=>'SET NAMES '. + strtolower(str_replace('-','', + \Base::instance()->get('ENCODING'))).';'); + parent::__construct($dsn,$user,$pw,$options); + $this->engine=parent::getattribute(parent::ATTR_DRIVER_NAME); + } + +} diff --git a/lib/db/sql/mapper.php b/lib/db/sql/mapper.php new file mode 100644 index 0000000..3dd772b --- /dev/null +++ b/lib/db/sql/mapper.php @@ -0,0 +1,485 @@ +fields+$this->adhoc); + } + + /** + Assign value to field + @return scalar + @param $key string + @param $val scalar + **/ + function set($key,$val) { + if (array_key_exists($key,$this->fields)) { + if (!is_null($val) || !$this->fields[$key]['nullable']) + $val=$this->value($this->fields[$key]['pdo_type'],$val); + if ($this->fields[$key]['value']!==$val || + $this->fields[$key]['default']!==$val) + $this->fields[$key]['changed']=TRUE; + return $this->fields[$key]['value']=$val; + } + // Parenthesize expression in case it's a subquery + $this->adhoc[$key]=array('expr'=>'('.$val.')','value'=>NULL); + return $val; + } + + /** + Retrieve value of field + @return scalar + @param $key string + **/ + function get($key) { + if ($key=='_id') + return $this->_id; + elseif (array_key_exists($key,$this->fields)) + return $this->fields[$key]['value']; + elseif (array_key_exists($key,$this->adhoc)) + return $this->adhoc[$key]['value']; + user_error(sprintf(self::E_Field,$key)); + } + + /** + Clear value of field + @return NULL + @param $key string + **/ + function clear($key) { + if (array_key_exists($key,$this->adhoc)) + unset($this->adhoc[$key]); + } + + /** + Get PHP type equivalent of PDO constant + @return string + @param $pdo string + **/ + function type($pdo) { + switch ($pdo) { + case \PDO::PARAM_NULL: + return 'unset'; + case \PDO::PARAM_INT: + return 'int'; + case \PDO::PARAM_BOOL: + return 'bool'; + case \PDO::PARAM_STR: + return 'string'; + } + } + + /** + Cast value to PHP type + @return scalar + @param $type string + @param $val scalar + **/ + function value($type,$val) { + switch ($type) { + case \PDO::PARAM_NULL: + return (unset)$val; + case \PDO::PARAM_INT: + return (int)$val; + case \PDO::PARAM_BOOL: + return (bool)$val; + case \PDO::PARAM_STR: + return (string)$val; + } + } + + /** + Convert array to mapper object + @return object + @param $row array + **/ + protected function factory($row) { + $mapper=clone($this); + $mapper->reset(); + foreach ($row as $key=>$val) { + $var=array_key_exists($key,$this->fields)?'fields':'adhoc'; + $mapper->{$var}[$key]['value']=$val; + if ($var=='fields' && $mapper->{$var}[$key]['pkey']) + $mapper->{$var}[$key]['previous']=$val; + } + $mapper->query=array($row); + $mapper->ptr=0; + return $mapper; + } + + /** + Return fields of mapper object as an associative array + @return array + @param $obj object + **/ + function cast($obj=NULL) { + if (!$obj) + $obj=$this; + return array_map( + function($row) { + return $row['value' ]; + }, + $obj->fields+$obj->adhoc + ); + } + + /** + Build query string and execute + @return array + @param $fields string + @param $filter string|array + @param $options array + @param $ttl int + **/ + function select($fields,$filter=NULL,array $options=NULL,$ttl=0) { + if (!$options) + $options=array(); + $options+=array( + 'group'=>NULL, + 'order'=>NULL, + 'limit'=>0, + 'offset'=>0 + ); + $sql='SELECT '.$fields.' FROM '.$this->table; + $args=array(); + if ($filter) { + if (is_array($filter)) { + $args=isset($filter[1]) && is_array($filter[1])? + $filter[1]: + array_slice($filter,1,NULL,TRUE); + $args=is_array($args)?$args:array(1=>$args); + list($filter)=$filter; + } + $sql.=' WHERE '.$filter; + } + if ($options['group']) + $sql.=' GROUP BY '.$options['group']; + if ($options['order']) + $sql.=' ORDER BY '.$options['order']; + if ($options['limit']) + $sql.=' LIMIT '.$options['limit']; + if ($options['offset']) + $sql.=' OFFSET '.$options['offset']; + $result=$this->db->exec($sql.';',$args,$ttl); + $out=array(); + foreach ($result as &$row) { + foreach ($row as $field=>&$val) { + if (array_key_exists($field,$this->fields)) { + if (!is_null($val) || !$this->fields[$field]['nullable']) + $val=$this->value( + $this->fields[$field]['pdo_type'],$val); + } + elseif (array_key_exists($field,$this->adhoc)) + $this->adhoc[$field]['value']=$val; + unset($val); + } + $out[]=$this->factory($row); + unset($row); + } + return $out; + } + + /** + Return records that match criteria + @return array + @param $filter string|array + @param $options array + @param $ttl int + **/ + function find($filter=NULL,array $options=NULL,$ttl=0) { + if (!$options) + $options=array(); + $options+=array( + 'group'=>NULL, + 'order'=>NULL, + 'limit'=>0, + 'offset'=>0 + ); + $adhoc=''; + foreach ($this->adhoc as $key=>$field) + $adhoc.=','.$field['expr'].' AS '.$key; + return $this->select('*'.$adhoc,$filter,$options,$ttl); + } + + /** + Count records that match criteria + @return int + @param $filter string|array + **/ + function count($filter=NULL) { + $sql='SELECT COUNT(*) AS rows FROM '.$this->table; + $args=array(); + if ($filter) { + if (is_array($filter)) { + $args=isset($filter[1]) && is_array($filter[1])? + $filter[1]: + array_slice($filter,1,NULL,TRUE); + $args=is_array($args)?$args:array(1=>$args); + list($filter)=$filter; + } + $sql.=' WHERE '.$filter; + } + $result=$this->db->exec($sql.';',$args); + return $result[0]['rows']; + } + + /** + Return record at specified offset using same criteria as + previous load() call and make it active + @return array + @param $ofs int + **/ + function skip($ofs=1) { + if ($out=parent::skip($ofs)) { + foreach ($this->fields as $key=>&$field) { + $field['value']=$out->fields[$key]['value']; + $field['changed']=FALSE; + if ($field['pkey']) + $field['previous']=$out->fields[$key]['value']; + unset($field); + } + foreach ($this->adhoc as $key=>&$field) { + $field['value']=$out->adhoc[$key]['value']; + unset($field); + } + } + return $out; + } + + /** + Insert new record + @return array + **/ + function insert() { + $args=array(); + $ctr=0; + $fields=''; + $values=''; + $pkeys=array(); + $inc=NULL; + foreach ($this->fields as $key=>&$field) { + if ($field['pkey']) { + $pkeys[]=$key; + $field['previous']=$field['value']; + if (!$inc && $field['pdo_type']==\PDO::PARAM_INT && + empty($field['value']) && !$field['nullable']) + $inc=$key; + } + if ($field['changed'] && $key!=$inc) { + $fields.=($ctr?',':''). + ($this->engine=='mysql'?('`'.$key.'`'):$key); + $values.=($ctr?',':'').'?'; + $args[$ctr+1]=array($field['value'],$field['pdo_type']); + $ctr++; + } + $field['changed']=FALSE; + unset($field); + } + if ($fields) + $this->db->exec( + 'INSERT INTO '.$this->table.' ('.$fields.') '. + 'VALUES ('.$values.');',$args + ); + $seq=NULL; + if ($this->engine=='pgsql') + $seq=$this->table.'_'.end($pkeys).'_seq'; + $this->_id=$this->db->lastinsertid($seq); + if (!$inc) { + $ctr=0; + $query=''; + $args=''; + foreach ($pkeys as $pkey) { + $query.=($query?' AND ':'').$pkey.'=?'; + $args[$ctr+1]=$this->fields[$pkey]['value']; + $ctr++; + } + return $this->load(array($query,$args)); + } + // Reload to obtain default and auto-increment field values + return $this->load(array($inc.'=?', + $this->value($this->fields[$inc]['pdo_type'],$this->_id))); + } + + /** + Update current record + @return array + **/ + function update() { + $args=array(); + $ctr=0; + $pairs=''; + $filter=''; + foreach ($this->fields as $key=>$field) + if ($field['changed']) { + $pairs.=($pairs?',':''). + ($this->engine=='mysql'?('`'.$key.'`'):$key).'=?'; + $args[$ctr+1]=array($field['value'],$field['pdo_type']); + $ctr++; + } + foreach ($this->fields as $key=>$field) + if ($field['pkey']) { + $filter.=($filter?' AND ':'').$key.'=?'; + $args[$ctr+1]=array($field['previous'],$field['pdo_type']); + $ctr++; + } + if ($pairs) { + $sql='UPDATE '.$this->table.' SET '.$pairs; + if ($filter) + $sql.=' WHERE '.$filter; + return $this->db->exec($sql.';',$args); + } + } + + /** + Delete current record + @return int + @param $filter string|array + **/ + function erase($filter=NULL) { + if ($filter) { + $args=array(); + if (is_array($filter)) { + $args=isset($filter[1]) && is_array($filter[1])? + $filter[1]: + array_slice($filter,1,NULL,TRUE); + $args=is_array($args)?$args:array(1=>$args); + list($filter)=$filter; + } + return $this->db-> + exec('DELETE FROM '.$this->table.' WHERE '.$filter.';',$args); + } + $args=array(); + $ctr=0; + $filter=''; + foreach ($this->fields as $key=>&$field) { + if ($field['pkey']) { + $filter.=($filter?' AND ':'').$key.'=?'; + $args[$ctr+1]=array($field['previous'],$field['pdo_type']); + $ctr++; + } + $field['value']=NULL; + $field['changed']=(bool)$field['default']; + if ($field['pkey']) + $field['previous']=NULL; + unset($field); + } + foreach ($this->adhoc as &$field) { + $field['value']=NULL; + unset($field); + } + parent::erase(); + $this->skip(0); + return $this->db-> + exec('DELETE FROM '.$this->table.' WHERE '.$filter.';',$args); + } + + /** + Reset cursor + @return NULL + **/ + function reset() { + foreach ($this->fields as &$field) { + $field['value']=NULL; + $field['changed']=FALSE; + if ($field['pkey']) + $field['previous']=NULL; + unset($field); + } + foreach ($this->adhoc as &$field) { + $field['value']=NULL; + unset($field); + } + parent::reset(); + } + + /** + Hydrate mapper object using hive array variable + @return NULL + @param $key string + **/ + function copyfrom($key) { + foreach (\Base::instance()->get($key) as $key=>$val) + if (in_array($key,array_keys($this->fields))) { + $field=&$this->fields[$key]; + if ($field['value']!==$val) { + $field['value']=$val; + $field['changed']=TRUE; + } + unset($field); + } + } + + /** + Populate hive array variable with mapper fields + @return NULL + @param $key string + **/ + function copyto($key) { + $var=&\Base::instance()->ref($key); + foreach ($this->fields as $key=>$field) + $var[$key]=$field['value']; + } + + /** + Return schema + @return array + **/ + function schema() { + return $this->fields; + } + + /** + Instantiate class + @param $db object + @param $table string + @param $ttl int + **/ + function __construct(\DB\SQL $db,$table,$ttl=60) { + $this->db=$db; + $this->engine=$db->driver(); + $this->table=$table; + $this->fields=$db->schema($table,$ttl); + $this->reset(); + } + +} diff --git a/lib/db/sql/session.php b/lib/db/sql/session.php new file mode 100644 index 0000000..33bef7a --- /dev/null +++ b/lib/db/sql/session.php @@ -0,0 +1,148 @@ +load(array('session_id=?',$id)); + return $this->dry()?FALSE:$this->get('data'); + } + + /** + Write session data + @return TRUE + @param $id string + @param $data string + **/ + function write($id,$data) { + $fw=\Base::instance(); + $headers=$fw->get('HEADERS'); + $this->load(array('session_id=?',$id)); + $this->set('session_id',$id); + $this->set('data',$data); + $this->set('ip',$fw->get('IP')); + $this->set('agent', + isset($headers['User-Agent'])?$headers['User-Agent']:''); + $this->set('stamp',time()); + $this->save(); + return TRUE; + } + + /** + Destroy session + @return TRUE + @param $id string + **/ + function destroy($id) { + $this->erase(array('session_id=?',$id)); + return TRUE; + } + + /** + Garbage collector + @return TRUE + @param $max int + **/ + function cleanup($max) { + $this->erase('stamp+'.$max.'<'.time()); + return TRUE; + } + + /** + Return IP address associated with specified session ID + @return string|FALSE + @param $id string + **/ + function ip($id=NULL) { + $this->load(array('session_id=?',$id?:session_id())); + return $this->dry()?FALSE:$this->get('ip'); + } + + /** + Return Unix timestamp associated with specified session ID + @return string|FALSE + @param $id string + **/ + function stamp($id=NULL) { + $this->load(array('session_id=?',$id?:session_id())); + return $this->dry()?FALSE:$this->get('stamp'); + } + + /** + Return HTTP user agent associated with specified session ID + @return string|FALSE + @param $id string + **/ + function agent($id=NULL) { + $this->load(array('session_id=?',$id?:session_id())); + return $this->dry()?FALSE:$this->get('agent'); + } + + /** + Instantiate class + @param $db object + @param $table string + **/ + function __construct(\DB\SQL $db,$table='sessions') { + $db->exec( + 'CREATE TABLE IF NOT EXISTS '. + (($name=$db->name())?($name.'.'):'').$table.' ('. + 'session_id VARCHAR(40),'. + 'data TEXT,'. + 'ip VARCHAR(40),'. + 'agent VARCHAR(255),'. + 'stamp INTEGER,'. + 'PRIMARY KEY(session_id)'. + ');' + ); + parent::__construct($db,$table); + session_set_save_handler( + array($this,'open'), + array($this,'close'), + array($this,'read'), + array($this,'write'), + array($this,'destroy'), + array($this,'cleanup') + ); + register_shutdown_function('session_commit'); + } + +} diff --git a/lib/f3.php b/lib/f3.php new file mode 100644 index 0000000..dfed454 --- /dev/null +++ b/lib/f3.php @@ -0,0 +1,35 @@ +6) + user_error(sprintf(self::E_Color,'0x'.$hex)); + $color=str_split($hex,$len/3); + foreach ($color as &$hue) { + $hue=hexdec(str_repeat($hue,6/$len)); + unset($hue); + } + return $color; + } + + /** + Invert image + @return object + **/ + function invert() { + imagefilter($this->data,IMG_FILTER_NEGATE); + return $this->save(); + } + + /** + Adjust brightness (range:-255 to 255) + @return object + @param $level int + **/ + function brightness($level) { + imagefilter($this->data,IMG_FILTER_BRIGHTNESS,$level); + return $this->save(); + } + + /** + Adjust contrast (range:-100 to 100) + @return object + @param $level int + **/ + function contrast($level) { + imagefilter($this->data,IMG_FILTER_CONTRAST,$level); + return $this->save(); + } + + /** + Convert to grayscale + @return object + **/ + function grayscale() { + imagefilter($this->data,IMG_FILTER_GRAYSCALE); + return $this->save(); + } + + /** + Adjust smoothness + @return object + @param $level int + **/ + function smooth($level) { + imagefilter($this->data,IMG_FILTER_SMOOTH,$level); + return $this->save(); + } + + /** + Emboss the image + @return object + **/ + function emboss() { + imagefilter($this->data,IMG_FILTER_EMBOSS); + return $this->save(); + } + + /** + Apply sepia effect + @return object + **/ + function sepia() { + imagefilter($this->data,IMG_FILTER_GRAYSCALE); + imagefilter($this->data,IMG_FILTER_COLORIZE,90,60,45); + return $this->save(); + } + + /** + Pixelate the image + @return object + @param $size int + **/ + function pixelate($size) { + imagefilter($this->data,IMG_FILTER_PIXELATE,$size,TRUE); + return $this->save(); + } + + /** + Blur the image using Gaussian filter + @return object + @param $selective bool + **/ + function blur($selective=FALSE) { + imagefilter($this->data, + $selective?IMG_FILTER_SELECTIVE_BLUR:IMG_FILTER_GAUSSIAN_BLUR); + return $this->save(); + } + + /** + Apply sketch effect + @return object + **/ + function sketch() { + imagefilter($this->data,IMG_FILTER_MEAN_REMOVAL); + return $this->save(); + } + + /** + Flip on horizontal axis + @return object + **/ + function hflip() { + $tmp=imagecreatetruecolor( + $width=$this->width(),$height=$this->height()); + imagesavealpha($tmp,TRUE); + imagefill($tmp,0,0,IMG_COLOR_TRANSPARENT); + imagecopyresampled($tmp,$this->data, + 0,0,$width-1,0,$width,$height,-$width,$height); + imagedestroy($this->data); + $this->data=$tmp; + return $this->save(); + } + + /** + Flip on vertical axis + @return object + **/ + function vflip() { + $tmp=imagecreatetruecolor( + $width=$this->width(),$height=$this->height()); + imagesavealpha($tmp,TRUE); + imagefill($tmp,0,0,IMG_COLOR_TRANSPARENT); + imagecopyresampled($tmp,$this->data, + 0,0,0,$height-1,$width,$height,$width,-$height); + imagedestroy($this->data); + $this->data=$tmp; + return $this->save(); + } + + /** + Resize image (Maintain aspect ratio); Crop relative to center + if flag is enabled + @return object + @param $width int + @param $height int + @param $crop bool + **/ + function resize($width,$height,$crop=TRUE) { + // Adjust dimensions; retain aspect ratio + $ratio=($origw=imagesx($this->data))/($origh=imagesy($this->data)); + if (!$crop) + if ($width/$ratio<=$height) + $height=$width/$ratio; + else + $width=$height*$ratio; + // Create blank image + $tmp=imagecreatetruecolor($width,$height); + imagesavealpha($tmp,TRUE); + imagefill($tmp,0,0,IMG_COLOR_TRANSPARENT); + // Resize + if ($crop) { + if ($width/$ratio<=$height) { + $cropw=$origh*$width/$height; + imagecopyresampled($tmp,$this->data, + 0,0,($origw-$cropw)/2,0,$width,$height,$cropw,$origh); + } + else { + $croph=$origw*$height/$width; + imagecopyresampled($tmp,$this->data, + 0,0,0,($origh-$croph)/2,$width,$height,$origw,$croph); + } + } + else + imagecopyresampled($tmp,$this->data, + 0,0,0,0,$width,$height,$origw,$origh); + imagedestroy($this->data); + $this->data=$tmp; + return $this->save(); + } + + /** + Rotate image + @return object + @param $angle int + **/ + function rotate($angle) { + $this->data=imagerotate($this->data,$angle,IMG_COLOR_TRANSPARENT); + imagesavealpha($this->data,TRUE); + return $this->save(); + } + + /** + Apply an image overlay + @return object + @param $img object + @param $align int + **/ + function overlay(Image $img,$align=NULL) { + if (is_null($align)) + $align=self::POS_Right|self::POS_Bottom; + $ovr=imagecreatefromstring($img->dump()); + imagesavealpha($ovr,TRUE); + $imgw=$this->width(); + $imgh=$this->height(); + $ovrw=imagesx($ovr); + $ovrh=imagesy($ovr); + if ($align & self::POS_Left) + $posx=0; + if ($align & self::POS_Center) + $posx=($imgw-$ovrw)/2; + if ($align & self::POS_Right) + $posx=$imgw-$ovrw; + if ($align & self::POS_Top) + $posy=0; + if ($align & self::POS_Middle) + $posy=($imgh-$ovrh)/2; + if ($align & self::POS_Bottom) + $posy=$imgh-$ovrh; + if (empty($posx)) + $posx=0; + if (empty($posy)) + $posy=0; + imagecopy($this->data,$ovr,$posx,$posy,0,0,$ovrw,$ovrh); + return $this->save(); + } + + /** + Generate identicon + @return object + @param $str string + @param $size int + @param $blocks int + **/ + function identicon($str,$size=64,$blocks=4) { + $sprites=array( + array(.5,1,1,0,1,1), + array(.5,0,1,0,.5,1,0,1), + array(.5,0,1,0,1,1,.5,1,1,.5), + array(0,.5,.5,0,1,.5,.5,1,.5,.5), + array(0,.5,1,0,1,1,0,1,1,.5), + array(1,0,1,1,.5,1,1,.5,.5,.5), + array(0,0,1,0,1,.5,0,0,.5,1,0,1), + array(0,0,.5,0,1,.5,.5,1,0,1,.5,.5), + array(.5,0,.5,.5,1,.5,1,1,.5,1,.5,.5,0,.5), + array(0,0,1,0,.5,.5,1,.5,.5,1,.5,.5,0,1), + array(0,.5,.5,1,1,.5,.5,0,1,0,1,1,0,1), + array(.5,0,1,0,1,1,.5,1,1,.75,.5,.5,1,.25), + array(0,.5,.5,0,.5,.5,1,0,1,.5,.5,1,.5,.5,0,1), + array(0,0,1,0,1,1,0,1,1,.5,.5,.25,.5,.75,0,.5,.5,.25), + array(0,.5,.5,.5,.5,0,1,0,.5,.5,1,.5,.5,1,.5,.5,0,1), + array(0,0,1,0,.5,.5,.5,0,0,.5,1,.5,.5,1,.5,.5,0,1) + ); + $this->data=imagecreatetruecolor($size,$size); + list($r,$g,$b)=$this->rgb(mt_rand(0x333,0xCCC)); + $fg=imagecolorallocate($this->data,$r,$g,$b); + imagefill($this->data,0,0,IMG_COLOR_TRANSPARENT); + $hash=sha1($str); + $ctr=count($sprites); + $dim=$blocks*floor($size/$blocks)*2/$blocks; + for ($j=0,$y=ceil($blocks/2);$j<$y;$j++) + for ($i=$j,$x=$blocks-1-$j;$i<$x;$i++) { + $sprite=imagecreatetruecolor($dim,$dim); + imagefill($sprite,0,0,IMG_COLOR_TRANSPARENT); + if ($block=$sprites[ + hexdec($hash[($j*$blocks+$i)*2])%$ctr]) { + for ($k=0,$pts=count($block);$k<$pts;$k++) + $block[$k]*=$dim; + imagefilledpolygon($sprite,$block,$pts/2,$fg); + } + $sprite=imagerotate($sprite, + 90*(hexdec($hash[($j*$blocks+$i)*2+1])%4), + IMG_COLOR_TRANSPARENT); + for ($k=0;$k<4;$k++) { + imagecopyresampled($this->data,$sprite, + $i*$dim/2,$j*$dim/2,0,0,$dim/2,$dim/2,$dim,$dim); + $this->data=imagerotate($this->data,90, + IMG_COLOR_TRANSPARENT); + } + imagedestroy($sprite); + } + imagesavealpha($this->data,TRUE); + return $this->save(); + } + + /** + Generate CAPTCHA image + @return object|FALSE + @param $font string + @param $size int + @param $len int + @param $key string + **/ + function captcha($font,$size=24,$len=5,$key=NULL) { + $fw=Base::instance(); + foreach ($fw->split($fw->get('UI')) as $dir) + if (is_file($path=$dir.$font)) { + $seed=strtoupper(substr(uniqid(),-$len)); + $block=$size*3; + $tmp=array(); + for ($i=0,$width=0,$height=0;$i<$len;$i++) { + // Process at 2x magnification + $box=imagettfbbox($size*2,0,$path,$seed[$i]); + $w=$box[2]-$box[0]; + $h=$box[1]-$box[5]; + $char=imagecreatetruecolor($block,$block); + imagefill($char,0,0,0); + imagettftext($char,$size*2,0, + ($block-$w)/2,$block-($block-$h)/2, + 0xFFFFFF,$path,$seed[$i]); + $char=imagerotate($char, + mt_rand(-30,30),IMG_COLOR_TRANSPARENT); + // Reduce to normal size + $tmp[$i]=imagecreatetruecolor( + ($w=imagesx($char))/2,($h=imagesy($char))/2); + imagefill($tmp[$i],0,0,IMG_COLOR_TRANSPARENT); + imagecopyresampled($tmp[$i],$char,0,0,0,0,$w/2,$h/2,$w,$h); + imagedestroy($char); + $width+=$i+1<$len?$block/2:$w/2; + $height=max($height,$h/2); + } + $this->data=imagecreatetruecolor($width,$height); + imagefill($this->data,0,0,IMG_COLOR_TRANSPARENT); + for ($i=0;$i<$len;$i++) { + imagecopy($this->data,$tmp[$i], + $i*$block/2,($height-imagesy($tmp[$i]))/2,0,0, + imagesx($tmp[$i]),imagesy($tmp[$i])); + imagedestroy($tmp[$i]); + } + imagesavealpha($this->data,TRUE); + if ($key) + $fw->set($key,$seed); + return $this->save(); + } + user_error(self::E_Font); + return FALSE; + } + + /** + Return image width + @return int + **/ + function width() { + return imagesx($this->data); + } + + /** + Return image height + @return int + **/ + function height() { + return imagesy($this->data); + } + + /** + Send image to HTTP client + @return NULL + **/ + function render() { + $args=func_get_args(); + $format=$args?array_shift($args):'png'; + if (PHP_SAPI!='cli') { + header('Content-Type: image/'.$format); + header('X-Powered-By: '.Base::instance()->get('PACKAGE')); + } + call_user_func_array('image'.$format,array_merge(array($this->data),$args)); + } + + /** + Return image as a string + @return string + **/ + function dump() { + $args=func_get_args(); + $format=$args?array_shift($args):'png'; + ob_start(); + call_user_func_array('image'.$format,array_merge(array($this->data),$args)); + return ob_get_clean(); + } + + /** + Save current state + @return object + **/ + function save() { + $fw=Base::instance(); + if ($this->flag) { + if (!is_dir($dir=$fw->get('TEMP'))) + mkdir($dir,Base::MODE,TRUE); + $this->count++; + $fw->write($dir.'/'. + $fw->hash($fw->get('ROOT').$fw->get('BASE')).'.'. + $fw->hash($this->file).'-'.$this->count.'.png', + $this->dump()); + } + return $this; + } + + /** + Revert to specified state + @return object + @param $state int + **/ + function restore($state=1) { + $fw=Base::instance(); + if ($this->flag && is_file($file=($path=$fw->get('TEMP'). + $fw->hash($fw->get('ROOT').$fw->get('BASE')).'.'. + $fw->hash($this->file).'-').$state.'.png')) { + if (is_resource($this->data)) + imagedestroy($this->data); + $this->data=imagecreatefromstring($fw->read($file)); + imagesavealpha($this->data,TRUE); + foreach (glob($path.'*.png',GLOB_NOSORT) as $match) + if (preg_match('/-(\d+)\.png/',$match,$parts) && + $parts[1]>$state) + @unlink($match); + $this->count=$state; + } + return $this; + } + + /** + Undo most recently applied filter + @return object + **/ + function undo() { + if ($this->flag) { + if ($this->count) + $this->count--; + return $this->restore($this->count); + } + return $this; + } + + /** + Instantiate image + @param $file string + @param $flag bool + **/ + function __construct($file=NULL,$flag=FALSE) { + $this->flag=$flag; + if ($file) { + $fw=Base::instance(); + // Create image from file + $this->file=$file; + foreach ($fw->split($fw->get('UI')) as $dir) + if (is_file($dir.$file)) { + $this->data=imagecreatefromstring($fw->read($dir.$file)); + imagesavealpha($this->data,TRUE); + $this->save(); + } + } + } + + /** + Wrap-up + @return NULL + **/ + function __destruct() { + if (is_resource($this->data)) { + imagedestroy($this->data); + $fw=Base::instance(); + $path=$fw->get('TEMP'). + $fw->hash($fw->get('ROOT').$fw->get('BASE')).'.'. + $fw->hash($this->file); + foreach (glob($path.'*.png',GLOB_NOSORT) as $match) + if (preg_match('/-(\d+)\.png/',$match)) + @unlink($match); + } + } + +} diff --git a/lib/license.txt b/lib/license.txt new file mode 100644 index 0000000..3c7236c --- /dev/null +++ b/lib/license.txt @@ -0,0 +1,621 @@ +GNU GENERAL PUBLIC LICENSE +Version 3, 29 June 2007 + +Copyright (C) 2007 Free Software Foundation, Inc. +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + +Preamble + +The GNU General Public License is a free, copyleft license for +software and other kinds of works. + +The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + +When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + +To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + +For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + +Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + +For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + +Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + +Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + +The precise terms and conditions for copying, distribution and +modification follow. + +TERMS AND CONDITIONS + +0. Definitions. + +"This License" refers to version 3 of the GNU General Public License. + +"Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + +"The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + +To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + +A "covered work" means either the unmodified Program or a work based +on the Program. + +To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + +To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + +An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + +1. Source Code. + +The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + +A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + +The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + +The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + +The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + +The Corresponding Source for a work in source code form is that +same work. + +2. Basic Permissions. + +All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + +You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + +Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + +3. Protecting Users' Legal Rights From Anti-Circumvention Law. + +No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + +When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + +4. Conveying Verbatim Copies. + +You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + +You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + +5. Conveying Modified Source Versions. + +You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + +a) The work must carry prominent notices stating that you modified +it, and giving a relevant date. + +b) The work must carry prominent notices stating that it is +released under this License and any conditions added under section +7. This requirement modifies the requirement in section 4 to +"keep intact all notices". + +c) You must license the entire work, as a whole, under this +License to anyone who comes into possession of a copy. This +License will therefore apply, along with any applicable section 7 +additional terms, to the whole of the work, and all its parts, +regardless of how they are packaged. This License gives no +permission to license the work in any other way, but it does not +invalidate such permission if you have separately received it. + +d) If the work has interactive user interfaces, each must display +Appropriate Legal Notices; however, if the Program has interactive +interfaces that do not display Appropriate Legal Notices, your +work need not make them do so. + +A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + +6. Conveying Non-Source Forms. + +You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + +a) Convey the object code in, or embodied in, a physical product +(including a physical distribution medium), accompanied by the +Corresponding Source fixed on a durable physical medium +customarily used for software interchange. + +b) Convey the object code in, or embodied in, a physical product +(including a physical distribution medium), accompanied by a +written offer, valid for at least three years and valid for as +long as you offer spare parts or customer support for that product +model, to give anyone who possesses the object code either (1) a +copy of the Corresponding Source for all the software in the +product that is covered by this License, on a durable physical +medium customarily used for software interchange, for a price no +more than your reasonable cost of physically performing this +conveying of source, or (2) access to copy the +Corresponding Source from a network server at no charge. + +c) Convey individual copies of the object code with a copy of the +written offer to provide the Corresponding Source. This +alternative is allowed only occasionally and noncommercially, and +only if you received the object code with such an offer, in accord +with subsection 6b. + +d) Convey the object code by offering access from a designated +place (gratis or for a charge), and offer equivalent access to the +Corresponding Source in the same way through the same place at no +further charge. You need not require recipients to copy the +Corresponding Source along with the object code. If the place to +copy the object code is a network server, the Corresponding Source +may be on a different server (operated by you or a third party) +that supports equivalent copying facilities, provided you maintain +clear directions next to the object code saying where to find the +Corresponding Source. Regardless of what server hosts the +Corresponding Source, you remain obligated to ensure that it is +available for as long as needed to satisfy these requirements. + +e) Convey the object code using peer-to-peer transmission, provided +you inform other peers where the object code and Corresponding +Source of the work are being offered to the general public at no +charge under subsection 6d. + +A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + +A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + +"Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + +If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + +The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + +Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + +7. Additional Terms. + +"Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + +When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + +Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + +a) Disclaiming warranty or limiting liability differently from the +terms of sections 15 and 16 of this License; or + +b) Requiring preservation of specified reasonable legal notices or +author attributions in that material or in the Appropriate Legal +Notices displayed by works containing it; or + +c) Prohibiting misrepresentation of the origin of that material, or +requiring that modified versions of such material be marked in +reasonable ways as different from the original version; or + +d) Limiting the use for publicity purposes of names of licensors or +authors of the material; or + +e) Declining to grant rights under trademark law for use of some +trade names, trademarks, or service marks; or + +f) Requiring indemnification of licensors and authors of that +material by anyone who conveys the material (or modified versions of +it) with contractual assumptions of liability to the recipient, for +any liability that these contractual assumptions directly impose on +those licensors and authors. + +All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + +If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + +Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + +8. Termination. + +You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + +However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + +Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + +Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + +9. Acceptance Not Required for Having Copies. + +You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + +10. Automatic Licensing of Downstream Recipients. + +Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + +An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + +You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + +11. Patents. + +A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + +A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + +Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + +In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + +If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + +If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + +A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + +Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + +12. No Surrender of Others' Freedom. + +If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + +13. Use with the GNU Affero General Public License. + +Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + +14. Revised Versions of this License. + +The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + +If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + +Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + +15. Disclaimer of Warranty. + +THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + +16. Limitation of Liability. + +IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + +17. Interpretation of Sections 15 and 16. + +If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + +END OF TERMS AND CONDITIONS diff --git a/lib/log.php b/lib/log.php new file mode 100644 index 0000000..eb938e5 --- /dev/null +++ b/lib/log.php @@ -0,0 +1,60 @@ +write( + $this->file, + date($format). + (isset($_SERVER['REMOTE_ADDR'])? + (' ['.$_SERVER['REMOTE_ADDR'].']'):'').' '. + trim($text).PHP_EOL, + TRUE + ); + } + + /** + Erase log + @return NULL + **/ + function erase() { + @unlink($this->file); + } + + /** + Instantiate class + @param $file string + **/ + function __construct($file) { + $fw=Base::instance(); + if (!is_dir($dir=$fw->get('LOGS'))) + mkdir($dir,Base::MODE,TRUE); + $this->file=$dir.$file; + } + +} diff --git a/lib/magic.php b/lib/magic.php new file mode 100644 index 0000000..39277e4 --- /dev/null +++ b/lib/magic.php @@ -0,0 +1,140 @@ +ispublic(); + unset($ref); + return $out; + } + return FALSE; + } + + /** + Convenience method for checking property value + @return mixed + @param $key string + **/ + function offsetexists($key) { + return $this->visible($key)?isset($this->$key):$this->exists($key); + } + + /** + Alias for offsetexists() + @return mixed + @param $key string + **/ + function __isset($key) { + return $this->offsetexists($key); + } + + /** + Convenience method for assigning property value + @return mixed + @param $key string + @param $val scalar + **/ + function offsetset($key,$val) { + return $this->visible($key)?($this->key=$val):$this->set($key,$val); + } + + /** + Alias for offsetset() + @return mixed + @param $key string + @param $val scalar + **/ + function __set($key,$val) { + return $this->offsetset($key,$val); + } + + /** + Convenience method for retrieving property value + @return mixed + @param $key string + **/ + function offsetget($key) { + return $this->visible($key)?$this->$key:$this->get($key); + } + + /** + Alias for offsetget() + @return mixed + @param $key string + **/ + function __get($key) { + return $this->offsetget($key); + } + + /** + Convenience method for checking property value + @return NULL + @param $key string + **/ + function offsetunset($key) { + if ($this->visible($key)) + unset($this->$key); + else + $this->clear($key); + } + + /** + Alias for offsetunset() + @return NULL + @param $key string + **/ + function __unset($key) { + $this->offsetunset($key); + } + +} diff --git a/lib/markdown.php b/lib/markdown.php new file mode 100644 index 0000000..42145cb --- /dev/null +++ b/lib/markdown.php @@ -0,0 +1,563 @@ +\h?(.*?(?:\n+|$))/','\1',$str); + return strlen($str)? + ('
    '.$this->build($str).'
    '."\n\n"):''; + } + + /** + Process whitespace-prefixed code block + @return string + @param $str string + **/ + protected function _pre($str) { + $str=preg_replace('/(?<=^|\n)(?: {4}|\t)(.+?(?:\n+|$))/','\1', + $this->esc($str)); + return strlen($str)? + ('
    '.
    +				$this->esc($this->snip($str)).
    +			'
    '."\n\n"): + ''; + } + + /** + Process fenced code block + @return string + @param $hint string + @param $str string + **/ + protected function _fence($hint,$str) { + $str=$this->snip($str); + $fw=Base::instance(); + if ($fw->get('HIGHLIGHT')) { + switch (strtolower($hint)) { + case 'php': + $str=$fw->highlight($str); + break; + case 'apache': + preg_match_all('/(?<=^|\n)(\h*)'. + '(?:(<\/?)(\w+)((?:\h+[^>]+)*)(>)|'. + '(?:(\w+)(\h.+?)))(\h*(?:\n+|$))/', + $str,$matches,PREG_SET_ORDER); + $out=''; + foreach ($matches as $match) + $out.=$match[1]. + ($match[3]? + (''. + $this->esc($match[2]).$match[3]. + ''. + ($match[4]? + (''. + $this->esc($match[4]). + ''): + ''). + ''. + $this->esc($match[5]). + ''): + (''. + $match[6]. + ''. + ''. + $this->esc($match[7]). + '')). + $match[8]; + $str=''.$out.''; + break; + case 'html': + preg_match_all( + '/(?:(?:<(\/?)(\w+)'. + '((?:\h+(?:\w+\h*=\h*)?".+?"|[^>]+)*|'. + '\h+.+?)(\h*\/?)>)|(.+?))/s', + $str,$matches,PREG_SET_ORDER + ); + $out=''; + foreach ($matches as $match) { + if ($match[2]) { + $out.='<'. + $match[1].$match[2].''; + if ($match[3]) { + preg_match_all( + '/(?:\h+(?:(?:(\w+)\h*=\h*)?'. + '(".+?")|(.+)))/', + $match[3],$parts,PREG_SET_ORDER + ); + foreach ($parts as $part) + $out.=' '. + (empty($part[3])? + ((empty($part[1])? + '': + (''. + $part[1].'=')). + ''. + $part[2].''): + (''. + $part[3].'')); + } + $out.=''. + $match[4].'>'; + } + else + $out.=$this->esc($match[5]); + } + $str=''.$out.''; + break; + case 'ini': + preg_match_all( + '/(?<=^|\n)(?:'. + '(;[^\n]*)|(?:<\?php.+?\?>?)|'. + '(?:\[(.+?)\])|'. + '(.+?)\h*=\h*'. + '((?:\\\\\h*\r?\n|.+?)*)'. + ')((?:\r?\n)+|$)/', + $str,$matches,PREG_SET_ORDER + ); + $out=''; + foreach ($matches as $match) { + if ($match[1]) + $out.=''.$match[1]. + ''; + elseif ($match[2]) + $out.='['.$match[2].']'. + ''; + elseif ($match[3]) + $out.=''.$match[3]. + '='. + ($match[4]? + (''. + $match[4].''):''); + else + $out.=$match[0]; + if (isset($match[5])) + $out.=$match[5]; + } + $str=''.$out.''; + break; + default: + $str=''.$this->esc($str).''; + break; + } + } + else + $str=''.$this->esc($str).''; + return '
    '.$str.'
    '."\n\n"; + } + + /** + Process horizontal rule + @return string + **/ + protected function _hr() { + return '
    '."\n\n"; + } + + /** + Process atx-style heading + @return string + @param $type string + @param $str string + **/ + protected function _atx($type,$str) { + $level=strlen($type); + return ''. + $this->scan($str).''."\n\n"; + } + + /** + Process setext-style heading + @return string + @param $str string + @param $type string + **/ + protected function _setext($str,$type) { + $level=strpos('=-',$type)+1; + return ''. + $this->scan($str).''."\n\n"; + } + + /** + Process ordered/unordered list + @return string + @param $str string + **/ + protected function _li($str) { + // Initialize list parser + $len=strlen($str); + $ptr=0; + $dst=''; + $first=TRUE; + $tight=TRUE; + $type='ul'; + // Main loop + while ($ptr<$len) { + if (preg_match('/^\h*[*-](?:\h?[*-]){2,}(?:\n+|$)/', + substr($str,$ptr),$match)) { + $ptr+=strlen($match[0]); + // Embedded horizontal rule + return (strlen($dst)? + ('<'.$type.'>'."\n".$dst.''."\n\n"):''). + '
    '."\n\n".$this->build(substr($str,$ptr)); + } + elseif (preg_match('/(?<=^|\n)([*+-]|\d+\.)\h'. + '(.+?(?:\n+|$))((?:(?: {4}|\t)+.+?(?:\n+|$))*)/s', + substr($str,$ptr),$match)) { + $match[3]=preg_replace('/(?<=^|\n)(?: {4}|\t)/','',$match[3]); + $found=FALSE; + foreach (array_slice($this->blocks,0,-1) as $regex) + if (preg_match($regex,$match[3])) { + $found=TRUE; + break; + } + // List + if ($first) { + // First pass + if (is_numeric($match[1])) + $type='ol'; + if (preg_match('/\n{2,}$/',$match[2]. + ($found?'':$match[3]))) + // Loose structure; Use paragraphs + $tight=FALSE; + $first=FALSE; + } + // Strip leading whitespaces + $ptr+=strlen($match[0]); + $tmp=$this->snip($match[2].$match[3]); + if ($tight) { + if ($found) + $tmp=$match[2].$this->build($this->snip($match[3])); + } + else + $tmp=$this->build($tmp); + $dst.='
  • '.$this->scan(trim($tmp)).'
  • '."\n"; + } + } + return strlen($dst)? + ('<'.$type.'>'."\n".$dst.''."\n\n"):''; + } + + /** + Ignore raw HTML + @return string + @param $str string + **/ + protected function _raw($str) { + return $str; + } + + /** + Process paragraph + @return string + @param $str string + **/ + protected function _p($str) { + $str=trim($str); + if (strlen($str)) { + if (preg_match('/(.+?\n)([>#].+)/',$str,$parts)) + return $this->_p($parts[1]).$this->build($parts[2]); + $self=$this; + $str=preg_replace_callback( + '/([^<\[]+)?(<.+?>|\[.+?\]\s*\(.+?\))([>\]]+)?|(.+)/s', + function($expr) use($self) { + $tmp=''; + if (isset($expr[4])) + $tmp.=$self->esc($expr[4]); + else { + if (isset($expr[1])) + $tmp.=$self->esc($expr[1]); + $tmp.=$expr[2]; + if (isset($expr[3])) + $tmp.=$self->esc($expr[3]); + } + return $tmp; + }, + $str + ); + return '

    '.$this->scan($str).'

    '."\n\n"; + } + return ''; + } + + /** + Process strong/em spans + @return string + @param $str string + **/ + protected function _text($str) { + $tmp=''; + while ($str!=$tmp) + $str=preg_replace_callback( + '/(?'.$expr[2].''; + case 2: + return ''.$expr[2].''; + } + }, + $tmp=$str + ); + return $str; + } + + /** + Process image span + @return string + @param $str string + **/ + protected function _img($str) { + $self=$this; + return preg_replace_callback( + '/!(?:\[(.+?)\])?\h*\(?(?:\h*"(.*?)"\h*)?\)/', + function($expr) use($self) { + return ''.$self->esc($expr[1]).''; + }, + $str + ); + } + + /** + Process anchor span + @return string + @param $str string + **/ + protected function _a($str) { + $self=$this; + return preg_replace_callback( + '/(??(?:\h*"(.*?)"\h*)?\)/', + function($expr) use($self) { + return ''.$self->scan($expr[1]).''; + }, + $str + ); + } + + /** + Auto-convert links + @return string + @param $str string + **/ + protected function _auto($str) { + $self=$this; + return preg_replace_callback( + '/`.*?<(.+?)>.*?`|<(.+?)>/', + function($expr) use($self) { + if (empty($expr[1]) && parse_url($expr[2],PHP_URL_SCHEME)) { + $expr[2]=$self->esc($expr[2]); + return ''.$expr[2].''; + } + return $expr[0]; + }, + $str + ); + } + + /** + Process code span + @return string + @param $str string + **/ + protected function _code($str) { + $self=$this; + return preg_replace_callback( + '/`` (.+?) ``|(?'. + $self->esc(empty($expr[1])?$expr[2]:$expr[1]).''; + }, + $str + ); + } + + /** + Convert characters to HTML entities + @return string + @param $str string + **/ + function esc($str) { + if (!$this->special) + $this->special=array( + '...'=>'…', + '(tm)'=>'™', + '(r)'=>'®', + '(c)'=>'©' + ); + foreach ($this->special as $key=>$val) + $str=preg_replace('/'.preg_quote($key,'/').'/i',$val,$str); + return htmlspecialchars($str,ENT_COMPAT, + Base::instance()->get('ENCODING'),FALSE); + } + + /** + Reduce multiple line feeds + @return string + @param $str string + **/ + protected function snip($str) { + return preg_replace('/(?:(?<=\n)\n+)|\n+$/',"\n",$str); + } + + /** + Scan line for convertible spans + @return string + @param $str string + **/ + function scan($str) { + $inline=array('img','a','text','auto','code'); + foreach ($inline as $func) + $str=$this->{'_'.$func}($str); + return $str; + } + + /** + Assemble blocks + @return string + @param $str string + **/ + protected function build($str) { + if (!$this->blocks) { + // Regexes for capturing entire blocks + $this->blocks=array( + 'blockquote'=>'/^(?:\h?>\h?.*?(?:\n+|$))+/', + 'pre'=>'/^(?:(?: {4}|\t).+?(?:\n+|$))+/', + 'fence'=>'/^`{3}\h*(\w+)?.*?[^\n]*\n+(.+?)`{3}[^\n]*'. + '(?:\n+|$)/s', + 'hr'=>'/^\h*[*_-](?:\h?[\*_-]){2,}\h*(?:\n+|$)/', + 'atx'=>'/^\h*(#{1,6})\h?(.+?)\h*(?:#.*)?(?:\n+|$)/', + 'setext'=>'/^\h*(.+?)\h*\n([=-])+\h*(?:\n+|$)/', + 'li'=>'/^(?:(?:[*+-]|\d+\.)\h.+?(?:\n+|$)'. + '(?:(?: {4}|\t)+.+?(?:\n+|$))*)+/s', + 'raw'=>'/^((?:|<\?.+?\?>|<%.+?%>|'. + '<(address|article|aside|audio|blockquote|canvas|dd|'. + 'div|dl|fieldset|figcaption|figure|footer|form|h\d|'. + 'header|hgroup|hr|noscript|object|ol|output|p|pre|'. + 'section|table|tfoot|ul|video).'. + '*?(?:\/>|>(?:(?>[^><]+)|(?R))*<\/\2>))'. + '\h*(?:\n{2,}|\n?$))/s', + 'p'=>'/^(.+?(?:\n{2,}|\n?$))/s' + ); + } + $self=$this; + // Treat lines with nothing but whitespaces as empty lines + $str=preg_replace('/\n\h+(?=\n)/',"\n",$str); + // Initialize block parser + $len=strlen($str); + $ptr=0; + $dst=''; + // Main loop + while ($ptr<$len) { + if (preg_match('/^ {0,3}\[([^\[\]]+)\]:\s*?\s*'. + '(?:"([^\n]*)")?(?:\n+|$)/s',substr($str,$ptr),$match)) { + // Reference-style link; Backtrack + $ptr+=strlen($match[0]); + $tmp=''; + // Catch line breaks in title attribute + $ref=preg_replace('/\h/','\s',preg_quote($match[1],'/')); + while ($dst!=$tmp) { + $dst=preg_replace_callback( + '/(?esc($match[2]).'"'. + (empty($match[3])? + '': + (' title="'. + $self->esc($match[3]).'"')).'>'. + // Link + $self->scan( + empty($expr[3])? + (empty($expr[1])? + $expr[4]: + $expr[1]): + $expr[3] + ).''): + // Image + (''.
+										$self->esc($expr[3]).''); + }, + $tmp=$dst + ); + } + } + else + foreach ($this->blocks as $func=>$regex) + if (preg_match($regex,substr($str,$ptr),$match)) { + $ptr+=strlen($match[0]); + $dst.=call_user_func_array( + array($this,'_'.$func), + count($match)>1?array_slice($match,1):$match + ); + break; + } + } + return $dst; + } + + /** + Render HTML equivalent of markdown + @return string + @param $txt string + **/ + function convert($txt) { + $txt=preg_replace_callback( + '/(.+?<\/code>|'. + '<[^>\n]+>|\([^\n\)]+\)|"[^"\n]+")|'. + '\\\\(.)/s', + function($expr) { + // Process escaped characters + return empty($expr[1])?$expr[2]:$expr[1]; + }, + $this->build(preg_replace('/\r\n|\r/',"\n",$txt)) + ); + return $this->snip($txt); + } + +} diff --git a/lib/matrix.php b/lib/matrix.php new file mode 100644 index 0000000..8b94a08 --- /dev/null +++ b/lib/matrix.php @@ -0,0 +1,101 @@ +$cols) + foreach ($cols as $keyy=>$valy) + $out[$keyy][$keyx]=$valy; + $var=$out; + } + + /** + Sort a multi-dimensional array variable on a specified column + @return bool + @param $var array + @param $col mixed + @param $order int + **/ + function sort(array &$var,$col,$order=SORT_ASC) { + uasort( + $var, + function($val1,$val2) use($col,$order) { + list($v1,$v2)=array($val1[$col],$val2[$col]); + $out=is_numeric($v1) && is_numeric($v2)? + Base::instance()->sign($v1-$v2):strcmp($v1,$v2); + if ($order==SORT_DESC) + $out=-$out; + return $out; + } + ); + $var=array_values($var); + } + + /** + Change the key of a two-dimensional array element + @return NULL + @param $var array + @param $old string + @param $new string + **/ + function changekey(array &$var,$old,$new) { + $keys=array_keys($var); + $vals=array_values($var); + $keys[array_search($old,$keys)]=$new; + $var=array_combine($keys,$vals); + } + + /** + Return month calendar of specified date, with optional setting for + first day of week (0 for Sunday) + @return array + @param $date string + @param $first int + **/ + function calendar($date='now',$first=0) { + $parts=getdate(strtotime($date)); + $days=cal_days_in_month(CAL_GREGORIAN,$parts['mon'],$parts['year']); + $ref=date('w',strtotime(date('Y-m',$parts[0]).'-01'))+(7-$first)%7; + $out=array(); + for ($i=0;$i<$days;$i++) + $out[floor(($ref+$i)/7)][($ref+$i)%7]=$i+1; + return $out; + } + +} diff --git a/lib/session.php b/lib/session.php new file mode 100644 index 0000000..b00a46a --- /dev/null +++ b/lib/session.php @@ -0,0 +1,135 @@ +exists($id.'.@',$data)?$data['data']:FALSE; + } + + /** + Write session data + @return TRUE + @param $id string + @param $data string + **/ + function write($id,$data) { + $fw=Base::instance(); + $headers=$fw->get('HEADERS'); + $jar=session_get_cookie_params(); + Cache::instance()->set($id.'.@', + array( + 'data'=>$data, + 'ip'=>$fw->get('IP'), + 'agent'=>isset($headers['User-Agent'])? + $headers['User-Agent']:'', + 'stamp'=>time() + ), + $jar['lifetime'] + ); + return TRUE; + } + + /** + Destroy session + @return TRUE + @param $id string + **/ + function destroy($id) { + Cache::instance()->clear($id.'.@'); + return TRUE; + } + + /** + Garbage collector + @return TRUE + @param $max int + **/ + function cleanup($max) { + Cache::instance()->reset('.@',$max); + return TRUE; + } + + /** + Return IP address associated with specified session ID + @return string|FALSE + @param $id string + **/ + function ip($id=NULL) { + return Cache::instance()->exists(($id?:session_id()).'.@',$data)? + $data['ip']:FALSE; + } + + /** + Return Unix timestamp associated with specified session ID + @return string|FALSE + @param $id string + **/ + function stamp($id=NULL) { + return Cache::instance()->exists(($id?:session_id()).'.@',$data)? + $data['stamp']:FALSE; + } + + /** + Return HTTP user agent associated with specified session ID + @return string|FALSE + @param $id string + **/ + function agent($id=NULL) { + return Cache::instance()->exists(($id?:session_id()).'.@',$data)? + $data['agent']:FALSE; + } + + /** + Instantiate class + @return object + **/ + function __construct() { + session_set_save_handler( + array($this,'open'), + array($this,'close'), + array($this,'read'), + array($this,'write'), + array($this,'destroy'), + array($this,'cleanup') + ); + register_shutdown_function('session_commit'); + } + +} diff --git a/lib/smtp.php b/lib/smtp.php new file mode 100644 index 0000000..3896969 --- /dev/null +++ b/lib/smtp.php @@ -0,0 +1,267 @@ +fixheader($key); + return isset($this->headers[$key]); + } + + /** + Bind value to e-mail header + @return string + @param $key string + @param $val string + **/ + function set($key,$val) { + $key=$this->fixheader($key); + return $this->headers[$key]=$val; + } + + /** + Return value of e-mail header + @return string|NULL + @param $key string + **/ + function get($key) { + $key=$this->fixheader($key); + return isset($this->headers[$key])?$this->headers[$key]:NULL; + } + + /** + Remove header + @return NULL + @param $key string + **/ + function clear($key) { + $key=$this->fixheader($key); + unset($this->headers[$key]); + } + + /** + Return client-server conversation history + @return string + **/ + function log() { + return str_replace("\n",PHP_EOL,$this->log); + } + + /** + Send SMTP command and record server response + @return NULL + @param $cmd string + @param $log bool + **/ + protected function dialog($cmd=NULL,$log=FALSE) { + $socket=&$this->socket; + if (!is_null($cmd)) + fputs($socket,$cmd."\r\n"); + $reply=''; + while (!feof($socket) && ($info=stream_get_meta_data($socket)) && + !$info['timed_out'] && $str=fgets($socket,4096)) { + $reply.=$str; + if (preg_match('/(?:^|\n)\d{3} .+?\r\n/s',$reply)) + break; + } + if ($log) { + $this->log.=$cmd."\n"; + $this->log.=str_replace("\r",'',$reply); + } + } + + /** + Add e-mail attachment + @return NULL + @param $file + **/ + function attach($file) { + if (!is_file($file)) + user_error(sprintf(self::E_Attach,$file)); + $this->attachments[]=$file; + } + + /** + Transmit message + @return bool + @param $message string + **/ + function send($message) { + if ($this->scheme=='ssl' && !extension_loaded('openssl')) + return FALSE; + $fw=Base::instance(); + // Connect to the server + $socket=&$this->socket; + $socket=@fsockopen($this->host,$this->port); + if (!$socket) + return FALSE; + stream_set_blocking($socket,TRUE); + // Get server's initial response + $this->dialog(); + // Announce presence + $this->dialog('EHLO '.$fw->get('HOST'),TRUE); + if (strtolower($this->scheme)=='tls') { + $this->dialog('STARTTLS',TRUE); + stream_socket_enable_crypto( + $socket,TRUE,STREAM_CRYPTO_METHOD_TLS_CLIENT); + $this->dialog('EHLO '.$fw->get('HOST'),TRUE); + } + if ($this->user && $this->pw) { + // Authenticate + $this->dialog('AUTH LOGIN',TRUE); + $this->dialog(base64_encode($this->user),TRUE); + $this->dialog(base64_encode($this->pw),TRUE); + } + // Required headers + $reqd=array('From','To','Subject'); + // Retrieve headers + $headers=$this->headers; + foreach ($reqd as $id) + if (empty($headers[$id])) + user_error(sprintf(self::E_Header,$id)); + // Message should not be blank + if (!$message) + user_error(self::E_Blank); + $eol="\r\n"; + $str=''; + // Stringify headers + foreach ($headers as $key=>$val) + if (!in_array($key,$reqd)) + $str.=$key.': '.$val.$eol; + // Start message dialog + $this->dialog('MAIL FROM: '.strstr($headers['From'],'<'),TRUE); + foreach ($fw->split($headers['To']. + (isset($headers['Cc'])?(';'.$headers['Cc']):''). + (isset($headers['Bcc'])?(';'.$headers['Bcc']):'')) as $dst) + $this->dialog('RCPT TO: '.strstr($dst,'<'),TRUE); + $this->dialog('DATA',TRUE); + if ($this->attachments) { + // Replace Content-Type + $hash=uniqid(); + $type=$headers['Content-Type']; + $headers['Content-Type']='multipart/mixed; '. + 'boundary="'.$hash.'"'; + // Send mail headers + $out=''; + foreach ($headers as $key=>$val) + if ($key!='Bcc') + $out.=$key.': '.$val.$eol; + $out.=$eol; + $out.='This is a multi-part message in MIME format'.$eol; + $out.=$eol; + $out.='--'.$hash.$eol; + $out.='Content-Type: '.$type.$eol; + $out.=$eol; + $out.=$message.$eol; + foreach ($this->attachments as $attachment) { + $out.='--'.$hash.$eol; + $out.='Content-Type: application/octet-stream'.$eol; + $out.='Content-Transfer-Encoding: base64'.$eol; + $out.='Content-Disposition: attachment; '. + 'filename="'.basename($attachment).'"'.$eol; + $out.=$eol; + $out.=chunk_split( + base64_encode(file_get_contents($attachment))).$eol; + } + $out.=$eol; + $out.='--'.$hash.'--'.$eol; + $out.='.'; + $this->dialog($out,TRUE); + } + else { + // Send mail headers + $out=''; + foreach ($headers as $key=>$val) + if ($key!='Bcc') + $out.=$key.': '.$val.$eol; + $out.=$eol; + $out.=$message.$eol; + $out.='.'; + // Send message + $this->dialog($out,TRUE); + } + $this->dialog('QUIT',TRUE); + if ($socket) + fclose($socket); + return TRUE; + } + + /** + Instantiate class + @param $host string + @param $port int + @param $scheme string + @param $user string + @param $pw string + **/ + function __construct($host,$port,$scheme,$user,$pw) { + $this->headers=array( + 'MIME-Version'=>'1.0', + 'Content-Type'=>'text/plain; '. + 'charset='.Base::instance()->get('ENCODING'), + 'Content-Transfer-Encoding'=>'8bit' + ); + $this->host=$host; + if (strtolower($this->scheme=strtolower($scheme))=='ssl') + $this->host='ssl://'.$host; + $this->port=$port; + $this->user=$user; + $this->pw=$pw; + } + +} diff --git a/lib/template.php b/lib/template.php new file mode 100644 index 0000000..6ef8845 --- /dev/null +++ b/lib/template.php @@ -0,0 +1,352 @@ +|::)*)/', + function($var) use($self) { + // Convert from JS dot notation to PHP array notation + return '$'.preg_replace_callback( + '/(\.\w+)|\[((?:[^\[\]]*|(?R))*)\]/', + function($expr) use($self) { + $fw=Base::instance(); + return + '['. + ($expr[1]? + $fw->stringify(substr($expr[1],1)): + (preg_match('/^\w+/', + $mix=$self->token($expr[2]))? + $fw->stringify($mix): + $mix)). + ']'; + }, + $var[1] + ); + }, + $str + ); + return trim(preg_replace('/{{(.+?)}}/',trim('\1'),$str)); + } + + /** + Template -set- tag handler + @return string + @param $node array + **/ + protected function _set(array $node) { + $out=''; + foreach ($node['@attrib'] as $key=>$val) + $out.='$'.$key.'='. + (preg_match('/{{(.+?)}}/',$val)? + $this->token($val): + Base::instance()->stringify($val)).'; '; + return ''; + } + + /** + Template -include- tag handler + @return string + @param $node array + **/ + protected function _include(array $node) { + $attrib=$node['@attrib']; + return + 'token($attrib['if']).') '):''). + ('echo $this->render('. + (preg_match('/{{(.+?)}}/',$attrib['href'])? + $this->token($attrib['href']): + Base::instance()->stringify($attrib['href'])).','. + '$this->mime,get_defined_vars()); ?>'); + } + + /** + Template -exclude- tag handler + @return string + **/ + protected function _exclude() { + return ''; + } + + /** + Template -ignore- tag handler + @return string + @param $node array + **/ + protected function _ignore(array $node) { + return $node[0]; + } + + /** + Template -loop- tag handler + @return string + @param $node array + **/ + protected function _loop(array $node) { + $attrib=$node['@attrib']; + unset($node['@attrib']); + return + 'token($attrib['from']).';'. + $this->token($attrib['to']).';'. + $this->token($attrib['step']).'): ?>'. + $this->build($node). + ''; + } + + /** + Template -repeat- tag handler + @return string + @param $node array + **/ + protected function _repeat(array $node) { + $attrib=$node['@attrib']; + unset($node['@attrib']); + return + 'token($attrib['counter'])).'=0; '):''). + 'foreach (('. + $this->token($attrib['group']).'?:array()) as '. + (isset($attrib['key'])? + ($this->token($attrib['key']).'=>'):''). + $this->token($attrib['value']).'):'. + (isset($ctr)?(' '.$ctr.'++;'):'').' ?>'. + $this->build($node). + ''; + } + + /** + Template -check- tag handler + @return string + @param $node array + **/ + protected function _check(array $node) { + $attrib=$node['@attrib']; + unset($node['@attrib']); + // Grab and blocks + foreach ($node as $pos=>$block) + if (isset($block['true'])) + $true=array($pos,$block); + elseif (isset($block['false'])) + $false=array($pos,$block); + if (isset($true,$false) && $true[0]>$false[0]) + // Reverse and blocks + list($node[$true[0]],$node[$false[0]])=array($false[1],$true[1]); + return + 'token($attrib['if']).'): ?>'. + $this->build($node). + ''; + } + + /** + Template -true- tag handler + @return string + @param $node array + **/ + protected function _true(array $node) { + return $this->build($node); + } + + /** + Template -false- tag handler + @return string + @param $node array + **/ + protected function _false(array $node) { + return ''.$this->build($node); + } + + /** + Assemble markup + @return string + @param $node array|string + **/ + protected function build($node) { + if (is_string($node)) { + $self=$this; + return preg_replace_callback( + '/{{(.+?)}}/s', + function($expr) use($self) { + $str=trim($self->token($expr[1])); + if (preg_match('/^(.+?)\h*\|\h*(raw|esc|format)$/', + $str,$parts)) + $str='Base::instance()->'.$parts[2].'('.$parts[1].')'; + return ''; + }, + $node + ); + } + $out=''; + foreach ($node as $key=>$val) + $out.=is_int($key)?$this->build($val):$this->{'_'.$key}($val); + return $out; + } + + /** + Extend template with custom tag + @return NULL + @param $tag string + @param $func callback + **/ + function extend($tag,$func) { + $this->tags.='|'.$tag; + $this->custom['_'.$tag]=$func; + } + + /** + Call custom tag handler + @return string|FALSE + @param $func callback + @param $args array + **/ + function __call($func,array $args) { + if ($func[0]=='_') + return call_user_func_array($this->custom[$func],$args); + if (method_exists($this,$func)) + return call_user_func_array(array($this,$func),$args); + user_error(sprintf(self::E_Method,$func)); + } + + /** + Render template + @return string + @param $file string + @param $mime string + @param $hive array + **/ + function render($file,$mime='text/html',array $hive=NULL) { + $fw=Base::instance(); + if (!is_dir($tmp=$fw->get('TEMP'))) + mkdir($tmp,Base::MODE,TRUE); + foreach ($fw->split($fw->get('UI')) as $dir) + if (is_file($view=$fw->fixslashes($dir.$file))) { + if (!is_file($this->view=($tmp.'/'. + $fw->hash($fw->get('ROOT').$fw->get('BASE')).'.'. + $fw->hash($view).'.php')) || + filemtime($this->view)|{{\*.+?\*}}/is','', + $fw->read($view)); + // Build tree structure + for ($ptr=0,$len=strlen($text),$tree=array(),$node=&$tree, + $stack=array(),$depth=0,$tmp='';$ptr<$len;) + if (preg_match('/^<(\/?)(?:F3:)?('.$this->tags.')\b'. + '((?:\h+\w+\h*=\h*(?:"(?:.+?)"|\'(?:.+?)\'))*)'. + '\h*(\/?)>/is',substr($text,$ptr),$match)) { + if (strlen($tmp)) + $node[]=$tmp; + // Element node + if ($match[1]) { + // Find matching start tag + $save=$depth; + $found=FALSE; + while ($depth>0) { + $depth--; + foreach ($stack[$depth] as $item) + if (is_array($item) && + isset($item[$match[2]])) { + // Start tag found + $found=TRUE; + break 2; + } + } + if (!$found) + // Unbalanced tag + $depth=$save; + $node=&$stack[$depth]; + } + else { + // Start tag + $stack[$depth]=&$node; + $node=&$node[][$match[2]]; + if ($match[3]) { + // Process attributes + preg_match_all( + '/\b(\w+)\h*=\h*'. + '(?:"(.+?)"|\'(.+?)\')/s', + $match[3],$attr,PREG_SET_ORDER); + foreach ($attr as $kv) + $node['@attrib'][$kv[1]]= + $kv[2]?:$kv[3]; + } + if ($match[4]) + // Empty tag + $node=&$stack[$depth]; + else + $depth++; + } + $tmp=''; + $ptr+=strlen($match[0]); + } + else { + // Text node + $tmp.=$text[$ptr]; + $ptr++; + } + if (strlen($tmp)) + // Append trailing text + $node[]=$tmp; + // Break references + unset($node); + unset($stack); + $fw->write($this->view,$this->build($tree)); + } + if (isset($_COOKIE[session_name()])) + @session_start(); + $fw->sync('SESSION'); + if (!$hive) + $hive=$fw->hive(); + $this->hive=$fw->get('ESCAPE')?$fw->esc($hive):$hive; + if (PHP_SAPI!='cli') + header('Content-Type: '.($this->mime=$mime).'; '. + 'charset='.$fw->get('ENCODING')); + return $this->sandbox(); + } + user_error(sprintf(Base::E_Open,$file)); + } + + function __construct() { + $ref=new ReflectionClass(__CLASS__); + $this->tags=''; + foreach ($ref->getmethods() as $method) + if (preg_match('/^_(?=[[:alpha:]])/',$method->name)) + $this->tags.=(strlen($this->tags)?'|':''). + substr($method->name,1); + } + +} diff --git a/lib/test.php b/lib/test.php new file mode 100644 index 0000000..92f1e96 --- /dev/null +++ b/lib/test.php @@ -0,0 +1,78 @@ +data; + } + + /** + Evaluate condition and save test result + @return NULL + @param $cond bool + @param $text string + **/ + function expect($cond,$text=NULL) { + $out=(bool)$cond; + if ($this->level==self::FLAG_True && $out || + $this->level==self::FLAG_False && !$out || + $this->level==self::FLAG_Both) { + $data=array('status'=>$out,'text'=>$text,'source'=>NULL); + foreach (debug_backtrace() as $frame) + if (isset($frame['file'])) { + $data['source']=Base::instance()-> + fixslashes($frame['file']).':'.$frame['line']; + break; + } + $this->data[]=$data; + } + } + + /** + Push message to test results + @return NULL + @param $text string + **/ + function message($text) { + $this->expect(TRUE,$text); + } + + /** + Class constructor + @return NULL + @param $level int + **/ + function __construct($level=self::FLAG_Both) { + $this->level=$level; + } + +} diff --git a/lib/utf.php b/lib/utf.php new file mode 100644 index 0000000..e6c7588 --- /dev/null +++ b/lib/utf.php @@ -0,0 +1,185 @@ +strpos($stack,$needle,$ofs,TRUE); + } + + /** + Get string length + @return int + @param $str string + **/ + function strlen($str) { + preg_match_all('/./u',$str,$parts); + return count($parts[0]); + } + + /** + Find position of first occurrence of a string + @return int|FALSE + @param $stack string + @param $needle string + @param $ofs int + @param $case bool + **/ + function strpos($stack,$needle,$ofs=0,$case=FALSE) { + preg_match('/^(.*?)'.preg_quote($needle,'/').'/u'.($case?'i':''), + $this->substr($stack,$ofs),$match); + return isset($match[1])?$this->strlen($match[1]):FALSE; + } + + /** + Finds position of last occurrence of a string (case-insensitive) + @return int|FALSE + @param $stack string + @param $needle string + @param $ofs int + **/ + function strripos($stack,$needle,$ofs=0) { + return $this->strrpos($stack,$needle,$ofs,TRUE); + } + + /** + Find position of last occurrence of a string + @return int|FALSE + @param $stack string + @param $needle string + @param $ofs int + @param $case bool + **/ + function strrpos($stack,$needle,$ofs=0,$case=FALSE) { + if (!$needle) + return FALSE; + $len=$this->strlen($stack); + for ($ptr=$ofs;$ptr<$len;$ptr+=$this->strlen($match[0])) { + $sub=$this->substr($stack,$ptr); + if (!$sub || !preg_match('/^(.*?)'. + preg_quote($needle,'/').'/u'.($case?'i':''),$sub,$match)) + break; + $ofs=$ptr+$this->strlen($match[1]); + } + return $sub?$ofs:FALSE; + } + + /** + Returns part of haystack string from the first occurrence of + needle to the end of haystack (case-insensitive) + @return string|FALSE + @param $stack string + @param $needle string + @param $before bool + **/ + function stristr($stack,$needle,$before=FALSE) { + return strstr($stack,$needle,$before,TRUE); + } + + /** + Returns part of haystack string from the first occurrence of + needle to the end of haystack + @return string|FALSE + @param $stack string + @param $needle string + @param $before bool + @param $case bool + **/ + function strstr($stack,$needle,$before=FALSE,$case=FALSE) { + if (!$needle) + return FALSE; + preg_match('/^(.*?)'.preg_quote($needle,'/').'/u'.($case?'i':''), + $stack,$match); + return isset($match[1])? + ($before? + $match[1]: + $this->substr($stack,$this->strlen($match[1]))): + FALSE; + } + + /** + Return part of a string + @return string|FALSE + @param $str string + @param $start int + @param $len int + **/ + function substr($str,$start,$len=0) { + if ($start<0) { + $len=-$start; + $start=$this->strlen($str)+$start; + } + if (!$len) + $len=$this->strlen($str)-$start; + return preg_match('/^.{'.$start.'}(.{0,'.$len.'})/u',$str,$match)? + $match[1]:FALSE; + } + + /** + Count the number of substring occurrences + @return int + @param $stack string + @param $needle string + **/ + function substr_count($stack,$needle) { + preg_match_all('/'.preg_quote($needle,'/').'/u',$stack, + $matches,PREG_SET_ORDER); + return count($matches); + } + + /** + Strip whitespaces from the beginning of a string + @return string + @param $str string + **/ + function ltrim($str) { + return preg_replace('/^[\pZ\pC]+/u','',$str); + } + + /** + Strip whitespaces from the end of a string + @return string + @param $str string + **/ + function rtrim($str) { + return preg_replace('/[\pZ\pC]+$/u','',$str); + } + + /** + Strip whitespaces from the beginning and end of a string + @return string + @param $str string + **/ + function trim($str) { + return preg_replace('/^[\pZ\pC]+|[\pZ\pC]+$/u','',$str); + } + + /** + Return UTF-8 byte order mark + @return string + **/ + function bom() { + return chr(0xef).chr(0xbb).chr(0xbf); + } + +} diff --git a/lib/web.php b/lib/web.php new file mode 100644 index 0000000..cff807b --- /dev/null +++ b/lib/web.php @@ -0,0 +1,748 @@ +'audio/basic', + 'avi'=>'video/avi', + 'bmp'=>'image/bmp', + 'bz2'=>'application/x-bzip2', + 'css'=>'text/css', + 'dtd'=>'application/xml-dtd', + 'doc'=>'application/msword', + 'gif'=>'image/gif', + 'gz'=>'application/x-gzip', + 'hqx'=>'application/mac-binhex40', + 'html?'=>'text/html', + 'jar'=>'application/java-archive', + 'jpe?g'=>'image/jpeg', + 'js'=>'application/x-javascript', + 'midi'=>'audio/x-midi', + 'mp3'=>'audio/mpeg', + 'mpe?g'=>'video/mpeg', + 'ogg'=>'audio/vorbis', + 'pdf'=>'application/pdf', + 'png'=>'image/png', + 'ppt'=>'application/vnd.ms-powerpoint', + 'ps'=>'application/postscript', + 'qt'=>'video/quicktime', + 'ram?'=>'audio/x-pn-realaudio', + 'rdf'=>'application/rdf', + 'rtf'=>'application/rtf', + 'sgml?'=>'text/sgml', + 'sit'=>'application/x-stuffit', + 'svg'=>'image/svg+xml', + 'swf'=>'application/x-shockwave-flash', + 'tgz'=>'application/x-tar', + 'tiff'=>'image/tiff', + 'txt'=>'text/plain', + 'wav'=>'audio/wav', + 'xls'=>'application/vnd.ms-excel', + 'xml'=>'application/xml', + 'zip'=>'application/zip' + ); + foreach ($map as $key=>$val) + if (preg_match('/'.$key.'/',$ext[0])) + return $val; + } + return 'application/octet-stream'; + } + + /** + Return the MIME types stated in the HTTP Accept header as an array; + If a list of MIME types is specified, return the best match; or + FALSE if none found + @return array|string|FALSE + @param $list string|array + **/ + function acceptable($list=NULL) { + $accept=array(); + foreach (explode(',',str_replace(' ','',$_SERVER['HTTP_ACCEPT'])) + as $mime) + if (preg_match('/(.+?)(?:;q=([\d\.]+)|$)/',$mime,$parts)) + $accept[$parts[1]]=isset($parts[2])?$parts[2]:1; + if (!$accept) + $accept['*/*']=1; + else { + krsort($accept); + arsort($accept); + } + if ($list) { + if (is_string($list)) + $list=explode(',',$list); + foreach ($accept as $mime=>$q) + if ($q && $out=preg_grep('/'. + str_replace('\*','.*',preg_quote($mime,'/')).'/',$list)) + return current($out); + return FALSE; + } + return $accept; + } + + /** + Transmit file to HTTP client; Return file size if successful, + FALSE otherwise + @return int|FALSE + @param $file string + @param $mime string + @param $kbps int + @param $force bool + **/ + function send($file,$mime=NULL,$kbps=0,$force=TRUE) { + if (!is_file($file)) + return FALSE; + if (PHP_SAPI!='cli') { + header('Content-Type: '.$mime?:$this->mime($file)); + if ($force) + header('Content-Disposition: attachment; '. + 'filename='.basename($file)); + header('Accept-Ranges: bytes'); + header('Content-Length: '.$size=filesize($file)); + header('X-Powered-By: '.Base::instance()->get('PACKAGE')); + } + $ctr=0; + $handle=fopen($file,'rb'); + $start=microtime(TRUE); + while (!feof($handle) && + ($info=stream_get_meta_data($handle)) && + !$info['timed_out'] && !connection_aborted()) { + if ($kbps) { + // Throttle output + $ctr++; + if ($ctr/$kbps>$elapsed=microtime(TRUE)-$start) + usleep(1e6*($ctr/$kbps-$elapsed)); + } + // Send 1KiB and reset timer + echo fread($handle,1024); + } + fclose($handle); + return $size; + } + + /** + Receive file(s) from HTTP client; Return file size if successful, + FALSE otherwise + @return int|FALSE + @param $func callback + @param $overwrite bool + @param $slug bool + **/ + function receive($func=NULL,$overwrite=FALSE,$slug=TRUE) { + $fw=Base::instance(); + $dir=$fw->get('UPLOADS'); + if (!is_dir($dir)) + mkdir($dir,Base::MODE,TRUE); + if ($fw->get('VERB')=='PUT') { + $fw->write($dir.basename($fw->get('URI')),$fw->get('BODY')); + return TRUE; + } + if ($fw->get('VERB')=='POST') + foreach ($_FILES as $item) { + if (is_array($item['name'])) { + // Transpose array + $out=array(); + foreach ($item as $keyx=>$cols) + foreach ($cols as $keyy=>$valy) + $out[$keyy][$keyx]=$valy; + $item=$out; + } + else + $item=array($item); + foreach ($item as $file) { + if (empty($file['name'])) + return FALSE; + $base=basename($file['name']); + $dst=$dir. + ($slug && preg_match('/(.+?)(\.\w+)?$/',$base,$parts)? + $this->slug($parts[1]). + (isset($parts[2])?$parts[2]:''):$base); + if ($file['error'] || + $file['type']!=$this->mime($file['name']) || + $overwrite && file_exists($dst) || + $func && !$fw->call($func,array($file)) || + !move_uploaded_file($file['tmp_name'],$dst)) + return FALSE; + } + return TRUE; + } + return FALSE; + } + + /** + Return upload progress in bytes, FALSE on failure + @return int|FALSE + @param $id string + **/ + function progress($id) { + // ID returned by session.upload_progress.name + return ini_get('session.upload_progress.enabled') && + isset($_SESSION[$id]['bytes_processed'])? + $_SESSION[$id]['bytes_processed']:FALSE; + } + + /** + HTTP request via cURL + @return array + @param $url string + @param $options array + **/ + protected function _curl($url,$options) { + $curl=curl_init($url); + curl_setopt($curl,CURLOPT_FOLLOWLOCATION, + $options['follow_location']); + curl_setopt($curl,CURLOPT_MAXREDIRS, + $options['max_redirects']); + curl_setopt($curl,CURLOPT_CUSTOMREQUEST,$options['method']); + if (isset($options['header'])) + curl_setopt($curl,CURLOPT_HTTPHEADER,$options['header']); + if (isset($options['user_agent'])) + curl_setopt($curl,CURLOPT_USERAGENT,$options['user_agent']); + if (isset($options['content'])) + curl_setopt($curl,CURLOPT_POSTFIELDS,$options['content']); + curl_setopt($curl,CURLOPT_ENCODING,'gzip,deflate'); + $timeout=isset($options['timeout'])? + $options['timeout']: + ini_get('default_socket_timeout'); + curl_setopt($curl,CURLOPT_CONNECTTIMEOUT,$timeout); + curl_setopt($curl,CURLOPT_TIMEOUT,$timeout); + $headers=array(); + curl_setopt($curl,CURLOPT_HEADERFUNCTION, + // Callback for response headers + function($curl,$line) use(&$headers) { + if ($trim=trim($line)) + $headers[]=$trim; + return strlen($line); + } + ); + curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,FALSE); + ob_start(); + curl_exec($curl); + curl_close($curl); + $body=ob_get_clean(); + return array( + 'body'=>$body, + 'headers'=>$headers, + 'engine'=>'cURL', + 'cached'=>FALSE + ); + } + + /** + HTTP request via PHP stream wrapper + @return array + @param $url string + @param $options array + **/ + protected function _stream($url,$options) { + $eol="\r\n"; + $options['header']=implode($eol,$options['header']); + $body=@file_get_contents($url,FALSE, + stream_context_create(array('http'=>$options))); + $headers=isset($http_response_header)? + $http_response_header:array(); + $match=NULL; + foreach ($headers as $header) + if (preg_match('/Content-Encoding: (.+)/',$header,$match)) + break; + if ($match) + switch ($match[1]) { + case 'gzip': + $body=gzdecode($body); + break; + case 'deflate': + $body=gzuncompress($body); + break; + } + return array( + 'body'=>$body, + 'headers'=>$headers, + 'engine'=>'stream', + 'cached'=>FALSE + ); + } + + /** + HTTP request via low-level TCP/IP socket + @return array + @param $url string + @param $options array + **/ + protected function _socket($url,$options) { + $eol="\r\n"; + $headers=array(); + $body=''; + $parts=parse_url($url); + if ($parts['scheme']=='https') { + $parts['host']='ssl://'.$parts['host']; + $parts['port']=443; + } + else + $parts['port']=80; + if (empty($parts['path'])) + $parts['path']='/'; + if (empty($parts['query'])) + $parts['query']=''; + $socket=@fsockopen($parts['host'],$parts['port']); + if (!$socket) + return FALSE; + stream_set_blocking($socket,TRUE); + fputs($socket,$options['method'].' '.$parts['path']. + ($parts['query']?('?'.$parts['query']):'').' HTTP/1.0'.$eol + ); + fputs($socket,implode($eol,$options['header']).$eol.$eol); + if (isset($options['content'])) + fputs($socket,$options['content'].$eol); + // Get response + $content=''; + while (!feof($socket) && + ($info=stream_get_meta_data($socket)) && + !$info['timed_out'] && $str=fgets($socket,4096)) + $content.=$str; + fclose($socket); + $html=explode($eol.$eol,$content,2); + $body=isset($html[1])?$html[1]:''; + $headers=array_merge($headers,$current=explode($eol,$html[0])); + $match=NULL; + foreach ($current as $header) + if (preg_match('/Content-Encoding: (.+)/',$header,$match)) + break; + if ($match) + switch ($match[1]) { + case 'gzip': + $body=gzdecode($body); + break; + case 'deflate': + $body=gzuncompress($body); + break; + } + if ($options['follow_location'] && + preg_match('/Location: (.+?)'.preg_quote($eol).'/', + $html[0],$loc)) { + $options['max_redirects']--; + return $this->request($loc[1],$options); + } + return array( + 'body'=>$body, + 'headers'=>$headers, + 'engine'=>'socket', + 'cached'=>FALSE + ); + } + + /** + Specify the HTTP request engine to use; If not available, + fall back to an applicable substitute + @return string + @param $arg string + **/ + function engine($arg='socket') { + $arg=strtolower($arg); + if ($arg=='curl' && ($curl=extension_loaded('curl')) || + $arg=='stream' && ($stream=ini_get('allow_url_fopen')) || + $arg=='socket' && ($socket=function_exists('fsockopen'))) + $this->wrapper=$arg; + elseif ($socket) + $this->wrapper='socket'; + elseif ($stream) + $this->wrapper='stream'; + elseif ($curl) + $this->wrapper='curl'; + else + user_error(E_Request); + } + + /** + Replace old headers with new elements + @return NULL + @param $old array + @param $new string|array + **/ + function subst(array &$old,$new) { + if (is_string($new)) + $new=array($new); + foreach ($new as $hdr) { + $old=preg_grep('/'.preg_quote(strstr($hdr,':',TRUE),'/').':.+/', + $old,PREG_GREP_INVERT); + array_push($old,$hdr); + } + } + + /** + Submit HTTP request; Use HTTP context options (described in + http://www.php.net/manual/en/context.http.php) if specified; + Cache the page as instructed by remote server + @return array|FALSE + @param $url string + @param $options array + **/ + function request($url,array $options=NULL) { + $fw=Base::instance(); + $parts=parse_url($url); + if (empty($parts['scheme'])) { + // Local URL + $url=$fw->get('SCHEME').'://'. + $fw->get('HOST'). + ($url[0]!='/'?($fw->get('BASE').'/'):'').$url; + $parts=parse_url($url); + } + elseif (!preg_match('/https?/',$parts['scheme'])) + return FALSE; + if (!is_array($options)) + $options=array(); + if (empty($options['header'])) + $options['header']=array(); + elseif (is_string($options['header'])) + $options['header']=array($options['header']); + if (!$this->wrapper) + $this->engine(); + if ($this->wrapper!='stream') { + // PHP streams can't cope with redirects when Host header is set + foreach ($options['header'] as &$header) + if (preg_match('/^Host:/',$header)) { + $header='Host: '.$parts['host']; + unset($header); + break; + } + $this->subst($options['header'],'Host: '.$parts['host']); + } + $this->subst($options['header'], + array( + 'Accept-Encoding: gzip,deflate', + 'User-Agent: Mozilla/5.0 (compatible; '.php_uname('s').')', + 'Connection: close' + ) + ); + if (isset($options['content'])) { + if ($options['method']=='POST') + $this->subst($options['header'], + 'Content-Type: application/x-www-form-urlencoded'); + $this->subst($options['header'], + 'Content-Length: '.strlen($options['content'])); + } + if (isset($parts['user'],$parts['pass'])) + $this->subst($options['header'], + 'Authorization: Basic '. + base64_encode($parts['user'].':'.$parts['pass']) + ); + $options+=array( + 'method'=>'GET', + 'header'=>$options['header'], + 'follow_location'=>TRUE, + 'max_redirects'=>20, + 'ignore_errors'=>FALSE + ); + $eol="\r\n"; + if ($fw->get('CACHE') && + preg_match('/GET|HEAD/',$options['method'])) { + $cache=Cache::instance(); + if ($cache->exists( + $hash=$fw->hash($options['method'].' '.$url).'.url',$data)) { + if (preg_match('/Last-Modified: (.+?)'.preg_quote($eol).'/', + implode($eol,$data['headers']),$mod)) + $this->subst($options['header'], + 'If-Modified-Since: '.$mod[1]); + } + } + $result=$this->{'_'.$this->wrapper}($url,$options); + if ($result && isset($cache)) { + if (preg_match('/HTTP\/1\.\d 304/', + implode($eol,$result['headers']))) { + $result=$cache->get($hash); + $result['cached']=TRUE; + } + elseif (preg_match('/Cache-Control: max-age=(.+?)'. + preg_quote($eol).'/',implode($eol,$result['headers']),$exp)) + $cache->set($hash,$result,$exp[1]); + } + return $result; + } + + /** + Strip Javascript/CSS files of extraneous whitespaces and comments; + Return combined output as a minified string + @return string + @param $files string|array + @param $mime string + @param $header bool + **/ + function minify($files,$mime=NULL,$header=TRUE) { + $fw=Base::instance(); + if (is_string($files)) + $files=$fw->split($files); + if (!$mime) + $mime=$this->mime($files[0]); + preg_match('/\w+$/',$files[0],$ext); + $cache=Cache::instance(); + $dst=''; + foreach ($fw->split($fw->get('UI')) as $dir) + foreach ($files as $file) + if (is_file($save=$fw->fixslashes($dir.$file))) { + if ($fw->get('CACHE') && + ($cached=$cache->exists( + $hash=$fw->hash($save).'.'.$ext[0],$data)) && + $cached>filemtime($save)) + $dst.=$data; + else { + $data=''; + $src=$fw->read($save); + for ($ptr=0,$len=strlen($src);$ptr<$len;) { + if (preg_match('/^@import\h+url'. + '\(\h*([\'"])(.+?)\1\h*\)[^;]*;/', + substr($src,$ptr),$parts)) { + $path=dirname($file); + $data.=$this->minify( + ($path?($path.'/'):'').$parts[2], + $mime,$header + ); + $ptr+=strlen($parts[0]); + continue; + } + if ($src[$ptr]=='/') { + if ($src[$ptr+1]=='*') { + // Multiline comment + $str=strstr( + substr($src,$ptr+2),'*/',TRUE); + $ptr+=strlen($str)+4; + } + elseif ($src[$ptr+1]=='/') { + // Single-line comment + $str=strstr( + substr($src,$ptr+2),"\n",TRUE); + $ptr+=strlen($str)+2; + } + else { + // Presume it's a regex pattern + $regex=TRUE; + // Backtrack and validate + for ($ofs=$ptr;$ofs;$ofs--) { + // Pattern should be preceded by + // open parenthesis, colon, + // object property or operator + if (preg_match( + '/(return|[(:=!+\-*&|])$/', + substr($src,0,$ofs))) { + $data.='/'; + $ptr++; + while ($ptr<$len) { + $data.=$src[$ptr]; + $ptr++; + if ($src[$ptr-1]=='\\') { + $data.=$src[$ptr]; + $ptr++; + } + elseif ($src[$ptr-1]=='/') + break; + } + break; + } + elseif (!ctype_space($src[$ofs-1])) { + // Not a regex pattern + $regex=FALSE; + break; + } + } + if (!$regex) { + // Division operator + $data.=$src[$ptr]; + $ptr++; + } + } + continue; + } + if (in_array($src[$ptr],array('\'','"'))) { + $match=$src[$ptr]; + $data.=$match; + $ptr++; + // String literal + while ($ptr<$len) { + $data.=$src[$ptr]; + $ptr++; + if ($src[$ptr-1]=='\\') { + $data.=$src[$ptr]; + $ptr++; + } + elseif ($src[$ptr-1]==$match) + break; + } + continue; + } + if (ctype_space($src[$ptr])) { + if ($ptr+1get('CACHE')) + $cache->set($hash,$data); + $dst.=$data; + } + } + if (PHP_SAPI!='cli' && $header) + header('Content-Type: '.$mime.'; charset='.$fw->get('ENCODING')); + return $dst; + } + + /** + Retrieve RSS/Atom feed and return as an array + @return array|FALSE + @param $url string + @param $max int + @param $tags string + **/ + function rss($url,$max=10,$tags=NULL) { + if (!$data=$this->request($url)) + return FALSE; + // Suppress errors caused by invalid XML structures + libxml_use_internal_errors(TRUE); + $xml=simplexml_load_string($data['body'], + NULL,LIBXML_NOBLANKS|LIBXML_NOERROR); + if (!is_object($xml)) + return FALSE; + $out=array(); + if (isset($xml->channel)) { + $out['source']=(string)$xml->channel->title; + for ($i=0;$i<$max;$i++) { + $item=$xml->channel->item[$i]; + $out['feed'][]=array( + 'title'=>(string)$item->title, + 'link'=>(string)$item->link, + 'text'=>(string)$item->description + ); + } + } + elseif (isset($xml->entry)) { + $out['source']=(string)$xml->author->name; + for ($i=0;$i<$max;$i++) { + $item=$xml->entry[$i]; + $out['feed'][]=array( + 'title'=>(string)$item->title, + 'link'=>(string)$item->link['href'], + 'text'=>(string)$item->summary + ); + } + } + else + return FALSE; + Base::instance()->scrub($out,$tags); + return $out; + } + + /** + Return a URL/filesystem-friendly version of string + @return string + @param $text string + **/ + function slug($text) { + return trim(strtolower(preg_replace('/([^\pL\pN])+/u','-', + trim(strtr(str_replace('\'','',$text), + Base::instance()->get('DIACRITICS')+ + array( + 'Ǎ'=>'A','А'=>'A','Ā'=>'A','Ă'=>'A','Ą'=>'A','Å'=>'A', + 'Ǻ'=>'A','Ä'=>'A','Á'=>'A','À'=>'A','Ã'=>'A','Â'=>'A', + 'Æ'=>'AE','Ǽ'=>'AE','Б'=>'B','Ç'=>'C','Ć'=>'C','Ĉ'=>'C', + 'Č'=>'C','Ċ'=>'C','Ц'=>'C','Ч'=>'Ch','Ð'=>'Dj','Đ'=>'Dj', + 'Ď'=>'Dj','Д'=>'Dj','É'=>'E','Ę'=>'E','Ё'=>'E','Ė'=>'E', + 'Ê'=>'E','Ě'=>'E','Ē'=>'E','È'=>'E','Е'=>'E','Э'=>'E', + 'Ë'=>'E','Ĕ'=>'E','Ф'=>'F','Г'=>'G','Ģ'=>'G','Ġ'=>'G', + 'Ĝ'=>'G','Ğ'=>'G','Х'=>'H','Ĥ'=>'H','Ħ'=>'H','Ï'=>'I', + 'Ĭ'=>'I','İ'=>'I','Į'=>'I','Ī'=>'I','Í'=>'I','Ì'=>'I', + 'И'=>'I','Ǐ'=>'I','Ĩ'=>'I','Î'=>'I','IJ'=>'IJ','Ĵ'=>'J', + 'Й'=>'J','Я'=>'Ja','Ю'=>'Ju','К'=>'K','Ķ'=>'K','Ĺ'=>'L', + 'Л'=>'L','Ł'=>'L','Ŀ'=>'L','Ļ'=>'L','Ľ'=>'L','М'=>'M', + 'Н'=>'N','Ń'=>'N','Ñ'=>'N','Ņ'=>'N','Ň'=>'N','Ō'=>'O', + 'О'=>'O','Ǿ'=>'O','Ǒ'=>'O','Ơ'=>'O','Ŏ'=>'O','Ő'=>'O', + 'Ø'=>'O','Ö'=>'O','Õ'=>'O','Ó'=>'O','Ò'=>'O','Ô'=>'O', + 'Œ'=>'OE','П'=>'P','Ŗ'=>'R','Р'=>'R','Ř'=>'R','Ŕ'=>'R', + 'Ŝ'=>'S','Ş'=>'S','Š'=>'S','Ș'=>'S','Ś'=>'S','С'=>'S', + 'Ш'=>'Sh','Щ'=>'Shch','Ť'=>'T','Ŧ'=>'T','Ţ'=>'T','Ț'=>'T', + 'Т'=>'T','Ů'=>'U','Ű'=>'U','Ŭ'=>'U','Ũ'=>'U','Ų'=>'U', + 'Ū'=>'U','Ǜ'=>'U','Ǚ'=>'U','Ù'=>'U','Ú'=>'U','Ü'=>'U', + 'Ǘ'=>'U','Ǖ'=>'U','У'=>'U','Ư'=>'U','Ǔ'=>'U','Û'=>'U', + 'В'=>'V','Ŵ'=>'W','Ы'=>'Y','Ŷ'=>'Y','Ý'=>'Y','Ÿ'=>'Y', + 'Ź'=>'Z','З'=>'Z','Ż'=>'Z','Ž'=>'Z','Ж'=>'Zh','á'=>'a', + 'ă'=>'a','â'=>'a','à'=>'a','ā'=>'a','ǻ'=>'a','å'=>'a', + 'ä'=>'a','ą'=>'a','ǎ'=>'a','ã'=>'a','а'=>'a','ª'=>'a', + 'æ'=>'ae','ǽ'=>'ae','б'=>'b','č'=>'c','ç'=>'c','ц'=>'c', + 'ċ'=>'c','ĉ'=>'c','ć'=>'c','ч'=>'ch','ð'=>'dj','ď'=>'dj', + 'д'=>'dj','đ'=>'dj','э'=>'e','é'=>'e','ё'=>'e','ë'=>'e', + 'ê'=>'e','е'=>'e','ĕ'=>'e','è'=>'e','ę'=>'e','ě'=>'e', + 'ė'=>'e','ē'=>'e','ƒ'=>'f','ф'=>'f','ġ'=>'g','ĝ'=>'g', + 'ğ'=>'g','г'=>'g','ģ'=>'g','х'=>'h','ĥ'=>'h','ħ'=>'h', + 'ǐ'=>'i','ĭ'=>'i','и'=>'i','ī'=>'i','ĩ'=>'i','į'=>'i', + 'ı'=>'i','ì'=>'i','î'=>'i','í'=>'i','ï'=>'i','ij'=>'ij', + 'ĵ'=>'j','й'=>'j','я'=>'ja','ю'=>'ju','ķ'=>'k','к'=>'k', + 'ľ'=>'l','ł'=>'l','ŀ'=>'l','ĺ'=>'l','ļ'=>'l','л'=>'l', + 'м'=>'m','ņ'=>'n','ñ'=>'n','ń'=>'n','н'=>'n','ň'=>'n', + 'ʼn'=>'n','ó'=>'o','ò'=>'o','ǒ'=>'o','ő'=>'o','о'=>'o', + 'ō'=>'o','º'=>'o','ơ'=>'o','ŏ'=>'o','ô'=>'o','ö'=>'o', + 'õ'=>'o','ø'=>'o','ǿ'=>'o','œ'=>'oe','п'=>'p','р'=>'r', + 'ř'=>'r','ŕ'=>'r','ŗ'=>'r','ſ'=>'s','ŝ'=>'s','ș'=>'s', + 'š'=>'s','ś'=>'s','с'=>'s','ş'=>'s','ш'=>'sh','щ'=>'shch', + 'ß'=>'ss','ţ'=>'t','т'=>'t','ŧ'=>'t','ť'=>'t','ț'=>'t', + 'у'=>'u','ǘ'=>'u','ŭ'=>'u','û'=>'u','ú'=>'u','ų'=>'u', + 'ù'=>'u','ű'=>'u','ů'=>'u','ư'=>'u','ū'=>'u','ǚ'=>'u', + 'ǜ'=>'u','ǔ'=>'u','ǖ'=>'u','ũ'=>'u','ü'=>'u','в'=>'v', + 'ŵ'=>'w','ы'=>'y','ÿ'=>'y','ý'=>'y','ŷ'=>'y','ź'=>'z', + 'ž'=>'z','з'=>'z','ż'=>'z','ж'=>'zh' + ))))),'-'); + } + +} + +if (!function_exists('gzdecode')) { + + /** + Decode gzip-compressed string + @param $data string + **/ + function gzdecode($str) { + $fw=Base::instance(); + if (!is_dir($tmp=$fw->get('TEMP'))) + mkdir($tmp,Base::MODE,TRUE); + file_put_contents($file=$tmp.'/'. + $fw->hash($fw->get('ROOT').$fw->get('BASE')).'.'. + $fw->hash(uniqid()).'.gz',$str,LOCK_EX); + ob_start(); + readgzfile($file); + $out=ob_get_clean(); + @unlink($file); + return $out; + } + +} diff --git a/lib/web/geo.php b/lib/web/geo.php new file mode 100644 index 0000000..86c1553 --- /dev/null +++ b/lib/web/geo.php @@ -0,0 +1,101 @@ +getLocation(); + $trn=$ref->getTransitions($now=time(),$now); + $out=array( + 'offset'=>$ref-> + getOffset(new \DateTime('now',new \DateTimeZone('GMT')))/3600, + 'country'=>$loc['country_code'], + 'latitude'=>$loc['latitude'], + 'longitude'=>$loc['longitude'], + 'dst'=>$trn[0]['isdst'] + ); + unset($ref); + return $out; + } + + /** + Return geolocation data based on specified/auto-detected IP address + @return array|FALSE + @param $ip string + **/ + function location($ip=NULL) { + $fw=\Base::instance(); + $web=\Web::instance(); + if (!$ip) + $ip=$fw->get('IP'); + $public=filter_var($ip,FILTER_VALIDATE_IP, + FILTER_FLAG_IPV4|FILTER_FLAG_IPV6| + FILTER_FLAG_NO_RES_RANGE|FILTER_FLAG_NO_PRIV_RANGE); + if (function_exists('geoip_db_avail') && + geoip_db_avail(GEOIP_CITY_EDITION_REV1) && + $out=@geoip_record_by_name($ip)) { + $out['request']=$ip; + $out['region_code']=$out['region']; + $out['region_name']=geoip_region_name_by_code( + $out['country_code'],$out['region']); + unset($out['country_code3'],$out['region'],$out['postal_code']); + return $out; + } + if (($req=$web->request('http://www.geoplugin.net/json.gp'. + ($public?('?ip='.$ip):''))) && + $data=json_decode($req['body'],TRUE)) { + $out=array(); + foreach ($data as $key=>$val) + if (!strpos($key,'currency') && $key!=='geoplugin_status' + && $key!=='geoplugin_region') + $out[$fw->snakecase(substr($key, 10))]=$val; + return $out; + } + return FALSE; + } + + /** + Return weather data based on specified latitude/longitude + @return array|FALSE + @param $latitude float + @param $longitude float + **/ + function weather($latitude,$longitude) { + $fw=\Base::instance(); + $web=\Web::instance(); + $query=array( + 'lat'=>$latitude, + 'lng'=>$longitude, + 'username'=>$fw->hash($fw->get('IP')) + ); + return ($req=$web->request( + 'http://ws.geonames.org/findNearByWeatherJSON?'. + http_build_query($query))) && + ($data=json_decode($req['body'],TRUE)) && + isset($data['weatherObservation'])? + $data['weatherObservation']: + FALSE; + } + +} diff --git a/lib/web/openid.php b/lib/web/openid.php new file mode 100644 index 0000000..0219c70 --- /dev/null +++ b/lib/web/openid.php @@ -0,0 +1,216 @@ +args['identity'])) + $this->args['identity']='http://'.$this->args['identity']; + $url=parse_url($this->args['identity']); + // Remove fragment; reconnect parts + $this->args['identity']=$url['scheme'].'://'. + (isset($url['user'])? + ($url['user']. + (isset($url['pass'])?(':'.$url['pass']):'').'@'):''). + strtolower($url['host']).(isset($url['path'])?$url['path']:'/'). + (isset($url['query'])?('?'.$url['query']):''); + // HTML-based discovery of OpenID provider + $req=\Web::instance()-> + request($this->args['identity'],array('proxy'=>$proxy)); + if (!$req) + return FALSE; + $type=array_values(preg_grep('/Content-Type:/',$req['headers'])); + if ($type && + preg_match('/application\/xrds\+xml|text\/xml/',$type[0]) && + ($sxml=simplexml_load_string($req['body'])) && + ($xrds=json_decode(json_encode($sxml),TRUE)) && + isset($xrds['XRD'])) { + // XRDS document + $svc=$xrds['XRD']['Service']; + if (isset($svc[0])) + $svc=$svc[0]; + if (preg_grep('/http:\/\/specs\.openid\.net\/auth\/2.0\/'. + '(?:server|signon)/',$svc['Type'])) { + $this->args['provider']=$svc['URI']; + if (isset($svc['LocalID'])) + $this->args['localidentity']=$svc['LocalID']; + elseif (isset($svc['CanonicalID'])) + $this->args['localidentity']=$svc['CanonicalID']; + } + $this->args['server']=$svc['URI']; + if (isset($svc['Delegate'])) + $this->args['delegate']=$svc['Delegate']; + } + else { + $len=strlen($req['body']); + $ptr=0; + // Parse document + while ($ptr<$len) + if (preg_match( + '/^/is', + substr($req['body'],$ptr),$parts)) { + if ($parts[1] && + // Process attributes + preg_match_all('/\b(rel|href)\h*=\h*'. + '(?:"(.+?)"|\'(.+?)\')/s',$parts[1],$attr, + PREG_SET_ORDER)) { + $node=array(); + foreach ($attr as $kv) + $node[$kv[1]]=isset($kv[2])?$kv[2]:$kv[3]; + if (isset($node['rel']) && + preg_match('/openid2?\.(\w+)/', + $node['rel'],$var) && + isset($node['href'])) + $this->args[$var[1]]=$node['href']; + + } + $ptr+=strlen($parts[0]); + } + else + $ptr++; + } + // Get OpenID provider's endpoint URL + if (isset($this->args['provider'])) { + // OpenID 2.0 + $this->args['ns']='http://specs.openid.net/auth/2.0'; + if (isset($this->args['localidentity'])) + $this->args['identity']=$this->args['localidentity']; + if (isset($this->args['trust_root'])) + $this->args['realm']=$this->args['trust_root']; + } + elseif (isset($this->args['server'])) { + // OpenID 1.1 + if (isset($this->args['delegate'])) + $this->args['identity']=$this->args['delegate']; + } + if (isset($this->args['provider'])) { + // OpenID 2.0 + if (empty($this->args['claimed_id'])) + $this->args['claimed_id']=$this->args['identity']; + return $this->args['provider']; + } + elseif (isset($this->args['server'])) + // OpenID 1.1 + return $this->args['server']; + else + return FALSE; + } + + /** + Initiate OpenID authentication sequence; Return FALSE on failure + or redirect to OpenID provider URL + @return bool + @param $proxy string + **/ + function auth($proxy=NULL) { + $fw=\Base::instance(); + $root=$fw->get('SCHEME').'://'.$fw->get('HOST'); + if (empty($this->args['trust_root'])) + $this->args['trust_root']=$root.$fw->get('BASE').'/'; + if (empty($this->args['return_to'])) + $this->args['return_to']=$root.$_SERVER['REQUEST_URI']; + $this->args['mode']='checkid_setup'; + if ($url=$this->discover($proxy)) { + $var=array(); + foreach ($this->args as $key=>$val) + $var['openid.'.$key]=$val; + $fw->reroute($url.'?'.http_build_query($var)); + } + return FALSE; + } + + /** + Return TRUE if OpenID verification was successful + @return bool + @param $proxy string + **/ + function verified($proxy=NULL) { + foreach ($_GET as $key=>$val) + if (preg_match('/^openid_(.+)/',$key,$match)) + $this->args[$match[1]]=$val; + if ($this->args['mode']!='error' && $url=$this->discover($proxy)) { + $this->args['mode']='check_authentication'; + $var=array(); + foreach ($this->args as $key=>$val) + $var['openid.'.$key]=$val; + $req=\Web::instance()->request( + $url, + array( + 'method'=>'POST', + 'content'=>http_build_query($var), + 'proxy'=>$proxy + ) + ); + return preg_match('/is_valid:true/i',$req['body']); + } + return FALSE; + } + + /** + Return TRUE if OpenID request parameter exists + @return bool + @param $key string + **/ + function exists($key) { + return isset($this->args[$key]); + } + + /** + Bind value to OpenID request parameter + @return string + @param $key string + @param $val string + **/ + function set($key,$val) { + return $this->args[$key]=$val; + } + + /** + Return value of OpenID request parameter + @return mixed + @param $key string + **/ + function get($key) { + return isset($this->args[$key])?$this->args[$key]:NULL; + } + + /** + Remove OpenID request parameter + @param $key + **/ + function clear($key) { + unset($this->args[$key]); + } + +} diff --git a/lib/web/pingback.php b/lib/web/pingback.php new file mode 100644 index 0000000..3b68e9a --- /dev/null +++ b/lib/web/pingback.php @@ -0,0 +1,170 @@ +request($url); + $found=FALSE; + if ($req && $req['body']) { + // Look for pingback header + foreach ($req['headers'] as $header) + if (preg_match('/^X-Pingback:\h*(.+)/',$header,$href)) { + $found=$href[1]; + break; + } + if (!$found && + // Scan page for pingback link tag + preg_match('//i',$req['body'],$parts) && + preg_match('/rel\h*=\h*"pingback"/i',$parts[1]) && + preg_match('/href\h*=\h*"\h*(.+?)\h*"/i',$parts[1],$href)) + $found=$href[1]; + } + return $found; + } + + /** + Load local page contents, parse HTML anchor tags, find permalinks, + and send XML-RPC calls to corresponding pingback servers + @return NULL + @param $source string + **/ + function inspect($source) { + $fw=\Base::instance(); + $web=\Web::instance(); + $parts=parse_url($source); + if (empty($parts['scheme']) || empty($parts['host']) || + $parts['host']==$fw->get('HOST')) { + $req=$web->request($source); + $doc=new \DOMDocument('1.0',$fw->get('ENCODING')); + $doc->stricterrorchecking=FALSE; + $doc->recover=TRUE; + if ($req && @$doc->loadhtml($req['body'])) { + // Parse anchor tags + $links=$doc->getelementsbytagname('a'); + foreach ($links as $link) { + $permalink=$link->getattribute('href'); + // Find pingback-enabled resources + if ($permalink && $found=$this->enabled($permalink)) { + $req=$web->request($found, + array( + 'method'=>'POST', + 'header'=>'Content-Type: application/xml', + 'content'=>xmlrpc_encode_request( + 'pingback.ping', + array($source,$permalink), + array('encoding'=>$fw->get('ENCODING')) + ) + ) + ); + if ($req && $req['body']) + $this->log.=date('r').' '. + $permalink.' [permalink:'.$found.']'.PHP_EOL. + $req['body'].PHP_EOL; + } + } + } + unset($doc); + } + } + + /** + Receive ping, check if local page is pingback-enabled, verify + source contents, and return XML-RPC response + @return string + @param $func callback + @param $path string + **/ + function listen($func,$path=NULL) { + $fw=\Base::instance(); + if (PHP_SAPI!='cli') { + header('X-Powered-By: '.$fw->get('PACKAGE')); + header('Content-Type: application/xml; '. + 'charset='.$charset=$fw->get('ENCODING')); + } + if (!$path) + $path=$fw->get('BASE'); + $web=\Web::instance(); + $args=xmlrpc_decode_request($fw->get('BODY'),$method,$charset); + $options=array('encoding'=>$charset); + if ($method=='pingback.ping' && isset($args[0],$args[1])) { + list($source,$permalink)=$args; + $doc=new \DOMDocument('1.0',$fw->get('ENCODING')); + // Check local page if pingback-enabled + $parts=parse_url($permalink); + if ((empty($parts['scheme']) || + $parts['host']==$fw->get('HOST')) && + preg_match('/^'.preg_quote($path,'/').'/'. + ($fw->get('CASELESS')?'i':''),$parts['path']) && + $this->enabled($permalink)) { + // Check source + $parts=parse_url($source); + if ((empty($parts['scheme']) || + $parts['host']==$fw->get('HOST')) && + ($req=$web->request($source)) && + $doc->loadhtml($req['body'])) { + $links=$doc->getelementsbytagname('a'); + foreach ($links as $link) { + if ($link->getattribute('href')==$permalink) { + call_user_func_array($func, + array($source,$req['body'])); + // Success + die(xmlrpc_encode_request(NULL,$source,$options)); + } + } + // No link to local page + die(xmlrpc_encode_request(NULL,0x11,$options)); + } + // Source failure + die(xmlrpc_encode_request(NULL,0x10,$options)); + } + // Doesn't exist (or not pingback-enabled) + die(xmlrpc_encode_request(NULL,0x21,$options)); + } + // Access denied + die(xmlrpc_encode_request(NULL,0x31,$options)); + } + + /** + Return transaction history + @return string + **/ + function log() { + return $this->log; + } + + /** + Instantiate class + @return object + **/ + function __construct() { + // Suppress errors caused by invalid HTML structures + libxml_use_internal_errors(TRUE); + } + +} diff --git a/temp/.DS_Store b/temp/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/temp/.DS_Store differ