├── .editorconfig ├── .gitattributes ├── .gitignore ├── .prettierrc ├── .travis.yml ├── Dockerfile ├── LICENSE ├── Makefile ├── README.md ├── TODO.txt ├── Vagrantfile ├── bin ├── compile-templates.php └── generate_secret.php ├── docs ├── database_model.md ├── install_appfog.md ├── install_base.md ├── install_external.md ├── pagination.md ├── philosophy.md ├── style_guide.md └── troubleshooting.md ├── extras ├── README.md ├── lib_base58.php └── lib_cache_memcache.php ├── schema ├── .htaccess ├── db_main.schema └── db_tickets.schema ├── tests ├── 01_files.t ├── 01_notices.t ├── 02_db.t ├── 02_http_codes.t ├── 02_http_methods.t ├── 04_db.t ├── 05_cache.t ├── 06_cache_memcache.t ├── 07_random.t ├── 08_crypto.t ├── 09_passwords.t ├── 10_users.t ├── 11_login.t ├── bench_quoted_keys.php ├── coverage.php ├── docker │ ├── 001-flamework.conf │ └── entrypoint.sh ├── helpers │ └── users.php ├── php.ini ├── testmore.php ├── travis │ ├── config.php │ ├── config_52.php │ └── setup.sh ├── vagrant │ └── init.sh └── wrapper.php └── www ├── .htaccess ├── 403.php ├── 404.php ├── about.php ├── account.php ├── account_delete.php ├── account_password.php ├── checkcookie.php ├── contact.php ├── cron ├── .htaccess └── generate_apache_config_bits.php ├── css ├── .htaccess ├── admin.source.css ├── bootstrap-responsive.css ├── bootstrap-responsive.min.css ├── bootstrap.css ├── bootstrap.min.css └── main.source.css ├── forgot.php ├── images ├── .htaccess ├── glyphicons-halflings-white.png ├── glyphicons-halflings.png └── stripes_bg.gif ├── include ├── .htaccess ├── config.php.example ├── init.php ├── lib_auth.php ├── lib_bcrypt.php ├── lib_cache.php ├── lib_cli.php ├── lib_crumb.php ├── lib_crypto.php ├── lib_db.php ├── lib_dbtickets.php ├── lib_email.php ├── lib_error.php ├── lib_features.php ├── lib_filter.php ├── lib_http.php ├── lib_log.php ├── lib_login.php ├── lib_paginate.php ├── lib_passwords.php ├── lib_random.php ├── lib_sanitize.php ├── lib_smarty.php ├── lib_users.php ├── lib_utf8.php └── smarty-2.6.28 │ ├── Config_File.class.php │ ├── Smarty.class.php │ ├── Smarty_Compiler.class.php │ ├── debug.tpl │ ├── internals │ ├── core.assemble_plugin_filepath.php │ ├── core.assign_smarty_interface.php │ ├── core.create_dir_structure.php │ ├── core.display_debug_console.php │ ├── core.get_include_path.php │ ├── core.get_microtime.php │ ├── core.get_php_resource.php │ ├── core.is_secure.php │ ├── core.is_trusted.php │ ├── core.load_plugins.php │ ├── core.load_resource_plugin.php │ ├── core.process_cached_inserts.php │ ├── core.process_compiled_include.php │ ├── core.read_cache_file.php │ ├── core.rm_auto.php │ ├── core.rmdir.php │ ├── core.run_insert_handler.php │ ├── core.smarty_include_php.php │ ├── core.write_cache_file.php │ ├── core.write_compiled_include.php │ ├── core.write_compiled_resource.php │ └── core.write_file.php │ └── plugins │ ├── block.textformat.php │ ├── compiler.assign.php │ ├── function.assign_debug_info.php │ ├── function.config_load.php │ ├── function.counter.php │ ├── function.cycle.php │ ├── function.debug.php │ ├── function.eval.php │ ├── function.fetch.php │ ├── function.html_checkboxes.php │ ├── function.html_image.php │ ├── function.html_options.php │ ├── function.html_radios.php │ ├── function.html_select_date.php │ ├── function.html_select_time.php │ ├── function.html_table.php │ ├── function.mailto.php │ ├── function.math.php │ ├── function.popup.php │ ├── function.popup_init.php │ ├── modifier.capitalize.php │ ├── modifier.cat.php │ ├── modifier.count_characters.php │ ├── modifier.count_paragraphs.php │ ├── modifier.count_sentences.php │ ├── modifier.count_words.php │ ├── modifier.date_format.php │ ├── modifier.debug_print_var.php │ ├── modifier.default.php │ ├── modifier.escape.php │ ├── modifier.indent.php │ ├── modifier.lower.php │ ├── modifier.nl2br.php │ ├── modifier.regex_replace.php │ ├── modifier.replace.php │ ├── modifier.spacify.php │ ├── modifier.string_format.php │ ├── modifier.strip.php │ ├── modifier.strip_tags.php │ ├── modifier.truncate.php │ ├── modifier.upper.php │ ├── modifier.wordwrap.php │ ├── outputfilter.trimwhitespace.php │ ├── shared.escape_special_chars.php │ └── shared.make_timestamp.php ├── index.php ├── javascript ├── .htaccess ├── bootstrap.js ├── bootstrap.min.js ├── html5.js ├── jquery-1.8.2.min.js └── jquery.touchwipe.min.js ├── paging.php ├── reset.php ├── signin.php ├── signout.php ├── signup.php ├── templates ├── .htaccess ├── email_contact.txt ├── email_password_reset.txt ├── inc_foot.txt ├── inc_head.txt ├── inc_pagination_nextprev.txt ├── inc_pagination_pretty.txt ├── inc_pagination_shortcuts.txt ├── page_about.txt ├── page_account.txt ├── page_account_delete.txt ├── page_account_delete_confirm.txt ├── page_account_delete_done.txt ├── page_account_password.txt ├── page_contact.txt ├── page_error_403.txt ├── page_error_404.txt ├── page_error_410.txt ├── page_error_500.txt ├── page_error_cookie.txt ├── page_feature_disabled.txt ├── page_forgot.txt ├── page_forgot_sent.txt ├── page_index.txt ├── page_paging.txt ├── page_reset.txt ├── page_signin.txt ├── page_signin_disabled.txt ├── page_signout.txt ├── page_signout_done.txt ├── page_signup.txt ├── page_signup_disabled.txt └── page_site_disabled.txt └── templates_c ├── .gitignore └── .htaccess /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | # Config EOL characters, not ending blank lines at the end of files, always use UTF-8, trim trailing whitespace 4 | [*] 5 | end_of_line = lf 6 | insert_final_newline = false 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | 10 | # Indent is 4 tabs almost everywhere 11 | [*.{js,jsx,ts,tsx,json,php,txt,html,md,less,css,t}] 12 | indent_style = tab 13 | indent_size = 4 -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.sh text eol=lf 2 | * text=auto -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | www/include/config.php 3 | .vagrant 4 | tests/coverage.state 5 | coverage/ 6 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "tabWidth": 4, 4 | "useTabs": true, 5 | "singleQuote": true, 6 | "trailingComma": "es5", 7 | "arrowParens": "always" 8 | } 9 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | php: 3 | - 5.2 4 | - 5.3 5 | - 5.4 6 | services: 7 | - memcached 8 | before_script: 9 | - /bin/bash tests/travis/setup.sh 10 | script: 11 | - "prove -v --exec 'php --php-ini ./tests/php.ini' ./tests/*.t" 12 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:14.04 2 | 3 | # Install the packages we need 4 | RUN export DEBIAN_FRONTEND=noninteractive && \ 5 | apt-get update && \ 6 | apt-get upgrade -y && \ 7 | apt-get install -y php5-cli git php5-mcrypt php5-curl apache2 libapache2-mod-php5 mysql-server php5-mysql memcached php5-memcache php5-mcrypt && \ 8 | apt-get autoremove && \ 9 | apt-get clean && apt-get autoclean 10 | 11 | # Turn on the mcrypt php module and the rewrite\ssl apache modules 12 | RUN php5enmod mcrypt && \ 13 | a2enmod rewrite && \ 14 | a2enmod ssl 15 | 16 | # TODO: Proper ssl certs via letsencrypt or something 17 | 18 | # Configure our path for where we'll serve source-code from 19 | WORKDIR /mnt/flamework 20 | COPY tests/docker/001-flamework.conf /etc/apache2/sites-available/ 21 | RUN a2ensite 001-flamework 22 | RUN a2dissite 000-default 23 | 24 | RUN rm -rf /var/www/html 25 | RUN ln -fs /mnt/flamework/www /var/www/html 26 | 27 | # TODO: PHPUnit via Pear is dead. Also, conditionally install only when running tests? 28 | #RUN apt-get install -y php-pear 29 | #RUN pear channel-discover pear.phpunit.de 30 | #RUN pear install phpunit/PHP_CodeCoverage 31 | 32 | # TODO: Only install when running tests? 33 | #RUN apt-get install -y make 34 | #RUN pecl install xdebug 35 | #RUN echo "zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so" > /etc/php5/conf.d/xdebug.ini 36 | 37 | # Allow mounting of source code from external to the container 38 | VOLUME ["/mnt/flamework"] 39 | 40 | # Optional persistence of the mysql data 41 | VOLUME ["/var/lib/mysql"] 42 | 43 | # Listen on the HTTP and HTTPS ports 44 | EXPOSE 80 45 | EXPOSE 443 46 | 47 | # When the container is run, this script will start mysql and apache, 48 | # and put a sample config in place if necessary 49 | ENTRYPOINT [ "/bin/bash", "tests/docker/entrypoint.sh" ] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010-2014, Cal Henderson 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other 8 | materials provided with the distribution. 9 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 10 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 11 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 12 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 13 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 14 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | all: clean todo 2 | 3 | clean: 4 | rm -f ./TODO.txt 5 | 6 | todo: TODO.txt 7 | 8 | TODO.txt: 9 | @echo "Generating TODO.txt file" 10 | @echo "# This file was generated automatically by grep-ing for 'TO DO' in the source code." > ./TODO.txt 11 | @echo "# This file is meant as a pointer to the actual details in the files themselves." >> TODO.txt 12 | @echo "# This file was created "`date` >> TODO.txt 13 | @echo "" >> TODO.txt 14 | @-grep -n -r -e "TO DO" www >> TODO.txt 15 | @-grep -n -r -e "TO DO" bin >> TODO.txt 16 | @-grep -n -r -e "TODO" www >> TODO.txt 17 | @-grep -n -r -e "TODO" bin >> TODO.txt 18 | 19 | templates: 20 | php -q ./bin/compile-templates.php 21 | 22 | secret: 23 | php -q ./bin/generate_secret.php 24 | 25 | test: 26 | prove -v --exec 'php --php-ini ./tests/php.ini' ./tests/*.t 27 | 28 | cover: 29 | rm -f ./tests/coverage.state 30 | rm -rf ./coverage 31 | -make test 32 | php -q ./tests/coverage.php 33 | 34 | docker: 35 | docker build -t flamework . 36 | docker run -ti -p80\:8081 -p443\:4331 -v ~/dev/flamework\:/mnt/flamework --name=flamework --rm flamework 37 | 38 | docker-test: 39 | docker exec -ti flamework apt-get install -y make 40 | docker exec -ti flamework make test 41 | -------------------------------------------------------------------------------- /TODO.txt: -------------------------------------------------------------------------------- 1 | # This file was generated automatically by grep-ing for 'TO DO' in the source code. 2 | # This file is meant as a pointer to the actual details in the files themselves. 3 | # This file was created Thu May 23 21:40:12 UTC 2013 4 | 5 | www/include/lib_error.php:169: # TO DO: work out how to use this for when the site is disabled 6 | www/include/lib_users.php:254: # TO DO: an actual cluster ID if federated 7 | www/include/lib_http.php:99: # TODO: sort out PUT-ing files 8 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | Vagrant.configure("2") do |config| 2 | config.vm.box = "precise32" 3 | config.vm.box_url = "http://files.vagrantup.com/precise32.box" 4 | 5 | config.vm.network :forwarded_port, guest: 80, host: 8080 6 | 7 | config.vm.provision :shell, :path => "tests/vagrant/init.sh" 8 | end 9 | -------------------------------------------------------------------------------- /bin/compile-templates.php: -------------------------------------------------------------------------------- 1 | compileAllTemplates('.txt', true); 12 | 13 | $pattern = "{$GLOBALS['cfg']['smarty_template_dir']}/*.txt"; 14 | $templates = array(); 15 | 16 | foreach (glob($pattern) as $f){ 17 | $templates[] = basename($f); 18 | } 19 | 20 | $GLOBALS['smarty']->force_compile = true; 21 | 22 | foreach ($templates as $t){ 23 | $GLOBALS['smarty']->fetch($t); 24 | } 25 | 26 | exit(); 27 | ?> 28 | -------------------------------------------------------------------------------- /bin/generate_secret.php: -------------------------------------------------------------------------------- 1 | 18 | -------------------------------------------------------------------------------- /docs/database_model.md: -------------------------------------------------------------------------------- 1 | # The Flamework database model 2 | 3 | Flamework assumes a federated model with all the various user data spread across a series of databases, 4 | or "clusters". For each cluster there are a series of corresponding helper functions defined in `lib_db.php`. 5 | 6 | **By default Flamework does not require that it be run under a fully-federated 7 | database system.** It takes advantage of the ability to run in "poor man's 8 | federated" mode which causes the database libraries to act as though there are 9 | multiple database clusters when there's only really one. Specifically, all the 10 | various databases are treated as though they live in the `db_main` 11 | cluster. The goal is to enable (and ensure) that when a given installation of 12 | a Flamework project outgrows a simple one or two machine setup that it can easily 13 | be migrated to a more robust system with a minimum of fuss. 14 | 15 | As of this writing Flamework defines/expects the following clusters: 16 | 17 | + **db_main** 18 | 19 | This is the database cluster where user accounts and other lookup-style database tables live. 20 | 21 | + **db_users** 22 | 23 | These are the federated tables, sometimes called "shards". This is where the bulk of the data in Dotspotting 24 | is stored because it can be spread out, in smaller chunks, across a whole bunch of databases rather than a 25 | single monolithic monster database that becomes a single point of failure and it just generally a nuisance 26 | to maintain. 27 | 28 | + **db_tickets** 29 | 30 | One of the things about storing federated user data is that from time to time you may need to "re-balance" 31 | your shards, for example moving all of a user's data from shard #5 to shard #23. That means you can no longer 32 | rely on an individual database to generate auto-incrementing unique IDs because each database shard creates 33 | those IDs in isolation and if you try to move a dot, for example, with ID `123` to a shard with another dot 34 | that already has the same ID everything will break and there will be tears. 35 | 36 | The way around this is to use "ticketing" servers whose only job is to sit around and assign unique IDs. 37 | A discussion of ticketing servers is outside the scope of this document but [Kellan wrote a good blog post 38 | about the subject](http://code.flickr.com/blog/2010/02/08/ticket-servers-distributed-unique-primary-keys-on-the-cheap/) 39 | if you're interested in learning more. Which is a long way of saying: Flamework uses tickets and they come 40 | from the `db_tickets` cluster. 41 | -------------------------------------------------------------------------------- /docs/install_appfog.md: -------------------------------------------------------------------------------- 1 | # Installation - AppFog.com 2 | 3 | Installation on AppFog.com is pretty simple and offers the advantage of being able to easily scale your app and move between infrastructures and data centers. 4 | 5 | 1) To begin, simply log in to your AppFog account and create a PHP App. You can select any available infrastructure. Wait for your app to launch and then add a MySQL service and bind to it via the control panel. This is also fairly trivial to do from the command line. 6 | 7 | 2) Once your app is running be sure you have the following installed: 8 | 9 | $ sudo gem install af 10 | $ sudo gem install caldecott 11 | 12 | 3) In your www/include/config.php file, add the following: 13 | 14 | $services = getenv("VCAP_SERVICES"); 15 | $services_json = json_decode($services,true); 16 | $mysql_config = $services_json["mysql-5.1"][0]["credentials"]; 17 | 18 | and replace this 19 | 20 | $GLOBALS['cfg']['db_main'] = array( 21 | 'host' => 'localhost', 22 | 'user' => 'root', 23 | 'pass' => 'root', 24 | 'name' => 'flamework', 25 | 'auto_connect' => 0, 26 | ); 27 | 28 | with this 29 | 30 | $GLOBALS['cfg']['db_main'] = array( 31 | 'host' => $mysql_config["hostname"], 32 | 'user' => $mysql_config["user"], 33 | 'pass' => $mysql_config["password"], 34 | 'name' => $mysql_config["name"], 35 | 'auto_connect' => 0, 36 | ); 37 | 38 | 4) Push the www directory to your new app by doing the following: 39 | 40 | $ cd /yourflameworkfolder/www 41 | $ af login 42 | $ af push myApp 43 | 44 | 5) Flamework is now installed on your AppFog app. You Should be able to see its basic home-page by going to your app's URL. To add the DB schema do the following. 45 | 46 | $ af tunnel myApp 47 | 48 | This will open a MySQL connection to your AppFog database. You can then use standard MySQL commands to copy in the schema files found in /yourflameworkfolder/schema. Once this is done, you should be able to create user accounts, etc on your AppFog/Flaework app. 49 | 50 | Enjoy. -------------------------------------------------------------------------------- /docs/install_base.md: -------------------------------------------------------------------------------- 1 | # Installation - As a base for a new project 2 | 3 | Get the [code from GitHub](https://github.com/exflickr/flamework). 4 | 5 | Decide on whether you'll host this on a sub-domain (something alone the lines of `flame.example.com`) or on a subdirectory 6 | (maybe something like `www.example.com/flame`). 7 | 8 | The rest of this section will assume the following: 9 | 10 | * That you'll be hosting on a sub-domain called *flame* on a domain called *example.com*, or, to put it another way, 11 | `flame.example.com`. Just mentally substitute your domain and sub-domain when reading, and physically substitute your 12 | domain and sub-domain during the installation process. Unless you actually own the example.com. 13 | * That you want the URL for Flamework to be `flame.example.com` and not `flame.example.com/www` 14 | * That `` is the path on your webserver where your web server has been configured to find the sub-domain. 15 | * That you have shell access (probably via SSH) to your web server. 16 | 17 | Now ... upload the code, plus all sub-directories to your web-server; don't forget the (hidden) `.htaccess` file in the 18 | root of the code's distribution. 19 | 20 | Copy `/www/include/config.php.example` to `/www/include/config.php` and edit this new file. 21 | 22 | Change the site name to reflect your sub-domain name and whether you're running in a production or development environment 23 | 24 | $GLOBALS['cfg']['site_name'] = 'flame'; 25 | $GLOBALS['cfg']['environment'] = 'prod'; 26 | 27 | Set up your database name, database user and database password. Copy and paste these into ... 28 | 29 | $GLOBALS['cfg']['db_main'] = array( 30 | 'host' => 'localhost', 31 | 'name' => 'my-database-name', 32 | 'user' => 'my-database-user', 33 | 'pass' => 'my-database-users-password', 34 | 'auto_connect' => 0, 35 | ); 36 | 37 | Setup your encryption secrets secrets. SSH to your host and run `php /bin/generate_secret.php`, 3 times. Copy and paste each secret into 38 | 39 | $GLOBALS['cfg']['crypto_cookie_secret'] = 'first-secret-here'; 40 | $GLOBALS['cfg']['crypto_password_secret'] = 'third-secret-here'; 41 | $GLOBALS['cfg']['crypto_crumb_secret'] = 'second-secret-here'; 42 | 43 | (If you don't have shell access to your web-server, you can run this command from the shell on a local machine) 44 | 45 | Create the database tables. Load `/schema/db_main.schema` and `/schema/db_users.schema` into the database. 46 | You can do this either via phpMyAdmin and the import option or via `mysql` on the shell's command line. 47 | 48 | Browse to http://flame.example.com 49 | 50 | If you get errors in your Apache error log such as ... 51 | 52 | www/.htaccess: Invalid command 'php_value', perhaps misspelled or defined by a module not included in the server configuration 53 | 54 | ... then your host is probably running PHP as a CGI and not as a module so you'll want to comment out any line in 55 | `/www/.htaccess` that starts with `php_value` or `php_flag` and put these values into a new file, 56 | `/www/php.ini`, without the leading `php_value` or `php_flag`. 57 | 58 | Click on *Sign In* and setup your user account. 59 | 60 | That's it. 61 | -------------------------------------------------------------------------------- /docs/pagination.md: -------------------------------------------------------------------------------- 1 | # Pagination 2 | 3 | Flamework provides helper functions for creating simple or complex pagaing widgets. 4 | 5 | Assuming you've used one of the paginated database fetching functions, all you need to do to 6 | paginate results is to add the following into a template: 7 | 8 | {pagination} 9 | 10 | To make paging appear at the top and bottom of results, simply include the function call in 11 | both places. 12 | 13 | 14 | ## How this works 15 | 16 | The `_db_fetch_paginated()` function registers a smarty variable called `$pagination` with 17 | the following contents: 18 | 19 | array( 20 | 'total_count' => 100, # Total number of records 21 | 'page' => 1, # Page we're viewing 22 | 'per_page' => 20, # Number of records per page 23 | 'page_count' => 5, # Total number of pages 24 | ) 25 | 26 | Note that because of spill handling, there might be more or less records on the current page 27 | than `per_page` specifies. If you're handling paging yourself, rather than through the DB 28 | library, then you can pass your own pagintation information to the widget: 29 | 30 | {pagination pagination=$my_data} 31 | 32 | 33 | ## URL formatting 34 | 35 | By default, the pagination uses a URL pattern of `/page#`. This means that if your base page 36 | URL is `/foo/bar`, that URL is kept for page 1, while page 2 will be at `/foo/bar/page2`. If 37 | you supplied a pattern of `-p#` then page 2 would be `/foo/bar-p2`. If you would rather pass 38 | page numbers as query string parameters, then you can pass a parameter name to be used. Some 39 | examples: 40 | 41 | {pagination} 42 | /foo/bar/page10 43 | 44 | {pagination page_pattern='-p#'} 45 | /foo/bar-p10 46 | 47 | {pagination page_param='pg'} 48 | /foo/bar?pg=10 49 | 50 | The code is smart about preserving any existing query string arguments in all cases. 51 | 52 | 53 | ## Multiple views 54 | 55 | By default, the pagination widget will show page numbers and prev/next links. You can switch to 56 | just prev/next links by adding a `style` param: 57 | 58 | {pagination style='nextprev'} 59 | 60 | This just tell the widget to use the template `inc_pagination_nextprev.txt` instead of the default 61 | one (`pretty`). You can add your own paging styles by modifying those templates or adding new ones. 62 | 63 | 64 | ## Keyboard shortcuts 65 | 66 | If the config options `pagination_keyboard_shortcuts` or `pagination_touch_shortcuts` are set, then 67 | the left/right cursor keys and back and forward swipe gestures will cause the next/prev page to be 68 | navigated to. Be aware that this will only work for the first pagination widget used on any page. 69 | 70 | 71 | -------------------------------------------------------------------------------- /docs/philosophy.md: -------------------------------------------------------------------------------- 1 | # Flamework Design Philosophy - Statement(s) of Bias 2 | 3 | *"Working on the crumbly edge of future-proofing." -- [Heather Champ](https://www.instagram.com/haitchchamp/)* 4 | 5 | If you've never watched [Cal Henderson's](http://www.iamcal.com) "Why I Hate Django" presentation now is probably 6 | as good a time as any. It will help you understand a lot about why things were done they were at Flickr and why 7 | those of us who've left prefer to keep doing them that way: 8 | 9 | + [http://www.youtube.com/watch?v=i6Fr65PFqfk](http://www.youtube.com/watch?v=i6Fr65PFqfk "Why I Hate Django") 10 | 11 | Flamework is not really a framework, at least not by most people's standards. All software development is 12 | basically pain management and Flamework assumes that the most important thing is *the speed with which the code 13 | running an application can be re-arranged, in order to adapt to circumstances*, even if it's at the cost of 14 | "doing things twice" or "repeating ourselves". 15 | 16 | (Also, in fairness to the Django kids a lot has changed and gotten better since Cal's talk way back when.) 17 | 18 | **Flamework is basically two things:** 19 | 20 | 1. A set of common libraries and functions. 21 | 2. A series of social conventions for how code is arranged. 22 | 23 | **Flamework also takes the following for granted:** 24 | 25 | * It uses [Smarty](http://www.smarty.net "Smarty") for templating. 26 | * It uses global variables. Not many of them but it also doesn't make a fuss about the idea of using them. 27 | * It does not use objects or "protected" variables. 28 | * It breaks it own rules occasionally and uses objects but only rarely and generally when they are defined 29 | by third-party libraries (like [Smarty](http://www.smarty.net/)). 30 | * That ["normalized data is for sissies"](http://kottke.org/04/10/normalized-data). 31 | 32 | **For all intents and purposes, Flamework *is* a model-view-controller (MVC) system:** 33 | 34 | * There are shared libraries (the model) 35 | * There are PHP files (the controller) 36 | * There are templates (the view) 37 | 38 | Here is a simple bare-bones example of how it all fits together: 39 | 40 | # /include/lib_example.php 41 | 42 | 48 | 49 | # /example.php 50 | # 51 | # note how we're importing lib_example.php (above) 52 | # and squirting everything out to page_example.txt (below) 53 | 54 | assign_by_ref("foo", $foo); 61 | $GLOBALS['smarty']->display("page_example.txt"); 62 | exit(); 63 | ?> 64 | 65 | # /templates/page_example.txt 66 | 67 | {include file="inc_head.txt" page_title="example page title"} 68 | 69 |

{if $cfg.user.id}Hello, {$cfg.user.username|escape}!{else}Hello, stranger!{/if}

70 |

foo is: {','|@implode:$foo|escape}

71 | 72 | {include file="inc_foot.txt"} 73 | 74 | The only "rules" here are: 75 | 76 | 1. Making sure you load `include/init.php` 77 | 2. The part where `init.php` handles authentication checking and assigns logged in users to the 78 | global `$cfg` variable (it also creates and assigns a global `$smarty` object) 79 | 3. The naming conventions for shared libraries, specifically: `lib_SOMETHING.php` which is 80 | imported as `loadlib("SOMETHING")`. 81 | 4. Functions defined in libraries are essentially "namespaced". 82 | 83 | Page template names and all that other stuff is, ultimately, your business. 84 | -------------------------------------------------------------------------------- /docs/style_guide.md: -------------------------------------------------------------------------------- 1 | # Flamework Style guide 2 | 3 | The coding style is idiosyncratic and will stay that way. There are no 4 | spaces between closing parentheses and opening braces. We indent with 5 | tabs. All functions in a library must start with the library name, 6 | globals too. We don't (often) use constants. An underscore at the 7 | start of a function means it's library-private, same with 8 | globals. Function names are all lowercase, split with underscores. We 9 | don't use objects. 10 | 11 | We turn on E_ALL & E_STRICT, but ignore most E_NOTICEs because they're 12 | dumb. We do quote all hash keys, but we don't care about undefined 13 | keys or variables - isset() is vary rarely used. 14 | 15 | If you submit patches that don't conform to the weird standards, 16 | they'll get reformatted. It's not you, it's me. 17 | -------------------------------------------------------------------------------- /docs/troubleshooting.md: -------------------------------------------------------------------------------- 1 | Troubleshooting 2 | =============== 3 | 4 | * __Login cookies don't work__ 5 | 6 | You may need to set your abs_root_url setting manually. auth_cookie_domains will 7 | try and pull the domain part from the root URL of your app. Modify it directly to set cookies at a different 8 | subdomain. Cookie paths are not supported (but we should fix that). 9 | 10 | 11 | * __No email gets delivered__ 12 | 13 | Have you set auto_email_args in your config? Your mail server may block delivery of mail 14 | with envelopes from domains that it does not control. 15 | -------------------------------------------------------------------------------- /extras/README.md: -------------------------------------------------------------------------------- 1 | Extras 2 | -- 3 | 4 | ## lib_cache_memcache.php 5 | 6 | In order to use the `memcache` plugin you will need to make sure that you have 7 | installed the `php5-memcache` client. 8 | 9 | You will also need to add a `memcache_pool` config to your `config.php` 10 | file. Memcache can bucket cache requests across a number of hosts hence the list 11 | of lists. For example: 12 | 13 | $GLOBALS['cfg']['memcache_pool'] = array( 14 | array('host' => 'localhost', 'port' => 11211) 15 | ); 16 | 17 | You will need to explicitly load the `cache_memcache` library in your code or 18 | enabled it using the `autoload_lib` array in your config file. Like this: 19 | 20 | $GLOBALS['cfg']['autoload_libs'] = array( 21 | 'cache_memcache', 22 | ); 23 | -------------------------------------------------------------------------------- /extras/lib_base58.php: -------------------------------------------------------------------------------- 1 | = $base_count) { 13 | $div = $num / $base_count; 14 | $mod = ($num - ($base_count * intval($div))); 15 | $encoded = $alphabet[$mod] . $encoded; 16 | $num = intval($div); 17 | } 18 | 19 | if ($num) { 20 | $encoded = $alphabet[$num] . $encoded; 21 | } 22 | 23 | return $encoded; 24 | } 25 | 26 | ################################################################# 27 | 28 | function base58_decode($num) { 29 | $alphabet = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'; 30 | $len = strlen($num); 31 | $decoded = 0; 32 | $multi = 1; 33 | 34 | for ($i = $len - 1; $i >= 0; $i--) { 35 | $decoded += $multi * strpos($alphabet, $num[$i]); 36 | $multi = $multi * strlen($alphabet); 37 | } 38 | 39 | return $decoded; 40 | } 41 | 42 | ################################################################# 43 | -------------------------------------------------------------------------------- /schema/.htaccess: -------------------------------------------------------------------------------- 1 | Order Allow,Deny 2 | Allow from none 3 | Deny from all 4 | -------------------------------------------------------------------------------- /schema/db_main.schema: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `users`; 2 | 3 | CREATE TABLE `users` ( 4 | `id` int(11) unsigned NOT NULL AUTO_INCREMENT, 5 | `username` varchar(255) DEFAULT NULL, 6 | `email` varchar(255) DEFAULT NULL, 7 | `deleted` int(10) unsigned NOT NULL, 8 | `created` int(10) unsigned NOT NULL, 9 | `password` char(64) DEFAULT NULL, 10 | `conf_code` char(24) DEFAULT NULL, 11 | `confirmed` int(10) unsigned NOT NULL, 12 | `cluster_id` tinyint(3) unsigned NOT NULL, 13 | PRIMARY KEY (`id`), 14 | UNIQUE KEY `by_email` (`email`), 15 | UNIQUE KEY `by_username` (`username`,`deleted`) 16 | ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; 17 | 18 | DROP TABLE IF EXISTS `users_password_reset`; 19 | 20 | CREATE TABLE `users_password_reset` ( 21 | `user_id` int(10) unsigned NOT NULL, 22 | `reset_code` char(32) DEFAULT NULL, 23 | `created` int(10) unsigned NOT NULL, 24 | UNIQUE KEY `by_code` (`reset_code`), 25 | KEY `by_user` (`user_id`), 26 | KEY `by_timestamp` (`created`) 27 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 28 | -------------------------------------------------------------------------------- /schema/db_tickets.schema: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `Tickets32`; 2 | 3 | CREATE TABLE `Tickets32` ( 4 | `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT, 5 | `stub` char(1) NOT NULL DEFAULT '', 6 | PRIMARY KEY (`id`), 7 | UNIQUE KEY `stub` (`stub`) 8 | ) ENGINE=MyISAM; 9 | 10 | DROP TABLE IF EXISTS `Tickets64`; 11 | 12 | CREATE TABLE `Tickets64` ( 13 | `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT, 14 | `stub` char(1) NOT NULL DEFAULT '', 15 | PRIMARY KEY (`id`), 16 | UNIQUE KEY `stub` (`stub`) 17 | ) ENGINE=MyISAM; 18 | 19 | -------------------------------------------------------------------------------- /tests/01_files.t: -------------------------------------------------------------------------------- 1 | '); 20 | cmp_ok($idx, '===', false, "No closing tag in $file"); 21 | 22 | $idx = strpos($content, '$'.'Id$'); 23 | cmp_ok($idx, '===', false, "No SVN keywordsin $file"); 24 | } 25 | -------------------------------------------------------------------------------- /tests/01_notices.t: -------------------------------------------------------------------------------- 1 | 2, 'c' => 3)); 41 | test_http_method($ret, 'POST', 1, 2); 42 | -------------------------------------------------------------------------------- /tests/05_cache.t: -------------------------------------------------------------------------------- 1 | 4); 12 | 13 | $ret = cache_set('test1', $a); 14 | 15 | is($ret['ok'], 1, "Local cache set"); 16 | is($ret['local'], 1, "Set worked locally"); 17 | isnt($ret['remote'], 1, "Set failed remote"); 18 | 19 | 20 | # 21 | # get 22 | # 23 | 24 | $ret = cache_get('test1'); 25 | 26 | is($ret['ok'], 1, "Local cache get"); 27 | is($ret['source'], 'local', "Cache get came from local cache"); 28 | is_deeply($ret['data'], $a, "Data matches original"); 29 | 30 | 31 | # 32 | # unset 33 | # 34 | 35 | $ret = cache_unset('test1'); 36 | is($ret['ok'], 1, "Local cache unset"); 37 | is($ret['local'], 1, "Unset worked locally"); 38 | isnt($ret['remote'], 1, "Unset failed remote"); 39 | 40 | -------------------------------------------------------------------------------- /tests/06_cache_memcache.t: -------------------------------------------------------------------------------- 1 | 'localhost', 'port' => 99999) 33 | ); 34 | 35 | $a = array('a' => 4); 36 | 37 | $ret = cache_set('test1', $a); 38 | is($ret['ok'], 0, "Memcache set with bad server"); 39 | is($ret['local'], 1, "Set worked locally"); 40 | is($ret['remote'], 0, "Set failed remotely"); 41 | is($ret['error'], 'memcache_cant_connect', "Expected error message"); 42 | 43 | $ret = cache_get('test2'); 44 | is($ret['ok'], 0, "Memcache get with bad server"); 45 | is($ret['error'], 'memcache_cant_connect', "Expected error message"); 46 | 47 | $ret = cache_unset('test3'); 48 | is($ret['ok'], 0, "Memcache unset with bad server"); 49 | is($ret['local'], 1, "Unset worked locally"); 50 | is($ret['remote'], 0, "Unset failed remotely"); 51 | is($ret['error'], 'memcache_cant_connect', "Expected error message"); 52 | 53 | 54 | # 55 | # connection success! 56 | # 57 | 58 | $GLOBALS['cfg']['memcache_pool'] = array( 59 | array('host' => 'localhost', 'port' => 11211) 60 | ); 61 | 62 | $conn = cache_memcache_connect(); 63 | 64 | if (!$conn){ 65 | skip("Skipping memcache tests - can't connect to local server", 9); 66 | exit; 67 | } 68 | 69 | 70 | # 71 | # set 72 | # 73 | 74 | $a = array( 75 | 'a' => time(), 76 | 'b' => md5(rand()), 77 | ); 78 | $key = 'test'.time(); 79 | 80 | $ret = cache_set($key, $a); 81 | 82 | is($ret['ok'], 1, "Remote cache set"); 83 | is($ret['local'], 1, "Set worked locally"); 84 | is($ret['remote'], 1, "Set worked remotely"); 85 | 86 | 87 | # 88 | # get 89 | # 90 | 91 | $GLOBALS['_cache_local'] = array(); 92 | 93 | $ret = cache_get($key); 94 | 95 | is($ret['ok'], 1, "Remote cache get"); 96 | is($ret['source'], 'memcache', "Cache get came from remote cache"); 97 | is_deeply($ret['data'], $a, "Data matches original"); 98 | 99 | 100 | # 101 | # unset 102 | # 103 | 104 | $ret = cache_unset($key); 105 | is($ret['ok'], 1, "Remote cache unset"); 106 | is($ret['local'], 1, "Unset worked locally"); 107 | is($ret['remote'], 1, "Unset worked remotely"); 108 | 109 | -------------------------------------------------------------------------------- /tests/07_random.t: -------------------------------------------------------------------------------- 1 |
\n"; 50 | 51 | echo "bare-word keys: ".number_format($t2-$t1)." ms
\n"; 52 | echo "quoted keys: ".number_format($t3-$t2)." ms
\n"; 53 | 54 | 55 | function try_nq(){ 56 | $a = array(); 57 | $a[b] = array(); 58 | $a[b][c] = array(); 59 | $a[b][c][d] = array(); 60 | $a[b][c][d][e] = array(); 61 | $a[b][c][d][e][f] = array(); 62 | $a[b][c][d][e][f][g] = array(); 63 | $a[b][c][d][e][f][g][h] = 1; 64 | return $a; 65 | } 66 | 67 | function try_qq(){ 68 | $a = array(); 69 | $a['b'] = array(); 70 | $a['b']['c'] = array(); 71 | $a['b']['c']['d'] = array(); 72 | $a['b']['c']['d']['e'] = array(); 73 | $a['b']['c']['d']['e']['f'] = array(); 74 | $a['b']['c']['d']['e']['f']['g'] = array(); 75 | $a['b']['c']['d']['e']['f']['g']['h'] = 1; 76 | return $a; 77 | } 78 | 79 | ?> 80 | -------------------------------------------------------------------------------- /tests/coverage.php: -------------------------------------------------------------------------------- 1 | filter = new PHP_CodeCoverage_Filter; 12 | } 13 | public function applyFilter(){ 14 | $this->applyListsFilter($this->data); 15 | } 16 | } 17 | 18 | $serial = file_get_contents($file); 19 | 20 | $old = 'O:16:"PHP_CodeCoverage"'; 21 | $new = 'O:10:"MyCoverage"'; 22 | $serial = str_replace($old, $new, $serial); 23 | 24 | $coverage = unserialize($serial); 25 | 26 | $root_path = dirname(__FILE__).'/..'; 27 | 28 | $coverage->resetFilter(); 29 | $coverage->filter()->addFilesToWhitelist(glob("$root_path/www/include/*.php")); 30 | $coverage->filter()->addFilesToWhitelist(glob("$root_path/extras/*.php")); 31 | $coverage->applyFilter(); 32 | 33 | $writer = new PHP_CodeCoverage_Report_HTML; 34 | $writer->process($coverage, './coverage'); 35 | -------------------------------------------------------------------------------- /tests/docker/001-flamework.conf: -------------------------------------------------------------------------------- 1 | 2 | DocumentRoot /var/www/html 3 | 4 | 5 | Options +Indexes +FollowSymLinks -MultiViews 6 | AllowOverride All 7 | Order allow,deny 8 | allow from all 9 | require all granted 10 | 11 | 12 | ErrorLog ${APACHE_LOG_DIR}/error.log 13 | 14 | # Possible values include: debug, info, notice, warn, error, crit, 15 | # alert, emerg. 16 | LogLevel warn 17 | 18 | CustomLog ${APACHE_LOG_DIR}/access.log combined 19 | 20 | RewriteEngine on 21 | #RewriteLog ${APACHE_LOG_DIR}/rewrite.log 22 | #RewriteLogLevel 3 23 | 24 | DirectoryIndex index.php 25 | 26 | 27 | 28 | DocumentRoot /var/www/html 29 | 30 | 31 | Options +Indexes -MultiViews 32 | AllowOverride All 33 | Order allow,deny 34 | allow from all 35 | require all granted 36 | 37 | 38 | ErrorLog ${APACHE_LOG_DIR}/error.log 39 | LogLevel warn 40 | CustomLog ${APACHE_LOG_DIR}/access.log combined 41 | 42 | RewriteEngine on 43 | 44 | DirectoryIndex index.php 45 | 46 | SSLEngine on 47 | SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem 48 | SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key 49 | -------------------------------------------------------------------------------- /tests/docker/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # We want to halt on errors and also print out what we're doing 4 | set -eux 5 | 6 | # Start memcached 7 | /etc/init.d/memcached start 8 | 9 | # Start mysql and create the database if it doesn't exist 10 | /etc/init.d/mysql start 11 | mysql -e 'CREATE DATABASE IF NOT EXISTS flamework;' 12 | mysql -Dflamework < schema/db_main.schema 13 | 14 | # Put the example configuration in place if it doesn't exist 15 | cd /mnt/flamework 16 | if [[ ! -e www/include/config.php ]]; then 17 | cp www/include/config.php.example www/include/config.php 18 | perl -i -pe "s/'pass'\t=> 'root',/'pass'\t=> '',/g" www/include/config.php 19 | fi 20 | 21 | # Templates need to be writable by the web server 22 | chown www-data www/templates_c 23 | chmod 755 www/templates_c 24 | 25 | # Start apache in the foreground so that the container stays running 26 | exec apachectl -D FOREGROUND -------------------------------------------------------------------------------- /tests/helpers/users.php: -------------------------------------------------------------------------------- 1 | $username, 16 | 'email' => "{$username}@example.com", 17 | 'password' => random_string(32), 18 | ); 19 | 20 | $ret = users_create_user($data); 21 | if (!$ret['ok']) return array(); 22 | 23 | return array( 24 | 'ok' => 1, 25 | 'data' => $data, 26 | 'user' => $ret['user'], 27 | ); 28 | } 29 | 30 | ################################################################# -------------------------------------------------------------------------------- /tests/php.ini: -------------------------------------------------------------------------------- 1 | magic_quotes_gpc = 0 2 | register_globals = 0 3 | magic_quotes_runtime = 0 4 | track_errors = 1 5 | last_modified = off 6 | short_open_tag = on 7 | display_errors = off 8 | error_reporting = 2147483639 9 | -------------------------------------------------------------------------------- /tests/travis/config.php: -------------------------------------------------------------------------------- 1 | 2 | $GLOBALS['cfg']['db_main'] = array( 3 | 'host' => 'localhost', 4 | 'user' => 'root', 5 | 'pass' => '', 6 | 'name' => 'flamework', 7 | 'auto_connect' => 1, 8 | ); 9 | -------------------------------------------------------------------------------- /tests/travis/config_52.php: -------------------------------------------------------------------------------- 1 | 2 | $GLOBALS['cfg']['passwords_use_bcrypt'] = false; 3 | $GLOBALS['cfg']['crypto_password_secret'] = '26d402fb6c95ce4ee3c78a439d516df905cf623ea403cfebe08d44c2cfb5038a'; 4 | -------------------------------------------------------------------------------- /tests/travis/setup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | env 4 | 5 | chmod 755 www/templates_c 6 | cp www/include/config.php.example www/include/config.php 7 | 8 | cat tests/travis/config.php >> www/include/config.php 9 | if [ "$TRAVIS_PHP_VERSION" == "5.2" ]; then 10 | cat tests/travis/config_52.php >> www/include/config.php 11 | fi 12 | 13 | mysql -e 'CREATE DATABASE flamework;' 14 | mysql -Dflamework < schema/db_main.schema 15 | #printf "\n" | pecl install memcache 16 | -------------------------------------------------------------------------------- /tests/vagrant/init.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | export DEBIAN_FRONTEND=noninteractive 4 | 5 | apt-get update 6 | apt-get install -y php5-cli git php5-mcrypt php5-curl 7 | apt-get install -y apache2 libapache2-mod-php5 8 | apt-get install -y mysql-server php5-mysql 9 | apt-get install -y memcached php5-memcache 10 | 11 | rm -rf /var/www 12 | ln -fs /vagrant/www /var/www 13 | 14 | cd /vagrant 15 | chmod 755 www/templates_c 16 | cp www/include/config.php.example www/include/config.php 17 | cat tests/travis/config.php >> www/include/config.php 18 | mysql -e 'CREATE DATABASE flamework;' 19 | mysql -Dflamework < schema/db_main.schema 20 | 21 | apt-get install -y php-pear 22 | pear channel-discover pear.phpunit.de 23 | pear install phpunit/PHP_CodeCoverage 24 | 25 | apt-get install -y make 26 | pecl install xdebug 27 | echo "zend_extension=/usr/lib/php5/20090626+lfs/xdebug.so" > /etc/php5/conf.d/xdebug.ini 28 | 29 | /etc/init.d/apache2 start 30 | -------------------------------------------------------------------------------- /tests/wrapper.php: -------------------------------------------------------------------------------- 1 | start($name); 21 | 22 | register_shutdown_function('end_coverage'); 23 | } 24 | } 25 | 26 | function end_coverage(){ 27 | $GLOBALS['coverage']->stop(); 28 | 29 | $dir = dirname(__FILE__); 30 | $fh = fopen("$dir/coverage.state", 'w'); 31 | fwrite($fh, serialize($GLOBALS['coverage'])); 32 | fclose($fh); 33 | } 34 | 35 | $dir = dirname(__FILE__); 36 | include($dir.'/testmore.php'); 37 | include($dir.'/../www/include/init.php'); 38 | 39 | include($dir.'/helpers/users.php'); 40 | 41 | $GLOBALS['log_handlers']['error'] = array('test_wrapper'); 42 | $GLOBALS['log_handlers']['fatal'] = array('test_wrapper'); 43 | $GLOBALS['this_is_test'] = 1; 44 | 45 | function _log_handler_test_wrapper($level, $msg, $more = array()){ 46 | 47 | $type = $more['type'] ? $more['type'] : $level; 48 | 49 | $out = ''; 50 | 51 | if ($type) $out .= "[$type] "; 52 | 53 | $out .= $msg; 54 | 55 | if ($more['time'] > -1) $out .= " ($more[time] ms)"; 56 | 57 | diag($out); 58 | } 59 | -------------------------------------------------------------------------------- /www/.htaccess: -------------------------------------------------------------------------------- 1 | # 2 | # Hey! Everything in here is better suited to httpd.conf, since 3 | # we get a performance boost if we can turn off AllowOverride and 4 | # not have to stat the webroot for every request. On the other 5 | # hand, this means we never have to touch apache once it's up. 6 | # Flexibility over performance. 7 | # 8 | # In an ideal world, you'd stick it in here on dev and your build 9 | # system would bundle the changes into (a file included in) httpd.conf 10 | # for your production deployment, perhaps wrapped in a 11 | # block. 12 | # 13 | 14 | # ETags are a bad idea if you have multiple web servers. We'll do 15 | # more explicit caching with Expires headers anyway. 16 | FileETag none 17 | 18 | # The base set of sensible PHP options. You could put these in your 19 | # php.ini file too, but having them in your Apache config puts 20 | # everything in one place. Magic quotes off because they are stupid. 21 | # Register globals off for the same reason. Track errors is so that 22 | # we can at least get at the error messages we hide using @func(). 23 | # last_modified is a bad idea if we have any dynamic content. Short 24 | # tags make for a few saved bytes of cruft and are fine unless you're 25 | # running another XML preprocessor over your code (wtf?). 26 | php_value magic_quotes_gpc 0 27 | php_value register_globals 0 28 | php_value magic_quotes_runtime 0 29 | php_value track_errors 1 30 | php_value last_modified off 31 | php_value short_open_tag on 32 | 33 | # This value is very useful for development, but should be disabled 34 | # on production deployments (by setting the value to 'off') 35 | php_flag display_errors on 36 | 37 | # this sets all current and future error flags on, except for E_NOTICE 38 | # which can go fuck itself. we have some separate code for checking the 39 | # one notice we do care about. 40 | php_value error_reporting 2147483639 41 | 42 | # Some basic pointers to php files 43 | DirectoryIndex index.php 44 | ErrorDocument 404 /404.php 45 | ErrorDocument 403 /403.php 46 | 47 | # Get mod_rewrite fired up 48 | RewriteEngine on 49 | 50 | # Login stuff 51 | 52 | RewriteRule ^signup$ signup.php [L] 53 | RewriteRule ^signin$ signin.php [L] 54 | RewriteRule ^signout$ signout.php [L] 55 | RewriteRule ^checkcookie$ checkcookie.php [L] 56 | 57 | # Password retrieval stuff 58 | 59 | RewriteRule ^forgot$ forgot.php [L] 60 | RewriteRule ^reset/([a-zA-Z0-9]+)$ reset.php?reset=$1 [L,QSA] 61 | 62 | # Account stuff 63 | 64 | RewriteRule ^account$ account.php [L] 65 | RewriteRule ^account/password$ account_password.php [L] 66 | RewriteRule ^account/delete$ account_delete.php [L] 67 | 68 | # General pages 69 | 70 | RewriteRule ^about$ about.php [L,QSA] 71 | RewriteRule ^contact$ contact.php [L,QSA] 72 | 73 | 74 | # Test pages 75 | 76 | RewriteRule ^paging$ paging.php [L] 77 | RewriteRule ^paging/page(\d+)$ paging.php?page=$1 [L,QSA] 78 | -------------------------------------------------------------------------------- /www/403.php: -------------------------------------------------------------------------------- 1 | display('page_about.txt'); 10 | -------------------------------------------------------------------------------- /www/account.php: -------------------------------------------------------------------------------- 1 | display("page_account.txt"); 12 | -------------------------------------------------------------------------------- /www/account_delete.php: -------------------------------------------------------------------------------- 1 | assign('crumb_key', $crumb_key); 13 | 14 | 15 | # 16 | # delete account? 17 | # 18 | 19 | if (post_str('delete') && crumb_check($crumb_key)){ 20 | 21 | if (post_str('confirm')){ 22 | 23 | $ok = users_delete_user($GLOBALS['cfg']['user']); 24 | 25 | if ($ok){ 26 | login_do_logout(); 27 | 28 | $smarty->display('page_account_delete_done.txt'); 29 | exit; 30 | } 31 | 32 | $smarty->assign('error_deleting', 1); 33 | 34 | $smarty->display('page_account_delete.txt'); 35 | exit; 36 | } 37 | 38 | $smarty->display('page_account_delete_confirm.txt'); 39 | exit; 40 | } 41 | 42 | 43 | # 44 | # output 45 | # 46 | 47 | $smarty->display("page_account_delete.txt"); 48 | -------------------------------------------------------------------------------- /www/account_password.php: -------------------------------------------------------------------------------- 1 | assign("crumb_key", $crumb_key); 13 | 14 | 15 | 16 | # 17 | # update? 18 | # 19 | 20 | if (post_str('change') && crumb_check($crumb_key)){ 21 | 22 | $old_pass = trim(post_str('old_password')); 23 | $new_pass1 = trim(post_str('new_password1')); 24 | $new_pass2 = trim(post_str('new_password2')); 25 | 26 | $ok = 1; 27 | 28 | if (! passwords_validate_password_for_user($old_pass, $GLOBALS['cfg']['user'])){ 29 | $smarty->assign('error_oldpass_mismatch', 1); 30 | $ok = 0; 31 | } 32 | 33 | if ($ok && $new_pass1 !== $new_pass2){ 34 | 35 | $smarty->assign('error_newpass_mismatch', 1); 36 | $ok = 0; 37 | } 38 | 39 | if ($ok && !strlen($new_pass2)){ 40 | 41 | $smarty->assign('error_newpass_empty', 1); 42 | $ok = 0; 43 | } 44 | 45 | if ($ok){ 46 | if (! users_update_password($GLOBALS['cfg']['user'], $new_pass1)){ 47 | 48 | $smarty->assign('error_fail', 1); 49 | $ok = 0; 50 | } 51 | } 52 | 53 | if ($ok){ 54 | 55 | # 56 | # Refresh the user so that we pick up the newer password when 57 | # we set new cookies. Should this be a function in lib_users? 58 | # (20101012/asc) 59 | # 60 | 61 | $GLOBALS['cfg']['user'] = users_get_by_id($GLOBALS['cfg']['user']['id']); 62 | 63 | login_do_login($GLOBALS['cfg']['user'], "/account/?password=1"); 64 | exit; 65 | } 66 | } 67 | 68 | 69 | # 70 | # output 71 | # 72 | 73 | $smarty->display("page_account_password.txt"); 74 | -------------------------------------------------------------------------------- /www/checkcookie.php: -------------------------------------------------------------------------------- 1 | display("page_error_cookie.txt"); 12 | exit; 13 | } 14 | 15 | 16 | # 17 | # where shall we bounce to? 18 | # 19 | 20 | $redir = $GLOBALS['cfg']['abs_root_url']; 21 | 22 | if ($_redir = get_str("redir")){ 23 | if (substr($_redir, 0, 1) == '/') $_redir = substr($_redir, 1); 24 | $redir .= $_redir; 25 | } 26 | 27 | 28 | # 29 | # go! 30 | # 31 | 32 | header("location: {$redir}"); 33 | exit; 34 | -------------------------------------------------------------------------------- /www/contact.php: -------------------------------------------------------------------------------- 1 | assign('name', $name); 18 | $smarty->assign('email', $email); 19 | $smarty->assign('message', $message); 20 | 21 | 22 | # 23 | # all fields are in order? 24 | # 25 | 26 | if ((!strlen($name)) || (!strlen($email)) || (!strlen($message))){ 27 | 28 | $smarty->assign('error_missing', 1); 29 | $ok = 0; 30 | } 31 | 32 | 33 | # 34 | # send it 35 | # 36 | 37 | if ($ok){ 38 | 39 | loadlib('email'); 40 | 41 | email_send(array( 42 | 'from_name' => $name, 43 | 'from_email' => $email, 44 | 'to_email' => $GLOBALS['cfg']['email_from_email'], 45 | 'template' => 'email_contact.txt', 46 | )); 47 | 48 | header('location: /contact/?sent=1'); 49 | exit; 50 | } 51 | } 52 | 53 | # 54 | # output 55 | # 56 | 57 | $smarty->display('page_contact.txt'); 58 | -------------------------------------------------------------------------------- /www/cron/.htaccess: -------------------------------------------------------------------------------- 1 | Order Allow,Deny 2 | Allow from none 3 | Deny from all 4 | -------------------------------------------------------------------------------- /www/cron/generate_apache_config_bits.php: -------------------------------------------------------------------------------- 1 | \n" . trim(file_get_contents(dirname(dirname(__FILE__)) . "/" . $file)) . "\n\n"; 17 | } 18 | file_put_contents(dirname(__FILE__) . "/flamework.directives.conf", $conf); -------------------------------------------------------------------------------- /www/css/.htaccess: -------------------------------------------------------------------------------- 1 | Options -Indexes -------------------------------------------------------------------------------- /www/css/admin.source.css: -------------------------------------------------------------------------------- 1 | /* rules for developer-only styles */ 2 | 3 | .admin-timings-wrapper { 4 | width:300px; 5 | margin:0 auto; 6 | padding:10px; 7 | 8 | border-top-left-radius:10px; 9 | -moz-border-radius-topleft:10px; 10 | -webkit-border-top-left-radius:10px; 11 | 12 | border-top-right-radius:10px; 13 | -moz-border-radius-topright:10px; 14 | -webkit-border-top-right-radius:10px; 15 | 16 | border-bottom-left-radius:10px; 17 | -moz-border-radius-bottomleft:10px; 18 | -webkit-border-bottom-left-radius:10px; 19 | 20 | border-bottom-right-radius:10px; 21 | -moz-border-radius-bottomright:10px; 22 | -webkit-border-bottom-right-radius:10px; 23 | 24 | background-image: url("/images/stripes_bg.gif"); 25 | } 26 | 27 | table.admin-timings { 28 | margin:0; 29 | background-color:white; 30 | text-align:left; 31 | width:100%; 32 | } 33 | 34 | table.admin-timings td, 35 | table.admin-timings th { 36 | padding:6px 20px; 37 | text-align:left; 38 | font: normal 13px/1em Arial,sans-serif; 39 | color: #383F41; 40 | } 41 | 42 | table.admin-timings td.tar { 43 | text-align: right; 44 | } 45 | 46 | table.admin-timings tr:nth-child(2n+1) td { 47 | background:#e9f0f0 48 | } 49 | 50 | .admin-section { 51 | background-image: url("/images/stripes_bg.gif"); 52 | border-top: 1px solid #BECCCC; 53 | border-bottom: 1px solid #BECCCC; 54 | padding: 40px; 55 | position: relative; 56 | text-align: left; 57 | } 58 | 59 | pre.admin-debug { 60 | background: none repeat scroll 0 0 #000000; 61 | color: #00FF00; 62 | font-size: 14px; 63 | margin: 0; 64 | padding: 1em; 65 | } 66 | -------------------------------------------------------------------------------- /www/css/main.source.css: -------------------------------------------------------------------------------- 1 | body { padding-bottom: 40px; } 2 | .navbar-static-top { margin-bottom: 20px; } 3 | -------------------------------------------------------------------------------- /www/forgot.php: -------------------------------------------------------------------------------- 1 | assign('error_nouser', 1); 25 | $ok = 0; 26 | } 27 | 28 | if ($ok && $user['deleted']){ 29 | 30 | $smarty->assign('error_deleted', 1); 31 | $ok = 0; 32 | } 33 | 34 | if ($ok && !users_send_password_reset_code($user)){ 35 | 36 | $smarty->assign('error_notsent', 1); 37 | $ok = 0; 38 | } 39 | 40 | if ($ok){ 41 | $smarty->assign('sent_to', $user['email']); 42 | 43 | $smarty->display('page_forgot_sent.txt'); 44 | exit; 45 | } 46 | } 47 | 48 | 49 | # 50 | # output 51 | # 52 | 53 | $smarty->display('page_forgot.txt'); 54 | -------------------------------------------------------------------------------- /www/images/.htaccess: -------------------------------------------------------------------------------- 1 | Options -Indexes -------------------------------------------------------------------------------- /www/images/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exflickr/flamework/49e4322d3914e497355bbf4002b75bfe40f6f22b/www/images/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /www/images/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exflickr/flamework/49e4322d3914e497355bbf4002b75bfe40f6f22b/www/images/glyphicons-halflings.png -------------------------------------------------------------------------------- /www/images/stripes_bg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/exflickr/flamework/49e4322d3914e497355bbf4002b75bfe40f6f22b/www/images/stripes_bg.gif -------------------------------------------------------------------------------- /www/include/.htaccess: -------------------------------------------------------------------------------- 1 | Order Allow,Deny 2 | Allow from none 3 | Deny from all 4 | -------------------------------------------------------------------------------- /www/include/lib_auth.php: -------------------------------------------------------------------------------- 1 | random_state = microtime(); 19 | if (function_exists('getmypid')) 20 | $this->random_state .= getmypid(); 21 | } 22 | 23 | function get_random_bytes($count) 24 | { 25 | $output = ''; 26 | if (is_readable('/dev/urandom') && 27 | ($fh = @fopen('/dev/urandom', 'rb'))) { 28 | $output = fread($fh, $count); 29 | fclose($fh); 30 | } 31 | 32 | if (strlen($output) < $count) { 33 | $output = ''; 34 | for ($i = 0; $i < $count; $i += 16) { 35 | $this->random_state = 36 | md5(microtime() . $this->random_state); 37 | $output .= 38 | pack('H*', md5($this->random_state)); 39 | } 40 | $output = substr($output, 0, $count); 41 | } 42 | 43 | return $output; 44 | } 45 | 46 | function gensalt_blowfish($input, $work_factor) 47 | { 48 | # This one needs to use a different order of characters and a 49 | # different encoding scheme from the one in encode64() in phpass. 50 | # We care because the last character in our encoded string will 51 | # only represent 2 bits. While two known implementations of 52 | # bcrypt will happily accept and correct a salt string which 53 | # has the 4 unused bits set to non-zero, we do not want to take 54 | # chances and we also do not want to waste an additional byte 55 | # of entropy. 56 | $itoa64 = './ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; 57 | 58 | $output = '$2a$'; 59 | $output .= chr(ord('0') + $work_factor / 10); 60 | $output .= chr(ord('0') + $work_factor % 10); 61 | $output .= '$'; 62 | 63 | $i = 0; 64 | do { 65 | $c1 = ord($input[$i++]); 66 | $output .= $itoa64[$c1 >> 2]; 67 | $c1 = ($c1 & 0x03) << 4; 68 | if ($i >= 16) { 69 | $output .= $itoa64[$c1]; 70 | break; 71 | } 72 | 73 | $c2 = ord($input[$i++]); 74 | $c1 |= $c2 >> 4; 75 | $output .= $itoa64[$c1]; 76 | $c1 = ($c2 & 0x0f) << 2; 77 | 78 | $c2 = ord($input[$i++]); 79 | $c1 |= $c2 >> 6; 80 | $output .= $itoa64[$c1]; 81 | $output .= $itoa64[$c2 & 0x3f]; 82 | } while (1); 83 | 84 | return $output; 85 | } 86 | 87 | function HashPassword($password, $work_factor=8) 88 | { 89 | if ($work_factor < 4 || $work_factor > 31) $work_factor = 8; 90 | 91 | $random = $this->get_random_bytes(16); 92 | $salt = $this->gensalt_blowfish($random, $work_factor); 93 | $hash = crypt($password, $salt); 94 | if (strlen($hash) == 60) return $hash; 95 | return '*'; 96 | } 97 | 98 | function CheckPassword($password, $stored_hash) 99 | { 100 | $hash = crypt($password, $stored_hash); 101 | return $hash == $stored_hash; 102 | } 103 | } 104 | 105 | -------------------------------------------------------------------------------- /www/include/lib_cache.php: -------------------------------------------------------------------------------- 1 | null, 14 | 'set' => null, 15 | 'unset' => null, 16 | ); 17 | 18 | ################################################################# 19 | 20 | function cache_get($key, $more=array()){ 21 | 22 | $key = _cache_prepare_key($key); 23 | 24 | # 25 | # try and fetch from local cache first 26 | # 27 | 28 | if (isset($GLOBALS['_cache_local'][$key])){ 29 | 30 | log_notice("cache", "get {$key} - local hit"); 31 | 32 | return array( 33 | 'ok' => 1, 34 | 'source' => 'local', 35 | 'data' => $GLOBALS['_cache_local'][$key], 36 | ); 37 | } 38 | 39 | 40 | # 41 | # try the remote cache? 42 | # 43 | 44 | if ($GLOBALS['_cache_hooks']['get']){ 45 | $rsp = call_user_func($GLOBALS['_cache_hooks']['get'], $key); 46 | return $rsp; 47 | } 48 | 49 | log_notice("cache", "get {$key} - local miss"); 50 | 51 | return array( 52 | 'error' => 'cache hook not defined', 53 | 'ok' => 0, 54 | ); 55 | } 56 | 57 | ################################################################# 58 | 59 | function cache_set($key, $data, $more=array()){ 60 | 61 | $key = _cache_prepare_key($key, $more); 62 | 63 | $GLOBALS['_cache_local'][$key] = $data; 64 | 65 | if ($GLOBALS['_cache_hooks']['set']){ 66 | 67 | return call_user_func($GLOBALS['_cache_hooks']['set'], $key, $data); 68 | } 69 | 70 | log_notice("cache", "set {$key}"); 71 | 72 | return array( 73 | 'ok' => 1, 74 | 'local' => 1, 75 | ); 76 | } 77 | 78 | ################################################################# 79 | 80 | function cache_unset($key, $more=array()){ 81 | 82 | $key = _cache_prepare_key($key, $more); 83 | 84 | unset($GLOBALS['_cache_local'][$key]); 85 | 86 | if ($GLOBALS['_cache_hooks']['unset']){ 87 | 88 | return call_user_func($GLOBALS['_cache_hooks']['unset'], $key); 89 | } 90 | 91 | log_notice("cache", "unset {$key}"); 92 | 93 | return array( 94 | 'ok' => 1, 95 | 'local' => 1, 96 | ); 97 | } 98 | 99 | ################################################################# 100 | 101 | function _cache_prepare_key($key, $more=array()){ 102 | 103 | if (features_is_enabled("cache_prefixes")){ 104 | 105 | if ($prefix = $GLOBALS['cfg']['cache_prefix']){ 106 | $key = "{$prefix}_{$key}"; 107 | } 108 | } 109 | 110 | return $key; 111 | } 112 | 113 | ################################################################# 114 | -------------------------------------------------------------------------------- /www/include/lib_crumb.php: -------------------------------------------------------------------------------- 1 | '; 30 | } 31 | 32 | ################################################################# 33 | 34 | function crumb_qs($key, $target=''){ 35 | 36 | $q = array( 37 | 'crumb' => crumb_generate($key, $target) 38 | ); 39 | 40 | return http_build_query($q); 41 | } 42 | 43 | ################################################################# 44 | 45 | function crumb_validate($crumb, $key, $ttl=0, $target=''){ 46 | 47 | list($time, $hash) = explode('-', $crumb); 48 | 49 | if ($ttl){ 50 | $then = $time + $ttl; 51 | $now = time(); 52 | 53 | if ($now > $then){ 54 | return 0; 55 | } 56 | } 57 | 58 | $base = crumb_get_base($key, $target); 59 | $hash_test = crumb_hash($base . $time, 10); 60 | 61 | $hash = str_split($hash); 62 | $hash_test = str_split($hash_test); 63 | 64 | $len_hash = count($hash); 65 | $len_test = count($hash_test); 66 | 67 | if ($len_hash != $len_test){ 68 | return 0; 69 | } 70 | 71 | for ($i=0; $i < $len_hash; $i++){ 72 | 73 | if ($hash[$i] != $hash_test[$i]){ 74 | return 0; 75 | } 76 | } 77 | 78 | return 1; 79 | } 80 | 81 | ################################################################# 82 | 83 | # returns a string which we'll use as a base to combine with 84 | # a timestamp to create the crumb. it should be a hex string. 85 | 86 | function crumb_get_base($key, $target=''){ 87 | 88 | if (! $target){ 89 | $target = $GLOBALS['_SERVER']['SCRIPT_NAME']; 90 | } 91 | 92 | # basic browser stuff 93 | 94 | $data = array( 95 | $key, 96 | $GLOBALS['_SERVER']['HTTP_USER_AGENT'], 97 | $target, 98 | $GLOBALS['_SERVER']['REMOTE_ADDR'], # check if mobile? 99 | ); 100 | 101 | # if they're signed in, use their account 102 | 103 | if ($GLOBALS['cfg']['user']['id']){ 104 | 105 | $data[] = $GLOBALS['cfg']['user']['id']; 106 | $data[] = md5($GLOBALS['cfg']['user']['conf_code']); 107 | } 108 | 109 | # this is a nice idea but likely to cause more pain than it's 110 | # worth the moment you have more than one web server. I suppose 111 | # you could hash the output of php_info... (20120122/straup) 112 | # $data[] = php_uname(); 113 | 114 | $base = implode(':', $data); 115 | return $base; 116 | } 117 | 118 | ################################################################# 119 | 120 | function crumb_hash($str, $len=5){ 121 | 122 | return substr(sha1($GLOBALS['cfg']['crypto_crumb_secret'] . $str), 0, $len); 123 | } 124 | 125 | ################################################################# 126 | -------------------------------------------------------------------------------- /www/include/lib_crypto.php: -------------------------------------------------------------------------------- 1 | "; 40 | 41 | 42 | # 43 | # other headers 44 | # 45 | 46 | if (!$headers['To']){ 47 | $headers['To'] = $args['to_email']; 48 | } 49 | 50 | if (!$headers['Reply-To']){ 51 | $headers['Reply-To'] = $from_email; 52 | } 53 | 54 | if (!$headers['Content-Type']){ 55 | 56 | $headers['Content-Type'] = 'text/plain; charset=utf-8'; 57 | } 58 | 59 | 60 | # 61 | # subject and message come from a smarty template 62 | # 63 | 64 | $message = trim($GLOBALS['smarty']->fetch($args['template'])); 65 | $subject = trim($GLOBALS['smarty']->get_template_vars('email_subject')); 66 | 67 | $message = email_format_body($message); 68 | $subject = email_quoted_printable($subject); 69 | 70 | 71 | # 72 | # send via local MTA 73 | # 74 | 75 | unset($headers['To']); 76 | 77 | mail($args['to_email'], $subject, $message, email_format_headers($headers), $GLOBALS['cfg']['auto_email_args']); 78 | } 79 | 80 | ######################################################################################### 81 | 82 | function email_format_body($message){ 83 | 84 | $message = str_replace("\r", "", $message); 85 | $message = wordwrap($message, 72); 86 | 87 | return $message; 88 | } 89 | 90 | ######################################################################################### 91 | 92 | function email_quoted_printable($subject){ 93 | 94 | if (preg_match('/[^a-z: ]/i', $subject)){ 95 | $subject = preg_replace_callback('/([^a-z ])/i', 'email_quoted_printable_encode', $subject); 96 | $subject = str_replace(' ', '_', $subject); 97 | return "=?utf-8?Q?$subject?="; 98 | } 99 | 100 | return $subject; 101 | } 102 | 103 | function email_quoted_printable_encode($m){ 104 | 105 | return sprintf('=%02x', StripSlashes(ord($m[1]))); 106 | } 107 | 108 | ######################################################################################### 109 | 110 | function email_format_headers(&$headers){ 111 | 112 | $h2 = array(); 113 | 114 | foreach ($headers as $h => $v){ 115 | $h2[] = "$h: $v"; 116 | } 117 | 118 | return implode("\r\n", $h2); 119 | } 120 | 121 | ######################################################################################### 122 | 123 | -------------------------------------------------------------------------------- /www/include/lib_features.php: -------------------------------------------------------------------------------- 1 | HashPassword($password); 33 | } 34 | 35 | return hash_hmac("sha256", $password, $GLOBALS['cfg']['crypto_password_secret']); 36 | } 37 | 38 | ################################################################# 39 | 40 | function passwords_validate_password($password, $enc_password){ 41 | 42 | if ($GLOBALS['cfg']['passwords_use_bcrypt']){ 43 | 44 | $h = new BCryptHasher(); 45 | return $h->CheckPassword($password, $enc_password); 46 | } 47 | 48 | $test = passwords_encrypt_password($password); 49 | 50 | return $test == $enc_password; 51 | } 52 | 53 | ################################################################# 54 | 55 | # a helper function which performs password hash promotion when a hash 56 | # is not yet bcrypt and we're configured to allow it. 57 | 58 | function passwords_validate_password_for_user($password, &$user){ 59 | 60 | # 61 | # is this is *not* a bcrypt hash, but we allow promotion, 62 | # then verify & promote it. 63 | # 64 | 65 | $is_bcrypt = substr($user['password'], 0, 4) == '$2a$'; 66 | 67 | if ($GLOBALS['cfg']['passwords_use_bcrypt'] && $GLOBALS['cfg']['passwords_allow_promotion'] && !$is_bcrypt){ 68 | 69 | $test = hash_hmac("sha256", $password, $GLOBALS['cfg']['crypto_password_secret']); 70 | 71 | $is_ok = $test == $user['password']; 72 | 73 | if ($is_ok){ 74 | 75 | if (users_update_password($user, $password)){ 76 | 77 | $user = users_get_by_id($user['id']); 78 | } 79 | } 80 | 81 | return $is_ok; 82 | } 83 | 84 | 85 | # 86 | # simple case 87 | # 88 | 89 | return passwords_validate_password($password, $user['password']); 90 | } 91 | 92 | ################################################################# 93 | -------------------------------------------------------------------------------- /www/include/lib_random.php: -------------------------------------------------------------------------------- 1 | template_dir = $GLOBALS['cfg']['smarty_template_dir']; 12 | $GLOBALS['smarty']->compile_dir = $GLOBALS['cfg']['smarty_compile_dir']; 13 | $GLOBALS['smarty']->compile_check = $GLOBALS['cfg']['smarty_compile']; 14 | $GLOBALS['smarty']->force_compile = $GLOBALS['cfg']['smarty_force_compile']; 15 | 16 | $GLOBALS['smarty']->assign_by_ref('cfg', $GLOBALS['cfg']); 17 | 18 | ####################################################################################### 19 | 20 | function smarty_timings(){ 21 | 22 | $GLOBALS['timings']['smarty_timings_out'] = microtime_ms(); 23 | 24 | echo "
\n"; 25 | echo "\n"; 26 | 27 | # we add this one last so it goes at the bottom of the list 28 | $GLOBALS['timing_keys']['smarty_comp'] = 'Templates Compiled'; 29 | 30 | foreach ($GLOBALS['timing_keys'] as $k => $v){ 31 | $c = intval($GLOBALS['timings']["{$k}_count"]); 32 | $t = intval($GLOBALS['timings']["{$k}_time"]); 33 | echo "\n"; 34 | } 35 | 36 | $map2 = array( 37 | array("Startup & Libraries", $GLOBALS['timings']['init_end'] - $GLOBALS['timings']['execution_start']), 38 | array("Page Execution", $GLOBALS['timings']['smarty_start_output'] - $GLOBALS['timings']['init_end']), 39 | array("Smarty Output", $GLOBALS['timings']['smarty_timings_out'] - $GLOBALS['timings']['smarty_start_output']), 40 | array("Total", $GLOBALS['timings']['smarty_timings_out'] - $GLOBALS['timings']['execution_start']), 41 | ); 42 | 43 | foreach ($map2 as $a){ 44 | echo "\n"; 45 | } 46 | 47 | echo "
$v$c$t ms
$a[0]$a[1] ms
\n"; 48 | echo "
\n"; 49 | } 50 | 51 | $GLOBALS['smarty']->register_function('timings', 'smarty_timings'); 52 | 53 | ####################################################################################### 54 | -------------------------------------------------------------------------------- /www/include/lib_utf8.php: -------------------------------------------------------------------------------- 1 | _parse_attrs($tag_attrs); 32 | if ($_params['mimetype']){ 33 | return "utf8_headers($_params[mimetype]);"; 34 | }else{ 35 | return "utf8_headers();"; 36 | } 37 | } 38 | 39 | $GLOBALS['smarty']->register_compiler_function('utf8_headers', 'utf8_headers_smarty_comp'); 40 | 41 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.assemble_plugin_filepath.php: -------------------------------------------------------------------------------- 1 | plugins_dir as $_plugin_dir) { 26 | 27 | $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; 28 | 29 | // see if path is relative 30 | if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $_plugin_dir)) { 31 | $_relative_paths[] = $_plugin_dir; 32 | // relative path, see if it is in the SMARTY_DIR 33 | if (@is_readable(SMARTY_DIR . $_plugin_filepath)) { 34 | $_return = SMARTY_DIR . $_plugin_filepath; 35 | break; 36 | } 37 | } 38 | // try relative to cwd (or absolute) 39 | if (@is_readable($_plugin_filepath)) { 40 | $_return = $_plugin_filepath; 41 | break; 42 | } 43 | } 44 | 45 | if($_return === false) { 46 | // still not found, try PHP include_path 47 | if(isset($_relative_paths)) { 48 | foreach ((array)$_relative_paths as $_plugin_dir) { 49 | 50 | $_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename; 51 | 52 | $_params = array('file_path' => $_plugin_filepath); 53 | require_once(SMARTY_CORE_DIR . 'core.get_include_path.php'); 54 | if(smarty_core_get_include_path($_params, $smarty)) { 55 | $_return = $_params['new_file_path']; 56 | break; 57 | } 58 | } 59 | } 60 | } 61 | $_filepaths_cache[$_plugin_filename] = $_return; 62 | return $_return; 63 | } 64 | 65 | /* vim: set expandtab: */ 66 | 67 | ?> 68 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.assign_smarty_interface.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: assign_smarty_interface
13 | * Purpose: assign the $smarty interface variable 14 | * @param array Format: null 15 | * @param Smarty 16 | */ 17 | function smarty_core_assign_smarty_interface($params, &$smarty) 18 | { 19 | if (isset($smarty->_smarty_vars) && isset($smarty->_smarty_vars['request'])) { 20 | return; 21 | } 22 | 23 | $_globals_map = array('g' => 'HTTP_GET_VARS', 24 | 'p' => 'HTTP_POST_VARS', 25 | 'c' => 'HTTP_COOKIE_VARS', 26 | 's' => 'HTTP_SERVER_VARS', 27 | 'e' => 'HTTP_ENV_VARS'); 28 | 29 | $_smarty_vars_request = array(); 30 | 31 | foreach (preg_split('!!', strtolower($smarty->request_vars_order)) as $_c) { 32 | if (isset($_globals_map[$_c])) { 33 | $_smarty_vars_request = array_merge($_smarty_vars_request, $GLOBALS[$_globals_map[$_c]]); 34 | } 35 | } 36 | $_smarty_vars_request = @array_merge($_smarty_vars_request, $GLOBALS['HTTP_SESSION_VARS']); 37 | 38 | $smarty->_smarty_vars['request'] = $_smarty_vars_request; 39 | } 40 | 41 | /* vim: set expandtab: */ 42 | 43 | ?> 44 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.create_dir_structure.php: -------------------------------------------------------------------------------- 1 | _dir_perms) && !is_dir($_new_dir)) { 69 | $smarty->trigger_error("problem creating directory '" . $_new_dir . "'"); 70 | return false; 71 | } 72 | $_new_dir .= '/'; 73 | } 74 | } 75 | } 76 | 77 | /* vim: set expandtab: */ 78 | 79 | ?> 80 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.display_debug_console.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: display_debug_console
13 | * Purpose: display the javascript debug console window 14 | * @param array Format: null 15 | * @param Smarty 16 | */ 17 | function smarty_core_display_debug_console($params, &$smarty) 18 | { 19 | // we must force compile the debug template in case the environment 20 | // changed between separate applications. 21 | 22 | if(empty($smarty->debug_tpl)) { 23 | // set path to debug template from SMARTY_DIR 24 | $smarty->debug_tpl = SMARTY_DIR . 'debug.tpl'; 25 | if($smarty->security && is_file($smarty->debug_tpl)) { 26 | $smarty->secure_dir[] = realpath($smarty->debug_tpl); 27 | } 28 | $smarty->debug_tpl = 'file:' . SMARTY_DIR . 'debug.tpl'; 29 | } 30 | 31 | $_ldelim_orig = $smarty->left_delimiter; 32 | $_rdelim_orig = $smarty->right_delimiter; 33 | 34 | $smarty->left_delimiter = '{'; 35 | $smarty->right_delimiter = '}'; 36 | 37 | $_compile_id_orig = $smarty->_compile_id; 38 | $smarty->_compile_id = null; 39 | 40 | $_compile_path = $smarty->_get_compile_path($smarty->debug_tpl); 41 | if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path)) 42 | { 43 | ob_start(); 44 | $smarty->_include($_compile_path); 45 | $_results = ob_get_contents(); 46 | ob_end_clean(); 47 | } else { 48 | $_results = ''; 49 | } 50 | 51 | $smarty->_compile_id = $_compile_id_orig; 52 | 53 | $smarty->left_delimiter = $_ldelim_orig; 54 | $smarty->right_delimiter = $_rdelim_orig; 55 | 56 | return $_results; 57 | } 58 | 59 | /* vim: set expandtab: */ 60 | 61 | ?> 62 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.get_include_path.php: -------------------------------------------------------------------------------- 1 | 45 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.get_microtime.php: -------------------------------------------------------------------------------- 1 | 24 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.get_php_resource.php: -------------------------------------------------------------------------------- 1 | trusted_dir; 22 | $smarty->_parse_resource_name($params, $smarty); 23 | 24 | /* 25 | * Find out if the resource exists. 26 | */ 27 | 28 | if ($params['resource_type'] == 'file') { 29 | $_readable = false; 30 | if(file_exists($params['resource_name']) && is_readable($params['resource_name'])) { 31 | $_readable = true; 32 | } else { 33 | // test for file in include_path 34 | $_params = array('file_path' => $params['resource_name']); 35 | require_once(SMARTY_CORE_DIR . 'core.get_include_path.php'); 36 | if(smarty_core_get_include_path($_params, $smarty)) { 37 | $_include_path = $_params['new_file_path']; 38 | $_readable = true; 39 | } 40 | } 41 | } else if ($params['resource_type'] != 'file') { 42 | $_template_source = null; 43 | $_readable = is_callable($smarty->_plugins['resource'][$params['resource_type']][0][0]) 44 | && call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][0], 45 | array($params['resource_name'], &$_template_source, &$smarty)); 46 | } 47 | 48 | /* 49 | * Set the error function, depending on which class calls us. 50 | */ 51 | if (method_exists($smarty, '_syntax_error')) { 52 | $_error_funcc = '_syntax_error'; 53 | } else { 54 | $_error_funcc = 'trigger_error'; 55 | } 56 | 57 | if ($_readable) { 58 | if ($smarty->security) { 59 | require_once(SMARTY_CORE_DIR . 'core.is_trusted.php'); 60 | if (!smarty_core_is_trusted($params, $smarty)) { 61 | $smarty->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted'); 62 | return false; 63 | } 64 | } 65 | } else { 66 | $smarty->$_error_funcc($params['resource_type'] . ':' . $params['resource_name'] . ' is not readable'); 67 | return false; 68 | } 69 | 70 | if ($params['resource_type'] == 'file') { 71 | $params['php_resource'] = $params['resource_name']; 72 | } else { 73 | $params['php_resource'] = $_template_source; 74 | } 75 | return true; 76 | } 77 | 78 | /* vim: set expandtab: */ 79 | 80 | ?> 81 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.is_secure.php: -------------------------------------------------------------------------------- 1 | security || $smarty->security_settings['INCLUDE_ANY']) { 21 | return true; 22 | } 23 | 24 | if ($params['resource_type'] == 'file') { 25 | $_rp = realpath($params['resource_name']); 26 | if (isset($params['resource_base_path'])) { 27 | foreach ((array)$params['resource_base_path'] as $curr_dir) { 28 | if ( ($_cd = realpath($curr_dir)) !== false && 29 | strncmp($_rp, $_cd, strlen($_cd)) == 0 && 30 | substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) { 31 | return true; 32 | } 33 | } 34 | } 35 | if (!empty($smarty->secure_dir)) { 36 | foreach ((array)$smarty->secure_dir as $curr_dir) { 37 | if ( ($_cd = realpath($curr_dir)) !== false) { 38 | if($_cd == $_rp) { 39 | return true; 40 | } elseif (strncmp($_rp, $_cd, strlen($_cd)) == 0 && 41 | substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR) { 42 | return true; 43 | } 44 | } 45 | } 46 | } 47 | } else { 48 | // resource is not on local file system 49 | return call_user_func_array( 50 | $smarty->_plugins['resource'][$params['resource_type']][0][2], 51 | array($params['resource_name'], &$smarty)); 52 | } 53 | 54 | return false; 55 | } 56 | 57 | /* vim: set expandtab: */ 58 | 59 | ?> 60 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.is_trusted.php: -------------------------------------------------------------------------------- 1 | trusted_dir)) { 23 | $_rp = realpath($params['resource_name']); 24 | foreach ((array)$smarty->trusted_dir as $curr_dir) { 25 | if (!empty($curr_dir) && is_readable ($curr_dir)) { 26 | $_cd = realpath($curr_dir); 27 | if (strncmp($_rp, $_cd, strlen($_cd)) == 0 28 | && substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) { 29 | $_smarty_trusted = true; 30 | break; 31 | } 32 | } 33 | } 34 | } 35 | 36 | } else { 37 | // resource is not on local file system 38 | $_smarty_trusted = call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][3], 39 | array($params['resource_name'], $smarty)); 40 | } 41 | 42 | return $_smarty_trusted; 43 | } 44 | 45 | /* vim: set expandtab: */ 46 | 47 | ?> 48 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.load_resource_plugin.php: -------------------------------------------------------------------------------- 1 | _plugins['resource'][$params['type']]; 26 | if (isset($_plugin)) { 27 | if (!$_plugin[1] && count($_plugin[0])) { 28 | $_plugin[1] = true; 29 | foreach ($_plugin[0] as $_plugin_func) { 30 | if (!is_callable($_plugin_func)) { 31 | $_plugin[1] = false; 32 | break; 33 | } 34 | } 35 | } 36 | 37 | if (!$_plugin[1]) { 38 | $smarty->_trigger_fatal_error("[plugin] resource '" . $params['type'] . "' is not implemented", null, null, __FILE__, __LINE__); 39 | } 40 | 41 | return; 42 | } 43 | 44 | $_plugin_file = $smarty->_get_plugin_filepath('resource', $params['type']); 45 | $_found = ($_plugin_file != false); 46 | 47 | if ($_found) { /* 48 | * If the plugin file is found, it -must- provide the properly named 49 | * plugin functions. 50 | */ 51 | include_once($_plugin_file); 52 | 53 | /* 54 | * Locate functions that we require the plugin to provide. 55 | */ 56 | $_resource_ops = array('source', 'timestamp', 'secure', 'trusted'); 57 | $_resource_funcs = array(); 58 | foreach ($_resource_ops as $_op) { 59 | $_plugin_func = 'smarty_resource_' . $params['type'] . '_' . $_op; 60 | if (!function_exists($_plugin_func)) { 61 | $smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", null, null, __FILE__, __LINE__); 62 | return; 63 | } else { 64 | $_resource_funcs[] = $_plugin_func; 65 | } 66 | } 67 | 68 | $smarty->_plugins['resource'][$params['type']] = array($_resource_funcs, true); 69 | } 70 | } 71 | 72 | /* vim: set expandtab: */ 73 | 74 | ?> 75 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.process_cached_inserts.php: -------------------------------------------------------------------------------- 1 | _smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis', 17 | $params['results'], $match); 18 | list($cached_inserts, $insert_args) = $match; 19 | 20 | for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) { 21 | if ($smarty->debugging) { 22 | $_params = array(); 23 | require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); 24 | $debug_start_time = smarty_core_get_microtime($_params, $smarty); 25 | } 26 | 27 | $args = unserialize($insert_args[$i]); 28 | $name = $args['name']; 29 | 30 | if (isset($args['script'])) { 31 | $_params = array('resource_name' => $smarty->_dequote($args['script'])); 32 | require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); 33 | if(!smarty_core_get_php_resource($_params, $smarty)) { 34 | return false; 35 | } 36 | $resource_type = $_params['resource_type']; 37 | $php_resource = $_params['php_resource']; 38 | 39 | 40 | if ($resource_type == 'file') { 41 | $smarty->_include($php_resource, true); 42 | } else { 43 | $smarty->_eval($php_resource); 44 | } 45 | } 46 | 47 | $function_name = $smarty->_plugins['insert'][$name][0]; 48 | if (empty($args['assign'])) { 49 | $replace = $function_name($args, $smarty); 50 | } else { 51 | $smarty->assign($args['assign'], $function_name($args, $smarty)); 52 | $replace = ''; 53 | } 54 | 55 | $params['results'] = substr_replace($params['results'], $replace, strpos($params['results'], $cached_inserts[$i]), strlen($cached_inserts[$i])); 56 | if ($smarty->debugging) { 57 | $_params = array(); 58 | require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); 59 | $smarty->_smarty_debug_info[] = array('type' => 'insert', 60 | 'filename' => 'insert_'.$name, 61 | 'depth' => $smarty->_inclusion_depth, 62 | 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $debug_start_time); 63 | } 64 | } 65 | 66 | return $params['results']; 67 | } 68 | 69 | /* vim: set expandtab: */ 70 | 71 | ?> 72 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.process_compiled_include.php: -------------------------------------------------------------------------------- 1 | _cache_including; 20 | $smarty->_cache_including = true; 21 | 22 | $_return = $params['results']; 23 | 24 | foreach ($smarty->_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) { 25 | $smarty->_include($_include_file_path, true); 26 | } 27 | 28 | foreach ($smarty->_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) { 29 | $_return = preg_replace_callback('!(\{nocache\:('.$_cache_serial.')#(\d+)\})!s', 30 | array(&$smarty, '_process_compiled_include_callback'), 31 | $_return); 32 | } 33 | $smarty->_cache_including = $_cache_including; 34 | return $_return; 35 | } 36 | 37 | ?> 38 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.rm_auto.php: -------------------------------------------------------------------------------- 1 | $params['auto_base'], 28 | 'level' => 0, 29 | 'exp_time' => $params['exp_time'] 30 | ); 31 | require_once(SMARTY_CORE_DIR . 'core.rmdir.php'); 32 | $_res = smarty_core_rmdir($_params, $smarty); 33 | } else { 34 | $_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']); 35 | 36 | if(isset($params['auto_source'])) { 37 | if (isset($params['extensions'])) { 38 | $_res = false; 39 | foreach ((array)$params['extensions'] as $_extension) 40 | $_res |= $smarty->_unlink($_tname.$_extension, $params['exp_time']); 41 | } else { 42 | $_res = $smarty->_unlink($_tname, $params['exp_time']); 43 | } 44 | } elseif ($smarty->use_sub_dirs) { 45 | $_params = array( 46 | 'dirname' => $_tname, 47 | 'level' => 1, 48 | 'exp_time' => $params['exp_time'] 49 | ); 50 | require_once(SMARTY_CORE_DIR . 'core.rmdir.php'); 51 | $_res = smarty_core_rmdir($_params, $smarty); 52 | } else { 53 | // remove matching file names 54 | $_handle = opendir($params['auto_base']); 55 | $_res = true; 56 | while (false !== ($_filename = readdir($_handle))) { 57 | if($_filename == '.' || $_filename == '..') { 58 | continue; 59 | } elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) { 60 | $_res &= (bool)$smarty->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']); 61 | } 62 | } 63 | } 64 | } 65 | 66 | return $_res; 67 | } 68 | 69 | /* vim: set expandtab: */ 70 | 71 | ?> 72 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.rmdir.php: -------------------------------------------------------------------------------- 1 | keep root) 10 | * WARNING: no tests, it will try to remove what you tell it! 11 | * 12 | * @param string $dirname 13 | * @param integer $level 14 | * @param integer $exp_time 15 | * @return boolean 16 | */ 17 | 18 | // $dirname, $level = 1, $exp_time = null 19 | 20 | function smarty_core_rmdir($params, &$smarty) 21 | { 22 | if(!isset($params['level'])) { $params['level'] = 1; } 23 | if(!isset($params['exp_time'])) { $params['exp_time'] = null; } 24 | 25 | if($_handle = @opendir($params['dirname'])) { 26 | 27 | while (false !== ($_entry = readdir($_handle))) { 28 | if ($_entry != '.' && $_entry != '..') { 29 | if (@is_dir($params['dirname'] . DIRECTORY_SEPARATOR . $_entry)) { 30 | $_params = array( 31 | 'dirname' => $params['dirname'] . DIRECTORY_SEPARATOR . $_entry, 32 | 'level' => $params['level'] + 1, 33 | 'exp_time' => $params['exp_time'] 34 | ); 35 | smarty_core_rmdir($_params, $smarty); 36 | } 37 | else { 38 | $smarty->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']); 39 | } 40 | } 41 | } 42 | closedir($_handle); 43 | } 44 | 45 | if ($params['level']) { 46 | return @rmdir($params['dirname']); 47 | } 48 | return (bool)$_handle; 49 | 50 | } 51 | 52 | /* vim: set expandtab: */ 53 | 54 | ?> 55 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.run_insert_handler.php: -------------------------------------------------------------------------------- 1 | debugging) { 19 | $_params = array(); 20 | $_debug_start_time = smarty_core_get_microtime($_params, $smarty); 21 | } 22 | 23 | if ($smarty->caching) { 24 | $_arg_string = serialize($params['args']); 25 | $_name = $params['args']['name']; 26 | if (!isset($smarty->_cache_info['insert_tags'][$_name])) { 27 | $smarty->_cache_info['insert_tags'][$_name] = array('insert', 28 | $_name, 29 | $smarty->_plugins['insert'][$_name][1], 30 | $smarty->_plugins['insert'][$_name][2], 31 | !empty($params['args']['script']) ? true : false); 32 | } 33 | return $smarty->_smarty_md5."{insert_cache $_arg_string}".$smarty->_smarty_md5; 34 | } else { 35 | if (isset($params['args']['script'])) { 36 | $_params = array('resource_name' => $smarty->_dequote($params['args']['script'])); 37 | require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); 38 | if(!smarty_core_get_php_resource($_params, $smarty)) { 39 | return false; 40 | } 41 | 42 | if ($_params['resource_type'] == 'file') { 43 | $smarty->_include($_params['php_resource'], true); 44 | } else { 45 | $smarty->_eval($_params['php_resource']); 46 | } 47 | unset($params['args']['script']); 48 | } 49 | 50 | $_funcname = $smarty->_plugins['insert'][$params['args']['name']][0]; 51 | $_content = $_funcname($params['args'], $smarty); 52 | if ($smarty->debugging) { 53 | $_params = array(); 54 | require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); 55 | $smarty->_smarty_debug_info[] = array('type' => 'insert', 56 | 'filename' => 'insert_'.$params['args']['name'], 57 | 'depth' => $smarty->_inclusion_depth, 58 | 'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time); 59 | } 60 | 61 | if (!empty($params['args']["assign"])) { 62 | $smarty->assign($params['args']["assign"], $_content); 63 | } else { 64 | return $_content; 65 | } 66 | } 67 | } 68 | 69 | /* vim: set expandtab: */ 70 | 71 | ?> 72 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.smarty_include_php.php: -------------------------------------------------------------------------------- 1 | $params['smarty_file']); 24 | require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php'); 25 | smarty_core_get_php_resource($_params, $smarty); 26 | $_smarty_resource_type = $_params['resource_type']; 27 | $_smarty_php_resource = $_params['php_resource']; 28 | 29 | if (!empty($params['smarty_assign'])) { 30 | ob_start(); 31 | if ($_smarty_resource_type == 'file') { 32 | $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']); 33 | } else { 34 | $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']); 35 | } 36 | $smarty->assign($params['smarty_assign'], ob_get_contents()); 37 | ob_end_clean(); 38 | } else { 39 | if ($_smarty_resource_type == 'file') { 40 | $smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']); 41 | } else { 42 | $smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']); 43 | } 44 | } 45 | } 46 | 47 | 48 | /* vim: set expandtab: */ 49 | 50 | ?> 51 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.write_compiled_include.php: -------------------------------------------------------------------------------- 1 | caching && \!\$this->_cache_including\)\: echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\'; endif;'; 19 | $_tag_end = 'if \(\$this->caching && \!\$this->_cache_including\)\: echo \'\{/nocache\:(\\2)#(\\3)\}\'; endif;'; 20 | 21 | preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us', 22 | $params['compiled_content'], $_match_source, PREG_SET_ORDER); 23 | 24 | // no nocache-parts found: done 25 | if (count($_match_source)==0) return; 26 | 27 | // convert the matched php-code to functions 28 | $_include_compiled = "_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n"; 29 | $_include_compiled .= " compiled from " . strtr(urlencode($params['resource_name']), array('%2F'=>'/', '%3A'=>':')) . " */\n\n"; 30 | 31 | $_compile_path = $params['include_file_path']; 32 | 33 | $smarty->_cache_serials[$_compile_path] = $params['cache_serial']; 34 | $_include_compiled .= "\$this->_cache_serials['".$_compile_path."'] = '".$params['cache_serial']."';\n\n?>"; 35 | 36 | $_include_compiled .= $params['plugins_code']; 37 | $_include_compiled .= "= 5.0) ? '_smarty' : 'this'; 40 | for ($_i = 0, $_for_max = count($_match_source); $_i < $_for_max; $_i++) { 41 | $_match =& $_match_source[$_i]; 42 | $source = $_match[4]; 43 | if ($this_varname == '_smarty') { 44 | /* rename $this to $_smarty in the sourcecode */ 45 | $tokens = token_get_all('\n"; 81 | 82 | $_params = array('filename' => $_compile_path, 83 | 'contents' => $_include_compiled, 'create_dirs' => true); 84 | 85 | require_once(SMARTY_CORE_DIR . 'core.write_file.php'); 86 | smarty_core_write_file($_params, $smarty); 87 | return true; 88 | } 89 | 90 | 91 | ?> 92 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.write_compiled_resource.php: -------------------------------------------------------------------------------- 1 | compile_dir)) { 18 | // compile_dir not writable, see if it exists 19 | if(!@is_dir($smarty->compile_dir)) { 20 | $smarty->trigger_error('the $compile_dir \'' . $smarty->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR); 21 | return false; 22 | } 23 | $smarty->trigger_error('unable to write to $compile_dir \'' . realpath($smarty->compile_dir) . '\'. Be sure $compile_dir is writable by the web server user.', E_USER_ERROR); 24 | return false; 25 | } 26 | 27 | $_params = array('filename' => $params['compile_path'], 'contents' => $params['compiled_content'], 'create_dirs' => true); 28 | require_once(SMARTY_CORE_DIR . 'core.write_file.php'); 29 | smarty_core_write_file($_params, $smarty); 30 | return true; 31 | } 32 | 33 | /* vim: set expandtab: */ 34 | 35 | ?> 36 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/internals/core.write_file.php: -------------------------------------------------------------------------------- 1 | $_dirname); 22 | require_once(SMARTY_CORE_DIR . 'core.create_dir_structure.php'); 23 | smarty_core_create_dir_structure($_params, $smarty); 24 | } 25 | 26 | // write to tmp file, then rename it to avoid file locking race condition 27 | $_tmp_file = tempnam($_dirname, 'wrt'); 28 | 29 | if (!($fd = @fopen($_tmp_file, 'wb'))) { 30 | $_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('wrt'); 31 | if (!($fd = @fopen($_tmp_file, 'wb'))) { 32 | $smarty->trigger_error("problem writing temporary file '$_tmp_file'"); 33 | return false; 34 | } 35 | } 36 | 37 | fwrite($fd, $params['contents']); 38 | fclose($fd); 39 | 40 | if (DIRECTORY_SEPARATOR == '\\' || !@rename($_tmp_file, $params['filename'])) { 41 | // On platforms and filesystems that cannot overwrite with rename() 42 | // delete the file before renaming it -- because windows always suffers 43 | // this, it is short-circuited to avoid the initial rename() attempt 44 | @unlink($params['filename']); 45 | @rename($_tmp_file, $params['filename']); 46 | } 47 | @chmod($params['filename'], $smarty->_file_perms); 48 | 49 | return true; 50 | } 51 | 52 | /* vim: set expandtab: */ 53 | 54 | ?> -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/block.textformat.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: textformat
13 | * Purpose: format text a certain way with preset styles 14 | * or custom wrap/indent settings
15 | * @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat} 16 | * (Smarty online manual) 17 | * @param array 18 | *
 19 |  * Params:   style: string (email)
 20 |  *           indent: integer (0)
 21 |  *           wrap: integer (80)
 22 |  *           wrap_char string ("\n")
 23 |  *           indent_char: string (" ")
 24 |  *           wrap_boundary: boolean (true)
 25 |  * 
26 | * @author Monte Ohrt 27 | * @param string contents of the block 28 | * @param Smarty clever simulation of a method 29 | * @return string string $content re-formatted 30 | */ 31 | function smarty_block_textformat($params, $content, &$smarty) 32 | { 33 | if (is_null($content)) { 34 | return; 35 | } 36 | 37 | $style = null; 38 | $indent = 0; 39 | $indent_first = 0; 40 | $indent_char = ' '; 41 | $wrap = 80; 42 | $wrap_char = "\n"; 43 | $wrap_cut = false; 44 | $assign = null; 45 | 46 | foreach ($params as $_key => $_val) { 47 | switch ($_key) { 48 | case 'style': 49 | case 'indent_char': 50 | case 'wrap_char': 51 | case 'assign': 52 | $$_key = (string)$_val; 53 | break; 54 | 55 | case 'indent': 56 | case 'indent_first': 57 | case 'wrap': 58 | $$_key = (int)$_val; 59 | break; 60 | 61 | case 'wrap_cut': 62 | $$_key = (bool)$_val; 63 | break; 64 | 65 | default: 66 | $smarty->trigger_error("textformat: unknown attribute '$_key'"); 67 | } 68 | } 69 | 70 | if ($style == 'email') { 71 | $wrap = 72; 72 | } 73 | 74 | // split into paragraphs 75 | $_paragraphs = preg_split('![\r\n][\r\n]!',$content); 76 | $_output = ''; 77 | 78 | for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) { 79 | if ($_paragraphs[$_x] == '') { 80 | continue; 81 | } 82 | // convert mult. spaces & special chars to single space 83 | $_paragraphs[$_x] = preg_replace(array('!\s+!','!(^\s+)|(\s+$)!'), array(' ',''), $_paragraphs[$_x]); 84 | // indent first line 85 | if($indent_first > 0) { 86 | $_paragraphs[$_x] = str_repeat($indent_char, $indent_first) . $_paragraphs[$_x]; 87 | } 88 | // wordwrap sentences 89 | $_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut); 90 | // indent lines 91 | if($indent > 0) { 92 | $_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]); 93 | } 94 | } 95 | $_output = implode($wrap_char . $wrap_char, $_paragraphs); 96 | 97 | return $assign ? $smarty->assign($assign, $_output) : $_output; 98 | 99 | } 100 | 101 | /* vim: set expandtab: */ 102 | 103 | ?> 104 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/compiler.assign.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: assign
13 | * Purpose: assign a value to a template variable 14 | * @link http://smarty.php.net/manual/en/language.custom.functions.php#LANGUAGE.FUNCTION.ASSIGN {assign} 15 | * (Smarty online manual) 16 | * @author Monte Ohrt (initial author) 17 | * @author messju mohr (conversion to compiler function) 18 | * @param string containing var-attribute and value-attribute 19 | * @param Smarty_Compiler 20 | */ 21 | function smarty_compiler_assign($tag_attrs, &$compiler) 22 | { 23 | $_params = $compiler->_parse_attrs($tag_attrs); 24 | 25 | if (!isset($_params['var'])) { 26 | $compiler->_syntax_error("assign: missing 'var' parameter", E_USER_WARNING); 27 | return; 28 | } 29 | 30 | if (!isset($_params['value'])) { 31 | $compiler->_syntax_error("assign: missing 'value' parameter", E_USER_WARNING); 32 | return; 33 | } 34 | 35 | return "\$this->assign({$_params['var']}, {$_params['value']});"; 36 | } 37 | 38 | /* vim: set expandtab: */ 39 | 40 | ?> 41 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/function.assign_debug_info.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: assign_debug_info
13 | * Purpose: assign debug info to the template
14 | * @author Monte Ohrt 15 | * @param array unused in this plugin, this plugin uses {@link Smarty::$_config}, 16 | * {@link Smarty::$_tpl_vars} and {@link Smarty::$_smarty_debug_info} 17 | * @param Smarty 18 | */ 19 | function smarty_function_assign_debug_info($params, &$smarty) 20 | { 21 | $assigned_vars = $smarty->_tpl_vars; 22 | ksort($assigned_vars); 23 | if (@is_array($smarty->_config[0])) { 24 | $config_vars = $smarty->_config[0]; 25 | ksort($config_vars); 26 | $smarty->assign("_debug_config_keys", array_keys($config_vars)); 27 | $smarty->assign("_debug_config_vals", array_values($config_vars)); 28 | } 29 | 30 | $included_templates = $smarty->_smarty_debug_info; 31 | 32 | $smarty->assign("_debug_keys", array_keys($assigned_vars)); 33 | $smarty->assign("_debug_vals", array_values($assigned_vars)); 34 | 35 | $smarty->assign("_debug_tpls", $included_templates); 36 | } 37 | 38 | /* vim: set expandtab: */ 39 | 40 | ?> 41 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/function.counter.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: counter
14 | * Purpose: print out a counter value 15 | * @author Monte Ohrt 16 | * @link http://smarty.php.net/manual/en/language.function.counter.php {counter} 17 | * (Smarty online manual) 18 | * @param array parameters 19 | * @param Smarty 20 | * @return string|null 21 | */ 22 | function smarty_function_counter($params, &$smarty) 23 | { 24 | static $counters = array(); 25 | 26 | $name = (isset($params['name'])) ? $params['name'] : 'default'; 27 | if (!isset($counters[$name])) { 28 | $counters[$name] = array( 29 | 'start'=>1, 30 | 'skip'=>1, 31 | 'direction'=>'up', 32 | 'count'=>1 33 | ); 34 | } 35 | $counter =& $counters[$name]; 36 | 37 | if (isset($params['start'])) { 38 | $counter['start'] = $counter['count'] = (int)$params['start']; 39 | } 40 | 41 | if (!empty($params['assign'])) { 42 | $counter['assign'] = $params['assign']; 43 | } 44 | 45 | if (isset($counter['assign'])) { 46 | $smarty->assign($counter['assign'], $counter['count']); 47 | } 48 | 49 | if (isset($params['print'])) { 50 | $print = (bool)$params['print']; 51 | } else { 52 | $print = empty($counter['assign']); 53 | } 54 | 55 | if ($print) { 56 | $retval = $counter['count']; 57 | } else { 58 | $retval = null; 59 | } 60 | 61 | if (isset($params['skip'])) { 62 | $counter['skip'] = $params['skip']; 63 | } 64 | 65 | if (isset($params['direction'])) { 66 | $counter['direction'] = $params['direction']; 67 | } 68 | 69 | if ($counter['direction'] == "down") 70 | $counter['count'] -= $counter['skip']; 71 | else 72 | $counter['count'] += $counter['skip']; 73 | 74 | return $retval; 75 | 76 | } 77 | 78 | /* vim: set expandtab: */ 79 | 80 | ?> 81 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/function.cycle.php: -------------------------------------------------------------------------------- 1 | 12 | * Name: cycle
13 | * Date: May 3, 2002
14 | * Purpose: cycle through given values
15 | * Input: 16 | * - name = name of cycle (optional) 17 | * - values = comma separated list of values to cycle, 18 | * or an array of values to cycle 19 | * (this can be left out for subsequent calls) 20 | * - reset = boolean - resets given var to true 21 | * - print = boolean - print var or not. default is true 22 | * - advance = boolean - whether or not to advance the cycle 23 | * - delimiter = the value delimiter, default is "," 24 | * - assign = boolean, assigns to template var instead of 25 | * printed. 26 | * 27 | * Examples:
28 | *
 29 |  * {cycle values="#eeeeee,#d0d0d0d"}
 30 |  * {cycle name=row values="one,two,three" reset=true}
 31 |  * {cycle name=row}
 32 |  * 
33 | * @link http://smarty.php.net/manual/en/language.function.cycle.php {cycle} 34 | * (Smarty online manual) 35 | * @author Monte Ohrt 36 | * @author credit to Mark Priatel 37 | * @author credit to Gerard 38 | * @author credit to Jason Sweat 39 | * @version 1.3 40 | * @param array 41 | * @param Smarty 42 | * @return string|null 43 | */ 44 | function smarty_function_cycle($params, &$smarty) 45 | { 46 | static $cycle_vars; 47 | 48 | $name = (empty($params['name'])) ? 'default' : $params['name']; 49 | $print = (isset($params['print'])) ? (bool)$params['print'] : true; 50 | $advance = (isset($params['advance'])) ? (bool)$params['advance'] : true; 51 | $reset = (isset($params['reset'])) ? (bool)$params['reset'] : false; 52 | 53 | if (!in_array('values', array_keys($params))) { 54 | if(!isset($cycle_vars[$name]['values'])) { 55 | $smarty->trigger_error("cycle: missing 'values' parameter"); 56 | return; 57 | } 58 | } else { 59 | if(isset($cycle_vars[$name]['values']) 60 | && $cycle_vars[$name]['values'] != $params['values'] ) { 61 | $cycle_vars[$name]['index'] = 0; 62 | } 63 | $cycle_vars[$name]['values'] = $params['values']; 64 | } 65 | 66 | if (isset($params['delimiter'])) { 67 | $cycle_vars[$name]['delimiter'] = $params['delimiter']; 68 | } elseif (!isset($cycle_vars[$name]['delimiter'])) { 69 | $cycle_vars[$name]['delimiter'] = ','; 70 | } 71 | 72 | if(is_array($cycle_vars[$name]['values'])) { 73 | $cycle_array = $cycle_vars[$name]['values']; 74 | } else { 75 | $cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']); 76 | } 77 | 78 | if(!isset($cycle_vars[$name]['index']) || $reset ) { 79 | $cycle_vars[$name]['index'] = 0; 80 | } 81 | 82 | if (isset($params['assign'])) { 83 | $print = false; 84 | $smarty->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]); 85 | } 86 | 87 | if($print) { 88 | $retval = $cycle_array[$cycle_vars[$name]['index']]; 89 | } else { 90 | $retval = null; 91 | } 92 | 93 | if($advance) { 94 | if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) { 95 | $cycle_vars[$name]['index'] = 0; 96 | } else { 97 | $cycle_vars[$name]['index']++; 98 | } 99 | } 100 | 101 | return $retval; 102 | } 103 | 104 | /* vim: set expandtab: */ 105 | 106 | ?> 107 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/function.debug.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: debug
14 | * Date: July 1, 2002
15 | * Purpose: popup debug window 16 | * @link http://smarty.php.net/manual/en/language.function.debug.php {debug} 17 | * (Smarty online manual) 18 | * @author Monte Ohrt 19 | * @version 1.0 20 | * @param array 21 | * @param Smarty 22 | * @return string output from {@link Smarty::_generate_debug_output()} 23 | */ 24 | function smarty_function_debug($params, &$smarty) 25 | { 26 | if (isset($params['output'])) { 27 | $smarty->assign('_smarty_debug_output', $params['output']); 28 | } 29 | require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php'); 30 | return smarty_core_display_debug_console(null, $smarty); 31 | } 32 | 33 | /* vim: set expandtab: */ 34 | 35 | ?> 36 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/function.eval.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: eval
14 | * Purpose: evaluate a template variable as a template
15 | * @link http://smarty.php.net/manual/en/language.function.eval.php {eval} 16 | * (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param array 19 | * @param Smarty 20 | */ 21 | function smarty_function_eval($params, &$smarty) 22 | { 23 | 24 | if (!isset($params['var'])) { 25 | $smarty->trigger_error("eval: missing 'var' parameter"); 26 | return; 27 | } 28 | 29 | if($params['var'] == '') { 30 | return; 31 | } 32 | 33 | $smarty->_compile_source('evaluated template', $params['var'], $_var_compiled); 34 | 35 | ob_start(); 36 | $smarty->_eval('?>' . $_var_compiled); 37 | $_contents = ob_get_contents(); 38 | ob_end_clean(); 39 | 40 | if (!empty($params['assign'])) { 41 | $smarty->assign($params['assign'], $_contents); 42 | } else { 43 | return $_contents; 44 | } 45 | } 46 | 47 | /* vim: set expandtab: */ 48 | 49 | ?> 50 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/function.math.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: math
14 | * Purpose: handle math computations in template
15 | * @link http://smarty.php.net/manual/en/language.function.math.php {math} 16 | * (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param array 19 | * @param Smarty 20 | * @return string 21 | */ 22 | function smarty_function_math($params, &$smarty) 23 | { 24 | // be sure equation parameter is present 25 | if (empty($params['equation'])) { 26 | $smarty->trigger_error("math: missing equation parameter"); 27 | return; 28 | } 29 | 30 | // strip out backticks, not necessary for math 31 | $equation = str_replace('`','',$params['equation']); 32 | 33 | // make sure parenthesis are balanced 34 | if (substr_count($equation,"(") != substr_count($equation,")")) { 35 | $smarty->trigger_error("math: unbalanced parenthesis"); 36 | return; 37 | } 38 | 39 | // match all vars in equation, make sure all are passed 40 | preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!",$equation, $match); 41 | $allowed_funcs = array('int','abs','ceil','cos','exp','floor','log','log10', 42 | 'max','min','pi','pow','rand','round','sin','sqrt','srand','tan'); 43 | 44 | foreach($match[1] as $curr_var) { 45 | if ($curr_var && !in_array($curr_var, array_keys($params)) && !in_array($curr_var, $allowed_funcs)) { 46 | $smarty->trigger_error("math: function call $curr_var not allowed"); 47 | return; 48 | } 49 | } 50 | 51 | foreach($params as $key => $val) { 52 | if ($key != "equation" && $key != "format" && $key != "assign") { 53 | // make sure value is not empty 54 | if (strlen($val)==0) { 55 | $smarty->trigger_error("math: parameter $key is empty"); 56 | return; 57 | } 58 | if (!is_numeric($val)) { 59 | $smarty->trigger_error("math: parameter $key: is not numeric"); 60 | return; 61 | } 62 | $equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation); 63 | } 64 | } 65 | 66 | eval("\$smarty_math_result = ".$equation.";"); 67 | 68 | if (empty($params['format'])) { 69 | if (empty($params['assign'])) { 70 | return $smarty_math_result; 71 | } else { 72 | $smarty->assign($params['assign'],$smarty_math_result); 73 | } 74 | } else { 75 | if (empty($params['assign'])){ 76 | printf($params['format'],$smarty_math_result); 77 | } else { 78 | $smarty->assign($params['assign'],sprintf($params['format'],$smarty_math_result)); 79 | } 80 | } 81 | } 82 | 83 | /* vim: set expandtab: */ 84 | 85 | ?> -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/function.popup.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: popup
14 | * Purpose: make text pop up in windows via overlib 15 | * @link http://smarty.php.net/manual/en/language.function.popup.php {popup} 16 | * (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param array 19 | * @param Smarty 20 | * @return string 21 | */ 22 | function smarty_function_popup($params, &$smarty) 23 | { 24 | $append = ''; 25 | foreach ($params as $_key=>$_value) { 26 | switch ($_key) { 27 | case 'text': 28 | case 'trigger': 29 | case 'function': 30 | case 'inarray': 31 | $$_key = (string)$_value; 32 | if ($_key == 'function' || $_key == 'inarray') 33 | $append .= ',' . strtoupper($_key) . ",'$_value'"; 34 | break; 35 | 36 | case 'caption': 37 | case 'closetext': 38 | case 'status': 39 | $append .= ',' . strtoupper($_key) . ",'" . str_replace("'","\'",$_value) . "'"; 40 | break; 41 | 42 | case 'fgcolor': 43 | case 'bgcolor': 44 | case 'textcolor': 45 | case 'capcolor': 46 | case 'closecolor': 47 | case 'textfont': 48 | case 'captionfont': 49 | case 'closefont': 50 | case 'fgbackground': 51 | case 'bgbackground': 52 | case 'caparray': 53 | case 'capicon': 54 | case 'background': 55 | case 'frame': 56 | $append .= ',' . strtoupper($_key) . ",'$_value'"; 57 | break; 58 | 59 | case 'textsize': 60 | case 'captionsize': 61 | case 'closesize': 62 | case 'width': 63 | case 'height': 64 | case 'border': 65 | case 'offsetx': 66 | case 'offsety': 67 | case 'snapx': 68 | case 'snapy': 69 | case 'fixx': 70 | case 'fixy': 71 | case 'padx': 72 | case 'pady': 73 | case 'timeout': 74 | case 'delay': 75 | $append .= ',' . strtoupper($_key) . ",$_value"; 76 | break; 77 | 78 | case 'sticky': 79 | case 'left': 80 | case 'right': 81 | case 'center': 82 | case 'above': 83 | case 'below': 84 | case 'noclose': 85 | case 'autostatus': 86 | case 'autostatuscap': 87 | case 'fullhtml': 88 | case 'hauto': 89 | case 'vauto': 90 | case 'mouseoff': 91 | case 'followmouse': 92 | case 'closeclick': 93 | if ($_value) $append .= ',' . strtoupper($_key); 94 | break; 95 | 96 | default: 97 | $smarty->trigger_error("[popup] unknown parameter $_key", E_USER_WARNING); 98 | } 99 | } 100 | 101 | if (empty($text) && !isset($inarray) && empty($function)) { 102 | $smarty->trigger_error("overlib: attribute 'text' or 'inarray' or 'function' required"); 103 | return false; 104 | } 105 | 106 | if (empty($trigger)) { $trigger = "onmouseover"; } 107 | 108 | $retval = $trigger . '="return overlib(\''.preg_replace(array("!'!","![\r\n]!"),array("\'",'\r'),$text).'\''; 109 | $retval .= $append . ');"'; 110 | if ($trigger == 'onmouseover') 111 | $retval .= ' onmouseout="nd();"'; 112 | 113 | 114 | return $retval; 115 | } 116 | 117 | /* vim: set expandtab: */ 118 | 119 | ?> 120 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/function.popup_init.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: popup_init
14 | * Purpose: initialize overlib 15 | * @link http://smarty.php.net/manual/en/language.function.popup.init.php {popup_init} 16 | * (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param array 19 | * @param Smarty 20 | * @return string 21 | */ 22 | function smarty_function_popup_init($params, &$smarty) 23 | { 24 | $zindex = 1000; 25 | 26 | if (!empty($params['zindex'])) { 27 | $zindex = $params['zindex']; 28 | } 29 | 30 | if (!empty($params['src'])) { 31 | return '' . "\n" 32 | . '' . "\n"; 33 | } else { 34 | $smarty->trigger_error("popup_init: missing src parameter"); 35 | } 36 | } 37 | 38 | /* vim: set expandtab: */ 39 | 40 | ?> 41 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.capitalize.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: capitalize
14 | * Purpose: capitalize words in the string 15 | * @link http://smarty.php.net/manual/en/language.modifiers.php#LANGUAGE.MODIFIER.CAPITALIZE 16 | * capitalize (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param string 19 | * @return string 20 | */ 21 | function smarty_modifier_capitalize($string, $uc_digits = false) 22 | { 23 | smarty_modifier_capitalize_ucfirst(null, $uc_digits); 24 | return preg_replace_callback('!\'?\b\w(\w|\')*\b!', 'smarty_modifier_capitalize_ucfirst', $string); 25 | } 26 | 27 | function smarty_modifier_capitalize_ucfirst($string, $uc_digits = null) 28 | { 29 | static $_uc_digits = false; 30 | 31 | if(isset($uc_digits)) { 32 | $_uc_digits = $uc_digits; 33 | return; 34 | } 35 | 36 | if(substr($string[0],0,1) != "'" && !preg_match("!\d!",$string[0]) || $_uc_digits) 37 | return ucfirst($string[0]); 38 | else 39 | return $string[0]; 40 | } 41 | 42 | 43 | ?> 44 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.cat.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: cat
14 | * Date: Feb 24, 2003 15 | * Purpose: catenate a value to a variable 16 | * Input: string to catenate 17 | * Example: {$var|cat:"foo"} 18 | * @link http://smarty.php.net/manual/en/language.modifier.cat.php cat 19 | * (Smarty online manual) 20 | * @author Monte Ohrt 21 | * @version 1.0 22 | * @param string 23 | * @param string 24 | * @return string 25 | */ 26 | function smarty_modifier_cat($string, $cat) 27 | { 28 | return $string . $cat; 29 | } 30 | 31 | /* vim: set expandtab: */ 32 | 33 | ?> 34 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.count_characters.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: count_characteres
14 | * Purpose: count the number of characters in a text 15 | * @link http://smarty.php.net/manual/en/language.modifier.count.characters.php 16 | * count_characters (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param string 19 | * @param boolean include whitespace in the character count 20 | * @return integer 21 | */ 22 | function smarty_modifier_count_characters($string, $include_spaces = false) 23 | { 24 | if ($include_spaces) 25 | return(strlen($string)); 26 | 27 | return preg_match_all("/[^\s]/",$string, $match); 28 | } 29 | 30 | /* vim: set expandtab: */ 31 | 32 | ?> 33 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.count_paragraphs.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: count_paragraphs
14 | * Purpose: count the number of paragraphs in a text 15 | * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php 16 | * count_paragraphs (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param string 19 | * @return integer 20 | */ 21 | function smarty_modifier_count_paragraphs($string) 22 | { 23 | // count \r or \n characters 24 | return count(preg_split('/[\r\n]+/', $string)); 25 | } 26 | 27 | /* vim: set expandtab: */ 28 | 29 | ?> 30 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.count_sentences.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: count_sentences 14 | * Purpose: count the number of sentences in a text 15 | * @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php 16 | * count_sentences (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param string 19 | * @return integer 20 | */ 21 | function smarty_modifier_count_sentences($string) 22 | { 23 | // find periods with a word before but not after. 24 | return preg_match_all('/[^\s]\.(?!\w)/', $string, $match); 25 | } 26 | 27 | /* vim: set expandtab: */ 28 | 29 | ?> 30 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.count_words.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: count_words
14 | * Purpose: count the number of words in a text 15 | * @link http://smarty.php.net/manual/en/language.modifier.count.words.php 16 | * count_words (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param string 19 | * @return integer 20 | */ 21 | function smarty_modifier_count_words($string) 22 | { 23 | // split text by ' ',\r,\n,\f,\t 24 | $split_array = preg_split('/\s+/',$string); 25 | // count matches that contain alphanumerics 26 | $word_count = preg_grep('/[a-zA-Z0-9\\x80-\\xff]/', $split_array); 27 | 28 | return count($word_count); 29 | } 30 | 31 | /* vim: set expandtab: */ 32 | 33 | ?> 34 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.date_format.php: -------------------------------------------------------------------------------- 1 | _get_plugin_filepath('shared', 'make_timestamp'); 12 | /** 13 | * Smarty date_format modifier plugin 14 | * 15 | * Type: modifier
16 | * Name: date_format
17 | * Purpose: format datestamps via strftime
18 | * Input:
19 | * - string: input date string 20 | * - format: strftime format for output 21 | * - default_date: default date if $string is empty 22 | * @link http://smarty.php.net/manual/en/language.modifier.date.format.php 23 | * date_format (Smarty online manual) 24 | * @author Monte Ohrt 25 | * @param string 26 | * @param string 27 | * @param string 28 | * @return string|void 29 | * @uses smarty_make_timestamp() 30 | */ 31 | function smarty_modifier_date_format($string, $format = '%b %e, %Y', $default_date = '') 32 | { 33 | if ($string != '') { 34 | $timestamp = smarty_make_timestamp($string); 35 | } elseif ($default_date != '') { 36 | $timestamp = smarty_make_timestamp($default_date); 37 | } else { 38 | return; 39 | } 40 | if (DIRECTORY_SEPARATOR == '\\') { 41 | $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); 42 | $_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S'); 43 | if (strpos($format, '%e') !== false) { 44 | $_win_from[] = '%e'; 45 | $_win_to[] = sprintf('%\' 2d', date('j', $timestamp)); 46 | } 47 | if (strpos($format, '%l') !== false) { 48 | $_win_from[] = '%l'; 49 | $_win_to[] = sprintf('%\' 2d', date('h', $timestamp)); 50 | } 51 | $format = str_replace($_win_from, $_win_to, $format); 52 | } 53 | return strftime($format, $timestamp); 54 | } 55 | 56 | /* vim: set expandtab: */ 57 | 58 | ?> 59 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.debug_print_var.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: debug_print_var
14 | * Purpose: formats variable contents for display in the console 15 | * @link http://smarty.php.net/manual/en/language.modifier.debug.print.var.php 16 | * debug_print_var (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param array|object 19 | * @param integer 20 | * @param integer 21 | * @return string 22 | */ 23 | function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40) 24 | { 25 | $_replace = array( 26 | "\n" => '\n', 27 | "\r" => '\r', 28 | "\t" => '\t' 29 | ); 30 | 31 | switch (gettype($var)) { 32 | case 'array' : 33 | $results = 'Array (' . count($var) . ')'; 34 | foreach ($var as $curr_key => $curr_val) { 35 | $results .= '
' . str_repeat(' ', $depth * 2) 36 | . '' . strtr($curr_key, $_replace) . ' => ' 37 | . smarty_modifier_debug_print_var($curr_val, ++$depth, $length); 38 | $depth--; 39 | } 40 | break; 41 | case 'object' : 42 | $object_vars = get_object_vars($var); 43 | $results = '' . get_class($var) . ' Object (' . count($object_vars) . ')'; 44 | foreach ($object_vars as $curr_key => $curr_val) { 45 | $results .= '
' . str_repeat(' ', $depth * 2) 46 | . ' ->' . strtr($curr_key, $_replace) . ' = ' 47 | . smarty_modifier_debug_print_var($curr_val, ++$depth, $length); 48 | $depth--; 49 | } 50 | break; 51 | case 'boolean' : 52 | case 'NULL' : 53 | case 'resource' : 54 | if (true === $var) { 55 | $results = 'true'; 56 | } elseif (false === $var) { 57 | $results = 'false'; 58 | } elseif (null === $var) { 59 | $results = 'null'; 60 | } else { 61 | $results = htmlspecialchars((string) $var); 62 | } 63 | $results = '' . $results . ''; 64 | break; 65 | case 'integer' : 66 | case 'float' : 67 | $results = htmlspecialchars((string) $var); 68 | break; 69 | case 'string' : 70 | $results = strtr($var, $_replace); 71 | if (strlen($var) > $length ) { 72 | $results = substr($var, 0, $length - 3) . '...'; 73 | } 74 | $results = htmlspecialchars('"' . $results . '"'); 75 | break; 76 | case 'unknown type' : 77 | default : 78 | $results = strtr((string) $var, $_replace); 79 | if (strlen($results) > $length ) { 80 | $results = substr($results, 0, $length - 3) . '...'; 81 | } 82 | $results = htmlspecialchars($results); 83 | } 84 | 85 | return $results; 86 | } 87 | 88 | /* vim: set expandtab: */ 89 | 90 | ?> 91 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.default.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: default
14 | * Purpose: designate default value for empty variables 15 | * @link http://smarty.php.net/manual/en/language.modifier.default.php 16 | * default (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param string 19 | * @param string 20 | * @return string 21 | */ 22 | function smarty_modifier_default($string, $default = '') 23 | { 24 | if (!isset($string) || $string === '') 25 | return $default; 26 | else 27 | return $string; 28 | } 29 | 30 | /* vim: set expandtab: */ 31 | 32 | ?> 33 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.escape.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: escape
14 | * Purpose: Escape the string according to escapement type 15 | * @link http://smarty.php.net/manual/en/language.modifier.escape.php 16 | * escape (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param string 19 | * @param html|htmlall|url|quotes|hex|hexentity|javascript 20 | * @return string 21 | */ 22 | function smarty_modifier_escape($string, $esc_type = 'html', $char_set = 'ISO-8859-1') 23 | { 24 | switch ($esc_type) { 25 | case 'html': 26 | return htmlspecialchars($string, ENT_QUOTES, $char_set); 27 | 28 | case 'htmlall': 29 | return htmlentities($string, ENT_QUOTES, $char_set); 30 | 31 | case 'url': 32 | return rawurlencode($string); 33 | 34 | case 'urlpathinfo': 35 | return str_replace('%2F','/',rawurlencode($string)); 36 | 37 | case 'quotes': 38 | // escape unescaped single quotes 39 | return preg_replace("%(?'\\\\',"'"=>"\\'",'"'=>'\\"',"\r"=>'\\r',"\n"=>'\\n',''<\/')); 66 | 67 | case 'mail': 68 | // safe way to display e-mail address on a web page 69 | return str_replace(array('@', '.'),array(' [AT] ', ' [DOT] '), $string); 70 | 71 | case 'nonstd': 72 | // escape non-standard chars, such as ms document quotes 73 | $_res = ''; 74 | for($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) { 75 | $_ord = ord(substr($string, $_i, 1)); 76 | // non-standard char, escape it 77 | if($_ord >= 126){ 78 | $_res .= '&#' . $_ord . ';'; 79 | } 80 | else { 81 | $_res .= substr($string, $_i, 1); 82 | } 83 | } 84 | return $_res; 85 | 86 | default: 87 | return $string; 88 | } 89 | } 90 | 91 | /* vim: set expandtab: */ 92 | 93 | ?> 94 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.indent.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: indent
14 | * Purpose: indent lines of text 15 | * @link http://smarty.php.net/manual/en/language.modifier.indent.php 16 | * indent (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param string 19 | * @param integer 20 | * @param string 21 | * @return string 22 | */ 23 | function smarty_modifier_indent($string,$chars=4,$char=" ") 24 | { 25 | return preg_replace('!^!m',str_repeat($char,$chars),$string); 26 | } 27 | 28 | ?> 29 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.lower.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: lower
14 | * Purpose: convert string to lowercase 15 | * @link http://smarty.php.net/manual/en/language.modifier.lower.php 16 | * lower (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param string 19 | * @return string 20 | */ 21 | function smarty_modifier_lower($string) 22 | { 23 | return strtolower($string); 24 | } 25 | 26 | ?> 27 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.nl2br.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: nl2br
14 | * Date: Feb 26, 2003 15 | * Purpose: convert \r\n, \r or \n to <
> 16 | * Input:
17 | * - contents = contents to replace 18 | * - preceed_test = if true, includes preceeding break tags 19 | * in replacement 20 | * Example: {$text|nl2br} 21 | * @link http://smarty.php.net/manual/en/language.modifier.nl2br.php 22 | * nl2br (Smarty online manual) 23 | * @version 1.0 24 | * @author Monte Ohrt 25 | * @param string 26 | * @return string 27 | */ 28 | function smarty_modifier_nl2br($string) 29 | { 30 | return nl2br($string); 31 | } 32 | 33 | /* vim: set expandtab: */ 34 | 35 | ?> 36 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.regex_replace.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: regex_replace
14 | * Purpose: regular expression search/replace 15 | * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php 16 | * regex_replace (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param string 19 | * @param string|array 20 | * @param string|array 21 | * @return string 22 | */ 23 | function smarty_modifier_regex_replace($string, $search, $replace) 24 | { 25 | if(is_array($search)) { 26 | foreach($search as $idx => $s) 27 | $search[$idx] = _smarty_regex_replace_check($s); 28 | } else { 29 | $search = _smarty_regex_replace_check($search); 30 | } 31 | 32 | return preg_replace($search, $replace, $string); 33 | } 34 | 35 | function _smarty_regex_replace_check($search) 36 | { 37 | if (($pos = strpos($search,"\0")) !== false) 38 | $search = substr($search,0,$pos); 39 | if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) { 40 | /* remove eval-modifier from $search */ 41 | $search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]); 42 | } 43 | return $search; 44 | } 45 | 46 | /* vim: set expandtab: */ 47 | 48 | ?> 49 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.replace.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: replace
14 | * Purpose: simple search/replace 15 | * @link http://smarty.php.net/manual/en/language.modifier.replace.php 16 | * replace (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param string 19 | * @param string 20 | * @param string 21 | * @return string 22 | */ 23 | function smarty_modifier_replace($string, $search, $replace) 24 | { 25 | return str_replace($search, $replace, $string); 26 | } 27 | 28 | /* vim: set expandtab: */ 29 | 30 | ?> 31 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.spacify.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: spacify
14 | * Purpose: add spaces between characters in a string 15 | * @link http://smarty.php.net/manual/en/language.modifier.spacify.php 16 | * spacify (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param string 19 | * @param string 20 | * @return string 21 | */ 22 | function smarty_modifier_spacify($string, $spacify_char = ' ') 23 | { 24 | return implode($spacify_char, 25 | preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY)); 26 | } 27 | 28 | /* vim: set expandtab: */ 29 | 30 | ?> 31 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.string_format.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: string_format
14 | * Purpose: format strings via sprintf 15 | * @link http://smarty.php.net/manual/en/language.modifier.string.format.php 16 | * string_format (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param string 19 | * @param string 20 | * @return string 21 | */ 22 | function smarty_modifier_string_format($string, $format) 23 | { 24 | return sprintf($format, $string); 25 | } 26 | 27 | /* vim: set expandtab: */ 28 | 29 | ?> 30 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.strip.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: strip
14 | * Purpose: Replace all repeated spaces, newlines, tabs 15 | * with a single space or supplied replacement string.
16 | * Example: {$var|strip} {$var|strip:" "} 17 | * Date: September 25th, 2002 18 | * @link http://smarty.php.net/manual/en/language.modifier.strip.php 19 | * strip (Smarty online manual) 20 | * @author Monte Ohrt 21 | * @version 1.0 22 | * @param string 23 | * @param string 24 | * @return string 25 | */ 26 | function smarty_modifier_strip($text, $replace = ' ') 27 | { 28 | return preg_replace('!\s+!', $replace, $text); 29 | } 30 | 31 | /* vim: set expandtab: */ 32 | 33 | ?> 34 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.strip_tags.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: strip_tags
14 | * Purpose: strip html tags from text 15 | * @link http://smarty.php.net/manual/en/language.modifier.strip.tags.php 16 | * strip_tags (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param string 19 | * @param boolean 20 | * @return string 21 | */ 22 | function smarty_modifier_strip_tags($string, $replace_with_space = true) 23 | { 24 | if ($replace_with_space) 25 | return preg_replace('!<[^>]*?>!', ' ', $string); 26 | else 27 | return strip_tags($string); 28 | } 29 | 30 | /* vim: set expandtab: */ 31 | 32 | ?> 33 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.truncate.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: truncate
14 | * Purpose: Truncate a string to a certain length if necessary, 15 | * optionally splitting in the middle of a word, and 16 | * appending the $etc string or inserting $etc into the middle. 17 | * @link http://smarty.php.net/manual/en/language.modifier.truncate.php 18 | * truncate (Smarty online manual) 19 | * @author Monte Ohrt 20 | * @param string 21 | * @param integer 22 | * @param string 23 | * @param boolean 24 | * @param boolean 25 | * @return string 26 | */ 27 | function smarty_modifier_truncate($string, $length = 80, $etc = '...', 28 | $break_words = false, $middle = false) 29 | { 30 | if ($length == 0) 31 | return ''; 32 | 33 | if (strlen($string) > $length) { 34 | $length -= min($length, strlen($etc)); 35 | if (!$break_words && !$middle) { 36 | $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1)); 37 | } 38 | if(!$middle) { 39 | return substr($string, 0, $length) . $etc; 40 | } else { 41 | return substr($string, 0, $length/2) . $etc . substr($string, -$length/2); 42 | } 43 | } else { 44 | return $string; 45 | } 46 | } 47 | 48 | /* vim: set expandtab: */ 49 | 50 | ?> 51 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.upper.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: upper
14 | * Purpose: convert string to uppercase 15 | * @link http://smarty.php.net/manual/en/language.modifier.upper.php 16 | * upper (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param string 19 | * @return string 20 | */ 21 | function smarty_modifier_upper($string) 22 | { 23 | return strtoupper($string); 24 | } 25 | 26 | ?> 27 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/modifier.wordwrap.php: -------------------------------------------------------------------------------- 1 | 13 | * Name: wordwrap
14 | * Purpose: wrap a string of text at a given length 15 | * @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php 16 | * wordwrap (Smarty online manual) 17 | * @author Monte Ohrt 18 | * @param string 19 | * @param integer 20 | * @param string 21 | * @param boolean 22 | * @return string 23 | */ 24 | function smarty_modifier_wordwrap($string,$length=80,$break="\n",$cut=false) 25 | { 26 | return wordwrap($string,$length,$break,$cut); 27 | } 28 | 29 | ?> 30 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/outputfilter.trimwhitespace.php: -------------------------------------------------------------------------------- 1 | 12 | * Type: outputfilter
13 | * Name: trimwhitespace
14 | * Date: Jan 25, 2003
15 | * Purpose: trim leading white space and blank lines from 16 | * template source after it gets interpreted, cleaning 17 | * up code and saving bandwidth. Does not affect 18 | * <
>
and blocks.
19 | * Install: Drop into the plugin directory, call 20 | * $smarty->load_filter('output','trimwhitespace'); 21 | * from application. 22 | * @author Monte Ohrt 23 | * @author Contributions from Lars Noschinski 24 | * @version 1.3 25 | * @param string 26 | * @param Smarty 27 | */ 28 | function smarty_outputfilter_trimwhitespace($source, &$smarty) 29 | { 30 | // Pull out the script blocks 31 | preg_match_all("!]*?>.*?!is", $source, $match); 32 | $_script_blocks = $match[0]; 33 | $source = preg_replace("!]*?>.*?!is", 34 | '@@@SMARTY:TRIM:SCRIPT@@@', $source); 35 | 36 | // Pull out the pre blocks 37 | preg_match_all("!]*?>.*?!is", $source, $match); 38 | $_pre_blocks = $match[0]; 39 | $source = preg_replace("!]*?>.*?!is", 40 | '@@@SMARTY:TRIM:PRE@@@', $source); 41 | 42 | // Pull out the textarea blocks 43 | preg_match_all("!]*?>.*?!is", $source, $match); 44 | $_textarea_blocks = $match[0]; 45 | $source = preg_replace("!]*?>.*?!is", 46 | '@@@SMARTY:TRIM:TEXTAREA@@@', $source); 47 | 48 | // remove all leading spaces, tabs and carriage returns NOT 49 | // preceeded by a php close tag. 50 | $source = trim(preg_replace('/((?)\n)[\s]+/m', '\1', $source)); 51 | 52 | // replace textarea blocks 53 | smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source); 54 | 55 | // replace pre blocks 56 | smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $source); 57 | 58 | // replace script blocks 59 | smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source); 60 | 61 | return $source; 62 | } 63 | 64 | function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject) { 65 | $_len = strlen($search_str); 66 | $_pos = 0; 67 | for ($_i=0, $_count=count($replace); $_i<$_count; $_i++) 68 | if (($_pos=strpos($subject, $search_str, $_pos))!==false) 69 | $subject = substr_replace($subject, $replace[$_i], $_pos, $_len); 70 | else 71 | break; 72 | 73 | } 74 | 75 | ?> 76 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/shared.escape_special_chars.php: -------------------------------------------------------------------------------- 1 | 13 | * Purpose: used by other smarty functions to escape 14 | * special chars except for already escaped ones 15 | * @author Monte Ohrt 16 | * @param string 17 | * @return string 18 | */ 19 | function smarty_function_escape_special_chars($string) 20 | { 21 | if(!is_array($string)) { 22 | $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); 23 | $string = htmlspecialchars($string); 24 | $string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string); 25 | } 26 | return $string; 27 | } 28 | 29 | /* vim: set expandtab: */ 30 | 31 | ?> 32 | -------------------------------------------------------------------------------- /www/include/smarty-2.6.28/plugins/shared.make_timestamp.php: -------------------------------------------------------------------------------- 1 | 11 | * Purpose: used by other smarty functions to make a timestamp 12 | * from a string. 13 | * @author Monte Ohrt 14 | * @param string 15 | * @return string 16 | */ 17 | function smarty_make_timestamp($string) 18 | { 19 | if(empty($string)) { 20 | // use "now": 21 | $time = time(); 22 | 23 | } elseif (preg_match('/^\d{14}$/', $string)) { 24 | // it is mysql timestamp format of YYYYMMDDHHMMSS? 25 | $time = mktime(substr($string, 8, 2),substr($string, 10, 2),substr($string, 12, 2), 26 | substr($string, 4, 2),substr($string, 6, 2),substr($string, 0, 4)); 27 | 28 | } elseif (is_numeric($string)) { 29 | // it is a numeric string, we handle it as timestamp 30 | $time = (int)$string; 31 | 32 | } else { 33 | // strtotime should handle it 34 | $time = strtotime($string); 35 | if ($time == -1 || $time === false) { 36 | // strtotime() was not able to parse $string, use "now": 37 | $time = time(); 38 | } 39 | } 40 | return $time; 41 | 42 | } 43 | 44 | /* vim: set expandtab: */ 45 | 46 | ?> 47 | -------------------------------------------------------------------------------- /www/index.php: -------------------------------------------------------------------------------- 1 | display('page_index.txt'); 29 | -------------------------------------------------------------------------------- /www/javascript/.htaccess: -------------------------------------------------------------------------------- 1 | Options -Indexes -------------------------------------------------------------------------------- /www/javascript/html5.js: -------------------------------------------------------------------------------- 1 | /*! HTML5 Shiv vpre3.6 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 2 | Uncompressed source: https://github.com/aFarkas/html5shiv */ 3 | (function(a,b){function h(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function i(){var a=l.elements;return typeof a=="string"?a.split(" "):a}function j(a){var b={},c=a.createElement,f=a.createDocumentFragment,g=f();a.createElement=function(a){if(!l.shivMethods)return c(a);var f;return b[a]?f=b[a].cloneNode():e.test(a)?f=(b[a]=c(a)).cloneNode():f=c(a),f.canHaveChildren&&!d.test(a)?g.appendChild(f):f},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+i().join().replace(/\w+/g,function(a){return c(a),g.createElement(a),'c("'+a+'")'})+");return n}")(l,g)}function k(a){var b;return a.documentShived?a:(l.shivCSS&&!f&&(b=!!h(a,"article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio{display:none}canvas,video{display:inline-block;*display:inline;*zoom:1}[hidden]{display:none}audio[controls]{display:inline-block;*display:inline;*zoom:1}mark{background:#FF0;color:#000}")),g||(b=!j(a)),b&&(a.documentShived=b),a)}var c=a.html5||{},d=/^<|^(?:button|form|map|select|textarea|object|iframe|option|optgroup)$/i,e=/^<|^(?:a|b|button|code|div|fieldset|form|h1|h2|h3|h4|h5|h6|i|iframe|img|input|label|li|link|ol|option|p|param|q|script|select|span|strong|style|table|tbody|td|textarea|tfoot|th|thead|tr|ul)$/i,f,g;(function(){var c=b.createElement("a");c.innerHTML="",f="hidden"in c,f&&typeof injectElementWithStyles=="function"&&injectElementWithStyles("#modernizr{}",function(b){b.hidden=!0,f=(a.getComputedStyle?getComputedStyle(b,null):b.currentStyle).display=="none"}),g=c.childNodes.length==1||function(){try{b.createElement("a")}catch(a){return!0}var c=b.createDocumentFragment();return typeof c.cloneNode=="undefined"||typeof c.createDocumentFragment=="undefined"||typeof c.createElement=="undefined"}()})();var l={elements:c.elements||"abbr article aside audio bdi canvas data datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video",shivCSS:c.shivCSS!==!1,shivMethods:c.shivMethods!==!1,type:"default",shivDocument:k};a.html5=l,k(b)})(this,document) -------------------------------------------------------------------------------- /www/javascript/jquery.touchwipe.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * jQuery Plugin to obtain touch gestures from iPhone, iPod Touch and iPad, should also work with Android mobile phones (not tested yet!) 3 | * Common usage: wipe images (left and right to show the previous or next image) 4 | * 5 | * @author Andreas Waltl, netCU Internetagentur (http://www.netcu.de) 6 | * @version 1.1.1 (9th December 2010) - fix bug (older IE's had problems) 7 | * @version 1.1 (1st September 2010) - support wipe up and wipe down 8 | * @version 1.0 (15th July 2010) 9 | */ 10 | (function($){$.fn.touchwipe=function(settings){var config={min_move_x:20,min_move_y:20,wipeLeft:function(){},wipeRight:function(){},wipeUp:function(){},wipeDown:function(){},preventDefaultEvents:true};if(settings)$.extend(config,settings);this.each(function(){var startX;var startY;var isMoving=false;function cancelTouch(){this.removeEventListener('touchmove',onTouchMove);startX=null;isMoving=false}function onTouchMove(e){if(config.preventDefaultEvents){e.preventDefault()}if(isMoving){var x=e.touches[0].pageX;var y=e.touches[0].pageY;var dx=startX-x;var dy=startY-y;if(Math.abs(dx)>=config.min_move_x){cancelTouch();if(dx>0){config.wipeLeft()}else{config.wipeRight()}}else if(Math.abs(dy)>=config.min_move_y){cancelTouch();if(dy>0){config.wipeDown()}else{config.wipeUp()}}}}function onTouchStart(e){if(e.touches.length==1){startX=e.touches[0].pageX;startY=e.touches[0].pageY;isMoving=true;this.addEventListener('touchmove',onTouchMove,false)}}if('ontouchstart'in document.documentElement){this.addEventListener('touchstart',onTouchStart,false)}});return this}})(jQuery); -------------------------------------------------------------------------------- /www/paging.php: -------------------------------------------------------------------------------- 1 | 'Single page', 8 | 'total_count' => 5, 9 | 'page' => 1, 10 | 'per_page' => 10, 11 | 'page_count' => 1, 12 | ); 13 | 14 | $tests[] = array( 15 | 'name' => 'Page one of many', 16 | 'total_count' => 500, 17 | 'page' => 1, 18 | 'per_page' => 10, 19 | 'page_count' => 50, 20 | ); 21 | 22 | $tests[] = array( 23 | 'name' => 'Low page of many', 24 | 'total_count' => 500, 25 | 'page' => 3, 26 | 'per_page' => 10, 27 | 'page_count' => 50, 28 | ); 29 | 30 | $tests[] = array( 31 | 'name' => 'Mid page of many', 32 | 'total_count' => 500, 33 | 'page' => 12, 34 | 'per_page' => 10, 35 | 'page_count' => 50, 36 | ); 37 | 38 | $tests[] = array( 39 | 'name' => 'High page of many', 40 | 'total_count' => 500, 41 | 'page' => 48, 42 | 'per_page' => 10, 43 | 'page_count' => 50, 44 | ); 45 | 46 | $tests[] = array( 47 | 'name' => 'Last page of many', 48 | 'total_count' => 500, 49 | 'page' => 50, 50 | 'per_page' => 10, 51 | 'page_count' => 50, 52 | ); 53 | 54 | $smarty->assign('tests', $tests); 55 | 56 | $smarty->display('page_paging.txt'); 57 | -------------------------------------------------------------------------------- /www/reset.php: -------------------------------------------------------------------------------- 1 | assign('error_nouser', 1); 26 | $smarty->display('page_reset.txt'); 27 | exit(); 28 | } 29 | 30 | $smarty->assign('reset_code', $reset_code); 31 | 32 | if (post_isset('done')){ 33 | 34 | $new_password1 = post_str('new_password1'); 35 | $new_password2 = post_str('new_password2'); 36 | 37 | if ((! $new_password1) || (! $new_password2)){ 38 | 39 | $smarty->assign('error_missing_password', 1); 40 | $smarty->display('page_reset.txt'); 41 | exit(); 42 | } 43 | 44 | if ($new_password1 !== $new_password2){ 45 | 46 | $smarty->assign('error_password_mismatch', 1); 47 | $smarty->display('page_reset.txt'); 48 | exit(); 49 | } 50 | 51 | if (! users_update_password($user, $new_password1)){ 52 | 53 | $smarty->assign('error_update_failed', 1); 54 | $smarty->display('page_reset.txt'); 55 | exit(); 56 | } 57 | 58 | users_purge_password_reset_codes($user); 59 | 60 | $user = users_get_by_id($user['id']); 61 | 62 | login_do_login($user, "/account?password=1"); 63 | exit(); 64 | } 65 | 66 | 67 | # 68 | # output 69 | # 70 | 71 | $smarty->display('page_reset.txt'); 72 | -------------------------------------------------------------------------------- /www/signin.php: -------------------------------------------------------------------------------- 1 | assign('redir', $redir); 15 | 16 | 17 | # 18 | # try and sign in? 19 | # 20 | 21 | if (post_str('signin')){ 22 | 23 | $email = post_str('email'); 24 | $password = post_str('password'); 25 | 26 | $smarty->assign('email', $email); 27 | 28 | $ok = 1; 29 | 30 | 31 | # 32 | # required fields? 33 | # 34 | 35 | if ((!strlen($email)) || (!strlen($password))){ 36 | 37 | $smarty->assign('error_missing', 1); 38 | $ok = 0; 39 | } 40 | 41 | 42 | # 43 | # user exists? 44 | # 45 | 46 | if ($ok){ 47 | $user = users_get_by_email($email); 48 | 49 | if (!$user['id']){ 50 | 51 | $smarty->assign('error_nouser', 1); 52 | $ok = 0; 53 | } 54 | } 55 | 56 | 57 | # 58 | # users deleted? 59 | # 60 | 61 | if ($ok && $user['deleted']){ 62 | 63 | $smarty->assign('error_deleted', 1); 64 | $ok = 0; 65 | } 66 | 67 | 68 | # 69 | # password match 70 | # 71 | 72 | if ($ok){ 73 | 74 | if (! passwords_validate_password_for_user($password, $user)){ 75 | $smarty->assign('error_password', 1); 76 | $ok = 0; 77 | } 78 | } 79 | 80 | 81 | # 82 | # it's all good - sign in 83 | # 84 | 85 | if ($ok){ 86 | $redir = ($redir) ? $redir : '/'; 87 | 88 | login_do_login($user, $redir); 89 | exit; 90 | } 91 | } 92 | 93 | 94 | # 95 | # output 96 | # 97 | 98 | $smarty->display('page_signin.txt'); 99 | -------------------------------------------------------------------------------- /www/signout.php: -------------------------------------------------------------------------------- 1 | assign("crumb_key", $crumb_key); 13 | 14 | 15 | # 16 | # sign out? 17 | # 18 | 19 | if (post_isset('done') && crumb_check($crumb_key)){ 20 | 21 | login_do_logout(); 22 | 23 | $smarty->display('page_signout_done.txt'); 24 | exit; 25 | } 26 | 27 | 28 | # 29 | # output 30 | # 31 | 32 | $smarty->display("page_signout.txt"); 33 | -------------------------------------------------------------------------------- /www/signup.php: -------------------------------------------------------------------------------- 1 | assign('redir', request_str('redir')); 14 | 15 | 16 | # 17 | # are we signing up? 18 | # 19 | 20 | if (post_str('signup')){ 21 | 22 | $ok = 1; 23 | 24 | $email = post_str('email'); 25 | $password = post_str('password'); 26 | $username = post_str('username'); 27 | $redir = post_str('redir'); 28 | 29 | $smarty->assign('email', $email); 30 | $smarty->assign('password', $password); 31 | $smarty->assign('username', $username); 32 | $smarty->assign('redir', $redir); 33 | 34 | 35 | # 36 | # all fields are in order? 37 | # 38 | 39 | if ((!strlen($email)) || (!strlen($password)) || (!strlen($username))){ 40 | 41 | $smarty->assign('error_missing', 1); 42 | $ok = 0; 43 | } 44 | 45 | 46 | # 47 | # email available? 48 | # 49 | 50 | if ($ok && users_is_email_taken($email)){ 51 | 52 | $smarty->assign('email', ''); 53 | $smarty->assign('error_email_taken', 1); 54 | $ok = 0; 55 | } 56 | 57 | 58 | # 59 | # username available? 60 | # 61 | 62 | if ($ok && users_is_username_taken($username)){ 63 | 64 | $smarty->assign('username', ''); 65 | $smarty->assign('error_username_taken', 1); 66 | $ok = 0; 67 | } 68 | 69 | # 70 | # create account 71 | # 72 | 73 | if ($ok){ 74 | 75 | $ret = users_create_user(array( 76 | 'username' => $username, 77 | 'email' => $email, 78 | 'password' => $password, 79 | )); 80 | 81 | if ($ret['ok']){ 82 | 83 | $redir = strlen($redir) ? $redir : '/'; 84 | 85 | login_do_login($ret['user'], $redir); 86 | exit; 87 | } 88 | 89 | $smarty->assign('error_failed', 1); 90 | $ok = 0; 91 | } 92 | } 93 | 94 | 95 | # 96 | # output 97 | # 98 | 99 | $smarty->display('page_signup.txt'); 100 | -------------------------------------------------------------------------------- /www/templates/.htaccess: -------------------------------------------------------------------------------- 1 | Order Allow,Deny 2 | Allow from none 3 | Deny from all 4 | -------------------------------------------------------------------------------- /www/templates/email_contact.txt: -------------------------------------------------------------------------------- 1 | {assign var="email_subject" value="Contact form submission"} 2 | 3 | Name: {$name|escape} 4 | Email: {$email|escape} 5 | Message: {$message|escape} -------------------------------------------------------------------------------- /www/templates/email_password_reset.txt: -------------------------------------------------------------------------------- 1 | {assign var="email_subject" value="Reset your password"} 2 | 3 | You told us you forgot your password. If you really did, click here to choose a new one: 4 | 5 | {$cfg.abs_root_url}reset/{$code} 6 | 7 | If you didn't mean to reset your password, then you can just ignore this email; your password will not change. 8 | -------------------------------------------------------------------------------- /www/templates/inc_foot.txt: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 | 5 |
6 |

© Company {$smarty.now|date_format:"%Y"}

7 |
8 | 9 | {if $cfg.auth_roles.staff} 10 | {timings} 11 | {/if} 12 | 13 |
14 | 15 | 17 | 18 | 19 | 20 | 21 | {pagination_footer} 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /www/templates/inc_head.txt: -------------------------------------------------------------------------------- 1 | {utf8_headers} 2 | 3 | 4 | 5 | {$cfg.site_name|escape}{if $page_title} | {$page_title|escape}{/if} 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | {if $cfg.auth_roles.staff} 15 | 16 | {/if} 17 | 18 | 19 | 22 | 23 | 24 | 25 | 26 | 27 | 65 | -------------------------------------------------------------------------------- /www/templates/inc_pagination_nextprev.txt: -------------------------------------------------------------------------------- 1 |
    2 | {if $pagination.has_prev} 3 | 4 | {else} 5 | 6 | {/if} 7 | {if $pagination.has_next} 8 | 9 | {else} 10 | 11 | {/if} 12 |
13 | -------------------------------------------------------------------------------- /www/templates/inc_pagination_pretty.txt: -------------------------------------------------------------------------------- 1 | 2 | 26 | 27 | -------------------------------------------------------------------------------- /www/templates/inc_pagination_shortcuts.txt: -------------------------------------------------------------------------------- 1 | {if $cfg.pagination_touch_shortcuts} 2 | 3 | {/if} 4 | {/literal} 55 | -------------------------------------------------------------------------------- /www/templates/page_about.txt: -------------------------------------------------------------------------------- 1 | {include file='inc_head.txt' nav_tab='about'} 2 | 3 |
4 |

About

5 | 6 |

About page is happy now.

7 |
8 | 9 | {include file='inc_foot.txt'} 10 | -------------------------------------------------------------------------------- /www/templates/page_account.txt: -------------------------------------------------------------------------------- 1 | {assign var="page_title" value="Your account" nav_tab='account'} 2 | {include file="inc_head.txt"} 3 | 4 |
5 |

Your account

6 | 7 | {if $smarty.get.password}

Your password has been updated.

{/if} 8 | 9 | 13 |
14 | 15 | {include file="inc_foot.txt"} 16 | -------------------------------------------------------------------------------- /www/templates/page_account_delete.txt: -------------------------------------------------------------------------------- 1 | {assign var='page_title' value="Delete your account" nav_tab='account'} 2 | {include file="inc_head.txt"} 3 | 4 |
5 | {if $error_deleting}

Something went wrong. Try again later pls.

{/if} 6 | 7 |

Are you sure you want to delete your account?

8 | 9 |
10 | 11 | {$crumb_key|crumb_input} 12 | 13 | 14 |
15 |
16 | 17 | {include file="inc_foot.txt"} 18 | -------------------------------------------------------------------------------- /www/templates/page_account_delete_confirm.txt: -------------------------------------------------------------------------------- 1 | {assign var='page_title' value="Delete your account" nav_tab='account'} 2 | {include file="inc_head.txt"} 3 | 4 |
5 |

Are you really sure you want to delete your account?

6 | 7 |
8 | 9 | {$crumb_key|crumb_input} 10 | 11 |
12 | 15 | 16 | 17 |
18 |
19 |
20 | 21 | {include file="inc_foot.txt"} 22 | -------------------------------------------------------------------------------- /www/templates/page_account_delete_done.txt: -------------------------------------------------------------------------------- 1 | {assign var='page_title' value="Delete your account" nav_tab='account'} 2 | {include file="inc_head.txt"} 3 | 4 |
5 |

Your account has been deleted.

6 |
7 | 8 | {include file="inc_foot.txt"} 9 | -------------------------------------------------------------------------------- /www/templates/page_account_password.txt: -------------------------------------------------------------------------------- 1 | {assign var="page_title" value="Change your password" nav_tab='account'} 2 | {include file="inc_head.txt"} 3 | 4 |
5 | 6 |

Change your password

7 | 8 | {if $error_oldpass_mismatch}

Incorrect old password.

{/if} 9 | {if $error_newpass_empty}

Please choose a new password.

{/if} 10 | {if $error_newpass_mismatch}

Your new passwords need to match.

{/if} 11 | {if $error_fail}

Unknown failure :(

{/if} 12 | 13 |
14 | 15 | {$crumb_key|crumb_input} 16 | 17 |
18 | 19 |
20 |
21 | 22 |
23 | 24 |
25 |
26 | 27 |
28 | 29 |
30 |
31 | 32 |
33 |
34 |
35 |
36 | 37 |
38 | 39 | {include file="inc_foot.txt"} 40 | -------------------------------------------------------------------------------- /www/templates/page_contact.txt: -------------------------------------------------------------------------------- 1 | {include file='inc_head.txt' nav_tab='contact'} 2 | 3 |
4 |

Contact

5 | 6 | {if $error_missing}

Please fill out all the fields

{/if} 7 | {if $smarty.get.sent}

Your message has been sent. Thanks!

{/if} 8 | 9 |

Here is a form that sends an email when it is submitted.

10 | 11 |
12 | 13 | 14 |
15 |
16 | 17 |
18 | 19 |
20 |
21 | 22 |
23 | 24 |
25 | 26 |
27 |
28 | 29 |
30 | 31 |
32 | 33 |
34 |
35 | 36 |
37 | 38 |
39 |
40 |
41 |
42 | 43 | {include file='inc_foot.txt'} 44 | -------------------------------------------------------------------------------- /www/templates/page_error_403.txt: -------------------------------------------------------------------------------- 1 | {"HTTP/1.1 403 Forbidden"|header}{include file='inc_head.txt' page_title='Permission Denied'} 2 | 3 |
4 |

Page not available

5 | 6 |

Sorry, you do not have permission to view this page.

7 | 8 | {if $cfg.auth_roles.staff} 9 |
10 |
{$debug_block}
11 |
12 | {/if} 13 | 14 |
15 | 16 | {include file='inc_foot.txt'} 17 | -------------------------------------------------------------------------------- /www/templates/page_error_404.txt: -------------------------------------------------------------------------------- 1 | {"HTTP/1.1 404 Not Found"|header}{include file='inc_head.txt' page_title='Page Not Found'} 2 | 3 |
4 |

Page not found

5 | 6 |

We can't find the page you requested. Sorry :(

7 | 8 | {if $cfg.auth_roles.staff} 9 |
10 |
{$debug_block}
11 |
12 | {/if} 13 | 14 |
15 | 16 | {include file='inc_foot.txt'} 17 | -------------------------------------------------------------------------------- /www/templates/page_error_410.txt: -------------------------------------------------------------------------------- 1 | {"HTTP/1.1 410 Gone"|header}{include file='inc_head.txt' page_title='All gone. Bye bye!'} 2 | 3 |
4 | 5 |

This page doesn't exist anymore. Poof!

6 | 7 | {if $message} 8 |

{$message|escape}

9 | {/if} 10 | 11 | {if $cfg.auth_roles.staff} 12 |
13 |
{$debug_block}
14 |
15 | {/if} 16 | 17 |
18 | 19 | {include file='inc_foot.txt'} 20 | -------------------------------------------------------------------------------- /www/templates/page_error_500.txt: -------------------------------------------------------------------------------- 1 | {"HTTP/1.1 500 Server Error"|header}{include file='inc_head.txt' page_title='Server Error'} 2 | 3 |
4 | 5 |

Server Error

6 | 7 |

There was a problem completing your request. We're looking in to it. Sorry :(

8 | 9 | {if $cfg.auth_roles.staff} 10 |
11 |
{$debug_block}
12 |
13 | {/if} 14 | 15 |
16 | 17 | {include file='inc_foot.txt'} 18 | -------------------------------------------------------------------------------- /www/templates/page_error_cookie.txt: -------------------------------------------------------------------------------- 1 | {include file="inc_head.txt"} 2 | 3 |
4 | 5 |

Unable to set cookie

6 | 7 |

You need to enable cookies to sign in.

8 |

Once you've done this, you can try to sign in again.

9 | 10 |
11 | 12 | {include file="inc_foot.txt"} 13 | -------------------------------------------------------------------------------- /www/templates/page_feature_disabled.txt: -------------------------------------------------------------------------------- 1 | {include file="inc_head.txt"} 2 | 3 |
4 | {* http://stosberg.net/unicode/crying-cat-face/codepoint/128575/ *} 5 |

😿 This part of the site is currently disabled. Sad face.

6 |
7 | 8 | {include file="inc_foot.txt"} 9 | -------------------------------------------------------------------------------- /www/templates/page_forgot.txt: -------------------------------------------------------------------------------- 1 | {assign var="page_title" value="Forgot your password?" nav_tab='signin'} 2 | {include file="inc_head.txt"} 3 | 4 |
5 | {if $error_nouser}

We can't find an account registered with that address.

{/if} 6 | {if $error_deleted}

Your account has been deleted.

{/if} 7 | {if $error_notsent}

Something went wrong :(

{/if} 8 | 9 | 10 |
11 | 12 | 13 |
14 |
15 | 16 |
17 | 18 |
19 |
20 | 21 |
22 | 23 |
24 |
25 |
26 |
27 | 28 | {include file="inc_foot.txt"} 29 | -------------------------------------------------------------------------------- /www/templates/page_forgot_sent.txt: -------------------------------------------------------------------------------- 1 | {assign var="page_title" value="Forgot your password?" nav_tab='signin'} 2 | {include file="inc_head.txt"} 3 | 4 |
5 |

A password reminder has been sent to {$sent_to|escape}.

6 |
7 | 8 | {include file="inc_foot.txt"} 9 | -------------------------------------------------------------------------------- /www/templates/page_index.txt: -------------------------------------------------------------------------------- 1 | {include file='inc_head.txt' nav_tab='home'} 2 | 3 |
4 |
5 |

Flamework

6 |

OK, looks like you got it installed. You win one (1) Internets.

7 | 11 |
12 |
13 | 14 | {include file='inc_foot.txt'} 15 | -------------------------------------------------------------------------------- /www/templates/page_paging.txt: -------------------------------------------------------------------------------- 1 | {include file='inc_head.txt'} 2 | 3 |
4 |

Pagination tests

5 | 6 | {foreach from=$tests item='row'} 7 |

{$row.name}:

8 |
9 | {pagination pagination=$row} 10 |
11 |
12 | {pagination pagination=$row style='nextprev'} 13 |
14 | {/foreach} 15 | 16 | 17 |
18 | 19 | {include file='inc_foot.txt'} 20 | -------------------------------------------------------------------------------- /www/templates/page_reset.txt: -------------------------------------------------------------------------------- 1 | {assign var="page_title" value="Reset your password"} 2 | {include file="inc_head.txt"} 3 | 4 |

This doesn't work very well yet

5 | 6 | {* very bad errors *} 7 | 8 | {if $error_nouser} 9 |

NO USER.

10 | {elseif $error_update_failed} 11 |

UPDATE FAILED.

12 | {else} 13 | 14 | {* user errors *} 15 | 16 | {if $error|@count} 17 |

18 | {if $error_missing_password} 19 | MISSING. 20 | {elseif $error_password_mismatch} 21 | MISMATCH. 22 | {else} 23 | INVISIBLE ERROR CAT HISSES AT YOU! 24 |

25 | {/if} 26 | {/if} 27 | 28 |

Please enter your new password

29 | 30 |
31 | 32 |
33 |
34 | 35 |
36 | {/if} 37 | 38 | {include file="inc_foot.txt"} 39 | -------------------------------------------------------------------------------- /www/templates/page_signin.txt: -------------------------------------------------------------------------------- 1 | {assign var='page_title' value='Sign in' nav_tab='signin'} 2 | {include file='inc_head.txt'} 3 | 4 |
5 | {if $error_missing}

Please enter your email address and password.

{/if} 6 | {if $error_nouser}

Sorry, we can't find an account with that email address.

{/if} 7 | {if $error_deleted}

Account has been deleted.

{/if} 8 | {if $error_password}

Incorrect password.

{/if} 9 | 10 |
11 | 12 | 13 | 14 |
15 |
16 | 17 |
18 | 19 |
20 |
21 | 22 |
23 | 24 |
25 | 26 |
27 |
28 | 29 |
30 | 31 |
32 |
33 |
34 | 35 | {if $cfg.enable_feature_password_retrieval} 36 |

Forgotten your password?

37 | {/if} 38 |
39 | 40 | {include file='inc_foot.txt'} 41 | -------------------------------------------------------------------------------- /www/templates/page_signin_disabled.txt: -------------------------------------------------------------------------------- 1 | {assign var='page_title' value='Sign in' nav_tab='signin'} 2 | {include file='inc_head.txt'} 3 | 4 |
5 |

Sign ins are currently disabled.

6 |
7 | 8 | {include file='inc_foot.txt'} 9 | -------------------------------------------------------------------------------- /www/templates/page_signout.txt: -------------------------------------------------------------------------------- 1 | {assign var='page_title' value='Sign out' nav_tab='account'} 2 | {include file='inc_head.txt'} 3 | 4 |
5 |

This is an intermediate page so that we can generate and check a crumb. We will inline this into the URL shortly.

6 | 7 |
8 | {$crumb_key|crumb_input} 9 | 10 | 11 |
12 |
13 | 14 | {include file='inc_foot.txt'} 15 | -------------------------------------------------------------------------------- /www/templates/page_signout_done.txt: -------------------------------------------------------------------------------- 1 | {assign var='page_title' value='Sign out' nav_tab='signout'} 2 | {include file='inc_head.txt'} 3 | 4 |
5 |

You are signed out!

6 |
7 | 8 | {include file='inc_foot.txt'} 9 | -------------------------------------------------------------------------------- /www/templates/page_signup.txt: -------------------------------------------------------------------------------- 1 | {assign var='page_title' value='Sign up for a new account' nav_tab='signup'} 2 | {include file='inc_head.txt'} 3 | 4 |
5 | {if $error_missing}

Please fill out all the fields

{/if} 6 | {if $error_email_taken}

Email address already registered.

{/if} 7 | {if $error_username_taken}

Username is taken.

{/if} 8 | {if $error_failed}

Failed for an unknown reason :(

{/if} 9 | 10 |
11 | 12 | 13 | 14 |
15 |
16 | 17 |
18 | 19 |
20 |
21 | 22 |
23 | 24 |
25 | 26 |
27 |
28 | 29 |
30 | 31 |
32 | 33 |
34 |
35 | 36 |
37 | 38 |
39 |
40 |
41 |
42 | 43 | {include file='inc_foot.txt'} 44 | -------------------------------------------------------------------------------- /www/templates/page_signup_disabled.txt: -------------------------------------------------------------------------------- 1 | {assign var='page_title' value='Sign up for a new account' nav_tab='signup'} 2 | {include file='inc_head.txt'} 3 | 4 |
5 |

Signups are currently disabled

6 |
7 | 8 | {include file='inc_foot.txt'} 9 | -------------------------------------------------------------------------------- /www/templates/page_site_disabled.txt: -------------------------------------------------------------------------------- 1 | {include file="inc_head.txt"} 2 | 3 |
4 |

This website is currently disabled and will return shortly.

5 |
6 | 7 | {include file="inc_foot.txt"} 8 | -------------------------------------------------------------------------------- /www/templates_c/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.php -------------------------------------------------------------------------------- /www/templates_c/.htaccess: -------------------------------------------------------------------------------- 1 | Order Allow,Deny 2 | Allow from none 3 | Deny from all 4 | --------------------------------------------------------------------------------