diff --git a/sources/.htaccess b/sources/.htaccess
new file mode 100644
index 00000000..7f393511
--- /dev/null
+++ b/sources/.htaccess
@@ -0,0 +1,30 @@
+Options -Indexes
+AddType application/x-java-archive .jar
+AddType audio/ogg .oga
+#SSLCipherSuite HIGH:AES256-SHA:AES128-SHA:RC4:!aNULL:!eNULL:!EDH
+
+# don't allow any web access to logfiles, even after rotation/compression
+
+
+ Require all denied
+
+
+ Order deny,allow
+ Deny from all
+
+
+
+
+ RewriteEngine on
+ # Protect repository directory from browsing
+ RewriteRule "(^|/)\.git" - [F]
+ RewriteRule "(^|/)store" - [F]
+
+ # Rewrite current-style URLs of the form 'index.php?q=x'.
+ # Also place auth information into REMOTE_USER for sites running
+ # in CGI mode.
+
+ RewriteCond %{REQUEST_FILENAME} !-f
+ RewriteCond %{REQUEST_FILENAME} !-d
+ RewriteRule ^(.*)$ index.php?q=$1 [E=REMOTE_USER:%{HTTP:Authorization},L,QSA]
+
diff --git a/sources/LICENSE b/sources/LICENSE
new file mode 100644
index 00000000..40cc07bb
--- /dev/null
+++ b/sources/LICENSE
@@ -0,0 +1,20 @@
+Copyright (c) 2010-2015 Hubzilla
+All rights reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/sources/README.md b/sources/README.md
new file mode 100644
index 00000000..ac62f721
--- /dev/null
+++ b/sources/README.md
@@ -0,0 +1,39 @@
+
+Hubzilla
+========
+
+###Websites. Redefined.
+
+
+![Hubzilla](images/ghash-32.png)
+
+**What are Hubs?**
+
+Hubs are independent general-purpose websites that not only connect with their associated members and viewers, but also connect together to exchange personal communications and other information with each other.
+This allows hub members on any hub to securely and privately share anything; with anybody, on any hub - anywhere; or share stuff publicly with anybody on the internet if desired.
+
+**Hubzilla** is the server software which makes this possible. It is a sophisticated and unique combination of an open source content management system and a decentralised identity, communications, and permissions framework and protocol suite, built using common webserver technology (PHP/MySQL/Apache, although Mariadb or Postgres and Nginx could also be used - we're pretty easy). The end result is a level of systems integration, privacy control, and communications features that you wouldn't think are possible in either a content management system or a decentralised communications network. It also brings a new level of cooperation and privacy to the web and introduces the concept of personally owned "single sign-on" to web services across the entire internet.
+
+Hubzilla hubs are
+
+* decentralised
+* inherently social
+* optionally inter-networked with other hubs
+* privacy-enabled (privacy exclusions work across the entire internet to any registered identity on any compatible hubs)
+
+Possible website applications include
+
+* decentralised social networking nodes
+* personal cloud storage
+* file dropboxes
+* managing organisational communications and activities
+* collaboration and community decision-making
+* small business websites
+* public and private media/file libraries
+* blogs
+* event promotion
+* feed aggregation and republishing
+* forums
+* dating websites
+* pretty much anything you can do on a traditional blog or community website, but that you could do better if you could easily connect it with other websites or privately share things across website boundaries.
+
diff --git a/sources/addon/adultphotoflag b/sources/addon/adultphotoflag
new file mode 120000
index 00000000..33607d83
--- /dev/null
+++ b/sources/addon/adultphotoflag
@@ -0,0 +1 @@
+../extend/addon/matrix/adultphotoflag
\ No newline at end of file
diff --git a/sources/addon/bbmath b/sources/addon/bbmath
new file mode 120000
index 00000000..86ee3399
--- /dev/null
+++ b/sources/addon/bbmath
@@ -0,0 +1 @@
+../extend/addon/matrix/bbmath
\ No newline at end of file
diff --git a/sources/addon/bookmarker b/sources/addon/bookmarker
new file mode 120000
index 00000000..261dacde
--- /dev/null
+++ b/sources/addon/bookmarker
@@ -0,0 +1 @@
+../extend/addon/matrix/bookmarker
\ No newline at end of file
diff --git a/sources/addon/buglink b/sources/addon/buglink
new file mode 120000
index 00000000..2f80f00f
--- /dev/null
+++ b/sources/addon/buglink
@@ -0,0 +1 @@
+../extend/addon/matrix/buglink
\ No newline at end of file
diff --git a/sources/addon/calc b/sources/addon/calc
new file mode 120000
index 00000000..9a1a36ec
--- /dev/null
+++ b/sources/addon/calc
@@ -0,0 +1 @@
+../extend/addon/matrix/calc
\ No newline at end of file
diff --git a/sources/addon/chords b/sources/addon/chords
new file mode 120000
index 00000000..c6304590
--- /dev/null
+++ b/sources/addon/chords
@@ -0,0 +1 @@
+../extend/addon/matrix/chords
\ No newline at end of file
diff --git a/sources/addon/custom_home b/sources/addon/custom_home
new file mode 120000
index 00000000..8a28b982
--- /dev/null
+++ b/sources/addon/custom_home
@@ -0,0 +1 @@
+../extend/addon/matrix/custom_home
\ No newline at end of file
diff --git a/sources/addon/diaspora b/sources/addon/diaspora
new file mode 120000
index 00000000..fa8d50c9
--- /dev/null
+++ b/sources/addon/diaspora
@@ -0,0 +1 @@
+../extend/addon/matrix/diaspora
\ No newline at end of file
diff --git a/sources/addon/diaspost b/sources/addon/diaspost
new file mode 120000
index 00000000..d846a76c
--- /dev/null
+++ b/sources/addon/diaspost
@@ -0,0 +1 @@
+../extend/addon/matrix/diaspost
\ No newline at end of file
diff --git a/sources/addon/dirstats b/sources/addon/dirstats
new file mode 120000
index 00000000..06de79c6
--- /dev/null
+++ b/sources/addon/dirstats
@@ -0,0 +1 @@
+../extend/addon/matrix/dirstats
\ No newline at end of file
diff --git a/sources/addon/donate b/sources/addon/donate
new file mode 120000
index 00000000..3081929f
--- /dev/null
+++ b/sources/addon/donate
@@ -0,0 +1 @@
+../extend/addon/matrix/donate
\ No newline at end of file
diff --git a/sources/addon/dwpost b/sources/addon/dwpost
new file mode 120000
index 00000000..b662c5bb
--- /dev/null
+++ b/sources/addon/dwpost
@@ -0,0 +1 @@
+../extend/addon/matrix/dwpost
\ No newline at end of file
diff --git a/sources/addon/embedly b/sources/addon/embedly
new file mode 120000
index 00000000..5963a57e
--- /dev/null
+++ b/sources/addon/embedly
@@ -0,0 +1 @@
+../extend/addon/matrix/embedly
\ No newline at end of file
diff --git a/sources/addon/extcron b/sources/addon/extcron
new file mode 120000
index 00000000..2d02ef89
--- /dev/null
+++ b/sources/addon/extcron
@@ -0,0 +1 @@
+../extend/addon/matrix/extcron
\ No newline at end of file
diff --git a/sources/addon/flattrwidget b/sources/addon/flattrwidget
new file mode 120000
index 00000000..8f227dec
--- /dev/null
+++ b/sources/addon/flattrwidget
@@ -0,0 +1 @@
+../extend/addon/matrix/flattrwidget
\ No newline at end of file
diff --git a/sources/addon/fortunate b/sources/addon/fortunate
new file mode 120000
index 00000000..9a51f156
--- /dev/null
+++ b/sources/addon/fortunate
@@ -0,0 +1 @@
+../extend/addon/matrix/fortunate
\ No newline at end of file
diff --git a/sources/addon/frphotos b/sources/addon/frphotos
new file mode 120000
index 00000000..55d3abd8
--- /dev/null
+++ b/sources/addon/frphotos
@@ -0,0 +1 @@
+../extend/addon/matrix/frphotos
\ No newline at end of file
diff --git a/sources/addon/hexit b/sources/addon/hexit
new file mode 120000
index 00000000..1c2ccebe
--- /dev/null
+++ b/sources/addon/hexit
@@ -0,0 +1 @@
+../extend/addon/matrix/hexit
\ No newline at end of file
diff --git a/sources/addon/ijpost b/sources/addon/ijpost
new file mode 120000
index 00000000..3ec48761
--- /dev/null
+++ b/sources/addon/ijpost
@@ -0,0 +1 @@
+../extend/addon/matrix/ijpost
\ No newline at end of file
diff --git a/sources/addon/irc b/sources/addon/irc
new file mode 120000
index 00000000..22c5bb8e
--- /dev/null
+++ b/sources/addon/irc
@@ -0,0 +1 @@
+../extend/addon/matrix/irc
\ No newline at end of file
diff --git a/sources/addon/jappixmini b/sources/addon/jappixmini
new file mode 120000
index 00000000..8c035194
--- /dev/null
+++ b/sources/addon/jappixmini
@@ -0,0 +1 @@
+../extend/addon/matrix/jappixmini
\ No newline at end of file
diff --git a/sources/addon/js_upload b/sources/addon/js_upload
new file mode 120000
index 00000000..49d474bc
--- /dev/null
+++ b/sources/addon/js_upload
@@ -0,0 +1 @@
+../extend/addon/matrix/js_upload
\ No newline at end of file
diff --git a/sources/addon/ldapauth b/sources/addon/ldapauth
new file mode 120000
index 00000000..3ca0d37b
--- /dev/null
+++ b/sources/addon/ldapauth
@@ -0,0 +1 @@
+../extend/addon/matrix/ldapauth
\ No newline at end of file
diff --git a/sources/addon/libertree b/sources/addon/libertree
new file mode 120000
index 00000000..7b5bbdf2
--- /dev/null
+++ b/sources/addon/libertree
@@ -0,0 +1 @@
+../extend/addon/matrix/libertree
\ No newline at end of file
diff --git a/sources/addon/likebanner b/sources/addon/likebanner
new file mode 120000
index 00000000..7e971707
--- /dev/null
+++ b/sources/addon/likebanner
@@ -0,0 +1 @@
+../extend/addon/matrix/likebanner
\ No newline at end of file
diff --git a/sources/addon/ljpost b/sources/addon/ljpost
new file mode 120000
index 00000000..55a53bc7
--- /dev/null
+++ b/sources/addon/ljpost
@@ -0,0 +1 @@
+../extend/addon/matrix/ljpost
\ No newline at end of file
diff --git a/sources/addon/mahjongg b/sources/addon/mahjongg
new file mode 120000
index 00000000..0d6939f0
--- /dev/null
+++ b/sources/addon/mahjongg
@@ -0,0 +1 @@
+../extend/addon/matrix/mahjongg
\ No newline at end of file
diff --git a/sources/addon/mailhost b/sources/addon/mailhost
new file mode 120000
index 00000000..fcfe7066
--- /dev/null
+++ b/sources/addon/mailhost
@@ -0,0 +1 @@
+../extend/addon/matrix/mailhost
\ No newline at end of file
diff --git a/sources/addon/morechoice b/sources/addon/morechoice
new file mode 120000
index 00000000..b91fbcae
--- /dev/null
+++ b/sources/addon/morechoice
@@ -0,0 +1 @@
+../extend/addon/matrix/morechoice
\ No newline at end of file
diff --git a/sources/addon/moremoods b/sources/addon/moremoods
new file mode 120000
index 00000000..565a7690
--- /dev/null
+++ b/sources/addon/moremoods
@@ -0,0 +1 @@
+../extend/addon/matrix/moremoods
\ No newline at end of file
diff --git a/sources/addon/nofed b/sources/addon/nofed
new file mode 120000
index 00000000..587029da
--- /dev/null
+++ b/sources/addon/nofed
@@ -0,0 +1 @@
+../extend/addon/matrix/nofed
\ No newline at end of file
diff --git a/sources/addon/nsabait b/sources/addon/nsabait
new file mode 120000
index 00000000..8f56590c
--- /dev/null
+++ b/sources/addon/nsabait
@@ -0,0 +1 @@
+../extend/addon/matrix/nsabait
\ No newline at end of file
diff --git a/sources/addon/nsfw b/sources/addon/nsfw
new file mode 120000
index 00000000..298fbb78
--- /dev/null
+++ b/sources/addon/nsfw
@@ -0,0 +1 @@
+../extend/addon/matrix/nsfw
\ No newline at end of file
diff --git a/sources/addon/openclipatar b/sources/addon/openclipatar
new file mode 120000
index 00000000..32884213
--- /dev/null
+++ b/sources/addon/openclipatar
@@ -0,0 +1 @@
+../extend/addon/matrix/openclipatar
\ No newline at end of file
diff --git a/sources/addon/openstreetmap b/sources/addon/openstreetmap
new file mode 120000
index 00000000..db03b9df
--- /dev/null
+++ b/sources/addon/openstreetmap
@@ -0,0 +1 @@
+../extend/addon/matrix/openstreetmap
\ No newline at end of file
diff --git a/sources/addon/piwik b/sources/addon/piwik
new file mode 120000
index 00000000..302a0298
--- /dev/null
+++ b/sources/addon/piwik
@@ -0,0 +1 @@
+../extend/addon/matrix/piwik
\ No newline at end of file
diff --git a/sources/addon/planets b/sources/addon/planets
new file mode 120000
index 00000000..40fec349
--- /dev/null
+++ b/sources/addon/planets
@@ -0,0 +1 @@
+../extend/addon/matrix/planets
\ No newline at end of file
diff --git a/sources/addon/pumpio b/sources/addon/pumpio
new file mode 120000
index 00000000..0c304c4f
--- /dev/null
+++ b/sources/addon/pumpio
@@ -0,0 +1 @@
+../extend/addon/matrix/pumpio
\ No newline at end of file
diff --git a/sources/addon/qrator b/sources/addon/qrator
new file mode 120000
index 00000000..8aa7e9b0
--- /dev/null
+++ b/sources/addon/qrator
@@ -0,0 +1 @@
+../extend/addon/matrix/qrator
\ No newline at end of file
diff --git a/sources/addon/rainbowtag b/sources/addon/rainbowtag
new file mode 120000
index 00000000..492850e4
--- /dev/null
+++ b/sources/addon/rainbowtag
@@ -0,0 +1 @@
+../extend/addon/matrix/rainbowtag
\ No newline at end of file
diff --git a/sources/addon/randpost b/sources/addon/randpost
new file mode 120000
index 00000000..4cd3e6e8
--- /dev/null
+++ b/sources/addon/randpost
@@ -0,0 +1 @@
+../extend/addon/matrix/randpost
\ No newline at end of file
diff --git a/sources/addon/redphotos b/sources/addon/redphotos
new file mode 120000
index 00000000..93fa601a
--- /dev/null
+++ b/sources/addon/redphotos
@@ -0,0 +1 @@
+../extend/addon/matrix/redphotos
\ No newline at end of file
diff --git a/sources/addon/redred b/sources/addon/redred
new file mode 120000
index 00000000..3b7076b3
--- /dev/null
+++ b/sources/addon/redred
@@ -0,0 +1 @@
+../extend/addon/matrix/redred
\ No newline at end of file
diff --git a/sources/addon/rtof b/sources/addon/rtof
new file mode 120000
index 00000000..77eb18b9
--- /dev/null
+++ b/sources/addon/rtof
@@ -0,0 +1 @@
+../extend/addon/matrix/rtof
\ No newline at end of file
diff --git a/sources/addon/sendzid b/sources/addon/sendzid
new file mode 120000
index 00000000..0c4087fa
--- /dev/null
+++ b/sources/addon/sendzid
@@ -0,0 +1 @@
+../extend/addon/matrix/sendzid
\ No newline at end of file
diff --git a/sources/addon/smiley_pack b/sources/addon/smiley_pack
new file mode 120000
index 00000000..861a674f
--- /dev/null
+++ b/sources/addon/smiley_pack
@@ -0,0 +1 @@
+../extend/addon/matrix/smiley_pack
\ No newline at end of file
diff --git a/sources/addon/smileybutton b/sources/addon/smileybutton
new file mode 120000
index 00000000..59940c4f
--- /dev/null
+++ b/sources/addon/smileybutton
@@ -0,0 +1 @@
+../extend/addon/matrix/smileybutton
\ No newline at end of file
diff --git a/sources/addon/startpage b/sources/addon/startpage
new file mode 120000
index 00000000..63cd7668
--- /dev/null
+++ b/sources/addon/startpage
@@ -0,0 +1 @@
+../extend/addon/matrix/startpage
\ No newline at end of file
diff --git a/sources/addon/statistics_json b/sources/addon/statistics_json
new file mode 120000
index 00000000..2f7b9159
--- /dev/null
+++ b/sources/addon/statistics_json
@@ -0,0 +1 @@
+../extend/addon/matrix/statistics_json
\ No newline at end of file
diff --git a/sources/addon/statusnet b/sources/addon/statusnet
new file mode 120000
index 00000000..d0006418
--- /dev/null
+++ b/sources/addon/statusnet
@@ -0,0 +1 @@
+../extend/addon/matrix/statusnet
\ No newline at end of file
diff --git a/sources/addon/superblock b/sources/addon/superblock
new file mode 120000
index 00000000..bf1e746f
--- /dev/null
+++ b/sources/addon/superblock
@@ -0,0 +1 @@
+../extend/addon/matrix/superblock
\ No newline at end of file
diff --git a/sources/addon/tictac b/sources/addon/tictac
new file mode 120000
index 00000000..a8c9ac94
--- /dev/null
+++ b/sources/addon/tictac
@@ -0,0 +1 @@
+../extend/addon/matrix/tictac
\ No newline at end of file
diff --git a/sources/addon/torch b/sources/addon/torch
new file mode 120000
index 00000000..575d236e
--- /dev/null
+++ b/sources/addon/torch
@@ -0,0 +1 @@
+../extend/addon/matrix/torch
\ No newline at end of file
diff --git a/sources/addon/tour b/sources/addon/tour
new file mode 120000
index 00000000..39fef8f0
--- /dev/null
+++ b/sources/addon/tour
@@ -0,0 +1 @@
+../extend/addon/matrix/tour
\ No newline at end of file
diff --git a/sources/addon/twitter b/sources/addon/twitter
new file mode 120000
index 00000000..6be8e2dc
--- /dev/null
+++ b/sources/addon/twitter
@@ -0,0 +1 @@
+../extend/addon/matrix/twitter
\ No newline at end of file
diff --git a/sources/addon/upload_limits b/sources/addon/upload_limits
new file mode 120000
index 00000000..4281a12a
--- /dev/null
+++ b/sources/addon/upload_limits
@@ -0,0 +1 @@
+../extend/addon/matrix/upload_limits
\ No newline at end of file
diff --git a/sources/addon/visage b/sources/addon/visage
new file mode 120000
index 00000000..3d5d20ef
--- /dev/null
+++ b/sources/addon/visage
@@ -0,0 +1 @@
+../extend/addon/matrix/visage
\ No newline at end of file
diff --git a/sources/addon/wppost b/sources/addon/wppost
new file mode 120000
index 00000000..3ac8fbc0
--- /dev/null
+++ b/sources/addon/wppost
@@ -0,0 +1 @@
+../extend/addon/matrix/wppost
\ No newline at end of file
diff --git a/sources/app/admin.apd b/sources/app/admin.apd
new file mode 100644
index 00000000..dbd2f697
--- /dev/null
+++ b/sources/app/admin.apd
@@ -0,0 +1,4 @@
+url: $baseurl/admin
+requires: admin
+name: Site Admin
+photo: $baseurl/app/admin.png
diff --git a/sources/app/admin.png b/sources/app/admin.png
new file mode 100644
index 00000000..cde922e8
Binary files /dev/null and b/sources/app/admin.png differ
diff --git a/sources/app/bookmarks.apd b/sources/app/bookmarks.apd
new file mode 100644
index 00000000..9581a220
--- /dev/null
+++ b/sources/app/bookmarks.apd
@@ -0,0 +1,4 @@
+url: $baseurl/bookmarks
+requires: local_channel
+name: View bookmarks
+photo: $baseurl/app/bookmarks.png
diff --git a/sources/app/bookmarks.png b/sources/app/bookmarks.png
new file mode 100644
index 00000000..fffad332
Binary files /dev/null and b/sources/app/bookmarks.png differ
diff --git a/sources/app/bugreport.apd b/sources/app/bugreport.apd
new file mode 100644
index 00000000..3714f062
--- /dev/null
+++ b/sources/app/bugreport.apd
@@ -0,0 +1,3 @@
+url: https://github.com/redmatrix/hubzilla/issues
+name: Bug Report
+photo: $baseurl/app/bugreport.png
diff --git a/sources/app/bugreport.png b/sources/app/bugreport.png
new file mode 100644
index 00000000..4b59da18
Binary files /dev/null and b/sources/app/bugreport.png differ
diff --git a/sources/app/channel.apd b/sources/app/channel.apd
new file mode 100644
index 00000000..0b5400ae
--- /dev/null
+++ b/sources/app/channel.apd
@@ -0,0 +1,4 @@
+url: $baseurl/channel/$nick
+requires: local_channel
+name: Channel Home
+photo: $baseurl/app/home.png
diff --git a/sources/app/chat.apd b/sources/app/chat.apd
new file mode 100644
index 00000000..d4879c0b
--- /dev/null
+++ b/sources/app/chat.apd
@@ -0,0 +1,4 @@
+url: $baseurl/chat/$nick
+requires: local_channel
+name: My chatrooms
+photo: $baseurl/app/chat.png
diff --git a/sources/app/chat.png b/sources/app/chat.png
new file mode 100644
index 00000000..9d3fdebd
Binary files /dev/null and b/sources/app/chat.png differ
diff --git a/sources/app/connections.apd b/sources/app/connections.apd
new file mode 100644
index 00000000..f4b5ad87
--- /dev/null
+++ b/sources/app/connections.apd
@@ -0,0 +1,4 @@
+url: $baseurl/connections
+requires: local_channel
+name: Connections
+photo: $baseurl/app/connections.png
diff --git a/sources/app/connections.png b/sources/app/connections.png
new file mode 100644
index 00000000..6f610076
Binary files /dev/null and b/sources/app/connections.png differ
diff --git a/sources/app/directory.apd b/sources/app/directory.apd
new file mode 100644
index 00000000..c4a6f12d
--- /dev/null
+++ b/sources/app/directory.apd
@@ -0,0 +1,3 @@
+url: $baseurl/directory
+name: Directory
+photo: $baseurl/app/directory.png
diff --git a/sources/app/directory.png b/sources/app/directory.png
new file mode 100644
index 00000000..659f6905
Binary files /dev/null and b/sources/app/directory.png differ
diff --git a/sources/app/events.apd b/sources/app/events.apd
new file mode 100644
index 00000000..dd725e17
--- /dev/null
+++ b/sources/app/events.apd
@@ -0,0 +1,4 @@
+url: $baseurl/events
+requires: local_channel
+name: Events
+photo: $baseurl/app/events.png
diff --git a/sources/app/events.png b/sources/app/events.png
new file mode 100644
index 00000000..a5670fd1
Binary files /dev/null and b/sources/app/events.png differ
diff --git a/sources/app/features.apd b/sources/app/features.apd
new file mode 100644
index 00000000..521df479
--- /dev/null
+++ b/sources/app/features.apd
@@ -0,0 +1,4 @@
+url: $baseurl/settings/features
+requires: local_channel
+name: Features
+photo: $baseurl/app/features.png
diff --git a/sources/app/features.png b/sources/app/features.png
new file mode 100644
index 00000000..5faf14bc
Binary files /dev/null and b/sources/app/features.png differ
diff --git a/sources/app/help.apd b/sources/app/help.apd
new file mode 100644
index 00000000..ca7208e6
--- /dev/null
+++ b/sources/app/help.apd
@@ -0,0 +1,3 @@
+url: $baseurl/help
+name: Help
+photo: $baseurl/app/help.png
diff --git a/sources/app/help.png b/sources/app/help.png
new file mode 100644
index 00000000..6b9b1ccb
Binary files /dev/null and b/sources/app/help.png differ
diff --git a/sources/app/home.png b/sources/app/home.png
new file mode 100644
index 00000000..4b45f2a7
Binary files /dev/null and b/sources/app/home.png differ
diff --git a/sources/app/invite.apd b/sources/app/invite.apd
new file mode 100644
index 00000000..96bafff1
--- /dev/null
+++ b/sources/app/invite.apd
@@ -0,0 +1,4 @@
+url: $baseurl/invite
+requires: local_channel
+name: Invite
+photo: $baseurl/app/invite.png
diff --git a/sources/app/invite.png b/sources/app/invite.png
new file mode 100644
index 00000000..dbc2cbbf
Binary files /dev/null and b/sources/app/invite.png differ
diff --git a/sources/app/lang.apd b/sources/app/lang.apd
new file mode 100644
index 00000000..afe04986
--- /dev/null
+++ b/sources/app/lang.apd
@@ -0,0 +1,3 @@
+url: $baseurl/lang
+name: Language
+photo: $baseurl/app/lang.png
diff --git a/sources/app/lang.png b/sources/app/lang.png
new file mode 100644
index 00000000..89a61c26
Binary files /dev/null and b/sources/app/lang.png differ
diff --git a/sources/app/login.apd b/sources/app/login.apd
new file mode 100644
index 00000000..e4cccbc7
--- /dev/null
+++ b/sources/app/login.apd
@@ -0,0 +1,4 @@
+url: $baseurl/login
+requires: nologin
+name: Login
+photo: $baseurl/app/login.png
diff --git a/sources/app/login.png b/sources/app/login.png
new file mode 100644
index 00000000..4e5625ee
Binary files /dev/null and b/sources/app/login.png differ
diff --git a/sources/app/mail.apd b/sources/app/mail.apd
new file mode 100644
index 00000000..b9fdb996
--- /dev/null
+++ b/sources/app/mail.apd
@@ -0,0 +1,4 @@
+url: $baseurl/message
+requires: local_channel
+name: Mail
+photo: $baseurl/app/mail.png
diff --git a/sources/app/mail.png b/sources/app/mail.png
new file mode 100644
index 00000000..bbd9f844
Binary files /dev/null and b/sources/app/mail.png differ
diff --git a/sources/app/manage.apd b/sources/app/manage.apd
new file mode 100644
index 00000000..27938e4c
--- /dev/null
+++ b/sources/app/manage.apd
@@ -0,0 +1,4 @@
+url: $baseurl/manage
+requires: local_channel
+name: Channel Manager
+photo: $baseurl/app/manage.png
diff --git a/sources/app/manage.png b/sources/app/manage.png
new file mode 100644
index 00000000..38a4dcba
Binary files /dev/null and b/sources/app/manage.png differ
diff --git a/sources/app/matrix.apd b/sources/app/matrix.apd
new file mode 100644
index 00000000..68188bfd
--- /dev/null
+++ b/sources/app/matrix.apd
@@ -0,0 +1,4 @@
+url: $baseurl/network
+requires: local_channel
+name: Matrix
+photo: $baseurl/app/matrix.png
diff --git a/sources/app/matrix.png b/sources/app/matrix.png
new file mode 100644
index 00000000..aba2c35d
Binary files /dev/null and b/sources/app/matrix.png differ
diff --git a/sources/app/mood.apd b/sources/app/mood.apd
new file mode 100644
index 00000000..6f381fd4
--- /dev/null
+++ b/sources/app/mood.apd
@@ -0,0 +1,4 @@
+url: $baseurl/mood
+requires: local_channel
+name: Mood
+photo: $baseurl/app/mood.png
diff --git a/sources/app/mood.png b/sources/app/mood.png
new file mode 100644
index 00000000..2a5c1aca
Binary files /dev/null and b/sources/app/mood.png differ
diff --git a/sources/app/photos.apd b/sources/app/photos.apd
new file mode 100644
index 00000000..3422d520
--- /dev/null
+++ b/sources/app/photos.apd
@@ -0,0 +1,4 @@
+url: $baseurl/photos/$nick
+requires: local_channel
+name: Photos
+photo: $baseurl/app/photos.png
diff --git a/sources/app/photos.png b/sources/app/photos.png
new file mode 100644
index 00000000..59b03828
Binary files /dev/null and b/sources/app/photos.png differ
diff --git a/sources/app/poke.apd b/sources/app/poke.apd
new file mode 100644
index 00000000..7e3bb4ff
--- /dev/null
+++ b/sources/app/poke.apd
@@ -0,0 +1,4 @@
+url: $baseurl/poke
+requires: local_channel
+name: Poke
+photo: $baseurl/app/poke.png
diff --git a/sources/app/poke.png b/sources/app/poke.png
new file mode 100644
index 00000000..9655d54f
Binary files /dev/null and b/sources/app/poke.png differ
diff --git a/sources/app/post.apd b/sources/app/post.apd
new file mode 100644
index 00000000..780eed47
--- /dev/null
+++ b/sources/app/post.apd
@@ -0,0 +1,4 @@
+url: $baseurl/rpost?f=&body=%0A
+requires: observer
+name: Post
+photo: $baseurl/app/post.png
diff --git a/sources/app/post.png b/sources/app/post.png
new file mode 100644
index 00000000..4a435558
Binary files /dev/null and b/sources/app/post.png differ
diff --git a/sources/app/pphoto.apd b/sources/app/pphoto.apd
new file mode 100644
index 00000000..302b85d9
--- /dev/null
+++ b/sources/app/pphoto.apd
@@ -0,0 +1,4 @@
+url: $baseurl/profile_photo
+requires: local_channel
+name: Profile Photo
+photo: $baseurl/app/pphoto.png
diff --git a/sources/app/pphoto.png b/sources/app/pphoto.png
new file mode 100644
index 00000000..041ff1e0
Binary files /dev/null and b/sources/app/pphoto.png differ
diff --git a/sources/app/probe.apd b/sources/app/probe.apd
new file mode 100644
index 00000000..e1ab5fc4
--- /dev/null
+++ b/sources/app/probe.apd
@@ -0,0 +1,4 @@
+url: $baseurl/probe
+requires: local_channel
+name: Remote diagnostics
+photo: $baseurl/app/probe.png
diff --git a/sources/app/probe.png b/sources/app/probe.png
new file mode 100644
index 00000000..21bd85cd
Binary files /dev/null and b/sources/app/probe.png differ
diff --git a/sources/app/profile.apd b/sources/app/profile.apd
new file mode 100644
index 00000000..d353d574
--- /dev/null
+++ b/sources/app/profile.apd
@@ -0,0 +1,4 @@
+url: $baseurl/profile/$nick
+requires: local_channel
+name: View profile
+photo: $baseurl/app/profile.png
diff --git a/sources/app/profile.png b/sources/app/profile.png
new file mode 100644
index 00000000..e6e137c8
Binary files /dev/null and b/sources/app/profile.png differ
diff --git a/sources/app/randprof.apd b/sources/app/randprof.apd
new file mode 100644
index 00000000..9534c77f
--- /dev/null
+++ b/sources/app/randprof.apd
@@ -0,0 +1,6 @@
+url: $baseurl/randprof
+name: Random Channel
+target: randprof
+photo: $baseurl/app/randprof.png
+
+
diff --git a/sources/app/randprof.png b/sources/app/randprof.png
new file mode 100644
index 00000000..7bb438dc
Binary files /dev/null and b/sources/app/randprof.png differ
diff --git a/sources/app/search.apd b/sources/app/search.apd
new file mode 100644
index 00000000..ed48909b
--- /dev/null
+++ b/sources/app/search.apd
@@ -0,0 +1,3 @@
+url: $baseurl/search
+name: Search
+photo: $baseurl/app/search.png
diff --git a/sources/app/search.png b/sources/app/search.png
new file mode 100644
index 00000000..505d93c3
Binary files /dev/null and b/sources/app/search.png differ
diff --git a/sources/app/settings.apd b/sources/app/settings.apd
new file mode 100644
index 00000000..fbb5eacd
--- /dev/null
+++ b/sources/app/settings.apd
@@ -0,0 +1,4 @@
+url: $baseurl/settings
+requires: local_channel
+name: Settings
+photo: $baseurl/app/settings.png
diff --git a/sources/app/settings.png b/sources/app/settings.png
new file mode 100644
index 00000000..2ba11a79
Binary files /dev/null and b/sources/app/settings.png differ
diff --git a/sources/app/storage.apd b/sources/app/storage.apd
new file mode 100644
index 00000000..c959a3cd
--- /dev/null
+++ b/sources/app/storage.apd
@@ -0,0 +1,4 @@
+url: $baseurl/cloud/$nick
+requires: local_channel
+name: Files
+photo: $baseurl/app/storage.png
diff --git a/sources/app/storage.png b/sources/app/storage.png
new file mode 100644
index 00000000..ad8b89f6
Binary files /dev/null and b/sources/app/storage.png differ
diff --git a/sources/app/suggest.apd b/sources/app/suggest.apd
new file mode 100644
index 00000000..f3d17e0e
--- /dev/null
+++ b/sources/app/suggest.apd
@@ -0,0 +1,4 @@
+url: $baseurl/suggest
+requires: local_channel
+name: Suggest channels
+photo: $baseurl/app/suggest.png
diff --git a/sources/app/suggest.png b/sources/app/suggest.png
new file mode 100644
index 00000000..ca918052
Binary files /dev/null and b/sources/app/suggest.png differ
diff --git a/sources/app/webpages.apd b/sources/app/webpages.apd
new file mode 100644
index 00000000..78e7abba
--- /dev/null
+++ b/sources/app/webpages.apd
@@ -0,0 +1,4 @@
+url: $baseurl/webpages/$nick
+requires: local_channel, webpages
+name: Webpages
+photo: $baseurl/app/webpages.png
diff --git a/sources/app/webpages.png b/sources/app/webpages.png
new file mode 100644
index 00000000..72a09183
Binary files /dev/null and b/sources/app/webpages.png differ
diff --git a/sources/boot.php b/sources/boot.php
new file mode 100755
index 00000000..458d676d
--- /dev/null
+++ b/sources/boot.php
@@ -0,0 +1,2316 @@
+' . "\r\n" );
+define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
+//define ( 'NULL_DATE', '0000-00-00 00:00:00' );
+define ( 'TEMPLATE_BUILD_PATH', 'store/[data]/smarty3' );
+
+define ( 'DIRECTORY_MODE_NORMAL', 0x0000); // This is technically DIRECTORY_MODE_TERTIARY, but it's the default, hence 0x0000
+define ( 'DIRECTORY_MODE_PRIMARY', 0x0001);
+define ( 'DIRECTORY_MODE_SECONDARY', 0x0002);
+define ( 'DIRECTORY_MODE_STANDALONE', 0x0100);
+
+// We will look for upstream directories whenever me make contact
+// with other sites, but if this is a new installation and isn't
+// a standalone hub, we need to seed the service with a starting
+// point to go out and find the rest of the world.
+
+define ( 'DIRECTORY_REALM', 'RED_GLOBAL');
+define ( 'DIRECTORY_FALLBACK_MASTER', 'https://zothub.com');
+
+$DIRECTORY_FALLBACK_SERVERS = array(
+ 'https://zothub.com',
+ 'https://zotid.net',
+ 'https://red.zottel.red',
+ 'https://redmatrix.info',
+ 'https://my.federated.social',
+ 'https://redmatrix.nl'
+);
+
+
+/**
+ *
+ * Image storage quality. Lower numbers save space at cost of image detail.
+ * For ease of upgrade, please do not change here. Change jpeg quality with
+ * $a->config['system']['jpeg_quality'] = n;
+ * in .htconfig.php, where n is netween 1 and 100, and with very poor results
+ * below about 50
+ *
+ */
+
+define ( 'JPEG_QUALITY', 100 );
+/**
+ * $a->config['system']['png_quality'] from 0 (uncompressed) to 9
+ */
+define ( 'PNG_QUALITY', 8 );
+
+/**
+ * Language detection parameters
+ */
+
+define ( 'LANGUAGE_DETECT_MIN_LENGTH', 128 );
+define ( 'LANGUAGE_DETECT_MIN_CONFIDENCE', 0.01 );
+
+
+/**
+ * Default permissions for file-based storage (webDAV, etc.)
+ * These files will be owned by the webserver who will need write
+ * access to the "storage" folder.
+ * Ideally you should make this 700, however some hosted platforms
+ * may not let you change ownership of this directory so we're
+ * defaulting to both owner-write and group-write privilege.
+ * This should work for most cases without modification.
+ * Over-ride this in your .htconfig.php if you need something
+ * either more or less restrictive.
+ */
+
+define ( 'STORAGE_DEFAULT_PERMISSIONS', 0770 );
+
+
+/**
+ *
+ * An alternate way of limiting picture upload sizes. Specify the maximum pixel
+ * length that pictures are allowed to be (for non-square pictures, it will apply
+ * to the longest side). Pictures longer than this length will be resized to be
+ * this length (on the longest side, the other side will be scaled appropriately).
+ * Modify this value using
+ *
+ * $a->config['system']['max_image_length'] = n;
+ *
+ * in .htconfig.php
+ *
+ * If you don't want to set a maximum length, set to -1. The default value is
+ * defined by 'MAX_IMAGE_LENGTH' below.
+ *
+ */
+define ( 'MAX_IMAGE_LENGTH', -1 );
+
+
+/**
+ * Not yet used
+ */
+
+define ( 'DEFAULT_DB_ENGINE', 'MyISAM' );
+
+/**
+ * SSL redirection policies
+ */
+
+define ( 'SSL_POLICY_NONE', 0 );
+define ( 'SSL_POLICY_FULL', 1 );
+define ( 'SSL_POLICY_SELFSIGN', 2 ); // NOT supported in Red
+
+
+/**
+ * log levels
+ */
+
+define ( 'LOGGER_NORMAL', 0 );
+define ( 'LOGGER_TRACE', 1 );
+define ( 'LOGGER_DEBUG', 2 );
+define ( 'LOGGER_DATA', 3 );
+define ( 'LOGGER_ALL', 4 );
+
+/**
+ * registration policies
+ */
+
+define ( 'REGISTER_CLOSED', 0 );
+define ( 'REGISTER_APPROVE', 1 );
+define ( 'REGISTER_OPEN', 2 );
+
+
+/**
+ * site access policy
+ */
+
+define ( 'ACCESS_PRIVATE', 0 );
+define ( 'ACCESS_PAID', 1 );
+define ( 'ACCESS_FREE', 2 );
+define ( 'ACCESS_TIERED', 3 );
+
+/**
+ * relationship types
+ */
+
+define ( 'CONTACT_IS_FOLLOWER', 1);
+define ( 'CONTACT_IS_SHARING', 2);
+define ( 'CONTACT_IS_FRIEND', 3);
+
+
+/**
+ * DB update return values
+ */
+
+define ( 'UPDATE_SUCCESS', 0);
+define ( 'UPDATE_FAILED', 1);
+
+
+define ( 'CLIENT_MODE_NORMAL', 0x0000);
+define ( 'CLIENT_MODE_LOAD', 0x0001);
+define ( 'CLIENT_MODE_UPDATE', 0x0002);
+
+
+/**
+ *
+ * Channel pageflags
+ *
+ */
+
+define ( 'PAGE_NORMAL', 0x0000 );
+define ( 'PAGE_HIDDEN', 0x0001 );
+define ( 'PAGE_AUTOCONNECT', 0x0002 );
+define ( 'PAGE_APPLICATION', 0x0004 );
+define ( 'PAGE_ALLOWCODE', 0x0008 );
+define ( 'PAGE_PREMIUM', 0x0010 );
+define ( 'PAGE_ADULT', 0x0020 );
+define ( 'PAGE_CENSORED', 0x0040 ); // Site admin has blocked this channel from appearing in casual search results and site feeds
+define ( 'PAGE_SYSTEM', 0x1000 );
+define ( 'PAGE_HUBADMIN', 0x2000 ); // set this to indicate a preferred admin channel rather than the
+ // default channel of any accounts with the admin role.
+define ( 'PAGE_REMOVED', 0x8000 );
+
+
+/**
+ * Photo usage types
+ */
+
+define ( 'PHOTO_NORMAL', 0x0000 );
+define ( 'PHOTO_PROFILE', 0x0001 );
+define ( 'PHOTO_XCHAN', 0x0002 );
+define ( 'PHOTO_THING', 0x0004 );
+define ( 'PHOTO_COVER', 0x0010 );
+
+define ( 'PHOTO_ADULT', 0x0008 );
+define ( 'PHOTO_FLAG_OS', 0x4000 );
+
+/**
+ * Menu types
+ */
+
+define ( 'MENU_SYSTEM', 0x0001 );
+define ( 'MENU_BOOKMARK', 0x0002 );
+
+/**
+ * Network and protocol family types
+ */
+
+define ( 'NETWORK_DFRN', 'dfrn'); // Friendica, Mistpark, other DFRN implementations
+define ( 'NETWORK_ZOT', 'zot!'); // Zot!
+define ( 'NETWORK_OSTATUS', 'stat'); // status.net, identi.ca, GNU-social, other OStatus implementations
+define ( 'NETWORK_FEED', 'feed'); // RSS/Atom feeds with no known "post/notify" protocol
+define ( 'NETWORK_DIASPORA', 'dspr'); // Diaspora
+define ( 'NETWORK_MAIL', 'mail'); // IMAP/POP
+define ( 'NETWORK_MAIL2', 'mai2'); // extended IMAP/POP
+define ( 'NETWORK_FACEBOOK', 'face'); // Facebook API
+define ( 'NETWORK_LINKEDIN', 'lnkd'); // LinkedIn
+define ( 'NETWORK_XMPP', 'xmpp'); // XMPP
+define ( 'NETWORK_MYSPACE', 'mysp'); // MySpace
+define ( 'NETWORK_GPLUS', 'goog'); // Google+
+
+define ( 'NETWORK_PHANTOM', 'unkn'); // Place holder
+
+
+/**
+ * Permissions
+ */
+
+define ( 'PERMS_R_STREAM', 0x00001);
+define ( 'PERMS_R_PROFILE', 0x00002);
+define ( 'PERMS_R_PHOTOS', 0x00004);
+define ( 'PERMS_R_ABOOK', 0x00008);
+
+define ( 'PERMS_W_STREAM', 0x00010);
+define ( 'PERMS_W_WALL', 0x00020);
+define ( 'PERMS_W_TAGWALL', 0x00040);
+define ( 'PERMS_W_COMMENT', 0x00080);
+define ( 'PERMS_W_MAIL', 0x00100);
+define ( 'PERMS_W_PHOTOS', 0x00200);
+define ( 'PERMS_W_CHAT', 0x00400);
+define ( 'PERMS_A_DELEGATE', 0x00800);
+
+define ( 'PERMS_R_STORAGE', 0x01000);
+define ( 'PERMS_W_STORAGE', 0x02000);
+define ( 'PERMS_R_PAGES', 0x04000);
+define ( 'PERMS_W_PAGES', 0x08000);
+define ( 'PERMS_A_REPUBLISH', 0x10000);
+define ( 'PERMS_W_LIKE', 0x20000);
+
+// General channel permissions
+
+define ( 'PERMS_PUBLIC' , 0x0001 );
+define ( 'PERMS_NETWORK' , 0x0002 );
+define ( 'PERMS_SITE' , 0x0004 );
+define ( 'PERMS_CONTACTS' , 0x0008 );
+define ( 'PERMS_SPECIFIC' , 0x0080 );
+define ( 'PERMS_AUTHED' , 0x0100 );
+define ( 'PERMS_PENDING' , 0x0200 );
+
+
+// Address book flags
+
+define ( 'ABOOK_FLAG_BLOCKED' , 0x0001);
+define ( 'ABOOK_FLAG_IGNORED' , 0x0002);
+define ( 'ABOOK_FLAG_HIDDEN' , 0x0004);
+define ( 'ABOOK_FLAG_ARCHIVED' , 0x0008);
+define ( 'ABOOK_FLAG_PENDING' , 0x0010);
+define ( 'ABOOK_FLAG_UNCONNECTED', 0x0020);
+define ( 'ABOOK_FLAG_SELF' , 0x0080);
+define ( 'ABOOK_FLAG_FEED' , 0x0100);
+
+
+define ( 'MAIL_DELETED', 0x0001);
+define ( 'MAIL_REPLIED', 0x0002);
+define ( 'MAIL_ISREPLY', 0x0004);
+define ( 'MAIL_SEEN', 0x0008);
+define ( 'MAIL_RECALLED', 0x0010);
+define ( 'MAIL_OBSCURED', 0x0020);
+
+
+define ( 'ATTACH_FLAG_DIR', 0x0001);
+define ( 'ATTACH_FLAG_OS', 0x0002);
+
+
+define ( 'MENU_ITEM_ZID', 0x0001);
+define ( 'MENU_ITEM_NEWWIN', 0x0002);
+define ( 'MENU_ITEM_CHATROOM', 0x0004);
+
+/**
+ * Poll/Survey types
+ */
+
+define ( 'POLL_SIMPLE_RATING', 0x0001); // 1-5
+define ( 'POLL_TENSCALE', 0x0002); // 1-10
+define ( 'POLL_MULTIPLE_CHOICE', 0x0004);
+define ( 'POLL_OVERWRITE', 0x8000); // If you vote twice remove the prior entry
+
+
+define ( 'UPDATE_FLAGS_UPDATED', 0x0001);
+define ( 'UPDATE_FLAGS_FORCED', 0x0002);
+define ( 'UPDATE_FLAGS_DELETED', 0x1000);
+
+
+define ( 'DROPITEM_NORMAL', 0);
+define ( 'DROPITEM_PHASE1', 1);
+define ( 'DROPITEM_PHASE2', 2);
+
+
+/**
+ * Maximum number of "people who like (or don't like) this" that we will list by name
+ */
+
+define ( 'MAX_LIKERS', 10);
+
+/**
+ * Communication timeout
+ */
+
+define ( 'ZCURL_TIMEOUT' , (-1));
+
+
+/**
+ * email notification options
+ */
+
+define ( 'NOTIFY_INTRO', 0x0001 );
+define ( 'NOTIFY_CONFIRM', 0x0002 );
+define ( 'NOTIFY_WALL', 0x0004 );
+define ( 'NOTIFY_COMMENT', 0x0008 );
+define ( 'NOTIFY_MAIL', 0x0010 );
+define ( 'NOTIFY_SUGGEST', 0x0020 );
+define ( 'NOTIFY_PROFILE', 0x0040 );
+define ( 'NOTIFY_TAGSELF', 0x0080 );
+define ( 'NOTIFY_TAGSHARE', 0x0100 );
+define ( 'NOTIFY_POKE', 0x0200 );
+
+define ( 'NOTIFY_SYSTEM', 0x8000 );
+
+/**
+ * visual notification options
+ */
+
+define ( 'VNOTIFY_NETWORK', 0x0001 );
+define ( 'VNOTIFY_CHANNEL', 0x0002 );
+define ( 'VNOTIFY_MAIL', 0x0004 );
+define ( 'VNOTIFY_EVENT', 0x0008 );
+define ( 'VNOTIFY_EVENTTODAY', 0x0010 );
+define ( 'VNOTIFY_BIRTHDAY', 0x0020 );
+define ( 'VNOTIFY_SYSTEM', 0x0040 );
+define ( 'VNOTIFY_INFO', 0x0080 );
+define ( 'VNOTIFY_ALERT', 0x0100 );
+define ( 'VNOTIFY_INTRO', 0x0200 );
+define ( 'VNOTIFY_REGISTER', 0x0400 );
+
+
+
+/**
+ * Tag/term types
+ */
+
+define ( 'TERM_UNKNOWN', 0 );
+define ( 'TERM_HASHTAG', 1 );
+define ( 'TERM_MENTION', 2 );
+define ( 'TERM_CATEGORY', 3 );
+define ( 'TERM_PCATEGORY', 4 );
+define ( 'TERM_FILE', 5 );
+define ( 'TERM_SAVEDSEARCH', 6 );
+define ( 'TERM_THING', 7 );
+define ( 'TERM_BOOKMARK', 8 );
+define ( 'TERM_HIERARCHY', 9 );
+
+define ( 'TERM_OBJ_POST', 1 );
+define ( 'TERM_OBJ_PHOTO', 2 );
+define ( 'TERM_OBJ_PROFILE', 3 );
+define ( 'TERM_OBJ_CHANNEL', 4 );
+define ( 'TERM_OBJ_OBJECT', 5 );
+define ( 'TERM_OBJ_THING', 6 );
+define ( 'TERM_OBJ_APP', 7 );
+
+
+/**
+ * various namespaces we may need to parse
+ */
+
+define ( 'NAMESPACE_ZOT', 'http://purl.org/zot' );
+define ( 'NAMESPACE_DFRN' , 'http://purl.org/macgirvin/dfrn/1.0' );
+define ( 'NAMESPACE_THREAD' , 'http://purl.org/syndication/thread/1.0' );
+define ( 'NAMESPACE_TOMB' , 'http://purl.org/atompub/tombstones/1.0' );
+define ( 'NAMESPACE_ACTIVITY', 'http://activitystrea.ms/spec/1.0/' );
+define ( 'NAMESPACE_ACTIVITY_SCHEMA', 'http://activitystrea.ms/schema/1.0/' );
+define ( 'NAMESPACE_MEDIA', 'http://purl.org/syndication/atommedia' );
+define ( 'NAMESPACE_SALMON_ME', 'http://salmon-protocol.org/ns/magic-env' );
+define ( 'NAMESPACE_OSTATUSSUB', 'http://ostatus.org/schema/1.0/subscribe' );
+define ( 'NAMESPACE_GEORSS', 'http://www.georss.org/georss' );
+define ( 'NAMESPACE_POCO', 'http://portablecontacts.net/spec/1.0' );
+define ( 'NAMESPACE_FEED', 'http://schemas.google.com/g/2010#updates-from' );
+define ( 'NAMESPACE_OSTATUS', 'http://ostatus.org/schema/1.0' );
+define ( 'NAMESPACE_STATUSNET', 'http://status.net/schema/api/1/' );
+define ( 'NAMESPACE_ATOM1', 'http://www.w3.org/2005/Atom' );
+define ( 'NAMESPACE_YMEDIA', 'http://search.yahoo.com/mrss/' );
+
+/**
+ * activity stream defines
+ */
+
+define ( 'ACTIVITY_LIKE', NAMESPACE_ACTIVITY_SCHEMA . 'like' );
+define ( 'ACTIVITY_DISLIKE', NAMESPACE_ZOT . '/activity/dislike' );
+define ( 'ACTIVITY_AGREE', NAMESPACE_ZOT . '/activity/agree' );
+define ( 'ACTIVITY_DISAGREE', NAMESPACE_ZOT . '/activity/disagree' );
+define ( 'ACTIVITY_ABSTAIN', NAMESPACE_ZOT . '/activity/abstain' );
+define ( 'ACTIVITY_ATTEND', NAMESPACE_ZOT . '/activity/attendyes' );
+define ( 'ACTIVITY_ATTENDNO', NAMESPACE_ZOT . '/activity/attendno' );
+define ( 'ACTIVITY_ATTENDMAYBE', NAMESPACE_ZOT . '/activity/attendmaybe' );
+
+define ( 'ACTIVITY_OBJ_HEART', NAMESPACE_ZOT . '/activity/heart' );
+
+define ( 'ACTIVITY_FRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'make-friend' );
+define ( 'ACTIVITY_REQ_FRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'request-friend' );
+define ( 'ACTIVITY_UNFRIEND', NAMESPACE_ACTIVITY_SCHEMA . 'remove-friend' );
+define ( 'ACTIVITY_FOLLOW', NAMESPACE_ACTIVITY_SCHEMA . 'follow' );
+define ( 'ACTIVITY_UNFOLLOW', NAMESPACE_ACTIVITY_SCHEMA . 'stop-following' );
+define ( 'ACTIVITY_JOIN', NAMESPACE_ACTIVITY_SCHEMA . 'join' );
+
+define ( 'ACTIVITY_POST', NAMESPACE_ACTIVITY_SCHEMA . 'post' );
+define ( 'ACTIVITY_UPDATE', NAMESPACE_ACTIVITY_SCHEMA . 'update' );
+define ( 'ACTIVITY_TAG', NAMESPACE_ACTIVITY_SCHEMA . 'tag' );
+define ( 'ACTIVITY_FAVORITE', NAMESPACE_ACTIVITY_SCHEMA . 'favorite' );
+
+define ( 'ACTIVITY_POKE', NAMESPACE_ZOT . '/activity/poke' );
+define ( 'ACTIVITY_MOOD', NAMESPACE_ZOT . '/activity/mood' );
+
+define ( 'ACTIVITY_OBJ_COMMENT', NAMESPACE_ACTIVITY_SCHEMA . 'comment' );
+define ( 'ACTIVITY_OBJ_NOTE', NAMESPACE_ACTIVITY_SCHEMA . 'note' );
+define ( 'ACTIVITY_OBJ_PERSON', NAMESPACE_ACTIVITY_SCHEMA . 'person' );
+define ( 'ACTIVITY_OBJ_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'photo' );
+define ( 'ACTIVITY_OBJ_P_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'profile-photo' );
+define ( 'ACTIVITY_OBJ_ALBUM', NAMESPACE_ACTIVITY_SCHEMA . 'photo-album' );
+define ( 'ACTIVITY_OBJ_EVENT', NAMESPACE_ACTIVITY_SCHEMA . 'event' );
+define ( 'ACTIVITY_OBJ_GROUP', NAMESPACE_ACTIVITY_SCHEMA . 'group' );
+define ( 'ACTIVITY_OBJ_TAGTERM', NAMESPACE_ZOT . '/activity/tagterm' );
+define ( 'ACTIVITY_OBJ_PROFILE', NAMESPACE_ZOT . '/activity/profile' );
+define ( 'ACTIVITY_OBJ_THING', NAMESPACE_ZOT . '/activity/thing' );
+define ( 'ACTIVITY_OBJ_LOCATION',NAMESPACE_ZOT . '/activity/location' );
+define ( 'ACTIVITY_OBJ_FILE', NAMESPACE_ZOT . '/activity/file' );
+
+/**
+ * item weight for query ordering
+ */
+
+define ( 'GRAVITY_PARENT', 0);
+define ( 'GRAVITY_LIKE', 3);
+define ( 'GRAVITY_COMMENT', 6);
+
+/**
+ * Account Flags
+ */
+
+define ( 'ACCOUNT_OK', 0x0000 );
+define ( 'ACCOUNT_UNVERIFIED', 0x0001 );
+define ( 'ACCOUNT_BLOCKED', 0x0002 );
+define ( 'ACCOUNT_EXPIRED', 0x0004 );
+define ( 'ACCOUNT_REMOVED', 0x0008 );
+define ( 'ACCOUNT_PENDING', 0x0010 );
+
+/**
+ * Account roles
+ */
+
+define ( 'ACCOUNT_ROLE_ALLOWCODE', 0x0001 );
+define ( 'ACCOUNT_ROLE_SYSTEM', 0x0002 );
+define ( 'ACCOUNT_ROLE_DEVELOPER', 0x0004 );
+define ( 'ACCOUNT_ROLE_ADMIN', 0x1000 );
+
+/**
+ * Item visibility
+ */
+
+define ( 'ITEM_VISIBLE', 0x0000);
+//define ( 'ITEM_HIDDEN', 0x0001);
+define ( 'ITEM_BLOCKED', 0x0002);
+define ( 'ITEM_MODERATED', 0x0004);
+define ( 'ITEM_SPAM', 0x0008);
+//define ( 'ITEM_DELETED', 0x0010);
+define ( 'ITEM_UNPUBLISHED', 0x0020);
+//define ( 'ITEM_WEBPAGE', 0x0040); // is a static web page, not a conversational item
+define ( 'ITEM_DELAYED_PUBLISH', 0x0080);
+define ( 'ITEM_BUILDBLOCK', 0x0100); // Named thusly to make sure nobody confuses this with ITEM_BLOCKED
+//define ( 'ITEM_PDL', 0x0200); // Page Description Language - e.g. Comanche
+define ( 'ITEM_BUG', 0x0400); // Is a bug, can be used by the internal bug tracker
+define ( 'ITEM_PENDING_REMOVE', 0x0800); // deleted, notification period has lapsed
+define ( 'ITEM_DOC', 0x1000); // hubzilla only, define here so that item import does the right thing
+
+define ( 'ITEM_TYPE_POST', 0 );
+define ( 'ITEM_TYPE_BLOCK', 1 );
+define ( 'ITEM_TYPE_PDL', 2 );
+define ( 'ITEM_TYPE_WEBPAGE', 3 );
+define ( 'ITEM_TYPE_BUG', 4 );
+define ( 'ITEM_TYPE_DOC', 5 );
+
+define ( 'DBTYPE_MYSQL', 0 );
+define ( 'DBTYPE_POSTGRES', 1 );
+
+/**
+ *
+ * Reverse the effect of magic_quotes_gpc if it is enabled.
+ * Please disable magic_quotes_gpc so we don't have to do this.
+ * See http://php.net/manual/en/security.magicquotes.disabling.php
+ *
+ */
+
+function startup() {
+ error_reporting(E_ERROR | E_WARNING | E_PARSE);
+
+ // Some hosting providers block/disable this
+ @set_time_limit(0);
+
+ if(function_exists ('ini_set')) {
+ // This has to be quite large to deal with embedded private photos
+ @ini_set('pcre.backtrack_limit', 500000);
+
+ // Use cookies to store the session ID on the client side
+ @ini_set('session.use_only_cookies', 1);
+
+ // Disable transparent Session ID support
+ @ini_set('session.use_trans_sid', 0);
+ }
+
+ if (get_magic_quotes_gpc()) {
+ $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
+ while (list($key, $val) = each($process)) {
+ foreach ($val as $k => $v) {
+ unset($process[$key][$k]);
+ if (is_array($v)) {
+ $process[$key][stripslashes($k)] = $v;
+ $process[] = &$process[$key][stripslashes($k)];
+ } else {
+ $process[$key][stripslashes($k)] = stripslashes($v);
+ }
+ }
+ }
+ unset($process);
+ }
+}
+
+/**
+ * class: App
+ *
+ * @brief Our main application structure for the life of this page.
+ *
+ * Primarily deals with the URL that got us here
+ * and tries to make some sense of it, and
+ * stores our page contents and config storage
+ * and anything else that might need to be passed around
+ * before we spit the page out.
+ *
+ */
+class App {
+
+ public $install = false; // true if we are installing the software
+
+ public $account = null; // account record of the logged-in account
+ public $channel = null; // channel record of the current channel of the logged-in account
+ public $observer = null; // xchan record of the page observer
+ public $profile_uid = 0; // If applicable, the channel_id of the "page owner"
+ public $poi = null; // "person of interest", generally a referenced connection
+ private $oauth_key = null; // consumer_id of oauth request, if used
+ public $layout = array(); // Comanche parsed template
+ public $pdl = null;
+ private $perms = null; // observer permissions
+ private $widgets = array(); // widgets for this page
+ //private $widgetlist = null; // widget ordering and inclusion directives
+
+ public $groups;
+ public $language;
+ public $module_loaded = false;
+ public $query_string;
+ public $config; // config cache
+ public $page;
+ public $profile;
+ public $user;
+ public $cid;
+ public $contact;
+ public $contacts;
+ public $content;
+ public $data = array();
+ public $error = false;
+ public $cmd;
+ public $argv;
+ public $argc;
+ public $module;
+ public $pager;
+ public $strings;
+ public $hooks;
+ public $timezone;
+ public $interactive = true;
+ public $plugins;
+ private $apps = array();
+ public $identities;
+ public $css_sources = array();
+ public $js_sources = array();
+ public $theme_info = array();
+ public $is_sys = false;
+ public $nav_sel;
+
+ public $category;
+
+ // Allow themes to control internal parameters
+ // by changing App values in theme.php
+
+ public $sourcename = '';
+ public $videowidth = 425;
+ public $videoheight = 350;
+ public $force_max_items = 0;
+ public $theme_thread_allow = true;
+
+ /**
+ * @brief An array for all theme-controllable parameters
+ *
+ * Mostly unimplemented yet. Only options 'template_engine' and
+ * beyond are used.
+ */
+ private $theme = array(
+ 'sourcename' => '',
+ 'videowidth' => 425,
+ 'videoheight' => 350,
+ 'force_max_items' => 0,
+ 'thread_allow' => true,
+ 'stylesheet' => '',
+ 'template_engine' => 'smarty3',
+ );
+
+ /**
+ * @brief An array of registered template engines ('name'=>'class name')
+ */
+ public $template_engines = array();
+ /**
+ * @brief An array of instanced template engines ('name'=>'instance')
+ */
+ public $template_engine_instance = array();
+
+ private $ldelim = array(
+ 'internal' => '',
+ 'smarty3' => '{{'
+ );
+ private $rdelim = array(
+ 'internal' => '',
+ 'smarty3' => '}}'
+ );
+
+ private $scheme;
+ private $hostname;
+ private $baseurl;
+ private $path;
+
+ /**
+ * App constructor.
+ */
+ function __construct() {
+ // we'll reset this after we read our config file
+ date_default_timezone_set('UTC');
+
+ $this->config = array('system'=>array());
+ $this->page = array();
+ $this->pager= array();
+
+ $this->query_string = '';
+
+ startup();
+
+ set_include_path(
+ 'include' . PATH_SEPARATOR
+ . 'library' . PATH_SEPARATOR
+ . 'library/langdet' . PATH_SEPARATOR
+ . '.' );
+
+ $this->scheme = 'http';
+ if(x($_SERVER,'HTTPS') && $_SERVER['HTTPS'])
+ $this->scheme = 'https';
+ elseif(x($_SERVER,'SERVER_PORT') && (intval($_SERVER['SERVER_PORT']) == 443))
+ $this->scheme = 'https';
+
+ if(x($_SERVER,'SERVER_NAME')) {
+ $this->hostname = $_SERVER['SERVER_NAME'];
+
+ if(x($_SERVER,'SERVER_PORT') && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443)
+ $this->hostname .= ':' . $_SERVER['SERVER_PORT'];
+ /**
+ * Figure out if we are running at the top of a domain
+ * or in a sub-directory and adjust accordingly
+ */
+
+ $path = trim(dirname($_SERVER['SCRIPT_NAME']),'/\\');
+ if(isset($path) && strlen($path) && ($path != $this->path))
+ $this->path = $path;
+ }
+
+ set_include_path("include/$this->hostname" . PATH_SEPARATOR . get_include_path());
+
+ if((x($_SERVER,'QUERY_STRING')) && substr($_SERVER['QUERY_STRING'], 0, 2) === "q=") {
+ $this->query_string = substr($_SERVER['QUERY_STRING'], 2);
+ // removing trailing / - maybe a nginx problem
+ if (substr($this->query_string, 0, 1) == "/")
+ $this->query_string = substr($this->query_string, 1);
+ }
+ if(x($_GET,'q'))
+ $this->cmd = trim($_GET['q'],'/\\');
+
+ // unix style "homedir"
+
+ if(substr($this->cmd, 0, 1) === '~')
+ $this->cmd = 'channel/' . substr($this->cmd, 1);
+
+ /*
+ * Break the URL path into C style argc/argv style arguments for our
+ * modules. Given "http://example.com/module/arg1/arg2", $this->argc
+ * will be 3 (integer) and $this->argv will contain:
+ * [0] => 'module'
+ * [1] => 'arg1'
+ * [2] => 'arg2'
+ *
+ * There will always be one argument. If provided a naked domain
+ * URL, $this->argv[0] is set to "home".
+ */
+
+ $this->argv = explode('/', $this->cmd);
+ $this->argc = count($this->argv);
+ if ((array_key_exists('0', $this->argv)) && strlen($this->argv[0])) {
+ $this->module = str_replace(".", "_", $this->argv[0]);
+ $this->module = str_replace("-", "_", $this->module);
+ } else {
+ $this->argc = 1;
+ $this->argv = array('home');
+ $this->module = 'home';
+ }
+
+ /*
+ * See if there is any page number information, and initialise
+ * pagination
+ */
+
+ $this->pager['page'] = ((x($_GET,'page') && intval($_GET['page']) > 0) ? intval($_GET['page']) : 1);
+ $this->pager['itemspage'] = 60;
+ $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
+ if($this->pager['start'] < 0)
+ $this->pager['start'] = 0;
+ $this->pager['total'] = 0;
+
+ /*
+ * Detect mobile devices
+ */
+
+ $mobile_detect = new Mobile_Detect();
+ $this->is_mobile = $mobile_detect->isMobile();
+ $this->is_tablet = $mobile_detect->isTablet();
+
+ $this->head_set_icon('/images/rm-32.png');
+
+ BaseObject::set_app($this);
+
+ /*
+ * register template engines
+ */
+ $dc = get_declared_classes();
+ foreach ($dc as $k) {
+ if (in_array("ITemplateEngine", class_implements($k))){
+ $this->register_template_engine($k);
+ }
+ }
+ }
+
+ function get_baseurl($ssl = false) {
+ if(is_array($this->config)
+ && array_key_exists('system',$this->config)
+ && is_array($this->config['system'])
+ && array_key_exists('baseurl',$this->config['system'])
+ && strlen($this->config['system']['baseurl'])) {
+ $url = $this->config['system']['baseurl'];
+
+ return $url;
+ }
+
+ $scheme = $this->scheme;
+
+ $this->baseurl = $scheme . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' );
+
+ return $this->baseurl;
+ }
+
+ function set_baseurl($url) {
+ if(is_array($this->config)
+ && array_key_exists('system',$this->config)
+ && is_array($this->config['system'])
+ && array_key_exists('baseurl',$this->config['system'])
+ && strlen($this->config['system']['baseurl'])) {
+ $url = $this->config['system']['baseurl'];
+ }
+
+ $parsed = @parse_url($url);
+
+ $this->baseurl = $url;
+
+ if($parsed) {
+ $this->scheme = $parsed['scheme'];
+
+ $this->hostname = $parsed['host'];
+ if(x($parsed,'port'))
+ $this->hostname .= ':' . $parsed['port'];
+ if(x($parsed,'path'))
+ $this->path = trim($parsed['path'],'\\/');
+ }
+ }
+
+ function get_hostname() {
+ return $this->hostname;
+ }
+
+ function set_hostname($h) {
+ $this->hostname = $h;
+ }
+
+ function set_path($p) {
+ $this->path = trim(trim($p), '/');
+ }
+
+ function get_path() {
+ return $this->path;
+ }
+
+ function set_account($acct) {
+ $this->account = $acct;
+ }
+
+ function get_account() {
+ return $this->account;
+ }
+
+ function set_channel($channel) {
+ $this->channel = $channel;
+ }
+
+ function get_channel() {
+ return $this->channel;
+ }
+
+ function set_observer($xchan) {
+ $this->observer = $xchan;
+ }
+
+
+ function get_observer() {
+ return $this->observer;
+ }
+
+ function set_perms($perms) {
+ $this->perms = $perms;
+ }
+
+ function get_perms() {
+ return $this->perms;
+ }
+
+ function set_oauth_key($consumer_id) {
+ $this->oauth_key = $consumer_id;
+ }
+
+ function get_oauth_key() {
+ return $this->oauth_key;
+ }
+
+ function get_apps() {
+ return $this->apps;
+ }
+
+ function set_apps($arr) {
+ $this->apps = $arr;
+ }
+
+ function set_groups($g) {
+ $this->groups = $g;
+ }
+
+ function get_groups() {
+ return $this->groups;
+ }
+
+ function set_widget($title,$html, $location = 'aside') {
+ $this->widgets[] = array('title' => $title, 'html' => $html, 'location' => $location);
+ }
+
+ function get_widgets($location = '') {
+ if($location && count($this->widgets)) {
+ $ret = array();
+ foreach($this->widgets as $w) {
+ if ($w['location'] == $location)
+ $ret[] = $w;
+ }
+ $arr = array('location' => $location, 'widgets' => $ret);
+ call_hooks('get_widgets', $arr);
+ return $arr['widgets'];
+ }
+ $arr = array('location' => $location, 'widgets' => $this->widgets);
+ call_hooks('get_widgets', $arr);
+ return $arr['widgets'];
+ }
+
+ function set_pager_total($n) {
+ $this->pager['total'] = intval($n);
+ }
+
+ function set_pager_itemspage($n) {
+ $this->pager['itemspage'] = ((intval($n) > 0) ? intval($n) : 0);
+ $this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
+ }
+
+ function build_pagehead() {
+
+ $user_scalable = ((local_channel()) ? get_pconfig(local_channel(),'system','user_scalable') : 1);
+ if ($user_scalable === false)
+ $user_scalable = 1;
+
+ $interval = ((local_channel()) ? get_pconfig(local_channel(),'system','update_interval') : 80000);
+ if($interval < 10000)
+ $interval = 80000;
+
+ if(! x($this->page,'title'))
+ $this->page['title'] = $this->config['system']['sitename'];
+
+ /* put the head template at the beginning of page['htmlhead']
+ * since the code added by the modules frequently depends on it
+ * being first
+ */
+ $tpl = get_markup_template('head.tpl');
+ $this->page['htmlhead'] = replace_macros($tpl, array(
+ '$user_scalable' => $user_scalable,
+ '$baseurl' => $this->get_baseurl(),
+ '$local_channel' => local_channel(),
+ '$generator' => PLATFORM_NAME . ' ' . RED_VERSION,
+ '$update_interval' => $interval,
+ '$icon' => head_get_icon(),
+ '$head_css' => head_get_css(),
+ '$head_js' => head_get_js(),
+ '$js_strings' => js_strings(),
+ '$zid' => get_my_address(),
+ '$channel_id' => $this->profile['uid'],
+ )) . $this->page['htmlhead'];
+
+ // always put main.js at the end
+ $this->page['htmlhead'] .= head_get_main_js();
+ }
+
+ /**
+ * register template engine class
+ * if $name is "", is used class static property $class::$name
+ * @param string $class
+ * @param string $name
+ */
+ function register_template_engine($class, $name = '') {
+ if ($name === ""){
+ $v = get_class_vars( $class );
+ if(x($v, "name")) $name = $v['name'];
+ }
+ if ($name === ""){
+ echo "template engine $class cannot be registered without a name.\n";
+ killme();
+ }
+ $this->template_engines[$name] = $class;
+ }
+
+ /**
+ * return template engine instance. If $name is not defined,
+ * return engine defined by theme, or default
+ *
+ * @param string $name Template engine name
+ *
+ * @return object Template Engine instance
+ */
+ function template_engine($name = ''){
+ if ($name !== "") {
+ $template_engine = $name;
+ } else {
+ $template_engine = 'smarty3';
+ if (x($this->theme, 'template_engine')) {
+ $template_engine = $this->theme['template_engine'];
+ }
+ }
+
+ if (isset($this->template_engines[$template_engine])){
+ if(isset($this->template_engine_instance[$template_engine])){
+ return $this->template_engine_instance[$template_engine];
+ } else {
+ $class = $this->template_engines[$template_engine];
+ $obj = new $class;
+ $this->template_engine_instance[$template_engine] = $obj;
+ return $obj;
+ }
+ }
+
+ echo "template engine $template_engine is not registered!\n"; killme();
+ }
+
+ /**
+ * @brief Returns the active template engine.
+ *
+ * @return string
+ */
+ function get_template_engine() {
+ return $this->theme['template_engine'];
+ }
+
+ function set_template_engine($engine = 'smarty3') {
+ $this->theme['template_engine'] = $engine;
+ }
+
+ function get_template_ldelim($engine = 'smarty3') {
+ return $this->ldelim[$engine];
+ }
+
+ function get_template_rdelim($engine = 'smarty3') {
+ return $this->rdelim[$engine];
+ }
+
+ function head_set_icon($icon) {
+ $this->data['pageicon'] = $icon;
+ }
+
+ function head_get_icon() {
+ $icon = $this->data['pageicon'];
+ if(! strpos($icon,'://'))
+ $icon = z_root() . $icon;
+ return $icon;
+ }
+
+} // End App class
+
+
+/**
+ * @brief Retrieve the App structure.
+ *
+ * Useful in functions which require it but don't get it passed to them
+ *
+ * @return App
+ */
+function get_app() {
+ global $a;
+ return $a;
+}
+
+
+/**
+ * @brief Multi-purpose function to check variable state.
+ *
+ * Usage: x($var) or $x($array, 'key')
+ *
+ * returns false if variable/key is not set
+ * if variable is set, returns 1 if has 'non-zero' value, otherwise returns 0.
+ * e.g. x('') or x(0) returns 0;
+ *
+ * @param string|array $s variable to check
+ * @param string $k key inside the array to check
+ *
+ * @return bool|int
+ */
+function x($s, $k = null) {
+ if($k != null) {
+ if((is_array($s)) && (array_key_exists($k, $s))) {
+ if($s[$k])
+ return (int) 1;
+ return (int) 0;
+ }
+ return false;
+ }
+ else {
+ if(isset($s)) {
+ if($s) {
+ return (int) 1;
+ }
+ return (int) 0;
+ }
+ return false;
+ }
+}
+
+
+// called from db initialisation if db is dead.
+
+function system_unavailable() {
+ include('include/system_unavailable.php');
+ system_down();
+ killme();
+}
+
+
+function clean_urls() {
+ global $a;
+
+ // if($a->config['system']['clean_urls'])
+ return true;
+ // return false;
+}
+
+function z_path() {
+ global $a;
+
+ $base = $a->get_baseurl();
+ if(! clean_urls())
+ $base .= '/?q=';
+
+ return $base;
+}
+
+/**
+ * @brief Returns the baseurl.
+ *
+ * @see App::get_baseurl()
+ *
+ * @return string
+ */
+function z_root() {
+ global $a;
+ return $a->get_baseurl();
+}
+
+/**
+ * @brief Return absolut URL for given $path.
+ *
+ * @param string $path
+ *
+ * @return string
+ */
+function absurl($path) {
+ if(strpos($path, '/') === 0)
+ return z_path() . $path;
+
+ return $path;
+}
+
+function os_mkdir($path, $mode = 0777, $recursive = false) {
+ $oldumask = @umask(0);
+ $result = @mkdir($path, $mode, $recursive);
+ @umask($oldumask);
+ return $result;
+}
+
+/**
+ * @brief Function to check if request was an AJAX (xmlhttprequest) request.
+ *
+ * @return boolean
+ */
+function is_ajax() {
+ return (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
+}
+
+
+// Primarily involved with database upgrade, but also sets the
+// base url for use in cmdline programs which don't have
+// $_SERVER variables, and synchronising the state of installed plugins.
+
+function check_config(&$a) {
+
+ $build = get_config('system','db_version');
+ if(! intval($build))
+ $build = set_config('system','db_version',DB_UPDATE_VERSION);
+
+ $saved = get_config('system','urlverify');
+ if(! $saved)
+ set_config('system','urlverify',bin2hex(z_root()));
+
+ if(($saved) && ($saved != bin2hex(z_root()))) {
+ // our URL changed. Do something.
+
+ $oldurl = hex2bin($saved);
+ logger('Baseurl changed!');
+
+ $oldhost = substr($oldurl, strpos($oldurl, '//') + 2);
+ $host = substr(z_root(), strpos(z_root(), '//') + 2);
+
+ $is_ip_addr = ((preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$host)) ? true : false);
+ $was_ip_addr = ((preg_match("/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/",$oldhost)) ? true : false);
+ // only change the url to an ip address if it was already an ip and not a dns name
+ if((! $is_ip_addr) || ($is_ip_addr && $was_ip_addr)) {
+ fix_system_urls($oldurl,z_root());
+ set_config('system', 'urlverify', bin2hex(z_root()));
+ }
+ else
+ logger('Attempt to change baseurl from a DNS name to an IP address was refused.');
+ }
+
+ // This will actually set the url to the one stored in .htconfig, and ignore what
+ // we're passing - unless we are installing and it has never been set.
+
+ $a->set_baseurl($a->get_baseurl());
+
+ // Make sure each site has a system channel. This is now created on install
+ // so we just need to keep this around a couple of weeks until the hubs that
+ // already exist have one
+ $syschan_exists = get_sys_channel();
+ if (! $syschan_exists)
+ create_sys_channel();
+
+ if($build != DB_UPDATE_VERSION) {
+ $stored = intval($build);
+ if(! $stored) {
+ logger('Critical: check_config unable to determine database schema version');
+ return;
+ }
+ $current = intval(DB_UPDATE_VERSION);
+ if(($stored < $current) && file_exists('install/update.php')) {
+
+ load_config('database');
+
+ // We're reporting a different version than what is currently installed.
+ // Run any existing update scripts to bring the database up to current.
+ require_once('install/update.php');
+
+ // make sure that boot.php and update.php are the same release, we might be
+ // updating right this very second and the correct version of the update.php
+ // file may not be here yet. This can happen on a very busy site.
+
+ if(DB_UPDATE_VERSION == UPDATE_VERSION) {
+ for($x = $stored; $x < $current; $x ++) {
+ if(function_exists('update_r' . $x)) {
+ // There could be a lot of processes running or about to run.
+ // We want exactly one process to run the update command.
+ // So store the fact that we're taking responsibility
+ // after first checking to see if somebody else already has.
+
+ // If the update fails or times-out completely you may need to
+ // delete the config entry to try again.
+
+ if(get_config('database','update_r' . $x))
+ break;
+ set_config('database','update_r' . $x, '1');
+ // call the specific update
+
+ $func = 'update_r' . $x;
+ $retval = $func();
+ if($retval) {
+
+ // Prevent sending hundreds of thousands of emails by creating
+ // a lockfile.
+
+ $lockfile = 'store/[data]/mailsent';
+
+ if ((file_exists($lockfile)) && (filemtime($lockfile) > (time() - 86400)))
+ return;
+ @unlink($lockfile);
+ //send the administrator an e-mail
+ file_put_contents($lockfile, $x);
+
+ $email_tpl = get_intltext_template("update_fail_eml.tpl");
+ $email_msg = replace_macros($email_tpl, array(
+ '$sitename' => $a->config['system']['sitename'],
+ '$siteurl' => $a->get_baseurl(),
+ '$update' => $x,
+ '$error' => sprintf( t('Update %s failed. See error logs.'), $x)
+ ));
+
+ $subject = email_header_encode(sprintf(t('Update Error at %s'), $a->get_baseurl()));
+
+ mail($a->config['system']['admin_email'], $subject, $email_msg,
+ 'From: Administrator' . '@' . $_SERVER['SERVER_NAME'] . "\n"
+ . 'Content-type: text/plain; charset=UTF-8' . "\n"
+ . 'Content-transfer-encoding: 8bit' );
+ //try the logger
+ logger('CRITICAL: Update Failed: ' . $x);
+ }
+ else
+ set_config('database','update_r' . $x, 'success');
+ }
+ }
+ set_config('system','db_version', DB_UPDATE_VERSION);
+ }
+ }
+ }
+
+ /**
+ *
+ * Synchronise plugins:
+ *
+ * $a->config['system']['addon'] contains a comma-separated list of names
+ * of plugins/addons which are used on this system.
+ * Go through the database list of already installed addons, and if we have
+ * an entry, but it isn't in the config list, call the unload procedure
+ * and mark it uninstalled in the database (for now we'll remove it).
+ * Then go through the config list and if we have a plugin that isn't installed,
+ * call the install procedure and add it to the database.
+ *
+ */
+
+ $r = q("SELECT * FROM `addon` WHERE `installed` = 1");
+ if($r)
+ $installed = $r;
+ else
+ $installed = array();
+
+ $plugins = get_config('system', 'addon');
+ $plugins_arr = array();
+
+ if($plugins)
+ $plugins_arr = explode(',', str_replace(' ', '', $plugins));
+
+ $a->plugins = $plugins_arr;
+
+ $installed_arr = array();
+
+ if(count($installed)) {
+ foreach($installed as $i) {
+ if(! in_array($i['name'], $plugins_arr)) {
+ unload_plugin($i['name']);
+ }
+ else {
+ $installed_arr[] = $i['name'];
+ }
+ }
+ }
+
+ if(count($plugins_arr)) {
+ foreach($plugins_arr as $p) {
+ if(! in_array($p, $installed_arr)) {
+ load_plugin($p);
+ }
+ }
+ }
+
+ load_hooks();
+}
+
+
+function fix_system_urls($oldurl, $newurl) {
+
+ require_once('include/crypto.php');
+
+ logger('fix_system_urls: renaming ' . $oldurl . ' to ' . $newurl);
+
+ // Basically a site rename, but this can happen if you change from http to https for instance - even if the site name didn't change
+ // This should fix URL changes on our site, but other sites will end up with orphan hublocs which they will try to contact and will
+ // cause wasted communications.
+ // What we need to do after fixing this up is to send a revocation of the old URL to every other site that we communicate with so
+ // that they can clean up their hubloc tables (this includes directories).
+ // It's a very expensive operation so you don't want to have to do it often or after your site gets to be large.
+
+ $r = q("select xchan.*, hubloc.* from xchan left join hubloc on xchan_hash = hubloc_hash where hubloc_url like '%s'",
+ dbesc($oldurl . '%')
+ );
+
+ if($r) {
+ foreach($r as $rr) {
+ $channel_address = substr($rr['hubloc_addr'],0,strpos($rr['hubloc_addr'],'@'));
+
+ // get the associated channel. If we don't have a local channel, do nothing for this entry.
+
+ $c = q("select * from channel where channel_hash = '%s' limit 1",
+ dbesc($rr['hubloc_hash'])
+ );
+ if(! $c)
+ continue;
+
+ $parsed = @parse_url($newurl);
+ if(! $parsed)
+ continue;
+ $newhost = $parsed['host'];
+
+ // sometimes parse_url returns unexpected results.
+
+ if(strpos($newhost,'/') !== false)
+ $newhost = substr($newhost,0,strpos($newhost,'/'));
+
+ $rhs = $newhost . (($parsed['port']) ? ':' . $parsed['port'] : '');
+
+ // paths aren't going to work. You have to be at the (sub)domain root
+ // . (($parsed['path']) ? $parsed['path'] : '');
+
+ // The xchan_url might point to another nomadic identity clone
+
+ $replace_xchan_url = ((strpos($rr['xchan_url'],$oldurl) !== false) ? true : false);
+
+ $x = q("update xchan set xchan_addr = '%s', xchan_url = '%s', xchan_connurl = '%s', xchan_follow = '%s', xchan_connpage = '%s', xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_date = '%s' where xchan_hash = '%s'",
+ dbesc($channel_address . '@' . $rhs),
+ dbesc(($replace_xchan_url) ? str_replace($oldurl,$newurl,$rr['xchan_url']) : $rr['xchan_url']),
+ dbesc(str_replace($oldurl,$newurl,$rr['xchan_connurl'])),
+ dbesc(str_replace($oldurl,$newurl,$rr['xchan_follow'])),
+ dbesc(str_replace($oldurl,$newurl,$rr['xchan_connpage'])),
+ dbesc(str_replace($oldurl,$newurl,$rr['xchan_photo_l'])),
+ dbesc(str_replace($oldurl,$newurl,$rr['xchan_photo_m'])),
+ dbesc(str_replace($oldurl,$newurl,$rr['xchan_photo_s'])),
+ dbesc(datetime_convert()),
+ dbesc($rr['xchan_hash'])
+ );
+
+ $y = q("update hubloc set hubloc_addr = '%s', hubloc_url = '%s', hubloc_url_sig = '%s', hubloc_host = '%s', hubloc_callback = '%s' where hubloc_hash = '%s' and hubloc_url = '%s'",
+ dbesc($channel_address . '@' . $rhs),
+ dbesc($newurl),
+ dbesc(base64url_encode(rsa_sign($newurl,$c[0]['channel_prvkey']))),
+ dbesc($newhost),
+ dbesc($newurl . '/post'),
+ dbesc($rr['xchan_hash']),
+ dbesc($oldurl)
+ );
+
+ $z = q("update profile set photo = '%s', thumb = '%s' where uid = %d",
+ dbesc(str_replace($oldurl,$newurl,$rr['xchan_photo_l'])),
+ dbesc(str_replace($oldurl,$newurl,$rr['xchan_photo_m'])),
+ intval($c[0]['channel_id'])
+ );
+
+ proc_run('php', 'include/notifier.php', 'refresh_all', $c[0]['channel_id']);
+ }
+ }
+}
+
+
+// wrapper for adding a login box. If $register == true provide a registration
+// link. This will most always depend on the value of $a->config['system']['register_policy'].
+// returns the complete html for inserting into the page
+
+function login($register = false, $form_id = 'main-login', $hiddens=false) {
+ $a = get_app();
+ $o = '';
+ $reg = false;
+ $reglink = get_config('system', 'register_link');
+ if(! strlen($reglink))
+ $reglink = 'register';
+
+ $reg = array(
+ 'title' => t('Create an account to access services and applications within the Hubzilla'),
+ 'desc' => t('Register'),
+ 'link' => (($register) ? $reglink : 'pubsites')
+ );
+
+ $dest_url = $a->get_baseurl(true) . '/' . $a->query_string;
+
+ if(local_channel()) {
+ $tpl = get_markup_template("logout.tpl");
+ }
+ else {
+// There's no such thing as login_head.tpl, has never been in Red, removed from Friendica 1 Jun 2013...
+
+// $a->page['htmlhead'] .= replace_macros(get_markup_template("login_head.tpl"), array(
+// '$baseurl' => $a->get_baseurl(true)
+// ));
+
+ $tpl = get_markup_template("login.tpl");
+ if(strlen($a->query_string))
+ $_SESSION['login_return_url'] = $a->query_string;
+ }
+
+ $o .= replace_macros($tpl,array(
+ '$dest_url' => $dest_url,
+ '$logout' => t('Logout'),
+ '$login' => t('Login'),
+ '$form_id' => $form_id,
+ '$lname' => array('username', t('Email') , '', ''),
+ '$lpassword' => array('password', t('Password'), '', ''),
+ '$remember' => array('remember', t('Remember me'), '', '',array(t('No'),t('Yes'))),
+ '$hiddens' => $hiddens,
+ '$register' => $reg,
+ '$lostpass' => t('Forgot your password?'),
+ '$lostlink' => t('Password Reset'),
+ ));
+
+ call_hooks('login_hook', $o);
+
+ return $o;
+}
+
+
+/**
+ * @brief Used to end the current process, after saving session state.
+ */
+function killme() {
+ session_write_close();
+ exit;
+}
+
+/**
+ * @brief Redirect to another URL and terminate this process.
+ */
+function goaway($s) {
+ header("Location: $s");
+ killme();
+}
+
+/**
+ * @brief Returns the entity id of locally logged in account or false.
+ *
+ * Returns numeric account_id if authenticated or 0. It is possible to be
+ * authenticated and not connected to a channel.
+ *
+ * @return int|bool account_id or false
+ */
+function get_account_id() {
+ if(get_app()->account)
+ return intval(get_app()->account['account_id']);
+
+ return false;
+}
+
+/**
+ * @brief Returns the entity id (channel_id) of locally logged in channel or false.
+ *
+ * Returns authenticated numeric channel_id if authenticated and connected to
+ * a channel or 0. Sometimes referred to as $uid in the code.
+ *
+ * Before 2.1 this function was called local_user().
+ *
+ * @since 2.1
+ * @return int|bool channel_id or false
+ */
+function local_channel() {
+ if((x($_SESSION, 'authenticated')) && (x($_SESSION, 'uid')))
+ return intval($_SESSION['uid']);
+
+ return false;
+}
+
+/**
+ * local_user() got deprecated and replaced by local_channel().
+ *
+ * @deprecated since v2.1, use local_channel()
+ * @see local_channel()
+ */
+function local_user() {
+ logger('local_user() is DEPRECATED, use local_channel()');
+ return local_channel();
+}
+
+
+/**
+ * @brief Returns a xchan_hash (visitor_id) of remote authenticated visitor
+ * or false.
+ *
+ * Returns authenticated string hash of Red global identifier (xchan_hash), if
+ * authenticated via remote auth, or an empty string.
+ *
+ * Before 2.1 this function was called remote_user().
+ *
+ * @since 2.1
+ * @return string|bool visitor_id or false
+ */
+function remote_channel() {
+ if((x($_SESSION, 'authenticated')) && (x($_SESSION, 'visitor_id')))
+ return $_SESSION['visitor_id'];
+
+ return false;
+}
+
+/**
+ * remote_user() got deprecated and replaced by remote_channel().
+ *
+ * @deprecated since v2.1, use remote_channel()
+ * @see remote_channel()
+ */
+function remote_user() {
+ logger('remote_user() is DEPRECATED, use remote_channel()');
+ return remote_channel();
+}
+
+
+/**
+ * Contents of $s are displayed prominently on the page the next time
+ * a page is loaded. Usually used for errors or alerts.
+ *
+ * @param string $s Text to display
+ */
+function notice($s) {
+ $a = get_app();
+ if(! x($_SESSION, 'sysmsg')) $_SESSION['sysmsg'] = array();
+
+ // ignore duplicated error messages which haven't yet been displayed
+ // - typically seen as multiple 'permission denied' messages
+ // as a result of auto-reloading a protected page with &JS=1
+
+ if(in_array($s,$_SESSION['sysmsg']))
+ return;
+
+ if($a->interactive) {
+ $_SESSION['sysmsg'][] = $s;
+ }
+
+}
+
+/**
+ * Contents of $s are displayed prominently on the page the next time a page is
+ * loaded. Usually used for information.
+ * For error and alerts use notice().
+ *
+ * @param string $s Text to display
+ */
+function info($s) {
+ $a = get_app();
+ if(! x($_SESSION, 'sysmsg_info')) $_SESSION['sysmsg_info'] = array();
+ if($a->interactive)
+ $_SESSION['sysmsg_info'][] = $s;
+}
+
+/**
+ * @brief Wrapper around config to limit the text length of an incoming message
+ *
+ * @return int
+ */
+function get_max_import_size() {
+ return(intval(get_config('system', 'max_import_size')));
+}
+
+
+/**
+ *
+ * Wrap calls to proc_close(proc_open()) and call hook
+ * so plugins can take part in process :)
+ *
+ * args:
+ * $cmd program to run
+ * next args are passed as $cmd command line
+ *
+ * e.g.: proc_run("ls","-la","/tmp");
+ *
+ * $cmd and string args are surrounded with ""
+ */
+function proc_run($cmd){
+
+ $a = get_app();
+
+ $args = func_get_args();
+
+ $newargs = array();
+ if(! count($args))
+ return;
+
+ // expand any arrays
+
+ foreach($args as $arg) {
+ if(is_array($arg)) {
+ foreach($arg as $n) {
+ $newargs[] = $n;
+ }
+ }
+ else
+ $newargs[] = $arg;
+ }
+
+ $args = $newargs;
+
+ $arr = array('args' => $args, 'run_cmd' => true);
+
+ call_hooks("proc_run", $arr);
+ if(! $arr['run_cmd'])
+ return;
+
+ if(count($args) && $args[0] === 'php')
+ $args[0] = ((x($a->config,'system')) && (x($a->config['system'],'php_path')) && (strlen($a->config['system']['php_path'])) ? $a->config['system']['php_path'] : 'php');
+
+ for($x = 0; $x < count($args); $x++)
+ $args[$x] = escapeshellarg($args[$x]);
+
+ $cmdline = implode($args," ");
+
+ if(is_windows()) {
+ $cwd = getcwd();
+ $cmd = "cmd /c start \"title\" /D \"$cwd\" /b $cmdline";
+ proc_close(proc_open($cmd, array(), $foo));
+ }
+ else
+ proc_close(proc_open($cmdline ." &", array(), $foo));
+}
+
+/**
+ * @brief Checks if we are running on M$ Windows.
+ *
+ * @return bool true if we run on M$ Windows
+ */
+function is_windows() {
+ return ((strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? true : false);
+}
+
+
+function current_theme(){
+ $app_base_themes = array('redbasic');
+
+ $a = get_app();
+ $page_theme = null;
+
+ // Find the theme that belongs to the channel whose stuff we are looking at
+
+ if($a->profile_uid && $a->profile_uid != local_channel()) {
+ $r = q("select channel_theme from channel where channel_id = %d limit 1",
+ intval($a->profile_uid)
+ );
+ if($r)
+ $page_theme = $r[0]['channel_theme'];
+ }
+
+ if(array_key_exists('theme', $a->layout) && $a->layout['theme'])
+ $page_theme = $a->layout['theme'];
+
+ // Allow folks to over-rule channel themes and always use their own on their own site.
+ // The default is for channel themes to take precedence over your own on pages belonging
+ // to that channel.
+
+ if($page_theme && local_channel() && local_channel() != $a->profile_url) {
+ if(get_pconfig(local_channel(),'system','always_my_theme'))
+ $page_theme = null;
+ }
+
+ $is_mobile = $a->is_mobile || $a->is_tablet;
+
+ $standard_system_theme = ((isset($a->config['system']['theme'])) ? $a->config['system']['theme'] : '');
+ $standard_theme_name = ((isset($_SESSION) && x($_SESSION,'theme')) ? $_SESSION['theme'] : $standard_system_theme);
+
+ if($is_mobile) {
+ if(isset($_SESSION['show_mobile']) && !$_SESSION['show_mobile']) {
+ $system_theme = $standard_system_theme;
+ $theme_name = $standard_theme_name;
+ }
+ else {
+ $system_theme = ((isset($a->config['system']['mobile_theme'])) ? $a->config['system']['mobile_theme'] : '');
+ $theme_name = ((isset($_SESSION) && x($_SESSION,'mobile_theme')) ? $_SESSION['mobile_theme'] : $system_theme);
+
+ if($theme_name === '' || $theme_name === '---' ) {
+ // user has selected to have the mobile theme be the same as the normal one
+ $system_theme = $standard_system_theme;
+ $theme_name = $standard_theme_name;
+ }
+ }
+ }
+ else {
+ $system_theme = $standard_system_theme;
+ $theme_name = $standard_theme_name;
+
+ if($page_theme)
+ $theme_name = $page_theme;
+ }
+
+ if($theme_name &&
+ (file_exists('view/theme/' . $theme_name . '/css/style.css') ||
+ file_exists('view/theme/' . $theme_name . '/php/style.php')))
+ return($theme_name);
+
+ foreach($app_base_themes as $t) {
+ if(file_exists('view/theme/' . $t . '/css/style.css') ||
+ file_exists('view/theme/' . $t . '/php/style.php'))
+ return($t);
+ }
+
+ $fallback = array_merge(glob('view/theme/*/css/style.css'),glob('view/theme/*/php/style.php'));
+ if(count($fallback))
+ return (str_replace('view/theme/','', substr($fallback[0],0,-10)));
+
+}
+
+
+/**
+ * @brief Return full URL to theme which is currently in effect.
+ *
+ * Provide a sane default if nothing is chosen or the specified theme does not exist.
+ *
+ * @param bool $installing default false
+ *
+ * @return string
+ */
+function current_theme_url($installing = false) {
+ global $a;
+
+ $t = current_theme();
+
+ $opts = '';
+ $opts = (($a->profile_uid) ? '?f=&puid=' . $a->profile_uid : '');
+ $opts .= ((x($a->layout,'schema')) ? '&schema=' . $a->layout['schema'] : '');
+ if(file_exists('view/theme/' . $t . '/php/style.php'))
+ return('view/theme/' . $t . '/php/style.pcss' . $opts);
+
+ return('view/theme/' . $t . '/css/style.css');
+}
+
+/**
+ * @brief Check if current user has admin role.
+ *
+ * Check if the current user has ACCOUNT_ROLE_ADMIN.
+ *
+ * @return bool true if user is an admin
+ */
+function is_site_admin() {
+ $a = get_app();
+
+ if($_SESSION['delegate'])
+ return false;
+
+ if((intval($_SESSION['authenticated']))
+ && (is_array($a->account))
+ && ($a->account['account_roles'] & ACCOUNT_ROLE_ADMIN))
+ return true;
+
+ return false;
+}
+
+/**
+ * @brief Check if current user has developer role.
+ *
+ * Check if the current user has ACCOUNT_ROLE_DEVELOPER.
+ *
+ * @return bool true if user is a developer
+ */
+function is_developer() {
+ $a = get_app();
+ if((intval($_SESSION['authenticated']))
+ && (is_array($a->account))
+ && ($a->account['account_roles'] & ACCOUNT_ROLE_DEVELOPER))
+ return true;
+
+ return false;
+}
+
+
+function load_contact_links($uid) {
+ $a = get_app();
+
+ $ret = array();
+
+ if(! $uid || x($a->contacts,'empty'))
+ return;
+
+// logger('load_contact_links');
+
+ $r = q("SELECT abook_id, abook_flags, abook_my_perms, abook_their_perms, xchan_hash, xchan_photo_m, xchan_name, xchan_url from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d ",
+ intval($uid)
+ );
+ if($r) {
+ foreach($r as $rr){
+ $ret[$rr['xchan_hash']] = $rr;
+ }
+ }
+ else
+ $ret['empty'] = true;
+
+ $a->contacts = $ret;
+}
+
+
+/**
+ * @brief Returns querystring as string from a mapped array.
+ *
+ * @param array $params mapped array with query parameters
+ * @param string $name of parameter, default null
+ *
+ * @return string
+ */
+function build_querystring($params, $name = null) {
+ $ret = '';
+ foreach($params as $key => $val) {
+ if(is_array($val)) {
+ if($name === null) {
+ $ret .= build_querystring($val, $key);
+ } else {
+ $ret .= build_querystring($val, $name . "[$key]");
+ }
+ } else {
+ $val = urlencode($val);
+ if($name != null) {
+ $ret .= $name . "[$key]" . "=$val&";
+ } else {
+ $ret .= "$key=$val&";
+ }
+ }
+ }
+ return $ret;
+}
+
+
+// much better way of dealing with c-style args
+
+function argc() {
+ return get_app()->argc;
+}
+
+function argv($x) {
+ if(array_key_exists($x,get_app()->argv))
+ return get_app()->argv[$x];
+
+ return '';
+}
+
+function dba_timer() {
+ return microtime(true);
+}
+
+/**
+ * @brief Returns xchan_hash from the observer.
+ *
+ * @return string Empty if no observer, otherwise xchan_hash from observer
+ */
+function get_observer_hash() {
+ $observer = get_app()->get_observer();
+ if(is_array($observer))
+ return $observer['xchan_hash'];
+
+ return '';
+}
+
+
+/**
+ * Returns the complete URL of the current page, e.g.: http(s)://something.com/network
+ *
+ * Taken from http://webcheatsheet.com/php/get_current_page_url.php
+ */
+function curPageURL() {
+ $pageURL = 'http';
+ if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
+ $pageURL .= "://";
+ if ($_SERVER["SERVER_PORT"] != "80" && $_SERVER["SERVER_PORT"] != "443") {
+ $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
+ } else {
+ $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
+ }
+ return $pageURL;
+}
+
+/**
+ * @brief Returns a custom navigation by name???
+ *
+ * If no $navname provided load default page['nav']
+ *
+ * @todo not fully implemented yet
+ *
+ * @param App $a global application object
+ * @param string $navname
+ *
+ * @return mixed
+ */
+function get_custom_nav(&$a, $navname) {
+ if (! $navname)
+ return $a->page['nav'];
+ // load custom nav menu by name here
+}
+
+/**
+ * @brief Loads a page definition file for a module.
+ *
+ * If there is no parsed Comanche template already load a module's pdl file
+ * and parse it with Comanche.
+ *
+ * @param App &$a global application object
+ */
+function load_pdl(&$a) {
+ require_once('include/comanche.php');
+
+ if (! count($a->layout)) {
+
+ $arr = array('module' => $a->module, 'layout' => '');
+ call_hooks('load_pdl',$arr);
+ $s = $arr['layout'];
+
+ $n = 'mod_' . $a->module . '.pdl' ;
+ $u = comanche_get_channel_id();
+ if($u)
+ $s = get_pconfig($u, 'system', $n);
+
+ if((! $s) && (($p = theme_include($n)) != ''))
+ $s = @file_get_contents($p);
+ if($s) {
+ comanche_parser($a, $s);
+ $a->pdl = $s;
+ }
+ }
+
+}
+
+
+function exec_pdl(&$a) {
+ require_once('include/comanche.php');
+
+ if($a->pdl) {
+ comanche_parser($a, $a->pdl,1);
+ }
+}
+
+
+/**
+ * @brief build the page.
+ *
+ * Build the page - now that we have all the components
+ *
+ * @param App &$a global application object
+ */
+function construct_page(&$a) {
+
+ exec_pdl($a);
+
+ $comanche = ((count($a->layout)) ? true : false);
+
+ require_once(theme_include('theme_init.php'));
+
+ $installing = false;
+
+ if ($a->module == 'setup') {
+ $installing = true;
+ } else {
+ nav($a);
+ }
+
+ if ($comanche) {
+ if ($a->layout['nav']) {
+ $a->page['nav'] = get_custom_nav($a, $a->layout['nav']);
+ }
+ }
+
+ if (($p = theme_include(current_theme() . '.js')) != '')
+ head_add_js($p);
+
+ if (($p = theme_include('mod_' . $a->module . '.php')) != '')
+ require_once($p);
+
+ require_once('include/js_strings.php');
+
+ if (x($a->page, 'template_style'))
+ head_add_css($a->page['template_style'] . '.css');
+ else
+ head_add_css(((x($a->page, 'template')) ? $a->page['template'] : 'default' ) . '.css');
+
+ head_add_css('mod_' . $a->module . '.css');
+ head_add_css(current_theme_url($installing));
+
+ head_add_js('mod_' . $a->module . '.js');
+
+ $a->build_pagehead();
+
+ $arr = $a->get_widgets();
+ ksort($arr, SORT_NUMERIC);
+ if(count($arr)) {
+ foreach($arr as $x) {
+ if(! array_key_exists($x['location'], $a->page))
+ $a->page[$x['location']] = '';
+
+ $a->page[$x['location']] .= $x['html'];
+ }
+ }
+
+ // Let's say we have a comanche declaration '[region=nav][/region][region=content]$nav $content[/region]'.
+ // The text 'region=' identifies a section of the layout by that name. So what we want to do here is leave
+ // $a->page['nav'] empty and put the default content from $a->page['nav'] and $a->page['section']
+ // into a new region called $a->data['content']. It is presumed that the chosen layout file for this comanche page
+ // has a '' element instead of a ''.
+
+ // This way the Comanche layout can include any existing content, alter the layout by adding stuff around it or changing the
+ // layout completely with a new layout definition, or replace/remove existing content.
+
+ if($comanche) {
+ $arr = array('module' => $a->module, 'layout' => $a->layout);
+ call_hooks('construct_page', $arr);
+ $a->layout = $arr['layout'];
+
+ foreach($a->layout as $k => $v) {
+ if((strpos($k, 'region_') === 0) && strlen($v)) {
+ if(strpos($v, '$region_') !== false) {
+ $v = preg_replace_callback('/\$region_([a-zA-Z0-9]+)/ism', 'comanche_replace_region', $v);
+ }
+
+ // And a couple of convenience macros
+ if(strpos($v, '$htmlhead') !== false) {
+ $v = str_replace('$htmlhead', $a->page['htmlhead'], $v);
+ }
+ if(strpos($v, '$nav') !== false) {
+ $v = str_replace('$nav', $a->page['nav'], $v);
+ }
+ if(strpos($v, '$content') !== false) {
+ $v = str_replace('$content', $a->page['content'], $v);
+ }
+
+ $a->page[substr($k, 7)] = $v;
+ }
+ }
+ }
+
+ if($a->is_mobile || $a->is_tablet) {
+ if(isset($_SESSION['show_mobile']) && !$_SESSION['show_mobile']) {
+ $link = $a->get_baseurl() . '/toggle_mobile?f=&address=' . curPageURL();
+ }
+ else {
+ $link = $a->get_baseurl() . '/toggle_mobile?f=&off=1&address=' . curPageURL();
+ }
+ if ((isset($_SESSION) && $_SESSION['mobile_theme'] !='' && $_SESSION['mobile_theme'] !='---' ) ||
+ (isset($a->config['system']['mobile_theme']) && !isset($_SESSION['mobile_theme']))) {
+ $a->page['footer'] .= replace_macros(get_markup_template("toggle_mobile_footer.tpl"), array(
+ '$toggle_link' => $link,
+ '$toggle_text' => t('toggle mobile')
+ ));
+ }
+ }
+
+ $page = $a->page;
+ $profile = $a->profile;
+
+ header("Content-type: text/html; charset=utf-8");
+
+ require_once(theme_include(
+ ((x($a->page, 'template')) ? $a->page['template'] : 'default' ) . '.php' )
+ );
+}
+
+/**
+ * @brief Returns Hubzilla's root directory.
+ *
+ * @return string
+ */
+function appdirpath() {
+ return dirname(__FILE__);
+}
+
+/**
+ * @brief Set a pageicon.
+ *
+ * @param string $icon
+ */
+function head_set_icon($icon) {
+ global $a;
+
+ $a->data['pageicon'] = $icon;
+// logger('head_set_icon: ' . $icon);
+}
+
+/**
+ * @brief Get the pageicon.
+ *
+ * @return string absolut path to pageicon
+ */
+function head_get_icon() {
+ global $a;
+
+ $icon = $a->data['pageicon'];
+ if(! strpos($icon, '://'))
+ $icon = z_root() . $icon;
+
+ return $icon;
+}
+
+/**
+ * @brief Return the Realm of the directory.
+ *
+ * @return string
+ */
+function get_directory_realm() {
+ if($x = get_config('system', 'directory_realm'))
+ return $x;
+
+ return DIRECTORY_REALM;
+}
+
+/**
+ * @brief Return the primary directory server.
+ *
+ * @return string
+ */
+function get_directory_primary() {
+
+ $dirmode = intval(get_config('system','directory_mode'));
+
+ if($dirmode == DIRECTORY_MODE_STANDALONE || $dirmode == DIRECTORY_MODE_PRIMARY) {
+ return z_root();
+ }
+
+ if($x = get_config('system', 'directory_primary'))
+ return $x;
+
+ return DIRECTORY_FALLBACK_MASTER;
+}
+
+
+/**
+ * @brief return relative date of last completed poller execution.
+ */
+function get_poller_runtime() {
+ $t = get_config('system', 'lastpoll');
+ return relative_date($t);
+}
+
+function z_get_upload_dir() {
+ $upload_dir = get_config('system','uploaddir');
+ if(! $upload_dir)
+ $upload_dir = ini_get('upload_tmp_dir');
+ if(! $upload_dir)
+ $upload_dir = sys_get_temp_dir();
+ return $upload_dir;
+}
+
+function z_get_temp_dir() {
+ $temp_dir = get_config('system','tempdir');
+ if(! $temp_dir)
+ $temp_dir = sys_get_temp_dir();
+ return $upload_dir;
+}
+
+function z_check_cert() {
+ $a = get_app();
+ if(strpos(z_root(),'https://') !== false) {
+ $x = z_fetch_url(z_root() . '/siteinfo/json');
+ if(! $x['success']) {
+ $recurse = 0;
+ $y = z_fetch_url(z_root() . '/siteinfo/json',false,$recurse,array('novalidate' => true));
+ if($y['success'])
+ cert_bad_email();
+ }
+ }
+}
+
+
+/**
+ * @brief Send email to admin if server has an invalid certificate.
+ *
+ * If a Hubzilla hub is available over https it must have a publicly valid
+ * certificate.
+ */
+function cert_bad_email() {
+
+ $a = get_app();
+
+ $email_tpl = get_intltext_template("cert_bad_eml.tpl");
+ $email_msg = replace_macros($email_tpl, array(
+ '$sitename' => $a->config['system']['sitename'],
+ '$siteurl' => $a->get_baseurl(),
+ '$error' => t('Website SSL certificate is not valid. Please correct.')
+ ));
+
+ $subject = email_header_encode(sprintf(t('[hubzilla] Website SSL error for %s'), $a->get_hostname()));
+ mail($a->config['system']['admin_email'], $subject, $email_msg,
+ 'From: Administrator' . '@' . $a->get_hostname() . "\n"
+ . 'Content-type: text/plain; charset=UTF-8' . "\n"
+ . 'Content-transfer-encoding: 8bit' );
+}
+
+
+/**
+ * @brief Send warnings every 3-5 days if cron is not running.
+ */
+function check_cron_broken() {
+
+ $t = get_config('system','lastpollcheck');
+ if(! $t) {
+ // never checked before. Start the timer.
+ set_config('system','lastpollcheck',datetime_convert());
+ return;
+ }
+ if($t > datetime_convert('UTC','UTC','now - 3 days')) {
+ // Wait for 3 days before we do anything so as not to swamp the admin with messages
+ return;
+ }
+
+ $d = get_config('system','lastpoll');
+ if(($d) && ($d > datetime_convert('UTC','UTC','now - 3 days'))) {
+ // Scheduled tasks have run successfully in the last 3 days.
+ set_config('system','lastpollcheck',datetime_convert());
+ return;
+ }
+
+ $a = get_app();
+
+ $email_tpl = get_intltext_template("cron_bad_eml.tpl");
+ $email_msg = replace_macros($email_tpl, array(
+ '$sitename' => $a->config['system']['sitename'],
+ '$siteurl' => $a->get_baseurl(),
+ '$error' => t('Cron/Scheduled tasks not running.'),
+ '$lastdate' => (($d)? $d : t('never'))
+ ));
+
+ $subject = email_header_encode(sprintf(t('[hubzilla] Cron tasks not running on %s'), $a->get_hostname()));
+ mail($a->config['system']['admin_email'], $subject, $email_msg,
+ 'From: Administrator' . '@' . $a->get_hostname() . "\n"
+ . 'Content-type: text/plain; charset=UTF-8' . "\n"
+ . 'Content-transfer-encoding: 8bit' );
+ set_config('system','lastpollcheck',datetime_convert());
+ return;
+}
diff --git a/sources/doc/AdvancedSearch.md b/sources/doc/AdvancedSearch.md
new file mode 100644
index 00000000..a67c1fc1
--- /dev/null
+++ b/sources/doc/AdvancedSearch.md
@@ -0,0 +1,53 @@
+Advanced Directory Search
+=========================
+
+
+Advanced Directory Search is enabled in "Expert Mode" from your Settings => Additional features page.
+
+On the Directory page an option named "Advanced" will apear in the "Find Channels" widget (typically in the sidebar). Clicking "Advanced" will open another search box for entering advanced search requests.
+
+Advanced requests include
+
+* name=xxx
+[Channel name contains xxx]
+
+* address=xxx
+[Channel address (webbie) contains xxx]
+
+* locale=xxx
+[Locale (typically 'city') contains xxx]
+
+* region=xxx
+[Region (state/territory) contains xxx]
+
+* postcode=xxx
+[Postcode or zip code contains xxx]
+
+* country=xxx
+[Country name contains xxx]
+
+* gender=xxx
+[Gender contains xxx]
+
+* marital=xxx
+[Marital status contains xxx]
+
+* sexual=xxx
+[Sexual preference contains xxx]
+
+* keywords=xxx
+[Keywords contain xxx]
+
+There are many reasons why a match may not return what you're looking for, as many channels do not provide detailed information in their default (public) profile, and many of these fields allow free-text input in several languages - and this may be difficult to match precisely. For instance you may have better results finding somebody in the USA with 'country=u' (along with some odd channels from Deutschland and Bulgaria and Australia) because this could be represented in a profile as US, U.S.A, USA, United States, etc...
+
+Future revisions of this tool may try to smooth over some of these difficulties.
+
+Requests may be joined together with 'and', 'or', and 'and not'.
+
+Terms containing spaces must be quoted.
+
+Example:
+
+ name="charlie brown" and country=canada and not gender=female
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/Comparison-of-activity-stream-networks.md b/sources/doc/Comparison-of-activity-stream-networks.md
new file mode 100644
index 00000000..d76ae100
--- /dev/null
+++ b/sources/doc/Comparison-of-activity-stream-networks.md
@@ -0,0 +1,23 @@
+Comparison of different server-client networks providing activity streams to users
+====================================
+The goal of this table was to provide an overview of the security and privacy provided by server-client networks providing activity-streams.
+
+| project | license | distributed | supports node isolation | server-to-server encryption | 1-click E2EE* | database encryption sceme | supports cloning[^5] | encryption of private messages | PFS chat | wall-to-wall interaction | supports post editing and unsend private message | other |
+|-----------+---------------+-------------+-------------------------+-------------------------------------------+------------------------------------------+-----------------------------------------------------+-------------------------+-------------------------------------------------------------------------------------------------+-----------------------------------------------+--------------------------------------------------------------+--------------------------------------------------+------------------------------------------------------------------------------|
+| hubzilla | ISC aka MIT | yes | yes | Zot (PKI) + TLS | yes (via JavaScript, AES-256) | content obfuscation, private keys hidden in the DB. | yes, partly implemented | impossible to message privately in plaintext | no | yes, multiple separated channels possible within one account | yes | privacy built in, run your own @ home, nodes are called hubs |
+| diaspora | AGPLv3orlater | yes | no[^1] | PKI + SSL/TLS[^1] | no[^2] | mostly plaintext | no | ? | no | yes, no naming policy | no | nodes are called pods |
+| facebook | proprietary | no | no | planned, probably not implemented yet[^3] | implemented but not offered to users[^4] | unknown | no, walled garden | no, 3-d party plugin Cryptocat and pidgin is availiable but the user is not informed about this | no, with Cryptocat: yes, with pidgin+OTR: yes | only one wall allowed | only post editing | "real name"-policy enforced, advertising-driven, for profit company US-based |
+| twitter | proprietary | no | no | unknown | no | unknown, probably none | no, walled garden | no | no | yes | only post editing | advertising-driven, for profit company US-based |
+| | | | | | | | | | | | | |
+
+This table was edited with emacs using org-mode.
+
+[^1]: https://wiki.diasporafoundation.org/Federation_protocol_overview
+
+[^2]: forks providing this exists
+
+[^3]: http://news.softpedia.com/news/Facebook-Aims-to-Encrypt-Everything-Between-Data-Centers-433091.shtml
+
+[^4]: http://www.computerworld.com/article/2488773/cybercrime-hacking/facebook-holds-back-on-end-to-end-encryption.html
+
+[^5]: see the hubzilla help files for details about this feature.
diff --git a/sources/doc/Creating-Templates.md b/sources/doc/Creating-Templates.md
new file mode 100644
index 00000000..6de627f3
--- /dev/null
+++ b/sources/doc/Creating-Templates.md
@@ -0,0 +1,93 @@
+Creating Page Templates
+=======================
+
+
+A page template for use with Comanche requires two files - a PHP template and a CSS file. Page templates will need to be installed by the system administrator of your site.
+
+
+First choose a name. Here we'll create a template and call it "demo".
+
+You will need to create the files "view/php/demo.php" and "view/css/demo.css" to hold the PHP template and CSS respectively.
+
+To get a better idea of this process, let's look at an existing template - the "default" template. This is used by default throughout the application.
+
+view/php/default.php
+====================
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Here's is the corresponding CSS file
+
+view/php/default.css
+====================
+
+
+ aside#region_1 {
+ display: block;
+ width: 210px;
+ position: absolute;
+ top: 65px;
+ left: 0;
+ margin-left: 10px;
+ }
+
+ aside input[type='text'] {
+ width: 174px;
+ }
+
+
+ section {
+ position: absolute;
+ top: 65px;
+ left: 250px;
+ display: block;
+ right: 15px;
+ padding-bottom: 350px;
+ }
+
+
+Some things you may notice when looking at these definitions:
+
+* We have not specified any CSS for the "nav", "right_aside", or "footer" regions. In this template "nav" and "footer" will be the full page width and we will let the size and placement of these elements be controlled by the theme. "right_aside" is not currently used.
+
+* There are elements on the page such as "page-footer" and "pause" for which there is no apparent content. This content will come from Javascript elements.
+
+* Our default template uses absolute positioning. Modern web design often uses "float" div containers so that scrollbars aren't typically needed when viewing on small-screen devices.
+
+To design a new template, it is best to start with an existing template, and modify it as desired. That is what we will do here.
+
+The way that Comanche provides content inside a specific region is by using a region tag.
+
+ [region=aside][widget=profile][/widget][/region]
+
+This example will place a "profile" widget in the "aside" region. But what it actually does is place the HTML for the widget into a code variable **$page['aside']**. Our default page template defines a region on the page (the CSS positions this as an absolute sidebar) and then inserts the contents of $page['aside'] (if it exists).
+
+So if you wanted to create a template with a region named "foo", you would provide a place for it on the page, then include the contents of $page['foo'] wherever you wanted to use it, and then using Comanche, you could specify
+
+ [region=foo][widget=profile][/widget][/region]
+
+and this would place a profile widget into the "foo" region you created.
+
+Use the CSS file to position the region on the page where desired and optionally control its size.
+
+[To be continued]
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/DerivedTheme1.md b/sources/doc/DerivedTheme1.md
new file mode 100644
index 00000000..805d6b61
--- /dev/null
+++ b/sources/doc/DerivedTheme1.md
@@ -0,0 +1,77 @@
+Creating a Derived Theme
+========================
+
+**Lesson 1**
+
+A derived theme takes most of the settings from its "parent" theme and lets you change a few things to your liking without creating an entire theme package.
+
+
+To create a derived theme, first choose a name. For our example we'll call our theme 'mytheme'. Hopefully you'll be a bit more creative. But throughout this document, wherever you see 'mytheme', replace that with the name you chose.
+
+**Directory Structure**
+
+First you need to create a theme directory structure. We'll keep it simple. We need a php directory and a css directory. Here are the Unix/Linux commands to do this. Assume that 'mywebsite' is your top level $Projectname folder.
+
+
+ cd mywebsite
+ mkdir view/theme/mytheme
+ mkdir view/theme/mytheme/css
+ mkdir view/theme/mytheme/php
+
+
+Great. Now we need a couple of files. The first one is your theme info file, which describes the theme.
+
+It will be called view/theme/mytheme/php/theme.php (clever name huh?)
+
+Inside it, put the following information - edit as needed
+
+ theme_info['extends'] = 'redbasic';
+
+
+ }
+
+
+Remember to rename the mytheme_init function with your theme name. In this case we will be extending the theme 'redbasic'.
+
+
+Now create another file. We call this a PCSS file, but it's really a PHP file.
+
+The file is called view/theme/mytheme/php/style.php
+
+In it, put the following:
+
+ Display Settings as their default theme.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/Developers.md b/sources/doc/Developers.md
new file mode 100644
index 00000000..b19b4fc2
--- /dev/null
+++ b/sources/doc/Developers.md
@@ -0,0 +1,54 @@
+Developer Guide
+===================
+
+**Here is how you can join us.**
+
+First, get yourself a working git package on the system where you will be
+doing development.
+
+Create your own github account.
+
+You may fork/clone the Red repository from [https://github.com/redmatrix/hubzilla.git](https://github.com/redmatrix/hubzilla.git).
+
+Follow the instructions provided here: [http://help.github.com/fork-a-repo/](http://help.github.com/fork-a-repo/)
+to create and use your own tracking fork on github
+
+Then go to your github page and create a "Pull request" when you are ready
+to notify us to merge your work.
+
+**Translations**
+
+Our translations are managed through Transifex. If you wish to help out translating the $Projectname to another language, sign up on transifex.com, visit [https://www.transifex.com/projects/p/red-matrix/](https://www.transifex.com/projects/p/red-matrix/) and request to join one of the existing language teams or create a new one. Notify one of the core developers when you have a translation update which requires merging, or ask about merging it yourself if you're comfortable with git and PHP. We have a string file called 'messages.po' which is gettext compliant and a handful of email templates, and from there we automatically generate the application's language files.
+
+[Translations - More Info](help/Translations)
+
+**Important**
+
+Please pull in any changes from the project repository and merge them with your work **before** issuing a pull request. We reserve the right to reject any patch which results in a large number of merge conflicts. This is especially true in the case of language translations - where we may not be able to understand the subtle differences between conflicting versions.
+
+Also - **test your changes**. Don't assume that a simple fix won't break something else. If possible get an experienced Red developer to review the code.
+
+
+**Licensing**
+
+All code contributed to the project falls under the MIT license, unless otherwise specified. We will accept third-party code which falls under MIT, BSD and LGPL, but copyleft licensing (GPL, and AGPL) is only permitted in addons. It must be possible to completely remove the GPL (copyleft) code from the main project without breaking anything.
+
+**Coding Style**
+
+In the interests of consistency we adopt the following code styling. We may accept patches using other styles, but where possible please try to provide a consistent code style. We aren't going to argue or debate the merits of this style, and it is irrelevant what project 'xyz' uses. This is not project 'xyz'. This is a baseline to try and keep the code readable now and in the future.
+
+* All comments should be in English.
+
+* We use doxygen to generate documentation. This hasn't been consistently applied, but learning it and using it are highly encouraged.
+
+* Indentation is accomplished primarily with tabs using a tab-width of 4.
+
+* String concatenation and operators should be separated by whitespace. e.g. "$foo = $bar . 'abc';" instead of "$foo=$bar.'abc';"
+
+* Generally speaking, we use single quotes for string variables and double quotes for SQL statements. "Here documents" should be avoided. Sometimes using double quoted strings with variable replacement is the most efficient means of creating the string. In most cases, you should be using single quotes.
+
+* Use whitespace liberally to enhance readability. When creating arrays with many elements, we will often set one key/value pair per line, indented from the parent line appropriately. Lining up the assignment operators takes a bit more work, but also increases readability.
+
+* Generally speaking, opening braces go on the same line as the thing which opens the brace. They are the last character on the line. Closing braces are on a line by themselves.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/Features.md b/sources/doc/Features.md
new file mode 100644
index 00000000..5a1e8c74
--- /dev/null
+++ b/sources/doc/Features.md
@@ -0,0 +1,108 @@
+Extra Features
+==============
+
+The default interface of the $Projectname was designed to be uncluttered. There are a huge number of extra features (some of which are extremely useful) which you can turn on and get the most of the application. These are found under the [Extra Features](settings/features) link of your [Settings](settings) page.
+
+**Content Expiration**
+
+Remove posts/comments and/or private messages at a future time. An extra button is added to the post editor which asks you for an expiration. Typically this in "yyyy-mm-dd hh:mm" format, but in the English language you have a bit more freedom and can use most any recognisable date reference such as "next Thursday" or "+1 day". At the specified time (give or take approximately ten minutes based on the remote system's checking frequency) the post is removed.
+
+**Multiple Profiles**
+
+The ability to create multiple profiles which are visible only to specific persons or groups. Your default profile may be visible to anybody, but secondary profiles can all contain different or additional information and can only be seen by those to whom that profile is assigned.
+
+**Web Pages**
+
+Provides the ability to use web page design feaures and create custom webpages from your own content and also to design the pages with page layouts, custom menus, and content blocks.
+
+**Private Notes**
+
+On pages where it is available (your matrix page and personal web pages) provide a "widget" to create and store personal reminders and notes.
+
+**Enhanced Photo Albums**
+
+Provides a photo album viewer that is a bit prettier than the normal interface.
+
+**Extended Identity Sharing**
+
+By default your identity travels with you as you browse the matrix to remote sites - and they know who you are and can show you content that only you can see. With Extended Identity Sharing you can provide this information to any website you visit from within the matrix.
+
+**Expert Mode**
+
+This allows you to see some advanced configuration options that would confuse some people or cause support issues. In particular this can give you full control over theme features and colours - so that you can tweak a large number of settings of the display theme to your liking.
+
+**Premium Channel**
+
+This allows you to set restrictions and terms on those that connect with your channel. This may be used by celebrities or anybody else who wishes to describe their channel to people who wish to connect with it. In certain cases you may be asked for payment in order to connect.
+
+
+**Richtext Editor**
+
+The status post editor is plaintext, but the matrix allows a wide range of markup using BBcode. The visual editor provides "what you see is what you get" for many of the most frequently used markup tags.
+
+**Post Preview**
+
+Allows previewing posts and comments exactly as they would look on the page before publishing them.
+
+**Channel Sources**
+
+Automatically import and re-publish channel content from other channels or feeds. This allows you to create sub-channels and super-channels from content provided elsewhere. The rules are that the content must be public, and the channel owner must give you permission to source their channel.
+
+**Even More Encryption**
+
+Private messages are encrypted during transport and storage. In this day and age, this encyption may not be enough if your communications are extremely sensitive. This options lets you provide optional encryption of content "end-to-end" with a shared secret key. How the recipient learns the secret key is completely up to you. You can provide a hint such as "the name of aunt Claire's first dog".
+
+
+**Search by Date**
+
+This provides the ability to select posts by date ranges
+
+**Collections Filter**
+
+Enable widget to display stream posts only from selected collections. This also toggles the outbound permissions while you are viewing a collection. This is analogous to Google "circles" or Disapora "aspects".
+
+**Saved Searches**
+
+Provides a search widget on your matrix page which can save selected search terms for re-use.
+
+**Personal Tab**
+
+Enable tab to display only matrix posts that you've interacted with in some way, as an author or a contributor to the conversation.
+
+**New Tab**
+
+Enables a tab to display all new matrix activity as a firehose or timeline.
+
+**Affinity Tool**
+
+Filter matrix stream activity by the depth of your relationships
+
+**Edit Sent Posts**
+
+Edit and correct posts and comments after sending
+
+**Tagging**
+
+Ability to tag existing posts, including those written by others.
+
+**Post Categories**
+
+Add categories to your channel posts
+
+**Saved Folders**
+
+Ability to file posts under folders or tags for later recall
+
+**Dislike Posts**
+
+Ability to dislike posts/comments
+
+**Star Posts**
+
+Ability to mark special posts with a star indicator
+
+**Tag Cloud**
+
+Provide a personal tag cloud on your channel page
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/Hooks.md b/sources/doc/Hooks.md
new file mode 100644
index 00000000..90edff62
--- /dev/null
+++ b/sources/doc/Hooks.md
@@ -0,0 +1,136 @@
+Hooks - Complete List
+=====================
+
+
+* 'about_hook'
+* 'account_settings'
+* 'app_menu'
+* 'atom_author'
+* 'atom_entry'
+* 'atom_feed'
+* 'atom_feed_end'
+* 'authenticate'
+* 'avatar_lookup'
+* 'bb2diaspora'
+* 'bbcode'
+* 'channel_remove'
+* 'check_account_email'
+* 'check_account_invite'
+* 'check_account_password'
+* 'connect_premium'
+* 'connector_settings'
+* 'contact_block_end'
+* 'contact_edit'
+* 'contact_edit_post'
+* 'contact_photo_menu'
+* 'contact_select_options'
+* 'conversation_start'
+* 'cron'
+* 'directory_item'
+* 'display_item'
+* 'display_item'
+* 'display_settings'
+* 'display_settings_post'
+* 'enotify'
+* 'enotify_mail'
+* 'enotify_store'
+* 'event_created'
+* 'event_updated'
+* 'feature_enabled'
+* 'feature_settings'
+* 'feature_settings_post'
+* 'follow'
+* 'gender_selector'
+* 'get_all_perms'
+* 'get_features'
+* 'get_widgets'
+* 'global_permissions'
+* 'home_content'
+* 'home_init'
+* 'html2bbcode'
+* 'import_directory_profile'
+* 'init_1'
+* 'item_photo_menu'
+* 'item_translate'
+* 'jot_networks'
+* 'jot_tool'
+* 'logged_in'
+* 'login_hook'
+* 'logging_out'
+* 'magic_auth'
+* 'magic_auth_success'
+* 'main_slider'
+* 'marital_selector'
+* 'mood_verbs'
+* 'network_content_init'
+* 'network_ping'
+* 'network_tabs'
+* 'network_to_name'
+* 'notifier_end'
+* 'notifier_normal'
+* 'obj_verbs'
+* 'oembed_probe'
+* 'page_content_top'
+* 'page_end'
+* 'page_header'
+* 'parse_atom'
+* 'parse_link'
+* 'pdl_selector'
+* 'perm_is_allowed'
+* 'personal_xrd'
+* 'photo_post_end'
+* 'photo_post_end'
+* 'photo_upload_begin'
+* 'photo_upload_end'
+* 'photo_upload_file'
+* 'photo_upload_form'
+* 'poke_verbs'
+* 'post_local'
+* 'post_local_end'
+* 'post_local_start'
+* 'post_mail'
+* 'post_mail_end'
+* 'post_remote'
+* 'post_remote_end'
+* 'post_remote_update'
+* 'post_remote_update_end'
+* 'prepare_body'
+* 'prepare_body_final'
+* 'prepare_body_init'
+* 'proc_run'
+* 'profile_advanced'
+* 'profile_edit'
+* 'profile_post'
+* 'profile_sidebar'
+* 'profile_sidebar_enter'
+* 'profile_tabs'
+* 'register_account'
+* 'render_location'
+* 'settings_account'
+* 'settings_form'
+* 'settings_post'
+* 'sexpref_selector'
+* 'smilie'
+* 'validate_channelname'
+* 'webfinger'
+* 'zid'
+* 'zid_init'
+
+***General Module Hooks***
+
+* $a->module . '_mod_aftercontent'
+* $a->module . '_mod_aside'
+* $a->module . '_mod_content'
+* $a->module . '_mod_init'
+* $a->module . '_mod_post'
+
+***General Selector Hooks***
+
+* $a->module . '_post_' . $selname
+* $a->module . '_post_' . $selname
+* $a->module . '_post_' . $selname
+* $a->module . '_pre_' . $selname
+* $a->module . '_pre_' . $selname
+* $a->module . '_pre_' . $selname
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/Plugins.md b/sources/doc/Plugins.md
new file mode 100644
index 00000000..90ff0fb7
--- /dev/null
+++ b/sources/doc/Plugins.md
@@ -0,0 +1,263 @@
+
+Creating Plugins/Addons for the $Projectname
+==========================================
+
+
+So you want to make the $Projectname do something it doesn't already do. There are lots of ways. But let's learn how to write a plugin or addon.
+
+
+In your $Projectname folder/directory, you will probably see a sub-directory called 'addon'. If you don't have one already, go ahead and create it.
+
+
+ mkdir addon
+
+Then figure out a name for your addon. You probably have at least a vague idea of what you want it to do. For our example I'm going to create a plugin called 'randplace' that provides a somewhat random location for each of your posts. The name of your plugin is used to find the functions we need to access and is part of the function names, so to be safe, use only simple text characters.
+
+Once you've chosen a name, create a directory beneath 'addon' to hold your working file or files.
+
+ mkdir addon/randplace
+
+Now create your plugin file. It needs to have the same name, and it's a PHP script, so using your favourite editor, create the file
+
+ addon/randplace/randplace.php
+
+The very first line of this file needs to be
+
+
+ *
+ */
+
+These tags will be seen by the site administrator when he/she installs or manages plugins from the admin panel. There can be more than one author. Just add another line starting with 'Author:'.
+
+The typical plugin will have at least the following functions:
+
+* pluginname_load()
+* pluginname_unload()
+
+In our case, we'll call them randplace_load() and randplace_unload(), as that is the name of our plugin. These functions are called whenever we wish to either initialise the plugin or remove it from the current webpage. Also if your plugin requires things like altering the database schema before it can run for the very first time, you would likely place these instructions in the functions named
+
+* pluginname_install()
+* pluginname_uninstall()
+
+
+Next we'll talk about **hooks**. Hooks are places in the $Projectname code where we allow plugins to do stuff. There are a [lot of these](help/Hooks), and they each have a name. What we normally do is use the pluginname_load() function to register a "handler function" for any hooks you are interested in. Then when any of these hooks are triggered, your code will be called.
+
+We register hook handlers with the 'register_hook()' function. It takes 3 arguments. The first is the hook we wish to catch, the second is the filename of the file to find our handler function (relative to the base of your $Projectname installation), and the third is the function name of your handler function. So let's create our randplace_load() function right now.
+
+
+ function randplace_load() {
+ register_hook('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook');
+
+ register_hook('feature_settings', 'addon/randplace/randplace.php', 'randplace_settings');
+ register_hook('feature_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post');
+
+ }
+
+
+So we're going to catch three events, 'post_local' which is triggered when a post is made on the local system, 'feature_settings' to set some preferences for our plugin, and 'feature_settings_post' to store those settings.
+
+Next we'll create an unload function. This is easy, as it just unregisters our hooks. It takes exactly the same arguments.
+
+ function randplace_unload() {
+ unregister_hook('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook');
+
+ unregister_hook('feature_settings', 'addon/randplace/randplace.php', 'randplace_settings');
+ unregister_hook('feature_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post');
+
+ }
+
+
+Hooks are called with two arguments. The first is always $a, which is our global App structure and contains a huge amount of information about the state of the web request we are processing; as well as who the viewer is, and what our login state is, and the current contents of the web page we're probably constructing.
+
+The second argument is specific to the hook you're calling. It contains information relevant to that particular place in the program, and often allows you to look at, and even change it. In order to change it, you need to add '&' to the variable name so it is passed to your function by reference. Otherwise it will create a copy and any changes you make will be lost when the hook process returns. Usually (but not always) the second argument is a named array of data structures. Please see the "hook reference" (not yet written as of this date) for details on any specific hook. Occasionally you may need to view the program source to see precisely how a given hook is called and how the results are processed.
+
+Let's go ahead and add some code to implement our post_local hook handler.
+
+ function randplace_post_hook($a, &$item) {
+
+ /**
+ *
+ * An item was posted on the local system.
+ * We are going to look for specific items:
+ * - A status post by a profile owner
+ * - The profile owner must have allowed our plugin
+ *
+ */
+
+ logger('randplace invoked');
+
+ if(! local_channel()) /* non-zero if this is a logged in user of this system */
+ return;
+
+ if(local_channel() != $item['uid']) /* Does this person own the post? */
+ return;
+
+ if(($item['parent']) || (! is_item_normal($item))) {
+ /* If the item has a parent, or isn't "normal", this is a comment or something else, not a status post. */
+ return;
+ }
+
+ /* Retrieve our personal config setting */
+
+ $active = get_pconfig(local_channel(), 'randplace', 'enable');
+
+ if(! $active)
+ return;
+ /**
+ *
+ * OK, we're allowed to do our stuff.
+ * Here's what we are going to do:
+ * load the list of timezone names, and use that to generate a list of world cities.
+ * Then we'll pick one of those at random and put it in the "location" field for the post.
+ *
+ */
+
+ $cities = array();
+ $zones = timezone_identifiers_list();
+ foreach($zones as $zone) {
+ if((strpos($zone,'/')) && (! stristr($zone,'US/')) && (! stristr($zone,'Etc/')))
+ $cities[] = str_replace('_', ' ',substr($zone,strpos($zone,'/') + 1));
+ }
+
+ if(! count($cities))
+ return;
+ $city = array_rand($cities,1);
+ $item['location'] = $cities[$city];
+
+ return;
+ }
+
+
+Now let's add our functions to create and store preference settings.
+
+ /**
+ *
+ * Callback from the settings post function.
+ * $post contains the global $_POST array.
+ * We will make sure we've got a valid user account
+ * and that only our own submit button was clicked
+ * and if so set our configuration setting for this person.
+ *
+ */
+
+ function randplace_settings_post($a,$post) {
+ if(! local_channel())
+ return;
+ if($_POST['randplace-submit'])
+ set_pconfig(local_channel(),'randplace','enable',intval($_POST['randplace']));
+ }
+
+
+
+ /**
+ *
+ * Called from the Feature Setting form.
+ * The second argument is a string in this case, the HTML content region of the page.
+ * Add our own settings info to the string.
+ *
+ * For uniformity of settings pages, we use the following convention
+ *
+ *
title
+ * .... settings html - many elements will be floated...
+ *
+ *
+ *
+ */
+
+
+
+ function randplace_settings(&$a,&$s) {
+
+ if(! local_channel())
+ return;
+
+ /* Add our stylesheet to the page so we can make our settings look nice */
+
+ head_add_css('/addon/randplace/randplace.css');
+
+ /* Get the current state of our config variable */
+
+ $enabled = get_pconfig(local_channel(),'randplace','enable');
+
+ $checked = (($enabled) ? ' checked="checked" ' : '');
+
+ /* Add some HTML to the existing form */
+
+ $s .= '
';
+ $s .= '
' . t('Randplace Settings') . '
';
+ $s .= '
';
+ $s .= '';
+ $s .= '';
+ $s .= '
';
+
+ /* provide a submit button */
+
+ $s .= '
';
+
+ }
+
+
+
+
+
+***Advanced Plugins***
+
+Sometimes your plugins want to provide a range of new functionality which isn't provided at all or is clumsy to provide using hooks. In this case your plugin can also act as a 'module'. A module in our case refers to a structured webpage handler which responds to a given URL. Then anything which accesses that URL will be handled completely by your plugin.
+
+The key to this is to create a simple function named pluginname_module() which does nothing.
+
+ function randplace_module() { return; }
+
+Once this function exists, the URL https://yoursite/randplace will access your plugin as a module. Then you can define functions which are called at various points to build a webpage just like the modules in the mod/ directory. The typical functions and the order which they are called is
+
+ modulename_init($a) // (e.g. randplace_init($a);) called first - if you wish to emit json or xml,
+ // you should do it here, followed by killme() which will avoid the default action of building a webpage
+ modulename_aside($a) // Often used to create sidebar content
+ modulename_post($a) // Called whenever the page is accessed via the "post" method
+ modulename_content($a) // called to generate the central page content. This function should return a string
+ // consisting of the central page content.
+
+Your module functions have access to the URL path as if they were standalone programs in the Unix operating system. For instance if you visit the page
+
+ https://yoursite/randplace/something/somewhere/whatever
+
+we will create an argc/argv list for use by your module functions
+
+ $x = argc(); $x will be 4, the number of path arguments after the sitename
+
+ for($x = 0; $x < argc(); $x ++)
+ echo $x . ' ' . argv($x);
+
+
+ 0 randplace
+ 1 something
+ 2 somewhere
+ 3 whatever
+
+
+***Porting Friendica Plugins***
+
+The $Projectname uses a similar plugin architecture to the Friendica project. The authentication, identity, and permissions systems are completely different. Many Friendica can be ported reasonably easily by renaming a few functions - and then ensuring that the permissions model is adhered to. The functions which need to be renamed are:
+
+* Friendica's pluginname_install() is pluginname_load()
+
+* Friendica's pluginname_uninstall() is pluginname_unload()
+
+The $Projectname has _install and _uninstall functions but these are used differently.
+
+* Friendica's "plugin_settings" hook is called "feature_settings"
+
+* Friendica's "plugin_settings_post" hook is called "feature_settings_post"
+
+Changing these will often allow your plugin to function, but please double check all your permission and identity code because the concepts behind it are completely different in the $Projectname. Many structured data names (especially DB schema columns) are also quite different.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/Primary-Directory.md b/sources/doc/Primary-Directory.md
new file mode 100644
index 00000000..37b0c043
--- /dev/null
+++ b/sources/doc/Primary-Directory.md
@@ -0,0 +1,47 @@
+#Primary Directory#
+
+By default, $Projectname will use available Directories on the web, which show you channels available around the world.
+
+There are certain scenarios where you might want your own directory-server that you can connect multiple hubs to. This will limit the channels that appear in all of your hubs to only channels on hubs connected to your directory-server.
+
+
+
+##Instuctions on how to set up one hub as the Primary Directory for a series of private hubs.##
+***
+
+
+* On the hub that will be the Directory Server, open the .htconfig.php file and set:
+
+ `$a->config['system']['directory_mode'] = DIRECTORY_MODE_PRIMARY;`
+
+
+ By default it should already be set as **DIRECTORY_MODE_NORMAL**, so just edit that line to say **DIRECTORY_MODE_PRIMARY**
+
+* Next, for each hub (including the Directory Server), from a terminal, cd into the folder where it is installed and run this :
+
+ `util/config system directory_realm YOURREALMNAME`
+
+ (**YOURREALMNAME** can be whatever you want your realm-name to be)
+
+ then:
+
+ `util/config system realm_token THEPASSWORD`
+
+ (**THEPASSWORD** is whatever password you want for your realm)
+
+ **NOTE:** Use the same realm-name and password for each hub
+
+* Lastly, for each "client" hub, (from a terminal) run:
+
+ `util/config system directory_server https://theaddressofyourdirectoryserver.com`
+
+***
+Now when you view the directory of each hub, it should only show the channels that exist on the hubs in your realm. I have tested with two hubs so far, and it seems to be working fine.
+Channels created in each hub are reflected in the Primary Directory, and subsequently in the directory of all client hubs
+
+##Issues##
+***
+
+When I created the first hub,it was up and running for an hour or so before I changed it to PRIMARY_MODE, and after changing it, there were a few channels from across the matrix still present in the directory. I deleted them from the xchan table and that seems to have fixed the issue.
+
+
diff --git a/sources/doc/Privacy.md b/sources/doc/Privacy.md
new file mode 100644
index 00000000..fd6df631
--- /dev/null
+++ b/sources/doc/Privacy.md
@@ -0,0 +1,73 @@
+#Privacy Policy
+
+##Summary
+
+Q: Who can see my content?
+
+A: By default ANYBODY on the internet, UNLESS you restrict it. The $Projectname allows you to choose the privacy level you desire. Restricted content will NOT be visible to spy networks and their advertisers. It will be protected against eavesdropping by outsiders - to the best of our ability. Hub administrators with sufficient skills and patience MAY be able to eavesdrop on some private communications but they must expend effort to do so. Privacy modes exist within the $Projectname which are even resistant to eavesdropping by skilled and determined hub administrators.
+
+Q: Can my content be censored?
+
+A: The $Projectname (the network) CANNOT censor your content. Server and hub administrators are subject to local laws and MAY remove objectionable content from their site/hub. Anybody MAY become a hub administrator, including you; and therefore publish content which might otherwise be censored. You still MAY be subject to local laws.
+
+
+##Definitions
+
+**$Projectname**
+
+Otherwise referred to as "the network", the $Projectname is a collection of individual computers/servers (aka **hubs**) which connect together to form a larger cooperative network.
+
+**hub**
+
+An individual computer or server connected to the $Projectname. These are provided by a **hub administrator** and may be public or private, paid or free.
+
+**hub administrator**
+
+The system operator of an individual hub.
+
+##Policies
+
+**Public Information**
+
+Any information or anything posted by you within the $Projectname MAY be public or visible to anybody on the internet. To the extent possible, the $Projectname allows you to protect content and restrict who can view it.
+
+Your profile photo, your channel name, and the location (URL or network address) of your channel are visible to anybody on the internet and privacy controls will not affect the display of these items.
+
+You MAY additionally provide other profile information. Any information which you provide in your "default" or **public profile** MAY be transmitted to other hubs in the $Projectname and additionally MAY be displayed in the channel directory. You can restrict the viewing of this profile information. It may be restricted only to members of your hub, or only connections (friends), or other limited sets of viewers as you desire. If you wish for your profile to be restricted, you must set the appropriate privacy setting, or simply DO NOT provide additional information.
+
+**Content**
+
+Content you provide (status posts, photos, files, etc.) belongs to you. The $Projectname default is to publish content openly and visible to anybody on the internet (PUBLIC). You MAY control this in your channel settings and restrict the default permissions or you MAY restrict the visibility of any single published item separately (PRIVATE). The $Projectname developers will ensure that restricted content is ONLY visible to those in the restriction list - to the best of their ability.
+
+Content (especially status posts) that you share with other networks or that you have made visible to anybody on the internet (PUBLIC) cannot easily be taken back once it has been published. It MAY be shared with other networks and made available through RSS/Atom feeds. It may also be syndicated on other $Projectname sites. It MAY appear on spy networks and internet searches. If you do not wish this default behaviour please adjust your channel settings and restrict who can see your content.
+
+**Comments and Forum posts**
+
+Comments to posts that were created by others and posts which are designated as forum posts belong to you as the creator/author, but the distribution of these posts is not under your direct control. These posts/comments MAY be re-distributed to others, and MAY be visible to anybody on the internet. In the case of comments, the creator of the "first message" in the thread to which you are replying controls the distribution of all comments and replies to that message.
+
+
+**Private Information**
+
+$Projectname developers will ensure that any content you provide which is designated as PRIVATE will be protected against eavesdropping - to the best of their ability. Private content is generally hidden or obscured even from hub administrators. It is also stripped from email notifications. It is difficult but NOT impossible for this content to be seen by a hub administrator. This is a side effect of the physical laws of the universe. Unfortunately, if a database needs to decrypt a post at display time, it must have the means to decrypt the post! End to end encryption is also provided and this CANNOT be seen, even by a determined administrator.
+
+##Identity Privacy
+
+Privacy for your identity is another aspect. Because you have a decentralized identity in the $Projectname, your privacy extends beyond your home hub. If you want to have complete control of your privacy and security you should run your own hub on a dedicated server. For many people, this is complicated and may stretch their technical abilities. So let's list a few precautions you can make to assure your privacy as much as possible.
+
+A decentralized identity has a lot of advantages and gives you al lot of interesting features, but you should be aware of the fact that your identity is known by other hubs in the $Projectname network. One of those advantages is that other channels can serve you customized content and allow you to see private things (such as private photos which others wish to share with you). Because of this those channels need to know who you are. But we understand that sometimes those other channels know more from you than you might desire. For instance the plug-in Visage that can tell a channel owner the last time you visit their profile. You can easily OPT-OUT of this low level and we think, harmless tracking.
+
+* You can enable [Do Not Track (DNT)](http://donottrack.us/) in your web browser. We respect this new privacy policy proposal. All modern browsers support DNT. You will find it in the privacy settings of your browsers or else you can consult the web browser's manual. This will not affect the functionality of the $Projectname. This setting is probably enough for most people.
+*You can [disable publication](settings) of your channel in our channel directory. If you want people to find your channel, you should give your channel address directly to them. We think this is a good indication that you prefer extra privacy and automatically enable "Do Not Track" if this is the case.
+* You can have a blocked hub. That means that all channels and content on that hub is not public, and not visible to the outside world. This is something only your hub administrator can do. We also respect this and automatically enable "Do Not Track" if it is set.
+
+###Censorship
+
+The $Projectname is a global network which is inclusive of all religions and cultures. This does not imply that every member of the network feels the same way you do on contentious issues, and some people may be STRONGLY opposed to the content you post. In general, if you wish to post something that you know may nor be universally acceptable, the best approach is to restrict the audience using privacy controls to a small circle of friends.
+
+The $Projectname as a network provider is unable to censor content. However, hub administrators MAY censor any content which appears on their hub to comply with local laws or even personal judgement. Their decision is final. If you have issues with any hub administrator, you may move your account and postings to another site which is more in line with your expectations. Please check (periodically) the [Terms of Service](help/TermsOfService) of your hub to learn about any rules or guidelines. If your content consists of material which is illegal or may cause issues, you are STRONGLY encouraged to host your own (become a hub administrator). You may still find that your content is blocked on some hubs, but the $Projectname as a network cannot block it from being posted.
+
+The $Projectname RECOMMENDS that hub administrators provide a grace period of 1-2 days between warning an account holder of content that needs to be removed and physically removing or disabling the account. This will give the content owner an opportunity to export their channel meta-data and import it to another site. In rare cases the content may be of such a nature to justify the immediate termination of the account. This is a hub decision, not a $Projectname decision.
+
+If you typically and regularly post content of an adult or offensive nature, you are STRONGLY encouraged to mark your account "NSFW" (Not Safe For Work). This will prevent the display of your profile photo in the directory except to viewers that have chosen to disable "safe mode". If your profile photo is found by directory administrators to be adult or offensive, the directory administrator MAY flag your profile photo as NSFW. There is currently no official mechanism to contest or reverse this decision, which is why you SHOULD mark your own account NSFW if it is likely to be inappropriate for general audiences.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/README.md b/sources/doc/README.md
new file mode 100644
index 00000000..90585a90
--- /dev/null
+++ b/sources/doc/README.md
@@ -0,0 +1,42 @@
+
+Hubzilla
+========
+
+###Websites. Redefined.
+
+
+![Hubzilla](images/ghash-32.png)
+
+**What are Hubs?**
+
+Hubs are independent general-purpose websites that not only connect with their associated members and viewers, but also connect together to exchange personal communications and other information with each other.
+This allows hub members on any hub to securely and privately share anything; with anybody, on any hub - anywhere; or share stuff publicly with anybody on the internet if desired.
+
+**Hubzilla** is the server software which makes this possible. It is a sophisticated and unique combination of an open source content management system and a decentralised identity, communications, and permissions framework and protocol suite, built using common webserver technology (PHP/MySQL/Apache, although Mariadb or Postgres and Nginx could also be used - we're pretty easy). The end result is a level of systems integration, privacy control, and communications features that you wouldn't think are possible in either a content management system or a decentralised communications network. It also brings a new level of cooperation and privacy to the web and introduces the concept of personally owned "single sign-on" to web services across the entire internet.
+
+Hubzilla hubs are
+
+* decentralised
+* inherently social
+* optionally inter-networked with other hubs
+* privacy-enabled (privacy exclusions work across the entire internet to any registered identity on any compatible hubs)
+
+Possible website applications include
+
+* decentralised social networking nodes
+* personal cloud storage
+* file dropboxes
+* managing organisational communications and activities
+* collaboration and community decision-making
+* small business websites
+* public and private media/file libraries
+* blogs
+* event promotion
+* feed aggregation and republishing
+* forums
+* dating websites
+* pretty much anything you can do on a traditional blog or community website, but that you could do better if you could easily connect it with other websites or privately share things across website boundaries.
+
+
+
+This project is under development and is not yet available for general use.
\ No newline at end of file
diff --git a/sources/doc/Remove-Account.md b/sources/doc/Remove-Account.md
new file mode 100644
index 00000000..a8ef733a
--- /dev/null
+++ b/sources/doc/Remove-Account.md
@@ -0,0 +1,26 @@
+// this page is out of date...
+Remove Account
+==============
+
+It is presently not possible to remove an account without asking your site administrator for assistance.
+We'll have better doco when somebody finishes that bit.
+
+
+Remove Channel
+==============
+
+Visit the URL
+
+ https://yoursite/removeme
+
+(replace 'yoursite' with the domain name of your $Projectname site).
+
+You will need to confirm your password and the channel you are currently logged into will be removed.
+
+This is irreversible.
+
+If you have identity clones on other sites this only removes the channel instance which exists
+on this site.
+
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/Schema-development.md b/sources/doc/Schema-development.md
new file mode 100644
index 00000000..e811bb8c
--- /dev/null
+++ b/sources/doc/Schema-development.md
@@ -0,0 +1,81 @@
+Red development - a guide to the schema system
+==============================================
+
+
+A schema, in a nutshell, is a collection of settings for a bunch of variables to define
+certain elements of a theme. A schema is loaded as though it were part of config.php
+and has access to all the same information. Importantly, this means it is identity aware,
+and can be used to do some interesting things. One could, for example, restrict options
+by service class, or present different options to different members.
+
+By default, we filter only by whether or not expert mode is enabled. If expert mode is
+enabled, all options are presented to the member. If it is not, only scheme, background
+image, font face, and iconset are available as choices.
+
+A schema is loaded *after* the member's personal settings. Therefore, to allow a member
+to overwrite a particular aspect of a schema you would use the following syntax:
+
+ if (! $foo)
+ $foo = 'bar';
+
+However, there are circumstances - particularly with positional elements - where it
+may be desirable (or necessary) to override a member's settings. In this case, the syntax
+is even simpler:
+
+ $foo = 'bar';
+
+Members will not thank you for this, however, so only use it when it is required.
+
+If no personal options are set, and no schema is selected, we will first try to load a schema
+with the file name "default.php". This file should never be included with a theme. If it
+is, merge conflicts will occur as people update their code. Rather, this should be defined
+by administrators on a site by site basis.
+default.php and default.css MUST be symlinks to existing scheme files.
+
+You schema does not need to - and should not - contain all of these values. Only the values
+that differ from the defaults should be listed. This gives you some very powerful options
+with very few lines of code.
+
+Note the options available differ with each theme. The options available with the Redbasic
+theme are as follows:
+
+* nav_colour
+ The colour of the navigation bar. Options are red, black and silver. Alternatively,
+ one can set $nav_bg_1, $nav_bg_2, $nav_bg_3 and $nav_bg_4 to provide gradient and
+ hover effects.
+* banner_colour
+ The font colour of the banner element. Accepts an RGB or Hex value.
+* bgcolour
+ Set the body background colour. Accepts an RGB or Hex value.
+* background_image
+ Sets a background image. Accepts a URL or path.
+* item_colour
+ Set the background colour of items. Accepts an RGB or Hex value.
+* item_opacity
+ Set the opacity of items. Accepts a value from 0.01 to 1
+* toolicon_colour
+ Set the colour of tool icons. Accepts an RGB or Hex value.
+* toolicon_activecolour
+ Set the colour of active or hovered icon tools.
+* font_size
+ Set the size of fonts in items and posts. Accepts px or em.
+* body_font_size
+ Sets the size of fonts at the body level. Accepts px or em.
+* font_colour
+ Sets the font colour. Accepts an RGB or Hex value.
+* radius
+ Set the radius of corners. Accepts a numeral, and is always in px.
+* shadow
+ Set the size of shadows shown with inline images. Accepts a numerical
+ value. Note shadows are not applied to smileys.
+* converse_width
+ Set the maximum width of the content region in px.
+* nav_min_opacity
+* top_photo
+* reply_photo
+
+If a your_schema_name.css file is found, the content of this file will be attached to the end of style.css.
+This gives the schem developer the possiblity to override any style component.
+
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/Tags-and-Mentions.md b/sources/doc/Tags-and-Mentions.md
new file mode 100644
index 00000000..84442dd7
--- /dev/null
+++ b/sources/doc/Tags-and-Mentions.md
@@ -0,0 +1,26 @@
+Tags and Mentions
+=================
+
+Like many other platforms, Red uses a special notation inside messages to indicate "tags" or contextual links to other entities.
+
+**Mentions**
+
+Channels are tagged by simply preceding their name with the @ character. Unless their system blocks unsolicited "mentions", the person tagged will likely receive a "Mention" post/activity or become a direct participant in the conversation in the case of public posts.
+
+When you start to mention somebody, it will create an auto-complete box to select from your immediate connections. Select one as appropriate. Some connections will be displayed in different colours. A light blue entry (using the default theme) indicates a channel which will redeliver to others if tagged. This is generally a conversation group or forum. But be aware that when tagged, the message will also go to anybody they choose, in addition to anybody you choose.
+
+**Private Mentions**
+
+If you wish to restrict a post to a single person or a number of people, you can do this by selecting channels or collections from the privacy tool. You can also just tag them with a privacy tag. A privacy tag is a name preceded by the two characters @! - and in addition to tagging these channels, will also change the privacy permissions of the post to include them (and perhaps restrict the post from "everybody" if this was the default). You can have more than one privacy tag, for instance @!bob and @!linda will send the post only to Bob and Linda (in addition to any recipients you selected with the privacy selector - if any).
+
+You may also tag public collections. When you create or edit a collection, there is a checkbox to allow the group members to be seen by others. If this box is checked for a collection and you tag (for instance) @!Friends - the post will be restricted to the Friends collection. Check that the collection is public before doing this - as there is no way to take back a post except to delete it. The collection name will appear in the post and will alert members of that collection that they are members of it.
+
+
+
+**Topical Tags**
+
+Topical tags are indicated by preceding the tag name with the # character. This will create a link in the post to a generalised site search for the term provided. For example, #cars will provide a search link for all posts mentioning 'cars' on your site. Topical tags are generally a minimum of three characters in length. Shorter search terms are not likely to yield any search results, although this depends on the database configuration. The same rules apply as with names that spaces within tags are represented by the underscore character. It is therefore not possible to create a tag whose target contains an underscore.
+
+Topical tags are also not linked if they are purely numeric, e.g. #1. If you wish to use a numerica hashtag, please add some descriptive text such as #2012-elections.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/TermsOfService.md b/sources/doc/TermsOfService.md
new file mode 100644
index 00000000..97e9881a
--- /dev/null
+++ b/sources/doc/TermsOfService.md
@@ -0,0 +1,5 @@
+Terms of Service
+================
+
+#include doc/SiteTOS.md;
+
diff --git a/sources/doc/Translations.md b/sources/doc/Translations.md
new file mode 100644
index 00000000..d0fe489f
--- /dev/null
+++ b/sources/doc/Translations.md
@@ -0,0 +1,93 @@
+Translating the $Projectname
+==========================
+
+Translation Process
+-------------------
+
+The strings used in the UI of Red is translated at [Transifex][1] and then
+included in the git repository at github. If you want to help with translation
+for any language, be it correcting terms or translating Red to a
+currently not supported language, please register an account at transifex.com
+and contact the Red translation team there.
+
+Translating Red is simple. Just use the online tool at transifex. If you
+don't want to deal with git & co. that is fine, we check the status of the
+translations regularly and import them into the source tree at github so that
+others can use them.
+
+We do not include every translation from transifex in the source tree to avoid
+a scattered and disturbed overall experience. As an uneducated guess we have a
+lower limit of 50% translated strings before we include the language. This
+limit is judging only by the amount of translated strings under the assumption
+that the most prominent strings for the UI will be translated first by a
+translation team. If you feel your translation useable before this limit,
+please contact us and we will probably include your teams work in the source
+tree.
+
+If you want to get your work into the source tree yourself, feel free to do so
+and contact us with and question that arises. The process is simple and
+Red ships with all the tools necessary.
+
+The location of the translated files in the source tree is
+ /view/LNG-CODE/
+where LNG-CODE is the language code used, e.g. de for German or fr for French.
+For the email templates (the *.tpl files) just place them into the directory
+and you are done. The translated strings come as a "messages.po" file from
+transifex which needs to be translated into the PHP file Red uses. To do
+so, place the file in the directory mentioned above and use the "po2php"
+utility from the util directory of your Red installation.
+
+Assuming you want to convert the German localization which is placed in
+view/de/messages.po you would do the following.
+
+1. Navigate at the command prompt to the base directory of your
+ Red installation
+
+2. Execute the po2php script, which will place the translation
+ in the strings.php file that is used by Red.
+
+ $> php util/po2php.php view/de/messages.po
+
+ The output of the script will be placed at view/de/strings.php where
+ froemdoca os expecting it, so you can test your translation mmediately.
+
+3. Visit your Red page to check if it still works in the language you
+ just translated. If not try to find the error, most likely PHP will give
+ you a hint in the log/warnings.about the error.
+
+ For debugging you can also try to "run" the file with PHP. This should
+ not give any output if the file is ok but might give a hint for
+ searching the bug in the file.
+
+ $> php view/de/strings.php
+
+4. commit the two files with a meaningful commit message to your git
+ repository, push it to your fork of the Red repository at github and
+ issue a pull request for that commit.
+
+Utilities
+---------
+
+Additional to the po2php script there are some more utilities for translation
+in the "util" directory of the Red source tree. If you only want to
+translate Red into another language you wont need any of these tools most
+likely but it gives you an idea how the translation process of Red
+works.
+
+For further information see the utils/README file.
+
+Known Problems
+--------------
+
+* Red uses the language setting of the visitors browser to determain the
+ language for the UI. Most of the time this works, but there are some known
+ quirks.
+* the early translations are based on the friendica translations, if you
+ some rough translations please let us know or fix them at Transifex.
+
+Links
+------
+[1]: http://www.transifex.com/projects/p/red-matrix/
+
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/Webpages.md b/sources/doc/Webpages.md
new file mode 100644
index 00000000..dafd3661
--- /dev/null
+++ b/sources/doc/Webpages.md
@@ -0,0 +1,16 @@
+Creating Webpages
+=================
+
+Red enables users to create static webpages. To activate this feature, enable the web pages feature in your Additional Features section.
+
+Once enabled, a new tab will appear on your channel page labelled "Webpages". Clicking this link will take you to the webpage editor. Here you can create a post using either BBCode or the rich text editor.
+
+Pages will be accessible at mydomain/page/username/pagelinktitle
+
+The "page link title" box allows a user to specify the "pagelinktitle" of this URL. If no page link title is set, we will set one for you automatically, using the message ID of the item.
+
+Beneath the page creation box, a list of existing pages will appear with an "edit" link. Clicking this will take you to an editor, similar to that of the post editor, where you can make changes to your webpages.
+
+If you are the admin of a site, you can specify a channel whose webpages we will use at key points around the site. Presently, the only place this is implemented is the home page. If you specify the channel "admin" and then the channel called "admin" creates a webpage called "home", we will display it's content on your websites home page. We expect this functionality to be extended to other areas in future.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/Widgets.md b/sources/doc/Widgets.md
new file mode 100644
index 00000000..5cc7eab2
--- /dev/null
+++ b/sources/doc/Widgets.md
@@ -0,0 +1,123 @@
+Core Widgets
+============
+
+Some/many of these widgets have restrictions which may restrict the type of page where they may appear or may require login
+
+
+* clock - displays the current time
+ * args: military (1 or 0) - use 24 hour time as opposed to AM/PM
+
+
+* profile - displays a profile sidebar on pages which load profiles (pages with nickname in the URL)
+
+* tagcloud - display a tagcloud of webpage items
+
+ * args: count - number of items to return (default 24)
+
+
+* collections - collection selector for the current logged in channel
+
+ * args: mode - one of "conversation", "group", "abook" depending on module
+
+
+* suggestions - friend suggestions for the current logged on channel
+
+* follow - presents a text box for following another channel
+
+* notes - private notes area for the current logged in channel if private_notes feature is enabled
+
+* savedsearch - network/matrix search with save - must be logged in and savedsearch feature enabled
+
+* filer - select filed items from network/matrix stream - must be logged in
+
+* archive - date range selector for network and channel pages
+ * args: 'wall' - 1 or 0, limit to wall posts or network/matrix posts (default)
+
+
+* fullprofile - same as profile currently
+
+* categories - categories filter (channel page)
+
+* tagcloud_wall - tagcloud for channel page only
+ * args: 'limit' - number of tags to return (default 50)
+
+
+* catcloud_wall - tagcloud for channel page categories
+ * args: 'limit' - number of categories to return (default 50)
+
+
+* affinity - affinity slider for network page - must be logged in
+
+* settings_menu - sidebar menu for settings page, must be logged in
+
+* mailmenu - sidebar menu for private message page - must be logged in
+
+* design_tools - design tools menu for webpage building pages, must be logged in
+
+* findpeople - tools to find other channels
+
+* photo_albums - list photo albums of the current page owner with a selector menu
+
+* vcard - mini profile sidebar for the person of interest (page owner, whatever)
+
+* dirsafemode - directory selection tool - only on directory pages
+
+* dirsort - directory selection tool - only on directory pages
+
+* dirtags - directory tool - only on directory pages
+
+* menu_preview - preview a menu - only on menu edit pages
+
+* chatroom_list - list of chatrooms for the page owner
+
+* bookmarkedchats - list of bookmarked chatrooms collected on this site for the current observer
+
+* suggestedchats - "interesting" chatrooms chosen for the current observer
+
+* item - displays a single webpage item by mid
+ * args: mid - message_id of webpage to display
+
+
+* photo - display a single photo
+ * args:
+ * url - URL of photo, must be http or https
+ * zrl - use zid authenticated link
+ * style - CSS style string
+
+
+* photo_rand - display a random photo from one of your photo albums. Photo permissions are honoured
+ * args:
+ * album - album name (very strongly recommended if you have lots of photos)
+ * scale - typically 0 (original size), 1 (640px), or 2 (320px)
+ * style - CSS style string
+ * channel_id - if not your own
+
+
+* random_block - display a random block element from your webpage design tools collection. Permissions are honoured.
+ * args:
+ * contains - only return blocks which include the contains string in the block name
+ * channel_id - if not your own
+
+
+* tasklist - provide a task or to-do list for the currently logged-in channel.
+ * args:
+ * all - display completed tasks if all is non-zero.
+
+
+
+Creating New Widgets
+====================
+
+If you want a widget named 'slugfish', create widget/slugfish.php containing
+
+
+ Connections. In the right column under "Developers," click the link to "Register an OAuth client application to use with this instance of StatusNet." This link may be found at your instance here:
+
+https://yourgnusocialinstance.org/settings/oauthapps
+
+Next, click the link to Register a new application. That brings up the new application form. Here's what to do on each field.
+
+Icon. I uploaded the $Projectname icon located at this link, after saving it to my computer:
+
+https://github.com/redmatrix/hubzilla/blob/master/images/rm-32.png
+
+Name. Give the application an appropriate name. I called mine hubzilla. You might prefer r2g.
+
+Description. Use this field to describe the purpose of the application. I put something to the effect of use for crossposting from $Projectname to GNUsocial.
+
+
+Source URL. Put the main domain name of the Red site you're using. Don't forget to put the "s" in https://yourhubzillasite.com. If your Red installation is a subdomain, that would probably be called for.
+
+Organization. Since $Projectname is unorganized, I put that. If you use your installation for a group or business, that might be a good option.
+
+Homepage. If your group is using a subdomain, you probably want to put your main domain URI here. Since I'm on a hosted site, I put redmatrix.me.
+
+Callback URL. Leave blank.
+
+Type of application: select "desktop."
+
+Default access: select "Read-write."
+
+All fields except the callback URL must be filled in.
+
+Click on the save button.
+
+Then click on the icon or the name of the application for the information you'll need to insert over on $Projectname.
+
+*****
+
+Now open up a new tab or window and go to your $Projectname account, to Settings > Feature settings. Find the StatusNet Posting Settings.
+
+Insert the strings of numbers given on the GNUsocial site into the $Projectname fields for Consumer Key and Consumer Secret.
+
+The Base API Path (remember the trailing /) will be your instance domain, plus the /api/ following. It will probably look like this:
+
+https://yourgnusocialinstance.org/api/
+
+In case of doubt check on your GNUsocial instance site in order to find the domain URLs of the Request token, Access token, and Authorization. It will be the first part of the domains, minus the /oauth/....
+
+StatusNet application name: Insert the name you gave to the application over on the GNUsocial site.
+
+Click Submit.
+
+A button will appear for you to "Sign in to StatusNet." Click it and that will open a tab or window on the GNUsocial site for you to click "Allow." Once clicked and successfully authorized, a security code number will appear. Copy it and go back to the $Projectname app you just left and insert it in the field: "Copy the security code from StatusNet here." Click Submit.
+
+If successful, your information from the GNUsocial instance should appear in the $Projectname app.
+
+You now have several options to choose, if you desire, and those will need to be confirmed by clicking "Submit" also. The most interesting is "Send public postings to StatusNet by default." This option automatically sends any post of yours made in your $Projectname account to your GNUsocial instance.
+
+If you don't choose this option, you will have an option to send a post to your GNUsocial instance by first opening the post (by clicking in the post text area) and clicking on the lock icon next to the Share button. Select the GNUsocial icon made up of three colored dialog baloons. Close that window, then make your post.
+
+If all goes well, you have just cross-posted your $Projectname post to your account on a GNUsocial instance.
+
+#include doc/macros/addons_footer.bb;
+
diff --git a/sources/doc/api_functions.bb b/sources/doc/api_functions.bb
new file mode 100644
index 00000000..e6cde3dc
--- /dev/null
+++ b/sources/doc/api_functions.bb
@@ -0,0 +1,133 @@
+[b]Red Twitter API[/b]
+
+The "basic" Red web API is based on the Twitter API, as this provides instant compatibility with a huge number of third-party clients and applications without requiring any code changes on their part. It is also a super-set of the StatusNet version of the Twitter API, as this also has existing wide support.
+
+Red has a lot more capability that isn't exposed in the Twitter interfaces or where we are forced to "dumb-down" the API functions to work with the primitive Twitter/StatusNet communications and privacy model. So we plan to extend the Twitter API in ways that will allow Red-specific clients to make full use of Red features without being crippled.
+
+A dedicated Red API is also being developed to work with native data structures and permissions and which do not require translating to different privacy and permission models and storage formats. This will be described in other documents. The prefix for all of the native endpoints is 'api/red'.
+
+Red provides multiple channels accesible via the same login account. With Red, any API function which requires authentication will accept a parameter &channel={channel_nickname} - and will select that channel and make it current before executing the API command. By default, the default channel associated with an account is selected.
+
+Red also provides an extended permission model. In the absence of any Red specific API calls to set permissions, they will be set to the default permissions settings which are associated with the current channel.
+
+Red will probably never be able to support the Twitter 'api/friendships' functions fully because Red is not a social network and has no concept of "friendships" - it only recognises permissions to do stuff (or not do stuff as the case may be).
+
+Legend: T= Twitter, S= StatusNet, F= Friendica, R= Red, ()=Not yet working, J= JSON only (XML formats deprecated)
+
+Twitter API compatible functions:
+
+ api/account/verify_credentials T,S,F,R
+ api/statuses/update T,S,F,R
+ api/users/show T,S,F,R
+ api/statuses/home_timeline T,S,F,R
+ api/statuses/friends_timeline T,S,F,R
+ api/statuses/public_timeline T,S,F,R
+ api/statuses/show T,S,F,R
+ api/statuses/retweet T,S,F,R
+ api/statuses/destroy T,S,F,(R)
+ api/statuses/mentions T,S,F,(R)
+ api/statuses/replies T,S,F,(R)
+ api/statuses/user_timeline T,S,F,(R)
+ api/favorites T,S,F,R
+ api/account/rate_limit_status T,S,F,R
+ api/help/test T,S,F,R
+ api/statuses/friends T,S,F,R
+ api/statuses/followers T,S,F,R
+ api/friends/ids T,S,F,R
+ api/followers/ids T,S,F,R
+ api/direct_messages/new T,S,F,R
+ api/direct_messages/conversation T,S,F,R
+ api/direct_messages/all T,S,F,R
+ api/direct_messages/sent T,S,F,R
+ api/direct_messages T,S,F,R
+ api/oauth/request_token T,S,F,R
+ api/oauth/access_token T,S,F,R
+ api/favorites T,S,R
+ api/favorites/create T,S,R
+ api/favorites/destroy T,S,R
+
+Twitter API functions supported by StatusNet but not currently by Friendica or Red
+
+ api/statuses/retweets_of_me T,S
+ api/friendships/create T,S
+ api/friendships/destroy T,S
+ api/friendships/exists T,S
+ api/friendships/show T,S
+ api/account/update_location T,S
+ api/account/update_profile_background_image T,S
+ api/account/update_profile_image T,S
+ api/blocks/create T,S
+ api/blocks/destroy T,S
+
+Twitter API functions not currently supported by StatusNet
+
+ api/statuses/retweeted_to_me T
+ api/statuses/retweeted_by_me T
+ api/direct_messages/destroy T
+ api/account/end_session T,(R)
+ api/account/update_delivery_device T
+ api/notifications/follow T
+ api/notifications/leave T
+ api/blocks/exists T
+ api/blocks/blocking T
+ api/lists T
+
+Statusnet compatible extensions to the Twitter API supported in both Friendica and Red
+
+ api/statusnet/version S,F,R
+ api/statusnet/config S,F,R
+
+Friendica API extensions to the Twitter API supported in both Friendica and Red
+
+ api/statuses/mediap F,R
+
+Red specific API extensions to the Twitter API not supported in Friendica
+
+ api/account/logout R
+ api/export/basic R,J
+ api/friendica/config R
+ api/red/config R
+ api/friendica/version R
+
+ api/red/version R
+
+ api/red/channel/export/basic R,J
+ api/red/channel/stream R,J (currently post only)
+ api/red/albums R,J
+ api/red/photos R,J (option album=xxxx)
+
+Red proposed API extensions to the Twitter API
+
+ api/statuses/edit (R),J
+ api/statuses/permissions (R),J
+ api/statuses/permissions/update (R),J
+ api/statuses/ids (R),J # search for existing message_id before importing a foreign post
+ api/files/show (R),J
+ api/files/destroy (R),J
+ api/files/update (R),J
+ api/files/permissions (R),J
+ api/files/permissions/update (R),J
+ api/pages/show (R),J
+ api/pages/destroy (R),J
+ api/pages/update (R),J
+ api/pages/permissions (R),J
+ api/pages/permissions/update (R),J
+ api/events/show (R),J
+ api/events/update (R),J
+ api/events/permissions (R),J
+ api/events/permissions/update (R),J
+ api/events/destroy (R),J
+ api/photos/show (R),J
+ api/photos/update (R),J
+ api/photos/permissions (R),J
+ api/photos/permissions/update (R),J
+ api/albums/destroy (R),J
+ api/albums/show (R),J
+ api/albums/update (R),J
+ api/albums/permissions (R),J
+ api/albums/permissions/update (R),J
+ api/albums/destroy (R),J
+ api/friends/permissions (R),J
+
+#include doc/macros/main_footer.bb;
+
diff --git a/sources/doc/api_posting.bb b/sources/doc/api_posting.bb
new file mode 100644
index 00000000..fa955826
--- /dev/null
+++ b/sources/doc/api_posting.bb
@@ -0,0 +1,23 @@
+[b][size=xx-large]Posting to the Matrix via the API[/size][/b]
+
+The API allows you to post to the red# by HTTP POST request. Below you see an example using the command line tool cURL:
+
+[code]curl -ssl -u [color=blue]$E-Mail[/color]:[color=blue]$Password[/color] -d "[color=blue]$Parameters[/color]" [url][observer=1][observer.baseurl][/observer][observer=0]example.com[/observer]/api/statuses/update
+[/url][/code]
+[table][tr][td]$E-Mail:[/td][td]The E-Mail Adress you use to login[/td][/tr]
+[tr][td]$Password:[/td][td]The Password you use to login[/td][/tr]
+[tr][td]$Parameters:[/td][td]That's the interesting part, here you insert the content you want to send using the following parameters:[/td][/tr][/table]
+
+[ul]
+[*]title: the title of the posting
+[*]channel: the channel you want to post to
+[*]category: a comma-seperated list of categories for the posting
+[*]status: the content of the posting, formatted with BBCode
+ OR
+[*]htmlstatus:the content of the posting, formatted in HTML.
+[/ul]
+
+
+Instead of calling [observer=1][observer.baseurl][/observer][observer=0]example.com[/observer]/api/statuses/update which returns a json (you could also add .json on the end to clarify) output, you can use [observer.baseurl]/api/statuses/update.xml to get an xml formatted return.
+
+Instead of Basic HTTP Authentification you could also use oAuth.
diff --git a/sources/doc/bbcode.html b/sources/doc/bbcode.html
new file mode 100644
index 00000000..4fe47842
--- /dev/null
+++ b/sources/doc/bbcode.html
@@ -0,0 +1,88 @@
+
[zrl]https://redmatrix.me[/zrl] Magic-auth version of [url] tag
+
[zmg]https://redmatrix.me/some/photo.jpg[/zmg] Magic-auth version of [img] tag
+
+
[observer=1]Text to display if observer is authenticated in the matrix[/observer]
+
[observer=0]Text to display if observer is not authenticated in the matrix[/observer]
+
[observer.baseurl] website of observer
+
[observer.url] channel URL of observer
+
[observer.name] name of observer
+
[observer.address] address (zot-id) of observer
+
[observer.photo] profile photo of observer
+
+
[spoiler] for hiding spoilers
+
+
[rpost=title]Text to post[/rpost] The observer will be returned to their home hub to enter a post with the specified title and body. Both are optional
+
[qr]text to post[/qr] - create a QR code.
+
[toc] - create a table of content in a webpage. Please refer to the original jquery toc to get more explanations.
+
+
Optional param: 'data-toc'. If ommited the default is 'body'
+
Optional param: 'data-toc-headings'. If ommited the default is 'h1,h2,h3'
+
Full example: [toc data-toc='div.page-body' data-toc-headings='h1,h2']
+
+
+
+
+
These require a suitable map plugin/addon such as openstreetmap or else the result will be blank
+
+
[map] Generate an inline map using the current browser coordinates of the poster, if browser location is enabled
+
[map=latitude,longitude] Generate a map using global coordinates.
+
[map]Place Name[/map] Generate a map for a given named location. The first matching location is returned. For instance "Sydney" will usually return Sydney, Australia and not Sydney, Nova Scotia, Canada unless the more precise location is specified. It is highly recommended to use the post preview utility to ensure you have the correct location before submitting the post.
+
+
+#include doc/macros/main_footer.bb;
+
+
+
+
diff --git a/sources/doc/campaign.bb b/sources/doc/campaign.bb
new file mode 100644
index 00000000..48f28f0c
--- /dev/null
+++ b/sources/doc/campaign.bb
@@ -0,0 +1,237 @@
+[b]Initial Indiegg pitch[/b]
+
+[b][color= grey][size=20]What have we done, and what we hope to achieve[/size][/color][/b]
+
+[b][color= grey][size=18]Single-click sign on, nomadic identity, censorship-resistance, privacy, self-hosting[/size][/color][/b]
+
+We started the $Projectname project by asking ourselves a few questions:
+
+- Imagine if it was possible to just access the content of different web sites, without the need to enter usernames and passwords for every site. Such a feature would permit Single-Click user identification: the ability to access sites simply by clicking on links to remote sites.
+Authentication just happens automagically behind the scenes. Forget about remembering multiple user names with multiple passwords when accessing different sites online.
+
+We liked this idea and went ahead with coding it immediately. Today, single-click sign is in alpha state. It needs more love, which means a solid three months of full-time development efforts.
+
+- Think of your Facebook, Twitter, WordPress, or any other website where you currently have an account. Now imagine being able to clone your account, to make an exact duplicate of it (with all of your friends, posts and settings), then export your cloned account into another server that is part of this communication network. After you're done, both of your accounts are synced from the time they were cloned. It doesn't matter where you log in (at your original location, or where you imported your clone). You see the same content, the same friends, posts, and account settings.
+At that point, it is more appropriate to call your account an identity that is nomadic (it is not tied to one home, unless you choose to do so!).
+It's 2013, our online presence no longer has to be tied to a single server, domain name or IP address. We should be able to clone and import our identities to other servers. In such a network, it should only matter who you are, not where you are.
+
+We're very intrigued by the possibilities nomadic identities open up for freedom, censorship-resistance, and identity resilience. Consider the following scenarios:
+
+ -- Should a repressive government or corporation decide to delete your account, your cloned identity lives on, because it is located on another server, across the world, which is part of the same communication network. You can't be silenced!
+
+ -- What if there is a server meltdown, and your identity goes off line. No problem, you log into your clone and all is good.
+
+ -- Your server administrator can no longer afford to keep paying to support a free service (a labor love and principle, which all of us have participating in as system administrators of Friendica sites!). She notifies you that you must clone your account before the shutoff date. Rather than loose all your friends, and start from scratch by creating a new identity somewhere, you clone and move to another server.
+We feel this is especially helpful for the free web, where administrators of FOSS community sites are often faced with difficult financial decisions. Since many of them rely on donations, sometimes servers have to be taken offline, when costs become prohibitive for the brave DIY souls running those server. Nomadic identities should relieve some of the pressures associated with such situations.
+
+At the same time, we are also thinking of solutions that would make it possible for people running Red hubs to be financially sustainable. To that end, we're starting to implement service classes in our code, which would allow administrators to structure paid levels of service, if they choose to do so.
+
+Today, nomadic identity is currently in alpha state. It also needs more love, which means a solid three months of full-time development efforts.
+
+- Imagine a social network that is censorship-resistant, and privacy-respecting by design. It is not controlled by one mega-corporation, and where users cannot be easily censored by oppressive governments. So, in addition to nomadic identities, we are talking about decentralization, open source, freely software, that can run on any hardware that supports a database and a modern web browser. And we mean "any hardware", from a self-hosted $35 Raspberry Pi, to the very latest Intel Xeon and AMD Bulldozer-powered server behemoths.
+
+We've realized that privacy requires full control over content. We should be able to delete, backup and download all of our content, as well as associated account/identity information. To this end, we have already implemented the initial version of account export and backup.
+
+Concerned about pages and pages of posts from months and years past? The solution should be simple: visit your settings page, specify that all content older than 7 days, with the exception of starred posts, should be automatically deleted. Done, the clutter is gone! (Consider also the privacy and anti-mass surveillance implications of this feature. PRISM disclosures have hinted that three-letter spying agencies around the world are recording all internet traffic and storing it for a few days at a time. We feel that automatic post expiration becomes a rather useful feature in this context, and implementing it is one of our near future priorities.)
+
+[b][color= grey][size=18]The Affinity Slider and Access Control Lists[/size][/color][/b]
+
+- What if the permissions and access control lists that help secure modern operating systems were extended into a communication network that lived on the internet? This means somebody could log into this network from their home site, and with the simple click of a few buttons dynamically sort who can have access to their online content on a very fine level: from restricting others from seeing your latest blog post, to sharing your bookmarks with the world.
+
+We've coded the initial version of such a new feature. It is called the "Affinity Slider", and in our very-alpha user interface it looks like this.
+[img]https://friendicared.net/photo/b07b0262e3146325508b81a9d1ae4a1e-0.png[/img]
+
+{INSERT SCREENSHOT OF A MATRIX PAGE}
+
+Think of it as an easy way to filter content that you see, based on the degree of "closeness" to you. Move the slider to Friends, and only content coming from contacts you've tagged as friends is displayed on your home page. Uncluttering thousands of contacts, friends, RSS feeds, and other content should be a basic feature of modern communication on the web, but not at the expense of ease of use.
+
+In addition to the Affinity Slider, we also have the ACL (Access Control List). Say you want to share something with only 5 of your contacts (a blog, two friends from college, and two forums). You click on the padlock, choose the recipients, and that's it. Only those identities will recieve their posts. Furthermore, the post will be encrypted via PKI (pulic key encryption) to help maintain privacy. In the age of PRISM, we don't know all the details on what's safe out there, but we still think that privacy by design should be automatically present, invisible to the user, and easy to use.
+Attaching permissions to any data that lives on this network, potentially solves a great many headaches, while achieving simplicity in communication.
+
+Think of it this way: the internet is nothing, but a bunch of permissions and a folder of data. You, the user controls the permissions and thus the data that is relevant to you.
+
+[b][color= grey][size=20]The Matrix is Born![/size][/color][/b]
+
+After asking and striving to answer a number of such questions, we realized that we were imagining a general purpose communication network with a number of unique, and potentially game-changing, features. We called it the $Projectname and started thinking of it as an over-lay on top of the internet as it exists today; an operating system re-invented as a communication network, with its own permissions, access control lists, protocol, connectors to others services, and open-ended possibilities via its API. The sum of the matrix is greater than it's parts. We're not building website, but a way for websites to link together and grow into something that is unique and ever-changing, with autonomy and privacy.
+
+It's a lot of work, for anyone. So far, we've got a team of a handful of volunteers, code geeks, brave early adopters, system administrators and other good people, willing to give the project a shot. We're motivated by our commitment to a free web, where privacy is built-in, and corporations don't have a stranglehold on our daily communication.
+
+We need your help to finish it and release it to the world!
+
+[b][color= grey][size=20]What have we written so far[/size][/color][/b]
+
+As of the today, the $Projectname is in developer preview (alpha) state. It is not ready for everyday use, but some of the initial set of core features are implemented (again, in alpha state). These include:
+
+- Zot, the protocol powering the matrix
+- Single-signon logins.
+- Nomadic identities
+- Basic content manipulation: creation, deletion, rudimentary handling of photos, and media files
+- A bare-bones outline of the API and user documentation.
+
+
+[b][color= grey][size=20]Our TO-DO List[/size][/color][/b]
+
+However, in addition to finishing and polishing the above, there are a number of features that have to implemented to make the $Projectname ready for daily use. If we meet our fundraising goal, we hope to dive into the following road map, by order of priority:
+
+- A professionally designed user interface (UI), interface that is adaptive to any user level, from end users who want to use the Matrix as a social network, to tinkerers who will put together a customized blog using Comanche, to hackers who will develop and extend the matrix using a built-in code editor, that hooks to the API and the git.
+
+- Comanche, our new markup language, similar to BBCode, with which to create elaborate and complex web pages by assembling them from a series of components - some of which are pre-built and others which can be defined on the fly. You can read more about it on our github wiki: https://github.com/friendica/red/wiki/Comanche
+
+- A unique help system that lives in the matrix, but is not based on the principles of a search engine. We have some interesting ideas about decentralizing help documentation, without going down the road of distributed search engines. Here's a hint: We shouldn't be searching at all, we should just be filtering what's already there in new, and cunning ways.
+
+- An appropriate logo, along with professionally done documentation system, both for our API, as well as users.
+
+- WordPress-like single button software upgrades
+
+- A built-in development environment, using an integrated web-based code editor such as Ace9
+
+[b][color= grey][size=20]What will the money be used for[/size][/color][/b]
+
+If we raise our targeted amount of funds, we plan to use it as follows:
+
+1) Fund 6 months {OR WHATEVER} of full time work for our current core developers, Mike, Thomas, and Tobias {ANYONE ELSE?]
+
+2) Pay a professional web developer to design an kick ass reference theme, along with a project logo.
+
+3) {WHAT ELSE?}
+
+[b][color= grey][size=20]Deadlines[/size][/color][/b]
+
+[b]March, 2014: $Projectname Beta with the following features[/b]
+
+- {LIST FEATURES}
+
+[b][color= grey][size=20]Who We Are[/size][/color][/b]
+
+Mike: {FILL IN BIO, reference Friendica, etc.}
+
+Thomas: {bio blurb}
+
+Tobias: {bio blurb}
+
+Arto: {documentation, etc.}
+
+{WHO ELSE? WE NEED A TEAM, AT LEAST 3-4 PEOPLE}
+
+[b][color= grey][size=20]What Do I Get as a Supporter?[/size][/color][/b]
+
+Our ability to reach 1.0 stable release depends on your generosity and support. We appreciate your help, regardless of the amount! Here's what we're thinking as far as different contribution levels go:
+
+[b]$1: {CATCHY TAGLINE}[/b]
+
+We'll list your name on our initial supporters list, a Hall of Fame of the matrix!
+
+[b]$5:[/b]
+
+[b]$10: [/b]
+
+[b]$16: [/b]
+
+You get one of your $Projectname t-shirts, as well as our undying gratitude.
+
+[b]$32: [/b]
+
+[b]$64 [/b]
+
+[b]128 [/b]
+
+[b]$256: [/b]
+
+[b]$512: [/b]
+
+[b]$1024 [/b]
+
+[b]$2048[/b]
+
+Each contributor at this level gets their own $Projectname virtual private server, installed, hosted and supported by us for a period of 1 year.
+
+[b][color= grey][size=20]Why are we so excited about the $Projectname?[/size][/color][/b]
+
+{SOMETHING ABOUT THE POTENTIAL IMPACT OF RED, ITS INNOVATIONS, ETC>
+
+[b][color= grey][size=20]Other Ways to Help[/size][/color][/b]
+
+We're a handful of volunteers, and we understand that not everyone can contribute by donating money. There are many other ways you can in getting the Matrix to version 1.0!
+
+First, you can checkout our source code on github: https://github.com/redmatrix/hubzilla
+
+Maybe you can dive in and help us out with some development.
+
+Second, you can install the current developer preview on a server and start compiling bug reports.
+
+Third, register at one of the public alpha Red hubs, and get a feel for what Red is trying to do!
+
+Perhaps you're good at writing and documenting stuff. Grab an account at one of the public alphas and give us a hand.
+
+[b][color= grey][size=20]Frequently Asked Questions[/size][/color][/b]
+
+[b]1. Is Red a social network?[/b]
+
+The $Projectname is not a social network. We're thinking of it as a general purpose communication network, with sharing, and public/private communications built into the matrix.
+
+[b]2. What is the difference between Red and Friendica?[/b]
+
+What's the difference between a passport, and a postcard?
+
+Friendica is really, really good at sending postcards. It can do all sorts of things with postcards. It can send them to your friends. It can send them to people you don't know. It can put them in an envelope and send them privately. It can run them through a photocopier and plaster them all over the internet. It can even take postcards in one language and convert them to many others so your friends who speak a different language can read them.
+
+What Friendica can't do, is wave a postcard at somebody and expect them to believe that holding this postcard prove you are who you say you are. Sure, if you've been sending somebody postcards, they might accept that it is you in the picture, but somebody who has never heard of you will not accept ownership of a postcard as proof of identity.
+
+The $Projectname offers a passport.
+
+You can still use it to send postcards. At the same time, when you wave your passport at somebody, they do accept it as proof of identity. No longer do you need to register at every single site you use. You already have an account - it's just not necessarily at our site - so we'll ask to see your passport instead.
+
+Once you've proven your identity, a Red hub lets you use our services, as though you'd registered with directly, and we'd verified your credentials as would have happened in the olden days. These resources can, of course, be anything at all.
+
+[b]2. Why did you choose PHP, instead of Ruby or Python?[/b]
+
+The reference implementation is in PHP. We chose PHP, because it is available everywhere, and is easily configurable. We understand the debates between proponents and opponents of PHP, Ruby and Python. Nothing prevents implementations of Zot and the matrix in those languages. In fact, people on the matrix have already started developing a version of Red in Python [SOURCE?], and there is talk about future implementations in C (aiming for blazing native performance) and Java. It's free and open source, so we feel it's only a matter of time, once Red is initially completed.
+
+[b]4. Other than PHP, what other technology does Red use?[/b]
+
+We use MySQL as our database (this include any forks such as, MariaDB or Percona), and any modern webserver (Apache, nginx, etc.).
+
+[b]5. How is the Affinity Slider different from Mozilla's Persona?[/b]
+{COMPLETE}
+
+[b]6. Does the $Projectname use encryption? Details please![/b]
+
+Yes, we do our best to use free and open source encryption libraries to help achieve privacy from general, mass surveillance.
+
+Communication between web browsers and Red hubs is encrypted using SSL certificates.
+
+Private communication on the matrix is protected by AES symmetric encryption, which is itself protected by RSA PKI (public key encryption). By default, we use AES-256-CBC, and our RSA keys are set to 4096-bits.
+
+For more info on our initial implementation of encrypted communication, check out our source code at Github: https://github.com/friendica/red/blob/master/include/crypto.php
+
+[b]7. What do you mean by decentralization? [/b]
+
+
+[b]8. Can I build my own website with in the $Projectname?[/b]
+
+Yes. The short explanation: We've got this spiffy idea we're calling "Comanche", which will allow non-programmers to build complete custom websites, and any such website will be able to connect to any other website or channel in the matrix. The goal of Comanche is to hide the technical complexities of communicating in the matrix, while encouraging people to use their creativity and put together their own unique presence on the matrix.
+
+The longer explanation: Comanche is a markup language, similar to bbcode, with which to create elaborate and complex web pages by assembling them from a series of components - some of which are pre-built and others which can be defined on the fly. Comanche uses a Page Description Language file (".pdl", pronounced "puddle") to create these pages. Bbcode is not a requirement; an XML PDL file could also be used. The tag delimiters would be different. Usage is the same.
+
+Additional information is available on our Github project wiki: https://github.com/friendica/red/wiki/Comanche
+
+Comanche is another one of our priorities for the next six months.
+
+[b]9. Where can I see some technical description of Zot?[/b]
+
+Our github wiki contains a number of high-level and technical descriptions of Zot, Comanche, and Red in general: https://github.com/friendica/red/wiki
+
+[b]10. What happens if you raise more than {TARGETED NUMBER}?[/b]
+
+Raising more than our initial goal of funds, will speed up our development efforts. More developers will be able to take time off from other jobs, and concentrate efforts on finishing Red.
+
+[b]11 Can I make a contribution via Bitcoin?[/b]
+
+{YES/NO}
+
+[b]12. I have additional Questions[/]
+
+Awesome. We'd be more than happy to chat. You can find us {HERE}
+
+#include doc/macros/main_footer.bb;
+
diff --git a/sources/doc/channels.bb b/sources/doc/channels.bb
new file mode 100644
index 00000000..ff044654
--- /dev/null
+++ b/sources/doc/channels.bb
@@ -0,0 +1,30 @@
+[b]Channels[/b]
+
+Channels are simply collections of content stored in one place. A channel can represent anything. It could represent you, a website, a forum, photo albums, anything. For most people, their first channel with be "Me".
+
+The most important features for a channel that represents "me" are:
+
+Secure and private "spam free" communications
+
+Identity and "single-signon" across the entire network
+
+Privacy controls and permissions which extend to the entire network
+
+Directory services (like a phone book)
+
+In short, a channel that represents yourself is "me, on the internet".
+
+You will be required to create your first channel as part of the sign up process. You can also create additonal channels from the "Select channel" link.
+
+You will be asked to provide a channel name, and a short nick name. For a channel that represents yourself, it is a good idea to use your real name here to ensure your friends can find you, and connect to your channel. The short nickname will be used to generate a "webbie". This is a bit like a username, and will look like an email address, taking the form nickname@domain. You should put a little thought into what you want to use here. Imagine somebody asking for your webbie and having to tell them it is "llamas-are_kewl.123". "llamasarecool" would be a much better choice.
+
+Once you have created your channel, you will be taken to the settings page, where you can configure your channel, and set your default permissions.
+
+Once you have done this, your channel is ready to use. At [observer=1][observer.url][/observer][observer=0]example.com/channel/username[/observer] you will find your channel "stream". This is where your recent activity will appear, in reverse chronological order. If you post in the box marked "share", the entry will appear at the top of your stream. You will also find links to all the other communication areas for this channel here. The "About" tab contains your "profile", the photos page contain photo albums, and the events page contains events share by both yourself and your contacts.
+
+The "Matrix" page contains all recent posts from across the matrix, again in reverse chronologial order. The exact posts that appear here depend largely on your permissions. At their most permissive, you will receive posts from complete strangers. At the other end of the scale, you may see posts from only your friends - or if you're feeling really anti-social, only your own posts.
+
+As mentioned at the start, many other kinds of channel are possible, however, the creation procedure is the same. The difference between channels lies primarily in the permissions assigned. For example, a channel for sharing documents with colleagues at work would probably want more permissive settings for "Can write to my "public" file storage" than a personal account. For more information, see the permissions section.
+
+#include doc/macros/main_footer.bb;
+
diff --git a/sources/doc/checking_account_quota_usage.bb b/sources/doc/checking_account_quota_usage.bb
new file mode 100644
index 00000000..ca7e070a
--- /dev/null
+++ b/sources/doc/checking_account_quota_usage.bb
@@ -0,0 +1,20 @@
+[b]Checking your account quota usage (service limits usage)[/b]
+
+Your hub might implement service class limits, assigning limits to the total size of file, photo, channels, top-level posts, etc., that can be created by an account holder for a specific service level.
+
+Here's how you can quickly check how much of your assigned quota you're currently using:
+
+[b]Check file storage quota levels[/b]
+Visit the following URL in your browser:
+[observer=1][observer.baseurl]/filestorage/[observer.webname][/observer]
+[observer=0]example.com/filestorage/username[/observer]
+
+[b]Check uploaded photos storage quota levels[/b]
+[observer=1][observer.baseurl]/photos/[observer.webname][/observer]
+[observer=0]example.com/photos/username[/observer]
+
+Example:
+[observer=1][observer.baseurl]/filestorage/[observer.webname][/observer]
+[observer=0]example.com/filestorage/username[/observer]
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/classRedmatrix_1_1Import_1_1Import-members.html b/sources/doc/classRedmatrix_1_1Import_1_1Import-members.html
new file mode 100644
index 00000000..d5e2f927
--- /dev/null
+++ b/sources/doc/classRedmatrix_1_1Import_1_1Import-members.html
@@ -0,0 +1,131 @@
+
+
+
+
+
+
+The Hubzilla: Member List
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sources/doc/cloud.bb b/sources/doc/cloud.bb
new file mode 100644
index 00000000..20498e6a
--- /dev/null
+++ b/sources/doc/cloud.bb
@@ -0,0 +1,27 @@
+[b]Personal Cloud Storage[/b]
+
+The $Projectname provides an ability to store privately and/or share arbitrary files with friends.
+
+You may either upload files from your computer into your storage area, or copy them directly from the operating system using the WebDAV protocol.
+
+On many public servers there may be limits on disk usage.
+
+[b]File Attachments[/b]
+
+The quickest and easiest way to share files is through file attachments. In the row of icons below the status post editor is a tool to upload attachments. Click the tool, select a file and submit. After the file is uploaded, you will see an attachment code placed inside the text region. Do not edit this line or it may break the ability for your friends to see the attachment. You can use the post permissions dialogue box or privacy hashtags to restrict the visibility of the file - which will be set to match the permissions of the post your are sending.
+
+To delete attachments or change the permissions on the stored files, visit [observer.baseurl]/filestorage/{{username}}" replacing {{username}} with the nickname you provided during channel creation.
+
+[b]Web Access[/b]
+
+Your files are visible on the web at the location "cloud/{{username}}" to anybody who is allowed to view them. If the viewer has sufficient privileges, they may also have the ability to create new files and folders/directories.
+
+[b]WebDAV access[/b]
+
+See: [zrl=[baseurl]/help/cloud_desktop_clients]Cloud Desktop Clients[/zrl]
+
+[b]Permissions[/b]
+
+When using WebDAV, the file is created with your channel's default file permissions and this cannot be changed from within the operating system. It also may not be as restrictive as you would like. What we've found is that the preferred method of making files private is to first create folders or directories; then visit "filestorage/{{username}}"; select the directory and change the permissions. Do this before you put anything into the directory. The directory permissions take precedence so you can then put files or other folders into that container and they will be protected from unwanted viewers by the directory permissions. It is common for folks to create a "personal" or "private" folder which is restricted to themselves. You can use this as a personal cloud to store anything from anywhere on the web or any computer and it is protected from others. You might also create folders for "family" and "friends" with permission granted to appropriate collections of channels.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/cloud_desktop_clients.bb b/sources/doc/cloud_desktop_clients.bb
new file mode 100644
index 00000000..2f099527
--- /dev/null
+++ b/sources/doc/cloud_desktop_clients.bb
@@ -0,0 +1,21 @@
+[b]Cloud Desktop Clients[/b]
+
+[b]Windows Clients[/b]
+
+[li][zrl=[baseurl]/help/dav_windows]Windows Internal Client[/zrl][/li]
+
+
+[b]Linux Clients[/b]
+
+[li][zrl=[baseurl]/help/dav_mount]Command Line as a Filesystem[/zrl][/li]
+[li][zrl=[baseurl]/help/dav_dolphin]Dolphin[/zrl][/li]
+[li][zrl=[baseurl]/help/dav_konqueror]Konqueror[/zrl][/li]
+[li][zrl=[baseurl]/help/dav_nautilus]Nautilus[/zrl][/li]
+[li][zrl=[baseurl]/help/dav_nemo]Nemo[/zrl][/li]
+
+
+[b]Server Notes[/b]
+
+Note: There have been reported issues with clients that use "chunked transfer encoding", which includes Apple iOS services, and also the "AnyClient" and "CyberDuck" tools. These work fine for downloads, but uploads often end up with files of zero size. This is caused by an incorrect implemention of chunked encoding in some current FCGI (fast-cgi) implementations. Apache running with PHP as a module does not have these issues, but when running under FCGI you may need to use alternative clients or use the web uploader. At the time of this writing the issue has been open and no updates provided for at least a year. If you encounter zero size files with other clients, please check the client notes; as there are occasional configuration issues which can also produce these symptoms.
+
+#include doc/macros/cloud_footer.bb;
diff --git a/sources/doc/comanche.bb b/sources/doc/comanche.bb
new file mode 100644
index 00000000..2eaa15de
--- /dev/null
+++ b/sources/doc/comanche.bb
@@ -0,0 +1,220 @@
+[b]Comanche Page Description Language[/b]
+
+Comanche is a markup language similar to bbcode with which to create elaborate and complex web pages by assembling them from a series of components - some of which are pre-built and others which can be defined on the fly. Comanche uses a Page Decription Language to create these pages.
+
+Comanche primarily chooses what content will appear in various regions of the page. The various regions have names and these names can change depending on what layout template you choose.
+
+[b]Page Templates[/b]
+Currently there are five layout templates, unless your site provides additional layouts.
+
+[code]
+ [b]default[/b]
+ The default template defines a "nav" region across the top, "aside" as a fixed width sidebar,
+ "content" for the main content region, and "footer" for a page footer.
+
+
+ [b]full[/b]
+ The full template defines the same as the default template with the exception that there is no "aside" region.
+
+
+ [b]choklet[/b]
+ The choklet template provides a number of fluid layout styles which can be specified by flavour:
+
+ (default flavour) - a two column layout similar to the "default" template, but more fluid
+ bannertwo - a two column layout with a banner region, compatible with the "default" template on small displays
+ three - three column layout (adds a "right_aside" region to the default template)
+ edgestwo - two column layout with fixed side margins
+ edgesthree - three column layout with fixed side margins
+ full - three column layout with fixed side margins and adds a "header" region beneath the navigation bar
+
+ [b]redable[/b]
+ A template for reading longer texts. Three columns: aside, content and right_aside.
+ For maximum readability it is advised to only use the middle content column.
+
+ [b]zen[/b]
+ Gives you the freedom to do everything yourself. Just a blank page with a content region.
+
+[/code]
+
+To choose a layout template, use the 'template' tag.
+
+[code]
+ [template]full[/template]
+
+[/code]
+
+To choose the "choklet" template with the "three" flavour:
+
+[code]
+ [template=three]choklet[/template]
+
+[/code]
+
+The default template will be used if no other template is specified. The template can use any names it desires for content regions. You will be using 'region' tags to decide what content to place in the respective regions.
+
+Three "macros" have been defined for your use.
+[code]
+ $htmlhead - replaced with the site head content.
+ $nav - replaced with the site navigation bar content.
+ $content - replaced with the main page content.
+
+[/code]
+
+By default, $nav is placed in the "nav" page region and $content is placed in the "content" region. You only need to use these macros if you wish to re-arrange where these items appear, either to change the order or to move them to other regions.
+
+
+To select a theme for your page, use the 'theme' tag.
+[code]
+ [theme]apw[/theme]
+
+[/code]
+This will select the theme named "apw". By default your channel's preferred theme will be used.
+
+[code]
+ [theme=passion]apw[/theme]
+
+[/code]
+This will select the theme named "apw" and select the "passion" schema (theme variant).
+
+
+[b]Regions[/b]
+Each region has a name, as noted above. You will specify the region of interest using a 'region' tag, which includes the name. Any content you wish placed in this region should be placed between the opening region tag and the closing tag.
+
+[code]
+ [region=htmlhead]....content goes here....[/region]
+ [region=aside]....content goes here....[/region]
+ [region=nav]....content goes here....[/region]
+ [region=content]....content goes here....[/region]
+
+[/code]
+
+[b]CSS and Javascript[/b]
+We have the possibility to include javascript and css libraries in the htmlhead region. At present we make use of jquery (js), bootstrap (css/js) and foundation (css/js).
+This will overwrite the selected themes htmlhead.
+
+[code]
+ [region=htmlhead]
+ [css]bootstrap[/css]
+ [js]jquery[/js]
+ [js]bootstrap[/js]
+ [/region]
+
+[/code]
+
+[b]Menus and Blocks[/b]
+Your webpage creation tools allow you to create menus and blocks, in addition to page content. These provide a chunk of existing content to be placed in whatever regions and whatever order you specify. Each of these has a name which you define when the menu or block is created.
+
+[code]
+ [menu]mymenu[/menu]
+
+[/code]
+This places the menu called "mymenu" at this location on the page, which must be inside a region.
+
+[code]
+ [menu=horizontal]mymenu[/menu]
+
+[/code]
+This places the menu called "mymenu" at this location on the page, which must be inside a region. Additionally it applies the "horizontal" class to the menu. "horizontal" is defined in the redbasic theme. It may or may not be available in other themes.
+
+[code]
+ [menu][var=wrap]none[/var]mymenu[/menu]
+
+[/code]
+The variable [var=wrap]none[/var] in a block removes the wrapping div element from the menu.
+
+[code]
+ [block]contributors[/block]
+[/code]
+This places a block named "contributors" in this region.
+
+[code]
+ [block=someclass]contributors[/block]
+
+[/code]
+This places a block named "contributors" in this region. Additionally it applies the "someclass" class to the block. This replaces the default block classes "bblock widget".
+
+[code]
+ [block][var=wrap]none[/var]contributors[/block]
+
+[/code]
+The variable [var=wrap]none[/var] in a block removes the wrapping div element from the block.
+
+[b]Widgets[/b]
+Widgets are executable apps provided by the system which you can place on your page. Some widgets take arguments which allows you to tailor the widget to your purpose. (TODO: list available widgets and arguments). The base system provides
+
+[code]
+ profile - widget which duplicates the profile sidebar of your channel page. This widget takes no arguments
+ tagcloud - provides a tag cloud of categories
+ count - maximum number of category tags to list
+
+[/code]
+
+Widgets and arguments are specified with the 'widget' and 'var' tags.
+[code]
+ [widget=recent_visitors][var=count]24[/var][/widget]
+
+[/code]
+
+This loads the "recent_visitors" widget and supplies it with the argument "count" set to "24".
+
+[b]Comments[/b]
+The 'comment' tag is used to delimit comments. These comments will not appear on the rendered page.
+
+[code]
+ [comment]This is a comment[/comment]
+
+[/code]
+
+[b]Complex Example[/b]
+[code]
+ [comment]use an existing page template which provides a banner region plus 3 columns beneath it[/comment]
+
+ [template]3-column-with-header[/template]
+
+ [comment]Use the "darknight" theme[/comment]
+
+ [theme]darkknight[/theme]
+
+ [comment]Use the existing site navigation menu[/comment]
+
+ [region=nav]$nav[/region]
+
+ [region=side]
+
+ [comment]Use my chosen menu and a couple of widgets[/comment]
+
+ [menu]myfavouritemenu[/menu]
+
+ [widget=recent_visitors]
+ [var=count]24[/var]
+ [var=names_only]1[/var]
+ [/widget]
+
+ [widget=tagcloud][/widget]
+ [block]donate[/block]
+
+ [/region]
+
+
+
+ [region=middle]
+
+ [comment]Show the normal page content[/comment]
+
+ $content
+
+ [/region]
+
+
+
+ [region=right]
+
+ [comment]Show my condensed channel "wall" feed and allow interaction if the observer is allowed to interact[/comment]
+
+ [widget]channel[/widget]
+
+ [/region]
+
+[/code]
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/connecting_to_channels.bb b/sources/doc/connecting_to_channels.bb
new file mode 100644
index 00000000..be37eb25
--- /dev/null
+++ b/sources/doc/connecting_to_channels.bb
@@ -0,0 +1,19 @@
+[b]Connecting To Channels[/b]
+
+Connections in the $Projectname can take on a great many different meanings. But let's keep it simple, you want to be friends with somebody like you are familiar with from social networking. How do you do it?
+
+First, you need to find some channels to connect to. There are two primary ways of doing this. Firstly, setting the "Can send me their channel stream and posts" permission to "Anybody in this network" will bring posts from complete strangers to your matrix. This will give you a lot of public content and should hopefully help you find interesting, entertaing people, forums, and channels.
+
+The next thing you can do is look at the Directory. The directory is available on every $Projectname website which means searching from your own site will bring in results from the entire network. You can search by name, interest, location and keyword. This is incomplete, so we'll improve this paragraph later.
+
+To connect with other $Projectname channels:
+
+Visit their profile by clicking their photograph in the directory, matrix, or comments, and it will open their channel home page in the channel viewer. At the left hand side of the screen, you will usually see a link called "connect". Click it, and you're done. Depending on the settings of the channel you are connecting to, you may need to wait for them to approve your connection, but no further action is needed on your part. Once you've initiated the connection, you will be taken to the connection editor. This allows you to assign specific permissions for this channel. If you don't allow any permissions, communication will be very limited. There are some quick links which you can use to avoid setting individual permissions. To provide a social network environment, "Full Sharing" is recommended. You may review the settings that are applied with the quick links to ensure they are suitable for the channel you are connecting with and adjust if necessary. Then scroll to the bottom of the page and click "Submit".
+
+You may also connect with any channel by visiting the "Connections" page of your site or the Directory and typing their "webbie" into the "Add New Connection" field. Use this method if somebody tells you their webbie and you wish to connect with them. A webbie looks like an email address; for example "bob@example.com". The process is the same as connecting via the "Connect" button - you will then be taken to the connection editor to set permissions.
+
+[b]Premium Channels[/b]
+
+Some channels are designated "Premium Channels" and may require some action on your part before a connection can be established. The Connect button will for these channels will take you to a page which lists in detail what terms the channel owner has set. If the terms are accepted, the connection will then proceed normally. In some cases, such as with celebrities and world-reknowned publishers, this may involve payment. If you do not agree to the terms, the connection will not proceed, or it may proceed but with reduced permissions allowed on your interactions with that channel.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/connecting_to_channels.md b/sources/doc/connecting_to_channels.md
new file mode 100644
index 00000000..60834c24
--- /dev/null
+++ b/sources/doc/connecting_to_channels.md
@@ -0,0 +1,34 @@
+# Connecting To Channels #
+
+Connections in the $Projectname can take on a great many different meanings. But let's keep it simple, you want to be friends with somebody like you are familiar with from social networking. How do you do it?
+
+First, you need to find some channels to connect to. There are two primary ways of doing this. Firstly, setting the "Can send me their channel stream and posts" permission to "Anybody in this network" will bring posts from complete strangers to your matrix. This will give you a lot of public content and should hopefully help you find interesting, entertaing people, forums, and channels.
+
+The next thing you can do is look at the Directory. The directory is available on every $Projectname website which means searching from your own site will bring in results from the entire network. You can search by name, interest, location and keyword. This is incomplete, so we'll improve this paragraph later.
+
+To connect with other $Projectname channels:
+
+Visit their profile by clicking their photograph in the directory, matrix, or comments, and it will open their channel home page in the channel viewer. At the left hand side of the screen, you will usually see a link called "connect". Click it, and you're done. Depending on the settings of the channel you are connecting to, you may need to wait for them to approve your connection, but no further action is needed on your part. Once you've initiated the connection, you will be taken to the connection editor. This allows you to assign specific permissions for this channel. If you don't allow any permissions, communication will be very limited. There are some quick links which you can use to avoid setting individual permissions. To provide a social network environment, "Full Sharing" is recommended. You may review the settings that are applied with the quick links to ensure they are suitable for the channel you are connecting with and adjust if necessary. Then scroll to the bottom of the page and click "Submit".
+
+You may also connect with any channel by visiting the "Connections" page of your site or the Directory and typing their "webbie" into the "Add New Connection" field. Use this method if somebody tells you their webbie and you wish to connect with them. A webbie looks like an email address; for example "bob@example.com". The process is the same as connecting via the "Connect" button - you will then be taken to the connection editor to set permissions.
+
+## Block/Ignore/Archive/Hide channels ##
+
+Channels in your address book can have statuses such as *blocked*, *ignored*, *archived* and *hidden*. From your connections page you can see tabs that display the channels with those statuses. From your edit connection pages you can change the statuses of a channel.
+
+Here's their meaning:
+
+**Blocked:** the channel can't read your items regardless of permissions, nor can it write to your channel.
+
+**Ignored:** the channel can read your items if it has permission, but can't write to your channel.
+
+**Hidden:** the channel does not show up in your profile's connections list, noone can see you're connected, but beware they may still show up to your other connections, for example in post replies.
+
+**Archived:** if a channel can't be reached for 30 days, it is automatically marked as archived. This keeps all the data but stops polling the channel for new information and removes it from autocomplete. If later you learn the channel has come back online, you may manually unarchive it.
+
+
+## Premium Channels ##
+
+Some channels are designated "Premium Channels" and **may** require some action on your part before a connection can be established. The Connect button will for these channels will take you to a page which lists in detail what terms the channel owner has set. If the terms are accepted, the connection will then proceed normally. In some cases, such as with celebrities and world-reknowned publishers, this **may** involve payment. If you do not agree to the terms, the connection will not proceed, or it may proceed but with reduced permissions allowed on your interactions with that channel.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/credits.bb b/sources/doc/credits.bb
new file mode 100644
index 00000000..5459c7d7
--- /dev/null
+++ b/sources/doc/credits.bb
@@ -0,0 +1,75 @@
+[b]Credits[/b]
+
+Mike Macgirvin
+Fabio Comuni
+Simon L'nu
+marijus
+Tobias Diekershoff
+fabrixxm
+tommy tomson
+Simon
+zottel
+Christian Vogeley
+jeroenpraat
+Michael Vogel
+erik
+Zach Prezkuta
+Paolo T
+Michael Meer
+Michael
+Abinoam P. Marques Jr
+Tobias Hößl
+Alexander Kampmann
+Olaf Conradi
+Paolo Tacconi
+tobiasd
+Devlon Duthie
+Zvi ben Yaakov (a.k.a rdc)
+Alexandre Hannud Abdo
+Olivier Migeot
+Chris Case
+Klaus Weidenbach
+Michael Johnston
+olivierm
+Vasudev Kamath
+pixelroot
+Max Weller
+duthied
+Martin Schmitt
+Sebastian Egbers
+Erkan Yilmaz
+sasiflo
+Stefan Parviainen
+Haakon Meland Eriksen
+Oliver Hartmann (23n)
+Erik Lundin
+habeascodice
+sirius
+Charles
+Tony Baldwin
+Hauke Zuehl
+Keith Fernie
+Anne Walk
+toclimb
+Daniel Frank
+Matthew Exon
+Michal Supler
+Tobias Luther
+U-SOUND\mike
+mrjive
+nostupidzone
+tonnerkiller
+Antoine G
+Christian Drechsler
+Ludovic Grossard
+Stanislav Lechev [0xAF]
+aweiher
+bufalo1973
+dsp1986
+felixgilles
+ike
+maase2
+mycocham
+ndurchx
+pafcu
+Simó Albert i Beltran
diff --git a/sources/doc/database.bb b/sources/doc/database.bb
new file mode 100644
index 00000000..fe193cf7
--- /dev/null
+++ b/sources/doc/database.bb
@@ -0,0 +1,66 @@
+[h2]Database Tables[/h2]
+[table]
+[tr][th]Table[/th][th]Description[/th][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_abook]abook[/zrl][/td][td]connections of local channels[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_account]account[/zrl][/td][td]service provider account[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_addon]addon[/zrl][/td][td]registered plugins[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_app]app[/zrl][/td][td]personal app data[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_attach]attach[/zrl][/td][td]file attachments[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_auth_codes]auth_codes[/zrl][/td][td]OAuth usage[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_cache]cache[/zrl][/td][td]OEmbed cache[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_channel]channel[/zrl][/td][td]local channels[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_chat]chat[/zrl][/td][td]chat room content[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_chatpresence]chatpresence[/zrl][/td][td]channel presence information for chat[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_chatroom]chatroom[/zrl][/td][td]data for the actual chat room[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_clients]clients[/zrl][/td][td]OAuth usage[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_config]config[/zrl][/td][td]main configuration storage[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_conv]conv[/zrl][/td][td]Diaspora private messages meta conversation structure[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_event]event[/zrl][/td][td]Events[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_fcontact]fcontact[/zrl][/td][td]friend suggestion stuff (obsolete)[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_ffinder]ffinder[/zrl][/td][td]friend suggestion stuff (obsolete)[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_fserver]fserver[/zrl][/td][td]obsolete[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_fsuggest]fsuggest[/zrl][/td][td]friend suggestion stuff (unused)[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_group_member]group_member[/zrl][/td][td]privacy groups (collections), group info[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_groups]groups[/zrl][/td][td]privacy groups (collections), member info[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_hook]hook[/zrl][/td][td]plugin hook registry[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_hubloc]hubloc[/zrl][/td][td]Red location storage, ties a hub location to an xchan[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_issue]issue[/zrl][/td][td]future bug/issue database[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_item]item[/zrl][/td][td]all posts and webpages[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_item_id]item_id[/zrl][/td][td]other identifiers on other services for posts[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_likes]likes[/zrl][/td][td]likes of 'things'[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_mail]mail[/zrl][/td][td]private messages[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_manage]manage[/zrl][/td][td]may be unused in Red, table of accounts that can "su" each other[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_menu]menu[/zrl][/td][td]webpage menu data[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_menu_item]menu_item[/zrl][/td][td]entries for webpage menus[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_notify]notify[/zrl][/td][td]notifications[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_obj]obj[/zrl][/td][td]object data for things (x has y)[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_outq]outq[/zrl][/td][td]Red output queue[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_pconfig]pconfig[/zrl][/td][td]personal (per channel) configuration storage[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_photo]photo[/zrl][/td][td]photo storage[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_poll]poll[/zrl][/td][td]data for polls[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_poll_elm]poll_elm[/zrl][/td][td]data for poll elements[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_profdef]profdef[/zrl][/td][td]custom profile field definitions[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_profext]profext[/zrl][/td][td]custom profile field data[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_profile]profile[/zrl][/td][td]channel profiles[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_profile_check]profile_check[/zrl][/td][td]DFRN remote auth use, may be obsolete[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_register]register[/zrl][/td][td]registrations requiring admin approval[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_session]session[/zrl][/td][td]web session storage[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_shares]shares[/zrl][/td][td]shared item information[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_sign]sign[/zrl][/td][td]Diaspora signatures. To be phased out.[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_site]site[/zrl][/td][td]site table to find directory peers[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_source]source[/zrl][/td][td]channel sources data[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_spam]spam[/zrl][/td][td]unfinished[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_sys_perms]sys_perms[/zrl][/td][td]extensible permissions for OAuth[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_term]term[/zrl][/td][td]item taxonomy (categories, tags, etc.) table[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_tokens]tokens[/zrl][/td][td]OAuth usage[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_updates]updates[/zrl][/td][td]directory sync updates[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_verify]verify[/zrl][/td][td]general purpose verification structure[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_vote]vote[/zrl][/td][td]vote data for polls[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_xchan]xchan[/zrl][/td][td]list of known channels in the universe[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_xchat]xchat[/zrl][/td][td]bookmarked chat rooms[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_xconfig]xconfig[/zrl][/td][td]as pconfig but for channels with no local account[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_xign]xign[/zrl][/td][td]channels ignored by friend suggestions[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_xlink]xlink[/zrl][/td][td]"friends of friends" linkages derived from poco, also ratings storage[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_xprof]xprof[/zrl][/td][td]if this hub is a directory server, contains basic public profile info of everybody in the network[/td][/tr]
+[tr][td][zrl=[baseurl]/help/database/db_xtag]xtag[/zrl][/td][td]if this hub is a directory server, contains tags or interests of everybody in the network[/td][/tr]
+[/table]
diff --git a/sources/doc/database/db_abook.bb b/sources/doc/database/db_abook.bb
new file mode 100644
index 00000000..a34e5199
--- /dev/null
+++ b/sources/doc/database/db_abook.bb
@@ -0,0 +1,55 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]abook_id[/td][td]Sequential ID[/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]abook_account[/td][td]account.account_id of the channel which owns this record[/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]abook_channel[/td][td]channel.channel_id of the channel which owns this record[/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]abook_xchan[/td][td]xchan.xchan_hash of the target identity (this channel's connection)[/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]abook_my_perms[/td][td]bitfield of all specific permissions granted this connection[/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]abook_their_perms[/td][td]bitfield of all permissions granted to you by this connection[/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]abook_closeness[/td][td]"closeness" value for optional affinity tool, 0-99[/td][td]tinyint(3) unsigned[/td][td]NO[/td][td]MUL[/td][td]99[/td][td]
+[/td][/tr]
+[tr][td]abook_rating[/td][td]The channel owner's (public) rating of this connection -10 to +10, default 0 or unrated[/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]abook_rating_text[/td][td]The channel owner's (public) rating of this connection free form text[/td][td]text[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]abook_created[/td][td]Datetime this record was created[/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]abook_updated[/td][td]Datetime this record was modified[/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]abook_connected[/td][td]datetime of last successful "poll" for this connection[/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]abook_dob[/td][td]Datetime of connection's birthday converted from *their* timezone to UTC[/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]abook_flags[/td][td]Bitfield containing blocked(0x1), ignored(0x2), hidden(0x4), archived(0x8), pending(0x10), unconnected(0x20), self(0x80), feed(0x100)[/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]abook_profile[/td][td]profile.guid of profile to display to this connection if authenticated[/td][td]char(64)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[/table]
+
+
+Notes:
+
+ABOOK_FLAGS_BLOCKED - Bi-directional communications with this channel are blocked, regardless of other permissions.
+
+ABOOK_FLAGS_IGNORED - Incoming communications from this channel are blocked, regardless of other permissions.
+
+ABOOK_FLAGS_HIDDEN - This connection will not be shown as a connection to anybody but the channel owner
+
+ABOOK_FLAGS_ARCHIVED - This connection is likely non-functioning and the entry and conversations are preserved, but further polled communications will not be attempted.
+
+ABOOK_FLAGS_PENDING - A connection request was received from this channel but has not been approved by the channel owner, public communications may still be visible but no additional permissions have been granted.
+
+ABOOK_FLAGS_UNCONNECTED - currently unused. Projected usage is to indicate "one-way" connections which were insitgated on this end but are still pending on the remote end.
+
+ABOOK_FLAGS_SELF is a special case where the owner is the target. Every channel has one abook entry with ABOOK_FLAGS_SELF with a target abook_xchan set to channel.channel_hash . When this flag is present, abook_my_perms is the default permissions granted to all new connections and several other fields are unused.
+
+ABOOK_FLAGS_FEED - indicates this connection is an RSS/Atom feed and may trigger special handling.
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_account.bb b/sources/doc/database/db_account.bb
new file mode 100644
index 00000000..354f2d3a
--- /dev/null
+++ b/sources/doc/database/db_account.bb
@@ -0,0 +1,67 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]account_id[/td][td]table index[/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]account_parent[/td][td]for hierarchical accounts, the account_id of the parent to this one, if account_parent = account_id, this is the top level account[/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]account_default_channel[/td][td]channel_id of channel to connect on login[/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]account_salt[/td][td]complexity token for account_password[/td][td]char(32)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]account_password[/td][td]hashed password for this account[/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]account_email[/td][td]essentially the login ID, although it is usually possible to login with a channel address[/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]account_external[/td][td]Currently unused[/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]account_language[/td][td]default language (closest available browser-accept language when account was created)[/td][td]char(16)[/td][td]NO[/td][td][/td][td]en[/td][td]
+[/td][/tr]
+[tr][td]account_created[/td][td]timestamp of account creation[/td][td]datetime[/td][td]NO[/td][td][/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]account_lastlog[/td][td]timestamp of last login (or daily update if "remember me" is in effect)[/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]account_flags[/td][td]see notes[/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]account_roles[/td][td]see notes[/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]account_reset[/td][td]verification token for password reset[/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]account_expires[/td][td]timestamp when account expires and will be deleted[/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]account_expire_notified[/td][td]timestamp of last warning of account expiration[/td][td]datetime[/td][td]NO[/td][td][/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]account_service_class[/td][td]service class for this account, determines what if any limits/restrictions are in place[/td][td]char(32)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]account_level[/td][td]future use[/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]account_password_changed[/td][td]timestamp of last password change - to limit account deletion for 48 hours to prevent malicious activity[/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[/table]
+
+Notes:
+
+
+
+/**
+ * Account Flags
+ */
+
+define ( 'ACCOUNT_OK', 0x0000 );
+define ( 'ACCOUNT_UNVERIFIED', 0x0001 );
+define ( 'ACCOUNT_BLOCKED', 0x0002 );
+define ( 'ACCOUNT_EXPIRED', 0x0004 );
+define ( 'ACCOUNT_REMOVED', 0x0008 );
+define ( 'ACCOUNT_PENDING', 0x0010 );
+
+/**
+ * Account roles
+ */
+
+define ( 'ACCOUNT_ROLE_ALLOWCODE', 0x0001 ); // 1 - this account can create content with PHP/Javascript
+define ( 'ACCOUNT_ROLE_SYSTEM', 0x0002 ); // 2 - this is the special system account
+define ( 'ACCOUNT_ROLE_DEVELOPER', 0x0004 );
+define ( 'ACCOUNT_ROLE_ADMIN', 0x1000 ); // 4096 - this account is an administrator
+
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_addon.bb b/sources/doc/database/db_addon.bb
new file mode 100644
index 00000000..afa06d56
--- /dev/null
+++ b/sources/doc/database/db_addon.bb
@@ -0,0 +1,24 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td]generated index[td]int(11)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]name[/td][td]plugin base (file)name[/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]version[/td][td]currently unused[/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]installed[/td][td]currently always 1[/td][td]tinyint(1)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]hidden[/td][td]currently unused[/td][td]tinyint(1)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]timestamp[/td][td]file timestamp to check for reloads[/td][td]bigint(20)[/td][td]NO[/td][td][/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]plugin_admin[/td][td]1 = has admin config, 0 = has no admin config[/td][td]tinyint(1)[/td][td]NO[/td][td][/td][td]0[/td][td]
+[/td][/tr]
+[/table]
+
+Notes:
+
+These are addons which have been enabled by the site administrator on the admin/plugin page
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_app.bb b/sources/doc/database/db_app.bb
new file mode 100644
index 00000000..7076bffd
--- /dev/null
+++ b/sources/doc/database/db_app.bb
@@ -0,0 +1,36 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td]generated index[/td][td]int(11)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]app_id[/td][td]hash identifying this app[/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]app_sig[/td][td]currently unused[/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]app_author[/td][td]xchan_hash of app creator[/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]app_name[/td][td]name of app[/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]app_desc[/td][td]optional description of app[/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]app_url[/td][td]target_url[/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]app_photo[/td][td]app icon[/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]app_version[/td][td]version of app[/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]app_channel[/td][td]channel_id owning this instance of the app[/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]app_addr[/td][td]reddress/webbie of app creator[/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]app_price[/td][td]free-form price field[/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]app_page[/td][td]currently unused[/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]app_requires[/td][td]currently unused[/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[/table]
+
+Storage for personal apps
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_attach.bb b/sources/doc/database/db_attach.bb
new file mode 100644
index 00000000..4514c87f
--- /dev/null
+++ b/sources/doc/database/db_attach.bb
@@ -0,0 +1,50 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td]generated index[/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]aid[/td][td]account_id of owner[/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]uid[/td][td]channel_id of owner[/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]hash[/td][td]hash for cross-site identification[/td][td]char(64)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]creator[/td][td]xchan_hash of author/creator[/td][td]char(128)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]filename[/td][td]filename of original[/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]filetype[/td][td]mimetype[/td][td]char(64)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]filesize[/td][td]size in bytes[/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]revision[/td][td]for version control (partially implemented)[/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]folder[/td][td]attach.hash of parent folder[/td][td]char(64)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]flags[/td][td]see notes[/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]data[/td][td]file data or pathname to stored data if ATTACH_FLAG_OS[/td][td]longblob[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]created[/td][td]creation time[/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]edited[/td][td]last edit time[/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]allow_cid[/td][td]permissions[/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]allow_gid[/td][td]permissions[/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]deny_cid[/td][td]permissions[/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]deny_gid[/td][td]permissions[/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+
+Bitmasks
+
+define ( 'ATTACH_FLAG_DIR', 0x0001); This is a directory
+define ( 'ATTACH_FLAG_OS', 0x0002); Data content is link to OS file containing data, if unset the data filed contains the file data
+
+permissions are xchan_hash or group_hash surrounded by angle chars. e.g. ''
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_auth_codes.bb b/sources/doc/database/db_auth_codes.bb
new file mode 100644
index 00000000..c60f064a
--- /dev/null
+++ b/sources/doc/database/db_auth_codes.bb
@@ -0,0 +1,19 @@
+
+OAuth2 authorisation register - currently implemented but unused
+
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]varchar(40)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]client_id[/td][td][/td][td]varchar(20)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]redirect_uri[/td][td][/td][td]varchar(200)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]expires[/td][td][/td][td]int(11)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]scope[/td][td][/td][td]varchar(250)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_cache.bb b/sources/doc/database/db_cache.bb
new file mode 100644
index 00000000..02c292f2
--- /dev/null
+++ b/sources/doc/database/db_cache.bb
@@ -0,0 +1,15 @@
+
+OEmbed information cache
+
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]k[/td][td]horizontal width + url or resource[/td][td]char(255)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]v[/td][td]OEmbed response from site[/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]updated[/td][td]datetime of cache insertion[/td][td]datetime[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_channel.bb b/sources/doc/database/db_channel.bb
new file mode 100644
index 00000000..215db3fb
--- /dev/null
+++ b/sources/doc/database/db_channel.bb
@@ -0,0 +1,96 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]channel_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]channel_account_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]channel_primary[/td][td][/td][td]tinyint(1) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]channel_name[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]channel_address[/td][td][/td][td]char(255)[/td][td]NO[/td][td]UNI[/td][td][/td][td]
+[/td][/tr]
+[tr][td]channel_guid[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]channel_guid_sig[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]channel_hash[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]channel_timezone[/td][td][/td][td]char(128)[/td][td]NO[/td][td]MUL[/td][td]UTC[/td][td]
+[/td][/tr]
+[tr][td]channel_location[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]channel_theme[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]channel_startpage[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]channel_pubkey[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]channel_prvkey[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]channel_notifyflags[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]65535[/td][td]
+[/td][/tr]
+[tr][td]channel_pageflags[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]channel_dirdate[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]channel_deleted[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]channel_max_anon_mail[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]10[/td][td]
+[/td][/tr]
+[tr][td]channel_max_friend_req[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]10[/td][td]
+[/td][/tr]
+[tr][td]channel_expire_days[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]channel_passwd_reset[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]channel_default_group[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]channel_allow_cid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]channel_allow_gid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]channel_deny_cid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]channel_deny_gid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]channel_r_stream[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]128[/td][td]
+[/td][/tr]
+[tr][td]channel_r_profile[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]128[/td][td]
+[/td][/tr]
+[tr][td]channel_r_photos[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]128[/td][td]
+[/td][/tr]
+[tr][td]channel_r_abook[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]128[/td][td]
+[/td][/tr]
+[tr][td]channel_w_stream[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]128[/td][td]
+[/td][/tr]
+[tr][td]channel_w_wall[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]128[/td][td]
+[/td][/tr]
+[tr][td]channel_w_tagwall[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]128[/td][td]
+[/td][/tr]
+[tr][td]channel_w_comment[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]128[/td][td]
+[/td][/tr]
+[tr][td]channel_w_mail[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]128[/td][td]
+[/td][/tr]
+[tr][td]channel_w_photos[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]128[/td][td]
+[/td][/tr]
+[tr][td]channel_w_chat[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]128[/td][td]
+[/td][/tr]
+[tr][td]channel_a_delegate[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]channel_r_storage[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]128[/td][td]
+[/td][/tr]
+[tr][td]channel_w_storage[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]128[/td][td]
+[/td][/tr]
+[tr][td]channel_r_pages[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]128[/td][td]
+[/td][/tr]
+[tr][td]channel_w_pages[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]128[/td][td]
+[/td][/tr]
+[tr][td]channel_a_republish[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]128[/td][td]
+[/td][/tr]
+[tr][td]channel_w_like[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]128[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_chat.bb b/sources/doc/database/db_chat.bb
new file mode 100644
index 00000000..6221f36e
--- /dev/null
+++ b/sources/doc/database/db_chat.bb
@@ -0,0 +1,16 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]chat_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]chat_room[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]chat_xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]chat_text[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]created[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_chatpresence.bb b/sources/doc/database/db_chatpresence.bb
new file mode 100644
index 00000000..cdc948a6
--- /dev/null
+++ b/sources/doc/database/db_chatpresence.bb
@@ -0,0 +1,18 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]cp_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]cp_room[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]cp_xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]cp_last[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]cp_status[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]cp_client[/td][td][/td][td]char(128)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_chatroom.bb b/sources/doc/database/db_chatroom.bb
new file mode 100644
index 00000000..b2da762c
--- /dev/null
+++ b/sources/doc/database/db_chatroom.bb
@@ -0,0 +1,28 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]cr_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]cr_aid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]cr_uid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]cr_name[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]cr_created[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]cr_edited[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]cr_expire[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]allow_cid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]allow_gid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]deny_cid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]deny_gid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_clients.bb b/sources/doc/database/db_clients.bb
new file mode 100644
index 00000000..d342b529
--- /dev/null
+++ b/sources/doc/database/db_clients.bb
@@ -0,0 +1,18 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]client_id[/td][td][/td][td]varchar(20)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]pw[/td][td][/td][td]varchar(20)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]redirect_uri[/td][td][/td][td]varchar(200)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]name[/td][td][/td][td]text[/td][td]YES[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]icon[/td][td][/td][td]text[/td][td]YES[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(11)[/td][td]NO[/td][td][/td][td]0[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_config.bb b/sources/doc/database/db_config.bb
new file mode 100644
index 00000000..f32d3c25
--- /dev/null
+++ b/sources/doc/database/db_config.bb
@@ -0,0 +1,14 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]cat[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]k[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]v[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_conv.bb b/sources/doc/database/db_conv.bb
new file mode 100644
index 00000000..ba1ba7f0
--- /dev/null
+++ b/sources/doc/database/db_conv.bb
@@ -0,0 +1,22 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]guid[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]recips[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(11)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]creator[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]created[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]updated[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]subject[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_event.bb b/sources/doc/database/db_event.bb
new file mode 100644
index 00000000..7c31d7fd
--- /dev/null
+++ b/sources/doc/database/db_event.bb
@@ -0,0 +1,46 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(11)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]aid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]event_xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]event_hash[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]created[/td][td][/td][td]datetime[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]edited[/td][td][/td][td]datetime[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]start[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]finish[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]summary[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]description[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]location[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]type[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]nofinish[/td][td][/td][td]tinyint(1)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]adjust[/td][td][/td][td]tinyint(1)[/td][td]NO[/td][td]MUL[/td][td]1[/td][td]
+[/td][/tr]
+[tr][td]ignore[/td][td][/td][td]tinyint(1)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]allow_cid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]allow_gid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]deny_cid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]deny_gid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_fcontact.bb b/sources/doc/database/db_fcontact.bb
new file mode 100644
index 00000000..9bd8c20f
--- /dev/null
+++ b/sources/doc/database/db_fcontact.bb
@@ -0,0 +1,38 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]url[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]name[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]photo[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]request[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]nick[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]addr[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]batch[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]notify[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]poll[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]confirm[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]priority[/td][td][/td][td]tinyint(1)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]network[/td][td][/td][td]char(32)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]alias[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]pubkey[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]updated[/td][td][/td][td]datetime[/td][td]NO[/td][td][/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_ffinder.bb b/sources/doc/database/db_ffinder.bb
new file mode 100644
index 00000000..c20158d5
--- /dev/null
+++ b/sources/doc/database/db_ffinder.bb
@@ -0,0 +1,14 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]cid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]fid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_fserver.bb b/sources/doc/database/db_fserver.bb
new file mode 100644
index 00000000..4c4b0b53
--- /dev/null
+++ b/sources/doc/database/db_fserver.bb
@@ -0,0 +1,14 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(11)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]server[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]posturl[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]key[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_fsuggest.bb b/sources/doc/database/db_fsuggest.bb
new file mode 100644
index 00000000..9da1f2f6
--- /dev/null
+++ b/sources/doc/database/db_fsuggest.bb
@@ -0,0 +1,24 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(11)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(11)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]cid[/td][td][/td][td]int(11)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]name[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]url[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]request[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]photo[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]note[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]created[/td][td][/td][td]datetime[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_group_member.bb b/sources/doc/database/db_group_member.bb
new file mode 100644
index 00000000..d31fa1ed
--- /dev/null
+++ b/sources/doc/database/db_group_member.bb
@@ -0,0 +1,14 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]gid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_groups.bb b/sources/doc/database/db_groups.bb
new file mode 100644
index 00000000..03e4fe2d
--- /dev/null
+++ b/sources/doc/database/db_groups.bb
@@ -0,0 +1,18 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]hash[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]visible[/td][td][/td][td]tinyint(1)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]deleted[/td][td][/td][td]tinyint(1)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]name[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_hook.bb b/sources/doc/database/db_hook.bb
new file mode 100644
index 00000000..6e8e907a
--- /dev/null
+++ b/sources/doc/database/db_hook.bb
@@ -0,0 +1,16 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(11)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]hook[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]file[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]function[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]priority[/td][td][/td][td]int(11) unsigned[/td][td]NO[/td][td][/td][td]0[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_hubloc.bb b/sources/doc/database/db_hubloc.bb
new file mode 100644
index 00000000..e4ab7159
--- /dev/null
+++ b/sources/doc/database/db_hubloc.bb
@@ -0,0 +1,38 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]hubloc_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]hubloc_guid[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]hubloc_guid_sig[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]hubloc_hash[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]hubloc_addr[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]hubloc_network[/td][td][/td][td]char(32)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]hubloc_flags[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]hubloc_status[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]hubloc_url[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]hubloc_url_sig[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]hubloc_host[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]hubloc_callback[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]hubloc_connect[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]hubloc_sitekey[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]hubloc_updated[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]hubloc_connected[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_issue.bb b/sources/doc/database/db_issue.bb
new file mode 100644
index 00000000..0a6f2912
--- /dev/null
+++ b/sources/doc/database/db_issue.bb
@@ -0,0 +1,20 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]issue_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]issue_created[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]issue_updated[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]issue_assigned[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]issue_priority[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]issue_status[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]issue_component[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_item.bb b/sources/doc/database/db_item.bb
new file mode 100644
index 00000000..b31823d6
--- /dev/null
+++ b/sources/doc/database/db_item.bb
@@ -0,0 +1,104 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]mid[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]aid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]parent[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]parent_mid[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]thr_parent[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]created[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]edited[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]expires[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]commented[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]received[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]changed[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]comments_closed[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]owner_xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]author_xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]source_xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]mimetype[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]title[/td][td][/td][td]text[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]body[/td][td][/td][td]mediumtext[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]app[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]lang[/td][td][/td][td]char(64)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]revision[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]verb[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]obj_type[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]object[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]tgt_type[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]target[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]layout_mid[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]postopts[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]route[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]llink[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]plink[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]resource_id[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]resource_type[/td][td][/td][td]char(16)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]attach[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]sig[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]diaspora_meta[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]location[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]coord[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]public_policy[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]comment_policy[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]allow_cid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]allow_gid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]deny_cid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]deny_gid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]item_restrict[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]item_flags[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]item_private[/td][td][/td][td]tinyint(4)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_item_id.bb b/sources/doc/database/db_item_id.bb
new file mode 100644
index 00000000..b77ae2d1
--- /dev/null
+++ b/sources/doc/database/db_item_id.bb
@@ -0,0 +1,16 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]iid[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]sid[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]service[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_likes.bb b/sources/doc/database/db_likes.bb
new file mode 100644
index 00000000..118c9a87
--- /dev/null
+++ b/sources/doc/database/db_likes.bb
@@ -0,0 +1,24 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]channel_id[/td][td][/td][td]int(11) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]liker[/td][td][/td][td]char(128)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]likee[/td][td][/td][td]char(128)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]iid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]verb[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]target_type[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]target_id[/td][td][/td][td]char(128)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]target[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_mail.bb b/sources/doc/database/db_mail.bb
new file mode 100644
index 00000000..0628584a
--- /dev/null
+++ b/sources/doc/database/db_mail.bb
@@ -0,0 +1,34 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]convid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]mail_flags[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]from_xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]to_xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]account_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]channel_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]title[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]body[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]attach[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]mid[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]parent_mid[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]created[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]expires[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_manage.bb b/sources/doc/database/db_manage.bb
new file mode 100644
index 00000000..a0fdf5aa
--- /dev/null
+++ b/sources/doc/database/db_manage.bb
@@ -0,0 +1,12 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(11)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_menu.bb b/sources/doc/database/db_menu.bb
new file mode 100644
index 00000000..5b478115
--- /dev/null
+++ b/sources/doc/database/db_menu.bb
@@ -0,0 +1,16 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]menu_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]menu_channel_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]menu_name[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]menu_desc[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]menu_flags[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_menu_item.bb b/sources/doc/database/db_menu_item.bb
new file mode 100644
index 00000000..b14aac5e
--- /dev/null
+++ b/sources/doc/database/db_menu_item.bb
@@ -0,0 +1,28 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]mitem_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]mitem_link[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]mitem_desc[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]mitem_flags[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]allow_cid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]allow_gid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]deny_cid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]deny_gid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]mitem_channel_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]mitem_menu_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]mitem_order[/td][td][/td][td]int(11)[/td][td]NO[/td][td][/td][td]0[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_notify.bb b/sources/doc/database/db_notify.bb
new file mode 100644
index 00000000..42f9350e
--- /dev/null
+++ b/sources/doc/database/db_notify.bb
@@ -0,0 +1,36 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(11)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]hash[/td][td][/td][td]char(64)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]name[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]url[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]photo[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]date[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]msg[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]aid[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]link[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]parent[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]seen[/td][td][/td][td]tinyint(1)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]type[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]verb[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]otype[/td][td][/td][td]char(16)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_obj.bb b/sources/doc/database/db_obj.bb
new file mode 100644
index 00000000..cc5e7559
--- /dev/null
+++ b/sources/doc/database/db_obj.bb
@@ -0,0 +1,26 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]obj_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]obj_page[/td][td][/td][td]char(64)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]obj_verb[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]obj_type[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]obj_obj[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]obj_channel[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]allow_cid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]allow_gid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]deny_cid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]deny_gid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_outq.bb b/sources/doc/database/db_outq.bb
new file mode 100644
index 00000000..970f99de
--- /dev/null
+++ b/sources/doc/database/db_outq.bb
@@ -0,0 +1,28 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]outq_hash[/td][td][/td][td]char(255)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]outq_account[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]outq_channel[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]outq_driver[/td][td][/td][td]char(32)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]outq_posturl[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]outq_async[/td][td][/td][td]tinyint(1)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]outq_delivered[/td][td][/td][td]tinyint(1)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]outq_created[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]outq_updated[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]outq_notify[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]outq_msg[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_pconfig.bb b/sources/doc/database/db_pconfig.bb
new file mode 100644
index 00000000..2ac36e61
--- /dev/null
+++ b/sources/doc/database/db_pconfig.bb
@@ -0,0 +1,16 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(11)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]cat[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]k[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]v[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_photo.bb b/sources/doc/database/db_photo.bb
new file mode 100644
index 00000000..6a0cdf36
--- /dev/null
+++ b/sources/doc/database/db_photo.bb
@@ -0,0 +1,52 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]aid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]resource_id[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]created[/td][td][/td][td]datetime[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]edited[/td][td][/td][td]datetime[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]title[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]description[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]album[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]filename[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]type[/td][td][/td][td]char(128)[/td][td]NO[/td][td]MUL[/td][td]image/jpeg[/td][td]
+[/td][/tr]
+[tr][td]height[/td][td][/td][td]smallint(6)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]width[/td][td][/td][td]smallint(6)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]size[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]data[/td][td][/td][td]mediumblob[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]scale[/td][td][/td][td]tinyint(3)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]profile[/td][td][/td][td]tinyint(1)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]photo_flags[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]allow_cid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]allow_gid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]deny_cid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]deny_gid[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_poll.bb b/sources/doc/database/db_poll.bb
new file mode 100644
index 00000000..57d808b7
--- /dev/null
+++ b/sources/doc/database/db_poll.bb
@@ -0,0 +1,16 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]poll_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]poll_channel[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]poll_desc[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]poll_flags[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]poll_votes[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_poll_elm.bb b/sources/doc/database/db_poll_elm.bb
new file mode 100644
index 00000000..fd649d5a
--- /dev/null
+++ b/sources/doc/database/db_poll_elm.bb
@@ -0,0 +1,16 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]pelm_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]pelm_poll[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]pelm_desc[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]pelm_flags[/td][td][/td][td]int(11)[/td][td]NO[/td][td][/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]pelm_result[/td][td][/td][td]float[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_profdef.bb b/sources/doc/database/db_profdef.bb
new file mode 100644
index 00000000..a0904fd7
--- /dev/null
+++ b/sources/doc/database/db_profdef.bb
@@ -0,0 +1,18 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]field_name[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]field_type[/td][td][/td][td]char(16)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]field_desc[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]field_help[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]field_inputs[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_profext.bb b/sources/doc/database/db_profext.bb
new file mode 100644
index 00000000..ada9dce2
--- /dev/null
+++ b/sources/doc/database/db_profext.bb
@@ -0,0 +1,16 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]channel_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]hash[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]k[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]v[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_profile.bb b/sources/doc/database/db_profile.bb
new file mode 100644
index 00000000..83db7571
--- /dev/null
+++ b/sources/doc/database/db_profile.bb
@@ -0,0 +1,94 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(11)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]profile_guid[/td][td][/td][td]char(64)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]aid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]profile_name[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]is_default[/td][td][/td][td]tinyint(1)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]hide_friends[/td][td][/td][td]tinyint(1)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]name[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]pdesc[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]chandesc[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]dob[/td][td][/td][td]char(32)[/td][td]NO[/td][td][/td][td]0000-00-00[/td][td]
+[/td][/tr]
+[tr][td]dob_tz[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]UTC[/td][td]
+[/td][/tr]
+[tr][td]address[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]locality[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]region[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]postal_code[/td][td][/td][td]char(32)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]country_name[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]hometown[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]gender[/td][td][/td][td]char(32)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]marital[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]with[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]howlong[/td][td][/td][td]datetime[/td][td]NO[/td][td][/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]sexual[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]politic[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]religion[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]keywords[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]likes[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]dislikes[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]about[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]summary[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]music[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]book[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]tv[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]film[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]interest[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]romance[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]work[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]education[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]contact[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]channels[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]homepage[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]photo[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]thumb[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]publish[/td][td][/td][td]tinyint(1)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_profile_check.bb b/sources/doc/database/db_profile_check.bb
new file mode 100644
index 00000000..3be64c5d
--- /dev/null
+++ b/sources/doc/database/db_profile_check.bb
@@ -0,0 +1,18 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]cid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]dfrn_id[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]sec[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]expire[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_register.bb b/sources/doc/database/db_register.bb
new file mode 100644
index 00000000..50672b5e
--- /dev/null
+++ b/sources/doc/database/db_register.bb
@@ -0,0 +1,18 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]hash[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]created[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]password[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]language[/td][td][/td][td]char(16)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_session.bb b/sources/doc/database/db_session.bb
new file mode 100644
index 00000000..d7ff0482
--- /dev/null
+++ b/sources/doc/database/db_session.bb
@@ -0,0 +1,14 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]bigint(20) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]sid[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]data[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]expire[/td][td][/td][td]bigint(20) unsigned[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_shares.bb b/sources/doc/database/db_shares.bb
new file mode 100644
index 00000000..be5255c0
--- /dev/null
+++ b/sources/doc/database/db_shares.bb
@@ -0,0 +1,14 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]share_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]share_type[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]share_target[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]share_xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_sign.bb b/sources/doc/database/db_sign.bb
new file mode 100644
index 00000000..e80ea7ef
--- /dev/null
+++ b/sources/doc/database/db_sign.bb
@@ -0,0 +1,18 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]iid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]retract_iid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]signed_text[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]signature[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]signer[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_site.bb b/sources/doc/database/db_site.bb
new file mode 100644
index 00000000..8dea4dae
--- /dev/null
+++ b/sources/doc/database/db_site.bb
@@ -0,0 +1,28 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]site_url[/td][td][/td][td]char(255)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]site_access[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]site_flags[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]site_update[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]site_pull[/td][td][/td][td]datetime[/td][td]NO[/td][td][/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]site_sync[/td][td][/td][td]datetime[/td][td]NO[/td][td][/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]site_directory[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]site_register[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]site_sellpage[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]site_location[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]site_realm[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_source.bb b/sources/doc/database/db_source.bb
new file mode 100644
index 00000000..92850a82
--- /dev/null
+++ b/sources/doc/database/db_source.bb
@@ -0,0 +1,16 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]src_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]src_channel_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]src_channel_xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]src_xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]src_patt[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_spam.bb b/sources/doc/database/db_spam.bb
new file mode 100644
index 00000000..b75e1edd
--- /dev/null
+++ b/sources/doc/database/db_spam.bb
@@ -0,0 +1,18 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(11)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]spam[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]ham[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]term[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]date[/td][td][/td][td]datetime[/td][td]NO[/td][td][/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_sys_perms.bb b/sources/doc/database/db_sys_perms.bb
new file mode 100644
index 00000000..04416a26
--- /dev/null
+++ b/sources/doc/database/db_sys_perms.bb
@@ -0,0 +1,16 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]cat[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]k[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]v[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]public_perm[/td][td][/td][td]tinyint(1) unsigned[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_term.bb b/sources/doc/database/db_term.bb
new file mode 100644
index 00000000..c0546cc6
--- /dev/null
+++ b/sources/doc/database/db_term.bb
@@ -0,0 +1,28 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]tid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]aid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]oid[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]otype[/td][td][/td][td]tinyint(3) unsigned[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]type[/td][td][/td][td]tinyint(3) unsigned[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]term[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]url[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]imgurl[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]term_hash[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]parent_hash[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_tokens.bb b/sources/doc/database/db_tokens.bb
new file mode 100644
index 00000000..35da2458
--- /dev/null
+++ b/sources/doc/database/db_tokens.bb
@@ -0,0 +1,18 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]varchar(40)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]secret[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]client_id[/td][td][/td][td]varchar(20)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]expires[/td][td][/td][td]bigint(20) unsigned[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]scope[/td][td][/td][td]varchar(200)[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_updates.bb b/sources/doc/database/db_updates.bb
new file mode 100644
index 00000000..f2e25d84
--- /dev/null
+++ b/sources/doc/database/db_updates.bb
@@ -0,0 +1,20 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]ud_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]ud_hash[/td][td][/td][td]char(128)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]ud_guid[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]ud_date[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]ud_last[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]ud_flags[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]ud_addr[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_verify.bb b/sources/doc/database/db_verify.bb
new file mode 100644
index 00000000..9d01181c
--- /dev/null
+++ b/sources/doc/database/db_verify.bb
@@ -0,0 +1,18 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]channel[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]type[/td][td][/td][td]char(32)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]token[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]meta[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]created[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_vote.bb b/sources/doc/database/db_vote.bb
new file mode 100644
index 00000000..0b9a423e
--- /dev/null
+++ b/sources/doc/database/db_vote.bb
@@ -0,0 +1,16 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]vote_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]vote_poll[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]vote_element[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]vote_result[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]vote_xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_xchan.bb b/sources/doc/database/db_xchan.bb
new file mode 100644
index 00000000..fd1d6829
--- /dev/null
+++ b/sources/doc/database/db_xchan.bb
@@ -0,0 +1,44 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]xchan_hash[/td][td][/td][td]char(255)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]xchan_guid[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xchan_guid_sig[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]xchan_pubkey[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]xchan_photo_mimetype[/td][td][/td][td]char(32)[/td][td]NO[/td][td][/td][td]image/jpeg[/td][td]
+[/td][/tr]
+[tr][td]xchan_photo_l[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]xchan_photo_m[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]xchan_photo_s[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]xchan_addr[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xchan_url[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xchan_connurl[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xchan_follow[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xchan_connpage[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]xchan_name[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xchan_network[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xchan_instance_url[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xchan_flags[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]xchan_photo_date[/td][td][/td][td]datetime[/td][td]NO[/td][td][/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[tr][td]xchan_name_date[/td][td][/td][td]datetime[/td][td]NO[/td][td][/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_xchat.bb b/sources/doc/database/db_xchat.bb
new file mode 100644
index 00000000..0897408d
--- /dev/null
+++ b/sources/doc/database/db_xchat.bb
@@ -0,0 +1,16 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]xchat_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]xchat_url[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xchat_desc[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xchat_xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xchat_edited[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_xconfig.bb b/sources/doc/database/db_xconfig.bb
new file mode 100644
index 00000000..111d1ce3
--- /dev/null
+++ b/sources/doc/database/db_xconfig.bb
@@ -0,0 +1,16 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]cat[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]k[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]v[/td][td][/td][td]mediumtext[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_xign.bb b/sources/doc/database/db_xign.bb
new file mode 100644
index 00000000..e216e11c
--- /dev/null
+++ b/sources/doc/database/db_xign.bb
@@ -0,0 +1,12 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]uid[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_xlink.bb b/sources/doc/database/db_xlink.bb
new file mode 100644
index 00000000..2eefec14
--- /dev/null
+++ b/sources/doc/database/db_xlink.bb
@@ -0,0 +1,16 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]xlink_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]xlink_xchan[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xlink_link[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xlink_rating[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]xlink_updated[/td][td][/td][td]datetime[/td][td]NO[/td][td]MUL[/td][td]0000-00-00 00:00:00[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_xprof.bb b/sources/doc/database/db_xprof.bb
new file mode 100644
index 00000000..d98fb3f1
--- /dev/null
+++ b/sources/doc/database/db_xprof.bb
@@ -0,0 +1,36 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]xprof_hash[/td][td][/td][td]char(255)[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]xprof_age[/td][td][/td][td]tinyint(3) unsigned[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[tr][td]xprof_desc[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xprof_dob[/td][td][/td][td]char(12)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xprof_gender[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xprof_marital[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xprof_sexual[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xprof_locale[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xprof_region[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xprof_postcode[/td][td][/td][td]char(32)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xprof_country[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xprof_keywords[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]xprof_about[/td][td][/td][td]text[/td][td]NO[/td][td][/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]xprof_homepage[/td][td][/td][td]char(255)[/td][td]NO[/td][td][/td][td][/td][td]
+[/td][/tr]
+[tr][td]xprof_hometown[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/database/db_xtag.bb b/sources/doc/database/db_xtag.bb
new file mode 100644
index 00000000..1e6fb996
--- /dev/null
+++ b/sources/doc/database/db_xtag.bb
@@ -0,0 +1,14 @@
+[table]
+[tr][th]Field[/th][th]Description[/th][th]Type[/th][th]Null[/th][th]Key[/th][th]Default[/th][th]Extra
+[/th][/tr]
+[tr][td]xtag_id[/td][td][/td][td]int(10) unsigned[/td][td]NO[/td][td]PRI[/td][td]NULL[/td][td]auto_increment
+[/td][/tr]
+[tr][td]xtag_hash[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td]NULL[/td][td]
+[/td][/tr]
+[tr][td]xtag_term[/td][td][/td][td]char(255)[/td][td]NO[/td][td]MUL[/td][td][/td][td]
+[/td][/tr]
+[tr][td]xtag_flags[/td][td][/td][td]int(11)[/td][td]NO[/td][td]MUL[/td][td]0[/td][td]
+[/td][/tr]
+[/table]
+
+Return to [zrl=[baseurl]/help/database]database documentation[/zrl]
\ No newline at end of file
diff --git a/sources/doc/dav_dolphin.bb b/sources/doc/dav_dolphin.bb
new file mode 100644
index 00000000..a1ebba39
--- /dev/null
+++ b/sources/doc/dav_dolphin.bb
@@ -0,0 +1,9 @@
+[b]Using The Cloud - Dolphin[/b]
+
+Visit webdavs://example.com/cloud where "example.com" is the URL of your hub.
+
+When prompted for a username and password, enter your username (the first part of your webbie - no @ or domain name) and password for your normal account.
+
+Note, if you are already logged in to the web interface via Konqueror, you will not be prompted for further authentication.
+
+#include doc/macros/cloud_footer.bb;
diff --git a/sources/doc/dav_konqueror.bb b/sources/doc/dav_konqueror.bb
new file mode 100644
index 00000000..79108e1d
--- /dev/null
+++ b/sources/doc/dav_konqueror.bb
@@ -0,0 +1,12 @@
+[b]Using The Cloud - Konqueror[/b]
+
+Simply visit webdavs://example.com/cloud after logging in to your hub, where "example.com" is the URL of your hub.
+
+No further authentication is required if you are logged in to your hub in the normal manner.
+
+Additionally, if one has authenticated at a different hub during their normal browser session, your identity will be passed to the cloud for these hubs too - meaning you can access any private files on any server, as long as you have permissions to see them, as long as you have visited that site earlier in your session.
+
+This functionality is normally restricted to the web interface, and is not available to any desktop software other than KDE.
+
+#include doc/macros/cloud_footer.bb;
+
diff --git a/sources/doc/dav_mount.bb b/sources/doc/dav_mount.bb
new file mode 100644
index 00000000..d8cb2e08
--- /dev/null
+++ b/sources/doc/dav_mount.bb
@@ -0,0 +1,86 @@
+[b]Mounting As A Filesystem[/b]
+
+To install your cloud directory as a filesystem, you first need davfs2 installed. 99% of the time, this will be included in your distributions repositories. In Debian
+
+[code]apt-get install davfs2[/code]
+
+If you want to let normal users mount the filesystem
+
+[code] dpkg-reconfigure davfs2[/code]
+
+and select "yes" at the prompt.
+
+Now you need to add any user you want to be able to mount dav to the davfs2 group
+
+[code]usermod -aG davfs2 <DesktopUser>[/code]
+
+[b]Note:[/b] on some systems the user group may be different, i.e. - "network"
+on Arch Linux. If in doubt, check the davfs documentation for your
+particular OS.
+
+Edit /etc/fstab
+
+[code]nano /etc/fstab[/code]
+
+ to include your cloud directory by adding
+
+[code]
+[baseurl]/cloud/ /mount/point davfs user,noauto,uid=<DesktopUser>,file_mode=600,dir_mode=700 0 1
+[/code]
+
+Where [baseurl] is the URL of your hub, /mount/point is the location you want to mount the cloud, and <DesktopUser> is the user you log in to one your computer. Note that if you are mounting as a normal user (not root) the mount point must be in your home directory.
+
+For example, if I wanted to mount my cloud to a directory called 'cloud' in my home directory, and my username was bob, my fstab would be
+
+[code][baseurl]/cloud/ /home/bob/cloud davfs user,noauto,uid=bob,file_mode=600,dir_mode=700 0 1[/code]
+
+Now, create the mount point.
+
+[code]mkdir /home/bob/cloud[/code]
+
+and also create a directory file to store your credentials
+
+[code]mkdir /home/bob/.davfs2[/code]
+
+Create a file called 'secrets'
+
+[code]nano /home/bob/.davfs2/secrets[/code]
+
+and add your cloud login credentials
+
+[code]
+[baseurl]/cloud <username> <password>
+[/code]
+
+Where <username> and <password> are the username and password [i]for your hub[/i].
+
+Don't let this file be writeable by anyone who doesn't need it with
+
+[code]chmod 600 /home/bob/.davfs2/secrets[/code]
+
+Finally, mount the drive.
+
+[code]mount [baseurl]/cloud[/code]
+
+You can now find your cloud at /home/bob/cloud and use it as though it were part of your local filesystem - even if the applications you are using have no dav support themselves.
+
+[b]Troubleshooting[/b]
+
+With some webservers and certain configurations, you may find davfs2 creating files with 0 bytes file size where other clients work just fine. This is generally caused by cache and locks. If you are affected by this issue, you need to edit your davfs2 configuration.
+
+[code]nano /etc/davfs2/davfs2.conf[/code]
+
+Your distribution will provide a sample configuration, and this file should already exist, however, most of it will be commented out with a # at the beginning of the line.
+
+First step is to remove locks.
+
+Edit the use_locks line so it reads [code]use_locks 0[/code].
+
+Unmount your file system, remount your file system, and try copying over a file from the command line. Note you should copy a new file, and not overwrite an old one for this test. Leave it a minute or two then do [code]ls -l -h[/code] and check the file size of your new file is still greater than 0 bytes. If it is, stop there, and do nothing else.
+
+If that still doesn't work, disable the cache. Note that this has a performance impact so should only be done if disabling locks didn't solve your problem. Edit the cache_size and set it to [code]cache_size 0[/code] and also set file_refresh to [code]file_refresh 0[/code]. Unmount your filesystem, remount your file system, and test it again.
+
+If it [i]still[/i] doesn't work, there is one more thing you can try. (This one is caused by a bug in older versions of dav2fs itself, so updating to a new version may also help). Enable weak etag dropping by setting [code]drop_weak_etags 1[/code]. Unmount and remount your filesystem to apply the changes.
+
+#include doc/macros/cloud_footer.bb;
+
diff --git a/sources/doc/dav_nautilus.bb b/sources/doc/dav_nautilus.bb
new file mode 100644
index 00000000..51663b6d
--- /dev/null
+++ b/sources/doc/dav_nautilus.bb
@@ -0,0 +1,9 @@
+[b]Using The Cloud - Nautilus[/b]
+
+1. Open a File browsing window (that's Nautilus)
+2. Select File > Connect to server from the menu
+3. Type davs://<domain_name>/cloud/<your_username> and click Connect
+4. You will be prompted for your username (same as above) and password
+5. Your personal DAV directory will be shown in the window
+
+#include doc/macros/cloud_footer.bb;
diff --git a/sources/doc/dav_nemo.bb b/sources/doc/dav_nemo.bb
new file mode 100644
index 00000000..2c88b078
--- /dev/null
+++ b/sources/doc/dav_nemo.bb
@@ -0,0 +1,19 @@
+[b]Using The Cloud - Nemo[/b]
+
+For (file browser) Nemo 1.8.2 under Linux Mint 15, Cinnamon 1.8.8. Nemo ist the standard file browser there.
+
+1st way
+type "davs://yourusername@friendicared.net/cloud" in the address bar
+
+2nd way
+Menu > file > connect to server
+Fill the dialog
+- Server: friendicared.net
+- Type: Secure WebDAV (https)
+- Folder: /cloud
+- Username: yourusername
+- Passwort: yourpasswort
+
+Once open you can set a bookmark.
+
+#include doc/macros/cloud_footer.bb;
diff --git a/sources/doc/dav_windows.bb b/sources/doc/dav_windows.bb
new file mode 100644
index 00000000..0eaffd4d
--- /dev/null
+++ b/sources/doc/dav_windows.bb
@@ -0,0 +1,11 @@
+[b]Using The Cloud - Windows Internal Client[/b]
+
+RedDav using Windows 7 graphical user interface wizard:
+1. Left-click the Start-button to open the start menu.
+2. Right-click the My computer icon to access its menu.
+3. Left-click Map network drive... to open the connection dialog wizard.
+4. Type #^[url=https://example.net/cloud/your_user_name]https://example.net/cloud/your_user_name[/url] in the textbox and click the Complete button where "example.net" is the URL of your hub.
+5. Type your Red account's user name. IMPORTANT - NO at-sign or domain name.
+6. Type your Red password
+
+#include doc/macros/cloud_footer.bb;
diff --git a/sources/doc/de/about.bb b/sources/doc/de/about.bb
new file mode 100644
index 00000000..313337f1
--- /dev/null
+++ b/sources/doc/de/about.bb
@@ -0,0 +1,23 @@
+[size=large][b]Was ist die Red-Matrix?[/b][/size]
+
+Die Red-Matrix ist ein dezentralisiertes Kommunikationsnetzwerk mit dem Ziel, Kommunikationsmöglichkeiten bereitzustellen, die Zensur umgehen, die Privatsphäre respektieren und somit frei sind von den Einschränkungen, die die heutigen kommerziellen Kommunikationsgiganten uns auferlegen. Diese stellen in erster Linie Spionagenetzwerke für zahlende Kunden aller Art zur Verfügung und monopolisieren und zentralisieren das ganze Internet – was ursprünglich eben gerade nicht unter den revolutionären Zielen war, die einst zum World Wide Web führten.
+
+Die Software der Red-Matrix ist frei, kostenlos und Open Source. Sie wurde entwickelt, um auf einem Raspberry Pi für € 30,– ebenso zu laufen wie auf den größten AMD- und Intel-Xeon-Multiprozessor-Servern. Sie kann für die Kommunikation zwischen einigen wenigen Einzelpersonen genutzt werden oder viele tausend Leute und mehr miteinander verbinden.
+
+Ein weiteres Ziel ist es, von Können und Ressourcen unabhängig zu sein. Die Red-Matrix ist für den einfachen Computernutzer ebenso leicht bedienbar wie für Systemadministratoren und Entwickler.
+
+Wie Du sie benutzt hängt davon ab, wie Du sie benutzen [i]willst.[/i]
+
+Die Red-Matrix ist in PHP geschrieben, dadurch ist es einfach, sie auf jedweder heutigen Hosting-Plattform zu installieren, inklusive Self-Hosting zu Hause, auf Shared Servern wie bei [url=https://uberspace.de/]Uberspace[/url], [url=http://mediatemple.com/]Media Temple[/url] und [url=http://www.dreamhost.com/]Dreamhost[/url], oder auf virtuellen und dedizierten Servern, wie es sie zum Beispiel bei [url=https://www.linode.com]Linode[/url], [url=http://greenqloud.com]GreenQloud[/url] oder [url=https://aws.amazon.com]Amazon AWS[/url] gibt.
+
+Mit anderen Worten, die Red-Matrix kann auf jeder Plattform laufen, die einen Web-Server, eine MySQL-kompatible Datenbank und PHP mitbringt.
+
+Dabei bietet Red einige einzigartige Leckerbissen:
+
+[b]Ein-Klick-Identifikation:[/b] Du kannst auf andere Server in der Red-Matrix zugreifen, indem Du einfach auf einen Link dorthin klickst. Die Authentifizierung wird ganz einfach automatisch hinter den Kulissen durchgeführt. Vergiss viele verschiedene Usernamen für verschiedene Seiten und die Passwörter dazu – das tut alles die Matrix für Dich.
+
+[b]Klone:[/b] Du kannst Deine Online-Identität (oder, wie wir sagen, einen Kanal) klonen. Sie ist nicht mehr länger an einen bestimmten Server, eine Domain oder eine IP-Adresse gebunden. Importiere sie einfach auf einem anderen Red-Server (oder Red-Hub) – direkt online oder mit Hilfe eines vorher generierten Exports. Wenn Dein primärer Hub plötzlich nicht mehr online ist, kein Problem, Deine Kontakte, Posts* und Nachrichten* sind automagisch weiterhin unter Deiner geklonten Identität verfügbar und zugreifbar. [i](*: nur Posts und Nachrichten, die nach dem Moment des Klonens erstellt wurden)[/i]
+
+[b]Privatsphäre:[/b] Red-Identitäten (Zot-IDs) können gelöscht, gesichert/heruntergeladen und geklont werden. Du hast volle Kontrolle über Deine Daten. Wenn Du Dich entscheidest, all Deine Daten und Deine Zot-ID zu löschen, musst Du nur auf einen Link klicken, und sie werden sofort von dem Server gelöscht. Keine Fragen, keine Umstände.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/de/channels.bb b/sources/doc/de/channels.bb
new file mode 100644
index 00000000..1c963fc0
--- /dev/null
+++ b/sources/doc/de/channels.bb
@@ -0,0 +1,26 @@
+[size=large][b]Kanäle[/b][/size]
+
+Kanäle sind Sammlungen von Inhalten, die an einem Ort gespeichert werden. Ein Kanal kann alles mögliche repräsentieren. Zum Beispiel Dich, eine Website, ein Forum oder ein Fotoalbum. Normalerweise wird Dein erster Kanal Dich selbst repräsentieren.
+
+Die wichtigsten Funktionen für einen Kanal, der einen selbst repräsentiert, sind:
+
+[ul][*]Sichere und private, spamfreie Kommunikation
+[*]Identifikation und automatisches Einloggen im gesamten Red-Matrix-Netzwerk
+[*]Datenschutzeinstellungen und Zugriffsberechtigungen, die im gesamten Netzwerk gültig sind
+[*]Verzeichnisdienste (ähnlich einem Telefonbuch)[/ul]
+
+Kurz gesagt, ein Kanal der Dich repräsentiert ist sozusagen „Ich im Internet“.
+
+Du musst Deinen ersten Kanal erstellen, während Du Dich anmeldest. Du kannst auch weitere Kanäle erstellen und zwischen ihnen wechseln, indem Du auf „Kanal-Manager“ im Menü unter Deinem Profilbild klickst.
+
+Du wirst nach einem Kanalnamen und einem kurzen Spitznamen gefragt. Für einen Kanal, der Dich repräsentiert, ist es eine gute Idee, hier Deinen Realnamen anzugeben, damit Deine Freunde Dich finden und sich mit Dir verbinden können. Der Spitzname wird genutzt, um Deinen „Webbie“ zu erstellen. Das ist so etwas wie ein Username und sieht aus wie eine E-Mail-Adresse, zum Beispiel spitzname@red-hub.de. Überlege ein bisschen, was Du als Spitzname nutzen willst. Stell Dir vor, Du wirst nach Deinem Webbie gefragt und musst Deinem Bekannten dann buchstabieren, dass Dein Webbie „llamas.sind-cool_274@example.com“ ist. „llamassindcool@exmaple.com“ wäre da viel einfacher gewesen.
+
+Nachdem Du Deinen Kanal erstellt hast, wirst Du zu den Einstellungen weitergeleitet. Hier kannst Du Deinen Kanal einrichten und die Standard-Berechtigungen setzen.
+
+Nachdem Du auch das getan hast, kannst Du Deinen Kanal verwenden. Unter der Addresse https://example.com/channel/spitzname [observer=1]( [observer.url] )[/observer] findest Du Deinen Kanal. Hier werden Deine letzten Aktivitäten gezeigt, die neuesten oben. Wenn Du etwas in die Textbox schreibst, in der „Teilen“ steht, wird der neue Eintrag ganz oben in Deinem Kanal auftauchen. Du findest hier auch Links zu den anderen Kommunikationsbereichen Deines Kanals. Der „Über“-Reiter enthält Dein Profil, der „Fotos“-Reiter Deine Fotoalben, und der Veranstaltungskalender enthält Termine und Veranstaltungen, die Du und Deine Kontakte geteilt haben.
+
+Die „Matrix“-Seite enthält alle neuen Beiträge aus der gesamten $Projectname, wieder die neuesten oben. Was genau zu sehen ist ist abhängig von den Zugriffsrechten. Falls die Zugriffsrechte Deines Kanals so eingestellt sind, dass jeder Beiträge in Deinen Stream stellen kann, wirst du auch Beiträge von Dir völlig unbekannten Personen hier sehen. Am anderen Ende der Skala kannst Du die Berechtigungen aber auch so einstellen, dass du nur die Beiträge deiner Freunde oder gar nur Deine eigenen siehst.
+
+Wie zu Anfang erwähnt sind viele Arten von Kanälen möglich, diese unterscheiden sich hauptsächlich durch die Berechtigungen. Das Anlegen dieser Kanäle unterscheidet sich dagegen nicht. Beispiel: Um einen Kanal zum Austausch von Dokumenten zu erstellen, wirst du vermutlich die Berechtigung „Kann in meinen öffentlichen Dateiordner schreiben“ freizügiger einstellen. Für weitere Informationen sieh bitte in der Hilfe unter Zugriffsrechte nach.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/de/features.bb b/sources/doc/de/features.bb
new file mode 100644
index 00000000..6bee360e
--- /dev/null
+++ b/sources/doc/de/features.bb
@@ -0,0 +1,186 @@
+[size=large][b]Features der $Projectname[/b][/size]
+
+Die $Projectname ist ein Allzweck-Kommunikationsnetzwerk mit einigen einzigartigen Features. Sie wurde für eine große Bandbreite von Nutzern entwickelt, von Nutzern sozialer Netzwerke über technisch nicht interessierte Blogger bis hin zu PHP-Experten und erfahrenen Systemadministratoren.
+
+Diese Seite listet einige der Kern-Features von Red auf, die in der offiziellen Distribution enthalten sind. Wie immer bei freier Open-Source-Software sind den Möglichkeiten keine Grenzen gesetzt. Beliebige Erweiterungen, Addons, Themes und Konfigurationen sind möglich.
+
+[h2]Entwickelt für Privatsphäre und Freiheit[/h2]
+
+Eines der Design-Ziele von Red ist einfache Kommunikations über das Web, ohne die Privatsphäre zu vernachlässigen, wenn die Nutzer das Wünschen. Um dieses Ziel zu erreichen, verfügt Red über einige Features, die beliebige Stufen des Privatsphäre-Schutzes ermöglichen:
+
+[b]Beziehungs-Tool[/b]
+
+Wenn Du in der $Projectname einen Kontakt hinzufügst (und das Beziehungs-Tool aktiviert hast), hast Du die Möglichkeit, einen „Grad der Freundschaft“ zu bestimmen. Bespiel: Wenn Du ein Blog eines Bekannten hinzufügst, könntest Du ihm den Freundschaftsgrad „Bekannte“ (Acquaintances) geben.
+
+
+[img]https://friendicared.net/photo/b07b0262e3146325508b81a9d1ae4a1e-0.png[/img]
+
+Wenn Du aber den privaten Kanal eines Freundes hinzufügst, wäre der Freundschaftsgrad „Freunde“ vermutlich passender.
+
+Wenn Du allen Kontakten solche Freundschaftsgrade zugeordnet hast, kannst Du mit dem Beziehungs-Tool, das (sofern aktiviert) oben auf Deiner Matrix-Seite erscheint, bestimmen, welche Inhalte Du sehen willst. Indem Du die Schieberegler so einstellst, dass der linke auf „Ich“ und der rechte auf „Freunde“ steht, kannst Du dafür sorgen, dass nur Inhalte von Kontakten angezeigt werden, deren Freundschaftsgrad sich irgendwo im Bereich zwischen „Ich“, „Beste Freunde“ und „Freunde“ bewegt. Alle anderen Kontakte, zum Beispiel solche mit einem Freundschaftsgrad in der Nähe von „Bekannte“, werden nicht angezeigt.
+
+Das Beziehungs-Tool erlaubt blitzschnelles Filtern von großen Mengen Inhalt, gruppiert nach Freundschaftsgrad.
+
+[b]Zugriffsrechte[/b]
+
+Wenn Du Inhalte mit anderen teilst, hast Du die Option, den Zugriff darauf einzuschränken. Wenn Du auf das Schloss unterhalb des Beitrags-Editors klickst, kannst Du auswählen, wer diesen Beitrag sehen darf, indem Du einfach auf die Namen klickst.
+
+Diese Nachricht kann dann nur vom Absender und den eingestellten Empfängern betrachtet werden. Mit anderen Worten, sie erscheint nicht öffentlich auf einer Pinnwand.
+
+Solche Zugriffsrechte gibt es bei Beiträgen, Fotos, Terminen, Webseiten, Chat-Räumen und Dateien.
+
+[b]Ein Passwort für alle $Projectname-Server (Single Sign-on)[/b]
+
+Zugriffsrechte funktionieren in der gesamten $Projectname mit allen Kanälen. Die meisten Links, die innerhalb der $Projectname verlinken, enthalten deine Identität (zid), so dass der Zielserver Dich direkt anmelden kann. Du kannst Dich aber auch so auf jedem $Projectname-Server mit Deinem $Projectname-Identität anmelden und erhältst dann Zugriff auf die Inhalte, die für Dich freigegeben sind.
+
+Du loggst Dich nur einmal auf Deinem Heimatserver ein. Ab dann funktioniert die Authentifizierung gegenüber anderen $Projectname-Servern „magisch“ von selbst.
+
+[b]Dateiablage (Cloud) mit WebDAV-Zugriff[/b]
+
+Du kannst in Deinem persönlichen Speicherbereich Dateien hochladen und ihn sogar als Verzeichnis von Deinem lokalen Betriebssystem anzeigen lassen (via WebDAV). Die Dateien können über Zugriffsrechte bestimmten $Projectname-Mitgliedern (und den Mitgliedern mancher anderer Netze) zugänglich gemacht oder auch komplett öffentlich zur Verfügung gestellt werden.
+
+[b]Fotoalben[/b]
+
+Stelle Deine Fotos online in Alben zur Verfügung. Auch hier kann der Zugriff über die Zugriffsrechte eingeschränkt werden.
+
+[b]Terminkalender[/b]
+
+Im eingebauten Terminkalender kannst Du Termine erstellen und verwalten. Auch hier greifen die Zugriffsrechte für andere. Termine können im vcalendar/iCal-Format exportiert und mit anderen geteilt werden. Wenn Deine Kontakte ihren Geburtstag in ihr Profil eingetragen haben, werden diese Geburtstage automatisch zu Deinem Kalender hinzugefügt – mit entsprechender Anpassung der Zeitzone, so dass Du nie zu früh oder zu spät gratulierst.
+
+[b]Chat-Räume[/b]
+
+Du kannst Chaträume erstellen und über die Zugriffsrechte nur bestimmten Nutzern öffnen. Die Nachrichten sind sicherer verschlüsselt als es normalerweise bei Jabber/XMPP, IRC und anderen Instant Messengern üblich ist. Über Plugins ist es aber auch möglich, andere IM-Dienste aus der $Projectname heraus zu nutzen.
+
+[b]Erstellen von Webseiten[/b]
+
+In der $Projectname gibt es Werkzeuge für „Content Management“, mit denen Du einfache Webseiten erstellen kannst, aber auch komplexe Layouts, Menüs, Blöcke und Widgets. Auch hier greifen die Zugriffsrechte, so dass die entstandenen Seiten nur von denen betrachtet werden können, denen Du das Recht dazu eingeräumt hast.
+
+[b]Apps[/b]
+
+$Projectname-Mitglieder könnnen Apps erstellen und verteilen. Anders als bei anderen Systemen, bei denen man an den System-Anbieter gebunden ist, werden diese Apps komplett vom App-Anbieter kontrolliert, der auf Wunsch seine eigene Zugriffskontrolle und ein Bezahlsystem einbauen kann. Die meisten Apps in der $Projectname sind kostenlos. Sie sind sehr einfach und ohne große Programmierkenntnisse zu erstellen.
+
+[b]Layout[/b]
+
+Das Seiten-Layout basiert auf eine Beschreibungssprache namens Comanche. Die $Projectname ist selbst in Comanche-Layouts verfasst, die man verändern kann. Dadurch ist eine sehr starke Anpassung an die eigenen Bedürfnisse möglich, wie man sie so in Multi-User-Umgebungen normalerweise nicht findet.
+
+[b]Lesezeichen[/b]
+
+Du kannst Lesezeichen teilen, speichern und verwalten, direkt aus den Unterhaltungen mit anderen heraus.
+
+[b]Verschlüsselung privater Nachrichten[/b]
+
+Nachrichten mit eingeschränktem Empfängerkreis werden mit einem symmetrischen 256-bit-AES-CBC-Schlüssel verschlüsselt, der seinerseits mit Public-Key-Kryptografie auf Basis von 4096-bittigen RSA-Schlüsseln geschützt (nochmal verschlüsselt) wird, die mit dem sendenden Kanal verbunden sind. Diese Nachrichten werden auch auf anderen Red-Servern verschlüsselt gespeichert.
+
+Jeder Red-Kanal hat seinen eigenes 4096-bit-RSA-Schlüsselpaar, das erzeugt wird, wenn der Kanal erstellt wird.
+
+Zusätzlich können Nachrichten mit Ende-zu-Ende-Verschlüsselung versehen werden, so dass weder $Projectname-Server-Administratoren noch ISPs irgendetwas mitlesen können, solange sie nicht über das Passwort verfügen.
+
+Komplett öffentliche Nachrichten werden weder in der Datenbank noch bei der Übertragung verschlüsselt (abgesehen ggfs. von SSL).
+
+Private Nachrichten können gelöscht (zurückgezogen) werden, aber es kann natürlich nicht garantiert werden, dass der Empfänger sie nicht schon gelesen hat.
+
+Alle Nachrichten können mit einem „Verfallsdatum“ versehen werden. Zu diesem Zeitpunkt werden sie dann von den Servern der Empfänger gelöscht.
+
+[b]Verbindung zu anderen Diensten[/b]
+
+Neben Plugins, die das „crossposten“ zu diversen anderen Netzwerk erlauben, wird der Import von RSS/Atom-Feeds nativ unterstützt, auch, um mit diesen Inhalten spezielle Kanäle zu erstellen. Außerdem kann über das Diaspora-Protokoll mit Kontakten in den Netzwerken Friendica und Diaspora kommuniziert werden. Diese Unterstützung ist als experimentell eingestuft, da diese Netzwerke nicht die gleichen Möglichkeiten wie die $Projectname in Sachen Privatsphäre und Verschlüsselung bieten, so dass Kommunikation mit ihnen zu Privatsphäreproblemen führen könnte.
+
+Weiterhin wird OpenID auf experimenteller Ebene unterstützt und kann bei den Zugriffsrechten genutzt werden, um Inhalte für per OpenID authentifizierte Nutzer freizugeben. An dieser Funktion wird noch gearbeitet.
+
+Die Inhalte von Kanälen können als Quellen für andere Kanäle dienen (wenn der Kanalinhaber das erlaubt), so dass Themen-Kanäle mit den Inhalten von zwei oder mehr Kanälen erstellt werden können.
+
+[b]Sammlungen[/b]
+
+„Sammlungen“ sind unsere Implementation von Privatsphäregruppen, ähnlich den „Kreisen“ bei Google+ und den „Aspekten“ bei Diaspora. Sammlungen können zur Filterung der angezeigten Nachrichten genutzt werden (nur Threads anzeigen, die von einem Mitglied dieser Sammlung gestartet wurden), aber auch zum Setzen von Zugriffsrechten.
+
+[b]Verzeichnisdienste[/b]
+
+Wir stellen einfachen Zugriff auf ein Mitgliederverzeichnis zur Verfügung, samt einer dezentralen Möglichkeit, sich neue Kontakte basierend auf den eigenen vorschlagen zu lassen. Die Verzeichnis-Server sind normale $Projectname-Server, bei denen der Administrator sich entschieden hat, sie auch als Verzeichnis agieren zu lassen. Das benötigt mehr Ressourcen als eine normale $Projectname-Installation, deshalb ist das nicht voreingestellt. Die Verzeichnis-Server synchronisieren sich miteinander, so dass (abgesehen von einer gewissen Verzögerung bis zur nächsten Synchronisation) all Verzeichnis-Server aktuelle Informationen über das gesamte Netzwerk bereitstellen können.
+
+[b]TLS/SSL[/b]
+
+Red-Server, die TLS/SSL benutzen, verschlüsseln ihre Kommunikation vom Server zum Nutzer mit SSL. Nach den aktuellen Enthüllungen über das Umgehen von Verschlüsselung durch NSA, GHCQ und andere Dienste, sollte man jedoch nicht mehr davon ausgehen, dass diese Verbindungen nicht mitgelesen werden können.
+
+[b]Kanal-Einstellungen[/b]
+
+Wenn ein Kanal erstellt wird, muss eine bestimmte Zugriffsrechte-Kategorie (z.B. öffentliches Forum oder privater Kanal für soziales Netzwerken) ausgewählt werden, die dafür sorgt, dass sinnvolle Privatsphäre-Einstellungen für diese Art von Kanal ausgewählt werden.
+
+Wenn Du die Experten-Kategorie wählst, kannst Du detaillierte Zugriffseinstellungen für verschiedenste Aspekte der Kommunikation festlegen. Unter den „Sicherheits- und Privatsphäre-Einstellungen“ kann für jeden Punkt auf der linken Seite eine von 7-8 möglichen Optionen aus dem Menü gewählt werden. Daneben gibt es diverse weitere Einstellmöglichkeiten zum Thema Privatsphäre.
+
+[img]https://friendicared.net/photo/0f5be8da282858edd645b0a1a6626491.png[/img]
+
+Die Optionen für die einzelnen Punkte (z.B., wer Deine normalen Beiträge sehen kann) sind:
+[ul][*]Niemand außer Du selbst
+[*]Nur die, denen Du es explizit erlaubst
+[*]Angenommene Verbindungen
+[*]Beliebige Verbindungen
+[*]Jeder auf diesem Website
+[*]Alle Red-Nutzer
+[*]Jeder authentifizierte
+[*]Jeder im Internet[/ul]
+
+[b]Private und öffentliche Foren[/b]
+
+Foren sind Kanäle, in denen mehrere Nutzer als Autoren fungieren können; eine Nachricht eines entsprechend berechtigten Nutzers an das Forum wird an alle Foren-Mitglieder verteilt. Es gibt momentan zwei Arten, um auf diese Weise an ein Forum zu posten: 1) Direktes Posten auf der Kanal-Seite des Forums („wall-to-wall post“) oder 2) über @mention-Tags. Jeder kann Foren erstellen, und sie können für beliebige Zwecke genutzt werden. Das Kanal-Verzeichnis ermöglicht es, direkt nach öffentlichen Foren zu suchen. Private Foren können meist nur von den Mitgliedern beschickt und gelesen werden.
+
+[b]Klone[/b]
+
+Konten in der $Projectname werden auch als [i]nomadische Identitäten[/i] bezeichnet (eine ausführliche Erklärung dazu gibt es unter [url=[baseurl]/help/what_is_zot]What is Zot?[/url]). Nomadisch, weil bei anderen Diensten die Identität eines Nutzers an den Server oder die Plattform gebunden ist, auf der er ursprünglich erstellt wurde. Ein Facebook- oder Gmail-Konto ist and diese Dienste gekettet. Er funktioniert nicht ohne Facebook.com bzw. Gmail.com.
+
+Bei Red ist das anders. Sagen wir, Du hast eine Red-Indentität namens tina@redhub.com. Die kannst Du auf einen anderen Server klonen, mit dem gleichen oder einem anderen Namen, zum Beispiel lebtEwig@matrixserver.info.
+
+Beide Kanäle sind jetzt miteinander synchronisiert, das heißt, dass alle Kontakte und Einstellungen auf dem Klon immer die gleichen sind wie auf dem ursprünglichen Kanal. Es ist egal, ob Du eine Nachricht von dort aus oder vom Klon aus schickst. Alle Nachrichten sind in beiden Klonen vorhanden.
+
+Das ist ein ziemlich revolutionäres Feature, wenn man sich einige Szenarien dazu ansieht:
+
+[ul][*]Was passiert, wenn ein Server, auf dem sich Deine Identität befindet, plötzlich offline ist? Ohne Klone ist der Nutzer nicht in der Lage zu kommunzieren, bis der Server wieder online ist. Mit Klonen loggst Du Dich einfach bei Deinem geklonten Kanal ein und lebst glücklich bis an Dein Ende.
+[*]Der Administrator Deines Red-Servers kann es sich nicht länger leisten, seinen für alle kostenlosen Server zu bezahlen. Er gibt bekannt, dass der Server in zwei Wochen vom Netz gehen wird. Zeit genug, um Deine Red-Kanäle auf andere Server zu klonen und somit Verbindungen und Freunde zu behalten.
+[*]Was, wenn Dein Kanal staatlicher Zensur unterliegt? Dein Server-Admin wird gezwungen, Dein Konto und alle damit verbundenen Kanäle und Daten zu löschen. Durch Klone bietet die $Projectname Zensur-Resistenz. Wenn Du willst, kannst Du hunderte von Klonen haben, alle mit unterschiedlichen Namen und auf unterschiedlichen Servern überall im Internet.[/ul]
+
+Red bietet interessante, neue Möglichkeiten in Bezug auf die Privatsphäre. Mehr dazu unter „Tipps und Tricks zur privaten Kommunikation“.
+
+Klone unterliegen einigen Restriktionen. Eine vollständige Erklärung zum Klonen von Identitäten gibt es unter „Klone“.
+
+[b]Mehrere Profile[/b]
+
+Jeder Kanal kann beliebig viele Profile mit unterschiedlichen Informationen definieren. Dann kannst Du einstellen, wer von Deinen Kontakten welches Profil zu sehen bekommt. Das Default-Profil ist für alle anderen zu sehen und kann so auf nur wenige Informationen beschränkt werden, während Freunde und Bekannte mehr zu sehen bekommen.
+
+[b]Kanal-Backups[/b]
+
+In Red gibt es ein einfaches Ein-Klick-Backup, mit dem Du ein komplettes Backup Deiner Kanal-Einstellungen und Verbindungen herunterladen kannst.
+
+Solche Backups sind ein Weg, um Klone zu erstellen, und können genutzt werden, um einen Kanal wiederherzustellen.
+
+[b]Löschen von Konten[/b]
+
+Konten und Kanäle können sofort gelöscht werden, indem Du einfach auf einen Link klickst. Das wars. Alle damit verbundenen Inhalte werden aus der Matrix gelöscht (inklusiver aller Beiträge und sonstiger Inhalte, die von dem gelöschten Konto/Kanal erzeugt wurden). Je nach Anzahl Deiner Verbindungen kann es etwas dauern, bis die Inhalte auch von allen Servern Deiner Kontakte gelöscht werden, aber die Löschung wird so schnell wie sinnvoll möglich durchgeführt.
+
+[h2]Erstellen von Inhalten[/h2]
+
+[b]Beiträge schreiben[/b]
+
+Red unterstützt diverse verschiedene Wege, um Inhalte mit Auszeichnung (z.B. fett, kursiv, farbig etc.) zu erstellen. Voreinstellung ist die $Projectname-Variante von BBCode (wie in vielen Web-Foren) mit einigen Ergänzungen, die nur hier funktionieren. Du kannst auch Markdown benutzen, wenn Dir das leichter fällt. Bis vor kurzem konnte auch ein grafischer Editor eingesetzt werden, der jedoch große Probleme aufwies und deshalb entfernt wurde. Wir suchen gerade nach einer Alternative.
+
+Webseiten können neben BBCode und Markdown auch in HTML und Plain Text erstellt werden.
+
+[b]Inhalte löschen[/b]
+
+Alle Inhalte in der $Projectname bleiben unter der Kontrolle des Mitglieds (bzw. Kanals), der sie ursprünglich erstellt hat. Alle Beiträge können jederzeit gelöscht werden, egal, ob sie auf dem Heimat-Server des Nutzers oder auf einem anderen Server erstellt wurden, an dem der Nutzer via Zot angemeldet war.
+
+[b]Medien[/b]
+
+Genau wie jedes andere Blog-System, soziale Netzwerk oder Mikro-Blogging-Dienst unterstützt Red das Hochladen von Dateien, das Einbetten von Bildern und Videos und das Verlinken von Seiten.
+
+[b]Vorschau/Editieren[/b]
+
+Vor dem Absenden kann eine Vorschau von Beiträgen betrachtet werden. Außerdem können Beiträge auch nach dem Absenden noch verändert werden.
+
+[b]$Projectname erweitern[/b]
+
+Die $Projectname kann auf vielerlei Art erweitert werden: Durch Server-Anpassung, persönliche Anpassung, setzen von Optionen, Themes und Addons/Plugins.
+
+[b]API[/b]
+
+Es existiert eine API, die von beliebigen Programmen/Apps und Diensten genutzt werden kann. Sie basiert auf der ursprünglichen Twitter-API (für die es hunderte von Tools und Apps gibt). Sie wird aktuell erweitert, um Zugriff auf Möglichkeiten zu gewähren, die es nur in der $Projectname gibt. Authentifikation erfolgt über Login/Passwort oder OAuth. Eine Client-Registrierung für OAuth-Applikationen ist möglich.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/de/main.bb b/sources/doc/de/main.bb
new file mode 100644
index 00000000..f310d0ab
--- /dev/null
+++ b/sources/doc/de/main.bb
@@ -0,0 +1,86 @@
+[img][baseurl]/assets/hashlogo.png[/img]
+
+[zrl=[baseurl]/help/about]Was ist die RedMatrix?[/zrl]
+Die RedMatrix ist eine dezentrale Kommunikations- und Publishing-Plattform. Sie ermöglicht Dir die volle Kontrolle über all Deine Kommunikation mit Hilfe von automatischer Verschlüsselung und detaillierter Zugriffskontrolle. Du, und [i]nur[/i] Du, entscheidest, wer Deine Beiträge sehen darf.
+
+[zrl=[baseurl]/help/features]Features der RedMatrix[/zrl]
+Die RedMatrix funktioniert schon heute als ein globales verteiltes Netzwerk und beweist täglich ihre Vielseitigkeit und Skalierbarkeit auf kleinen Privatservern wie auch auf riesigen Sites.
+Kommunikationsplattformen für Familien, verteilte Online-Communities, Support-Foren, Blogs und Homepages. Oder auch professionelle Inhalte-Anbieter mit kommerziellen Premium-Kanälen und eingeschränktem Zugriff – was immer Du willst, die RedMatrix unterstützt Dich in Deinem kreativen Schaffen.
+
+[zrl=[baseurl]/help/what_is_zot]Got Zot? Hast Du schon Zot? Wenn nicht wird es Zeit.[/zrl]
+Zot ist das großartige neue Kommunikationsprotokoll, das extra für die RedMatrix entwickelt wurde. Als Mitglied bist Du dank „Nomadischer Identität“ nicht länger an einen einzigen Server oder Anbieter gebunden. Ziehe einfach auf einen anderen Server um und behalte dabei alle Deine Kontakte, oder klone Deinen Kanal und lasse ihn auf mehreren Servern gleichzeitig laufen – sollte einer davon plötzlich geschlossen werden, ist das kein Problem für Dich. Und bist Du erst Teil der RedMatrix, musst Du Dich nie wieder mehrfach anmelden, selbst wenn Du Seiten auf einem andere Red-Server betrachtest. Zot ist, was die RedMatrix besonders macht.
+
+[h3]Erste Schritte[/h3]
+[zrl=[baseurl]/help/Privacy]Datenschutz[/zrl]
+[zrl=[baseurl]/help/registration]Ein Konto registrieren[/zrl]
+[zrl=[baseurl]/help/accounts_profiles_channels_basics]Du in der RedMatrix: Konten, Profile und Kanäle kurz erklärt[/zrl]
+[zrl=[baseurl]/help/profiles]Profile[/zrl]
+[zrl=[baseurl]/help/channels]Kanäle[/zrl]
+[zrl=[baseurl]/help/roles]Zugriffsrechte-Kategorien und Kanaltypen[/zrl]
+[zrl=[baseurl]/help/first-post]Dein erster Beitrag[/zrl]
+[zrl=[baseurl]/help/connecting_to_channels]Sich mit anderen Kanälen verbinden[/zrl]
+[zrl=[baseurl]/help/permissions]Zugriffsrechte und Verschlüsselung: Du hast alles unter Kontrolle[/zrl]
+[zrl=[baseurl]/help/cloud]Cloud-Speicher[/zrl]
+[zrl=[baseurl]/help/remove_account]Einen Kanal oder das ganze Konto löschen[/zrl]
+
+[h3]Hilfe für $Projectname-Mitglieder[/h3]
+[zrl=[baseurl]/help/tags_and_mentions]Tags und Erwähnungen[/zrl]
+[zrl=[baseurl]/help/webpages]Webseiten[/zrl]
+[zrl=[baseurl]/help/bbcode]BBcode-Referenz für Posts und Kommentare[/zrl]
+[zrl=[baseurl]/help/checking_account_quota_usage]Überprüfung der Kontenlimits[/zrl]
+[zrl=[baseurl]/help/cloud_desktop_clients]Desktop-Anwendungen und die Cloud[/zrl]
+[zrl=[baseurl]/help/AdvancedSearch]Fortgeschrittene Suche im Kanalverzeichnis[/zrl]
+[zrl=[baseurl]/help/addons]Hilfe zu Addons[/zrl]
+[zrl=[baseurl]/help/diaspora_compat]Kompatibilität zum Diaspora-Protokoll (zur Kommunikation mit Kontakten aus Diaspora und Friendica)[/zrl]
+[zrl=[baseurl]/help/faq_members]FAQ für Mitglieder[/zrl]
+
+[h3]Hilfe für Administratoren[/h3]
+[zrl=[baseurl]/help/install]Installation[/zrl]
+[zrl=[baseurl]/help/red2pi]Red auf einem Raspberry Pi installieren[/zrl]
+[zrl=[baseurl]/help/troubleshooting]Troubleshooting-Tipps[/zrl]
+[zrl=[baseurl]/help/hidden_configs]Versteckte Konfigurations-Optionen[/zrl]
+[zrl=[baseurl]/help/faq_admins]FAQ für Admins[/zrl]
+[zrl=[baseurl]/help/service_classes]Serviceklassen[/zrl]
+
+[h3]Technische Dokumentation[/h3]
+[zrl=[baseurl]/help/history]Die Geschichte von $Projectname[/zrl]
+[zrl=[baseurl]/help/Zot---A-High-Level-Overview]Zot – ein grober Überblick[/zrl]
+[zrl=[baseurl]/help/zot]Eine Einführung ins Zot-Protokoll[/zrl]
+[zrl=[baseurl]/help/zot_structures]Zot-Strukturen[/zrl]
+[zrl=[baseurl]/help/comanche]Seitenbeschreibung in Comanche[/zrl]
+[zrl=[baseurl]/help/Creating-Templates]Vorlagen erstellen mit Comanche[/zrl]
+[zrl=[baseurl]/help/Widgets]Widgets[/zrl]
+[zrl=[baseurl]/help/plugins]Plugins[/zrl]
+[zrl=[baseurl]/help/doco]Selbst Dokumentation beisteuern[/zrl]
+[zrl=[baseurl]/help/DerivedTheme1]Einen Theme basierend auf einem anderen erstellen[/zrl]
+[zrl=[baseurl]/help/schema_development]Schemata[/zrl]
+[zrl=[baseurl]/help/Translations]Ãœbersetzungen[/zrl]
+[zrl=[baseurl]/help/developers]Entwickler[/zrl]
+[zrl=[baseurl]/help/intro_for_developers]Einführung für Entwickler[/zrl]
+[zrl=[baseurl]/help/database]Datenbank-Schema[/zrl]
+[zrl=[baseurl]/help/api_functions]API-Funktionen[/zrl]
+[zrl=[baseurl]/help/api_posting]Mit der API einen Beitrag erstellen[/zrl]
+[zrl=[baseurl]/help/developer_function_primer]Ãœbersicht der wichtigsten Red-Funktionen[/zrl]
+[zrl=[baseurl]/doc/html/]Code-Referenz (mit doxygen generiert - setzt Cookies)[/zrl]
+[zrl=[baseurl]/help/to_do_doco]To-Do-Liste für das Projekt Red-Dokumentation[/zrl]
+[zrl=[baseurl]/help/to_do_code]To-Do-Liste für Entwickler[/zrl]
+[zrl=[baseurl]/help/roadmap]Roadmap für Version 3[/zrl]
+[zrl=[baseurl]/help/git_for_non_developers]Git für Nicht-Entwickler[/zrl]
+[zrl=[baseurl]/help/dev_beginner]Schritt-für-Schritt-Einführung für neue Entwickler[/zrl]
+
+[h3]Häufig gestellte Fragen für Entwickler[/h3]
+[zrl=[baseurl]/help/faq_developers]FAQ für Entwickler[/zrl]
+
+[h3]Externe Ressourcen[/h3]
+[zrl=[baseurl]/help/external-resource-links]Links zu externen Ressourcen[/zrl]
+[url=https://github.com/redmatrix/redmatrix]Haupt-Website[/url]
+[url=https://github.com/redmatrix/redmatrix-addons]Addons-Website[/url]
+[url=https://zothub.com/channel/one]Entwickler-Kanal[/url]
+[url=https://federated.social/channel/postgres]Postgres-spezifischer Admin-Support-Kanal[/url]
+
+[url=[baseurl]/help/credits]$Projectname Credits[/url]
+
+[h3]Ãœber diesen Red-Server[/h3]
+[zrl=[baseurl]/help/TermsOfService]Nutzungsbedingungen dieses Red-Servers[/zrl]
+[zrl=[baseurl]/siteinfo]Informationen zu diesem Server und der Red-Version[/zrl]
+[zrl=[baseurl]/siteinfo/json]Detaillierte technische Informationen zu diesem Server im JSON-Format[/zrl]
diff --git a/sources/doc/de/profiles.bb b/sources/doc/de/profiles.bb
new file mode 100644
index 00000000..262aeb6e
--- /dev/null
+++ b/sources/doc/de/profiles.bb
@@ -0,0 +1,40 @@
+[size=large][b]Profile[/b][/size]
+
+In Red kannst Du beliebig viele Profile anlegen. Du kannst mehrere Profile nutzen, um verschiedenen Kontakten und Profilbesuchern unterschiedliche Seiten Deiner Persönlichkeit zu zeigen. Das ist nicht das gleiche wie das Anlegen mehrerer [i]Kanäle.[/i]
+
+Mehrere Kanäle erlauben es, komplett voneinander getrennte Informationen zu verwalten. Du könntest zum Beispiel einen Kanal für Dich selbst anlegen, einen für Deinen Schwimmverein, einen für Dein Blog und so weiter und so fort.
+
+Ein Profil erlaubt es, unterschiedlichen Leuten unterschiedliche Informationen über einen Kanal zu präsentieren. Beispiel: In Deinem Standard-Profil, das alle Profilbesucher zu sehen bekommen, könnte nur Dein Vorname stehen, sonst keine weiteren Informationen. Freunde und Bekannte könnten Deinen kompletten Realnamen und Deine Postadresse zu sehen bekommen, und im Profil für Deinen engsten Freundeskreis könnten peinliche Hobbies und Trinkrekorde ihren Platz finden.
+
+Jeder Kanal hat ein Standard-Profil (öffentliches Profil), das vor niemandem versteckt werden kann (außer evtl. auf privaten Servern, die nicht mit der Matrix verbunden sind). Du kannst und solltest Dich in der Auswahl dessen, was Du im Standard-Profil von Dir preisgibst, stark einschränken.
+
+Trotzdem: Wenn Du willst, dass Freunde Dich finden können, macht es Sinn, folgende Informationen ins öffentliche Profil einzutragen:
+
+[ul][*] Deinen Realnamen oder zumindest einen Spitznamen, unter dem Dich jeder kennt
+[*] Ein Foto, das auch wirklich Dich zeigt
+[*] Deinen Wohnort, oder zumindest Land oder Bundesland[/ul]
+
+Wenn Du Leute kennenlernen möchtest, die ähnliche Interessen haben wie Du, nimm Dir einen Moment Zeit und füge einige Schlüsselwörter hinzu. Zum Beispiel „Musik, Linux, Fotografie“ oder was auch immer. Danach können andere dann im Verzeichnis suchen. Du kannst so viele Schlüsselwörter eingeben wie Du möchtest.
+
+Um alternative Profile zu erstellen, besuche zunächst die Seite [zrl=[baseurl]/settings/features]Einstellungen > Zusätzliche Funktionen[/zrl] und aktiviere dort „Mehrfachprofile“. Ohne diese Aktivierung hast Du nur ein Profil, nämlich Dein Standard-Profil.
+
+Klicke dann auf „Profile bearbeiten“ im Menü Deines Red-Servers. Dort kannst Du existierende Profile bearbeiten, Dein Profilfoto verändern, Dinge zu einem Profil hinzufügen oder ein neues Profil erstellen. Du kannst auch ein Profil „klonen“, wenn Du nur einige wenige Einträge ändern willst, ohne die ganzen Informationen noch einmal einzugeben. Klicke dazu auf das Profil, das Du klonen willst, und wähle dann „Dieses Profil klonen“.
+
+In der Liste Deiner Profile kannst Du auch bestimmen, wer ein bestimmtes Profil zu sehen bekommt. Klicke dazu auf „Sichtbarkeit bearbeiten“ neben dem Profil, um das es geht (gibt es nur bei Profilen, die nicht Dein Standard-Profil sind). Klicke dann auf die Bilder derjenigen Kontakte, die dieses Profil sehen sollen – sie sind dann oben zu sehen. Wenn Du oben auf ein Bild klickst, wird dieser Kontakt wieder aus der Gruppe derjenigen herausgenommen, die dieses Profil zu sehen bekommen.
+
+Hast Du einem Kontakt ein Profil zugeordnet, wird er immer dieses Profil sehen, wenn er sich Dein Profil ansieht. Besucht er Deinen Red-Server, ohne sich anzumelden, sieht er aber weiterhin Dein Standard-Profil.
+
+Auf der allgemeinen „Einstellungen“-Seite gibt es eine Einstellung, mit der Du festlegen kannst, ob Dein Standard-Profil in den Red-Verzeichnissen veröffentlicht werden soll.
+
+Wenn Du nicht möchtest, dass andere Dich finden können, ohne dass Du ihnen Deine Kanal-Adresse gibst, kannst Du so verhindern, dass Dein Profil veröffentlicht wird.
+
+[b]Schlüsselwörter und Verzeichnissuche[/b]
+
+Im Verzeichnis (Kanal-Anzeiger) kannst Du nach Leuten suchen, die ihre Profile veröffentlichen. Zum Beispiel, indem Du Namen oder Spitznamen eingibst. Aktuell werden nur das Namensfeld und die Schlüsselwörter durchsucht. Wenn Du Schlüsselwörter in Dein Standard-Profil einträgst, können Dich Leute mit ähnlichen Interessen finden. Sie werden außerdem bei den Kanal-Vorschlägen benutzt. Sie sind im Verzeichnis nicht direkt sichtbar, wohl aber auf Deiner Profil-Seite.
+
+Auf Deiner „Verbindungen“-Seite und im Verzeichnis (Kanal-Anzeiger) gibt es einen Link „Vorschläge“ bzw. „Kanal-Vorschläge“. Dort findest Du Kanäle, die gleiche oder ähnliche Schlüsselwörter im Profil haben wie Du. Je mehr Schlüsselwörter Du in Dein Standard-Profil einträgst, desto besser werden die Suchergebnisse. Sie sind nach Relevanz sortiert.
+
+Siehe auch:
+
+[zrl=[baseurl]/help/AdvancedSearch]Fortgeschrittene Suche[/zrl]
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/de/registration.bb b/sources/doc/de/registration.bb
new file mode 100644
index 00000000..ebd18735
--- /dev/null
+++ b/sources/doc/de/registration.bb
@@ -0,0 +1,36 @@
+[size=large][b]Registrieren[/b][/size]
+
+Nicht alle Server in der Red-Matrix erlauben jedem, sich zu registrieren. Wenn eine Registrierung möglich ist, erscheint unter dem Anmelde-Formular ein Link mit dem Titel „Registrieren“, der Dich zur Registrierungs-Seite des Servers führt. Auf manchen Servern wirst Du auf einen anderen Server weitergeleitet, der Registrierungen erlaubt. Da alle Red-Server miteinander verbunden sind, ist es egal, auf welchem Du Dich registrierst.
+
+[b]Deine E-Mail-Adresse[/b]
+
+Bitte gib eine funktionierende E-Mail-Adresse an. Sie wird [b]nie[/b] veröffentlicht. Sie wird benutzt, um Dein Konto zu aktivieren, und wenn Du willst, kannst Du Dir an diese Adresse Benachrichtigungen schicken lassen, wenn Du neue Nachrichten oder Beiträge erhalten hast. Sie wird außerdem benutzt, um vergessene Passwörter wiederherstellen zu können.
+
+[b]Passwort[/b]
+
+Gib ein Passwort Deiner Wahl ein und wiederhole es in der zweiten Box, um sicherzugehen, dass Du Dich nicht vertippt hast. Da die Red-Matrix dezentralisierten Identitäsnachweis beherrscht, kannst Du Dich mit Deinem Konto auf vielen anderen Webseiten anmelden.
+
+[b]Nutzungsbedingungen[/b]
+
+Klicke auf den Link, um die [zrl=[baseurl]/help/TermsOfService]Nutzungsbedingungen[/zrl] dieses Servers zu lesen. Wenn Du sie gelesen hast, setze den Haken im Registrierungsformular, um sie zu akzeptieren.
+
+[b]Registrieren[/b]
+
+Wenn Du alles ausgefüllt hast, klicke auf den „Registrieren“-Knopf. Bei manchen Servern muss der Administrator Deiner Registrierung erst noch zustimmen, bevor Du Dein Konto nutzen kannst. Falls das der Fall ist, wird Dir das entsprechend angezeigt. Du erhältst dann eine E-Mail, wenn die Registrierung vollendet wurde. (Sicherheitshalber auch Spam-Ordner überprüfen!)
+
+[b]Einen Kanal anlegen[/b]
+
+Als nächstes kommst Du direkt auf den „Kanal hinzufügen“-Bildschirm. Dein erster Kanal wird normalerweise der sein, der Dich selbst repräsentiert. Es ist also sinnvoll, Deinen Namen oder Dein Pseudonym als Kanal-Namen zu verwenden.
+
+Der Kanal-Name ist der Titel oder eine kurze Beschreibung des Kanals. Der „Spitzname“ ist so etwas wie ein Benutzername. Was Du hier eingibst wird Teil Deiner Kanal-Adresse, die Andere benutzen, um sich mit Dir zu verbinden, und die Du selbst benutzt, um Dich auf anderen Servern anzumelden. Die Kanal-Adresse sieht aus wie eine E-Mail-Adresse, zum Beispiel so: spitzname@deinserver.xyz
+
+Wenn Dein Kanal angelegt ist, geht es direkt weiter zu den Einstellungen. Dort kannst Du Zugriffsrechte setzen, Funktionen zu- oder abschalten und so weiter. Diese Punkte werden auf den entsprechenden Hilfeseiten erklärt.
+
+Siehe auch
+[zrl=[baseurl]/help/accounts_profiles_channels_basics]Grundlagen zu Identitäten in der $Projectname[/zrl]
+[zrl=[baseurl]/help/accounts]Konten[/zrl]
+[zrl=[baseurl]/help/profiles]Profile[/zrl]
+[zrl=[baseurl]/help/permissions]Zugriffsrechte[/zrl]
+[zrl=[baseurl]/help/remove_account]Konto löschen[/zrl]
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/dev-function-overview.md b/sources/doc/dev-function-overview.md
new file mode 100644
index 00000000..e228268d
--- /dev/null
+++ b/sources/doc/dev-function-overview.md
@@ -0,0 +1,51 @@
+Red development - some useful basic functions
+=============================================
+
+
+
+* get_account_id()
+
+Returns numeric account_id if authenticated or 0. It is possible to be authenticated and not connected to a channel.
+
+* local_channel()
+
+Returns authenticated numeric channel_id if authenticated and connected to a channel or 0. Sometimes referred to as $uid in the code.
+
+* remote_channel()
+
+Returns authenticated string hash of Red global identifier, if authenticated via remote auth, or an empty string.
+
+* get_app()
+
+Returns the global app structure ($a).
+
+* App::get_observer()
+
+(App:: is usually assigned to the global $a), so $a->get_observer() or get_app()->get_observer() - returns an xchan structure representing the current viewer if authenticated (locally or remotely).
+
+* get_config($family,$key), get_pconfig($uid,$family,$key)
+
+Returns the config setting for $family and $key or false if unset.
+
+* set_config($family,$key,$value), set_pconfig($uid,$family,$key,$value)
+
+Sets the value of config setting for $family and $key to $value. Returns $value. The config versions operate on system-wide settings. The pconfig versions get/set the values for a specific integer uid (channel_id).
+
+* dbesc()
+
+Always escape strings being used in DB queries. This function returns the escaped string. Integer DB parameters should all be proven integers by wrapping with intval()
+
+* q($sql,$var1...)
+
+Perform a DB query with the SQL statement $sql. printf style arguments %s and %d are replaced with variable arguments, which should each be appropriately dbesc() or intval(). SELECT queries return an array of results or false if SQL or DB error. Other queries return true if the command was successful or false if it wasn't.
+
+* t($string)
+
+Returns the translated variant of $string for the current language or $string (default 'en' language) if the language is unrecognised or a translated version of the string does not exist.
+
+* x($var), $x($array,$key)
+
+Shorthand test to see if variable $var is set and is not empty. Tests vary by type. Returns false if $var or $key is not set.
+If variable is set, returns 1 if has 'non-zero' value, otherwise returns 0. -- e.g. x('') or x(0) returns 0;
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/dev_beginner.bb b/sources/doc/dev_beginner.bb
new file mode 100644
index 00000000..72962571
--- /dev/null
+++ b/sources/doc/dev_beginner.bb
@@ -0,0 +1,419 @@
+[h2]You want to contribute code?[/h2]
+[b]...and don't know how to start to...[/b]
+[list]
+[*] debug the red#matrix (php on the webserver),
+[*] contribute code to the project,
+[*] optionally - do it all from inside a virtual machine
+[/list]
+This manual was tested for Debian (Wheezy) as virtual machine on Lubuntu (Ubuntu 14.0) as host.
+
+Content
+
+[toc]
+
+[h2]Install a Virtual Machine (KVM)[/h2]
+
+[url=https://wiki.debian.org/KVM]Here[/url] the installation guide for Linux Debian.
+The summary:
+[list=1]
+[*] install KVM
+[code]# apt-get install qemu-kvm libvirt-bin[/code]
+[*] add yourself to the group libvirt [code]# adduser libvirt[/code]
+[*] install gui to manage virtual machines [code]# apt-get install virt-manager[/code]
+[*] download an operating system to run inside the vm ([url=http://ftp.nl.debian.org/debian/dists/wheezy/main/installer-amd64/current/images/netboot/mini.iso]mini.iso[/url])
+[*] start the virt manager
+- create new virtual machine (click on icon)
+- choose your iso image (just downloaded) as installation source
+- optional: configure the new vm: ram, cpu's,...
+- start virtual machine > result: linux debian starts in a new window.
+[*] (optional) avoid network errors after restart of host os
+[code]# virsh net-start default
+# virsh net-autostart default[/code]
+[/list]
+
+
+[h2]Install Apache Webserver[/h2]
+
+Open a terminal and make yourself root
+[code]su -l[/code]
+
+Create the standard group for the Apache webserver
+[code]groupadd www-data[/code]
+might exist already
+
+[code]usermod -a -G www-data www-data[/code]
+
+Check if the system is really up to date
+[code]apt-get update
+apt-get upgrade[/code]
+
+Optional restart services after installation
+[code]reboot[/code]
+
+If you restarted, make yourself root
+[code]su -l[/code]
+
+Install Apache: [code]
+apt-get install apache2 apache2-doc apache2-utils[/code]
+
+Open webbrowser on PC and check [url=localhost]localhost[/url]
+Should show you a page like "It works"
+
+(Source [url=http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#]http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#[/url])
+
+
+[h2]Install PHP, MySQL, phpMyAdmin[/h2]
+
+[h3]PHP, MySQL[/h3]
+
+[code]su -l
+apt-get install libapache2-mod-php5 php5 php-pear php5-xcache php5-curl php5-mcrypt php5-xdebug
+apt-get install php5-mysql
+apt-get install mysql-server mysql-client[/code]
+enter and note the mysql passwort
+
+Optional since its already enabled during phpmyadmin setup
+[code]
+php5enmod mcrypt
+[/code]
+
+[h3]phpMyAdmin[/h3]
+
+Install php myadmin
+[code]apt-get install phpmyadmin[/code]
+
+Configuring phpmyadmin
+- Select apache2 (hint: use the tab key to select)
+- Configure database for phpmyadmin with dbconfig-common?: Choose Yes
+
+(Source #^[url=http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#]http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#[/url])
+
+[h3]Enable rewrite[/h3]
+
+The default installation of Apache2 comes with mod_rewrite installed. To check whether this is the case, verify the existence of /etc/apache2/mods-available/rewrite.load
+
+[code]
+root@debian /var/www $ nano /etc/apache2/mods-available/rewrite.load
+[/code]
+
+ (You should find the content: LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so)
+To enable and load mod_rewrite, do the rest of steps.
+Create a symbolic link in /etc/apache2/mods-enabled
+
+[code]
+cd /var/www
+root@debian /var/www $ a2enmod rewrite
+[/code]
+
+Then open up the following file, and replace every occurrence of "AllowOverride None" with "AllowOverride all".
+
+[code]
+root@debian /var/www $nano /etc/apache2/apache2.conf
+[/code]
+or
+[code]
+root@debian:/var# gedit /etc/apache2/sites-enabled/000-default
+[/code]
+
+Finally, restart Apache2.
+
+[code]
+root@debian /var/www $service apache2 restart
+[/code]
+
+[h3]Test installation[/h3]
+
+[code]cd /var/www[/code]
+
+create a php file to test the php installation[code]nano phpinfo.php[/code]
+
+Insert into the file:
+[code]
+
+[/code]
+(save CTRL+0, ENTER, CTRL+X)
+
+open webbrowser on PC and try #^[url=http://localhost/phpinfo.php]http://localhost/phpinfo.php[/url] (page shows infos on php)
+
+connect phpMyAdmin with MySQL database [code]nano /etc/apache2/apache2.conf
+[/code]
+- CTRL+V... to the end of the file
+- Insert at the end of the file: (save CTRL+0, ENTER, CTRL+X)[code]Include /etc/phpmyadmin/apache.conf[/code]
+
+restart apache
+[code]/etc/init.d/apache2 restart
+apt-get update
+apt-get upgrade
+reboot[/code]
+
+[b]phpMyAdmin[/b]
+
+open webbrowser on PC and try #^[url=http://localhost/phpmyadmin]http://localhost/phpmyadmin[/url]
+
+(Source #^[url=http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#]http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#[/url])
+
+[h3]Create an empty database... that is later used by the red#matrix[/h3]
+
+
+open webbrowser on PC and try #^[url=http://localhost/phpmyadmin]http://localhost/phpmyadmin[/url]
+
+Create an empty database, for example named "red".
+Create a database user, for example "red".
+Grant all rights for the user "red" to the database "red".
+
+Note the access details (hostname, username, password, database name).
+
+
+[h2]Fork the project on github[/h2]
+
+Please follow the instruction in the offiical [url=http://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project] documentation[/url] of git.
+It is a good idea to read the whole manual! Git is different to other version control systems in many ways.
+
+Now you should
+[list]
+[*] create an account at github.com
+[*] fork https://github.com/redmatrix/hubzilla
+[*] fork https://github.com/redmatrix/hubzilla-addons
+[/list]
+
+If you not want to use GIT from the command line - there is a usefull Eclipse plugin named ""Eclipse Mylyn to GitHub connector".
+
+
+[h2]Install RED and its Addons[/h2]
+
+[h3]Git at your computer / vm[/h3]
+
+You should have created an account on github and forked the projects befor you procceed.
+
+Delete the directory www
+[code]root@debian:/var# rm -R www/
+[/code]
+
+Install git (and optionally git-gui a client gui)
+[code]apt-get install git git-gui[/code]
+
+[h3]Download red#matri and addons[/h3]
+
+Download the main project red and red-addons
+[code]
+root@debian:/var# git clone https://github.com/yourname/red www
+root@debian:/var# cd www/
+root@debian:/var/www# git clone https://github.com/yourname/red-addons addon
+[/code]
+
+Make this extra folder
+[code]
+root@debian:/var/www# mkdir -p "store/[data]/smarty3"
+[/code]
+
+Create .htconfig.php and make it writable by the webserver
+[code]
+root@debian:/var/www# touch .htconfig.php
+root@debian:/var/www# chmod ou+w .htconfig.php
+[/code]
+
+Make user www-data (webserver) is the owner all the project files
+[code]
+root@debian:/var/www# cd ..
+root@debian:/var# chown -R www-data:www-data www/
+[/code]
+
+Add yourself ("surfer" in this example) to the group www-data. Why? Later you want to modify files in eclipse or in another editor.
+Then make all files writable by the group www-date you are now a member of.
+[code]
+root@debian:/var# cd www/
+root@debian:/var/www# usermod -G www-data surfer
+root@debian:/var# chmod -R g+w www/
+[/code]
+
+Restart the computer (or vm)
+If you are still not able to modify the project files you can check the members of the group www-data with
+[code]
+cat /etc/group
+[/code]
+
+[h3]Register yourself as admin[/h3]
+
+Open http://localhost and init the matrix
+
+Befor you register a first user switch off the registration mails.
+Open /var/www/.htconfig.php
+and make sure "0" is set in this line
+[code]
+$a->config['system']['verify_email'] = 0;
+[/code]
+You should be able to change the file as "yourself" (instead of using root or www-data).
+
+[h3]Cron and the poller[/h3]
+
+Important!
+Run the poller to pick up the recent "public" postings of your friends
+Set up a cron job or scheduled task to run the poller once every 5-10
+minutes to pick up the recent "public" postings of your friends
+
+[code]
+crontab -e
+[/code]
+
+Add
+[code]
+*/10 * * * * cd /var/www/; /usr/bin/php include/poller.php
+[/code]
+
+If you don't know the path to PHP type
+[code]
+whereis php
+[/code]
+
+
+[h2]Debug the server via eclipse[/h2]
+
+[h3]Check the configuration of xdebug[/h3]
+
+You shoud already have installed xdebug in the steps befor
+[code]
+apt-get install php5-xdebug
+[/code]
+
+Configuring Xdebug
+
+Open your terminal and type as root (su -l)
+[code]
+gedit /etc/php5/mods-available/xdebug.ini
+[/code]
+
+if the file is empty try this location
+[code]
+gedit /etc/php5/conf.d/xdebug.ini
+[/code]
+
+That command should open the text editor gedit with the Xdebug configuration file
+At the end of the file content append the following text
+
+xdebug.remote_enable=on
+xdebug.remote_handler=dbgp
+xdebug.remote_host=localhost
+xdebug.remote_port=9000
+
+Save changes and close the editor.
+In you terminal type to restart the web server.
+[code]
+service apache2 restart
+[/code]
+
+
+[h3]Install Eclipse and start debugging[/h3]
+
+Install eclipse.
+Start eclipse with default worspace (or as you like)
+
+Install the PHP plugin
+Menu > Help > Install new software...
+Install "PHP Developnent Tools ..."
+
+Optionally - Install the GitHub connector plugin
+Menu > Help > Install new software...
+Install "Eclipse Mylyn to GitHub connector"
+
+Configure the PHP plugin
+Menu > Window > Preferences...
+> General > Webbrowser > Change to "Use external web browser"
+> PHP > Debug > Debug Settings > PHP Debugger > Change to "XDebug"
+
+Create a new PHP project
+Menu > File > New Project > Choose PHP > "PHP Project"
+> Choose Create project at existing location" and "/var/www"
+
+Start debugging
+Open index.php and "Debug as..."
+Choose as Launch URL: "http://localhost/"
+
+Expected:
+[list]
+[*] The web browser starts
+[*] The debugger will stop at the first php line
+[/list]
+
+
+[h2]Contribute your changes via github[/h2]
+
+[h3]Preparations[/h3]
+
+There is a related page in this docs: [zrl=[baseurl]/help/git_for_non_developers]Git for Non-Developers[/zrl].
+As stated befor it is recommended to read the official documentation [url=http://git-scm.com/book/en/v2/GitHub-Contributing-to-a-Project]GitHub-Contributing-to-a-Project[/url] of git.
+
+Eclipse has a usefull plugin for GIT: "Eclipse Mylyn to GitHub connector".
+
+Make sure you have set your data
+[code]
+surfer@debian:/var/www$ git config --global user.name "Your Name"
+surfer@debian:/var/www$ git config --global user.email "your@mail.com"
+[/code]
+
+[h3]Your first contribution[/h3]
+
+Create a descriptive topic branch
+[code]
+surfer@debian:/var/www$ git checkout -b dev_beginning
+[/code]
+
+Make sure your local repository is up-to-date with the main project.
+Add the original repository as a remote named “upstream†if not done yet
+[code]
+surfer@debian:/var/www$ git remote add upstream https://github.com/redmatrix/hubzilla
+[/code]
+
+Fetch the newest work from that remote
+[code]
+surfer@debian:/var/www$ git fetch upstream
+surfer@debian:/var/www$ git merge upstream/master
+[/code]
+
+Hint: You can list the branches
+[code]
+surfer@debian:/var/www$ git branch -v
+[/code]
+
+Make your changes. In this example it is a new doc file.
+
+Check your modifications
+[code]
+surfer@debian:/var/www$ git status
+[/code]
+
+Add (stage) the new file
+[code]
+surfer@debian:/var/www$ git add doc/dev_beginner.bb
+[/code]
+
+Commit the changes to your local branch. This will open an editor to provide a message.
+[code]
+surfer@debian:/var/www$ git commit -a
+[/code]
+
+Push back up to the same topic branch online
+[code]
+surfer@debian:/var/www$ git push
+[/code]
+
+Now you can go to your (online) account at github and create the pull request.
+
+[h3]Following contributions[/h3]
+
+In case the main devolpers want you to change something.
+Fetch the newest work from the remote upstream/master to be sure you have the latest changes.
+[code]
+surfer@debian:/var/www$ git fetch upstream
+surfer@debian:/var/www$ git merge upstream/master
+[/code]
+Make your changes, test them, commit (to local repository), push (to online repository)
+[code]
+surfer@debian:/var/www$ git status
+surfer@debian:/var/www$ git commit -a -m "added modification of branch"
+surfer@debian:/var/www$ git push
+[/code]
+
+
+#include doc/macros/main_footer.bb;
\ No newline at end of file
diff --git a/sources/doc/developer_function_primer.bb b/sources/doc/developer_function_primer.bb
new file mode 100644
index 00000000..37345444
--- /dev/null
+++ b/sources/doc/developer_function_primer.bb
@@ -0,0 +1,47 @@
+[b]Red development - some useful basic functions[/b]
+
+[b]get_account_id()[/b]
+
+Returns numeric account_id if authenticated or 0. It is possible to be authenticated and not connected to a channel.
+
+[b]local_channel()[/b]
+
+Returns authenticated numeric channel_id if authenticated and connected to a channel or 0. Sometimes referred to as $uid in the code.
+
+[b]remote_channel()[/b]
+
+Returns authenticated string hash of Red global identifier, if authenticated via remote auth, or an empty string.
+
+[b]get_app()[/b]
+
+Returns the global app structure ($a).
+
+[b]App::get_observer()[/b]
+
+(App:: is usually assigned to the global $a), so $a->get_observer() or get_app()->get_observer() - returns an xchan structure representing the current viewer if authenticated (locally or remotely).
+
+[b]get_config($family,$key), get_pconfig($uid,$family,$key), get_xconfig($xchan_hash,$family,$key)[/b]
+
+Returns the config setting for $family and $key or false if unset.
+
+[b] set_config($family,$key,$value), set_pconfig($uid,$family,$key,$value)[/b]
+
+Sets the value of config setting for $family and $key to $value. Returns $value. The config versions operate on system-wide settings. The pconfig versions get/set the values for a specific integer uid (channel_id). The xconfig version get/sets the value for a specific xchan hash - generally used for remote users.
+
+[b]dbesc()[/b]
+
+Always escape strings being used in DB queries. This function returns the escaped string. Integer DB parameters should all be proven integers by wrapping with intval()
+
+[b]q($sql,$var1...)[/b]
+
+Perform a DB query with the SQL statement $sql. printf style arguments %s and %d are replaced with variable arguments, which should each be appropriately dbesc() or intval(). SELECT queries return an array of results or false if SQL or DB error. Other queries return true if the command was successful or false if it wasn't.
+
+[b]t($string)[/b]
+
+Returns the translated variant of $string for the current language or $string (default 'en' language) if the language is unrecognised or a translated version of the string does not exist.
+
+[b]x($var), $x($array,$key)[/b]
+
+Shorthand test to see if variable $var is set and is not empty. Tests vary by type. Returns false if $var or $key is not set. If variable is set, returns 1 if has 'non-zero' value, otherwise returns 0. -- e.g. x('') or x(0) returns 0;
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/developers.bb b/sources/doc/developers.bb
new file mode 100644
index 00000000..e9dddc69
--- /dev/null
+++ b/sources/doc/developers.bb
@@ -0,0 +1,70 @@
+[b]$Projectname Developer Guide[/b]
+
+We're pretty relaxed when it comes to developers. We don't have a lot of rules. Some of us are over-worked and if you want to help we're happy to let you help. That said, attention to a few guidelines will make the process smoother and make it easier to work together. We have developers from across the globe with different abilities and different cultural backgrounds and different levels of patience. Our primary rule is to respect others. Sometimes this is hard and sometimes we have very different opinions of how things should work, but if everybody makes an effort, we'll get along just fine.
+
+[b]Here is how you can join us.[/b]
+
+First, get yourself a working git package on the system where you will be
+doing development.
+
+Create your own github account.
+
+You may fork/clone the Red repository from [url=https://github.com/redmatrix/hubzilla.git]https://github.com/redmatrix/hubzilla.git[/url]
+
+Follow the instructions provided here: [url=http://help.github.com/fork-a-repo/]http://help.github.com/fork-a-repo/[/url]
+to create and use your own tracking fork on github
+
+Then go to your github page and create a "Pull request" when you are ready
+to notify us to merge your work.
+
+[b]Translations[/b]
+
+Our translations are managed through Transifex. If you wish to help out translating the $Projectname to another language, sign up on transifex.com, visit [url=https://www.transifex.com/projects/p/red-matrix/]https://www.transifex.com/projects/p/red-matrix/[/url] and request to join one of the existing language teams or create a new one. Notify one of the core developers when you have a translation update which requires merging, or ask about merging it yourself if you're comfortable with git and PHP. We have a string file called 'messages.po' which is gettext compliant and a handful of email templates, and from there we automatically generate the application's language files.
+
+[zrl=[baseurl]/help/Translations]Translations - More Info[/zrl]
+
+[b]Important[/b]
+
+Please pull in any changes from the project repository and merge them with your work **before** issuing a pull request. We reserve the right to reject any patch which results in a large number of merge conflicts. This is especially true in the case of language translations - where we may not be able to understand the subtle differences between conflicting versions.
+
+Also - **test your changes**. Don't assume that a simple fix won't break something else. If possible get an experienced Red developer to review the code.
+
+Further documentation can be found at the Github wiki pages at: [url=https://github.com/friendica/red/wiki]https://github.com/friendica/red/wiki[/url]
+
+[b]Licensing[/b]
+
+All code contributed to the project falls under the MIT license, unless otherwise specified. We will accept third-party code which falls under MIT, BSD and LGPL, but copyleft licensing (GPL, and AGPL) is only permitted in addons. It must be possible to completely remove the GPL (copyleft) code from the main project without breaking anything.
+
+[b]Concensus Building[/b]
+
+Code changes which fix an obvious bug are pretty straight-forward. For instance if you click "Save" and the thing you're trying to save isn't saved, it's fairly obvious what the intended behaviour should be. Often when developing feature requests, it may affect large numbers of community members and it's possible that other members of the community won't agree with the need for the feature, or with your proposed implementation. They may not see something as a bug or a desirable feature.
+
+We encourage consensus building within the community when it comes to any feature which might be considered controversial or where there isn't unanimous decision that the proposed feature is the correct way to accomplish the task. The first place to pitch your ideas is to [url=https://zothub.com/channel/one]Channel One[/url]. Others may have some input or be able to point out facets of your concept which might be problematic in our environment. But also, you may encounter opposition to your plan. This doesn't mean you should stop and/or ignore the feature. Listen to the concerns of others and try and work through any implementation issues.
+
+There are places where opposition cannot be resolved. In these cases, please consider making your feature [b]optional[/b] or non-default behaviour that must be specifically enabled. This technique can often be used when a feature has significant but less than unanimous support. Those who desire the feature can turn it on and those who don't want it - will leave it turned off.
+
+If a feature uses other networks or websites and or is only seen as desirable by a small minority of the community, consider making the functionality available via an addon or plugin. Once again, those who don't desire the feature won't need to install it. Plugins are relatively easy to create and "hooks" can be easily added or modified if the current hooks do not do what is needed to allow your plugin to work.
+
+
+[b]Coding Style[/b]
+
+In the interests of consistency we adopt the following code styling. We may accept patches using other styles, but where possible please try to provide a consistent code style. We aren't going to argue or debate the merits of this style, and it is irrelevant what project 'xyz' uses. This is not project 'xyz'. This is a baseline to try and keep the code readable now and in the future.
+
+[li] All comments should be in English.[/li]
+
+[li] We use doxygen to generate documentation. This hasn't been consistently applied, but learning it and using it are highly encouraged.[/li]
+
+[li] Indentation is accomplished primarily with tabs using a tab-width of 4.[/li]
+
+[li] String concatenation and operators should be separated by whitespace. e.g. "$foo = $bar . 'abc';" instead of "$foo=$bar.'abc';"[/li]
+
+[li] Generally speaking, we use single quotes for string variables and double quotes for SQL statements. "Here documents" should be avoided. Sometimes using double quoted strings with variable replacement is the most efficient means of creating the string. In most cases, you should be using single quotes.[/li]
+
+[li] Use whitespace liberally to enhance readability. When creating arrays with many elements, we will often set one key/value pair per line, indented from the parent line appropriately. Lining up the assignment operators takes a bit more work, but also increases readability.[/li]
+
+[li] Generally speaking, opening braces go on the same line as the thing which opens the brace. They are the last character on the line. Closing braces are on a line by themselves. [/li]
+
+[b]See Also[/b]
+[zrl=[baseurl]/help/sql_conventions]SQL Conventions[/zrl]
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/diaspora_compat.md b/sources/doc/diaspora_compat.md
new file mode 100644
index 00000000..255b565a
--- /dev/null
+++ b/sources/doc/diaspora_compat.md
@@ -0,0 +1,60 @@
+##Diaspora Compatibility
+
+Diaspora protocol compatibility is presently considered an ***experimental*** feature. It may not be available on all sites and presents some serious compatibility issues with hubzilla. At the moment these compatibility issues will be shared with "Friendica-over-Diaspora" protocol communications.
+
+Private mail retraction (unsend) will not be possible on Diaspora.
+
+Private posts and their associated comments are sent in plaintext email notifications in Diaspora and Friendica. This is a major privacy issue and affects any private communications you have where *any* member of the conversation is on another network. Be aware of it.
+
+Access control only works on posts and comments. Diaspora members will get permission denied trying to access any other access controlled hubzilla objects such as files, photos, webpages, chatrooms, etc. In the case of private photos that are linked to posts, they will see a "prohibited sign" instead of the photo. Diaspora has no concept of private media. There is no workaround except to make your media resources public (to everybody on the internet).
+
+
+Edited posts will not be delivered. Diaspora members will see the original post/comment without edits. There is no mechanism in the protocol to update an existing post. We cannot delete it and submit another invisibly because the message-id will change and we need to keep the same message-id on our own network. The only workaround is to delete the post/comment and do it over. We may eventually provide a way to delete the out of date copy only from Diaspora and keep it intact on networks that can handle edits.
+
+Some comments from external services will not deliver to Diaspora, as they have no Diaspora service discovery. Currently this applies to comments from WordPress blogs which are imported into your stream; but will extend to most any service that has no Diaspora discover mechanism.
+
+
+Nomadic identity will not work with Diaspora. We will eventually provide an **option** which will allow you to "start sharing" from all of your clones when you make the first connection. The Diaspora person does not have to accept this, but it will allow your communications to continue if they accept this connection. Without this option, if you go to another server from where you made the connection originally or you make the connection before creating the clone, you will need to make friends with them again from the new location.
+
+Post expiration is not supported on Diaspora. We will provide you an option to not send expiring posts to that network. In the future this may be provided with a remote delete request.
+
+End-to-end encryption is not supported. We will translate these posts into a lock icon, which can never be unlocked from the Diaspora side.
+
+Message verification will eventually be supported.
+
+Multiple profiles are not supported. Diaspora members can only see your default profile.
+
+Birthday events will not appear in Diaspora. Other events will be translated and sent as a post, but all times will either be in the origination channel's timezone or in GMT. We do not know the recipient's timezone because Diaspora doesn't have this concept.
+
+We currently allow tags to be hijacked by default. We will provide an option to allow you to prevent the other end of the network from hijacking your tags and point them at its own resources.
+
+Community tags will not work. We will send a tagging activity as a comment. It won't do anything.
+
+Privacy tags (@!somebody) will not be available to Diaspora members. These tags may have to be stripped or obscured to prevent them from being hijacked - which could result in privacy issues.
+
+Plus-tagged hubzilla forums should work from Diaspora.
+
+Premium channel redirects will not be sent. If you allow Diaspora connections, they will not see that you have a premium channel.
+
+You cannot use Diaspora channels as channel sources.
+
+
+Dislikes of posts will be converted to comments and you will have the option to send these as comments or not send them to Diaspora (which does not provide dislike). Currently they are not sent.
+
+We will do the same for both likes and dislikes of comments. They can either be sent as comments or you will have the ability to prevent them from being transmitted to Diaspora. Currently they are not sent.
+
+
+"observer tags" will be converted to empty text.
+
+
+Embedded apps will be translated into links.
+
+
+Embedded page design elements (work in progress) will be either stripped or converted to an error message.
+
+Diaspora members will not appear in the directory.
+
+
+There are differences in oembed compatibility between the networks. Some embedded resources will turn into a link on one side or the other.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/doco.bb b/sources/doc/doco.bb
new file mode 100644
index 00000000..7ca64cfe
--- /dev/null
+++ b/sources/doc/doco.bb
@@ -0,0 +1,33 @@
+[b]Creating Documentation[/b]
+
+To contribute documentation, simply put some words in a cunning order, and make their existence known to a developer. You can do this literally anywhere as long as a developer can see it. Once made aware, somebody will check it in for you. You should try to avoid proprietary formats, or locations that require authentication with methods other than Zot in order to make it easy for a developer to access, but even this is not a strict requirement.
+
+If you wish to contribute directly, that's fine too. To contribute directly, documentation should be in one of the following formats:
+
+[li]Markdown[/li]
+[li]BBCode[/li]
+[li]HTML[/li]
+[li]Plain Text[/li]
+
+Other formats are also allowed, but support for the format must be added to mod/help.php first.
+
+If editing a plain text file, please keep column width to 80. This is because plain text is used in instances where we may not have a working installation - the installation documentation, for example - and it should be easy to read these from a CLI text editor.
+
+The advantage of Markdown is that it is human readable.
+
+The advantage of BBCode is that it is identity aware.
+
+Therefore, if using BBCode, try to make the most of it:
+[li]Use ZRL links where appropriate to ensure a link to another site retains authentication and keeps identity based documentation working[/li]
+[li]Use baseurl or observer.baseurl tags where appropriate instead of example.com for authenticated viewers.[/li]
+[li]Support non-authenticated users with observer=0 tags. We presently do not do this due to historical oversights. This needs adding everywhere[/li]
+
+[b]Translations[/b]
+
+To translate documentation, or provided documentation in languages other than English:
+[li]Create a directory in doc/ with your two letter country code if it doesn't already exist (eg, doc/de/ for German or doc/fr/ for French)[/li]
+[li]Create a document with the same filename as the English version, but with content in your own language. This allows us to fallback to the English if the translation for a particular page is not provided[/li]
+
+To create documentation that has no equivalent file in English, you can create a new file with a name of your choosing - but you'll also need to provide a localised version of the index page (main.bb in English) to make it accessible from the menu.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/encryption.bb b/sources/doc/encryption.bb
new file mode 100644
index 00000000..9985f4b3
--- /dev/null
+++ b/sources/doc/encryption.bb
@@ -0,0 +1,18 @@
+[size=large]Builtin Automatic Encryption[/size]
+
+Full disclosure: The encryption $Projectname uses per default is not absolutely waterproof. There [i]are[/i] known procedures to circumvent it. [i]But[/i] this takes a lot of effort and needs to be done individually for each channel. And to make this clear: Other services store your messages in plaintext, therefore we regard this approach as a [i]significant[/i] improvement for your privacy. Plus you are always free to use further encryption and password protection if you so desire.
+
+
+To explain this in more detail:
+
+- each channel has its key pair
+- every non-public post is automatically encrypted
+- optional password protect content via crypto-javascript browser-to-browser encryption (needs to be enabled in settings) Full disclosure: A rogue hub admin could injects malicious javascript-code (e.g. keylogging-abilities) into the code. Encrypt our stuff out of band with GPG, become a hub administrator yourself or use other means of communication if this worries you.
+
+So what is the scope of security? Full disclosure: This might be great, but it is not perfect.
+- every non-public post is automatically encrypted but persons who have access to the site's database and files [i]may[/i] be able to decrypt everything by using these keys which obviously need to be stored on the server. To be clear: The encrypion keys are different for every channel and it is [i]quite an effort[/i] to do this. And again: Other services store your messages in plain text unencrypted. So this [i]is[/i] quite a significant win for your privacy.
+
+We believe that the NSA-level dragnet plaintext extracting mass surveillance is probably not possible due to the design of the zot protocol. Dedicated attacks including hacking into one hub to obtain the server logs and database only partly reveal what is going on between people communication between different hubs. We believe that this makes it much more expensive for state-level attackers to access your content in $Projectname.
+
+
+We gladly accept help improving the security of the system and auditing it as well.
diff --git a/sources/doc/external-resource-links.bb b/sources/doc/external-resource-links.bb
new file mode 100644
index 00000000..412e8446
--- /dev/null
+++ b/sources/doc/external-resource-links.bb
@@ -0,0 +1,20 @@
+[b]External Resource Links[/b]
+
+[b][color= grey][size=24]External Links[/size][/color][/b]
+[b]Third-Party Themes[/b]
+
+[*][url=https://github.com/omigeot/redstrap3]Redstrap[/url]
+[*][url=https://bitbucket.org/tobiasd/red-clean]Clean[/url]
+[*][url=https://github.com/tonybaldwin/redmatrixthemes/]nubasic[/url]
+[*][url=https://github.com/deadsuperhero/redmatrix-themes]Sean Tilley's themes[/url]
+
+[b]Third-Party Addons[/b]
+[*][url=https://abcentric.net/git/abcjsplugin.git]ABCjs integration - display scores in posts (WIP)[/url]
+[b]Related Projects[/b]
+
+[*][url=https://addons.mozilla.org/en-US/firefox/addon/redshare/]Redshare for Firefox[/url]
+[*][url=https://github.com/cvogeley/red-for-android]Red for Android[/url]
+[*][url=https://github.com/zzottel/feed2red]feed2red.pl (posts Atom/RSS feeds to channel)[/url]
+[*][url=https://wordpress.org/plugins/hubzilla-wp/]WordPress gateway (combine with wppost addon for full features)[/url]
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/extra_features.bb b/sources/doc/extra_features.bb
new file mode 100644
index 00000000..ed513eeb
--- /dev/null
+++ b/sources/doc/extra_features.bb
@@ -0,0 +1,98 @@
+// multiple of these have been enabled by default. should we note this here somewhere, move it or remove them from this file?
+[b]Features[/b]
+
+The default interface of the $Projectname was designed to be uncluttered. There are a huge number of extra features (some of which are extremely useful) which you can turn on and get the most of the application. These are found under the Extra Features link of your Settings page.
+
+[b]Content Expiration[/b]
+
+Remove posts/comments and/or private messages at a future time. An extra button is added to the post editor which asks you for an expiration. Typically this in "yyyy-mm-dd hh:mm" format, but in the English language you have a bit more freedom and can use most any recognisable date reference such as "next Thursday" or "+1 day". At the specified time (give or take approximately ten minutes based on the remote system's checking frequency) the post is removed.
+
+[b]Multiple Profiles[/b]
+
+The ability to create multiple profiles which are visible only to specific persons or groups. Your default profile may be visible to anybody, but secondary profiles can all contain different or additional information and can only be seen by those to whom that profile is assigned.
+
+[b]Web Pages[/b]
+
+Provides the ability to use web page design feaures and create custom webpages from your own content and also to design the pages with page layouts, custom menus, and content blocks.
+
+[b]Private Notes[/b]
+
+On pages where it is available (your matrix page and personal web pages) provide a "widget" to create and store personal reminders and notes.
+
+[b]Extended Identity Sharing[/b]
+
+By default your identity travels with you as you browse the matrix to remote sites - and they know who you are and can show you content that only you can see. With Extended Identity Sharing you can provide this information to any website you visit from within the matrix.
+
+[b]Expert Mode[/b]
+
+This allows you to see some advanced configuration options that would confuse some people or cause support issues. In particular this can give you full control over theme features and colours - so that you can tweak a large number of settings of the display theme to your liking.
+
+[b]Premium Channel[/b]
+
+This allows you to set restrictions and terms on those that connect with your channel. This may be used by celebrities or anybody else who wishes to describe their channel to people who wish to connect with it. In certain cases you may be asked for payment in order to connect.
+
+[b]Post Preview[/b]
+
+Allows previewing posts and comments exactly as they would look on the page before publishing them.
+
+[b]Channel Sources[/b]
+
+Automatically import and re-publish channel content from other channels or feeds. This allows you to create sub-channels and super-channels from content provided elsewhere. The rules are that the content must be public, and the channel owner must give you permission to source their channel.
+
+[b]Even More Encryption[/b]
+
+Private messages are encrypted during transport and storage. In this day and age, this encyption may not be enough if your communications are extremely sensitive. This options lets you provide optional encryption of content "end-to-end" with a shared secret key. How the recipient learns the secret key is completely up to you. You can provide a hint such as "the name of aunt Claire's first dog".
+
+[b]Search by Date[/b]
+
+This provides the ability to select posts by date ranges
+
+[b]Collections Filter[/b]
+
+Enable widget to display stream posts only from selected collections. This also toggles the outbound permissions while you are viewing a collection. This is analogous to Google "circles" or Disapora "aspects".
+
+[b]Saved Searches[/b]
+
+Provides a search widget on your matrix page which can save selected search terms for re-use.
+
+[b]Personal Tab[/b]
+
+Enable tab to display only matrix posts that you've interacted with in some way, as an author or a contributor to the conversation.
+
+[b]New Tab[/b]
+
+Enables a tab to display all new matrix activity as a firehose or timeline.
+
+[b]Affinity Tool[/b]
+
+Filter matrix stream activity by the depth of your relationships
+
+[b]Edit Sent Posts[/b]
+
+Edit and correct posts and comments after sending
+
+[b]Tagging[/b]
+
+Ability to tag existing posts, including those written by others.
+
+[b]Post Categories[/b]
+
+Add categories to your channel posts
+
+[b]Saved Folders[/b]
+
+Ability to file posts under folders or tags for later recall
+
+[b]Dislike Posts[/b]
+
+Ability to dislike posts/comments
+
+[b]Star Posts[/b]
+
+Ability to mark special posts with a star indicator
+
+[b]Tag Cloud[/b]
+
+Provide a personal tag cloud on your channel page
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/faq_admins.bb b/sources/doc/faq_admins.bb
new file mode 100644
index 00000000..63418c1d
--- /dev/null
+++ b/sources/doc/faq_admins.bb
@@ -0,0 +1,78 @@
+[size=large][b]The $Projectname FAQ[/b][/size]
+
+[toc]
+
+[h3]Is there a way to change the Admin account?[/h3]
+[h3]Is there a way to have multiple administrators?[/h3]
+Yes, but it's a bit messy at the moment as it is not yet exposed in the UI. To make an account an administrative account,
+one needs to add 4096 to the account_roles entry in the account table of the database. Likewise, to remove administrative permissions,
+one must subtract 4096 from the account roles.
+
+[h3]I can log in, but there are no posts or webpages[/h3]
+
+Most likely, your item table has crashed. Run the MySQL command [code]repair table item;[/code]
+
+[h3]Login doesn't work, immediately after login, the page reloads and I'm logged out[/h3]
+
+Most likely, your session table has crashed. Run the MySQL command [code]repair table session;[/code]
+
+[h3]When I switch theme, I sometimes get elements of one theme superimposed on top of the other[/h3]
+
+a) store/[data]/smarty3 isn't writeable by the webserver. Make it so.
+
+b) You're using Midori, or with certain themes, Konqueror in KHTML mode.
+
+[b]My network tab won't load, it appears to be caused by a photo or video[/h3]
+
+Your PHP memory limit is too low. Increase the size of the memory_limit directive in your php.ini
+
+Contrary to popular belief, the number of users on a hub doesn't make any difference to the required memory limit, rather, the content
+of an individuals matrix counts. Streams with lots of photos and video require more memory than streams with lots of text.
+
+[h3]I have no communication with anybody[/h3]
+
+You're listening on port 443, but do not have a valid SSL certificate. Note this applies even if your baseurl is http.
+Don't listen on port 443 if you cannot use it. It is strongly recommended to solve this problem by installing a browser
+valid SSL certificate rather than disabling port 443.
+
+[h3]How do I update a non-Git install?[/h3]
+1) Backup .htconfig.php
+2) Backup everything in store/
+3) Backup any custom changes in mod/site/ and view/site
+3) Delete your existing installation
+4) Upload the new version.
+5) Upload the new version of themes and addons.
+6) Restore everything backed up earlier.
+
+[h3]What do I need to do when moving my hub to a different server[/h3]
+
+1) Git clone on the new server. Repeat the process for any custom themes, and addons.
+2) Rsync .htconfig.php
+3) Rsync everything in store/
+4) Rsync everything in mod/site/ and view/site (these will only exist if you have custom modules)
+5) Dump and restore DB.
+
+[h3]How do I reinstall an existing hub on the same server?[/h3]
+
+1) [code]git reset --hard HEAD[/code] will reset all files to their upstream defaults. This will not reset any local files that do not also exist upstream. Eg, if you have local changes to mod/channel.php, this will reset them - but will not reset any changes in mod/site/channel.php
+2) If you absolutely must reinstall - for example, if you need to upgrade operating system - follow the steps for moving to a different server, but instead of using rsync, backup and restore some other way.
+
+Do not reinstall a hub with a fresh database and fresh .htconfig.php unless as a very last resort. Creating a temporary account and ask for help via a support channel for non-trivial reinstalls is preferable to reinstalling fresh.
+
+[h3]How do I set the default homepage for logged out viewers?[/h3]
+
+Use the custom_home addon available in the main addons repository.
+
+[h3]What do the different directory mode settings mean?[/h3]
+[code]// Configure how we communicate with directory servers.
+// DIRECTORY_MODE_NORMAL = directory client, we will find a directory (all of your member's queries will be directed elsewhere)
+// DIRECTORY_MODE_SECONDARY = caching directory or mirror (keeps in sync with realm primary [adds significant cron execution time])
+// DIRECTORY_MODE_PRIMARY = main directory server (you do not want this unless you are operating your own realm. one per realm.)
+// DIRECTORY_MODE_STANDALONE = "off the grid" or private directory services (only local site members in directory)
+[/code]
+- The default is NORMAL. This off-loads most directory services to a different server. The server used is the config:system/directory_server. This setting MAY be updated by the code to one of the project secondaries if the current server is unreachable. You should either be in control of this other server, or should trust it to use this setting.
+- SECONDARY. This allows your local site to act as a directory server without exposing your member's queries to another server. It requires extra processing time during the cron polling, and is not recommended to be run on a shared web host.
+- PRIMARY. This allows you to run a completely separate 'Network' of directory servers with your own Realm. By default, all servers are on the RED_GLOBAL realm unless the config:system/directory_realm setting is overridden. [i]Do not use this unless you have your own directory_realm.[/i]
+- STANDALONE. This is like primary, except it's a 'Network' all on it's own without talking to any other servers. Use this if you have only one server and want to be segregated from the Red#Matrix directory listings.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/faq_developers.bb b/sources/doc/faq_developers.bb
new file mode 100644
index 00000000..027efe8f
--- /dev/null
+++ b/sources/doc/faq_developers.bb
@@ -0,0 +1,33 @@
+[size=large][b]Frequently Asked Questions For Developers[/b][/size]
+
+[toc]
+
+
+[h3]What does $a mean?[/h3]
+$a is a class defined in boot.php and passed all around $Projectname as a global reference variable. It defines everything necessary for the $Projectname application: Server variables, URL arguments, page structures, layouts, content, installed plugins, output device info, theme info, identity of the observer and (potential) page owner ...
+
+We don't ever create more than one instance and always modify the elements of the single instance. The mechanics of this are somewhat tricky. If you have a function that is passed $a and needs to modify $a you need to declare it as a reference with '&' e.g.
+
+[code]function foo(&$a) { $a->something = 'x'; // whatever };
+
+*or* access it within your function as a global variable via get_app()
+
+function foo() {
+ $a = get_app();
+ $a->something = 'x';
+}
+
+
+function foo($a) { $a->something = 'x'; };
+
+will *not* change the global app state.
+
+function foo() {
+ get_app()->something = 'x';
+}
+[/code]
+
+
+
+#include doc/macros/main_footer.bb;
+
diff --git a/sources/doc/faq_members.bb b/sources/doc/faq_members.bb
new file mode 100644
index 00000000..9d42d97a
--- /dev/null
+++ b/sources/doc/faq_members.bb
@@ -0,0 +1,18 @@
+[size=large][b]The $Projectname FAQ[/b][/size]
+
+[toc]
+
+
+[h3]I am able to edit a post's text after I saved it, but is there a way to change the permissions?[/h3]
+Short anser: No, there isn't. There are reasons. You are able to change permissons to your files, photos and the likes, but not to posts after you have saved them. The main reason is: Once you have saved a post it is being distributed either to the public channel and from there to other $Projectname servers or to those you intended it to go. Just like you cannot reclaim something you gave to another person, you cannot change permissions to $Projectname posts. We would need to track everywhere your posting goes, keep track of everyone you allowed to see it and then keep track of from whom to delete it.
+If a posting is public this is even harder, as the $Projectname is a global network and there is no way to follow a post, let alone reclaim it reliably. Other networks that may receive your post have no reliable way to delete or reclaim the post.
+
+[h3]I downloaded my channel and imported it (cloned my identity) to another site but there is no content, no posts, no photos. What is wrong???[/h3]
+To be honest: Nothing. That's the way it is right now. Technically it is surely possible to take at least your own posts and maybe even files with you, but this has simply put not implemented yet. When creating this feature we thought that keeping all your contacts was more important. Your friends have already seen your old content. Once we find someone willing to implement this, it will be done. :)
+[h3]I can't see private resources[/h3]
+You have probably disabled third party cookies. You need to enable them for remote authentication to work.
+[h3]There are a lot of foreign language posts. Let's auto-translate them.[/h3]
+There are also a lot of [b]private[/b] foreign language posts and auto-translation services would require us to transmit these private messages to the translation service; and we don't know what they will do with them on their servers. Actually we do know thanks to Edward Snowden. Our best bet is a project called [b][i]Apertium[/i][/b] which is an open source translator we can install locally. It is currently missing German translations - which are the most requested translation in the matrix. Once again, this will be implemented when we find somebody who really wants to make it happen.
+
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/features.bb b/sources/doc/features.bb
new file mode 100644
index 00000000..0a9bcee3
--- /dev/null
+++ b/sources/doc/features.bb
@@ -0,0 +1,208 @@
+[b][size=20]Features[/size][/b]
+
+[b][size=24]$Projectname in a Nutshell[/size][/b]
+
+TL;DR
+
+$Projectname provides distributed web publishing and social communications with [b]decentralised permissions[/b].
+
+So what exactly are "decentralised permissions"? They give me the ability to share something on my website (photos, media, files, webpages, etc.) with specific people on completely different websites - but not necessarily [i]everybody[/i] on those websites; and they do not need a password on my website and do not need to login to my website to view the things I've shared with them. They have one password on their own website and "magic authentication" between affiliated websites in the network. Also, as it is decentralised, there is no third party which has the ability to bypass permissions and see everything in the network.
+
+$Projectname combines many features of traditional blogs, social networking and media, content management systems, and personal cloud storage into an easy to use framework. Each node in the matrix can operate standalone or link with other nodes to create a super-network; leaving privacy under the control of the original publisher.
+
+$Projectname is an open source webserver application written originally in PHP/MySQL and is easily installable by those with basic website administration skills. It is also easily extended via plugins and themes and other third-party tools.
+
+[b][size=24]$Projectname Features[/size][/b]
+
+
+The $Projectname is a general-purpose web publishing and communication network, with several unique features. It is designed to be used by the widest range of people on the web, from non-technical bloggers, to expert PHP programmers and seasoned systems administrators.
+
+This page lists some of the core features of $Projectname that are bundled with the official release. As with most free and open source software, there may be many other extensions, additions, plugins, themes and configurations that are limited only by the needs and imagination of the members.
+
+[b][size=20]Built for Privacy and Freedom[/size][/b]
+
+One of the design goals of $Projectname is to enable easy communication on the web, while preserving privacy, if so desired by members. To achieve this goal, $Projectname includes a number of features allowing arbitrary levels of privacy:
+
+[b]Affinity Slider[/b]
+
+When adding connnections in $Projectname, members have the option of assigning "affinity" levels (how close your friendship is) to the new connection. For example, when adding someone who happens to be a person whose blog you follow, you could assign their channel an affinity level of "Acquaintances".
+
+On the other hand, when adding a friend's channel, they could be placed under the affinity level of "Friends".
+
+At this point, the $Projectname [i]Affinity Slider[/i] tool, which usually appears at the top of your "Matrix" page, adjusts the content on the page to include those within the desired affinity range. Channels outside that range will not be displayed, unless you adjust the slider to include them.
+
+The Affinity Slider allows instantaneous filtering of large amounts of content, grouped by levels of closeness.
+
+[b]Access Control Lists[/b]
+
+When sharing content, members have the option of restricting who sees the content. By clicking on the padlock underneath the sharing box, one may choose desired recipients of the post, by clicking on their names.
+
+Once sent, the message will be viewable only by the sender and the selected recipients. In other words, the message will not appear on any public walls.
+
+Access Control Lists may be applied to content and posts, photos, events, webpages, chatrooms and files.
+
+[b]Single Sign-on[/b]
+
+Access Control Lists work for all channels in the matrix due to our unique single sign-on technology. Most internal links provide an identity token which can be verified on other $Projectname sites and used to control access to private resources. You login once to your home hub. After that, authentication to all $Projectname resources is "magic".
+
+
+[b]WebDAV enabled File Storage[/b]
+
+Files may be uploaded to your personal storage area using your operating system utilities (drag and drop in most cases). You may protect these files with Access Control Lists to any combination of $Projectname members (including some third party network members) or make them public.
+
+[b]Photo Albums[/b]
+
+Store photos in albums. All your photos may be protected by Access Control Lists.
+
+[b]Events Calendar[/b]
+
+Create and manage events and tasks, which may also be protected with Access Control Lists. Events can be imported/exported to other software using the industry standard vcalendar/iCal format and shared in posts with others. Birthday events are automatically added from your friends and converted to your correct timezone so that you will know precisely when the birthday occurs - no matter where you are located in the world in relation to the birthday person. Events are normally created with attendance counters so your friends and connections can RSVP instantly.
+
+[b]Chatrooms[/b]
+
+You may create any number of personal chatrooms and allow access via Access Control Lists. These are typically more secure than XMPP, IRC, and other Instant Messaging transports, though we also allow using these other services via plugins.
+
+[b]Webpage Building[/b]
+
+$Projectname has many "Content Management" creation tools for building webpages, including layout editing, menus, blocks, widgets, and page/content regions. All of these may be access controlled so that the resulting pages are private to their intended audience.
+
+[b]Apps[/b]
+
+Apps may be built and distributed by members. These are different from traditional "vendor lockin" apps because they are controlled completely by the author - who can provide access control on the destination app pages and charge accordingly for this access. Most apps in $Projectname are free and can be created easily by those with no programming skills.
+
+[b]Layout[/b]
+
+Page layout is based on a description language called Comanche. $Projectname is itself written in Comanche layouts which you can change. This allows a level of customisation you won't typically find in so-called "multi-user environments".
+
+[b]Bookmarks[/b]
+
+Share and save/manage bookmarks from links provided in conversations.
+
+
+[b]Private Message Encryption and Privacy Concerns[/b]
+
+Messages marked [b]private[/b] are encrypted with AES-CBC 256-bit symmetric cipher, which is then protected (encrypted in turn) by public key cryptography, based on 4096-bit RSA keys, associated with the channel that is sending the message.
+
+These private messages are also stored in an encrypted form on remote systems.
+
+Each Red channel has it's own unique set of private and associated public RSA 4096-bit keys, generated when the channels is first created.
+
+Additionally, messages may be created utilising "end-to-end encryption" which cannot be read by $Projectname operators or ISPs or anybody who does not know the passcode.
+
+Public messages are generally not encrypted in transit or in storage.
+
+Private messages may be retracted (unsent) although there is no guarantee the recipient hasn't read it yet.
+
+Posts and messages may be created with an expiration date, at which time they will be deleted/removed on the recipient's site.
+
+
+[b]Service Federation[/b]
+
+In addition to addon "cross-post connectors" to a variety of alternate networks, there is native support for importation of content from RSS/Atom feeds and using this to create special channels. Also, an experimental but working implementation of the Diaspora protocol allows communication with people on the Friendica and Diaspora decentralised social networks. This is currently marked experimental because these networks do not have the same level of privacy and encryption features and abilities as $Projectname and may present privacy risks.
+
+There is also experimental support for OpenID authentication which may be used in Access Control Lists. This is a work in progress. Your $Projectname hub may be used as an OpenID provider to authenticate you to external services which use this technology.
+
+Channels may have permissions to become "derivative channels" where two or more existing channels combine to create a new topical channel.
+
+[b]Collections[/b]
+
+"Collections" is our implementation of privacy groups, which is similar to Google "Circles" and Diaspora "Aspects". This allows you to filter your incoming stream by collections or groups, and automatically set the outbound Access Control List to only those in the Collection when you post. You may over-ride this at any time (prior to sending the post).
+
+
+[b]Directory Services[/b]
+
+We provide easy access to a directory of members and provide decentralised tools capable of providing friend "suggestions". The directories are normal $Projectname sites which have chosen to accept the directory server role. This requires more resources than most typical sites so is not the default. Directories are synchronised and mirrored so that they all contain up-to-date information on the entire network (subject to normal propagation delays).
+
+
+[b]TLS/SSL[/b]
+
+For $Projectname hubs that use TLS/SSL, client to server communications are encrypted via TLS/SSL. Given recent disclosures in the media regarding widespread, global surveillance and encryption circumvention by the NSA and GCHQ, it is reasonable to assume that HTTPS-protected communications may be compromised in various ways. Private communications are consequently encrypted at a higher level before sending offsite.
+
+[b]Channel Settings[/b]
+
+When a channel is created, a role is chosen which applies a number of pre-configured security and privacy settings. These are chosen for best practives to maintain privacy at the requested levels.
+
+If you choose a "custom" privacy role, each channel allows fine-grained permissions to be set for various aspects of communication. For example, under the "Security and Privacy Settings" heading, each aspect on the left side of the page, has six (6) possible viewing/access options, that can be selected by clicking on the dropdown menu. There are also a number of other privacy settings you may edit.
+
+The options are:
+
+ - Nobody except yourself.
+ - Only those you specifically allow.
+ - Anybody in your address book.
+ - Anybody on this website.
+ - Anybody in this network.
+ - Anybody authenticated.
+ - Anybody on the Internet.
+
+
+[b]Public and Private Forums[/b]
+
+Forums are typically channels which may be open to participation from multiple authors. There are currently two mechanisms to post to forums: 1) "wall-to-wall" posts and 2) via forum @mention tags. Forums can be created by anybody and used for any purpose. The directory contains an option to search for public forums. Private forums can only be posted to and often only seen by members.
+
+
+[b]Account Cloning[/b]
+
+Accounts in the $Projectname are referred to as [i]nomadic identities[/i], because a member's identity is not bound to the hub where the identity was originally created. For example, when you create a Facebook or Gmail account, it is tied to those services. They cannot function without Facebook.com or Gmail.com.
+
+By contrast, say you've created a Red identity called [b]tina@redhub.com[/b]. You can clone it to another Red hub by choosing the same, or a different name: [b]liveForever@Some$ProjectnameHub.info[/b]
+
+Both channels are now synchronized, which means all your contacts and preferences will be duplicated on your clone. It doesn't matter whether you send a post from your original hub, or the new hub. Posts will be mirrored on both accounts.
+
+This is a rather revolutionary feature, if we consider some scenarios:
+
+ - What happens if the hub where an identity is based suddenly goes offline? Without cloning, a member will not be able to communicate until that hub comes back online (no doubt many of you have seen and cursed the Twitter "Fail Whale"). With cloning, you just log into your cloned account, and life goes on happily ever after.
+
+ - The administrator of your hub can no longer afford to pay for his free and public $Projectname hub. He announces that the hub will be shutting down in two weeks. This gives you ample time to clone your identity(ies) and preserve your Red relationships, friends and content.
+
+ - What if your identity is subject to government censorship? Your hub provider may be compelled to delete your account, along with any identities and associated data. With cloning, the $Projectname offers [b]censorship resistance[/b]. You can have hundreds of clones, if you wanted to, all named different, and existing on many different hubs, strewn around the internet.
+
+Red offers interesting new possibilities for privacy. You can read more at the <<Private Communications Best Practices>> page.
+
+Some caveats apply. For a full explanation of identity cloning, read the <HOW TO CLONE MY IDENTITY>.
+
+[b]Multiple Profiles[/b]
+
+Any number of profiles may be created containing different information and these may be made visible to certain of your connections/friends. A "default" profile can be seen by anybody and may contain limited information, with more information available to select groups or people. This means that the profile (and site content) your beer-drinking buddies see may be different than what your co-workers see, and also completely different from what is visible to the general public.
+
+[b]Account Backup[/b]
+
+Red offers a simple, one-click account backup, where you can download a complete backup of your profile(s).
+
+Backups can then be used to clone or restore a profile.
+
+[b]Account Deletion[/b]
+
+Accounts can be immediately deleted by clicking on a link. That's it. All associated content is then deleted from the matrix (this includes posts and any other content produced by the deleted profile). Depending on the number of connections you have, the process of deleting remote content could take some time but it is scheduled to happen as quickly as is practical.
+
+[b][size=20]Content Creation[/size][/b]
+
+[b]Writing Posts[/b]
+
+Red supports a number of different ways of adding rich-text content. The default is a custom variant of BBcode, tailored for use in $Projectname. You may also enable the use of Markdown if you find that easier to work with. A visual editor may also be used. The traditional visual editor for $Projectname had some serious issues and has since been removed. We are currently looking for a replacement.
+
+When creating "Websites", content may be entered in HTML, Markdown, BBcode, and/or plain text.
+
+[b]Deletion of content[/b]
+Any content created in the $Projectname remains under the control of the member (or channel) that originally created it. At any time, a member can delete a message, or a range of messages. The deletion process ensures that the content is deleted, regardless of whether it was posted on a channel's primary (home) hub, or on another hub, where the channel was remotely authenticated via Zot (the $Projectname communication and authentication protocol).
+
+[b]Media[/b]
+Similar to any other modern blogging system, social network, or a micro-blogging service, Red supports the uploading of files, embedding of videos, linking web pages.
+
+[b]Previewing/Editing[/b]
+Post can be previewed prior to sending and edited after sending.
+
+[b]Voting/Consensus[/b]
+Posts can be turned into "consensus" items which allows readers to offer feedback, which is collated into "agree", "disagree", and "abstain" counters. This lets you gauge interest for ideas and create informal surveys.
+
+
+[b]Extending $Projectname[/b]
+
+$Projectname can be extended in a number of ways, through site customisation, personal customisation, option setting, themes, and addons/plugins.
+
+[b]API[/b]
+
+An API is available for use by third-party services. This is based originally on the early Twitter API (for which hundreds of third-party tools exist). It is currently being extended to provide access to facilities and abilities which are specific to $Projectname. Access may be provided by login/password or OAuth and client registration of OAuth applications is provided.
+
+
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/first-post.bb b/sources/doc/first-post.bb
new file mode 100644
index 00000000..cf6ed5b4
--- /dev/null
+++ b/sources/doc/first-post.bb
@@ -0,0 +1,3 @@
+[size=large]Your first posting[/size]
+
+... to be written ...
diff --git a/sources/doc/git_for_non_developers.bb b/sources/doc/git_for_non_developers.bb
new file mode 100644
index 00000000..b0a62310
--- /dev/null
+++ b/sources/doc/git_for_non_developers.bb
@@ -0,0 +1,71 @@
+[b]Git For Non-Developers[/b]
+
+So you're handling a translation, or you're contributing to a theme, and every time you make a pull request you have to talk to one of the developers before your changes can be merged in?
+
+Chances are, you just haven't found a quick how-to explaining how to keep things in sync on your end. It's really very easy.
+
+After you've created a fork of the repo (just click "fork" at github), you need to clone your own copy.
+
+For the sake of examples, we'll assume you're working on a theme called redexample (which does not exist).
+
+[code]git clone https://github.com/username/red.git[/code]
+
+Once you've done that, cd into the directory, and add an upstream.
+
+[code]
+cd red
+git remote add upstream https://github.com/redmatrix/redmatrix
+[/code]
+
+From now on, you can pull upstream changes with the command
+[code]git fetch upstream[/code]
+
+Before your changes can be merged automatically, you will often need to merge upstream changes.
+
+[code]
+git merge upstream/master
+[/code]
+
+You should always merge upstream before pushing any changes, and [i]must[/i] merge upstream with any pull requests to make them automatically mergeable.
+
+99% of the time, this will all go well. The only time it won't is if somebody else has been editing the same files as you - and often, only if they have been editing the same lines of the same files. If that happens, that would be a good time to request help until you get the hang of handling your own merge conflicts.
+
+Then you just need to add your changes [code]git add view/theme/redexample/[/code]
+
+This will add all the files in view/theme/redexample and any subdirectories. If your particular files are mixed throughout the code, you should add one at a time. Try not to do git add -a, as this will add everything, including temporary files (we mostly, but not always catch those with a .gitignore) and any local changes you have, but did not intend to commit.
+
+Once you have added all the files you have changed, you need to commit them. [code]git commit[/code]
+
+This will open up an editor where you can describe the changes you have made. Save this file, and exit the editor.
+
+Finally, push the changes to your own git
+[code]git push[/code]
+
+And that's it, your repo is up to date!
+
+All you need to do now is actually create the pull request. There are two ways to do this.
+
+The easy way, if you're using Github is to simply click the green button at the top of your own copy of the repository, enter a description of the changes, and click 'create pull request'. The
+main repository, themes, and addons all have their main branch at Github, so this method can be used most of the time.
+
+Most people can stop here.
+
+Some projects in the extended RedMatrix ecosphere have no Github presence, to pull request these is a bit different - you'll have to create your pull request manually. Fortunately, this isn't
+much harder.
+
+[code]git request-pull -p [/code]
+
+Start is the name of a commit to start at. This must exist upstream. Normally, you just want master.
+
+URL is the URL of [i]your[/i] repo.
+
+One can also specify . This defaults to HEAD.
+
+Example:
+[code]
+git request-pull master https://example.com/project
+[/code]
+
+And simply send the output to the project maintainer.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/hidden_configs.bb b/sources/doc/hidden_configs.bb
new file mode 100644
index 00000000..76213851
--- /dev/null
+++ b/sources/doc/hidden_configs.bb
@@ -0,0 +1,139 @@
+[b]Advanced Configurations for Administrators[/b]
+
+$Projectname contains many configuration options hidden from the main admin panel.
+
+These are generally options considered too niche, confusing, or advanced for
+the average member. These settings can be activated from the the top level Red
+directory with the syntax [code]util/config cat key value[/code] for a site
+configuration, or [code]util/pconfig channel_id cat key value[/code] for a
+member configuration.
+
+This document assumes you're an administrator.
+
+[b]pconfig[/b]
+ [b]system > user_scalable[/b]
+ Determine if the app is scalable on touch screens. Defaults to on, to
+ disable, set to zero - real zero, not just false.
+ [b]system > always_my_theme[/b]
+ Always use your own theme when viewing channels on the same hub. This
+ will break in some quite imaginative ways when viewing channels with
+ theme dependent Comanche.
+ [b]system > paranoia[/b]
+ Sets the security level of IP checking. If the IP address of a logged-in session changes
+ apply this level to determine if the account should be logged out as a security breach.
+ Options are:
+ 0 - no IP checking
+ 1 - check 3 octets
+ 2 - check 2 octets
+ 3 - check for any difference at all
+ [b]system > prevent_tag_hijacking[/b]
+ Prevent foreign networks hijacking hashtags in your posts and directing them at its own resources.
+ [b]system > blocked[/b]
+ An array of xchans blocked by this channel. Technically, this is a
+ hidden config and does belong here, however, addons (notably
+ superblock) have made this available in the UI.
+ [b]system > default_cipher[/b]
+ Set the default cipher used for E2EE items.
+ [b]system > network_page_default[/b]
+ Set default params when viewing the network page. This should contain
+ the same querystring as manual filtering.
+ [b]system > display_friend_count[/b]
+ Set the number of connections to display in the connections profile
+ widget.
+ [b]system > taganyone[/b]
+ Requires the config of the same name to be enabled. Allow the @mention tagging
+ of anyone, whether you are connected or not. This doesn't scale.
+ [b]system > startpage[/b]
+ Another of those technically hidden configs made available by addons.
+ Sets the default page to view when logging in. This is exposed to the
+ UI by the startpage addon.
+ [b]system > forcepublicuploads[/b]
+ Force uploaded photos to be public when uploaded as wall items. It
+ makes far more sense to just set your permissions properly in the first
+ place. Do that instead.
+ [b]system > do_not_track[/b]
+ As the browser header. This will break many identity based features.
+ You should really just set permissions that make sense.
+
+[b]Site config[/b]
+ [b]system > taganyone[/b]
+ Allow the @mention tagging of anyone whether you are connected or not.
+ [b]system > directorytags[/b]
+ Set the number of keyword tags displayed on the directory page.
+ [b]system > startpage[/b]
+ Set the default page to be taken to after a login for all channels at
+ this website. Can be overwritten by user settings.
+ [b]system > projecthome[/b]
+ Set the project homepage as the homepage of your hub.
+ [b]system > workflowchannelnext[/b]
+ The page to direct users to immediately after creating a channel.
+ [b]system > max_daily_registrations[/b]
+ Set the maximum number of new registrations allowed on any day.
+ Useful to prevent oversubscription after a bout of publicity
+ for the project.
+ [b]system > tos_url[/b]
+ Set an alternative link for the ToS location.
+ [b]system > block_public_search[/b]
+ Similar to block_public, except only blocks public access to
+ search features. Useful for sites that want to be public, but
+ keep getting hammered by search engines.
+ [b]system > paranoia[/b]
+ As the pconfig, but on a site-wide basis. Can be overwritten
+ by member settings.
+ [b]system > openssl_conf_file[/b]
+ Specify a file containing OpenSSL configuration. Read the code first.
+ If you can't read the code, don't play with it.
+ [b]system > optimize_items[/b]
+ Runs optimise_table during some tasks to keep your database nice and
+ defragmented. This comes at a performance cost while the operations
+ are running, but also keeps things a bit faster while it's not.
+ There also exist CLI utilities for performing this operation, which you
+ may prefer, especially if you're a large site.
+ [b]system > expire_limit
+ Don't expire any more than this number of posts per channel per
+ expiration run to keep from exhausting memory. Default 5000.
+ [b]system > dlogfile[/b]
+ Logfile to use for logging development errors. Exactly the same as
+ logger otherwise. This isn't magic, and requires your own logging
+ statements. Developer tool.
+ [b]system > authlog[/b]
+ Logfile to use for logging auth errors. Used to plug in to server
+ side software such as fail2ban. Auth failures are still logged to
+ the main logs as well.
+ [b]system > hide_in_statistics[/b]
+ Tell the red statistics servers to completely hide this hub in hub lists.
+ [b]system > reserved_channels[/b]
+ Don't allow members to register channels with this comma separated
+ list of names (no spaces)
+ [b]system > auto_follow[/b]
+ Make the first channel of an account auto-follow channels listed here - comma separated list of webbies (member@hub addresses).
+ [b]system > admin_email[/b]
+ Specifies the administrator's email for this site. This is initially set during install.
+ [b]system > cron_hour[/b]
+ Specify an hour in which to run cron_daily. By default with no config, this will run at midnight UTC.
+ [b]system > minimum_feedcheck_minutes[/b]
+ The minimum interval between polling RSS feeds. If this is lower than the cron interval, feeds will be polled with each cronjob
+ [b]system > blacklisted_sites[/b]
+ An array of specific hubs to block from this hub completely.
+ [b]system > ignore_imagick[/b]
+ Ignore imagick and use GD, even if imagick is installed on the server. Prevents some issues with PNG files in older versions of imagick.
+ [b]system > no_age_restriction[/b]
+ Do not restrict registration to people over the age of 13. This carries legal responsibilities in many countries to require that age be provided and to block all personal information from minors, so please check your local laws before changing.
+ [b]system > override_poll_lockfile[/b]
+ Ignore the lock file in the poller process to allow more than one process to run at a time.
+ [b]system > projecthome[/b]
+ Display the project page on your home page for logged out viewers.
+ [b]system > sellpage[/b]
+ A URL shown in the public sites list to sell your hub - display service classes, etc.
+ [b]randprofile > check[/b]
+ When requesting a random profile, check that it actually exists first
+ [b]randprofile > retry[/b]
+ Number of times to retry getting a random profile
+ [b]system > photo_cache_time[/b]
+ How long to cache photos, in seconds. Default is 86400 (1 day).
+ Longer time increases performance, but it also means it takes longer for changed permissions to apply.
+ [b]system > poco_rating_enable[/b]
+ Distributed reputation reporting and data collection may be disabled. If your site does not participate in distributed reputation you will also not be able to make use of the data from your connections on other sites. By default and in the absence of any setting it is enabled. Individual members can opt out by restricting who can see their connections or by not providing any reputation information for their connections.
+
+#include doc/macros/main_footer.bb;
+
diff --git a/sources/doc/history.md b/sources/doc/history.md
new file mode 100644
index 00000000..32917712
--- /dev/null
+++ b/sources/doc/history.md
@@ -0,0 +1,50 @@
+Redmatrix History
+=================
+
+Redmatrix is a collaborative effort by the Redmatrix community and based on work introduced in Friendica by the Friendica community. The core design, the project mission, and software base itself were created/written primarily by Mike Macgirvin and represent the culmination of over a decade of software design using variations of this platform and an evolving vision of the role of communication software in our lives. Many others have contributed to this work, both conceptually and in terms of actual code (way too many to list individually).
+
+##Mike Macgirvin -- Biography
+
+Mike Macgirvin is an American software engineer now living in Australia. He spent his early adult years designing and repairing semiconductor fabrication equipment for a number of companies as a self-described "machine wizard". In 1985 he became a research engineer at Stanford University for the Gravity Probe-B space mission and soon became a Unix systems administrator writing communication software and utilities; and becoming an expert in emerging internet technologies such as the now ubiquitous "World Wide Web". He authored an email "client" called "ML" which pioneered some advanced concepts in encryption, the ability to filter message streams into different "views", and multi-protocol support; and was an active proponent of and participant in the open source software *movement*. In 1996 he went to Netscape Communications to become tech lead on their Messaging Server and integrate this with Collabra (groupware) into a comprehensive communications server package. He stayed on after Netscape was acquired by America Online and was tech manager of the Groups@AOL project until 2001.
+
+During a layoff round, Mike was let go from America Online in August 2001 and purchased a music store in Mountain View, California later to be known as "Sonica Music Company". Opening a retail store for non-essential goods at the beginning of a prolonged economic downturn was in retrospect probably not the wisest career move. Sonica eventually folded; in late 2006. Mike returned to working on software and systems support full-time and was employed briefly at Symantec before moving to Australia in early 2007. He currently lives on a farm "out in the middle of nowhere" and is employed as a Computer Systems Officer at the University of Wollongong.
+
+
+##Redmatrix - The Early Years
+
+The software which went into creating Redmatrix has been through three distinct historical phases. It began in 2003 when Mike Macgirvin was looking for a content management system to power the website for his music store and found the available solutions to be lacking in various respects. The project was born as the "PurpleHaze weblog" under the nom de plume "Nerdware Communications". It was a multi-user PHP/MySQL CMS which provided blogs, forums, photo albums, events and more. Initially it provided the basis for a social community and shopping for customers of the store, but was also linked to Mike's personal weblog running on another domain. The distinguishing characteristic of this software was the ability for so-called "normal users" to re-assemble the components and choose different content feeds - and in essence create their own personal "multi-user CMS" as a view. Their custom view was able to communicate with anybody else that used the system, but could be partitioned so that adult sites and motorcycle enthusiast sites would not be visible to each other and not clash (or in this case Mike's personal website and the music store website). This software was developed primarily from 2003 until 2008.
+
+In 2006 this software was used as the prototype for Symantec's "safeweb" reputation and community site. It was developed and enhanced until about 2008. A rewrite took place in 2008 named "Reflection" but work stagnated as the community dwindled. The need for content management systems and communications software dropped dramatically during this time as humans flocked to the new social aggregrators - Facebook and Twitter.
+
+
+##Mistpark/Friendica
+
+In early 2010, Mike left Facebook, concerned at the company's increasing hold and control of personal information. In his words "Companies die. We watched it happen in the dot-com years. When they do, their databases are sold to the highest bidder.". Mike used some remnants of the old CMS project to create a decentralised social communications platform. This was launched in July 2010 as "Mistpark". The name was chosen as a tribute to his new home in the Southern Highlands of Australia. The key innovation in this project was the ability to authenticate remotely and invisibly to other decentralised instances of the software so to allow remote viewing of private photos and provide "wall-to-wall" posting across website instances. The lack of simple remote identity *provenance* was a serious limitation of other decentralised communication protocols.
+
+In late 2010, the name was changed to "Friendika". The name Friendika had some symbolic issues, since the suffix was common with "swastika" and "Amerika", both having negative connotations, however the dot-com domain was available. Friendica was in fact the first choice but the 'friendica.com' domain name was already registered. It became available a year later and the project was renamed to Friendica in late 2011.
+
+Soon after version 1 was released in July 2010 - providing basic social communications, the software also took on a new role - cross-service federation; which was first introduced in August and September 2010. Federation allowed the software to "behave as" a StatusNet site and friends and messages could communicate to the other service from their own platforms. It was also hoped to provide federation with Diaspora - a project with similar scope being developed in secret in New York and first released in November of that year. Over the course of the next year, the federation ability was extended to provide integrated communications from RSS feeds, to and from email, StatusNet, Facebook, Twitter, and the emerging Diaspora project. The software provided a single "view" of your entire social space no matter what provider you or your friends used. StatusNet and Diaspora were supported natively so that one account could access any of these services. Facebook and Twitter used "API federation" which required the person to have an account on those services with which to link.
+
+By July 2012, Twitter and Facebook had both changed their terms of service and essentially outlawed "API federation" in the way Friendica was using it. Diaspora announced they were changing their protocol and would not maintain compatibility nor provide any warning when compatibility would break (or documentation on the proposed changes). The creator of StatusNet was also leaving his project to create something new (pump.io). As the software's primary purpose by this time was "federation of different social services into one interface", this created a bit of a crisis. The federated social web was crumbling. Also of concern was that independent and decentralised social websites shut down frequently, requiring all their members to start over again on another site. Often the effort involved to do this seemed daunting - and many people ran back to the relative safety of the large corporate providers - Facebook, Twitter, and now Google+.
+
+Mike realised he did not want to be held hostage to the decisions that other projects and companies and independent websites make. Friendica could operate on its own without attaching to these other networks, but its vision and implementation of a federated social world depended on federation with others for its project identity - so this created an identity crisis.
+
+Mike had been working on this project for some time and there were a number of things which needed re-writing, including the base communication protocol which Friendica used (DFRN or the "Distributed Friends and Relations Network" protocol). These ideas were starting to emerge as a different method of communication he called "zot". Zot began as a way to create a common language for federated websites, but there was no interest in this ability and as mentioned, the federated web was crumbling. The first version was soon scrapped and zot was re-designed and re-ignited as a streamlined communication protocol which was location-independent; e.g. not tied to any website. This would allow people to carry on unaffected if their website operator shut down temporarily or permanently. They wouldn't have to make friends all over again, and permissions of everything on the system wouldn't have to be changed to allow bob@site1 to see something that was private to him, even though he was now bob@site2. This was a serious problem with decentralisation. People moved and their online identities were lost and had to be re-created from scratch and existing relationships destroyed and had to be created all over again.
+
+
+##Redmatrix
+
+In July 2012, Mike left the Friendica project and began development of "zot" and a new base project called "red" in his somewhat elusive *spare time*. Red is Spanish for "network". It wasn't really a "social network" and especially not a "federated social network". It was just Red (technically "la red"), or "the network". Work began by removing all the "federation" components and going back to basics - communication and remote authentication. It was a major re-write and took roughly six months before even basic communication was re-established. It was also no longer compatible with Friendica - which had been given to the "Friendica community" and by this time (December 2012) was developing separately on its own track.
+
+It became clear during this time that the single most compelling feature of the project wasn't the social network at all, but the authentication layer and decentralised access control mechanisms. Combined with zot's location independence it created a new model for software which had never existed previously - decentralised identity-aware web publishing and single sign-on to any compatible provider across the web. These weren't *evolutionary*, they were **revolutionary**. One of the biggest flaws of the modern web is the reliance on different passwords for every service you use, or reliance on a single provider if you were to tie them to - say your Facebook login. Facebook can remove your account at any time. Gone. If you rely on their authentication for all your websites, your entire online identity - now gone. This is also what was missing from Friendica - a compelling software feature which could stand on its own, without requiring a social network and especially without requiring a federated social network with all the mentioned external dependencies.
+
+An early visitor to the project noted that he had some difficulty finding the project on Google because of the choice of name - "red". Yes, this was a poor decision in retrospect. We were buried on page 23,712 of the search results. The concept that was emerging around this identity-aware publishing was that of "a matrix of inter-connected thought streams", since we didn't have a concept of "people" and "friends". All were just connected "channels" with different ways to connect. So "Redmatrix" was chosen to give it a searchable name. It had nothing to do with the Matrix film and red and blue pills, though that is frequently cited (erronously); and in fact isn't a bad analogy.
+
+The concept of identity-aware content was alien to anything that existed previously on the web, so to make it useful we had to provide the ability to use it for content. It needed content publishing tools. This brought back concepts from the old "Content Management System" on which the software was originally based. To get it up and running quickly we created a markup language for webpages called "Comanche" which let you describe a page in high-level terms based on bbcode tags. We also added WebDAV so you could put decentralised access control on files and drag/drop from your operating system. So now you could have private photos, webpages, files, events, conversations, chatrooms - and they are visible to those you choose - no matter what site they use. All they need is zot. And your viewers could move to another site or just pop up at a different site any time they want and we don't care. And it **also** had a built-in social network; with lots of additional privacy and encryption features which were added even before the Snowden revelations gave them added urgency.
+
+Over time a few federation components re-emerged. The ability to view RSS feeds was important to many people. Diaspora never really managed to re-write their protocol, so that was re-implemented and allowed Redmatrix to connect with Diaspora and Friendica again (Friendica still had their Diaspora protocol intact, so this was the most common language now remaining on the free web - despite its faults). Diaspora communications aren't able to make use of the advanced identity features, but they work for basic communications.
+
+Mike stepped down as active coordinator for the project in early 2015.
+
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/html/index.php b/sources/doc/html/index.php
new file mode 100644
index 00000000..4ef28aad
--- /dev/null
+++ b/sources/doc/html/index.php
@@ -0,0 +1,22 @@
+
+
+
+<<<<<<< HEAD
+ Hubzilla Doxygen API Documentation
+
+
+
Hubzilla Doxygen API Documentation not rendered
+=======
+ $Projectname Doxygen API Documentation
+
+
+
$Projectname Doxygen API Documentation not rendered
+>>>>>>> f866a42a42b9e12756353f5bb39a0f31a64bb26a
+To get the Doxygen API Documentation you must render it with the program Doxygen (included in most distributions).
+
+$ doxygen util/Doxyfile
+
+
+back
+
+
diff --git a/sources/doc/install.bb b/sources/doc/install.bb
new file mode 100644
index 00000000..e68b4a23
--- /dev/null
+++ b/sources/doc/install.bb
@@ -0,0 +1,4 @@
+#include install/INSTALL.txt;
+
+#include doc/macros/main_footer.bb;
+
diff --git a/sources/doc/install/sample-lighttpd.conf b/sources/doc/install/sample-lighttpd.conf
new file mode 100644
index 00000000..db26c3b6
--- /dev/null
+++ b/sources/doc/install/sample-lighttpd.conf
@@ -0,0 +1,90 @@
+# See http://redmine.lighttpd.net/projects/lighttpd/wiki/Docs:ConfigurationOptions
+
+### LOAD MODULES
+server.modules = (
+ "mod_access",
+ "mod_accesslog",
+ "mod_fastcgi",
+ "mod_redirect",
+ "mod_rewrite"
+)
+
+### BASIC STUFF
+server.port = 80
+
+server.username = "http"
+
+server.groupname = "http"
+
+server.document-root = "/path/to/your/www/files" #adjust to your setup
+
+server.errorlog = "/var/log/lighttpd/error.log"
+
+accesslog.filename = "/var/log/lighttpd/access.log"
+
+### DISABLE DIR LISTING
+dir-listing.activate = "disable"
+
+### DISABLE REJECT EXPECT HEADER
+### (needed for curl POST requests - otherwise they fail with error 417)
+server.reject-expect-100-with-417 = "disable"
+
+### DEFINE SUPPORTED INDEX FILENAMES
+index-file.names = (
+ "index.html",
+ "index.htm",
+ "index.php"
+)
+
+### DEFINE SUPPORTED MIME TYPES
+mimetype.assign = (
+ ".html" => "text/html",
+ ".htm" => "text/html",
+ ".css" => "text/css",
+ ".txt" => "text/plain",
+ ".svg" => "image/svg+xml",
+ ".jpg" => "image/jpeg",
+ ".png" => "image/png"
+)
+
+### DONT EVER SERVE FILES WITH EXTENSION
+static-file.exclude-extensions = ( ".php" )
+
+### PHP WITH PHP-FPM
+### (needs php-fpm installed and running)
+fastcgi.server = (
+ ".php" => (
+ "localhost" => (
+ "socket" => "/run/php-fpm/php-fpm.sock",
+ "broken-scriptfilename" => "enable",
+ "allow-x-sendfile" => "enable"
+ )
+ )
+)
+
+### ENABLE SSL
+$SERVER["socket"] == ":443" {
+ ssl.engine = "enable"
+ ssl.ca-file = "/etc/lighttpd/certs/ca-certs.crt" #adjust to your needs
+ ssl.pemfile = "/etc/lighttpd/certs/red-ssl.crt" #adjust to your needs
+
+ ssl.use-compression = "disable"
+ ssl.use-sslv2 = "disable"
+ ssl.use-sslv3 = "disable"
+ ssl.cipher-list = "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA"
+}
+
+### RISTRICT ACCESS TO DIRECTORYS AND FILES
+$HTTP["url"] =~ "\.(out|log|htaccess)$" {
+ url.access-deny = ("")
+}
+
+$HTTP["url"] =~ "(^|/)\.git|(^|/)store" {
+ url.access-deny = ("")
+}
+
+### URL REWRITE RULES
+url.rewrite-if-not-file = (
+ "^\/([^\?]*)\?(.*)$" => "/index.php?q=$1&$2",
+ "^\/(.*)$" => "/index.php?q=$1"
+)
diff --git a/sources/doc/install/sample-nginx.conf b/sources/doc/install/sample-nginx.conf
new file mode 100644
index 00000000..e9a80d22
--- /dev/null
+++ b/sources/doc/install/sample-nginx.conf
@@ -0,0 +1,142 @@
+##
+# Red Nginx configuration
+# by Olaf Conradi
+#
+# On Debian based distributions you can add this file to
+# /etc/nginx/sites-available
+#
+# Then customize to your needs. To enable the configuration
+# symlink it to /etc/nginx/sites-enabled and reload Nginx using
+#
+# service nginx reload
+##
+
+##
+# You should look at the following URL's in order to grasp a solid understanding
+# of Nginx configuration files in order to fully unleash the power of Nginx.
+#
+# http://wiki.nginx.org/Pitfalls
+# http://wiki.nginx.org/QuickStart
+# http://wiki.nginx.org/Configuration
+##
+
+##
+# This configuration assumes your domain is example.net
+# You have a separate subdomain red.example.net
+# You want all red traffic to be https
+# You have an SSL certificate and key for your subdomain
+# You have PHP FastCGI Process Manager (php5-fpm) running on localhost
+# You have Red installed in /var/www/red
+##
+
+server {
+ listen 80;
+ server_name red.example.net;
+
+ index index.php;
+ root /var/www/red;
+ rewrite ^ https://red.example.net$request_uri? permanent;
+}
+
+##
+# Configure Red with SSL
+#
+# All requests are routed to the front controller
+# except for certain known file types like images, css, etc.
+# Those are served statically whenever possible with a
+# fall back to the front controller (needed for avatars, for example)
+##
+
+server {
+ listen 443 ssl;
+ server_name red.example.net;
+
+ ssl on;
+ ssl_certificate /etc/nginx/ssl/red.example.net.chain.pem;
+ ssl_certificate_key /etc/nginx/ssl/example.net.key;
+ ssl_session_timeout 5m;
+ ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
+ ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-DSS-AES128-SHA256:DHE-DSS-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA:!DHE-RSA-AES128-GCM-SHA256:!DHE-RSA-AES256-GCM-SHA384:!DHE-RSA-AES128-SHA256:!DHE-RSA-AES256-SHA:!DHE-RSA-AES128-SHA:!DHE-RSA-AES256-SHA256:!DHE-RSA-CAMELLIA128-SHA:!DHE-RSA-CAMELLIA256-SHA;
+ ssl_prefer_server_ciphers on;
+
+ fastcgi_param HTTPS on;
+
+ index index.php;
+ charset utf-8;
+ root /var/www/red;
+ access_log /var/log/nginx/red.log;
+ #Uncomment the following line to include a standard configuration file
+ #Note that the most specific rule wins and your standard configuration
+ #will therefore *add* to this file, but not override it.
+ #include standard.conf
+ # allow uploads up to 20MB in size
+ client_max_body_size 20m;
+ client_body_buffer_size 128k;
+
+ # rewrite to front controller as default rule
+ location / {
+ if ($is_args != "") {
+ rewrite ^/(.*) /index.php?q=$uri&$args last;
+ }
+ rewrite ^/(.*) /index.php?q=$uri last;
+ }
+
+ # make sure webfinger and other well known services aren't blocked
+ # by denying dot files and rewrite request to the front controller
+ location ^~ /.well-known/ {
+ allow all;
+ rewrite ^/(.*) /index.php?q=$uri&$args last;
+ }
+
+ # statically serve these file types when possible
+ # otherwise fall back to front controller
+ # allow browser to cache them
+ # added .htm for advanced source code editor library
+ location ~* \.(jpg|jpeg|gif|png|ico|css|js|htm|html|ttf|woff|svg)$ {
+ expires 30d;
+ try_files $uri /index.php?q=$uri&$args;
+ }
+
+ # block these file types
+ location ~* \.(tpl|md|tgz|log|out)$ {
+ deny all;
+ }
+
+ # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
+ # or a unix socket
+ location ~* \.php$ {
+ # Zero-day exploit defense.
+ # http://forum.nginx.org/read.php?2,88845,page=3
+ # Won't work properly (404 error) if the file is not stored on this
+ # server, which is entirely possible with php-fpm/php-fcgi.
+ # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on
+ # another machine. And then cross your fingers that you won't get hacked.
+ try_files $uri =404;
+
+ # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
+ fastcgi_split_path_info ^(.+\.php)(/.+)$;
+
+ # With php5-cgi alone:
+ # fastcgi_pass 127.0.0.1:9000;
+
+ # With php5-fpm:
+ fastcgi_pass unix:/var/run/php5-fpm.sock;
+
+ include fastcgi_params;
+ fastcgi_index index.php;
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+ }
+
+ # deny access to all dot files
+ location ~ /\. {
+ deny all;
+ }
+
+#deny access to store
+
+ location ~ /store {
+ deny all;
+ }
+
+
+}
diff --git a/sources/doc/intro_for_developers.bb b/sources/doc/intro_for_developers.bb
new file mode 100644
index 00000000..b8a4e4eb
--- /dev/null
+++ b/sources/doc/intro_for_developers.bb
@@ -0,0 +1,114 @@
+[b]Red Developer Guide[/b]
+
+[b]File system layout:[/b]
+
+[addon] optional addons/plugins
+
+[boot.php] Every process uses this to bootstrap the application structure
+
+[doc] Help Files
+
+[images] core required images
+
+[include] The "model" in MVC - (back-end functions), also contains PHP "executables" for background processing
+
+[index.php] The front-end controller for web access
+
+[install] Installation and upgrade files and DB schema
+
+[library] Third party modules (must be license compatible)
+
+[mod] Controller modules based on URL pathname (e.g. #^[url=http://sitename/foo]http://sitename/foo[/url] loads mod/foo.php)
+
+[mod/site/] site-specific mod overrides, excluded from git
+
+[util] translation tools, main English string database and other miscellaneous utilities
+
+[version.inc] contains current version (auto-updated via cron for the master repository and distributed via git)
+
+[view] theming and language files
+
+[view/(css,js,img,php,tpl)] default theme files
+
+[view/(en,it,es ...)] language strings and resources
+
+[view/theme/] individual named themes containing (css,js,img,php,tpl) over-rides
+
+[b]The Database:[/b]
+
+ [li]abook - contact table, replaces Friendica 'contact'[/li]
+ [li]account - service provider account[/li]
+ [li]addon - registered plugins[/li]
+ [li]app - peronal app data[/li]
+ [li]attach - file attachments[/li]
+ [li]auth_codes - OAuth usage[/li]
+ [li]cache - OEmbed cache[/li]
+ [li]channel - replaces Friendica 'user'[/li]
+ [li]chat - chat room content[/li]
+ [li]chatpresence - channel presence information for chat[/li]
+ [li]chatroom - data for the actual chat room[/li]
+ [li]clients - OAuth usage[/li]
+ [li]config - main configuration storage[/li]
+ [li]conv - Diaspora private messages[/li]
+ [li]event - Events[/li]
+ [li]fcontact - friend suggestion stuff[/li]
+ [li]ffinder - friend suggestion stuff[/li]
+ [li]fserver - obsolete[/li]
+ [li]fsuggest - friend suggestion stuff[/li]
+ [li]groups - privacy groups[/li]
+ [li]group_member - privacy groups[/li]
+ [li]hook - plugin hook registry[/li]
+ [li]hubloc - Red location storage, ties a location to an xchan[/li]
+ [li]item - posts[/li]
+ [li]item_id - other identifiers on other services for posts[/li]
+ [li]likes - likes of 'things'[/li]
+ [li]mail - private messages[/li]
+ [li]manage - may be unused in Red, table of accounts that can "su" each other[/li]
+ [li]menu - channel menu data[/li]
+ [li]menu_item - items uses by channel menus[/li]
+ [li]notify - notifications[/li]
+ [li]notify-threads - need to factor this out and use item thread info on notifications[/li]
+ [li]obj - object data for things (x has y)[/li]
+ [li]outq - Red output queue[/li]
+ [li]pconfig - personal (per channel) configuration storage[/li]
+ [li]photo - photo storage[/li]
+ [li]poll - data for polls[/li]
+ [li]poll_elm - data for poll elements[/li]
+ [li]profdef - custom profile field definitions[/li]
+ [li]profext - custom profile field data[/li]
+ [li]profile - channel profiles[/li]
+ [li]profile_check - DFRN remote auth use, may be obsolete[/li]
+ [li]register - registrations requiring admin approval[/li]
+ [li]session - web session storage[/li]
+ [li]shares - shared item information[/li]
+ [li[sign - Diaspora signatures. To be phased out.[/li]
+ [li]site - site table to find directory peers[/li]
+ [li]source - channel sources data[/li]
+ [li]spam - unfinished[/li]
+ [li]sys_perms - extensible permissions for the sys channel[/li]
+ [li]term - item taxonomy (categories, tags, etc.) table[/li]
+ [li]tokens - OAuth usage[/li]
+ [li]updates - directory sync updates[/li]
+ [li]verify - general purpose verification structure[/li]
+ [li]vote - vote data for polls[/li]
+ [li]xchan - replaces 'gcontact', list of known channels in the universe[/li]
+ [li]xchat - bookmarked chat rooms[/li]
+ [li]xconfig - as pconfig but for channels with no local account[/li]
+ [li]xlink - "friends of friends" linkages derived from poco[/li]
+ [li]xprof - if this hub is a directory server, contains basic public profile info of everybody in the network[/li]
+ [li]xtag - if this hub is a directory server, contains tags or interests of everybody in the network[/li]
+
+
+[b]How to theme Red - by Olivier Migeot[/b]
+
+This is a short documentation on what I found while trying to modify Red's appearance.
+
+First, you'll need to create a new theme. This is in /view/theme, and I chose to copy 'redbasic' since it's the only available for now. Let's assume I named it .
+
+Oh, and don't forget to rename the _init function in /php/theme.php to be _init() instead of redbasic_init().
+
+At that point, if you need to add javascript or css files, add them to /js or /css, and then "register" them in _init() through head_add_js('file.js') and head_add_css('file.css').
+
+Now you'll probably want to alter a template. These can be found in in /view/tpl OR view//tpl. All you should have to do is copy whatever you want to tweak from the first place to your theme's own tpl directory.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/macros/addons_footer.bb b/sources/doc/macros/addons_footer.bb
new file mode 100644
index 00000000..32814c59
--- /dev/null
+++ b/sources/doc/macros/addons_footer.bb
@@ -0,0 +1,2 @@
+Return to the [zrl=[baseurl]/help/addons]Addons documentation[/zrl]
+Return to the [zrl=[baseurl]/help/main]Main documentation[/zrl]
diff --git a/sources/doc/macros/cloud_footer.bb b/sources/doc/macros/cloud_footer.bb
new file mode 100644
index 00000000..798cc9ea
--- /dev/null
+++ b/sources/doc/macros/cloud_footer.bb
@@ -0,0 +1,2 @@
+Return to the [zrl=[baseurl]/help/cloud]Cloud documentation[/zrl]
+Return to the [zrl=[baseurl]/help/main]Main documentation page[/zrl]
diff --git a/sources/doc/macros/de/addons_footer.bb b/sources/doc/macros/de/addons_footer.bb
new file mode 100644
index 00000000..068bb7ec
--- /dev/null
+++ b/sources/doc/macros/de/addons_footer.bb
@@ -0,0 +1,2 @@
+Zurück zur [zrl=[baseurl]/help/addons]Addons-Hilfe[/zrl]
+Zurück zur [zrl=[baseurl]/help/main]Hilfe-Startseite[/zrl]
diff --git a/sources/doc/macros/de/cloud_footer.bb b/sources/doc/macros/de/cloud_footer.bb
new file mode 100644
index 00000000..921448a3
--- /dev/null
+++ b/sources/doc/macros/de/cloud_footer.bb
@@ -0,0 +1,2 @@
+Zurück zur [zrl=[baseurl]/help/cloud]Cloud-Hilfe[/zrl]
+Zurück zur [zrl=[baseurl]/help/main]Hilfe-Startseite[/zrl]
diff --git a/sources/doc/macros/de/main_footer.bb b/sources/doc/macros/de/main_footer.bb
new file mode 100644
index 00000000..e7160362
--- /dev/null
+++ b/sources/doc/macros/de/main_footer.bb
@@ -0,0 +1 @@
+Zurück zur [zrl=[baseurl]/help/main]Hilfe-Startseite[/zrl]
diff --git a/sources/doc/macros/de/troubleshooting_footer.bb b/sources/doc/macros/de/troubleshooting_footer.bb
new file mode 100644
index 00000000..be8c13a2
--- /dev/null
+++ b/sources/doc/macros/de/troubleshooting_footer.bb
@@ -0,0 +1,2 @@
+Zurück zur [zrl=[baseurl]/help/troubleshooting]Troubleshooting-Startseite[/zrl]
+Zurück zur [zrl=[baseurl]/help/troubleshooting]Hilfe-Startseite[/zrl]
diff --git a/sources/doc/macros/main_footer.bb b/sources/doc/macros/main_footer.bb
new file mode 100644
index 00000000..08f671de
--- /dev/null
+++ b/sources/doc/macros/main_footer.bb
@@ -0,0 +1 @@
+Return to the [zrl=[baseurl]/help/main]Main documentation page[/zrl]
diff --git a/sources/doc/macros/troubleshooting_footer.bb b/sources/doc/macros/troubleshooting_footer.bb
new file mode 100644
index 00000000..c7603a62
--- /dev/null
+++ b/sources/doc/macros/troubleshooting_footer.bb
@@ -0,0 +1,2 @@
+[zrl=[baseurl]/help/troubleshooting]Troubleshooting documentation[/zrl]
+[zrl=[baseurl]/help/troubleshooting]Documentation Main Page[/zrl]
diff --git a/sources/doc/main.bb b/sources/doc/main.bb
new file mode 100644
index 00000000..6998ee90
--- /dev/null
+++ b/sources/doc/main.bb
@@ -0,0 +1,86 @@
+
+[zrl=[baseurl]/help/about][b]What is $Projectname?[/b][/zrl]
+$Projectname is a decentralized communication and publishing platform that enables you to keep in control of your communication needs by automatic encryption and finely grained access control. It's you, and only you who decides who is allowed to see your stuff.
+
+[zrl=[baseurl]/help/features][b]$Projectname Features[/b][/zrl]
+
+$Projectname is already running as a global distributed network and proves its versatility and scalability from standalone to huge sites on a daily basis.
+Think of standalone family communication platforms, distributed online communities, support forums, blogs and homepages. Or professional content providers with commercial premium channels and targeted content acces. Whatever you want, the $Projectname is there to cater to your creativity.
+
+[zrl=[baseurl]/help/what_is_zot][b]Got Zot? Well, you should.[/b][/zrl]
+Zot is the great new communicaton protocol invented especially for $Projectname. As a member you are no longer bound to a single site or hub thanks to "Nomadic Identities". Migrate easily to another server and keep your contacts intact, or clone it and run the same channel on several servers. Just in case one of them might shut down, you don't lose out. Plus once you are inside $Projectname there is no need for you to authenticate twice, even when accessing another $Projectname site. Zot is what sets $Projectname apart.
+
+[h3]Getting Started[/h3]
+[zrl=[baseurl]/help/Privacy]Privacy Policy[/zrl]
+[zrl=[baseurl]/help/registration]Account Registration[/zrl]
+[zrl=[baseurl]/help/accounts_profiles_channels_basics]You at the $Projectname: accounts, profiles and channels in short[/zrl]
+[zrl=[baseurl]/help/profiles]Profiles[/zrl]
+[zrl=[baseurl]/help/channels]Channels[/zrl]
+[zrl=[baseurl]/help/roles]Permission roles and Channel types[/zrl]
+[zrl=[baseurl]/help/first-post]Your first posting[/zrl]
+[zrl=[baseurl]/help/connecting_to_channels]Connecting To Other Channels[/zrl]
+[zrl=[baseurl]/help/permissions]Permissions And Encryption: You Are In Control[/zrl]
+[zrl=[baseurl]/help/cloud]Cloud Storage[/zrl]
+[zrl=[baseurl]/help/remove_account]Remove Channel or Account[/zrl]
+
+[h3]Members Help[/h3]
+[zrl=[baseurl]/help/tags_and_mentions]Tags and Mentions[/zrl]
+[zrl=[baseurl]/help/webpages]Web Pages[/zrl]
+[zrl=[baseurl]/help/bbcode]BBcode reference for posts and comments[/zrl]
+[zrl=[baseurl]/help/checking_account_quota_usage]Checking Account Quota Usage[/zrl]
+[zrl=[baseurl]/help/cloud_desktop_clients]Cloud Desktop Clients[/zrl]
+[zrl=[baseurl]/help/AdvancedSearch]Advanced Directory Search[/zrl]
+[zrl=[baseurl]/help/addons]Help With Addons[/zrl]
+[zrl=[baseurl]/help/diaspora_compat]Diaspora Communications Compatibility (Diaspora and Friendica)[/zrl]
+[zrl=[baseurl]/help/faq_members]FAQ For Members[/zrl]
+
+[h3]Administrators Help[/h3]
+[zrl=[baseurl]/help/install]Install[/zrl]
+[zrl=[baseurl]/help/red2pi]Installing Red on the Raspberry Pi[/zrl]
+[zrl=[baseurl]/help/troubleshooting]Troubleshooting Tips[/zrl]
+[zrl=[baseurl]/help/hidden_configs]Tweaking $Projectname's Hidden Configurations[/zrl]
+[zrl=[baseurl]/help/faq_admins]FAQ For Admins[/zrl]
+[zrl=[baseurl]/help/service_classes]Service Classes[/zrl]
+
+[h3]Technical Documentation[/h3]
+[zrl=[baseurl]/help/history]$Projectname history[/zrl]
+[zrl=[baseurl]/help/Zot---A-High-Level-Overview]A high level overview of Zot[/zrl]
+[zrl=[baseurl]/help/zot]An introduction to Zot[/zrl]
+[zrl=[baseurl]/help/zot_structures]Zot Stuctures[/zrl]
+[zrl=[baseurl]/help/comanche]Comanche Page Descriptions[/zrl]
+[zrl=[baseurl]/help/Creating-Templates]Creating Comanche Templates[/zrl]
+[zrl=[baseurl]/help/Widgets]Widgets[/zrl]
+[zrl=[baseurl]/help/plugins]Plugins[/zrl]
+[zrl=[baseurl]/help/doco]Contributing Documentation[/zrl]
+[zrl=[baseurl]/help/DerivedTheme1]Creating Derivative Themes[/zrl]
+[zrl=[baseurl]/help/schema_development]Schemas[/zrl]
+[zrl=[baseurl]/help/Translations]Translations[/zrl]
+[zrl=[baseurl]/help/developers]Developers[/zrl]
+[zrl=[baseurl]/help/intro_for_developers]Intro for Developers[/zrl]
+[zrl=[baseurl]/help/database]Database schema documantation[/zrl]
+[zrl=[baseurl]/help/api_functions]API functions[/zrl]
+[zrl=[baseurl]/help/api_posting]Posting to the red# using the API[/zrl]
+[zrl=[baseurl]/help/developer_function_primer]Red Functions 101[/zrl]
+[zrl=[baseurl]/doc/html/]Code Reference (Doxygen generated - sets cookies)[/zrl]
+[zrl=[baseurl]/help/to_do_doco]To-Do list for the Red Documentation Project[/zrl]
+[zrl=[baseurl]/help/to_do_code]To-Do list for Developers[/zrl]
+[zrl=[baseurl]/help/roadmap]Version 3 roadmap[/zrl]
+[zrl=[baseurl]/help/git_for_non_developers]Git for Non-Developers[/zrl]
+[zrl=[baseurl]/help/dev_beginner]Step-for-step manual for beginning developers[/zrl]
+
+[h3]Frequently Asked Questions For Developers[/h3]
+[zrl=[baseurl]/help/faq_developers]FAQ For Developers[/zrl]
+
+[h3]External Resources[/h3]
+[zrl=[baseurl]/help/external-resource-links]External Resource Links[/zrl]
+[url=https://github.com/redmatrix/hubzilla]Main Website[/url]
+[url=https://github.com/redmatrix/hubzilla-addons]Addon Website[/url]
+[url=https://zothub.com/channel/one]Development Channel[/url]
+[url=https://federated.social/channel/postgres]Postgres-specific $Projectname Admin Support Channel[/url]
+
+[url=[baseurl]/help/credits]$Projectname Credits[/url]
+
+[h3]About This $Projectname Hub[/h3]
+[zrl=[baseurl]/help/TermsOfService]Terms of Service For This Hub[/zrl]
+[zrl=[baseurl]/siteinfo]Hub Information (/siteinfo)[/zrl]
+[zrl=[baseurl]/siteinfo/json]Detailed Technical Hub Information in JSON format(/siteinfo/json)[/zrl]
diff --git a/sources/doc/nb-no/api_functions.md b/sources/doc/nb-no/api_functions.md
new file mode 100644
index 00000000..f385dee0
--- /dev/null
+++ b/sources/doc/nb-no/api_functions.md
@@ -0,0 +1,138 @@
+Red Twitter API
+===============
+
+Det "grunnleggende" Red web API-et er basert på Twitter API-et, siden dette gir umiddelbar samhandling med et stort antall tredjepartsklienter og programmer uten å kreve noen kodeendring hos disse. Det er også et super-set av StatusNet-versjonen av Twitter API-et, siden den også har bred eksisterende støtte.
+
+Red har flere muligheter som ikke vises gjennom Twitter-grensesnittene, der vi tvinges til å gjøre API-funksjoner "dummere" for å kunne arbeide med den primitive kommunikasjons- og personvernmodellen i Twitter/StatusNet. Vi planlegger å utvide Twitter-API-et slik at Red-spesifikke klienter kan ta i bruk alle funksjoner i Red uten begrensninger.
+
+Et dedikert Red API som samvirker med egne datastrukturer og tillatelser er under utvikling, og dette krever ikke oversettelse til andre personvern- og tillatelsesmodeller og lagringsformater. Denne vil bli beskrevet i andre dokumenter. Prefikset for alle egne endepunkter er 'api/red'.
+
+Red tilbyr tilgang til flere kanaler via samme innloggingskonto. Med Red vil enhver API-funksjon som krever autentisering akseptere et parameter - &channel={channel_nickname} - og vil velge den kanalen og gjøre den gjeldende før utføring av API-kommandoen. Som standard er det standardkanalen i kontoen som velges.
+
+Red tilbyr også en utvidet tillatelsesmodell. Grunnet fraværet av Red-spesifikke API kall til å angi tillatelser, så vil disse innstillingene bli satt til standardtillatelsene assosiert med den gjeldende kanalen.
+
+Red vil antakelig aldri helt kunne støtte Twitter sine 'api/friendships' funksjoner, fordi Red er ikke et sosialt nettverk og har ikke innebygget noe konsept om "vennskap" - den gjenkjenner tillatelser til å gjøre ting (eller ikke gjøre ting hvis det er det som trengs).
+
+Tegnforklaring: T= Twitter, S= StatusNet, F= Friendica, R= Red, ()=Virker ikke ennå, J= kun JSON (XML-formater er avlegs)
+
+
+
+Twitter API kompatible funksjoner:
+
+* api/account/verify_credentials T,S,F,R
+* api/statuses/update T,S,F,R
+* api/users/show T,S,F,R
+* api/statuses/home_timeline T,S,F,R
+* api/statuses/friends_timeline T,S,F,R
+* api/statuses/public_timeline T,S,F,R
+* api/statuses/show T,S,F,R
+* api/statuses/retweet T,S,F,R
+* api/statuses/destroy T,S,F,(R)
+* api/statuses/mentions T,S,F,(R)
+* api/statuses/replies T,S,F,(R)
+* api/statuses/user_timeline T,S,F,(R)
+* api/favorites T,S,F,(R)
+* api/account/rate_limit_status T,S,F,R
+* api/help/test T,S,F,R
+* api/statuses/friends T,S,F,R
+* api/statuses/followers T,S,F,R
+* api/friends/ids T,S,F,R
+* api/followers/ids T,S,F,R
+* api/direct_messages/new T,S,F,(R)
+* api/direct_messages/conversation T,S,F,(R)
+* api/direct_messages/all T,S,F,(R)
+* api/direct_messages/sent T,S,F,(R)
+* api/direct_messages T,S,F,(R)
+* api/oauth/request_token T,S,F,R
+* api/oauth/access_token T,S,F,R
+
+
+Twitter API funksjoner støttet av StatusNet men for øyeblikket ikke av Friendica eller Red
+
+* api/favorites T,S
+* api/favorites/create T,S
+* api/favorites/destroy T,S
+* api/statuses/retweets_of_me T,S
+* api/friendships/create T,S
+* api/friendships/destroy T,S
+* api/friendships/exists T,S
+* api/friendships/show T,S
+* api/account/update_location T,S
+* api/account/update_profile_background_image T,S
+* api/account/update_profile_image T,S
+* api/blocks/create T,S
+* api/blocks/destroy T,S
+
+Twitter API funksjoner som for øyeblikket ikke er støttet av StatusNet
+
+* api/statuses/retweeted_to_me T
+* api/statuses/retweeted_by_me T
+* api/direct_messages/destroy T
+* api/account/end_session T,(R)
+* api/account/update_delivery_device T
+* api/notifications/follow T
+* api/notifications/leave T
+* api/blocks/exists T
+* api/blocks/blocking T
+* api/lists T
+
+
+StatusNet kompatible utvidelser til Twitter API-et støttet av både Friendica og Red
+
+* api/statusnet/version S,F,R
+* api/statusnet/config S,F,R
+
+Friendica API utvidelser til Twitter API-et støttet av både Friendica og Red
+
+* api/statuses/mediap F,R
+
+
+Red-spesifikke API utvidelser til Twitter API-et som ikke er støttet av Friendica
+
+* api/account/logout R
+* api/export/basic R,J
+* api/friendica/config R
+* api/red/config R
+* api/friendica/version R
+* api/red/version R
+
+* api/red/channel/export/basic R,J
+* api/red/channel/stream R,J (currently post only)
+* api/red/albums R,J
+* api/red/photos R,J (option album=xxxx)
+
+
+Foreslåtte Red API utvidelser til Twitter API-et
+
+* api/statuses/edit (R),J
+* api/statuses/permissions (R),J
+* api/statuses/permissions/update (R),J
+* api/statuses/ids (R),J # søk etter eksisterende message_id før importering av fremmed innlegg
+* api/files/show (R),J
+* api/files/destroy (R),J
+* api/files/update (R),J
+* api/files/permissions (R),J
+* api/files/permissions/update (R),J
+* api/pages/show (R),J
+* api/pages/destroy (R),J
+* api/pages/update (R),J
+* api/pages/permissions (R),J
+* api/pages/permissions/update (R),J
+* api/events/show (R),J
+* api/events/update (R),J
+* api/events/permissions (R),J
+* api/events/permissions/update (R),J
+* api/events/destroy (R),J
+* api/photos/show (R),J
+* api/photos/update (R),J
+* api/photos/permissions (R),J
+* api/photos/permissions/update (R),J
+* api/albums/destroy (R),J
+* api/albums/show (R),J
+* api/albums/update (R),J
+* api/albums/permissions (R),J
+* api/albums/permissions/update (R),J
+* api/albums/destroy (R),J
+* api/friends/permissions (R),J
+
+
diff --git a/sources/doc/nomadic-identity.bb b/sources/doc/nomadic-identity.bb
new file mode 100644
index 00000000..a062e58c
--- /dev/null
+++ b/sources/doc/nomadic-identity.bb
@@ -0,0 +1 @@
+This still needs to be written.
diff --git a/sources/doc/permissions.bb b/sources/doc/permissions.bb
new file mode 100644
index 00000000..bcf3c43e
--- /dev/null
+++ b/sources/doc/permissions.bb
@@ -0,0 +1,110 @@
+[b]Permissions[/b]
+
+Permissions in the $Projectname are more complete than you may be used to. This allows us to define more fine graded relationships than the black and white "this person is my friend, so they can do everything" or "this person is not my friend, so they can't do anything" permissions you may find elsewhere.
+
+[b]Default Permissions[/b]
+
+On your settings page, you will find a list of default permissions. These permissions are automatically applied to everybody unless you specify otherwise. The scope of these permissions varies from "Only me" to "Everybody" - though some scopes may not be available for some permissions. For example, you can't allow "anybody on the internet" to send you private messages, because we'd have no way to identify the sender, therefore no way to reply to them.
+
+We highly recommend that you use the "typical social network" settings when you create your first channel, as it allows others to communicate with you and help you out if you have difficulty. You will find that these settings allow you as much privacy as you desire - when you desire it; but also allow you to communicate in public if you choose to. You are free to use much more private settings once you have learned your way around.
+
+Be aware that altering the scope of who can see your "public" items is a more or less [b]permanent[/b] change. Your public items have no identified permissions attached to them - they are public. If you restrict who can see these items, there is no way of making any single item public ever again - without allowing access to every public item you ever created. You are certainly free to do this, but beware of the consequences.
+
+A more useful privacy setup is to leave "public" items visible to anybody on the internet; but force everything you create to be restricted. This can be done on your Channel Settings page by selecting the role "Social - restricted". This ensures a Default Privacy Group for all new contacts, and sets your Default Post Permissions to restrict all your posts to that group. We use the Default Post Permissions for everything you create - posts, photos, events, webpages, and everything else. However you can then edit the permissions when you create any individual thing and remove your default privacy group to make just that item visible to anybody.
+
+
+
+The scopes of permissions are:
+
+[li]Nobody Except Yourself. This is self explanatory. Only you will be allowed access.[/li]
+
+[li]Only those you specifically allow. By default, people you are not connected to, and all new contacts will have this permission denied. You will be able to make exceptions for individual channels on their contact edit screen.[/li]
+
+[li]Anybody in your address book. Anybody you do not know will have this permission denied, but anybody you accept as a contact will have this permission approved. This is the way most legacy platforms handle permissions.[/li]
+
+[li]Anybody On This Hub. Anybody using the same hub as you will have permission approved. Anybody who registered at a different hub will have this permission denied.[/li]
+
+[li]Anybody in this network. Anybody in the $Projectname will have this permission approved. Even complete strangers. However, anybody not logged in/authenticated will have this permission denied.[/li]
+
+[li]Anybody authenticated. This is similar to "anybody in this network" except that it can include anybody who can authenticate by any means - and therefore may include visitors from other networks.[/li]
+
+[li]Anybody on the internet. Completely public. This permission will be approved for anybody at all.[/li]
+
+The individual permissions are:
+
+[i]Can view my "public" stream and posts.[/i]
+
+This permision determines who can view your channel "stream" that is, the non-private posts that appear on the "home" tab when you're logged in.
+
+[i]Can view my "public" channel profile.[/i]
+
+This permission determines who can view your channel's profile. This refers to the "about" tab
+
+[i]Can view my "public" photo albums.[/i]
+
+ This permission determines who can view your photo albums. Individual photographs may still be posted to a more private audience.
+
+[i]Can view my "public" address book.[/i]
+
+This permission determines who can view your contacts. These are the connections displayed in the "View connections" section.
+
+[i]Can view my "public" file storage.[/i]
+
+This permission determines who can view your public files stored in your cloud.
+
+[i]Can view my "public" pages.[/i]
+
+This permission determines who can view your public web pages.
+
+[i]Can send me their channel stream and posts.[/i]
+
+This permission determines whose posts you will view. If your channel is a personal channel (ie, you as a person), you would probably want to set this to "anyone in my address book" at a minimum. A personal notes channel would probably want to choose "nobody except myself". Setting this to "Anybody in the network" will show you posts from complete strangers, which is a good form of discovery.
+
+[i]Can post on my channel page ("wall").[/i]
+
+This permission determines who can write to your wall when clicking through to your channel.
+
+[i]Can comment on my posts.[/i]
+
+This permission determines who can comment on posts you create. Normally, you would want this to match your "can view my public stream and posts" permission
+
+[i]Can send me private mail messages.[/i]
+
+This determines who can send you private messages (zotmail).
+
+[i]Can post photos to my photo albums.[/i]
+
+This determines who can post photographs in your albums. This is very useful for forum-like channels where connections may not be connected to each other.
+
+[i]Can forward to all my channel contacts via post tags.[/i]
+
+Using @- mentions will reproduce a copy of your post on the profile specified, as though you posted on the channel wall. This determines if people can post to your channel in this way.
+
+[i]Can chat with me (when available).[/i]
+
+This determines who can join the public chat rooms created by your channel.
+
+[i]Can write to my "public" file storage.[/i]
+
+This determines who can upload files to your public file storage, or 'cloud'.
+
+[i]Can edit my "public" pages.[/i]
+
+This determines who can edit your webpages. This is useful for wikis or sites with multiple editors.
+
+[i]Can administer my channel resources.[/i]
+
+This determines who can have full control of your channel. This should normally be set to "nobody except myself".
+
+[i]Note:[/i]
+Plugins/addons may provide special permission settings, so you may be offered additional permission settings beyond what is described here.
+
+If you have set any of these permissions to "only those I specifically allow", you may specify indivudal permissions on the connnection edit screen.
+
+[b]Affinity[/b]
+
+The connection edit screen offers a slider to select a degree of friendship with the connnection (this tool is enabled through the "Extra Features" tab of your Settings page). Think of this as a measure of how much you like or dislike them. 1 is for people you like, whose posts you want to see all the time. 99 is for people you don't care for, and whose posts you might only wish to look at occasionally. Once you've assigned a value here, you can use the affinity tool on the matrix page to filter content based on this number.
+
+The slider on the matrix page has both a minimum and maximum value. Posts will only be shown from people who fall between this range. Affinity has no relation to permissions, and is only useful in conjunction with the affinity tool feature.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/plugins.bb b/sources/doc/plugins.bb
new file mode 100644
index 00000000..f7427603
--- /dev/null
+++ b/sources/doc/plugins.bb
@@ -0,0 +1,264 @@
+[b]Plugins[/b]
+
+So you want to make the $Projectname do something it doesn't already do. There are lots of ways. But let's learn how to write a plugin or addon.
+
+
+In your $Projectname folder/directory, you will probably see a sub-directory called 'addon'. If you don't have one already, go ahead and create it.
+[code]
+ mkdir addon
+[/code]
+Then figure out a name for your addon. You probably have at least a vague idea of what you want it to do. For our example I'm going to create a plugin called 'randplace' that provides a somewhat random location for each of your posts. The name of your plugin is used to find the functions we need to access and is part of the function names, so to be safe, use only simple text characters.
+
+Once you've chosen a name, create a directory beneath 'addon' to hold your working file or files.
+[code]
+ mkdir addon/randplace
+[/code]
+Now create your plugin file. It needs to have the same name, and it's a PHP script, so using your favourite editor, create the file
+[code]
+ addon/randplace/randplace.php
+[/code]
+The very first line of this file needs to be
+[code]
+ <?php
+[/code]
+Then we're going to create a comment block to describe the plugin. There's a special format for this. We use /* ... */ comment-style and some tagged lines consisting of
+[code]
+ /**
+ *
+ * Name: Random Place (here you can use better descriptions than you could in the filename)
+ * Description: Sample $Projectname plugin, Sets a random place when posting.
+ * Version: 1.0
+ * Author: Mike Macgirvin <mike@zothub.com>
+ *
+ */
+[/code]
+These tags will be seen by the site administrator when he/she installs or manages plugins from the admin panel. There can be more than one author. Just add another line starting with 'Author:'.
+
+The typical plugin will have at least the following functions:
+[code]
+ pluginname_load()
+ pluginname_unload()
+[/code]
+In our case, we'll call them randplace_load() and randplace_unload(), as that is the name of our plugin. These functions are called whenever we wish to either initialise the plugin or remove it from the current webpage. Also if your plugin requires things like altering the database schema before it can run for the very first time, you would likely place these instructions in the functions named
+[code]
+ pluginname_install()
+ pluginname_uninstall()
+[/code]
+
+Next we'll talk about **hooks**. Hooks are places in the $Projectname code where we allow plugins to do stuff. There are a [lot of these](help/Hooks), and they each have a name. What we normally do is use the pluginname_load() function to register a "handler function" for any hooks you are interested in. Then when any of these hooks are triggered, your code will be called.
+
+We register hook handlers with the 'register_hook()' function. It takes 3 arguments. The first is the hook we wish to catch, the second is the filename of the file to find our handler function (relative to the base of your $Projectname installation), and the third is the function name of your handler function. So let's create our randplace_load() function right now.
+
+[code]
+ function randplace_load() {
+ register_hook('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook');
+
+ register_hook('feature_settings', 'addon/randplace/randplace.php', 'randplace_settings');
+ register_hook('feature_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post');
+
+ }
+[/code]
+
+So we're going to catch three events, 'post_local' which is triggered when a post is made on the local system, 'feature_settings' to set some preferences for our plugin, and 'feature_settings_post' to store those settings.
+
+Next we'll create an unload function. This is easy, as it just unregisters our hooks. It takes exactly the same arguments.
+[code]
+ function randplace_unload() {
+ unregister_hook('post_local', 'addon/randplace/randplace.php', 'randplace_post_hook');
+
+ unregister_hook('feature_settings', 'addon/randplace/randplace.php', 'randplace_settings');
+ unregister_hook('feature_settings_post', 'addon/randplace/randplace.php', 'randplace_settings_post');
+
+ }
+[/code]
+
+Hooks are called with two arguments. The first is always $a, which is our global App structure and contains a huge amount of information about the state of the web request we are processing; as well as who the viewer is, and what our login state is, and the current contents of the web page we're probably constructing.
+
+The second argument is specific to the hook you're calling. It contains information relevant to that particular place in the program, and often allows you to look at, and even change it. In order to change it, you need to add '&' to the variable name so it is passed to your function by reference. Otherwise it will create a copy and any changes you make will be lost when the hook process returns. Usually (but not always) the second argument is a named array of data structures. Please see the "hook reference" (not yet written as of this date) for details on any specific hook. Occasionally you may need to view the program source to see precisely how a given hook is called and how the results are processed.
+
+Let's go ahead and add some code to implement our post_local hook handler.
+[code]
+ function randplace_post_hook($a, &$item) {
+
+ /**
+ *
+ * An item was posted on the local system.
+ * We are going to look for specific items:
+ * - A status post by a profile owner
+ * - The profile owner must have allowed our plugin
+ *
+ */
+
+ logger('randplace invoked');
+
+ if(! local_channel()) /* non-zero if this is a logged in user of this system */
+ return;
+
+ if(local_channel() != $item['uid']) /* Does this person own the post? */
+ return;
+
+ if(($item['parent']) || (! is_item_normal($item))) {
+ /* If the item has a parent, or is not "normal", this is a comment or something else, not a status post. */
+ return;
+ }
+
+ /* Retrieve our personal config setting */
+
+ $active = get_pconfig(local_channel(), 'randplace', 'enable');
+
+ if(! $active)
+ return;
+ /**
+ *
+ * OK, we're allowed to do our stuff.
+ * Here's what we are going to do:
+ * load the list of timezone names, and use that to generate a list of world cities.
+ * Then we'll pick one of those at random and put it in the "location" field for the post.
+ *
+ */
+
+ $cities = array();
+ $zones = timezone_identifiers_list();
+ foreach($zones as $zone) {
+ if((strpos($zone,'/')) && (! stristr($zone,'US/')) && (! stristr($zone,'Etc/')))
+ $cities[] = str_replace('_', ' ',substr($zone,strpos($zone,'/') + 1));
+ }
+
+ if(! count($cities))
+ return;
+ $city = array_rand($cities,1);
+ $item['location'] = $cities[$city];
+
+ return;
+ }
+[/code]
+
+Now let's add our functions to create and store preference settings.
+[code]
+ /**
+ *
+ * Callback from the settings post function.
+ * $post contains the global $_POST array.
+ * We will make sure we've got a valid user account
+ * and that only our own submit button was clicked
+ * and if so set our configuration setting for this person.
+ *
+ */
+
+ function randplace_settings_post($a,$post) {
+ if(! local_channel())
+ return;
+ if($_POST['randplace-submit'])
+ set_pconfig(local_channel(),'randplace','enable',intval($_POST['randplace']));
+ }
+
+
+
+ /**
+ *
+ * Called from the Feature Setting form.
+ * The second argument is a string in this case, the HTML content region of the page.
+ * Add our own settings info to the string.
+ *
+ * For uniformity of settings pages, we use the following convention
+ * <div class="settings-block">
+ * <h3>title</h3>
+ * .... settings html - many elements will be floated...
+ * <div class="clear"></div> <!-- generic class which clears all floats -->
+ * <input type="submit" name="pluginnname-submit" class="settings-submit" ..... />
+ * </div>
+ */
+
+
+
+ function randplace_settings(&$a,&$s) {
+
+ if(! local_channel())
+ return;
+
+ /* Add our stylesheet to the page so we can make our settings look nice */
+
+ head_add_css(/addon/randplace/randplace.css');
+
+ /* Get the current state of our config variable */
+
+ $enabled = get_pconfig(local_channel(),'randplace','enable');
+
+ $checked = (($enabled) ? ' checked="checked" ' : '');
+
+ /* Add some HTML to the existing form */
+
+ $s .= '<div class="settings-block">';
+ $s .= '<h3>' . t('Randplace Settings') . '</h3>';
+ $s .= '<div id="randplace-enable-wrapper">';
+ $s .= '<label id="randplace-enable-label" for="randplace-checkbox">' . t('Enable Randplace Plugin') . '</label>';
+ $s .= '<input id="randplace-checkbox" type="checkbox" name="randplace" value="1" ' . $checked . '/>';
+ $s .= '</div><div class="clear"></div>';
+
+ /* provide a submit button */
+
+ $s .= '<div class="settings-submit-wrapper" ><input type="submit" name="randplace-submit" class="settings-submit" value="' . t('Submit') . '" /></div></div>';
+
+ }
+
+[/code]
+
+
+
+***Advanced Plugins***
+
+Sometimes your plugins want to provide a range of new functionality which isn't provided at all or is clumsy to provide using hooks. In this case your plugin can also act as a 'module'. A module in our case refers to a structured webpage handler which responds to a given URL. Then anything which accesses that URL will be handled completely by your plugin.
+
+The key to this is to create a simple function named pluginname_module() which does nothing.
+[code]
+ function randplace_module() { return; }
+[/code]
+Once this function exists, the URL #^[url=https://yoursite/randplace]https://yoursite/randplace[/url] will access your plugin as a module. Then you can define functions which are called at various points to build a webpage just like the modules in the mod/ directory. The typical functions and the order which they are called is
+[code]
+ modulename_init($a) // (e.g. randplace_init($a);) called first - if you wish to emit json or xml,
+ // you should do it here, followed by killme() which will avoid the default action of building a webpage
+ modulename_aside($a) // Often used to create sidebar content
+ modulename_post($a) // Called whenever the page is accessed via the "post" method
+ modulename_content($a) // called to generate the central page content. This function should return a string
+ // consisting of the central page content.
+[/code]
+Your module functions have access to the URL path as if they were standalone programs in the Unix operating system. For instance if you visit the page
+[code]
+ https://yoursite/randplace/something/somewhere/whatever
+[/code]
+we will create an argc/argv list for use by your module functions
+[code]
+ $x = argc(); $x will be 4, the number of path arguments after the sitename
+
+ for($x = 0; $x < argc(); $x ++)
+ echo $x . ' ' . argv($x);
+
+
+ 0 randplace
+ 1 something
+ 2 somewhere
+ 3 whatever
+[/code]
+
+If you want to keep your plugin hidden from the siteinfo page, simply create a file called '.hidden' in your addon directory
+[code]
+ touch addon//.hidden
+[/code]
+
+***Porting Friendica Plugins***
+
+The $Projectname uses a similar plugin architecture to the Friendica project. The authentication, identity, and permissions systems are completely different. Many Friendica can be ported reasonably easily by renaming a few functions - and then ensuring that the permissions model is adhered to. The functions which need to be renamed are:
+
+[li] Friendica's pluginname_install() is pluginname_load()[/li]
+
+[li] Friendica's pluginname_uninstall() is pluginname_unload()[/li]
+
+The $Projectname has _install and _uninstall functions but these are used differently.
+
+[li] Friendica's "plugin_settings" hook is called "feature_settings"[/li]
+
+[li] Friendica's "plugin_settings_post" hook is called "feature_settings_post"[/li]
+
+Changing these will often allow your plugin to function, but please double check all your permission and identity code because the concepts behind it are completely different in the $Projectname. Many structured data names (especially DB schema columns) are also quite different.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/problems-following-an-update.bb b/sources/doc/problems-following-an-update.bb
new file mode 100644
index 00000000..3bc7e9a5
--- /dev/null
+++ b/sources/doc/problems-following-an-update.bb
@@ -0,0 +1,38 @@
+[b]Problems Following An Update[/b]
+
+A good 90% of all bugs encountered immediately after updating the code to the latest version are simple cache errors of one sort or another. If you update and find something very obvious is broken - like your matrix page doesn't load, notifications are missing, or comment boxes are missing - the chances are it's not a bug at all. Breaking basic functionality is the kind of thing developers tend to notice.
+
+If this happens to you, there are a few simple steps to take before resorting to the support forums:
+
+[b]Browser Cache[/b]
+
+Symptoms: Menus do not expand, ACL selector does not open, progress indicator does not display (or loops forever), Matrix and channel pages do not load.
+
+Force reload the page. Shift reload, or ctrl+f5. Occasionally, but very, very rarely, you will also need to clear the session data - which is achieved by restarting the browser.
+
+[b]FastCGI[/b]
+
+Symptoms: Incorrect variables. The basic UI mostly works, but displays incorrect content or is missing content entirely.
+
+If you're using php5-fpm, this problem is usually resolved with [code]service php5-fpm restart[/code]
+
+[b]Smarty Cache[/b]
+
+Symptoms:
+
+1) White Screen Of Death. This is most prevalent on the settings and admin pages.
+
+2) Missing icons, tabs, menus or features.
+
+We use the Smarty3 template engine to generate pages. These templates are compiled before they are displayed. Occasionally, a new or modified template will fail to overwrite the old compiled version. To clear the Smarty cache, delete all the files in store/[data]/smarty3/compiled [b]but do not delete the directory itself[/b]. Templates will then be recompiled on their next access.
+
+[b]Theme Issues[/b]
+
+There are many themes for The $Projectname. Only Redbasic is officialy supported by the core developers. This applies [i]even if a core developer happens to support an additional theme[/i]. This means new features are only guaranteed to work in Redbasic.
+
+Redbasic uses a few javascript libraries that are done differently, or entirely absent in other themes. This means new features may only work properly in Redbasic. Before reporting an issue, therefore, you should switch to Redbasic to see if it exists there. If the issue goes away, this is not a bug - it's a theme that isn't up to date.
+
+Should you report an issue with the theme developers then? No. Theme developers use their themes. Chances are, they know. Give them two or three days to catch up and [i]then[/i] report the issue if it's still not fixed. There are two workarounds for this situation. Firstly, you can temporarily use Redbasic. Secondly, most themes are open source too - open a pull request and make yourself a friend.
+
+#include doc/macros/troubleshooting_footer.bb;
+
diff --git a/sources/doc/profiles.bb b/sources/doc/profiles.bb
new file mode 100644
index 00000000..cae51a9c
--- /dev/null
+++ b/sources/doc/profiles.bb
@@ -0,0 +1,37 @@
+[b]Profiles[/b]
+
+Red has unlimited profiles. You may use different profiles to show different "sides of yourself" to different audiences. This is different to having different channels. Different channels allow for completely different sets of information. You may have a channel for yourself, a channel for your sports team, a channel for your website, or whatever else. A profile allows for finely graded "sides" of each channel. For example, your default public profile might say "Hello, I'm Fred, and I like laughing". You may show your close friends a profile that adds "and I also enjoy dwarf tossing".
+
+You always have a profile known as your "default" or "public" profile. This profile is always available to the general public and cannot be hidden (there may be rare exceptions on privately run or disconnected sites). You may, and probably should restrict the information you make available on your public profile.
+
+That said, if you want other friends to be able to find you, it helps to have the following information in your public profile...
+
+[ul][*]Your real name or at least a nickname everybody knows
+[*]A photo of you
+[*]Your location on the planet, at least to a country level.[/ul]
+
+In addition, if you'd like to meet people that share some general interests with you, please take a moment and add some "Keywords" to your profile. Such as "music, linux, photography" or whatever. You can add as many keywords as you like.
+
+To create an alternate profile, first go to [zrl=[baseurl]/settings/features]Settings > Additional Features[/zrl] and enable "Multiple Profiles" there, otherwise you won't have the ability to use more than just your default profile.
+
+Then select "Edit Profiles" from the menu of your $Projectname site. You may edit an existing profile, change the profile photo, add things to a profile or create a new profile. You may also create a "clone" of an existing profile if you only wish to change a few items but don't wish to enter all the information again. To do that, click on the profile you want to clone and choose "Clone this profile" there.
+
+In the list of your profiles, you can also choose the contacts who can see a specific profile. Just click on "Edit visibility" next to the profile in question (only available for the profiles that are not your default profile) and then click on user images to add them to or remove them from the group of people who can see this profile.
+
+Once a profile has been selected, when the person views your profile, they will see the private profile you have assigned. If they are not authenticated, they will see your public profile.
+
+There is a setting which allows you to publish your profile to a directory and ensure that it can be found by others. You can change this setting on the "Settings" page.
+
+If you do not wish to be found be people unless you give them your channel address, you may leave your profile unpublished.
+
+[b]Keywords and Directory Search[/b]
+
+On the directory page, you may search for people with published profiles. Currently, only the name field and the keywords are searched. You may also include such keywords in your default profile - which may be used to search for common interests with other members. Keywords are used in the channel suggestion tool and although they aren't visible in the directory, they are shown if people visit your profile page.
+
+On your Connnections page and in the directory there is a link to "Suggestions" or "Channel Suggestions", respectively. This will find channels who have matching and/or similar keywords. The more keywords you provide, the more relevant the search results that are returned. These are sorted by relevance.
+
+See Also
+
+[zrl=[baseurl]/help/AdvancedSearch]Advanced Searching[/zrl]
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/red2pi.bb b/sources/doc/red2pi.bb
new file mode 100644
index 00000000..18e7d325
--- /dev/null
+++ b/sources/doc/red2pi.bb
@@ -0,0 +1,342 @@
+[b]How to install the $Projectname on a Raspberry Pi[/b]
+
+You just bought a Raspberry Pi and want to run the RED Matrix with your own domain name?
+
+Then this page is for you! You will:
+[list=1]
+[*] Install Raspberry OS (Debian Linux) on a Raspberry
+[*] Install Apache Web Server, PHP, MaySQL, phpMyAdmin
+[*] Register a free domain (dynamic DNS) and use it for your hub
+[*] Install $Projectname
+[*] Keep your Raspberry Pi and $Projectname up-to-date
+[*] TODO Setting up SSL
+[*] TODO Running with SSL
+[*] TODO Make the webserver less vulnarable to attacks
+[/list]
+
+[size=large]1. Install Raspberry OS (Debian Linux)[/size]
+
+instructions under [url=http://www.raspberrypi.org/downloads]http://www.raspberrypi.org/downloads[/url]
+This page links to the quick start containing detailed instruction.
+
+[b]Format SD card[/b]
+
+using the program gparted under Linux Mint 15
+
+format as FAT32
+
+[b]Download NOOBS (offline and network install)[/b]
+
+[url=http://downloads.raspberrypi.org/noobs]http://downloads.raspberrypi.org/noobs[/url]
+
+unzip
+
+copy unzipped files to SD card
+
+[b]Install Raspbian as OS on the Rasperry Pi[/b]
+
+connect with keyboard via USB
+
+connect with monitor via HDMI
+
+Insert SD card into Rasperry Pi
+
+Connect with power supply to switch on the Rasperry
+
+choose Raspbian as OS (> installs Raspbian....)
+
+wait for the coniguration program raspi-config (you can later start it by sudo raspi-config)
+
+[b]Configure Raspbian[/b]
+
+in raspi-config > advanced > choose to use ssh (!! You need this to connect to administrate your Pi from your PC !!)
+
+in raspi-config > change the password (of default user "pi" from "raspberry" to your password)
+
+in raspi-config (optional) > Internationalisation options > Change Locale > to de_DE.utf-8 utf-8 (for example)
+
+in raspi-config (optional) > Internationalisation options > Change Timezoe > set your timezone
+
+in raspi-config (optional) > Overlock > medium
+
+(Source [url=http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#]http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#[/url])
+
+
+[b]More[/b]
+
+[code]sudo reboot[/code]
+
+Now its time to connect the Pi to the network.
+[ul]
+[*] pull out keyboard
+[*] pull out monitor
+[*] you even can pull out the power supply (USB)
+[*] plug-in the network cable to the router
+[*] plug-in the power supply again
+[*] wait for a minute or to give the Pi time to boot and start ssh...
+[/ul]
+
+On your PC connect to the Pi to administrate (here update it).
+Open the console on the PC (Window: Start > cmd, Linux: Shell)
+
+Hint: use the router admin tool to find out the IP of your PI[code]ssh pi@192.168.178.37
+sudo apt-get update
+sudo apt-get dist-upgrade[/code]
+
+(Source [url=http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#]http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#[/url])
+
+
+
+[size=large]2. Install Apache Web Server, PHP, MaySQL, phpMyAdmin[/size]
+
+[b]Install Apache Webserver[/b]
+
+[code]sudo bash
+sudo groupadd www-data[/code] might exist already
+
+[code]sudo usermod -a -G www-data www-data
+sudo apt-get update
+sudo reboot[/code]
+
+wait...
+reconnect via ssh, example: [code]ssh pi@192.168.178.37
+sudo apt-get install apache2 apache2-doc apache2-utils[/code]
+
+Open webbrowser on PC and check [url=http://192.168.178.37]http://192.168.178.37[/url]
+Should show you a page like "It works"
+
+(Source [url=http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#]http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#[/url])
+
+
+[b]Install PHP, MaySQL, phpMyAdmin[/b]
+
+[code]sudo bash
+apt-get install libapache2-mod-php5 php5 php-pear php5-xcache php5-curl
+apt-get install php5-mysql
+apt-get install mysql-server mysql-client[/code] enter and note the mysql passwort
+
+[code]apt-get install phpmyadmin[/code]
+
+Configuring phpmyadmin
+- Select apache2
+- Configure database for phpmyadmin with dbconfig-common?: Choose Yes
+
+(Source [url=http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#]http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#[/url])
+
+
+[b]Test installation[/b]
+
+[code]cd /var/www[/code]
+
+create a php file to test the php installation[code]sudo nano phpinfo.php[/code]
+
+Insert into the file:[code]
+<?php
+ phpinfo();
+?>
+[/code]
+(save CTRL+0, ENTER, CTRL+X)
+
+open webbrowser on PC and try [url=http://192.168.178.37/phpinfo.php]http://192.168.178.37/phpinfo.php[/url] (page shows infos on php)
+
+connect phpMyAdmin with MySQL database [code]nano /etc/apache2/apache2.conf[/code]
+- CTRL+V... to the end of the file
+- Insert at the end of the file: (save CTRL+0, ENTER, CTRL+X)[code]Include /etc/phpmyadmin/apache.conf[/code]
+
+restart apache[code]/etc/init.d/apache2 restart
+sudo apt-get update
+sudo apt-get upgrade
+sudo reboot[/code]
+
+(Source [url=http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#]http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#[/url])
+
+
+[b]phpMyAdmin[/b]
+
+open webbrowser on PC and try #^[url=http://192.168.178.37/phpmyadmin]http://192.168.178.37/phpmyadmin[/url]
+
+(Source [url=http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#]http://www.manfred-steger.de/tuts/20-der-eigene-webserver-mit-dem-raspberry-pi#[/url])
+
+
+[b]Create an empty database... that is later used by RED[/b]
+
+open webbrowser on PC and try #^[url=http://192.168.178.37/phpmyadmin]http://192.168.178.37/phpmyadmin[/url]
+
+Create an empty database
+
+Note the access details (hostname, username, password, database name).
+
+
+[size=large]3. Selfhost[/size]
+
+(Source: #^[url=http://www.techjawab.com/2013/06/setup-dynamic-dns-dyndns-for-free-on.html]http://www.techjawab.com/2013/06/setup-dynamic-dns-dyndns-for-free-on.html[/url])
+
+[url=http://freedns.afraid.org/signup/]http://freedns.afraid.org/signup/[/url]
+
+[b]Step 1[/b]
+Register for a Free domain at #^[url=http://freedns.afraid.org/signup/]http://freedns.afraid.org/signup/[/url]
+(We will take techhome.homenet.org in this guide)
+
+[b]Step 2[/b]
+
+Logon to FreeDNS (where you just registered) and goto #^[url=http://freedns.afraid.org/dynamic/]http://freedns.afraid.org/dynamic/[/url]
+Right click on "Direct Link" and copy the URL and paste it somewhere.
+You should notice a large and unique alpha-numeric key in the URL, make a note of it as shown below:
+[code]http://freedns.afraid.org/dynamic/update.php?alphanumeric-key[/code]
+
+
+[b]Step 3[/b]
+Install inadyn using the following command:[code]sudo apt-get install inadyn[/code]
+
+[b]Step 4[/b]
+Configure inadyn using the below steps:[code]sudo nano /etc/inadyn.conf[/code]
+And add the following contains in it replacing the actual values:
+[code]
+--username [color=red]techhome[/color]
+--password [color=red]mypassword[/color]
+--update_period 3600
+--forced_update_period 14400
+--alias [color=red]techhome.homenet.org</b>,[color=red]alphanumeric key[/color]
+--background
+--dyndns_system default@freedns.afraid.org
+--syslog
+ [/code]
+
+
+[b]Step 5[/b]
+
+Now, we need to ensure that the DNS updater (Inadyn) runs automatically after every re-boot[code]export EDITOR=gedit && sudo crontab -e[/code]
+Add the following line:[code]@reboot /usr/sbin/inadyn[/code]
+
+
+[b]Step 6[/b]
+
+Reboot system and then run the following command to ensure inadyn is running:[code]
+sudo reboot
+ps -A | grep inadyn
+[/code]
+Now your host is ready and up for accessing from internet...
+You can trying ssh-ing from another computer over the internet
+[code]ssh username@techhome.homenet.org[/code]
+Or, if any web server is running, then simply browse to #^[url=http://techhome.homenet.org]http://techhome.homenet.org[/url]
+Or, you can just ping it to test ping techhome.homenet.org
+To check the logs you can use this:
+[code]more /var/log/messages |grep INADYN[/code]
+
+
+[size=large]4. Install $Projectname[/size]
+
+(Source: [zrl=[baseurl]/help/Install][baseurl]/help/Install[/zrl])
+
+Linux Appache document root is /var/www/
+Two files exist there (created by the steps above): index.html, phpinfo.php
+
+
+[b]Install $Projectname and its Addons[/b]
+
+Cleanup: Remove the directory www/ (Git will not create files and folders in directories that are not empty.) Make sure you are in directory var[code]pi@pi /var $ cd /var[/code]
+
+Remove directory[code]pi@pi /var $ sudo rm -rf www/[/code]
+
+Download the sources of $Projectname from GIT
+[code]pi@pi /var $ sudo git clone https://github.com/redmatrix/hubzilla.git www[/code]
+
+Download the sources of the addons from GIT
+[code]pi@pi /var/www $ sudo git clone https://github.com/redmatrix/hubzilla-addons.git addon[/code]
+
+Make user www-data the owner of the whole web directory (including subdirectories and files)
+(TODO: This step has to be proofed by the next installation.)
+[code]pi@pi /var $ chown -R www-data:www-data /var/www/[/code]
+
+Check if you can update the sources from git[code]
+pi@pi /var $ cd www
+pi@pi /var/www $ git pull
+[/code]
+
+Check if you can update the addons
+[code]pi@pi /var/www $ cd addon/
+pi@pi /var/www/addon $ sudo git pull[/code]
+
+Make sure folder store/[data]/smarty3 exists and is writable by the webserver
+[code]pi@pi /var/www $ sudo chmod ou+w "store/\[data\]/smarty3"[/code]
+
+Create .htconfig.php and is writable by the webserver
+[code]pi@pi /var/www $ sudo touch .htconfig.php
+pi@pi /var/www $ sudo chmod ou+w .htconfig.php[/code]
+
+[b]First start and initial configuration of your RED Matrix hub[/b]
+
+In browser open #^[zrl=http://einervonvielen.mooo.com/]http://einervonvielen.mooo.com/[/zrl]
+(Replace einervonvielen.mooo.com by your domain, see chapter selfhost. Be patient. It takes time.)
+(#^[zrl=http://einervonvielen.mooo.com/index.php?q=setup]http://einervonvielen.mooo.com/index.php?q=setup[/zrl])
+
+There might be errors like the following.
+
+Error: libCURL PHP module required but not installed.
+Solution:
+apt-get install php5-curl
+
+Error: Apache webserver mod-rewrite module is required but not installed.
+Solution
+(Source: [url=http://xmodulo.com/2013/01/how-to-enable-mod_rewrite-in-apache2-on-debian-ubuntu.html]http://xmodulo.com/2013/01/how-to-enable-mod_rewrite-in-apache2-on-debian-ubuntu.html[/url])
+The default installation of Apache2 comes with mod_rewrite installed. To check whether this is the case, verify the existence of /etc/apache2/mods-available/rewrite.load
+- pi@pi /var/www $ nano /etc/apache2/mods-available/rewrite.load
+ (You should find the contendt: LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so)
+To enable and load mod_rewrite, do the rest of steps.
+Create a symbolic link in /etc/apache2/mods-enabled
+- pi@pi /var/www $ sudo a2enmod rewrite
+Then open up the following file, and replace every occurrence of "AllowOverride None" with "AllowOverride all".
+- pi@pi /var/www $ sudo nano /etc/apache2/sites-available/default
+Finally, restart Apache2.
+- pi@pi /var/www $ sudo service apache2 restart
+
+Error store is writable (not checked)
+Solution:
+(TODO: Make writeable to group www-data only?)
+pi@pi /var/www $ sudo mkdir store
+pi@pi /var/www $ chown -R www-data:www-data /var/www/red/
+pi@pi /var/www $ sudo chmod ou+w view
+
+[b]More[/b]
+
+Set up a cron job to run the poller once every 15 minutes in order to perform background processing.
+- pi@pi /var/www $ which php
+Make sure you are in the document root directory of the webserver
+- pi@pi /var/www $ cd /var/www/
+Try to execute the poller in order to make sure it works
+- pi@pi /var/www $ /usr/bin/php include/poller.php
+Create the cronjob
+- pi@pi /var/www $ crontab -e
+Enter
+- */15 * * * * cd /var/www/; /usr/bin/php include/poller.php
+- Save and exit.
+
+Prevent search engines from indexing your search pages. Why? This can cause heavy resource use.
+
+[code]
+php util/config system block_public_search 1
+[/code]
+
+
+
+[size=large]5. Keep your Raspberry Pi and your $Projectname up-to-date[/size]
+
+Git update every day at 4 am and addons at 5 am every day
+Try if the command is working
+- pi@pi /var/www $ sudo git pull
+Create the cronjob
+- pi@pi /var/www $ crontab -e
+Enter the following to update at 4:01 am every day
+- 01 04 * * * cd /var/www/; sudo git pull
+Enter the following to update the addons at 5:01 am every day
+- 01 05 * * * cd /var/www/addon/; sudo git pull
+Enter the following to update the Raspberry Pi (Raspbian OS = Debian) at 6:01 am every day
+- 01 06 * * * sudo aptitude -y update && sudo aptitude -y safe-upgrade
+Save and exit.
+
+[size=large]6. Running with SSL[/size]
+
+Follow the instructions here:
+[url=https://github.com/friendica/friendica/wiki/Running-Friendica-with-SSL]https://github.com/friendica/friendica/wiki/Running-Friendica-with-SSL[/url]
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/registration.bb b/sources/doc/registration.bb
new file mode 100644
index 00000000..31d69622
--- /dev/null
+++ b/sources/doc/registration.bb
@@ -0,0 +1,35 @@
+[size=large][b]Registration[/b][/size]
+
+Not all $Projectname sites allow open registration. If registration is allowed, you will see a "Register" link immediately below the login prompts on the site home page. Following this link will take you to the site Registration page. On some sites it may redirect you to another site which allow registrations. As all $Projectname sites are linked, it does not matter where your account resides.
+
+[b]Your Email Address[/b]
+
+Please provide a valid email address. Your email address is never published. This address will be used to activate your account, to (optionally) send email notifications for incoming messages or items, [i]and to recover lost passwords[/i].
+
+[b]Password[/b]
+
+Enter a password of your choice, and repeat it in the second box to ensure it was typed correctly. As the $Projectname offers a decentralised identity, your account can log you in to many other websites.
+
+[b]Terms Of Service[/b]
+
+Click the link to read the site's [zrl=[baseurl]/help/TermsOfService]Terms of Service[/zrl]. Once you've read them, tick the box in the register form to confirm.
+
+[b]Register[/b]
+
+Once you have provided the necessary details, click the 'Register' button. Some sites may require administrator approval before the registration is processed, and you will be alerted if this is the case. Please watch your email (including spam folders) for your registration approval.
+
+[b]Create a Channel[/b]
+
+Next, you will be presented with the "Add a channel" screen. Normally, your first channel will be one that represents you - so using your own name (or psuedonym) as the channel name is a good idea. The channel name should be thought of as a title, or brief description of your channel. The "choose a short nickname" box is similar to a "username" field. We will use whatever you enter here to create a channel address, which other people will use to connect to you, and you will use to log in to other sites. This looks like an email address, and takes the form nickname@siteyouregisteredat.xyz
+
+When your channel is created you will be taken straight to your settings page where you can define permissions, enable features, etc. All these things are covered in the appropriate section of the helpfiles.
+
+See Also
+[zrl=[baseurl]/help/accounts_profiles_channels_basics]The Basics about Identities within the $Projectname[/zrl]
+[zrl=[baseurl]/help/accounts]Accounts[/zrl]
+[zrl=[baseurl]/help/profiles]Profiles[/zrl]
+[zrl=[baseurl]/help/permissions]Permissions[/zrl]
+[zrl=[baseurl]/help/remove_account]Remove Account[/zrl]
+
+#include doc/macros/main_footer.bb;
+
diff --git a/sources/doc/remove_account.bb b/sources/doc/remove_account.bb
new file mode 100644
index 00000000..704f0b94
--- /dev/null
+++ b/sources/doc/remove_account.bb
@@ -0,0 +1,27 @@
+[b]Remove Channel or Account[/b]
+
+[b]Remove Channel[/b]
+
+Go to the bottom of your channel settings page or visit the URL:
+
+ [baseurl]/removeme
+
+You will need to confirm your password and the channel you are currently logged into will be removed.
+
+This is irreversible.
+
+If you have identity clones on other hubs this only removes by default the channel instance which exists on this hub.
+
+[b]Remove Account[/b]
+
+Go to the bottom of your account settings page or visit the URL:
+
+ [baseurl]/removeaccount
+
+You will need to confirm your password and the account you are currently logged into will be removed.
+
+This is irreversible.
+
+All your channels will be deleted. If you have identity clones on other hubs this only removes by default the channels instances which exists on this hub.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/roadmap.bb b/sources/doc/roadmap.bb
new file mode 100644
index 00000000..f57c76b7
--- /dev/null
+++ b/sources/doc/roadmap.bb
@@ -0,0 +1,59 @@
+
+
+Roadmap for $Projectname V3
+
+*HZ = Hubzilla repository
+
+
+Crypto
+ Convert E2EE to dynamic loading (on demand) using jQuery.getScript() [or other methods] to only load encryption libs when you require them. This should also support multiple encryption libraries (e.g. SJCL, others) triggered from the choice of algorithm and remain pluggable.
+
+Diaspora
+ Convert core Diaspora federation code into a plugin. This presents a number of challenges since it touches and special cases a lot of core functionality. (HZ - in progress)
+
+Subscriptions and business models
+ Build enough into core(/addons) to generate income (or at least try and cover costs) out of the box (in progress Habeas Codice)
+
+Merge all uploads into common DAV interface
+ Separate photo albums from photos and turn them into file directories. (HZ - done)
+ Upload everything direct to /store (HZ - done)
+ If photo, generate thumbnails and image resources (HZ - done)
+ Provide default upload folders with %y (and other?) macros for both photos and other file resources (HZ - done)
+ Allow "media" (anything that we can generate a thumbnail for) in the Photos section (and show thumbnails in the Files section where possible) (HZ - done)
+
+ Resolve the "every photo has an item" confusion, perhaps every file should also - but only if we can explain it and separate them conceptually.
+
+Migration tools
+ Friendica importer
+ Diaspora importer (channel and connection import done, conversations and photos still in progress and waiting for support from Diaspora)
+
+Webpage design UI improvements
+ If practical, separate "conversation" sub-themes from overall themes so one can choose different conversation and content layouts within a base theme.
+ Make webpage building easy, with point-n-click selectors to build PDLs
+ bring back WYSIWYG, which ideally requires a JS abstraction layer so we can use any editor and change it based on mimetype
+
+Social Networking Federation
+ Friendica native mode?
+ Pump.io?
+ Others?
+
+Lists
+ Create a list object to contain arbitrary things for system use
+ Create a list object to contain arbitrary things for personal use
+
+Events
+ Recurring events
+
+Zot
+ Provide a way to sync web resources. This could be built on DAV except for preserving resource naming (guids) instead of filenames.
+
+API extensions
+ More, more, more.
+
+Evangelism
+ More documentation. More, more, more.
+ Libzot
+
+DNS abstraction for V3
+ Allow a channel to live in an arbitrary "DNS" namespace, for instance "mike@core.hubzilla". Use our directories and zot to find the actual DNS location via redirection. This could potentially allow hubs to be hidden behind tor or alt-roots and accessible only via the matrix.
+
\ No newline at end of file
diff --git a/sources/doc/roles.md b/sources/doc/roles.md
new file mode 100644
index 00000000..5d8d0711
--- /dev/null
+++ b/sources/doc/roles.md
@@ -0,0 +1,66 @@
+Account Permission Roles
+========================
+
+
+##Social
+
+**Mostly Public**
+
+The channel is a typical social networking profile. By default posts and published items are public, but one can over-ride this when creating the item and restrict it. You are listed in the directory. Your online presence and connections are visible to others.
+
+
+**Restricted**
+
+By default all posts and published items are sent to your 'Friends' collection and not made public. New friends are added to this collection. You can over-ride this and create a public post or published item if you desire. You are listed in the directory. Your online presence (for chat) and your connections (friends) are visible to your profile viewers.
+
+**Private**
+
+By default all posts and published items are sent to your 'Friends' collection. New friends are added to this collection. You can over-ride this and create a public post or public item if you desire. You are NOT listed in the directory. Only your connections can see your other connections. Your online presence is hidden.
+
+
+##Forum
+
+**Mostly Public**
+
+The channel is a typical forum. By default posts and published items are public. Members may post by @mention+ or wall-to-wall post. Posting photos and other published items is blocked. The channel is visible in the directory. Members are added automatically.
+
+
+**Restricted**
+
+By default all posts and published items are sent to the channel's 'Friends' collection. New friends are added to this collection. Members may post by @mention+ or wall-to-wall post, but posts and replies may also be seen by other receipients of the top-level post who are not members. The channel is visible in the directory. Members must be manually added by the forum owner.
+
+**Private**
+
+By default all posts and published items are sent to your 'Friends' collection. New friends are added to this collection. The owner can over-ride this and create a public post or public item if desired. Members cannot. You are NOT listed in the directory. Only your connections can see your other connections. Your online presence is hidden. Members must be manually added by the forum owner. Posting by @mention+ is disabled. Posts can only be made via wall-to-wall posts, and sent to members of the 'Friends' collection. They are not publicly visible.
+
+
+##Feed
+
+
+**Public**
+
+Similiar to Social - Mostly Public, but tailored for RSS feed sources. Items may be freely republished and sourced. Online presence is meaningless, therefore hidden. New connections are automatically approved.
+
+
+**Restricted**
+
+Not listed in directory. Online presence is meaningless, therefore hidden. Feed is published only to members of the 'Friends' collection. New connections are automatically added to this collections. Members must be manually approved by the channel owner.
+
+
+##Special
+
+**Celebrity/Soapbox**
+
+Listed in directory. Communications are by default public. Online presence is hidden. No commenting or feedback of any form is allowed, though connections have the ability to "like" your profile.
+
+
+**Group Repository**
+
+A public forum which allows members to post files/photos/webpages.
+
+
+##Custom/Expert Mode
+
+Set all the privacy and permissions manually to suit your specific needs.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/schema_development.bb b/sources/doc/schema_development.bb
new file mode 100644
index 00000000..3d4c84e8
--- /dev/null
+++ b/sources/doc/schema_development.bb
@@ -0,0 +1,78 @@
+[b]Red Development - A Guide To The Schema System[/b]
+
+A schema, in a nutshell, is a collection of settings for a bunch of variables to define
+certain elements of a theme. A schema is loaded as though it were part of config.php
+and has access to all the same information. Importantly, this means it is identity aware,
+and can be used to do some interesting things. One could, for example, restrict options
+by service class, or present different options to different members.
+
+By default, we filter only by whether or not expert mode is enabled. If expert mode is
+enabled, all options are presented to the member. If it is not, only scheme, background
+image, font face, and iconset are available as choices.
+
+A schema is loaded *after* the member's personal settings. Therefore, to allow a member
+to overwrite a particular aspect of a schema you would use the following syntax:
+[code]
+ if (! $foo)
+ $foo = 'bar';
+[/code]
+However, there are circumstances - particularly with positional elements - where it
+may be desirable (or necessary) to override a member's settings. In this case, the syntax
+is even simpler:
+[code]
+ $foo = 'bar';
+[/code]
+Members will not thank you for this, however, so only use it when it is required.
+
+If no personal options are set, and no schema is selected, we will first try to load a schema
+with the file name "default.php". This file should never be included with a theme. If it
+is, merge conflicts will occur as people update their code. Rather, this should be defined
+by administrators on a site by site basis.
+default.php and default.css MUST be symlinks to existing scheme files.
+
+You schema does not need to - and should not - contain all of these values. Only the values
+that differ from the defaults should be listed. This gives you some very powerful options
+with very few lines of code.
+
+Note the options available differ with each theme. The options available with the Redbasic
+theme are as follows:
+
+[li] nav_colour
+ The colour of the navigation bar. Options are red, black and silver. Alternatively,
+ one can set $nav_bg_1, $nav_bg_2, $nav_bg_3 and $nav_bg_4 to provide gradient and
+ hover effects.[/li]
+[li] banner_colour
+ The font colour of the banner element. Accepts an RGB or Hex value.[/li]
+[li] bgcolour
+ Set the body background colour. Accepts an RGB or Hex value.[/li]
+[li] background_image
+ Sets a background image. Accepts a URL or path.[/li]
+[li] item_colour
+ Set the background colour of items. Accepts an RGB or Hex value.[/li]
+[li] item_opacity
+ Set the opacity of items. Accepts a value from 0.01 to 1[/li]
+[li] toolicon_colour
+ Set the colour of tool icons. Accepts an RGB or Hex value.[/li]
+[li] toolicon_activecolour
+ Set the colour of active or hovered icon tools.[/li]
+[li] font_size
+ Set the size of fonts in items and posts. Accepts px or em.[/li]
+[li] body_font_size
+ Sets the size of fonts at the body level. Accepts px or em.[/li]
+[li] font_colour
+ Sets the font colour. Accepts an RGB or Hex value.[/li]
+[li] radius
+ Set the radius of corners. Accepts a numeral, and is always in px.[/li]
+[li] shadow
+ Set the size of shadows shown with inline images. Accepts a numerical
+ value. Note shadows are not applied to smileys.[/li]
+[li] converse_width
+ Set the maximum width of the content region in px.[/li]
+[li] nav_min_opacity[/li]
+[li] top_photo[/li]
+[li] reply_photo[/li]
+
+If a your_schema_name.css file is found, the content of this file will be attached to the end of style.css.
+This gives the schem developer the possiblity to override any style component.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/service_classes.bb b/sources/doc/service_classes.bb
new file mode 100644
index 00000000..e5d4ecfa
--- /dev/null
+++ b/sources/doc/service_classes.bb
@@ -0,0 +1,37 @@
+[b]Service Classes[/b]
+
+Service classes allow you to set limits on system resources. A GUI to configure this is currently under development.
+
+As a temporary measure, the following commandline utilities can be used:
+
+Usage:
+
+[code]util/service_class[/code]
+list service classes
+
+[code]util/config system default_service_class firstclass[/code]
+set the default service class to 'firstclass'
+
+[code]util/service_class firstclass[/code]
+list the services that are part of 'firstclass' service class
+
+[code]util/service_class firstclass photo_upload_limit 10000000[/code]
+set firstclass total photo disk usage to 10 million bytes
+
+[code]util/service_class --account=5 firstclass[/code]
+set account id 5 to service class 'firstclass' (with confirmation)
+
+[code]util/service_class --channel=blogchan firstclass[/code]
+set the account that owns channel 'blogchan' to service class 'firstclass' (with confirmation)
+
+[b]current limits[/b]
+photo_upload_limit - maximum total bytes for photos
+total_items - maximum total toplevel posts
+total_pages - maximum comanche pages
+total_identities - maximum number of channels owned by account
+total_channels - maximum number of connections
+total_feeds - maximum number of rss feed connections
+attach_upload_limit - maximum file upload storage (bytes)
+minimum_feedcheck_minutes - lowest setting allowed for polling rss feeds
+chatrooms - maximum chatrooms
+chatters_inroom - maximum chatters per room
diff --git a/sources/doc/sql_conventions.bb b/sources/doc/sql_conventions.bb
new file mode 100644
index 00000000..f6a4e251
--- /dev/null
+++ b/sources/doc/sql_conventions.bb
@@ -0,0 +1,91 @@
+[h1]SQL Conventions[/h1]
+[b]Intro[/b]
+The following common SQL conventions appear throughout the code in many places. We use a simple DBA (DataBase Abstraction layer) to handle differences between databases. Please be sure to use only standards-compliant SQL.
+
+[b]Rule One[/b]
+Worth Repeating: Don't use non-standard SQL. This goes for addons as well. If you do use non-standard SQL, and the dba funcs are insufficient, do a if()/switch() or similar for all currently supported databases. Currently nothing red# does requires non-standard SQL.
+
+[b]Using a format string[/b]
+[li]Uses sprintf()
+To be written
+[code]// Example
+$r = q("SELECT * FROM profile WHERE uid = %d",
+ local_channel()
+);
+[/code][/li]
+
+[b]Checking bit flags in a where clause[/b]
+[li]You must explicitly convert integers to booleans. The easiest way to do this is to compare to 0.
+[code]// Example
+$r = q("SELECT abook_id, abook_flags, abook_my_perms, abook_their_perms, xchan_hash, xchan_photo_m, xchan_name, xchan_url from abook left join xchan on abook_xchan = xchan_hash where abook_channel = %d and not (abook_flags & %d)>0 ",
+ intval($uid),
+ intval(ABOOK_FLAG_SELF)
+);
+[/code]
+[/li]
+[li]Turning off a flag
+[code]$y = q("update xchan set xchan_flags = (xchan_flags & ~%d) where (xchan_flags & %d)>0 and xchan_hash = '%s'",
+ intval(XCHAN_FLAGS_ORPHAN),
+ intval(XCHAN_FLAGS_ORPHAN),
+ dbesc($rr['hubloc_hash'])
+);[/code]
+[/li]
+[li]Turning on a flag
+[code]$y = q("update xchan set xchan_flags = (xchan_flags | %d) where xchan_hash = '%s'",
+ intval(XCHAN_FLAGS_ORPHAN),
+ dbesc($rr['hubloc_hash'])
+);[/code]
+[/li]
+
+[b]Using relative times (INTERVALs)[/b]
+[li]Sometimes you want to compare something, like less than x days old.
+[code]// Example
+$r = q("SELECT * FROM abook left join xchan on abook_xchan = xchan_hash
+ WHERE abook_dob > %s + interval %s and abook_dob < %s + interval %s",
+ db_utcnow(), db_quoteinterval('7 day'),
+ db_utcnow(), db_quoteinterval('14 day')
+);[/code]
+[/li]
+[b]Paged results[/b]
+[li]To be written
+[code]// Example
+$r = q("SELECT * FROM mail WHERE uid=%d AND $sql_extra ORDER BY created DESC LIMIT %d OFFSET %d",
+ intval(api_user()),
+ intval($count), intval($start)
+);[/code][/li]
+
+[b]NULL dates[/b]
+[li]To be written
+[code]// Example
+$r = q("DELETE FROM mail WHERE expires != '%s' AND expires < %s ",
+ dbesc(NULL_DATE),
+ db_utcnow()
+);[/code][/li]
+
+[b]Storing binary data[/b]
+[li]To be written
+[code]// Example
+$x = q("update photo set data = '%s', height = %d, width = %d where resource_id = '%s' and uid = %d and scale = 0",
+ dbescbin($ph->imageString()),
+ intval($height),
+ intval($width),
+ dbesc($resource_id),
+ intval($page_owner_uid)
+);[/code][/li]
+
+[b]Current timestamp[/b]
+[li][code]// Example
+$randfunc = db_getfunc('rand');
+$r = q("select xchan_url from xchan left join hubloc on hubloc_hash = xchan_hash where hubloc_connected > %s - interval %s order by $randfunc limit 1",
+ db_utcnow(), db_quoteinterval('30 day')
+);[/code][/li]
+
+[b]SQL Function and Operator Abstraction[/b]
+[li]Sometimes the same function or operator has a different name/symbol in each database. You use db_getfunc('funcname') to look them up. The string is [i]not[/i] case-sensitive; do [i]not[/i] include parens.
+[code]// Example
+$randfunc = db_getfunc('rand');
+$r = q("select xchan_url from xchan left join hubloc on hubloc_hash = xchan_hash where hubloc_connected > %s - interval %s order by $randfunc limit 1",
+ db_utcnow(), db_quoteinterval('30 day')
+);[/code][/li]
+
+#include doc/macros/main_footer.bb;
\ No newline at end of file
diff --git a/sources/doc/sv/main.bb b/sources/doc/sv/main.bb
new file mode 100644
index 00000000..eb35b0b3
--- /dev/null
+++ b/sources/doc/sv/main.bb
@@ -0,0 +1,84 @@
+[img][baseurl]/assets/hashlogo.png[/img]
+
+[zrl=[baseurl]/help/about][b]Vad är $Projectname?[/b][/zrl]
+$Projectname är en decentraliserad publicerings- och kommunikationsplattform som möjliggör att du behåller kontrollen över dina kommunikationer med hjälp av automatisk kryptering och fininställbar behörighetskontroll. Det är du, och bara du, som beslutar vem som är behörig att ta del av ditt innehåll.
+
+[zrl=[baseurl]/help/features][b]$Projectname funktioner[/b][/zrl]
+$Projectname används redan och bildar ett globalt distribuerad närverk och bevisar* dagligen sin skalbarhet och diversitet i allt från installationer med en kanal till installationer med många användare och många kanaler med en stor mängd innehåll.
+Föreställ dig isolerade familjekommunikationsplatformer, distribuerade nätforum med fildelning, hjälpforum, bloggar och hemsidor. Eller proffesionellt anpassade innehållsleverantörer med kommersiella premium* kanaler och målriktat innehållsstyrning. Vad du än önskar så finns $Projectname för att stödja dig i förverkligande av din kreativitet.
+
+[zrl=[baseurl]/help/what_is_zot][b]Har du Zot? Skaffa det, direkt.[/b][/zrl]
+Zot är en fantastisk ny kommunikationsprotokoll uppfunnit speciellt för $Projectname. Som medlem är du inte längre bunden till en enskild sida eller hub tack vara "nomadiska identiteter". Flytt lätt till en annan server och håll dina kontakter och förbindelser intakta eller klona och kör den samma kanal på flera servrar simultant. I tillfälle av att en av dem stänger ner så går du inte miste om något. Plus när du är loggat in i $Projectname så är det inga flera inloggningar även när du kontakter andra hubbar i nätverket. Zot är det som gör $Projectname till något särskilt värdefullt/som urskiljer $Projectname från mängden.
+
+[h3]Kom igång[/h3]
+[zrl=[baseurl]/help/Privacy]Privacy Policy[/zrl]
+[zrl=[baseurl]/help/registration]Account Registration[/zrl]
+[zrl=[baseurl]/help/accounts_profiles_channels_basics]You at the $Projectname: accounts, profiles and channels in short[/zrl]
+[zrl=[baseurl]/help/profiles]Profiles[/zrl]
+[zrl=[baseurl]/help/channels]Channels[/zrl]
+[zrl=[baseurl]/help/sv/roles]Behörighetsförval för kanaler[/zrl]
+[zrl=[baseurl]/help/first-post]Your first posting[/zrl]
+[zrl=[baseurl]/help/connecting_to_channels]Connecting To Other Channels[/zrl]
+[zrl=[baseurl]/help/permissions]Permissions And Encryption: You Are In Control[/zrl]
+[zrl=[baseurl]/help/cloud]Cloud Storage[/zrl]
+[zrl=[baseurl]/help/remove_account]Remove Channel or Account[/zrl]
+
+[h3]Hjälp till medlemmar[/h3]
+[zrl=[baseurl]/help/tags_and_mentions]Tags and Mentions[/zrl]
+[zrl=[baseurl]/help/webpages]Web Pages[/zrl]
+[zrl=[baseurl]/help/bbcode]BBcode reference for posts and comments[/zrl]
+[zrl=[baseurl]/help/checking_account_quota_usage]Checking Account Quota Usage[/zrl]
+[zrl=[baseurl]/help/cloud_desktop_clients]Cloud Desktop Clients[/zrl]
+[zrl=[baseurl]/help/AdvancedSearch]Advanced Directory Search[/zrl]
+[zrl=[baseurl]/help/addons]Help With Addons[/zrl]
+[zrl=[baseurl]/help/diaspora_compat]Diaspora Communications Compatibility (Diaspora and Friendica)[/zrl]
+[zrl=[baseurl]/help/faq_members]FAQ For Members[/zrl]
+
+[h3]Hjälp till administratorer[/h3]
+[zrl=[baseurl]/help/install]Install[/zrl]
+[zrl=[baseurl]/help/debian_install]Easy Install on Debian via script[/zrl]
+[zrl=[baseurl]/help/red2pi]Installing Red on the Raspberry Pi[/zrl]
+[zrl=[baseurl]/help/troubleshooting]Troubleshooting Tips[/zrl]
+[zrl=[baseurl]/help/hidden_configs]Tweaking $Projectname's Hidden Configurations[/zrl]
+[zrl=[baseurl]/help/faq_admins]FAQ For Admins[/zrl]
+
+[h3]Teknisk dokumentation[/h3]
+[zrl=[baseurl]/help/history]$Projectname history[/zrl]
+[zrl=[baseurl]/help/Zot---A-High-Level-Overview]A high level overview of Zot[/zrl]
+[zrl=[baseurl]/help/zot]An introduction to Zot[/zrl]
+[zrl=[baseurl]/help/zot_structures]Zot Stuctures[/zrl]
+[zrl=[baseurl]/help/comanche]Comanche Page Descriptions[/zrl]
+[zrl=[baseurl]/help/Creating-Templates]Creating Comanche Templates[/zrl]
+[zrl=[baseurl]/help/Widgets]Core Widgets[/zrl]
+[zrl=[baseurl]/help/plugins]Plugins[/zrl]
+[zrl=[baseurl]/help/doco]Contributing Documentation[/zrl]
+[zrl=[baseurl]/help/DerivedTheme1]Creating Derivative Themes[/zrl]
+[zrl=[baseurl]/help/schema_development]Schemas[/zrl]
+[zrl=[baseurl]/help/Translations]Translations[/zrl]
+[zrl=[baseurl]/help/developers]Developers[/zrl]
+[zrl=[baseurl]/help/intro_for_developers]Intro for Developers[/zrl]
+[zrl=[baseurl]/help/api_functions]API functions[/zrl]
+[zrl=[baseurl]/help/api_posting]Posting to the red# using the API[/zrl]
+[zrl=[baseurl]/help/developer_function_primer]Red Functions 101[/zrl]
+[zrl=[baseurl]/doc/html/]Code Reference (doxygen generated - sets cookies)[/zrl]
+[zrl=[baseurl]/help/to_do_doco]To-Do list for the Red Documentation Project[/zrl]
+[zrl=[baseurl]/help/to_do_code]To-Do list for Developers[/zrl]
+[zrl=[baseurl]/help/roadmap]Version 3 roadmap[/zrl]
+[zrl=[baseurl]/help/git_for_non_developers]Git for Non-Developers[/zrl]
+[zrl=[baseurl]/help/dev_beginner]Sep-for-step manual for beginning developers[/zrl]
+
+[h3]FAQ för utvecklare[/h3]
+[zrl=[baseurl]/help/faq_developers]FAQ For Developers[/zrl]
+
+[h3]Externa resurser[/h3]
+[zrl=[baseurl]/help/external-resource-links]External Resource Links[/zrl]
+[url=https://github.com/friendica/red]Main Website[/url]
+[url=https://github.com/friendica/red-addons]Addon Website[/url]
+[url=https://zothub.com/channel/one]Development Channel[/url]
+
+[url=[baseurl]/help/credits]$Projectname Credits[/url]
+
+[h3]About This $Projectname Hub[/h3]
+[zrl=[baseurl]/help/TermsOfService]Terms of Service For This Hub[/zrl]
+[zrl=[baseurl]/siteinfo]Hub Information (/siteinfo)[/zrl]
+[zrl=[baseurl]/siteinfo_json]Detailed Technical Hub Information (/siteinfo_json)[/zrl]
diff --git a/sources/doc/sv/roles.md b/sources/doc/sv/roles.md
new file mode 100644
index 00000000..f01b2a2f
--- /dev/null
+++ b/sources/doc/sv/roles.md
@@ -0,0 +1,57 @@
+Kanaltyper och deras behörighetsförval
+========================
+
+
+##Socialt
+
+**Övervägande offentlig**
+
+Kanalen är en typisk social nätverksprofil. Som standard är inlägg och publicerade filer offentliga men du kan ändra detta när du skapar innehållet i systemet och begränsa tillgången. Du är listat i katalogen. Din närvarostatus (för chatt) och dina kontakter (vänner) är synliga för andra.
+
+**Begränsad**
+
+Som standard delas alla inlägg och publicerade filer med din 'Friends'-krets* och är inte offentligt tillgängliga. Nya vänner läggs till denna krets. Du kan ändra detta och skapa offentliga inlägg eller filer om du så önskar. Du är listat i katalogen. Din närvarostatus (för chatt) och dina kontakter (vänner) är synliga för andra.
+
+**Privat**
+
+Som standard delas alla inlägg och publicerade filer med din 'Friends'-krets* och är inte offentligt tillgängliga. Nya vänner läggs till denna krets. Du kan ändra detta och skapa offentliga inlägg eller filer om du så önskar. Du är INTE listat i katalogen. Din närvarostatus är dold.
+
+##Forum
+
+**Övervägande offentlig**
+
+Kanalen är ett typiskt forum. Som standard är inlägg och publicerade filer offentliga. Forummedlemmar kan dela innehåll med forumet via @omnämnaden+ eller vägg-till-vägg inlägg. Skapandet av foton och andra filer är blockerad. Kanalen är listat i katalogen. Medlemmar läggs till automatisk.
+
+**Begränsad**
+
+Som standard delas alla inlägg och publicerade filer med din 'Friends'-krets* och är inte offentligt tillgängliga. Forummedlemmar kan dela innehåll med forumet via @omnämnaden+ eller vägg-till-vägg inlägg, men inlägg och svar kan också ses av andra mottagare av toppnivåinlägget. Skapandet av foton och andra filer är blockerad. Kanalen är listat i katalogen. Medlemmar måste läggas till av kanalägaren.
+
+**Privat**
+
+Som standard delas alla inlägg och publicerade filer med forumets medlemmar och är inte offentligt tillgängliga. Ägaren av forumet kan dela inlägg eller filer offentligt, men det kan inte medlemmarna. Inlägg kan endast skapas via vägg-till-vägg. Delning av innehåll med forumet via @omnämnaden+ är inaktiverad. Skapandet av foton och andra filer är blockerad. Kanalen är INTE listat i katalogen. Medlemmar måste läggas till av kanalägaren.
+
+##RSS-flöde
+
+**Offentlig**
+
+Lik socialt - övervägande offentlig, men specialanpassad till källor av RSS-flöden*. RSS-innehållet kan fritt delas och källhänvisas i systemet. Närvarostatus är meningslöst och därför inaktiverad. Nya kontakter läggs till automatisk.
+
+**Begränsad**
+
+Specialanpassad till källor av RSS-flöden*. RSS-innehållet delas endast med kanalens kontakter. Närvarostatus är meningslöst och därför inaktiverad. Kanalen är INTE listat i katalogen. Kontakter måste läggas till av kanalägaren.
+
+##Special
+
+**Berömdheter/envägskanal**
+
+Kanalen är en speciell social nätverksprofil anpassad till envägskontakt med anhängare. Din närvarostatus är dold. Kommentarer och återkoppling är inaktiverad. Som standard är inlägg och publicerade filer offentliga men du kan ändra detta när du skapar innehållet och begränsa tillgången. Kanalen är listat i katalogen.
+
+**Grupputrymme**
+
+Ett offentligt forum som möjliggör för medlemmar att dela filer, foton och webbsidor.
+
+##Specialanpassad/Expertläge
+
+Ställ själv in allt ihop så det passar till dina specifika önskemål.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/tags_and_mentions.bb b/sources/doc/tags_and_mentions.bb
new file mode 100644
index 00000000..d638492b
--- /dev/null
+++ b/sources/doc/tags_and_mentions.bb
@@ -0,0 +1,69 @@
+[b]Tags And Mentions[/b]
+
+Like many other platforms, Red uses a special notation inside messages to indicate "tags" or contextual links to other entities.
+
+[b]Mentions[/b]
+
+Channels are tagged by simply preceding their name with the @ character.
+
+[code]
+@Jack
+[/code]
+
+When you start to mention somebody, it will create an auto-complete box to select from your immediate connections. Select one as appropriate.
+
+If the person mentioned is in the list of recipients for the post, they will receive a tag notification.
+
+
+[b]Deliverable Mentions[/b]
+
+Some connections in the mention auto-complete box behave differently than others. If you mention a channel which provides "re-delivery of mentions" it will also send the post to all of that channel's default delivery connections. This is how one posts to "forums". The auto-complete box will provide two entries for these channels, one will mention just the channel. The other will invoke re-delivery and be listed as the channel's "network".
+
+[code]
+@Gardening - mention the Gardening forum
+[/code]
+
+[code]
+@Gardening+ - mention the Gardening Forum and also post to the Gardening "network" (e.g. all the forum members; if you have permission to do so)
+[/code]
+
+
+
+[b]Private Mentions[/b]
+
+If you wish to restrict a post to a single person or a number of people, you can do this by selecting channels or collections from the privacy tool. You can also just tag them with a privacy tag. A privacy tag is a name preceded by the two characters @! - and in addition to tagging these channels, will also change the privacy permissions of the post to only include them. You can have more than one privacy tag, for instance @!bob and @!linda will send the post only to Bob and Linda. This mechanism over-rides the privacy selector.
+
+You may also tag public collections. When you create or edit a collection, there is a checkbox to allow the group members to be seen by others. If this box is checked for a collection and you tag (for instance) @!Friends - the post will be restricted to the Friends collection. Check that the collection is public before doing this - as there is no way to take back a post except to delete it. The collection name will appear in the post and will alert members of that collection that they are members of it.
+
+
+[b]Mentions and Comments[/b]
+
+The above mechanisms only apply to "top-level" posts you create. Mentioning a channel with any of the above mechanisms has no effect in comments, except that the mentioned channel may receive a notification if they were already included as a recipient in the conversation.
+
+
+
+
+[b]Topical Tags[/b]
+
+Topical tags are indicated by preceding the tag name with the # character. This will create a link in the post to a generalised site search for the term provided. For example, #[zrl=https://friendicared.net/search?tag=cars]cars[/zrl] will provide a search link for all posts mentioning 'cars' on your site. Topical tags are generally a minimum of three characters in length. Shorter search terms are not likely to yield any search results, although this depends on the database configuration.
+
+Topical tags are also not linked if they are purely numeric, e.g. #1. If you wish to use a numeric hashtag, please add some descriptive text such as #[zrl=https://friendicared.net/search?tag=2012-elections]2012-elections[/zrl].
+
+
+[b]Spaces in Tags and Mentions[/b]
+
+Where possible please use the auto-complete window to select tag and mention recipients, because it will generate a coded tag which uniquely identifies one channel. Names are sometimes ambiguous. However, you can "manually" tag a channel by matching the channel name or address.
+
+[code]
+@Robert Johnson
+[/code]
+
+will tag Robert Johnson, but we can only match one space. If the name was "Blind Lemon Jefferson" it won't be found unless you enclose the entire name in double quotes or change the spaces to underscores.
+
+[code]
+@"Blind Lemon Jefferson"
+@Blind_Lemon_Jefferson
+[/code]
+
+are both equivalent.
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/to_do_code.bb b/sources/doc/to_do_code.bb
new file mode 100644
index 00000000..7fb6da85
--- /dev/null
+++ b/sources/doc/to_do_code.bb
@@ -0,0 +1,51 @@
+[b]Project Code To-Do List[/b]
+
+We need much more than this, but here are areas where developers can help. Please edit this page when items are finished. Another place for developers to start is with the issues list.
+
+[li]Documentation - see Red Documentation Project To-Do List[/li]
+[li]Include TOS link in registration/verification email[/li]
+[li](done) forum widget with unread counts (requires the DB schema changes from v3/hubzilla to be viable)[/li]
+[li]Create bug tracker module[/li]
+[li]translation plugins - moses or apertium[/li]
+[li]plugins - provide 'disable' which is softer than 'uninstall' for those plugins which create additional DB tables[/li]
+[li]Infinite scroll improvements (i.e. embedded page links) see http://scrollsample.appspot.com/items [/li]
+[li]Finish the anti-spam bayesian engine[/li]
+[li]implement an email permission denied bounce message from the sys channel[/li]
+[li]provide a way for xchans with a certain network type to upgrade (unknown to rss, rss to statusnet, friendica-over-diaspora to friendica, for instance) based on new knowledge and/or redmatrix ability[/li]
+[li](done - HZ) If DAV folders exist, add an option to the Settings page to set a default folder for attachment uploads.[/li]
+[li]Integrate the "open site" list with the register page[/li]
+[li]implement oembed provider interface[/li]
+[li]refactor the oembed client interface so that we can safely sandbox remote content[/li]
+[li]Many modern social apps now have both a profile photo and a "cover photo". Add support for this. [/li]
+[li]Write more webpage layouts[/li]
+[li]Write more webpage widgets[/li]
+[li]restricted access OAuth clients[/li]
+[li](Advanced) create a UI for building Comanche pages[/li]
+[li](less advanced) create a way to preview Comanche results on a preview page while editing on another page[/li]
+[li](done - HZ) Extend WebDAV to provide desktop access to photo albums[/li]
+[li]External post connectors - create standard interface[/li]
+[li]External post connectors, add popular services[/li]
+[li](in progress Habeas Codice) service classes - provide a pluggable subscription payment gateway for premium accounts[/li]
+[li](in progress Habeas Codice) service classes - account overview page showing resources consumed by channel. With special consideration this page can also be accessed at a meta level by the site admin to drill down on problematic accounts/channels.[/li]
+[li]Events module - fix permissions on events, and provide JS translation support for the calendar overview (done); integrate with calDAV[/li]
+[li]Uploads - integrate #^[url=https://github.com/blueimp/jQuery-File-Upload]https://github.com/blueimp/jQuery-File-Upload[/url][/li]
+[li]Import/export - include events, things, etc.[/li]
+[li]API extensions, for Twitter API - search, friending, threading. For Red API, lots of stuff[/li]
+[li]OAuth permission extensions[/li]
+[li]Import channel from Diaspora/Friendica (Diaspora partially done)[/li]
+[li]MediaGoblin photo "crosspost" connector[/li]
+[li]Create management page/UI for extensible profile fields[/li]
+[li]Create interface to include/exclude and re-order standard profile fields[/li]
+[li]Provide a mechanism to share page design elements in posts (just like apps) (done)[/li]
+[li]App taxonomy[/li]
+[li]Customisable App collection pages[/li]
+[li]replace the tinymce visual editor and/or make the visual editor pluggable and responsive to different output formats. We probably want library/bbedit for bbcode. This needs a fair bit of work to catch up with our "enhanced bbcode", but start with images, links, bold and highlight and work from there.[/li]
+[li]Photos module - turn photos into normal conversations and fix tagging[/li]
+[li]Create mobile clients for the top platforms - which involves extending the API so that we can do stuff far beyond the current crop of Twitter/Statusnet clients. Ditto for mobile themes. We can probably use something like the Friendica Android app as a base to start from.[/li]
+[li](in progress Habeas Codice) Implement owned and exchangeable "things".[/li]
+[li]Family Account creation - using service classes (an account holder can create a certain number of sub-accounts which are all tied to their subscription - if the subscription lapses they all go away).[/li]
+[li]Put mod_admin under Comanche[/li]
+
+In many cases some of the work has already been started and code exists so that you needn't start from scratch. Please contact one of the developer channels like Channel One (one@zothub.com) before embarking and we can tell you what we already have and provide some insights on how we envision these features fitting together.
+
+Return to the [url=[baseurl]/help/main]Main documentation page[/url]
diff --git a/sources/doc/to_do_doco.bb b/sources/doc/to_do_doco.bb
new file mode 100644
index 00000000..d0f595b3
--- /dev/null
+++ b/sources/doc/to_do_doco.bb
@@ -0,0 +1,23 @@
+[b]Documentation To-Do List[/b]
+
+[b]Documentation we need to write[/b]
+
+ Database schema detailed descriptions
+
+ Complete plugin hook documentation
+
+ API documentation
+
+ Function and code documentation (doxygen)
+
+ New Member guide
+
+ "Extra Feature" reference, description of each
+
+ Detailed Personal Settings Documentation
+
+ Administration Guide (post-install)
+
+ Administration Guide (pre-install)
+
+Return to the [url=[baseurl]/help/main]Main documentation page[/url]
diff --git a/sources/doc/to_do_doco.md b/sources/doc/to_do_doco.md
new file mode 100644
index 00000000..018b9efa
--- /dev/null
+++ b/sources/doc/to_do_doco.md
@@ -0,0 +1,31 @@
+# Documentation To-Do List #
+
+## How to contribute documentation ##
+
+Documentation files are in */doc*.
+
+When help is first accessed, the file loaded is *main.bb*. That file contains case sensitive links without an extension. The extensions is added automatically if the file is found, first *.md* then *.bb*.
+
+For translating documentation, create a directory in */doc* named by the language code, copy the files and translate the content.
+
+## Documentation we need to write ##
+
+* Database schema detailed descriptions
+
+* Complete plugin hook documentation
+
+* API documentation
+
+* Function and code documentation (doxygen)
+
+* New Member guide
+
+* "Extra Feature" reference, description of each
+
+* Detailed Personal Settings Documentation
+
+* Administration Guide (post-install)
+
+* Administration Guide (pre-install)
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/troubleshooting.bb b/sources/doc/troubleshooting.bb
new file mode 100644
index 00000000..1a2bd7f1
--- /dev/null
+++ b/sources/doc/troubleshooting.bb
@@ -0,0 +1,21 @@
+[b]Troubleshooting[/b]
+
+[li][zrl=[baseurl]/help/problems-following-an-update]Problems following an update[/zrl][/li]
+
+When reporting issues, please try to provide as much detail as may be necessary for developers to reproduce the issue and provide the complete text of all error messages.
+
+The system logfile is an extremely useful resource for tracking down things that go wrong. This can be enabled in the admin/log configuration page. A loglevel setting of LOGGER_DEBUG is preferred for stable production sites. Most things that go wrong with communications or storage are listed here. A setting of LOGGER_DATA provides [b]much[/b] more detail, but may fill your disk. In either case we recommend the use of logrotate on your operating system to cycle logs and discard older entries.
+
+At the bottom of your .htconfig.php file are several lines (commented out) which enable PHP error logging. This reports issues with code syntax and executing the code and is the first place you should look for issues which result in a "white screen" or blank page. This is typically the result of code/syntax problems.
+Database errors are reported to the system logfile, but we've found it useful to have a file in your top-level directory called dbfail.out which [b]only[/b] collects database related issues. If the file exists and is writable, database errors will be logged to it as well as to the system logfile.
+
+In the case of "500" errors, the issues may often be logged in your webserver logs, often /var/log/apache2/error.log or something similar. Consult your operating system documentation.
+
+We encourage you to try to the best of your abilities to use these logs combined with the source code in your possession to troubleshoot issues and find their cause. The community is often able to help, but only you have access to your site logfiles and it is considered a security risk to share them.
+
+
+If a code issue has been uncovered, please report it on the project bugtracker (https://github.com/redmatrix/hubzilla/issues). Again provide as much detail as possible to avoid us going back and forth asking questions about your configuration or how to duplicate the problem, so that we can get right to the problem and figure out what to do about it. You are also welcome to offer your own solutions and submit patches. In fact we encourage this as we are all volunteers and have little spare time available. The more people that help, the easier the workload for everybody. It's OK if your solution isn't perfect. Every little bit helps and perhaps we can improve on it.
+
+#include doc/macros/troubleshooting_footer.bb;
+#include doc/macros/main_footer.bb;
+
diff --git a/sources/doc/webpages.bb b/sources/doc/webpages.bb
new file mode 100644
index 00000000..040ad0c5
--- /dev/null
+++ b/sources/doc/webpages.bb
@@ -0,0 +1,90 @@
+[b]Creating Web Pages[/b]
+
+Red enables users to create static webpages. To activate this feature, enable the web pages feature in your Additional Features section.
+
+Once enabled, a new tab will appear on your channel page labelled "Webpages". Clicking this link will take you to the webpage editor.
+Pages will be accessible at mydomain/page/username/pagelinktitle
+
+The "page link title" box allows a user to specify the "pagelinktitle" of this URL. If no page link title is set, we will set one for you automatically, using the message ID of the item.
+
+Beneath the page creation box, a list of existing pages will appear with an "edit" link. Clicking this will take you to an editor, similar to that of the post editor, where you can make changes to your webpages.
+
+
+[b]Using Blocks[/b]
+
+Blocks can be parts of webpages. The basic HTML of a block looks like this
+[code]
+
+ Block Content
+
+
+[/code]
+
+If a block has text/html content type it can also contain menu elements. Sample content of
+[code]
+
HTML block content
+ [menu]menuname[/menu]
+
+[/code]
+will produce HTML like this
+[code]
+
+
+[/code]
+
+Via the $content macro a block can also contain the actual webpage content. For this create a block with only
+[code]
+ $content
+
+[/code]as content.
+
+To make a block appear in the webpage it must be defined in the page layout inside a region.
+[code]
+ [region=aside]
+ [block]blockname[/block]
+ [/region]
+
+[/code]
+
+The block appearance can be manipulated in the page layout.
+
+Custom classes can be assigned
+[code]
+ [region=aside]
+ [block=myclass]blockname[/block]
+ [/region]
+
+[/code]
+will produce this HTML
+[code]
+
+ Block Content
+
+
+[/code]
+
+Via the wrap variable a block can be stripped off its wrapping tag
+[code]
+ [region=aside]
+ [block][var=wrap]none[/var]blockname[/block]
+ [/region]
+
+[/code]
+will produce this HTML
+[code]
+ Block Content
+
+[/code]
+
+
+#include doc/macros/main_footer.bb;
+
diff --git a/sources/doc/what_is_zot.bb b/sources/doc/what_is_zot.bb
new file mode 100644
index 00000000..50df9e39
--- /dev/null
+++ b/sources/doc/what_is_zot.bb
@@ -0,0 +1,61 @@
+[b]What is Zot?[/b]
+
+Zot is the protocol that powers the $Projectname, providing three core capabilities: Communications, Identity, and Access Control.
+
+The functionality it provides can also be described as follows:
+
+ - a relationship online is just a bunch of permissions
+ - the internet is just another folder
+
+[b][size=20]Communications[/size][/b]
+
+Zot is a revolutionary protocol which provides [i]decentralised communications[/i] and [i]identity management[/i] across the matrix. The resulting platform can provide web services comparable to those offered by large corporate providers, but without the large corporate provider and their associated privacy issues, insatiable profit drive, and walled-garden mentality.
+
+Communications and social networking are an integral part of the matrix. Any channel (and any services provided by that channel) can make full use of feature-rich social communications on a global scale. These communications may be public or private - and private communications comprise not only fully encrypted transport, but also encrypted storage to help protect against accidental snooping and disclosure by rogue system administrators and internet service providers.
+
+Zot allows a wide array of background services in the matrix, from offering friend suggestions, to directory services. You can also perform other things which would typically only be possibly on a centralized provider - such as "Wall to Wall" posts. Priivate/multiple profiles can be easily created, and web content can be tailored to the viewer via the [i]Affinity Slider[/i].
+
+You won't find these features at all on other decentralized communication services. In addition to providing hub (server) decentralization, perhaps the most innovative and interesting Zot feature is its provision of [i]decentralized identity[/i] services.
+
+[b][size=20]Identity[/size][/b]
+
+Zot's identity layer is unique. It provides [i]invisible single sign-on[/i] across all sites in the matrix.
+
+It also provides [i]nomadic identity[/i], so that your communications with friends, family, and or anyone else you're communicating with won't be affected by the loss of your primary communication node - either temporarily or permanently.
+
+The important bits of your identity and relationships can be backed up to a thumb drive, or your laptop, and may appear at any node in the matrix at any time - with all your friends and preferences intact.
+
+Crucially, these nomadic instances are kept in sync so any instance can take over if another one is compromised or damaged. This protects you against not only major system failure, but also temporary site overloads and governmental manipulation or censorship.
+
+Nomadic identity, single sign-on, and Red's decentralization of hubs, we believe, introduce a high degree of degree of [i]resiliency[/i] and [i]persistence[/i] in internet communications, that are sorely needed amidst global trends towards corporate centralization, as well as mass and indiscriminate government surveillance and censorship.
+
+As you browse the matrix, viewing channels and their unique content, you are seamlessly authenticated as you go, even across completely different server hubs. No passwords to enter. Nothing to type. You're just greeted by name on every new site you visit.
+
+How does Zot do that? We call it [i]magic-auth[/i], because Red hides the details of the complexities that go into single sign-on logins, and nomadic identities, from the experience of browsing on the matrix. This is one of the design goals of Red: to increase privacy, and freedom on the web, while reducing the complexity and tedium brought by the need to enter new passwords and user names for every different sight that someone might visit online.
+
+You login only once on your home hub (or any nomadic backup hub you have chosen). This allows you to access any authenticated services provided anywhere in the matrix - such as shopping, blogs, forums, and access to private information. This is just like the services offered by large corporate providers with huge user databases; however you can be a member of this community, as well as a server on this network using a $35 Rasberry Pi. Your password isn't stored on a thousand different sites, or even worse, only on a few sites like Google and Facebook, beyond your direct control.
+
+You cannot be silenced. You cannot be removed from the matrix, unless you yourself choose to exit it.
+
+[b][size=20]Access Control[/size][/b]
+
+Zot's identity layer allows you to provide fine-grained permissions to any content you wish to publish - and these permissions extend across the $Projectname. This is like having one super huge website made up of an army of small individual websites - and where each channel in the matrix can completely control their privacy and sharing preferences for any web resources they create.
+
+Currently, the matrix supports communications, photo albums, events, and files. This will be extended in the future to provide content management services (web pages) and cloud storage facilities, such as WebDAV and multi-media libraries. Every object and how it is shared and with whom is completely under your control.
+
+This type of control is available on large corporate providers such as Facebook and Google, because they own the user database. Within the matrix, there is no need for a huge user databaseon your machine - because the matrix [i]is[/i] your user database. It has what is essentially infinite capacity (limited by the total number of hubs online across the internet), and is spread amongst hundreds, and potentially millions of computers.
+
+Access can be granted or denied for any resource, to any channel, or any group of channels; anywhere within the matrix. Others can access your content if you permit them to do so, and they do not even need to have an account on your hub. Your private photos cannot be viewed, because permission really work; they are not an addon that was added as an afterthought. If you aren't on the list of allowed viewers for a particular photo, you aren't going to look at it.
+
+[b][size=18]Additional Resources and Links[/size][/b]
+
+For more detailed, technical information about Zot, check out the following links:
+
+ - [url=https://github.com/friendica/red/wiki/Zot---A-High-Level-Overview]A high level overview[/url]
+
+ - [url=https://github.com/friendica/red/wiki/zot]Zot development specification[/url]
+
+ - [url=https://github.com/redmatrix/hubzilla/blob/master/include/zot.php]Zot reference implementation in PHP[/url]
+
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/zot.md b/sources/doc/zot.md
new file mode 100644
index 00000000..f8881c55
--- /dev/null
+++ b/sources/doc/zot.md
@@ -0,0 +1,400 @@
+Intro to Zot
+============
+
+Zot is a JSON-based web framework for implementing secure decentralised communications and services.
+
+It differs from many other communication protocols by building communications on top of a decentralised identity and authentication framework.
+
+The authentication component is similar to OpenID conceptually but is insulated from DNS-based identities. Where possible remote authentication is silent and invisible. This provides a mechanism for internet scale distributed access control which is unobtrusive.
+
+For example,
+
+Jaquelina wishes to share photos with Roberto from her blog at "jaquelina.com.xyz", but to nobody else. Roberto maintains his own family website at "roberto.com.xyz". Zot allows Jaquelina to create an access list containing "Roberto" and allow Roberto unhindered access to the photos but without allowing Roberto's brother Marco to see the photos.
+
+Roberto will only login once to his own website at roberto.com.xyz using his password. After this, no further passwords will be asked for. Marco may also have an account on roberto.com.xyz, but he is not allowed to see Jaquelina's photos.
+
+
+Additionally, zot allows Roberto to use another site - gadfly.com.xyz, and after login to gadfly.com.xyz he can also access Jaquelina's private photos. Jaquelina does not have to do anything extra to allow this, as she has already given access rights of her private photos to Roberto - no matter what site he is logged into.
+
+Zot also allows basic messaging and communications with anybody else on the Zot network.
+
+In order to provide this functionality, zot creates a decentralised globally unique identifier for each node on the network. This global identifier is not linked inextricably to DNS, providing the requisite mobility. Many existing decentralised communications frameworks provide the communication aspect, but do not provide remote access control and authentication. Additionally most of these are based on 'webfinger' such that in our example, Roberto would only be recognised if he accessed Jaquelina's photos from roberto.com.xyz - but not from gadfly.com.xyz.
+
+
+The primary issues zot addresses are
+
+* completely decentralised communications
+* insulation from DNS based identity
+* node mobility
+* invisible or reduced "interaction" remote authentication
+* high performance
+
+We will rely on DNS-based user@host addresses as a "user-friendly" mechanism to let people know where you are, specifically on a named host with a given username, and communication will be carried out to DNS entities using TCP and the web.
+
+But the underlying protocol will provide an abstraction layer on top of this, so that a communications node (e.g. "identity") can move to an alternate DNS location and (to the best of our ability) gracefully recover from site re-locations and/or maintain pre-existing communication relationships. A side effect of this requirement is the ability to communicate from alternate/multiple DNS locations and service providers and yet maintain a single online identity.
+
+We will call this overlay network the "grid". Servers attached to this network are known as "hubs" and may support any number of individual identities.
+
+An identity does not necessarily correspond to a person. It is just something which requires the ability to communicate within the grid.
+
+The ability to recover will be accomplished by communication to the original location when creating a new or replacement identity, or as a fallback from a stored file describing the identity and their contacts in the case where the old location no longer responds.
+
+At least on the short term, the mobility of existing content is not a top priority. This may or may not take place at a later stage. The most important things we want to keep are your identity and your friends.
+
+Addresses which are shared amongst people are user@host, and which describe the **current** local account credentials for a given identity. These are DNS based addresses and used as a seed to locate a given identity within the grid. The machine communications will bind this address to a globally unique ID. A single globally unique ID may be attached or bound to any number of DNS locations. Once an identity has been mapped or bound to a DNS location, communications will consist of just knowing the globally unique address, and what DNS (url) is being used currently (in order to call back and verify/complete the current communication). These concepts will be specified in better detail.
+
+In order for an identity to persist across locations, one must be able to provide or recover
+
+* the globally unique ID for that identity
+* the private key assigned to that identity
+* (if the original server no longer exists) an address book of contacts for that identity.
+
+This information will be exportable from the original server via API, and/or downloadable to disk or thumb-drive.
+
+We may also attempt to recover with even less information, but doing so is prone to account hijacking and will require that your contacts confirm the change.
+
+In order to implement high performance communications, the data transfer format for all aspects of zot is JSON. XML communications require way too much overhead.
+
+Bi-directional encryption is based on RSA 4096-bit keys expressed in DER/ASN.1 format using the PKCS#8 encoding variant, with AES-256-CBC used for block encryption of variable length or large items.
+
+Some aspects of well known "federation protocols" (webfinger, salmon, activitystreams, portablecontacts, etc.) may be used in zot, but we are not tied to them and will not be bound by them. The $Projectname project is attempting some rather novel developments in decentralised communications and if there is any need to diverge from such "standard protocols" we will do so without question or hesitation.
+
+In order to create a globally unique ID, we will base it on a whirlpool hash of the identity URL of the origination node and a psuedo-random number, which should provide us with a 256 bit ID with an extremely low probability of collision (256 bits represents approximately 115 quattuorviginitillion or 1.16 X 10^77 unique numbers). This will be represented in communications as a base64url-encoded string. We will not depend on probabilities however and the ID must also be attached to a public key with public key cryptography used to provide an assurance of identity which has not been copied or somehow collided in whirlpool hash space.
+
+Basing this ID on DNS provides a globally unique seed, which would not be the case if it was based completely on psuedo-random number generation.
+
+We will refer to the encoded globally unique uid string as zot_uid
+
+As there may be more than one DNS location attached/bound to a given zot_uid identity, delivery processes should deliver to all of them - as we do not know for sure which hub instance may be accessed at any given time. However we will designate one DNS location as "primary" and which will be the preferred location to view web profile information.
+
+We must also provide the ability to change the primary to a new location. A look-up of information on the current primary location may provide a "forwarding pointer" which will tell us to update our records and move everything to the new location. There is also the possibility that the primary location is defunct and no longer responding. In that case, a location which has already been mapped to this zot_uid can seize control, and declare itself to be primary. In both cases the primary designation is automatically approved and moved. A request can also be made from a primary location which requests that another location be removed.
+
+In order to map a zot_uid to a second (or tertiary) location, we require a secure exchange which verifies that the new location is in possession of the private key for this zot_uid. Security of the private key is thus essential to avoid hijacking of identities.
+
+Communications will then require
+
+* zot_uid (string)
+* uid_sig
+* callback (current location zot endpoint url)
+* callback_sig
+* spec (int)
+
+passed with every communique. The spec is a revision number of the applicable zot spec so that communications can be maintained with hubs using older and perhaps incompatible protocol specifications. Communications are verified using a stored public key which was copied when the connection to this zot_uid was first established.
+
+Key revocation and replacement must take place from the primary hub. The exact form for this is still being worked out, but will likely be a notification to all other bound hubs to "phone home" (to the primary hub) and request a copy of the new key. This communique should be verified using a site or hub key; as the original identity key may have been compromised and cannot be trusted.
+
+In order to eliminate confusion, there should be exactly one canonical url for any hub, so that these can be indexed and referenced without ambiguity.
+
+So as to avoid ambiguity of scheme, it is strongly encouraged that all addresses to be https with a "browser valid" cert and a single valid host component (either www.domain.ext or domain.ext, but not both), which is used in all communications. Multiple URLs may be provided locally, but only one unique URL should be used for all zot communications within the grid.
+
+Test installation which do not connect to the public grid may use non-SSL, but all traffic flowing over public networks should be safe from session-hijacking, preferably with a "browser recognised" cert.
+
+Where possible, zot encourages the use of "batching" to minimise network traffic between two hubs. This means that site 'A' can send multiple messages to site 'B' in a single transaction, and also consolidate deliveries of identical messages to multiple recipients on the same hub.
+
+Messages themselves may or may not be encrypted in transit, depending on the private nature of the messages. SSL (strongly encouraged) provides unconditional encryption of the data stream, however there is little point in encrypting public communications which have been designated as having unrestricted visibility. The encryption of data storage and so-called "end-to-end encryption" is outside the scope of zot. It is presumed that hub operators will take adequate safeguards to ensure the security of their data stores and these are functions of application and site integrity as opposed to protocol integrity.
+
+
+## Messages
+
+Given the constraints listed previously, a zot communique should therefore be a json array of individual messages. These can be mixed and combined within the same transmission.
+
+Each message then requires:
+
+* type
+* (optional) recipient list
+
+Lack of a recipient list would indicate an unencrypted public or site level message. The recipient list would contain an array of zot_uid with an individual decryption key, and a common iv. The decryption key is encoded with the recipient identity's public key. The iv is encrypted with the sender's private key.
+
+All messages should be digitally signed by the sender.
+
+The type can be one of (this list is extensible):
+
+* post (or activity)
+* mail
+* identity
+* authenticate
+
+Identity messages have no recipients and notify the system social graph of an identity update, which could be a new or deleted identity, a new or deleted location, or a change in primary hub. The signature for these messages uses system keys as opposed to identity-specific keys.
+
+Posts include many different types of activities, such as top-level posts, likes/dislikes, comments, tagging activities, etc. These types are indicated within the message sturcture.
+
+authenticate messages result in mutual authentication and browser redirect to protected resources on the remote hub such as the ability to post wall-to-wall messages and view private photo albums and events, etc.
+
+## Discovery
+
+A well-known url is used to probe a hub for zot capabilities and identity lookups, including the discovery of public keys, profile locations, profile photos, and primary hub location.
+
+The location for this service is /.well-known/zot-info - and must be available at the root of the chosen domain.
+
+To perform a lookup, a POST request is made to the discovery location with the following parameters:
+
+Required:
+
+address => an address on the target system such as "john"
+
+Optional
+
+target => the zot "guid" of the observer for evaluating permissions
+
+target_sig => an RSA signature (base64url encoded) of the guid
+
+key => The public key needed to verify the signature
+
+With no target provided, the permissions returned will be generic permissions
+for unknown or unauthenticated observers
+
+Example of discovery packet for 'mike@zothub.com'
+
+ {
+
+ "success": true,
+ "guid": "sebQ-IC4rmFn9d9iu17m4BXO-kHuNutWo2ySjeV2SIW1LzksUkss12xVo3m3fykYxN5HMcc7gUZVYv26asx-Pg",
+ "guid_sig": "Llenlbl4zHo6-g4sa63MlQmTP5dRCrsPmXHHFmoCHG63BLq5CUZJRLS1vRrrr_MNxr7zob_Ykt_m5xPKe5H0_i4pDj-UdP8dPZqH2fqhhx00kuYL4YUMJ8gRr5eO17vsZQ3XxTcyKewtgeW0j7ytwMp6-hFVUx_Cq08MrXas429ZrjzaEwgTfxGnbgeQYQ0R5EXpHpEmoERnZx77VaEahftmdjAUx9R4YKAp13pGYadJOX5xnLfqofHQD8DyRHWeMJ4G1OfWPSOlXfRayrV_jhnFlZjMU7vOdQwHoCMoR5TFsRsHuzd-qepbvo3pzvQZRWnTNu6oPucgbf94p13QbalYRpBXKOxdTXJrGdESNhGvhtaZnpT9c1QVqC46jdfP0LOX2xrVdbvvG2JMWFv7XJUVjLSk_yjzY6or2VD4V6ztYcjpCi9d_WoNHruoxro_br1YO3KatySxJs-LQ7SOkQI60FpysfbphNyvYMkotwUFI59G08IGKTMu3-GPnV1wp7NOQD1yzJbGGEGSEEysmEP0SO9vnN45kp3MiqbffBGc1r4_YM4e7DPmqOGM94qksOcLOJk1HNESw2dQYWxWQTBXPfOJT6jW9_crGLMEOsZ3Jcss0XS9KzBUA2p_9osvvhUKuKXbNztqH0oZIWlg37FEVsDs_hUwUJpv2Ar09k4",
+ "key": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA7QCwvuEIwCHjhjbpz3Oc\ntyei/Pz9nDksNbsc44Cm8jxYGMXsTPFXDZYCcCB5rcAhPPdZSlzaPkv4vPVcMIrw\n5cdX0tvbwa3rNTng6uFE7qkt15D3YCTkwF0Y9FVZiZ2Ko+G23QeBt9wqb9dlDN1d\nuPmu9BLYXIT/JXoBwf0vjIPFM9WBi5W/EHGaiuqw7lt0qI7zDGw77yO5yehKE4cu\n7dt3SakrXphL70LGiZh2XGoLg9Gmpz98t+gvPAUEotAJxIUqnoiTA8jlxoiQjeRK\nHlJkwMOGmRNPS33awPos0kcSxAywuBbh2X3aSqUMjcbE4cGJ++/13zoa6RUZRObC\nZnaLYJxqYBh13/N8SfH7d005hecDxWnoYXeYuuMeT3a2hV0J84ztkJX5OoxIwk7S\nWmvBq4+m66usn6LNL+p5IAcs93KbvOxxrjtQrzohBXc6+elfLVSQ1Rr9g5xbgpub\npSc+hvzbB6p0tleDRzwAy9X16NI4DYiTj4nkmVjigNo9v2VPnAle5zSam86eiYLO\nt2u9YRqysMLPKevNdj3CIvst+BaGGQONlQalRdIcq8Lin+BhuX+1TBgqyav4XD9K\nd+JHMb1aBk/rFLI9/f2S3BJ1XqpbjXz7AbYlaCwKiJ836+HS8PmLKxwVOnpLMbfH\nPYM8k83Lip4bEKIyAuf02qkCAwEAAQ==\n-----END PUBLIC KEY-----\n",
+ "name": "Mike Macgirvin",
+ "name_updated": "2012-12-06 04:59:13",
+ "address": "mike@zothub.com",
+ "photo_mimetype": "image/jpeg",
+ "photo": "https://zothub.com/photo/profile/l/1",
+ "photo_updated": "2012-12-06 05:06:11",
+ "url": "https://zothub.com/channel/mike",
+ "connections_url": "https://zothub.com/poco/mike",
+ "target": "",
+ "target_sig": "",
+ "searchable": false,
+ "permissions": {
+ "view_stream": true,
+ "view_profile": true,
+ "view_photos": true,
+ "view_contacts": true,
+ "view_storage": true,
+ "view_pages": true,
+ "send_stream": false,
+ "post_wall": false,
+ "post_comments": false,
+ "post_mail": false,
+ "post_photos": false,
+ "tag_deliver": false,
+ "chat": false,
+ "write_storage": false,
+ "write_pages": false,
+ "delegate": false
+ },
+ "profile": {
+ "description": "Freedom Fighter",
+ "birthday": "0000-05-14",
+ "next_birthday": "2013-05-14 00:00:00",
+ "gender": "Male",
+ "marital": "It's complicated",
+ "sexual": "Females",
+ "locale": "",
+ "region": "",
+ "postcode": "",
+ "country": "Australia"
+ },
+ "locations": [
+ {
+ "host": "zothub.com",
+ "address": "mike@zothub.com",
+ "primary": true,
+ "url": "https://zothub.com",
+ "url_sig": "eqkB_9Z8nduBYyyhaSQPPDN1AhSm5I4R0yfcFxPeFpuu17SYk7jKD7QzvmsyahM5Kq7vDW6VE8nx8kdFYpcNaurqw0_IKI2SWg15pGrhkZfrCnM-g6A6qbCv_gKCYqXvwpSMO8SMIO2mjQItbBrramSbWClUd2yO0ZAceq3Z_zhirCK1gNm6mGRJaDOCuuTQNb6D66TF80G8kGLklv0o8gBfxQTE12Gd0ThpUb5g6_1L3eDHcsArW_RWM2XnNPi_atGNyl9bS_eLI2TYq0fuxkEdcjjYx9Ka0-Ws-lXMGpTnynQNCaSFqy-Fe1aYF7X1JJVJIO01LX6cCs-kfSoz29ywnntj1I8ueYldLB6bUtu4t7eeo__4t2CUWd2PCZkY3PKcoOrrnm3TJP5_yVFV_VpjkcBCRj3skjoCwISPcGYrXDufJxfp6bayGKwgaCO6QoLPtqqjPGLFm-fbn8sVv3fYUDGilaR3sFNxdo9mQ3utxM291XE2Pd0jGgeUtpxZSRzBuhYeOybu9DPusID320QbgNcbEbEImO8DuGIxuVRartzEXQF4WSYRdraZzbOqCzmU0O55P836JAfrWjgxTQkXlYCic-DBk-iE75JeT72smCtZ4AOtoFWCjZAABCw42J7JELY9APixZXWriKtjy6JI0G9d3fs6r7SrXr1JMy0",
+ "callback": "https://zothub.com/post",
+ "sitekey": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA1IWXwd/BZuevq8jzNFoR\n3VkenduQH2RpR3Wy9n4+ZDpbrUKGJddUGm/zUeWEdKMVkgyllVA/xHdB7jdyKs1X\nuIet9mIdnzvhdLO/JFD5hgbNG2wpSBIUY6aSNeCFTzszqXmuSXMW5U0Ef5pCbzEA\nnhoCoGL1KAgPqyxnGKUlj7q2aDwC9IRNtAqNyFQL67oT91vOQxuMThjlDhbR/29Q\ncYR4i1RzyahgEPCnHCPkT2GbRrkAPjNZAdlnk9UesgP16o8QB3tE2j50TVrbVc/d\nYRbzC56QMPP9UgUsapNeSJBHji75Ip/E5Eg/kfJC/HEQgyCqjCGfb7XeUaeQ7lLO\nqc7CGuMP+Jqr/cE54/aSHg8boTwxkMp11Ykb+ng17fl57MHTM2RJ99qZ1KBkXezR\nuH1lyvjzeJPxEFr9rkUqc4GH74/AgfbgaFvQc8TS7ovEa5I/7Pg04m7vLSEYc6UF\nYJYxXKrzmZT2TDoKeJzaBBx5MFLhW19l68h9dQ8hJXIpTP0hJrpI+Sr6VUAEfFQC\ndIDRiFcgjz6j7T/x8anqh63/hpsyf2PMYph1+4/fxtSCWJdvf+9jCRM8F1IDfluX\n87gm+88KBNaklYpchmGIohbjivJyru41CsSLe0uinQFvA741W00w6JrcrOAX+hkS\nRQuK1dDVwGKoIY85KtTUiMcCAwEAAQ==\n-----END PUBLIC KEY-----\n"
+ }
+ ],
+ "site": {
+ "url": "https://zothub.com",
+ "directory_mode": "primary",
+ "directory_url": "https://zothub.com/dirsearch"
+ }
+
+ }
+
+
+
+Discovery returns a JSON array with the following components:
+
+'success' => ('1' or '') Operation was successful if '1'. Otherwise an optional 'message' may be present indicating the source of error.
+
+'guid' => the guid of the address on the target system
+
+'guid_sig' => the base64url encoded RSA signature of the guid, signed with the private key associated with that guid.
+
+'key' => the public key associated with that guid
+
+'name' => channel name
+
+'name_updated' => MySQL style timestamp '2012-01-01 00:00:00' when the name was last changed (UTC)
+
+'address' => "webbie" or user@host address associated with this channel
+
+'photo' => URL of a profile photo for this channel (ideally 175x175)
+
+'photo_mimetype' => content-type of the profile photo
+
+'photo_updated' => MySQL style timestamp when photo was last updated (UTC)
+
+'url' => location of channel homepage
+
+'connections_url' => location of Portable Contacts (extended for zot) URL for this channel
+
+'target' => if a permissions target was specified, it is mirrored
+
+'target_sig' => if a permissions target was specified, the signature is mirrored.
+
+'searchable' => ('1' or '') '1' indicates this entry can be searched in a directory
+
+###Permissions
+
+
+'permisssions' => extensible array of permissions appropriate to this target, values are '1' or ''
+
+ Permissions may include:
+
+* view_stream
+
+* view_profile
+
+* view_photos
+
+* view_contacts
+
+* view_storage
+
+* view_pages
+
+* send_stream
+
+* post_wall
+
+* post_comments
+
+* post_mail
+
+* post_photos
+
+* tag_deliver
+
+* chat
+
+* write_storage
+
+* write_pages
+
+* delegate
+
+
+
+###Profile
+
+
+'profile' => array of important profile fields
+
+* description
+
+* birthday YYYY-MM-DD , all fields are optional, any field (such as year) may be zero
+
+* next_birthday => MySQL datetime string representing the next upcoming birthday, converted from the channel's default timezone to UTC.
+
+* gender (free form)
+
+* marital (marital status)
+
+* sexual (preference)
+
+* locale (city)
+
+* region (state)
+
+* postcode
+
+* country
+
+
+###Locations
+
+
+'locations' => array of registered locations (DNS locations) this channel may be visible or may be posting from
+
+Each location is an array of
+
+'host' => DNS hostname, e.g. example.com
+
+'address' => the webbie or user@host identifier associated with this location
+
+'primary' => ('1' or '') whether or not this is the primary location for this channel where files and web pages are generally found
+
+'url' => url of the root of this DNS location e.g. https://example.com
+
+'url_sig' => base64url encoded RSA signature of the URL, signed with the channel private key
+
+'callback' => zot communications endpoint on this site, usually https://example.com/post
+
+'sitekey' => public key of this site/host
+
+
+###Site
+
+
+'site' => array providing the directory role of the site responding to this request
+
+'url' => url of this site e.g. https://example.com
+
+'directory_mode' => one of 'primary', 'secondary', 'normal', or 'standalone'
+
+'directory_url' => if this is a directory server or standalone, the URL for the directory search module
+
+
+
+Magic Auth
+==========
+
+
+So-called "magic auth" takes place by a special exchange. On the remote computer, a redirection is made to the zot endpoint with special GET parameters.
+
+Endpoint: https://example.com/post/name
+
+where 'name' is the left hand side of the channel webbie, for instance 'mike' where the webbie is 'mike@zothub.com'
+
+Additionally four parameters are supplied:
+
+* auth => the webbie of the person requesting access
+* dest => the desired destination URL (urlencoded)
+* sec => a random string which is also stored locally for use during the verification phase.
+* version => the zot revision
+
+When this packet is received, a zot message is initiated to the auth identity:
+
+
+ {
+ "type":"auth_check",
+ "sender":{
+ "guid":"kgVFf_1_SSbyqH-BNWjWuhAvJ2EhQBTUdw-Q1LwwssAntr8KTBgBSzNVzUm9_RwuDpxI6X8me_QQhZMf7RfjdA",
+ "guid_sig":"PT9-TApzpm7QtMxC63MjtdK2nUyxNI0tUoWlOYTFGke3kNdtxSzSvDV4uzq_7SSBtlrNnVMAFx2_1FDgyKawmqVtRPmT7QSXrKOL2oPzL8Hu_nnVVTs_0YOLQJJ0GYACOOK-R5874WuXLEept5-KYg0uShifsvhHnxnPIlDM9lWuZ1hSJTrk3NN9Ds6AKpyNRqf3DUdz81-Xvs8I2kj6y5vfFtm-FPKAqu77XP05r74vGaWbqb1r8zpWC7zxXakVVOHHC4plG6rLINjQzvdSFKCQb5R_xtGsPPfvuE24bv4fvN4ZG2ILvb6X4Dly37WW_HXBqBnUs24mngoTxFaPgNmz1nDQNYQu91-ekX4-BNaovjDx4tP379qIG3-NygHTjFoOMDVUvs-pOPi1kfaoMjmYF2mdZAmVYS2nNLWxbeUymkHXF8lT_iVsJSzyaRFJS1Iqn7zbvwH1iUBjD_pB9EmtNmnUraKrCU9eHES27xTwD-yaaH_GHNc1XwXNbhWJaPFAm35U8ki1Le4WbUVRluFx0qwVqlEF3ieGO84PMidrp51FPm83B_oGt80xpvf6P8Ht5WvVpytjMU8UG7-js8hAzWQeYiK05YTXk-78xg0AO6NoNe_RSRk05zYpF6KlA2yQ_My79rZBv9GFt4kUfIxNjd9OiV1wXdidO7Iaq_Q",
+ "url":"http:\/\/podunk.edu",
+ "url_sig":"T8Bp7j5DHHhQDCFcAHXfuhUfGk2P3inPbImwaXXF1xJd3TGgluoXyyKDx6WDm07x0hqbupoAoZB1qBP3_WfvWiJVAK4N1FD77EOYttUEHZ7L43xy5PCpojJQmkppGbPJc2jnTIc_F1vvGvw5fv8gBWZvPqTdb6LWF6FLrzwesZpi7j2rsioZ3wyUkqb5TDZaNNeWQrIEYXrEnWkRI_qTSOzx0dRTsGO6SpU1fPWuOOYMZG8Nh18nay0kLpxReuHCiCdxjXRVvk5k9rkcMbDBJcBovhiSioPKv_yJxcZVBATw3z3TTE95kGi4wxCEenxwhSpvouwa5b0hT7NS4Ay70QaxoKiLb3ZjhZaUUn4igCyZM0h6fllR5I6J_sAQxiMYD0v5ouIlb0u8YVMni93j3zlqMWdDUZ4WgTI7NNbo8ug9NQDHd92TPmSE1TytPTgya3tsFMzwyq0LZ0b-g-zSXWIES__jKQ7vAtIs9EwlPxqJXEDDniZ2AJ6biXRYgE2Kd6W_nmI7w31igwQTms3ecXe5ENI3ckEPUAq__llNnND7mxp5ZrdXzd5HHU9slXwDShYcW3yDeQLEwAVomTGSFpBrCX8W77n9hF3JClkWaeS4QcZ3xUtsSS81yLrp__ifFfQqx9_Be89WVyIOoF4oydr08EkZ8zwlAsbZLG7eLXY"
+ },
+ "recipients":{
+ {
+ "guid":"ZHSqb3yGar3TYV_o9S-JkD-6o_V4DhUcxtv0VeyX8Kj_ENHPI_M3SyAUucU835-mIayGMmTpqJz3ujPkcavVhA",
+ "guid_sig":"JsAAXigNghTkkbq8beGMJjj9LBKZn28hZ-pHSsoQuwYWvBJ2lSnfc4r9l--WgO6sucH-SR6RiBo78eWn1cZrh_cRMu3x3LLx4y-tjixg-oOOgtZakkBg4vmOhkKPkci0mFtzvUrpY4YHySqsWTuPwRx_vOlIYIGEY5bRXpnkNCoC8J4EJnRucDrgSARJvA8QQeQQL0H4mWEdGL7wlsZp_2VTC6nEMQ48Piu6Czu5ThvLggGPDbr7PEMUD2cZ0jE4SeaC040REYASq8IdXIEDMm6btSlGPuskNh3cD0AGzH2dMciFtWSjmMVuxBU59U1I6gHwcxYEV6BubWt_jQSfmA3EBiPhKLyu02cBMMiOvYIdJ3xmpGoMY1Cn__vhHnx_vEofFOIErb6nRzbD-pY49C28AOdBA5ffzLW3ss99d0A-6GxZmjsyYhgJu4tFUAa7JUl84tMbq28Tib0HW6qYo6QWw8K1HffxcTpHtwSL5Ifx0PAoGMJsGDZDD1y_r9a4vH5pjqmGrjL3RXJJUy-m4eLV5r7xMWXsxjqu3D8r04_dcw4hwwexpMT1Nwf8CTB0TKb8ElgeOpDFjYVgrqMYWP0XdhatcFtAJI7gsS-JtzsIwON9Kij66-VAkqy_z1IXI0ziyqV1yapSVYoUV1vMScRZ_nMqwiB5rEDx-XLfzko"
+ }
+ }
+ "callback":"\/post",
+ "version":1,
+ "secret":"1eaa6613699be6ebb2adcefa5379c61a3678aa0df89025470fac871431b70467",
+ "secret_sig":"eKV968b1sDkOVdSMi0tLRtOhQw4otA8yFKaVg6cA4I46_zlAQGbFptS-ODiZlSAqR7RiiZQv4E2uXCKar52dHo0vvNKbpOp_ezWYcwKRu1shvAlYytsflH5acnDWL-FKOOgz5zqLLZ6cKXFMoR1VJGG_Od-DKjSwajyV9uVzTry58Hz_w0W2pjxwQ-Xv11rab5R2O4kKSW77YzPG2R5E6Q7HN38FrLtyWD_ai3K9wlsFOpwdYC064dk66X7BZtcIbKtM6zKwMywcfJzvS5_0U5yc5GGbIY_lY6SViSfx9shOKyxkEKHfS29Ynk9ATYGnwO-jnlMqkJC7t149H-sI9hYWMkLuCzaeLP56k2B2TmtnYvE_vHNQjzVhTwuHCIRVr-p6nplQn_P3SkOpYqPi3k_tnnOLa2d3Wtga8ClEY90oLWFJC3j2UkBf_VEOBNcg-t5XO3T-j9O4Sbk96k1Qoalc-QlznbGx4bOVsGkRBBMiH4YUqiiWB_OkFHtdqv7dqGeC-u-B4u9IxzYst46vvmyA3O-Q4APSZ1RY8ITUH0jLTbh6EAV7Oki8pIbOg0t56p-8RlanOZqmFvR-grVSc7Ak1ZcD8NACmvidUpa1B7WEvRcOeffx9lype0bt5XenDnMyx6szevwxZIiM8qGM2lsSk4fu8HI9cW0mLywzZT0"
+ }
+
+
+auth_check messages MUST be encrypted with AES256CBC. This message is sent to the origination site, which checks the 'secret' to see if it is the same as the 'sec' which it passed originally. It also checks the secret_sig which is the secret signed by the destination channel's private key and base64url encoded. If everything checks out, a json packet is returned:
+
+ {
+ "success":1,
+ "confirm":"q0Ysovd1uQRsur2xG9Tg6bC23ynzw0191SkVd7CJcYoaePy6e_v0vnmPg2xBUtIaHpx_aSuhgAkd3aVjPeaVBmts6aakT6a_yAEy7l2rBydntu2tvrHhoVqRNOmw0Q1tI6hwobk1BgK9Pm0lwOeAo8Q98BqIJxf47yO9pATa0wktOg6a7LMogC2zkkhwOV5oEqjJfeHeo27TiHr1e2WaphfCusjmk27V_FAYTzw05HvW4SPCx55EeeTJYIwDfQwjLfP4aKV-I8HQCINt-2yxJvzH7Izy9AW-7rYU0Il_gW5hrhIS5MTM12GBXLVs2Ij1CCLXIs4cO0x6e8KEIKwIjf7iAu60JPmnb_fx4QgBlF2HLw9vXMwZokor8yktESoGl1nvf5VV5GHWSIKAur3KPS2Tb0ekNh-tIk9u-xob4d9eIf6tge_d3aq1LcAtrDBDLk8AD0bho5zrVuTmZ9k-lBVPr_DRHSV_dlpu088j3ThaBsuV1olHK3vLFRhYCDIO0CqqK5IuhqtRNnRaqhlNN6fQUHpXk2SwHiJ2W36RCYMTnno6ezFk_tN-RA2ly-FomNZoC5FPA9gFwoJR7ZmVFDmUeK3bW-zYTA5vu15lpBPnt7Up_5rZKkr0WQVbhWJmylqOuwuNWbn3SrMQ8rYFZ23Tv300cOfKVgRBaePWQb4"
+ }
+
+'confirm' in this case is the base64url encoded RSA signature of the concatenation of 'secret' with the base64url encoded whirlpool hash of the source guid and guid_sig; signed with the source channel private key. This prevents a man-in-the-middle from inserting a rogue success packet. Upon receipt and successful verification of this packet, the destination site will redirect to the original destination URL and indicate a successful remote login.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/doc/zot_structures.md b/sources/doc/zot_structures.md
new file mode 100644
index 00000000..e8a65ff1
--- /dev/null
+++ b/sources/doc/zot_structures.md
@@ -0,0 +1,62 @@
+Zot Structures
+==============
+
+**Zot signatures**
+All signed data in zot is accomplished by performing an RSA sign operation using the private key of the initiator. The binary result is then base64url encoded for transport.
+
+**Zot encryption**
+
+Encryption is currently provided by AES256CBC, though additional algorithms MAY be supported. A 32-octet key and 16-octet initialisation vector are randomly generated. The desired data is then encrypted using these generated strings and the result base64url encoded. Then we build an array:
+
+ data: the base64url encoded encrypted data
+ alg: The chosen algorithm, in this case the string 'aes256cbc'.
+ key: The randomly generated key, RSA encrypted using the recipients public key, and the result base64url encoded
+ iv: The randomly generated IV, RDSA encrypted using the recipient's public key, and the result base64url encoded
+
+
+
+**The zot basic packet**
+
+Used for initiating a dialogue with another zot site. This packet MAY be encrypted. The presence of an array element 'iv' indicates encryption has been applied. When sending an 'auth_check' packet type, this packet MUST be encrypted, using the public key of the destination site (the site key, as opposed to a sender key).
+
+
+ {
+ "type":"notify",
+ "sender":{
+ "guid":"kgVFf_1_SSbyqH-BNWjWuhAvJ2EhQBTUdw-Q1LwwssAntr8KTBgBSzNVzUm9_RwuDpxI6X8me_QQhZMf7RfjdA",
+ "guid_sig":"PT9-TApzpm7QtMxC63MjtdK2nUyxNI0tUoWlOYTFGke3kNdtxSzSvDV4uzq_7SSBtlrNnVMAFx2_1FDgyKawmqVtRPmT7QSXrKOL2oPzL8Hu_nnVVTs_0YOLQJJ0GYACOOK-R5874WuXLEept5-KYg0uShifsvhHnxnPIlDM9lWuZ1hSJTrk3NN9Ds6AKpyNRqf3DUdz81-Xvs8I2kj6y5vfFtm-FPKAqu77XP05r74vGaWbqb1r8zpWC7zxXakVVOHHC4plG6rLINjQzvdSFKCQb5R_xtGsPPfvuE24bv4fvN4ZG2ILvb6X4Dly37WW_HXBqBnUs24mngoTxFaPgNmz1nDQNYQu91-ekX4-BNaovjDx4tP379qIG3-NygHTjFoOMDVUvs-pOPi1kfaoMjmYF2mdZAmVYS2nNLWxbeUymkHXF8lT_iVsJSzyaRFJS1Iqn7zbvwH1iUBjD_pB9EmtNmnUraKrCU9eHES27xTwD-yaaH_GHNc1XwXNbhWJaPFAm35U8ki1Le4WbUVRluFx0qwVqlEF3ieGO84PMidrp51FPm83B_oGt80xpvf6P8Ht5WvVpytjMU8UG7-js8hAzWQeYiK05YTXk-78xg0AO6NoNe_RSRk05zYpF6KlA2yQ_My79rZBv9GFt4kUfIxNjd9OiV1wXdidO7Iaq_Q",
+ "url":"http:\/\/podunk.edu",
+ "url_sig":"T8Bp7j5DHHhQDCFcAHXfuhUfGk2P3inPbImwaXXF1xJd3TGgluoXyyKDx6WDm07x0hqbupoAoZB1qBP3_WfvWiJVAK4N1FD77EOYttUEHZ7L43xy5PCpojJQmkppGbPJc2jnTIc_F1vvGvw5fv8gBWZvPqTdb6LWF6FLrzwesZpi7j2rsioZ3wyUkqb5TDZaNNeWQrIEYXrEnWkRI_qTSOzx0dRTsGO6SpU1fPWuOOYMZG8Nh18nay0kLpxReuHCiCdxjXRVvk5k9rkcMbDBJcBovhiSioPKv_yJxcZVBATw3z3TTE95kGi4wxCEenxwhSpvouwa5b0hT7NS4Ay70QaxoKiLb3ZjhZaUUn4igCyZM0h6fllR5I6J_sAQxiMYD0v5ouIlb0u8YVMni93j3zlqMWdDUZ4WgTI7NNbo8ug9NQDHd92TPmSE1TytPTgya3tsFMzwyq0LZ0b-g-zSXWIES__jKQ7vAtIs9EwlPxqJXEDDniZ2AJ6biXRYgE2Kd6W_nmI7w31igwQTms3ecXe5ENI3ckEPUAq__llNnND7mxp5ZrdXzd5HHU9slXwDShYcW3yDeQLEwAVomTGSFpBrCX8W77n9hF3JClkWaeS4QcZ3xUtsSS81yLrp__ifFfQqx9_Be89WVyIOoF4oydr08EkZ8zwlAsbZLG7eLXY"
+ },
+ "callback":"\/post",
+ "version":1,
+ "secret":"1eaa6613699be6ebb2adcefa5379c61a3678aa0df89025470fac871431b70467",
+ "secret_sig":"0uShifsvhHnxnPIlDM9lWuZ1hSJTrk3NN9Ds6AKpyNRqf3DUdz81-Xvs8I2kj6y5vfFtm-FPKAqu77XP05r74vGaWbqb1r8zpWC7zxXakVVOHHC4plG6rLINjQzvdSFKCQb5R_xtGsPPfvuE24bv4fvN4ZG2ILvb6X4Dly37WW_HXBqBnUs24mngoTxFaPgNmz1nDQNYQu91-ekX4-BNaovjDx4tP379qIG3-NygHTjFoOMDVUvs-pOPi1kfaoMjmYF2mdZAmVYS2nNLWxbeUymkHXF8lT_iVsJSzyaRFJS1Iqn7zbvwH1iUBjD_pB9EmtNmnUraKrCU9eHES27xTwD-yaaH_GHNc1XwXNbhWJaPFAm35U8ki1Le4WbUVRluFx0qwVqlEF3ieGO84PMidrp51FPm83B_oGt80xpvf6P8Ht5WvVpytjMU8UG7-js8hAzWQeYiK05YTXk-78xg0AO6NoNe_RSRk05zYpF6KlA2yQ_My79rZBv9GFt4kUfIxNjd9OiV1wXdidO7Iaq_Q"
+ }
+
+
+Type: is the message type. One of 'notify', 'purge' refresh' 'force_refresh', 'auth_check', 'ping' or 'pickup'. The packet contents vary by message type. Here we will describe the 'notify' packet.
+
+Sender is an array of four components.
+
+The guid of the sender is typically a 64 character base64url encoded string. This is generated when an identity is created and an attempt is made that it be unique; though this isn't required.
+
+The guid_sig is the RSA signature of the guid, signed by the sender's private key.
+
+url is the base url of the location this post is originating from.
+
+url_sig is the RSA signature of url, signed by the sender's private key.
+
+
+These four elements provide a portable identity. We can contact the URL provided and download a zot info packet to obtain the public key of the sender, and use that to verify the sender guid and the posting URL signatures.
+
+
+callback is a string to be appended onto the url which identifies the zot communications endpoint on this system. It is typically the string "/post".
+
+version is the zot protocol identifier, to allow future protocol revisions to co-exist.
+
+secret is a 64-char string which is randomly generated by the sending site.
+
+secret_sig is the RSA signature of the secret, signed with the sender's private key.
+
+#include doc/macros/main_footer.bb;
diff --git a/sources/extend/addon/matrix/README.md b/sources/extend/addon/matrix/README.md
new file mode 100644
index 00000000..ffb55595
--- /dev/null
+++ b/sources/extend/addon/matrix/README.md
@@ -0,0 +1,6 @@
+hubzilla-addons
+================
+
+These are addons for hubzilla sites (see https://github.com/redmatrix/hubzilla )
+
+
diff --git a/sources/extend/addon/matrix/adultphotoflag/adultphotoflag.php b/sources/extend/addon/matrix/adultphotoflag/adultphotoflag.php
new file mode 100755
index 00000000..a8b1371a
--- /dev/null
+++ b/sources/extend/addon/matrix/adultphotoflag/adultphotoflag.php
@@ -0,0 +1,28 @@
+
+
+ */
+
+function adultphotoflag_load() {
+ register_hook('get_features','addon/adultphotoflag/adultphotoflag.php','adultphotoflag_get_features');
+}
+
+function adultphotoflag_unload() {
+ unregister_hook('get_features','addon/adultphotoflag/adultphotoflag.php','adultphotoflag_get_features');
+}
+
+function adultphotoflag_get_features(&$a,&$b) {
+
+ $b['tools'][] = array(
+ 'adult_photo_flagging',
+ t('Flag Adult Photos'),
+ t('Provide photo edit option to hide inappropriate photos from default album view'),false);
+
+}
+
diff --git a/sources/extend/addon/matrix/bbmath/README b/sources/extend/addon/matrix/bbmath/README
new file mode 100644
index 00000000..e2e9f62c
--- /dev/null
+++ b/sources/extend/addon/matrix/bbmath/README
@@ -0,0 +1,3 @@
+Adds a new tag, [tex] that can be used in bbcode. Note that you still also have to use $...$ to get equations correct, i.e. [tex] doesn't eneter math-mode by default.
+
+Requires images and tmp directory in your Red root directory (e.g. /var/www/red). Must be writable by server (e.g chown -R www-data tmp images). Also requires latex and imagemagick to be installed.
diff --git a/sources/extend/addon/matrix/bbmath/bbmath.php b/sources/extend/addon/matrix/bbmath/bbmath.php
new file mode 100644
index 00000000..118772dd
--- /dev/null
+++ b/sources/extend/addon/matrix/bbmath/bbmath.php
@@ -0,0 +1,22 @@
+
+ *
+ */
+
+require_once('phplatex.php');
+function bbmath_load() {
+ register_hook('bbcode','addon/bbmath/bbmath.php','bbmath_bbcode');
+
+}
+function bbmath_unload() {
+ unregister_hook('bbcode','addon/bbmath/bbmath.php','bbmath_bbcode');
+}
+
+function bbmath_bbcode($a,&$text) {
+ $text = preg_replace_callback('|\[tex\](.*?)\[/tex\]|',function($m) { return texify($m[1]); },$text);
+}
diff --git a/sources/extend/addon/matrix/bbmath/gpl.txt b/sources/extend/addon/matrix/bbmath/gpl.txt
new file mode 100644
index 00000000..d511905c
--- /dev/null
+++ b/sources/extend/addon/matrix/bbmath/gpl.txt
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Lesser General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ , 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.
diff --git a/sources/extend/addon/matrix/bbmath/phplatex.php b/sources/extend/addon/matrix/bbmath/phplatex.php
new file mode 100644
index 00000000..cf10cd94
--- /dev/null
+++ b/sources/extend/addon/matrix/bbmath/phplatex.php
@@ -0,0 +1,139 @@
+300) $dpi=300;
+
+ $back=phplatex_colorhex($br,$bg,$bb);
+ $fore=phplatex_colorhex($r,$g,$b);
+
+ # Figure out TeX, either to get the right cache entry or to, you know, compile
+ # Semi-common (ams) symbol packages are included.
+ $totex = "\\documentclass[14pt,landscape]{extarticle}\n".
+ "\\usepackage{color}\n".
+ "\\usepackage{amsmath}\n\\usepackage{amsfonts}\n\\usepackage{amssymb}\n".
+ $extraprelude."\n".
+ "\\pagestyle{empty}\n". #removes header/footer; necessary for trim
+ "\\begin{document}\n".
+ "\\color[rgb]{".$r.",".$g.",".$b."}\n".
+ "\\pagecolor[rgb]{".$br.",".$bg.",".$bb."}\n".
+ $string."\n".
+ "\\end{document}\n";
+
+ $strhash = sha1($totex).'.'.$dpi; #file cache entry string: 40-char hash string plus size
+ $stralt = str_replace("&","&", preg_replace("/[\"\n]/","",$string)); #stuck in the alt and title attributes
+ #May need some extra safety.
+ $heredir=getcwd();
+
+ #Experiment: Tries to adjust vertical positioning, so that rendered TeX text looks natural enough inline with HTML text
+ #Only descenders are really a problem since HTML's leeway is upwards.
+ #TODO: This can always use more work.
+ # Avoid using characters that are part of TeX commands.
+ # Some things vary per font, e.g. the slash. In the default CM it is a descender, in Times and others it isn't.
+ $ascenders ="/(b|d|f|h|i|j|k|l|t|A|B|C|D|E|F|G|H|I|J|L|K|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z|\[|\]|\\{|\\}|\(|\)|\/|0|1|2|3|4|5|6|7|8|9|\\#|\*|\?|'|\\\\'|\\\\`|\\\\v)/";
+ $monoliners="/(a|c|e|m|n|o|r|s|u|v|w|x|z|-|=|\+|:|.)/";
+ $descenders="/(g|j|p|\/|q|y|Q|,|;|\[|\]|\\{|\\}|\(|\)|\#|\\\\LaTeX|\\\\TeX|\\\\c\{)/";
+ $deepdescenders="/(\[|\]|\\{|\\}|\(|\)|\\int)/";
+
+ $ba = preg_match_all($ascenders, $string,$m);
+ $bm = preg_match_all($monoliners, $string,$m);
+ $bd = preg_match_all($descenders, $string,$m);
+ $dd = preg_match_all($deepdescenders, $string,$m);
+ if ($dd>0) $verticalalign="vertical-align: -25%"; # deep descenders: move down
+ else if ($bd>0 && $ba==0) $verticalalign="vertical-align: -15%"; # descenders: move down
+ else if ($bd==0 && $ba>0) $verticalalign="vertical-align: 0%"; # ascenders only: move up/do nothing?
+ else if ($bd==0 && $ba==0) $verticalalign="vertical-align: 0%"; # neither vertical-align: 0%
+ else $verticalalign="vertical-align: -15%"; # both ascender and regular descender
+
+ #check image cache, return link if exists
+ #the vertical-align is to fix text baseline/descender(/tail) details in and on-average sort of way
+ if (file_exists($heredir.'/images/'.$strhash.'.'.$imgfmt))
+ return '';
+
+
+ #chdir to have superfluous files be created in tmp. (you stiill have to empty this yourself)
+ error_reporting(0); # not checking existence myself, that would be double.
+ if (chdir("tmp")===FALSE) { return '[directory access error, fix permissions]'; } #I should chech whether file creation is allowed to give a nice error for that problem case
+ error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); # TODO: set old value
+
+ $tfn = tempnam(getcwd(), 'PTX'); #file in tmp dir
+
+ #write temporary .tex file
+ if ( ($tex = fopen($tfn.'.tex', "w"))==FALSE) { return '[file access error] '.phplatex_cleantmp($tfn,$heredir); }
+ fwrite($tex, $totex);
+ fclose($tex);
+
+
+ #Run latex to create a .dvi. Have it try to fix minor errors instead of breaking/pausing on them.
+ exec($path_to_latex.' --interaction=nonstopmode '.$tfn.'.tex');
+ if (!file_exists($tfn.".dvi")) {
+ $log = file_get_contents($tfn.'.log'); #The log always exists, but now it's actually interesting since it'll contain an error
+ return '[latex error, code follows]
'.$totex.'
Log file:
'.$log.'
'.phplatex_cleantmp($tfn,$heredir);
+ }
+
+
+ #DVI -> PostScript. Since dvips uses lpr, which may be configured to actually print by default, force writing to a file with -o
+ exec($path_to_dvips.' '.$tfn.'.dvi -o '.$tfn.'.ps');
+ if ( !file_exists($tfn.'.ps')) {
+ return '[dvi2ps error] '.phplatex_cleantmp($tfn,$heredir);
+ }
+
+
+ #PostScript -> image. Trim based on corner pixel, and set transparent color.
+ exec($path_to_convert.' -transparent-color "#'.$back.'" -colorspace RGB -density '.$dpi.' -trim +page '.$tfn.'.ps -transparent "#'.$back.'" '.$tfn.'.'.$imgfmt);
+ #Note: +page OR -page +0+0 OR +repage moves the image to the cropped area (kills offset)
+ #Older code tried: exec('/usr/bin/mogrify -density 90 -trim +page -format $imgfmt '.$tfn.'.ps');
+ # It seems some versions of convert may not have -trim. Old versions?
+
+ if (!file_exists($tfn.'.'.$imgfmt)) {
+ return '[image convert error] '.phplatex_cleantmp($tfn,$heredir);
+ }
+
+ #Copy result image to chache.
+ copy($tfn.'.'.$imgfmt, $heredir.'/images/'.$strhash.'.'.$imgfmt);
+
+ #Clean up temporary files, and return link to just-created image
+ return phplatex_cleantmp($tfn,$heredir).'';
+}
+?>
diff --git a/sources/extend/addon/matrix/bookmarker/bookmarker.php b/sources/extend/addon/matrix/bookmarker/bookmarker.php
new file mode 100755
index 00000000..41a86350
--- /dev/null
+++ b/sources/extend/addon/matrix/bookmarker/bookmarker.php
@@ -0,0 +1,41 @@
+
+ *
+ */
+
+function bookmarker_install() {
+ register_hook('prepare_body', 'addon/bookmarker/bookmarker.php', 'bookmarker_prepare_body', 10);
+}
+
+
+function bookmarker_uninstall() {
+ unregister_hook('prepare_body', 'addon/bookmarker/bookmarker.php', 'bookmarker_prepare_body');
+}
+
+function bookmarker_prepare_body(&$a,&$b) {
+
+
+ if(get_pconfig(local_channel(),'bookmarker','disable'))
+ return;
+
+ if(! strpos($b['html'],'bookmark-identifier'))
+ return;
+
+ if(! function_exists('redbasic_init'))
+ return;
+
+ $id = $b['item']['id'];
+ if(local_channel())
+ $link = ' ';
+ else
+ $link = ' ';
+
+ $b['html'] = str_replace('#^',$link,$b['html']);
+
+}
diff --git a/sources/extend/addon/matrix/buglink/bug-x.gif b/sources/extend/addon/matrix/buglink/bug-x.gif
new file mode 100755
index 00000000..10936caa
Binary files /dev/null and b/sources/extend/addon/matrix/buglink/bug-x.gif differ
diff --git a/sources/extend/addon/matrix/buglink/buglink.php b/sources/extend/addon/matrix/buglink/buglink.php
new file mode 100755
index 00000000..a237601b
--- /dev/null
+++ b/sources/extend/addon/matrix/buglink/buglink.php
@@ -0,0 +1,15 @@
+
+ */
+
+
+function buglink_load() { register_hook('page_end', 'addon/buglink/buglink.php', 'buglink_active'); }
+
+
+function buglink_unload() { unregister_hook('page_end', 'addon/buglink/buglink.php', 'buglink_active'); }
+
+function buglink_active(&$a,&$b) { $b .= '
'; }
diff --git a/sources/extend/addon/matrix/buglink/lang/C/messages.po b/sources/extend/addon/matrix/buglink/lang/C/messages.po
new file mode 100644
index 00000000..260c583a
--- /dev/null
+++ b/sources/extend/addon/matrix/buglink/lang/C/messages.po
@@ -0,0 +1,22 @@
+# ADDON buglink
+# Copyright (C)
+# This file is distributed under the same license as the Friendica buglink addon package.
+#
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: \n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2013-02-27 05:01-0500\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME \n"
+"Language-Team: LANGUAGE \n"
+"Language: \n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: buglink.php:15
+msgid "Report Bug"
+msgstr ""
diff --git a/sources/extend/addon/matrix/buglink/lang/ca/strings.php b/sources/extend/addon/matrix/buglink/lang/ca/strings.php
new file mode 100644
index 00000000..01fc9adb
--- /dev/null
+++ b/sources/extend/addon/matrix/buglink/lang/ca/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Informar de problema";
diff --git a/sources/extend/addon/matrix/buglink/lang/cs/strings.php b/sources/extend/addon/matrix/buglink/lang/cs/strings.php
new file mode 100644
index 00000000..a1cd51f4
--- /dev/null
+++ b/sources/extend/addon/matrix/buglink/lang/cs/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Nahlásit chybu";
diff --git a/sources/extend/addon/matrix/buglink/lang/de/strings.php b/sources/extend/addon/matrix/buglink/lang/de/strings.php
new file mode 100644
index 00000000..cf96a178
--- /dev/null
+++ b/sources/extend/addon/matrix/buglink/lang/de/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Fehlerreport erstellen";
diff --git a/sources/extend/addon/matrix/buglink/lang/eo/strings.php b/sources/extend/addon/matrix/buglink/lang/eo/strings.php
new file mode 100644
index 00000000..00d95a40
--- /dev/null
+++ b/sources/extend/addon/matrix/buglink/lang/eo/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Skribi cimraporton";
diff --git a/sources/extend/addon/matrix/buglink/lang/es/strings.php b/sources/extend/addon/matrix/buglink/lang/es/strings.php
new file mode 100644
index 00000000..fe632488
--- /dev/null
+++ b/sources/extend/addon/matrix/buglink/lang/es/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Informe de errores";
diff --git a/sources/extend/addon/matrix/buglink/lang/fr/strings.php b/sources/extend/addon/matrix/buglink/lang/fr/strings.php
new file mode 100644
index 00000000..0075fb0d
--- /dev/null
+++ b/sources/extend/addon/matrix/buglink/lang/fr/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Signaler un bug";
diff --git a/sources/extend/addon/matrix/buglink/lang/is/strings.php b/sources/extend/addon/matrix/buglink/lang/is/strings.php
new file mode 100644
index 00000000..7b3823a6
--- /dev/null
+++ b/sources/extend/addon/matrix/buglink/lang/is/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Tilkynna bilun";
diff --git a/sources/extend/addon/matrix/buglink/lang/it/strings.php b/sources/extend/addon/matrix/buglink/lang/it/strings.php
new file mode 100644
index 00000000..90df28fe
--- /dev/null
+++ b/sources/extend/addon/matrix/buglink/lang/it/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Segnala un Bug";
diff --git a/sources/extend/addon/matrix/buglink/lang/nb-no/strings.php b/sources/extend/addon/matrix/buglink/lang/nb-no/strings.php
new file mode 100644
index 00000000..ec212e9a
--- /dev/null
+++ b/sources/extend/addon/matrix/buglink/lang/nb-no/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "";
diff --git a/sources/extend/addon/matrix/buglink/lang/pl/strings.php b/sources/extend/addon/matrix/buglink/lang/pl/strings.php
new file mode 100644
index 00000000..8229e7a6
--- /dev/null
+++ b/sources/extend/addon/matrix/buglink/lang/pl/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Zgłoś problem";
diff --git a/sources/extend/addon/matrix/buglink/lang/pt-br/strings.php b/sources/extend/addon/matrix/buglink/lang/pt-br/strings.php
new file mode 100644
index 00000000..6283d77e
--- /dev/null
+++ b/sources/extend/addon/matrix/buglink/lang/pt-br/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Relate um Bug";
diff --git a/sources/extend/addon/matrix/buglink/lang/ru/strings.php b/sources/extend/addon/matrix/buglink/lang/ru/strings.php
new file mode 100644
index 00000000..c4223648
--- /dev/null
+++ b/sources/extend/addon/matrix/buglink/lang/ru/strings.php
@@ -0,0 +1,3 @@
+strings["Report Bug"] = "Сообщить об ошибке";
diff --git a/sources/extend/addon/matrix/buglink/lang/sv/strings.php b/sources/extend/addon/matrix/buglink/lang/sv/strings.php
new file mode 100644
index 00000000..ab4fa67a
--- /dev/null
+++ b/sources/extend/addon/matrix/buglink/lang/sv/strings.php
@@ -0,0 +1,2 @@
+strings["Report Bug"] = "报案程åºé”™è¯¯";
diff --git a/sources/extend/addon/matrix/calc/calc.apd b/sources/extend/addon/matrix/calc/calc.apd
new file mode 100644
index 00000000..8171ce06
--- /dev/null
+++ b/sources/extend/addon/matrix/calc/calc.apd
@@ -0,0 +1,3 @@
+url: $baseurl/calc
+name: Calculator
+photo: $baseurl/addon/calc/calc.png
diff --git a/sources/extend/addon/matrix/calc/calc.php b/sources/extend/addon/matrix/calc/calc.php
new file mode 100755
index 00000000..2935b4a2
--- /dev/null
+++ b/sources/extend/addon/matrix/calc/calc.php
@@ -0,0 +1,368 @@
+
+ */
+
+
+function calc_load() {
+ register_hook('app_menu', 'addon/calc/calc.php', 'calc_app_menu');
+}
+
+function calc_unload() {
+ unregister_hook('app_menu', 'addon/calc/calc.php', 'calc_app_menu');
+
+}
+
+function calc_app_menu($a,&$b) {
+ $b['app_menu'][] = '
+
+EOT;
+return $o;
+
+}
diff --git a/sources/extend/addon/matrix/calc/calc.png b/sources/extend/addon/matrix/calc/calc.png
new file mode 100644
index 00000000..e7d15c8c
Binary files /dev/null and b/sources/extend/addon/matrix/calc/calc.png differ
diff --git a/sources/extend/addon/matrix/chords/README.md b/sources/extend/addon/matrix/chords/README.md
new file mode 100644
index 00000000..a45e9730
--- /dev/null
+++ b/sources/extend/addon/matrix/chords/README.md
@@ -0,0 +1,9 @@
+Chord Generator
+===============
+
+Before enabling the plugin compile the chord generator binary.
+
+ g++ chord-generator.cpp -o chord
+
+The example is for Linux. Compilation instructions may vary on Windows or other platforms.
+
diff --git a/sources/extend/addon/matrix/chords/chord b/sources/extend/addon/matrix/chords/chord
new file mode 100755
index 00000000..b6c8a495
Binary files /dev/null and b/sources/extend/addon/matrix/chords/chord differ
diff --git a/sources/extend/addon/matrix/chords/chord-generator.cpp b/sources/extend/addon/matrix/chords/chord-generator.cpp
new file mode 100755
index 00000000..6a7f2c09
--- /dev/null
+++ b/sources/extend/addon/matrix/chords/chord-generator.cpp
@@ -0,0 +1,1133 @@
+//
+// I have been messing around with this program now for a couple weeks
+// and thought it might be useful to someone. Given a chord by name,
+// it generates all possible ways to play that chord on a guitar and
+// scores them based on things like finger span, root as bass note,
+// number of open strings, etc (see below). Then it prints the top
+// 50 it found (or more, you can set it). The program is pretty
+// configurable if you can stand to read the stuff at the top where
+// all the #define's are. Currently it prints out the score, and the
+// pieces that made up the score...you may want to get rid of the
+// extra info, but I found it interesting.
+//
+// It generates some wild chords and some interesting versions that
+// I have NEVER seen before. Probably a great program to find inversions
+// and stuff (especially if you lower the score given for having a root
+// note 1st). The program could easily be modified to do Drop D tuning
+// or any other alternate tuning, and I think it could do other instruments
+// without much change, but I have not tried.
+//
+// I have been having fun playing with this, if you make a changes or
+// fixes I would appreciate a copy. Other than that, this is public
+// domain, have a party. Oh yeah, the code is C++...
+//
+// Thanks,
+// Rick Eesley
+// re@warren.mentorg.com
+//
+//
+//
+// Chords can be built like: | = seperate fields, [ ... ] = range of values
+// <> = nothing
+//
+// [<--optional--->]
+// [<--repeating-->]
+// [A...G] | <> | <> | <> | # |
+// | # | min | maj | |
+// | b | m | add | |
+// | | sus2 | aug | |
+// | | sus4 | dim | |
+// | | dim | + | |
+// | | aug | - | |
+// | | | # |
+// | | | b |
+// | | | / |
+//
+// Legal chord names: A A7 Amaj7 Amaj9 Ammaj7 Aadd4 Asus2Add4 E7b13b11 ...
+// Does not do: C/G which is a c chord with a g root, just find a c
+// chord and pick out a g root you like for those...
+// Does not do: E5 (that's not a chord, just 2 notes)
+//
+//
+
+
+#undef DEBUG
+int lefty = 0;
+
+//////////////////////////////////////////////////////////////////////
+// Scoring a chord is influenced by these multipliers, change them around
+// to your own preferences
+//////////////////////////////////////////////////////////////////////
+
+//
+// Score for where this lands on the fretboard (Lower is better)
+// score += (15 - AverageFret) * POSITION_SCORE;
+#define POSITION_SCORE 20
+
+// Score for minimal span (ie: chord covering from fret 2 to fret 4 has
+// a span of 2. Open strings do NOT count in span, this is a measure
+// of whether a chord is playable
+// The maximum span allowed is set by the #define MAXSPAN
+// score += (MAXSPAN - span) * SPAN_SCORE;
+#define SPAN_SCORE 12
+
+// This score is for total Span (ie: includes open strings, which span
+// does not.
+// score += (15 - tspan) * TSPAN_SCORE;
+#define TSPAN_SCORE 3
+
+// This score is for number of open strings (I like them).
+// score += numberOfOpens * OPENS_SCORE
+#define OPENS_SCORE 10
+
+// This score multiplier is the score to add if the most bass string
+// is the root note
+// score += ROOT_SCORE
+#define ROOT_SCORE 50
+
+// This score multipier is used to penalize for adjacent notes
+// score += ADJ_SCORE * (5-adjNotes)
+// THe five is the max number of adjacent strings possible (duh...)
+#define ADJ_SCORE 9
+
+// This is the maximum finger reach, if this is bumped up to five or
+// more you get a zillion more fingers (mainly 'cause 5 takes you to
+// the notes on the next string...so leave it probably
+#define MAXSPAN 4
+
+// This is number of top scores to keep, something < 20 leaves out
+// too much, 100 is a lot to look at...but I am going with it...
+#define CHORDSTACK 250
+
+//
+// These are different types of scores, NUMSCORETYPES MUST be set to the
+// number of these types, so if any are added change it TOO!
+// Add any new scores onto the end, the total MUST be the 0th element
+//
+#define NUMSCORETYPES 7
+
+#define SCORE_TOTAL 0
+#define SCORE_SPAN 1
+#define SCORE_TOTALSPAN 2
+#define SCORE_OPENSTRINGS 3
+#define SCORE_FIRSTROOT 4
+#define SCORE_LOWONNECK 5
+#define SCORE_ADJNOTES 6
+
+// Just in case someone wants to port this to banjo or mandolin or something
+#define NUM_STRINGS 6
+
+
+#include
+#include
+#include
+#include
+
+/* A A# B C C# D D# E F F# G G# */
+/* A Bb B C Db D Eb E F Gb G Ab */
+/* 0 1 2 3 4 5 6 7 8 9 10 11 */
+
+/* STRINGS ARE: E=0, A=1, D=2, G=3, B=4, E=5 IN ORDER */
+
+// This can be reset for alternate tunings, this is EADGBE tuning
+// here:
+
+ int openStrings[NUM_STRINGS] = { 7, 0, 5, 10, 2, 7 };
+
+static char *strNotes[] = { "A ", "A#", "B ", "C ", "C#", "D ",
+ "D#", "E ", "F ", "F#", "G ", "G#" };
+
+//
+// This class contains a decode chord, and can take a string and turn
+// it into a chord. A chord is a triad or greater here. The code is
+// decoded from a string into notes in the c array (notes: are A=0, A#=1,
+// and so on. The longest chord you can possibly have is 12 notes which
+// would be every note in an octave, since chords are typical 3 to 5
+// notes, remaining notes in the c[] array are set to -1
+//
+class Chord
+{
+ public:
+ // String set to last error
+ char errorStr[64];
+
+ // Notes that are in the chord -1 should be ignored
+ int notes[12];
+
+ // NOtes that are optional have a 1, otherwise a zero
+ int optional[12];
+
+ // ------------------ MEMBER FUNCTIONS ----------------------------
+
+ // Clears last chord
+ void clear();
+
+ // Decodes input string into notes[] array, return error string
+ int findChord(char *s);
+
+ // Print last error message from chord parse
+ void printError();
+
+ // Prints out notes[] array to screen
+ void print(char *chordName);
+
+ // Is the note note in the chord
+ int inChord(int note);
+
+ // Is this chord covered by the array of notes (ie: Does the
+ // array contain all the notes of the chord
+ int covered(int *noteArray);
+
+ // Return the root note of the chord
+ int getRoot() { return notes[0]; }
+
+ // Given a chord string, return the note that starts it (and recognize
+ // sharps and flats (b and #)
+ int get_base(char *s);
+
+ // Get a note offset from another...
+ int note_offset(int base, int offset) {
+ if((! base) && (offset == (-1)))
+ return(11);
+ return ((base + offset) % 12);
+ }
+} ;
+
+//
+// This class holds a fingering for a chord, as well as a score for that
+// fingering. This class also keeps the CHORDSTACK (ie: 100) best version
+// of that chord to print out in sorted order (best score 1st).
+//
+class Fretboard
+{
+ public:
+
+ // Score of current chord, held in an array so we can track the
+ // components of the score (see the SCORE_ defines in the begining
+ // of this file
+ int score[NUMSCORETYPES];
+
+ // Fretboard of the current chord, fretboard[0] is the low (bass) E
+ // string. A fretboard value of 0 is an open string, -1 is an
+ // X'ed out string (not strung)
+ int fretboard[NUM_STRINGS];
+
+ // Notes of the current fretboard fingering for a chord
+ int notes[NUM_STRINGS];
+
+ // The best fret layouts so far based on score
+ int bestFrets[CHORDSTACK][NUM_STRINGS];
+
+ // The best fret layout note sets so far based on score
+ int bestNotes[CHORDSTACK][NUM_STRINGS];
+
+ // The best scores
+ int bestScores[CHORDSTACK][NUMSCORETYPES];
+
+ // Keep track of stack sDepth to speed it up!
+ int sDepth;
+
+ // ------------------ MEMBER FUNCTIONS ----------------------------
+
+ // Construct one
+ Fretboard();
+
+ // Given a chord (and the current fretboard state) score this doggie
+ // and leave the score value in score
+ void getScore(Chord &chord);
+
+ // Print the current Fretboard state (not the stack)
+ void print();
+
+ // Print the fretboard stack
+ void printStack();
+
+ // Iterate over different fretboard variations for a chord
+ void iterate(Chord &chord);
+
+ // Take the current fretboard state and put it into the stack
+ void addToBest();
+
+ // Get the span of the current chord, excluding open string
+ int getSpan();
+
+ // Get the span of the current chord, INCLUDING open string
+ int getTotalSpan();
+};
+
+//
+// Before building a chord, clear the notes and optional arrays
+//
+void
+Chord::clear()
+{
+ for (int i = 0; i < 12; i++)
+ {
+ notes[i] = -1;
+ optional[i] = 0;
+ }
+}
+
+//
+// Print out the last error string
+//
+void
+Chord::printError()
+{
+ printf("Error: %s\n", errorStr);
+}
+
+//
+// I dunno, our C++ compiler at work did not have strupr, so heres mine
+//
+void
+myStrupr(char *s)
+{
+ while (*s)
+ {
+ if (islower(*s))
+ *s = toupper(*s);
+ s++;
+ }
+}
+
+//
+// Decodes input string into notes[] array, return error string
+// always: 0 = root, 1 = 3rd, 2 = 5th
+// Also sets the optional array in parallel with the notes[]
+//
+int
+Chord::findChord(char *s)
+{
+ clear();
+
+ // up case the string
+ myStrupr(s);
+
+ // DECODE ROOT NOTE : A - G
+ notes[0] = get_base(s);
+ s++;
+
+ // CHECK FOR SHARP OR FLAT ROOT NOTE
+ if (*s == '#') s++;
+ if (*s == 'B') s++;
+
+ // MODIFY THE ROOT BY M, MIN, SUS2, SUS4, or diminished
+ if (!strncmp(s, "MIN", 3 ))
+ {
+ notes[1] = note_offset(notes[0], 3);
+ s += 3;
+ optional[2] = 1;
+ }
+ else if (!strncmp(s, "MAJ", 3))
+ {
+ // Do nothing, but stops program from seeing the
+ // first m in maj as a minor (see next line)...so give a normal 3rd
+ notes[1] = note_offset(notes[0], 4);
+ optional[2] = 1;
+ }
+ else if (!strncmp(s, "M", 1))
+ {
+ notes[1] = note_offset(notes[0], 3);
+ s += 1;
+ optional[2] = 1;
+ }
+ else if (!strncmp(s, "SUS", 1))
+ {
+ s += 3; // go past sus
+ if (*s == '2')
+ notes[1] = note_offset(notes[0], 2);
+ else if (*s == '4')
+ notes[1] = note_offset(notes[0], 5);
+ else
+ {
+ strcpy(errorStr, "sus must be followed by 2 or 4");
+ return 1;
+ }
+ s++; // Go past 2 or 4
+ optional[2] = 1;
+ }
+ else if ((!strncmp(s, "DIM", 3 )) && (!isdigit(s[3])))
+ {
+ // If it is diminished, just return (no other stuff allowed)/
+ notes[1] = note_offset(notes[0], 3);
+ notes[2] = note_offset(notes[0], 6);
+ notes[3] = note_offset(notes[0], 9);
+ return 0;
+ }
+ else if ((!strncmp(s, "AUG", 3 )) && (!isdigit(s[3])))
+ {
+ // If it is diminished, just return (no other stuff allowed)/
+ notes[1] = note_offset(notes[0], 4);
+ notes[2] = note_offset(notes[0], 8);
+ return 0;
+ }
+ else
+ {
+ notes[1] = note_offset(notes[0], 4);
+ // optional[1] = 1;
+ // optional[2] = 1;
+ }
+
+ notes[2] = note_offset(notes[0], 7);
+
+
+ // At this point, the 1,3,5 triad or variant is built, now add onto
+ // it until the string end is reached...
+ // Next note to add is index = 3...
+ int index = 3;
+ enum homeboy { NORMAL, MAJ, ADD, AUG, DIM } mtype ;
+ char lbuf[10];
+
+ while (*s)
+ {
+ // FIrst, check the mtype of modifier, ie: Aug, Maj, etc...
+ mtype = NORMAL;
+ if (!strncmp(s, "MAJ", 3))
+ {
+ mtype = MAJ;
+ s += 3;
+ }
+ else if (!strncmp(s, "ADD", 3))
+ {
+ mtype = ADD;
+ s += 3;
+ }
+ else if (!strncmp(s, "AUG", 3))
+ {
+ mtype = AUG ;
+ s += 3;
+ }
+ else if (!strncmp(s, "DIM", 3))
+ {
+ mtype = DIM;
+ s += 3;
+ }
+ else if ( *s == '+' )
+ {
+ mtype = AUG;
+ s += 1;
+ }
+ else if ( *s == '-' )
+ {
+ mtype = DIM;
+ s += 1;
+ }
+ else if ( *s == '#' )
+ {
+ mtype = AUG;
+ s += 1;
+ }
+ else if ( *s == 'B' )
+ {
+ mtype = DIM;
+ s += 1;
+ }
+ else if ( *s == '/' )
+ {
+ mtype = ADD;
+ s += 1;
+ }
+ // Now find the number...
+ if (isdigit(*s))
+ {
+ lbuf[0] = *s++;
+ lbuf[1] = '\0';
+ }
+ else
+ {
+ sprintf(errorStr, "Expecting number, got %s", s);
+ return 1;
+ }
+ // 2nd digit?
+ if (isdigit(*s))
+ {
+ lbuf[1] = *s++;
+ lbuf[2] = '\0';
+ }
+
+ int number = atoi(lbuf);
+
+ switch (number)
+ {
+ case 7 :
+ notes[index] = note_offset(notes[0], 10);
+ break;
+ case 9 :
+ notes[index] = note_offset(notes[0], 2);
+
+ // put the 7th in 2nd so it can be maj'ed if need be...
+ if ((mtype == NORMAL) || (mtype == MAJ))
+ {
+ index++;
+ notes[index] = note_offset(notes[0], 10);
+ optional[index] = 1; // 7th is optional, unless it is maj!
+ }
+
+ break;
+ case 11 :
+ notes[index] = note_offset(notes[0], 5);
+
+ // put the 7th in 2nd so it can be maj'ed if need be...
+ if ((mtype == NORMAL) || (mtype == MAJ))
+ {
+ index++;
+ notes[index] = note_offset(notes[0], 10);
+ optional[index] = 1; // 7th is optional, unless it is maj!
+ }
+
+ break;
+ case 13 :
+ notes[index] = note_offset(notes[0], 9);
+ index++;
+ notes[index] = note_offset(notes[0], 5);
+ optional[index] = 1; // 7th is optional, unless it is maj!
+ index++;
+ notes[index] = note_offset(notes[0], 2);
+ optional[index] = 1; // 7th is optional, unless it is maj!
+
+ // put the 7th in 2nd so it can be maj'ed if need be...
+ if ((mtype == NORMAL) || (mtype == MAJ))
+ {
+ index++;
+ notes[index] = note_offset(notes[0], 10);
+ optional[index] = 1; // 7th is optional, unless it is maj!
+ }
+
+ break;
+ case 2:
+ notes[index] = note_offset(notes[0], 2);
+ break;
+ case 4:
+ notes[index] = note_offset(notes[0], 5);
+ break;
+ case 6:
+ notes[index] = note_offset(notes[0], 9);
+ break;
+ case 5:
+ notes[index] = note_offset(notes[0], 7);
+ break;
+ default:
+ sprintf(errorStr, "Cannot do number: %d\n", number);
+ return 1;
+ }
+
+ switch (mtype)
+ {
+ case DIM:
+ notes[index] = note_offset(notes[index], -1);
+ break;
+ case MAJ:
+ // It is a major, so not optional
+ optional[index] = 0;
+ case AUG :
+ notes[index] = note_offset(notes[index], 1);
+ break;
+ case NORMAL:
+ case ADD:
+ break;
+ default:
+ break;
+ }
+
+ index++;
+ }
+ return 0;
+}
+
+//
+// Print out chord by name
+//
+void
+Chord::print(char *cname)
+{
+ printf("Notes for chord '%s': ", cname);
+ for (int i = 0; i < 12; i++)
+ {
+ if (notes[i] != -1)
+ printf("%s ", strNotes[notes[i]]);
+ }
+ printf("\n\n");
+}
+
+//
+// Are all the notes in this chord covered by the notes in the
+// noteArray, it is not necessary to cover the notes in the optional
+// array of the chord
+//
+int
+Chord::covered(int *noteArray)
+{
+ // noteArray is an array of notes this chord has, it is NUM_STRINGS notes
+ // long (like a guitar fretboard dude...unused notes may be set
+ // to -1 (which wont compare since -1 is tossed...
+
+ for (int i = 0; i < 12; i++)
+ {
+ if (notes[i] != -1)
+ {
+ int gotIt = 0;
+ for (int j = 0; j < NUM_STRINGS; j++)
+ {
+ if (noteArray[j] == notes[i])
+ {
+ gotIt = 1;
+ break;
+ }
+ }
+ // If it was not found, and it is NOT optional, then it is
+ // not covered
+ if ((gotIt == 0) && (optional[i] == 0))
+ return 0;
+ }
+ }
+ return 1;
+}
+
+
+//
+// Is the given note in the chord
+//
+int
+Chord::inChord(int note)
+{
+ for (int i = 0; i < 12; i++)
+ {
+ // Check if we are off the end of the notes set
+ if (notes[i] == -1)
+ return 0;
+ // Check if the note was found
+ if (note == notes[i])
+ return 1;
+ }
+ // Did not find out, return 0
+ return 0;
+}
+
+//
+// Given a chord string, pick off the root (either C or C# or Cb)...and
+// return that integer value (A = 0)
+//
+int
+Chord::get_base(char *s)
+{
+
+ static int halfsteps[] = { 0, 2, 3, 5, 7, 8, 10 };
+
+ if ((*s < 'A') || (*s > 'G'))
+ return 0;
+
+ if (s[1] == '#')
+ return ( note_offset(halfsteps[s[0] - 'A'], 1));
+ else if (s[1] == 'B')
+ return ( note_offset(halfsteps[s[0] - 'A'], -1));
+ else
+ return ( halfsteps[s[0] - 'A']);
+}
+
+
+//
+// Print out the current fretboard
+//
+void
+Fretboard::print()
+{
+ printf("SCORE: %3d ", score[SCORE_TOTAL]);
+ printf(
+ " SPN: %2d TSPN: %2d OS: %2d ROOT: %2d LOW %2d ADJ %2d",
+ score[SCORE_SPAN], score[SCORE_TOTALSPAN], score[SCORE_OPENSTRINGS],
+ score[SCORE_FIRSTROOT], score[SCORE_LOWONNECK],
+ score[SCORE_ADJNOTES]);
+
+ printf(" FB: ");
+ for (int i = 0; i < NUM_STRINGS; i++)
+ {
+ if (fretboard[i] != -1)
+ printf(" %2d", fretboard[i]);
+ else
+ printf(" X");
+ }
+
+ printf(" NT: ");
+ for (int i = 0; i < NUM_STRINGS; i++)
+ if (notes[i] != -1)
+ printf(" %s", strNotes[notes[i]]);
+ else
+ printf(" X ");
+ printf("\n");
+}
+
+//
+// Construct a fretboard -- reset to the openStrings, clear the stack
+// and reset all the bestScores to -1
+//
+Fretboard::Fretboard()
+{
+ sDepth = 0;
+ score[0] = 0;
+ for (int i = 0; i < NUM_STRINGS; i++)
+ {
+ notes[i] = openStrings[i];
+ fretboard[i] = 0;
+ }
+ for (int i = 0; i < CHORDSTACK; i++)
+ {
+ bestScores[i][0] = -1;
+ }
+}
+
+//
+// Get the span of this chord, don't count open strings
+//
+int
+Fretboard::getSpan()
+{
+ int min = 100, max = 0;
+ for (int i = 0; i < NUM_STRINGS; i++)
+ {
+ // Dont count X strings or open strings
+ if (fretboard[i] <= 0)
+ continue;
+ if (fretboard[i] > max) max = fretboard[i];
+ if (fretboard[i] < min) min = fretboard[i];
+ }
+ if (min == 100)
+ // All open strings, took awhile to catch this bug
+ return 0;
+ else
+ return (max - min);
+}
+
+//
+// Get the span of this chord, DO count open strings
+//
+int
+Fretboard::getTotalSpan()
+{
+ int min = 100, max = 0;
+ for (int i = 0; i < NUM_STRINGS; i++)
+ {
+ // Dont count X strings
+ if (fretboard[i] < 0)
+ continue;
+ if (fretboard[i] > max) max = fretboard[i];
+ if (fretboard[i] < min) min = fretboard[i];
+ }
+ if (min == -1)
+ min = 0;
+ return (max - min);
+}
+
+//
+// Add this chord to the best (if there is room in the stack)
+//
+void
+Fretboard::addToBest()
+{
+ // CHORDSTACK is the sDepth of keepers...
+#ifdef DEBUG
+ printf("ATB: ");
+ this->print();
+#endif
+
+ int i;
+
+ // NOTE: at the start, bestScores is full of -1's, so any reall
+ // real score will be better (worst score is 0)
+ for (i = 0; i < sDepth; i++)
+ {
+ if (score[0] > bestScores[i][0])
+ break;
+ }
+
+ // If score was not better than any in the stack just return
+ if (i >= CHORDSTACK)
+ return ;
+ // MOve down old guys to make room for the new guy
+ for (int j = CHORDSTACK - 1; j >= i; j--)
+ {
+ for (int q = 0; q < NUM_STRINGS; q++)
+ {
+ bestFrets[j][q] = bestFrets[j - 1][q];
+ bestNotes[j][q] = bestNotes[j - 1][q];
+ }
+ for (int q = 0; q < NUMSCORETYPES; q++)
+ bestScores[j][q] = bestScores[j - 1][q];
+ }
+
+ for (int q = 0; q < NUM_STRINGS; q++)
+ {
+ bestFrets[i][q] = fretboard[q];
+ bestNotes[i][q] = notes[q];
+ }
+ for (int q = 0; q < NUMSCORETYPES; q++)
+ bestScores[i][q] = score[q];
+
+ sDepth++;
+ if (sDepth > CHORDSTACK)
+ sDepth--;
+}
+
+//
+// Print out the stack to the screen
+//
+void
+Fretboard::printStack()
+{
+ static char *strNotes[] = { "A ", "A#", "B ", "C ", "C#", "D ",
+ "D#", "E ", "F ", "F#", "G ", "G#" };
+
+
+ for (int f = 0; f < sDepth; f++)
+ {
+ printf("\n\n ");
+
+ if(lefty) {
+ for (int i = NUM_STRINGS - 1; i >= 0; i--)
+ if (bestNotes[f][i] != -1)
+ printf(" %s", strNotes[bestNotes[f][i]]);
+ else
+ printf(" X ");
+ }
+ else {
+ for (int i = 0; i < NUM_STRINGS; i++)
+ if (bestNotes[f][i] != -1)
+ printf(" %s", strNotes[bestNotes[f][i]]);
+ else
+ printf(" X ");
+ }
+ printf("\n");
+ if(lefty) {
+ for (int i = NUM_STRINGS - 1; i >= 0; i--)
+ if (bestFrets[f][i] != -1)
+ printf(" %2d", bestFrets[f][i]);
+ else
+ printf(" X");
+
+ }
+ else {
+ for (int i = 0; i < NUM_STRINGS; i++)
+
+ if (bestFrets[f][i] != -1)
+ printf(" %2d", bestFrets[f][i]);
+ else
+ printf(" X");
+ }
+
+ printf("\n\n");
+
+
+ int highest = 0;
+
+ for(int i = 0; i < NUM_STRINGS; i++)
+ if(bestFrets[f][i] > highest)
+ highest = bestFrets[f][i];
+
+ printf("\n");
+
+ for(int i = 0; i <= (highest + 1); i ++) {
+ if(lefty) {
+ for (int x = NUM_STRINGS-1; x >= 0; x--) {
+ if(i == 0) {
+ if(bestFrets[f][x] == -1)
+ printf(" X");
+ else
+ if(bestFrets[f][x] == 0)
+ printf(" 0");
+ else
+ printf(" ");
+ }
+ else {
+ if(bestFrets[f][x] == i)
+ printf(" *");
+ else
+ printf(" |");
+ }
+ }
+ }
+ else {
+
+ for (int x = 0; x < NUM_STRINGS; x++) {
+ if(i == 0) {
+ if(bestFrets[f][x] == -1)
+ printf(" X");
+ else
+ if(bestFrets[f][x] == 0)
+ printf(" 0");
+ else
+ printf(" ");
+ }
+ else {
+ if(bestFrets[f][x] == i)
+ printf(" *");
+ else
+ printf(" |");
+ }
+ }
+ }
+ printf("\n ---------------- %2d\n",i);
+
+
+
+
+ }
+ }
+}
+
+
+//
+// Get the score for this chord
+//
+void
+Fretboard::getScore(Chord &chord)
+{
+
+ // First, points for small span (excluding opens)
+ score[SCORE_SPAN] = (MAXSPAN - getSpan()) * SPAN_SCORE;
+
+ // Then, points for small total span
+ score[SCORE_TOTALSPAN] = (15 - getTotalSpan()) * 3;
+
+ score[SCORE_OPENSTRINGS] = 0;
+ // Points for open strings
+ for (int i = 0; i < NUM_STRINGS; i++)
+ {
+ if (fretboard[i] == 0)
+ {
+ score[SCORE_OPENSTRINGS] += OPENS_SCORE;
+ }
+ }
+
+ // Points for first string being the root ...
+ score[SCORE_FIRSTROOT] = 0;
+ int i;
+ for (i = 0; (fretboard[i] == -1) && (i < NUM_STRINGS) ; i++)
+ ;
+ if (notes[i] == chord.getRoot())
+ {
+ score[SCORE_FIRSTROOT] = ROOT_SCORE;
+ }
+
+ // Points for being low on the neck...
+ int sum = 0, cnt = 0;
+ for (i = 0; i < NUM_STRINGS; i++)
+ {
+ // Don't count X strings or open strings
+ if (fretboard[i] > 0)
+ {
+ sum += fretboard[i];
+ cnt++;
+ }
+ }
+ if (cnt)
+ score[SCORE_LOWONNECK] = (int)(15 - ((double) sum / (double) cnt))
+ * POSITION_SCORE;
+ else
+ score[SCORE_LOWONNECK] = 15 * POSITION_SCORE;
+
+
+ int adjNotes = 0;
+ for (i = 0; i < 5; i++)
+ {
+ if ((notes[i] != -1) && (notes[i] == notes[i + 1]))
+ adjNotes++;
+ }
+ score[SCORE_ADJNOTES] = (ADJ_SCORE * (5 - adjNotes));
+
+ // FInally, total up the score
+ score[SCORE_TOTAL] = 0;
+ for (i = 1; i < NUMSCORETYPES; i++)
+ score[SCORE_TOTAL] += score[i];
+}
+
+
+//
+// Iterate over all fretboard config's for this chord, call addToBest
+// with any good ones (ie: < span, etc etc...)
+//
+void
+Fretboard::iterate(Chord &chord)
+{
+ int string = 0;
+
+ // Start notes setup, increment up the neck for each string until
+ // you find a note that is in this chord (may be an open note)
+ for (int i = 0; i < NUM_STRINGS; i++)
+ {
+ while (! chord.inChord(notes[i]))
+ {
+ fretboard[i]++;
+ notes[i] = ( notes[i] + 1 ) % 12;
+ }
+ }
+
+ // Back up the first note one...so the loop will work
+ fretboard[0] = -1;
+
+ // While we are still on the fretboard!
+ while (string < NUM_STRINGS)
+ {
+
+ // increment the current string
+ fretboard[string]++;
+ if (fretboard[string] == 0)
+ notes[string] = openStrings[string];
+ else
+ notes[string] = ( notes[string] + 1 ) % 12;
+
+ while (! chord.inChord(notes[string]))
+ {
+ fretboard[string]++;
+ notes[string] = ( notes[string] + 1 ) % 12;
+ }
+
+ if (fretboard[string] > 15)
+ {
+
+ // Before turning over the 3rd string from the bass, try
+ // to make a chord with the bass string, and 2nd from
+ // bass string X'ed out...(ie: set to -1)
+ if (string == 0)
+ {
+
+ notes[0] = fretboard[0] = -1;
+ int span = getSpan();
+ if ((span < MAXSPAN) && chord.covered(notes))
+ {
+ getScore(chord);
+ addToBest();
+ }
+ }
+
+ if (string == 1)
+ {
+ int store = notes[0];
+ int fstore = fretboard[0];
+ notes[1] = fretboard[1] = -1;
+ notes[0] = fretboard[0] = -1;
+ int span = getSpan();
+ if ((span < MAXSPAN) && chord.covered(notes))
+ {
+ getScore(chord);
+ addToBest();
+ }
+ // Restore the notes you X'ed out
+ notes[0] = store;
+ fretboard[0] = fstore;
+ }
+
+ fretboard[string] = 0;
+ notes[string] = openStrings[string];
+ while (! chord.inChord(notes[string]))
+ {
+ fretboard[string]++;
+ notes[string] = chord.note_offset(notes[string], 1);
+ }
+ string++;
+ continue;
+ }
+
+#ifdef DEBUG
+ printf("TRY: "); this->print();
+#endif
+
+ string = 0;
+ int span = getSpan();
+ if (span >= MAXSPAN)
+ {
+#ifdef DEBUG
+ printf("Rejected for span\n");
+#endif
+ continue;
+ }
+ if (!chord.covered(notes))
+ {
+#ifdef DEBUG
+ printf("Rejected for coverage\n");
+#endif
+ continue;
+ }
+
+ getScore(chord);
+
+ addToBest();
+ }
+}
+
+//
+// uh, main
+//
+int main(int argc, char **argv)
+{
+ char buf[256], buf2[256];
+
+ if(argc > 1)
+ {
+ strcpy(buf, argv[1]);
+ if(argc > 3) {
+ if(! strcmp(argv[3],"lefty")) {
+ lefty = 1;
+
+ }
+
+
+ }
+
+ if(argc > 2) {
+ if(! strcmp(argv[2],"dadgad")) {
+ openStrings[0] = 5;
+ openStrings[1] = 0;
+ openStrings[2] = 5;
+ openStrings[3] = 10;
+ openStrings[4] = 0;
+ openStrings[5] = 5;
+ }
+ if(! strcmp(argv[2],"openg")) {
+ openStrings[0] = 5;
+ openStrings[1] = 10;
+ openStrings[2] = 5;
+ openStrings[3] = 10;
+ openStrings[4] = 2;
+ openStrings[5] = 5;
+
+ }
+ if(! strcmp(argv[2],"opene")) {
+ openStrings[0] = 7;
+ openStrings[1] = 2;
+ openStrings[2] = 7;
+ openStrings[3] = 11;
+ openStrings[4] = 2;
+ openStrings[5] = 7;
+
+ }
+ if(! strcmp(argv[2],"lefty")) {
+ lefty = 1;
+
+ }
+ }
+
+
+ // Allocate it for DOS/WINDOWS, to avoid stack overflow (weak)
+ Fretboard *fb = new Fretboard; ;
+ Chord chord;
+
+
+ // findChord upppercases the input string, so save a copy
+ strcpy(buf2, buf);
+
+ if (chord.findChord(buf))
+ {
+ chord.printError();
+
+ }
+ else {
+ chord.print(buf2);
+ fb->iterate(chord);
+
+ fb->printStack();
+ }
+ delete fb;
+ }
+ return 0;
+}
+
diff --git a/sources/extend/addon/matrix/chords/chords.apd b/sources/extend/addon/matrix/chords/chords.apd
new file mode 100644
index 00000000..2ab5b99d
--- /dev/null
+++ b/sources/extend/addon/matrix/chords/chords.apd
@@ -0,0 +1,3 @@
+url: $baseurl/chords
+name: Guitar Chords
+photo: $baseurl/addon/chords/chords.png
diff --git a/sources/extend/addon/matrix/chords/chords.php b/sources/extend/addon/matrix/chords/chords.php
new file mode 100755
index 00000000..93bdbd94
--- /dev/null
+++ b/sources/extend/addon/matrix/chords/chords.php
@@ -0,0 +1,129 @@
+
+ */
+
+
+function chords_load() {
+ register_hook('app_menu', 'addon/chords/chords.php', 'chords_app_menu');
+}
+
+function chords_unload() {
+ unregister_hook('app_menu', 'addon/chords/chords.php', 'chords_app_menu');
+
+}
+
+function chords_app_menu($a,&$b) {
+ $b['app_menu'][] = '
+This is a fairly comprehensive and complete guitar chord dictionary which will list most of the available ways to play a certain chord, starting from the base of the fingerboard up to a few frets beyond the twelfth fret (beyond which everything repeats). A couple of non-standard tunings are provided for the benefit of slide players, etc.
+
+
+Chord names start with a root note (A-G) and may include sharps (#) and flats (b). This software will parse most of the standard naming conventions such as maj, min, dim, sus(2 or 4), aug, with optional repeating elements.
+
+
+Valid examples include A, A7, Am7, Amaj7, Amaj9, Ammaj7, Aadd4, Asus2Add4, E7b13b11 ...
+
diff --git a/sources/extend/addon/matrix/donate/donate.apd b/sources/extend/addon/matrix/donate/donate.apd
new file mode 100644
index 00000000..eff602d3
--- /dev/null
+++ b/sources/extend/addon/matrix/donate/donate.apd
@@ -0,0 +1,3 @@
+url: $baseurl/donate
+name: Support Hubzilla
+photo: $baseurl/addon/donate/donate.png
diff --git a/sources/extend/addon/matrix/donate/donate.php b/sources/extend/addon/matrix/donate/donate.php
new file mode 100644
index 00000000..1eb6d57d
--- /dev/null
+++ b/sources/extend/addon/matrix/donate/donate.php
@@ -0,0 +1,75 @@
+' . t('The Redmatrix/Hubzilla projects are provided primarily by volunteers giving their time and expertise - and often paying out of pocket for services they share with others.') . '';
+$text .= '
' . t('There is no corporate funding and no ads, and we do not collect and sell your personal information. (We don\'t control your personal information - you do.)') . '
';
+$text .= '
' . t('Help support our ground-breaking work in decentralisation, web identity, and privacy.') . '
';
+
+$text .= '
' . t('Your donations keep servers and services running and also helps us to provide innovative new features and continued development.') . '
';
+
+$o = replace_macros(get_markup_template('donate.tpl','addon/donate'),array(
+ '$header' => t('Donate'),
+ '$text' => $text,
+ '$choice' => t('Choose a project, developer, or public hub to support with a one-time donation'),
+ '$onetime' => t('Donate Now'),
+ '$repeat' => t('Or become a project sponsor (Hubzilla Project only)'),
+ '$note' => t('Please indicate if you would like your first name or full name (or nothing) to appear in our sponsor listing'),
+ '$subscribe' => t('Sponsor'),
+ '$contributors' => $contributors,
+ '$sponsors' => $sponsors,
+ '$thanks' => t('Special thanks to: '),
+));
+
+call_hooks('donate_plugin',$o);
+
+return $o;
+
+}
diff --git a/sources/extend/addon/matrix/donate/donate.png b/sources/extend/addon/matrix/donate/donate.png
new file mode 100644
index 00000000..d932f001
Binary files /dev/null and b/sources/extend/addon/matrix/donate/donate.png differ
diff --git a/sources/extend/addon/matrix/donate/tipping.jpg b/sources/extend/addon/matrix/donate/tipping.jpg
new file mode 100644
index 00000000..f370ece7
Binary files /dev/null and b/sources/extend/addon/matrix/donate/tipping.jpg differ
diff --git a/sources/extend/addon/matrix/donate/view/tpl/donate.tpl b/sources/extend/addon/matrix/donate/view/tpl/donate.tpl
new file mode 100644
index 00000000..6382cc6f
--- /dev/null
+++ b/sources/extend/addon/matrix/donate/view/tpl/donate.tpl
@@ -0,0 +1,64 @@
+
' +
+ _e("You have been registered, here is your XMPP address:") + ' ' + con.username.htmlEnc() + '@' + con.domain.htmlEnc() + ' - ' + _e("Login") + '' +
+ '
'
+ );
+
+ // Login link
+ $('#home .homediv.registerer .success a').click(function() {
+ return doLogin(con.username, con.domain, con.pass, con.resource, '10', false);
+ });
+
+ // Show the waiting image
+ showGeneralWait();
+
+ // Change the page title
+ pageTitle('wait');
+ }
+
+ catch(e) {
+ // Logs errors
+ logThis(e, 1);
+ }
+
+ finally {
+ return false;
+ }
+}
+
+// Does the user anonymous login
+function doAnonymous() {
+ logThis('Trying to login anonymously...', 3);
+
+ var aPath = '#home .anonymouser ';
+ var room = $(aPath + '.room').val();
+ var nick = $(aPath + '.nick').val();
+
+ // If the form is correctly completed
+ if(room && nick) {
+ // We remove the not completed class to avoid problems
+ $('#home .anonymouser input').removeClass('please-complete');
+
+ // Redirect the user to the anonymous room
+ window.location.href = JAPPIX_LOCATION + '?r=' + room + '&n=' + nick;
+ }
+
+ // We check if the form is entirely completed
+ else {
+ $(aPath + 'input[type=text]').each(function() {
+ var select = $(this);
+
+ if(!select.val())
+ $(document).oneTime(10, function() {
+ select.addClass('please-complete').focus();
+ });
+ else
+ select.removeClass('please-complete');
+ });
+ }
+
+ return false;
+}
+
+// Handles the user connected event
+var CONNECTED = false;
+
+function handleConnected() {
+ logThis('Jappix is now connected.', 3);
+
+ // Connection markers
+ CONNECTED = true;
+ RECONNECT_TRY = 0;
+ RECONNECT_TIMER = 0;
+
+ // We hide the home page
+ $('#home').hide();
+
+ // Not resumed?
+ if(!RESUME) {
+ // Remember the session?
+ if(getDB('remember', 'session'))
+ setPersistent('session', 1, CURRENT_SESSION);
+
+ // We show the chatting app.
+ createTalkPage();
+
+ // We reset the homepage
+ switchHome('default');
+
+ // We get all the other things
+ getEverything();
+
+ // Set last activity stamp
+ LAST_ACTIVITY = getTimeStamp();
+ }
+
+ // Resumed
+ else {
+ // Send our presence
+ presenceSend();
+
+ // Change the title
+ updateTitle();
+ }
+
+ // Remove the waiting item
+ removeGeneralWait();
+}
+
+// Handles the user disconnected event
+function handleDisconnected() {
+ logThis('Jappix is now disconnected.', 3);
+
+ // Normal disconnection
+ if(!CURRENT_SESSION && !CONNECTED)
+ destroyTalkPage();
+}
+
+// Setups the normal connection
+function setupCon(con) {
+ // We setup all the necessary handlers for the connection
+ con.registerHandler('message', handleMessage);
+ con.registerHandler('presence', handlePresence);
+ con.registerHandler('iq', handleIQ);
+ con.registerHandler('onconnect', handleConnected);
+ con.registerHandler('onerror', handleError);
+ con.registerHandler('ondisconnect', handleDisconnected);
+}
+
+// Logouts from the server
+function logout() {
+ // We are not connected
+ if(!isConnected())
+ return false;
+
+ // Disconnect from the XMPP server
+ con.disconnect();
+
+ logThis('Jappix is disconnecting...', 3);
+}
+
+// Terminates a session
+function terminate() {
+ if(!isConnected())
+ return;
+
+ // Clear temporary session storage
+ resetConMarkers();
+
+ // Show the waiting item (useful if BOSH is sloooow)
+ showGeneralWait();
+
+ // Change the page title
+ pageTitle('wait');
+
+ // Disconnect from the XMPP server
+ logout();
+}
+
+// Quitss a session
+function quit() {
+ if(!isConnected())
+ return;
+
+ // We show the waiting image
+ showGeneralWait();
+
+ // Change the page title
+ pageTitle('wait');
+
+ // We disconnect from the XMPP server
+ logout();
+}
+
+// Creates the reconnect pane
+var RECONNECT_TRY = 0;
+var RECONNECT_TIMER = 0;
+
+function createReconnect(mode) {
+ logThis('This is not a normal disconnection, show the reconnect pane...', 1);
+
+ // Reconnect pane not yet displayed?
+ if(!exists('#reconnect')) {
+ // Blur the focused input/textarea/select
+ $('input, select, textarea').blur();
+
+ // Create the HTML code
+ var html = '
' +
+ '
' +
+ _e("Due to a network issue, you were disconnected. What do you want to do now?");
+
+ // Can we cancel reconnection?
+ if(mode == 'normal')
+ html += '' + _e("Cancel") + '';
+
+ html += '' + _e("Reconnect") + '' +
+ '
'
+ );
+ });
+ }
+
+ return false;
+ }
+
+ // Dataform?
+ selector.find('field').each(function() {
+ // We parse the received xml
+ var type = $(this).attr('type');
+ var label = $(this).attr('label');
+ var field = $(this).attr('var');
+ var value = $(this).find('value:first').text();
+ var required = '';
+
+ // No value?
+ if(!field)
+ return;
+
+ // Required input?
+ if($(this).find('required').size())
+ required = ' required=""';
+
+ // Compatibility fix
+ if(!label)
+ label = field;
+
+ if(!type)
+ type = '';
+
+ // Generate some values
+ var input;
+ var hideThis = '';
+
+ // Fixed field
+ if(type == 'fixed')
+ $(pathID).append('
' + value.htmlEnc() + '
');
+
+ else {
+ // Hidden field
+ if(type == 'hidden') {
+ hideThis = ' style="display: none;"';
+ input = '';
+ }
+
+ // Boolean field
+ else if(type == 'boolean') {
+ var checked;
+
+ if(value == '1')
+ checked = 'checked';
+ else
+ checked = '';
+
+ input = '';
+ }
+
+ // List-single/list-multi field
+ else if((type == 'list-single') || (type == 'list-multi')) {
+ var multiple = '';
+
+ // Multiple options?
+ if(type == 'list-multi')
+ multiple = ' multiple=""';
+
+ // Append the select field
+ input = '';
+ }
+
+ // Text-multi field
+ else if(type == 'text-multi')
+ input = '';
+
+ // JID-multi field
+ else if(type == 'jid-multi') {
+ // Put the XID into an array
+ var xid_arr = [];
+
+ $(this).find('value').each(function() {
+ var cValue = $(this).text();
+
+ if(!existArrayValue(xid_arr, cValue))
+ xid_arr.push(cValue);
+ });
+
+ // Sort the array
+ xid_arr.sort();
+
+ // Create the input
+ var xid_value = '';
+
+ if(xid_arr.length) {
+ for(i in xid_arr) {
+ // Any pre-value
+ if(xid_value)
+ xid_value += ', ';
+
+ // Add the current XID
+ xid_value += xid_arr[i];
+ }
+ }
+
+ input = '';
+ }
+
+ // Other stuffs that are similar
+ else {
+ // Text-single field
+ var iType = 'text';
+
+ // Text-private field
+ if(type == 'text-private')
+ iType = 'password';
+
+ // JID-single field
+ else if(type == 'jid-single')
+ iType = 'email';
+
+ input = '';
+ }
+
+ // Append the HTML markup for this field
+ $(pathID).append(
+ '
' +
+ '' +
+ input +
+ '
'
+ );
+ }
+ });
+
+ return false;
+}
+
+// Gets the dataform type
+function getDataFormType(host, node, id) {
+ var iq = new JSJaCIQ();
+ iq.setID(id + '-' + genID());
+ iq.setTo(host);
+ iq.setType('get');
+
+ var iqQuery = iq.setQuery(NS_DISCO_INFO);
+
+ if(node)
+ iqQuery.setAttribute('node', node);
+
+ con.send(iq, handleThisBrowse);
+}
+
+// Handles the browse stanza
+function handleThisBrowse(iq) {
+ /* REF: http://xmpp.org/registrar/disco-categories.html */
+
+ var id = iq.getID();
+ var splitted = id.split('-');
+ var target = splitted[0];
+ var sessionID = target + '-' + splitted[1];
+ var from = fullXID(getStanzaFrom(iq));
+ var hash = hex_md5(from);
+ var handleXML = iq.getQuery();
+ var pathID = '#' + target + ' .results[data-session=' + sessionID + ']';
+
+ // We first remove the waiting element
+ $(pathID + ' .disco-wait .' + hash).remove();
+
+ if($(handleXML).find('identity').attr('type')) {
+ var category = $(handleXML).find('identity').attr('category');
+ var type = $(handleXML).find('identity').attr('type');
+ var named = $(handleXML).find('identity').attr('name');
+
+ if(named)
+ gName = named;
+ else
+ gName = '';
+
+ var one, two, three, four, five;
+
+ // Get the features that this entity supports
+ var findFeature = $(handleXML).find('feature');
+
+ for(i in findFeature) {
+ var current = findFeature.eq(i).attr('var');
+
+ switch(current) {
+ case NS_SEARCH:
+ one = 1;
+ break;
+
+ case NS_MUC:
+ two = 1;
+ break;
+
+ case NS_REGISTER:
+ three = 1;
+ break;
+
+ case NS_COMMANDS:
+ four = 1;
+ break;
+
+ case NS_DISCO_ITEMS:
+ five = 1;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ var buttons = Array(one, two, three, four, five);
+
+ // We define the toolbox links depending on the supported features
+ var tools = '';
+ var aTools = Array('search', 'join', 'subscribe', 'command', 'browse');
+ var bTools = Array(_e("Search"), _e("Join"), _e("Subscribe"), _e("Command"), _e("Browse"));
+
+ for(i in buttons) {
+ if(buttons[i])
+ tools += '';
+ }
+
+ // As defined in the ref, we detect the type of each category to put an icon
+ switch(category) {
+ case 'account':
+ case 'auth':
+ case 'automation':
+ case 'client':
+ case 'collaboration':
+ case 'component':
+ case 'conference':
+ case 'directory':
+ case 'gateway':
+ case 'headline':
+ case 'hierarchy':
+ case 'proxy':
+ case 'pubsub':
+ case 'server':
+ case 'store':
+ break;
+
+ default:
+ category = 'others';
+ }
+
+ // We display the item we found
+ $(pathID + ' .disco-' + category + ' .disco-category-title').after(
+ '
',
+ ''
+ ]
+ },
+ defaults = {
+ flat: false,
+ starts: 1,
+ prev: '◀',
+ next: '▶',
+ lastSel: false,
+ mode: 'single',
+ view: 'days',
+ calendars: 1,
+ format: 'Y-m-d',
+ position: 'bottom',
+ eventName: 'click',
+ onRender: function(){return {};},
+ onChange: function(){return true;},
+ onShow: function(){return true;},
+ onBeforeShow: function(){return true;},
+ onHide: function(){return true;},
+ locale: {
+ days: [_e("Sunday"), _e("Monday"), _e("Tuesday"), _e("Wednesday"), _e("Thursday"), _e("Friday"), _e("Saturday"), _e("Sunday")],
+ daysShort: [cut(_e("Sunday"), 3), cut(_e("Monday"), 3), cut(_e("Tuesday"), 3), cut(_e("Wednesday"), 3), cut(_e("Thursday"), 3), cut(_e("Friday"), 3), cut(_e("Saturday"), 3), cut(_e("Sunday"), 3)],
+ daysMin: [cut(_e("Sunday"), 2), cut(_e("Monday"), 2), cut(_e("Tuesday"), 2), cut(_e("Wednesday"), 2), cut(_e("Thursday"), 2), cut(_e("Friday"), 2), cut(_e("Saturday"), 2), cut(_e("Sunday"), 2)],
+ months: [_e("January"), _e("February"), _e("March"), _e("April"), _e("May"), _e("June"), _e("July"), _e("August"), _e("September"), _e("October"), _e("November"), _e("December")],
+ monthsShort: [cut(_e("January"), 3), cut(_e("February"), 3), cut(_e("March"), 3), cut(_e("April"), 3), cut(_e("May"), 3), cut(_e("June"), 3), cut(_e("July"), 3), cut(_e("August"), 3), cut(_e("September"), 3), cut(_e("October"), 3), cut(_e("November"), 3), cut(_e("December"), 3)],
+ weekMin: ''
+ }
+ },
+ fill = function(el) {
+ var options = $(el).data('datepicker');
+ var cal = $(el);
+ var currentCal = Math.floor(options.calendars/2), date, data, dow, month, cnt = 0, week, days, indic, indic2, html, tblCal;
+ cal.find('td>table tbody').remove();
+ for (var i = 0; i < options.calendars; i++) {
+ date = new Date(options.current);
+ date.addMonths(-currentCal + i);
+ tblCal = cal.find('table').eq(i+1);
+ switch (tblCal[0].className) {
+ case 'datepickerViewDays':
+ dow = formatDate(date, 'B, Y');
+ break;
+ case 'datepickerViewMonths':
+ dow = date.getFullYear();
+ break;
+ case 'datepickerViewYears':
+ dow = (date.getFullYear()-6) + ' - ' + (date.getFullYear()+5);
+ break;
+ }
+ tblCal.find('thead tr:first th:eq(1) span').text(dow);
+ dow = date.getFullYear()-6;
+ data = {
+ data: [],
+ className: 'datepickerYears'
+ }
+ for ( var j = 0; j < 12; j++) {
+ data.data.push(dow + j);
+ }
+ html = tmpl(tpl.months.join(''), data);
+ date.setDate(1);
+ data = {weeks:[], test: 10};
+ month = date.getMonth();
+ var dow = (date.getDay() - options.starts) % 7;
+ date.addDays(-(dow + (dow < 0 ? 7 : 0)));
+ week = -1;
+ cnt = 0;
+ while (cnt < 42) {
+ indic = parseInt(cnt/7,10);
+ indic2 = cnt%7;
+ if (!data.weeks[indic]) {
+ week = date.getWeekNumber();
+ data.weeks[indic] = {
+ week: week,
+ days: []
+ };
+ }
+ data.weeks[indic].days[indic2] = {
+ text: date.getDate(),
+ classname: []
+ };
+ if (month != date.getMonth()) {
+ data.weeks[indic].days[indic2].classname.push('datepickerNotInMonth');
+ }
+ if (date.getDay() == 0) {
+ data.weeks[indic].days[indic2].classname.push('datepickerSunday');
+ }
+ if (date.getDay() == 6) {
+ data.weeks[indic].days[indic2].classname.push('datepickerSaturday');
+ }
+ var fromUser = options.onRender(date);
+ var val = date.valueOf();
+ if (fromUser.selected || options.date == val || $.inArray(val, options.date) > -1 || (options.mode == 'range' && val >= options.date[0] && val <= options.date[1])) {
+ data.weeks[indic].days[indic2].classname.push('datepickerSelected');
+ }
+ if (fromUser.disabled) {
+ data.weeks[indic].days[indic2].classname.push('datepickerDisabled');
+ }
+ if (fromUser.className) {
+ data.weeks[indic].days[indic2].classname.push(fromUser.className);
+ }
+ data.weeks[indic].days[indic2].classname = data.weeks[indic].days[indic2].classname.join(' ');
+ cnt++;
+ date.addDays(1);
+ }
+ html = tmpl(tpl.days.join(''), data) + html;
+ data = {
+ data: options.locale.monthsShort,
+ className: 'datepickerMonths'
+ };
+ html = tmpl(tpl.months.join(''), data) + html;
+ tblCal.append(html);
+ }
+ },
+ parseDate = function (date, format) {
+ if (date.constructor == Date) {
+ return new Date(date);
+ }
+ var parts = date.split(/\W+/);
+ var against = format.split(/\W+/), d, m, y, h, min, now = new Date();
+ for (var i = 0; i < parts.length; i++) {
+ switch (against[i]) {
+ case 'd':
+ case 'e':
+ d = parseInt(parts[i],10);
+ break;
+ case 'm':
+ m = parseInt(parts[i], 10)-1;
+ break;
+ case 'Y':
+ case 'y':
+ y = parseInt(parts[i], 10);
+ y += y > 100 ? 0 : (y < 29 ? 2000 : 1900);
+ break;
+ case 'H':
+ case 'I':
+ case 'k':
+ case 'l':
+ h = parseInt(parts[i], 10);
+ break;
+ case 'P':
+ case 'p':
+ if (/pm/i.test(parts[i]) && h < 12) {
+ h += 12;
+ } else if (/am/i.test(parts[i]) && h >= 12) {
+ h -= 12;
+ }
+ break;
+ case 'M':
+ min = parseInt(parts[i], 10);
+ break;
+ }
+ }
+ return new Date(
+ y === undefined ? now.getFullYear() : y,
+ m === undefined ? now.getMonth() : m,
+ d === undefined ? now.getDate() : d,
+ h === undefined ? now.getHours() : h,
+ min === undefined ? now.getMinutes() : min,
+ 0
+ );
+ },
+ formatDate = function(date, format) {
+ var m = date.getMonth();
+ var d = date.getDate();
+ var y = date.getFullYear();
+ var wn = date.getWeekNumber();
+ var w = date.getDay();
+ var s = {};
+ var hr = date.getHours();
+ var pm = (hr >= 12);
+ var ir = (pm) ? (hr - 12) : hr;
+ var dy = date.getDayOfYear();
+ if (ir == 0) {
+ ir = 12;
+ }
+ var min = date.getMinutes();
+ var sec = date.getSeconds();
+ var parts = format.split(''), part;
+ for ( var i = 0; i < parts.length; i++ ) {
+ part = parts[i];
+ switch (parts[i]) {
+ case 'a':
+ part = date.getDayName();
+ break;
+ case 'A':
+ part = date.getDayName(true);
+ break;
+ case 'b':
+ part = date.getMonthName();
+ break;
+ case 'B':
+ part = date.getMonthName(true);
+ break;
+ case 'C':
+ part = 1 + Math.floor(y / 100);
+ break;
+ case 'd':
+ part = (d < 10) ? ("0" + d) : d;
+ break;
+ case 'e':
+ part = d;
+ break;
+ case 'H':
+ part = (hr < 10) ? ("0" + hr) : hr;
+ break;
+ case 'I':
+ part = (ir < 10) ? ("0" + ir) : ir;
+ break;
+ case 'j':
+ part = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy;
+ break;
+ case 'k':
+ part = hr;
+ break;
+ case 'l':
+ part = ir;
+ break;
+ case 'm':
+ part = (m < 9) ? ("0" + (1+m)) : (1+m);
+ break;
+ case 'M':
+ part = (min < 10) ? ("0" + min) : min;
+ break;
+ case 'p':
+ case 'P':
+ part = pm ? "PM" : "AM";
+ break;
+ case 's':
+ part = Math.floor(date.getTime() / 1000);
+ break;
+ case 'S':
+ part = (sec < 10) ? ("0" + sec) : sec;
+ break;
+ case 'u':
+ part = w + 1;
+ break;
+ case 'w':
+ part = w;
+ break;
+ case 'y':
+ part = ('' + y).substr(2, 2);
+ break;
+ case 'Y':
+ part = y;
+ break;
+ }
+ parts[i] = part;
+ }
+ return parts.join('');
+ },
+ extendDate = function(options) {
+ if (Date.prototype.tempDate) {
+ return;
+ }
+ Date.prototype.tempDate = null;
+ Date.prototype.months = options.months;
+ Date.prototype.monthsShort = options.monthsShort;
+ Date.prototype.days = options.days;
+ Date.prototype.daysShort = options.daysShort;
+ Date.prototype.getMonthName = function(fullName) {
+ return this[fullName ? 'months' : 'monthsShort'][this.getMonth()];
+ };
+ Date.prototype.getDayName = function(fullName) {
+ return this[fullName ? 'days' : 'daysShort'][this.getDay()];
+ };
+ Date.prototype.addDays = function (n) {
+ this.setDate(this.getDate() + n);
+ this.tempDate = this.getDate();
+ };
+ Date.prototype.addMonths = function (n) {
+ if (this.tempDate == null) {
+ this.tempDate = this.getDate();
+ }
+ this.setDate(1);
+ this.setMonth(this.getMonth() + n);
+ this.setDate(Math.min(this.tempDate, this.getMaxDays()));
+ };
+ Date.prototype.addYears = function (n) {
+ if (this.tempDate == null) {
+ this.tempDate = this.getDate();
+ }
+ this.setDate(1);
+ this.setFullYear(this.getFullYear() + n);
+ this.setDate(Math.min(this.tempDate, this.getMaxDays()));
+ };
+ Date.prototype.getMaxDays = function() {
+ var tmpDate = new Date(Date.parse(this)),
+ d = 28, m;
+ m = tmpDate.getMonth();
+ d = 28;
+ while (tmpDate.getMonth() == m) {
+ d ++;
+ tmpDate.setDate(d);
+ }
+ return d - 1;
+ };
+ Date.prototype.getFirstDay = function() {
+ var tmpDate = new Date(Date.parse(this));
+ tmpDate.setDate(1);
+ return tmpDate.getDay();
+ };
+ Date.prototype.getWeekNumber = function() {
+ var tempDate = new Date(this);
+ tempDate.setDate(tempDate.getDate() - (tempDate.getDay() + 6) % 7 + 3);
+ var dms = tempDate.valueOf();
+ tempDate.setMonth(0);
+ tempDate.setDate(4);
+ return Math.round((dms - tempDate.valueOf()) / (604800000)) + 1;
+ };
+ Date.prototype.getDayOfYear = function() {
+ var now = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
+ var then = new Date(this.getFullYear(), 0, 0, 0, 0, 0);
+ var time = now - then;
+ return Math.floor(time / 24*60*60*1000);
+ };
+ },
+ layout = function (el) {
+ var options = $(el).data('datepicker');
+ var cal = $('#' + options.id);
+ if (!options.extraHeight) {
+ var divs = $(el).find('div');
+ options.extraHeight = divs.get(0).offsetHeight + divs.get(1).offsetHeight;
+ options.extraWidth = divs.get(2).offsetWidth + divs.get(3).offsetWidth;
+ }
+ var tbl = cal.find('table:first').get(0);
+ var width = tbl.offsetWidth;
+ var height = tbl.offsetHeight;
+ cal.css({
+ width: width + options.extraWidth + 'px',
+ height: height + options.extraHeight + 'px'
+ }).find('div.datepickerContainer').css({
+ width: width + 'px',
+ height: height + 'px'
+ });
+ },
+ click = function(ev) {
+ if ($(ev.target).is('span')) {
+ ev.target = ev.target.parentNode;
+ }
+ var el = $(ev.target);
+ if (el.is('a')) {
+ ev.target.blur();
+ if (el.hasClass('datepickerDisabled')) {
+ return false;
+ }
+ var options = $(this).data('datepicker');
+ var parentEl = el.parent();
+ var tblEl = parentEl.parent().parent().parent();
+ var tblIndex = $('table', this).index(tblEl.get(0)) - 1;
+ var tmp = new Date(options.current);
+ var changed = false;
+ var fillIt = false;
+ if (parentEl.is('th')) {
+ if (parentEl.hasClass('datepickerWeek') && options.mode == 'range' && !parentEl.next().hasClass('datepickerDisabled')) {
+ var val = parseInt(parentEl.next().text(), 10);
+ tmp.addMonths(tblIndex - Math.floor(options.calendars/2));
+ if (parentEl.next().hasClass('datepickerNotInMonth')) {
+ tmp.addMonths(val > 15 ? -1 : 1);
+ }
+ tmp.setDate(val);
+ options.date[0] = (tmp.setHours(0,0,0,0)).valueOf();
+ tmp.setHours(23,59,59,0);
+ tmp.addDays(6);
+ options.date[1] = tmp.valueOf();
+ fillIt = true;
+ changed = true;
+ options.lastSel = false;
+ } else if (parentEl.hasClass('datepickerMonth')) {
+ tmp.addMonths(tblIndex - Math.floor(options.calendars/2));
+ switch (tblEl.get(0).className) {
+ case 'datepickerViewDays':
+ tblEl.get(0).className = 'datepickerViewMonths';
+ el.find('span').text(tmp.getFullYear());
+ break;
+ case 'datepickerViewMonths':
+ tblEl.get(0).className = 'datepickerViewYears';
+ el.find('span').text((tmp.getFullYear()-6) + ' - ' + (tmp.getFullYear()+5));
+ break;
+ case 'datepickerViewYears':
+ tblEl.get(0).className = 'datepickerViewDays';
+ el.find('span').text(formatDate(tmp, 'B, Y'));
+ break;
+ }
+ } else if (parentEl.parent().parent().is('thead')) {
+ switch (tblEl.get(0).className) {
+ case 'datepickerViewDays':
+ options.current.addMonths(parentEl.hasClass('datepickerGoPrev') ? -1 : 1);
+ break;
+ case 'datepickerViewMonths':
+ options.current.addYears(parentEl.hasClass('datepickerGoPrev') ? -1 : 1);
+ break;
+ case 'datepickerViewYears':
+ options.current.addYears(parentEl.hasClass('datepickerGoPrev') ? -12 : 12);
+ break;
+ }
+ fillIt = true;
+ }
+ } else if (parentEl.is('td') && !parentEl.hasClass('datepickerDisabled')) {
+ switch (tblEl.get(0).className) {
+ case 'datepickerViewMonths':
+ options.current.setMonth(tblEl.find('tbody.datepickerMonths td').index(parentEl));
+ options.current.setFullYear(parseInt(tblEl.find('thead th.datepickerMonth span').text(), 10));
+ options.current.addMonths(Math.floor(options.calendars/2) - tblIndex);
+ tblEl.get(0).className = 'datepickerViewDays';
+ break;
+ case 'datepickerViewYears':
+ options.current.setFullYear(parseInt(el.text(), 10));
+ tblEl.get(0).className = 'datepickerViewMonths';
+ break;
+ default:
+ var val = parseInt(el.text(), 10);
+ tmp.addMonths(tblIndex - Math.floor(options.calendars/2));
+ if (parentEl.hasClass('datepickerNotInMonth')) {
+ tmp.addMonths(val > 15 ? -1 : 1);
+ }
+ tmp.setDate(val);
+ switch (options.mode) {
+ case 'multiple':
+ val = (tmp.setHours(0,0,0,0)).valueOf();
+ if ($.inArray(val, options.date) > -1) {
+ $.each(options.date, function(nr, dat){
+ if (dat == val) {
+ options.date.splice(nr,1);
+ return false;
+ }
+ });
+ } else {
+ options.date.push(val);
+ }
+ break;
+ case 'range':
+ if (!options.lastSel) {
+ options.date[0] = (tmp.setHours(0,0,0,0)).valueOf();
+ }
+ val = (tmp.setHours(23,59,59,0)).valueOf();
+ if (val < options.date[0]) {
+ options.date[1] = options.date[0] + 86399000;
+ options.date[0] = val - 86399000;
+ } else {
+ options.date[1] = val;
+ }
+ options.lastSel = !options.lastSel;
+ break;
+ default:
+ options.date = tmp.valueOf();
+ break;
+ }
+ break;
+ }
+ fillIt = true;
+ changed = true;
+ }
+ if (fillIt) {
+ fill(this);
+ }
+ if (changed) {
+ options.onChange.apply(this, prepareDate(options));
+ }
+ }
+ return false;
+ },
+ prepareDate = function (options) {
+ var tmp;
+ if (options.mode == 'single') {
+ tmp = new Date(options.date);
+ return [formatDate(tmp, options.format), tmp, options.el];
+ } else {
+ tmp = [[],[], options.el];
+ $.each(options.date, function(nr, val){
+ var date = new Date(val);
+ tmp[0].push(formatDate(date, options.format));
+ tmp[1].push(date);
+ });
+ return tmp;
+ }
+ },
+ getViewport = function () {
+ var m = document.compatMode == 'CSS1Compat';
+ return {
+ l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
+ t : window.pageYOffset || (m ? document.documentElement.scrollTop : document.body.scrollTop),
+ w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth),
+ h : window.innerHeight || (m ? document.documentElement.clientHeight : document.body.clientHeight)
+ };
+ },
+ isChildOf = function(parentEl, el, container) {
+ if (parentEl == el) {
+ return true;
+ }
+ if (parentEl.contains) {
+ return parentEl.contains(el);
+ }
+ if ( parentEl.compareDocumentPosition ) {
+ return !!(parentEl.compareDocumentPosition(el) & 16);
+ }
+ var prEl = el.parentNode;
+ while(prEl && prEl != container) {
+ if (prEl == parentEl)
+ return true;
+ prEl = prEl.parentNode;
+ }
+ return false;
+ },
+ show = function (ev) {
+ var cal = $('#' + $(this).data('datepickerId'));
+ if (!cal.is(':visible')) {
+ var calEl = cal.get(0);
+ fill(calEl);
+ var options = cal.data('datepicker');
+ options.onBeforeShow.apply(this, [cal.get(0)]);
+ var pos = $(this).offset();
+ var viewPort = getViewport();
+ var top = pos.top;
+ var left = pos.left;
+ var oldDisplay = $.curCSS(calEl, 'display');
+ cal.css({
+ visibility: 'hidden',
+ display: 'block'
+ });
+ layout(calEl);
+ switch (options.position){
+ case 'top':
+ top -= calEl.offsetHeight;
+ break;
+ case 'left':
+ left -= calEl.offsetWidth;
+ break;
+ case 'right':
+ left += this.offsetWidth;
+ break;
+ case 'bottom':
+ top += this.offsetHeight;
+ break;
+ }
+ if (top + calEl.offsetHeight > viewPort.t + viewPort.h) {
+ top = pos.top - calEl.offsetHeight;
+ }
+ if (top < viewPort.t) {
+ top = pos.top + this.offsetHeight + calEl.offsetHeight;
+ }
+ if (left + calEl.offsetWidth > viewPort.l + viewPort.w) {
+ left = pos.left - calEl.offsetWidth;
+ }
+ if (left < viewPort.l) {
+ left = pos.left + this.offsetWidth
+ }
+ cal.css({
+ visibility: 'visible',
+ display: 'block',
+ top: top + 'px',
+ left: left + 'px'
+ });
+ if (options.onShow.apply(this, [cal.get(0)]) != false) {
+ cal.show();
+ }
+ $(document).bind('mousedown', {cal: cal, trigger: this}, hide);
+ }
+ return false;
+ },
+ hide = function (ev) {
+ if (ev.target != ev.data.trigger && !isChildOf(ev.data.cal.get(0), ev.target, ev.data.cal.get(0))) {
+ if (ev.data.cal.data('datepicker').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
+ ev.data.cal.hide();
+ }
+ $(document).unbind('mousedown', hide);
+ }
+ };
+ return {
+ init: function(options){
+ options = $.extend({}, defaults, options||{});
+ extendDate(options.locale);
+ options.calendars = Math.max(1, parseInt(options.calendars,10)||1);
+ options.mode = /single|multiple|range/.test(options.mode) ? options.mode : 'single';
+ return this.each(function(){
+ if (!$(this).data('datepicker')) {
+ options.el = this;
+ if (options.date.constructor == String) {
+ options.date = parseDate(options.date, options.format);
+ options.date.setHours(0,0,0,0);
+ }
+ if (options.mode != 'single') {
+ if (options.date.constructor != Array) {
+ options.date = [options.date.valueOf()];
+ if (options.mode == 'range') {
+ options.date.push(((new Date(options.date[0])).setHours(23,59,59,0)).valueOf());
+ }
+ } else {
+ for (var i = 0; i < options.date.length; i++) {
+ options.date[i] = (parseDate(options.date[i], options.format).setHours(0,0,0,0)).valueOf();
+ }
+ if (options.mode == 'range') {
+ options.date[1] = ((new Date(options.date[1])).setHours(23,59,59,0)).valueOf();
+ }
+ }
+ } else {
+ options.date = options.date.valueOf();
+ }
+ if (!options.current) {
+ options.current = new Date();
+ } else {
+ options.current = parseDate(options.current, options.format);
+ }
+ options.current.setDate(1);
+ options.current.setHours(0,0,0,0);
+ var id = 'datepicker_' + parseInt(Math.random() * 1000), cnt;
+ options.id = id;
+ $(this).data('datepickerId', options.id);
+ var cal = $(tpl.wrapper).attr('id', id).bind('click', click).data('datepicker', options);
+ if (options.className) {
+ cal.addClass(options.className);
+ }
+ var html = '';
+ for (var i = 0; i < options.calendars; i++) {
+ cnt = options.starts;
+ if (i > 0) {
+ html += tpl.space;
+ }
+ html += tmpl(tpl.head.join(''), {
+ week: options.locale.weekMin,
+ prev: options.prev,
+ next: options.next,
+ day1: options.locale.daysMin[(cnt++)%7],
+ day2: options.locale.daysMin[(cnt++)%7],
+ day3: options.locale.daysMin[(cnt++)%7],
+ day4: options.locale.daysMin[(cnt++)%7],
+ day5: options.locale.daysMin[(cnt++)%7],
+ day6: options.locale.daysMin[(cnt++)%7],
+ day7: options.locale.daysMin[(cnt++)%7]
+ });
+ }
+ cal
+ .find('tr:first').append(html)
+ .find('table').addClass(views[options.view]);
+ fill(cal.get(0));
+ if (options.flat) {
+ cal.appendTo(this).show().css('position', 'relative');
+ layout(cal.get(0));
+ } else {
+ cal.appendTo(document.body);
+ $(this).bind(options.eventName, show);
+ }
+ }
+ });
+ },
+ showPicker: function() {
+ return this.each( function () {
+ if ($(this).data('datepickerId')) {
+ show.apply(this);
+ }
+ });
+ },
+ hidePicker: function() {
+ return this.each( function () {
+ if ($(this).data('datepickerId')) {
+ $('#' + $(this).data('datepickerId')).hide();
+ }
+ });
+ },
+ setDate: function(date, shiftTo){
+ return this.each(function(){
+ if ($(this).data('datepickerId')) {
+ var cal = $('#' + $(this).data('datepickerId'));
+ var options = cal.data('datepicker');
+ options.date = date;
+ if (options.date.constructor == String) {
+ options.date = parseDate(options.date, options.format);
+ options.date.setHours(0,0,0,0);
+ }
+ if (options.mode != 'single') {
+ if (options.date.constructor != Array) {
+ options.date = [options.date.valueOf()];
+ if (options.mode == 'range') {
+ options.date.push(((new Date(options.date[0])).setHours(23,59,59,0)).valueOf());
+ }
+ } else {
+ for (var i = 0; i < options.date.length; i++) {
+ options.date[i] = (parseDate(options.date[i], options.format).setHours(0,0,0,0)).valueOf();
+ }
+ if (options.mode == 'range') {
+ options.date[1] = ((new Date(options.date[1])).setHours(23,59,59,0)).valueOf();
+ }
+ }
+ } else {
+ options.date = options.date.valueOf();
+ }
+ if (shiftTo) {
+ options.current = new Date (options.mode != 'single' ? options.date[0] : options.date);
+ }
+ fill(cal.get(0));
+ }
+ });
+ },
+ getDate: function(formated) {
+ if (this.size() > 0) {
+ return prepareDate($('#' + $(this).data('datepickerId')).data('datepicker'))[formated ? 0 : 1];
+ }
+ },
+ clear: function(){
+ return this.each(function(){
+ if ($(this).data('datepickerId')) {
+ var cal = $('#' + $(this).data('datepickerId'));
+ var options = cal.data('datepicker');
+ if (options.mode != 'single') {
+ options.date = [];
+ fill(cal.get(0));
+ }
+ }
+ });
+ },
+ fixLayout: function(){
+ return this.each(function(){
+ if ($(this).data('datepickerId')) {
+ var cal = $('#' + $(this).data('datepickerId'));
+ var options = cal.data('datepicker');
+ if (options.flat) {
+ layout(cal.get(0));
+ }
+ }
+ });
+ }
+ };
+ }();
+ $.fn.extend({
+ DatePicker: DatePicker.init,
+ DatePickerHide: DatePicker.hidePicker,
+ DatePickerShow: DatePicker.showPicker,
+ DatePickerSetDate: DatePicker.setDate,
+ DatePickerGetDate: DatePicker.getDate,
+ DatePickerClear: DatePicker.clear,
+ DatePickerLayout: DatePicker.fixLayout
+ });
+})(jQuery);
+
+(function(){
+ var cache = {};
+
+ this.tmpl = function tmpl(str, data){
+ // Figure out if we're getting a template, or if we need to
+ // load the template - and be sure to cache the result.
+ var fn = !/\W/.test(str) ?
+ cache[str] = cache[str] ||
+ tmpl(document.getElementById(str).innerHTML) :
+
+ // Generate a reusable function that will serve as a template
+ // generator (and which will be cached).
+ new Function("obj",
+ "var p=[],print=function(){p.push.apply(p,arguments);};" +
+
+ // Introduce the data as local variables using with(){}
+ "with(obj){p.push('" +
+
+ // Convert the template into pure JavaScript
+ str
+ .replace(/[\r\t\n]/g, " ")
+ .split("<%").join("\t")
+ .replace(/((^|%>)[^\t]*)'/g, "$1\r")
+ .replace(/\t=(.*?)%>/g, "',$1,'")
+ .split("\t").join("');")
+ .split("%>").join("p.push('")
+ .split("\r").join("\\'")
+ + "');}return p.join('');");
+
+ // Provide some basic currying to the user
+ return data ? fn( data ) : fn;
+ };
+})();
diff --git a/sources/extend/addon/matrix/jappixmini/jappix/js/jquery.form.js b/sources/extend/addon/matrix/jappixmini/jappix/js/jquery.form.js
new file mode 100644
index 00000000..2b853df4
--- /dev/null
+++ b/sources/extend/addon/matrix/jappixmini/jappix/js/jquery.form.js
@@ -0,0 +1,785 @@
+/*!
+ * jQuery Form Plugin
+ * version: 2.49 (18-OCT-2010)
+ * @requires jQuery v1.3.2 or later
+ *
+ * Examples and documentation at: http://malsup.com/jquery/form/
+ * Dual licensed under the MIT and GPL licenses:
+ * http://www.opensource.org/licenses/mit-license.php
+ * http://www.gnu.org/licenses/gpl.html
+ */
+;(function($) {
+
+/*
+ Usage Note:
+ -----------
+ Do not use both ajaxSubmit and ajaxForm on the same form. These
+ functions are intended to be exclusive. Use ajaxSubmit if you want
+ to bind your own submit handler to the form. For example,
+
+ $(document).ready(function() {
+ $('#myForm').bind('submit', function(e) {
+ e.preventDefault(); // <-- important
+ $(this).ajaxSubmit({
+ target: '#output'
+ });
+ });
+ });
+
+ Use ajaxForm when you want the plugin to manage all the event binding
+ for you. For example,
+
+ $(document).ready(function() {
+ $('#myForm').ajaxForm({
+ target: '#output'
+ });
+ });
+
+ When using ajaxForm, the ajaxSubmit function will be invoked for you
+ at the appropriate time.
+*/
+
+/**
+ * ajaxSubmit() provides a mechanism for immediately submitting
+ * an HTML form using AJAX.
+ */
+$.fn.ajaxSubmit = function(options) {
+ // fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
+ if (!this.length) {
+ log('ajaxSubmit: skipping submit process - no element selected');
+ return this;
+ }
+
+ if (typeof options == 'function') {
+ options = { success: options };
+ }
+
+ var url = $.trim(this.attr('action'));
+ if (url) {
+ // clean url (don't include hash vaue)
+ url = (url.match(/^([^#]+)/)||[])[1];
+ }
+ url = url || window.location.href || '';
+
+ options = $.extend(true, {
+ url: url,
+ type: this.attr('method') || 'GET',
+ iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
+ }, options);
+
+ // hook for manipulating the form data before it is extracted;
+ // convenient for use with rich editors like tinyMCE or FCKEditor
+ var veto = {};
+ this.trigger('form-pre-serialize', [this, options, veto]);
+ if (veto.veto) {
+ log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
+ return this;
+ }
+
+ // provide opportunity to alter form data before it is serialized
+ if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
+ log('ajaxSubmit: submit aborted via beforeSerialize callback');
+ return this;
+ }
+
+ var n,v,a = this.formToArray(options.semantic);
+ if (options.data) {
+ options.extraData = options.data;
+ for (n in options.data) {
+ if(options.data[n] instanceof Array) {
+ for (var k in options.data[n]) {
+ a.push( { name: n, value: options.data[n][k] } );
+ }
+ }
+ else {
+ v = options.data[n];
+ v = $.isFunction(v) ? v() : v; // if value is fn, invoke it
+ a.push( { name: n, value: v } );
+ }
+ }
+ }
+
+ // give pre-submit callback an opportunity to abort the submit
+ if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
+ log('ajaxSubmit: submit aborted via beforeSubmit callback');
+ return this;
+ }
+
+ // fire vetoable 'validate' event
+ this.trigger('form-submit-validate', [a, this, options, veto]);
+ if (veto.veto) {
+ log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
+ return this;
+ }
+
+ var q = $.param(a);
+
+ if (options.type.toUpperCase() == 'GET') {
+ options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
+ options.data = null; // data is null for 'get'
+ }
+ else {
+ options.data = q; // data is the query string for 'post'
+ }
+
+ var $form = this, callbacks = [];
+ if (options.resetForm) {
+ callbacks.push(function() { $form.resetForm(); });
+ }
+ if (options.clearForm) {
+ callbacks.push(function() { $form.clearForm(); });
+ }
+
+ // perform a load on the target only if dataType is not provided
+ if (!options.dataType && options.target) {
+ var oldSuccess = options.success || function(){};
+ callbacks.push(function(data) {
+ var fn = options.replaceTarget ? 'replaceWith' : 'html';
+ $(options.target)[fn](data).each(oldSuccess, arguments);
+ });
+ }
+ else if (options.success) {
+ callbacks.push(options.success);
+ }
+
+ options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
+ var context = options.context || options; // jQuery 1.4+ supports scope context
+ for (var i=0, max=callbacks.length; i < max; i++) {
+ callbacks[i].apply(context, [data, status, xhr || $form, $form]);
+ }
+ };
+
+ // are there files to upload?
+ var fileInputs = $('input:file', this).length > 0;
+ var mp = 'multipart/form-data';
+ var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
+
+ // options.iframe allows user to force iframe mode
+ // 06-NOV-09: now defaulting to iframe mode if file input is detected
+ if (options.iframe !== false && (fileInputs || options.iframe || multipart)) {
+ // hack to fix Safari hang (thanks to Tim Molendijk for this)
+ // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
+ if (options.closeKeepAlive) {
+ $.get(options.closeKeepAlive, fileUpload);
+ }
+ else {
+ fileUpload();
+ }
+ }
+ else {
+ $.ajax(options);
+ }
+
+ // fire 'notify' event
+ this.trigger('form-submit-notify', [this, options]);
+ return this;
+
+
+ // private function for handling file uploads (hat tip to YAHOO!)
+ function fileUpload() {
+ var form = $form[0];
+
+ if ($(':input[name=submit],:input[id=submit]', form).length) {
+ // if there is an input with a name or id of 'submit' then we won't be
+ // able to invoke the submit fn on the form (at least not x-browser)
+ alert('Error: Form elements must not have name or id of "submit".');
+ return;
+ }
+
+ var s = $.extend(true, {}, $.ajaxSettings, options);
+ s.context = s.context || s;
+ var id = 'jqFormIO' + (new Date().getTime()), fn = '_'+id;
+ window[fn] = function() {
+ var f = $io.data('form-plugin-onload');
+ if (f) {
+ f();
+ window[fn] = undefined;
+ try { delete window[fn]; } catch(e){}
+ }
+ }
+ var $io = $('');
+ var io = $io[0];
+
+ $io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
+
+ var xhr = { // mock object
+ aborted: 0,
+ responseText: null,
+ responseXML: null,
+ status: 0,
+ statusText: 'n/a',
+ getAllResponseHeaders: function() {},
+ getResponseHeader: function() {},
+ setRequestHeader: function() {},
+ abort: function() {
+ this.aborted = 1;
+ $io.attr('src', s.iframeSrc); // abort op in progress
+ }
+ };
+
+ var g = s.global;
+ // trigger ajax global events so that activity/block indicators work like normal
+ if (g && ! $.active++) {
+ $.event.trigger("ajaxStart");
+ }
+ if (g) {
+ $.event.trigger("ajaxSend", [xhr, s]);
+ }
+
+ if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
+ if (s.global) {
+ $.active--;
+ }
+ return;
+ }
+ if (xhr.aborted) {
+ return;
+ }
+
+ var cbInvoked = false;
+ var timedOut = 0;
+
+ // add submitting element to data if we know it
+ var sub = form.clk;
+ if (sub) {
+ var n = sub.name;
+ if (n && !sub.disabled) {
+ s.extraData = s.extraData || {};
+ s.extraData[n] = sub.value;
+ if (sub.type == "image") {
+ s.extraData[n+'.x'] = form.clk_x;
+ s.extraData[n+'.y'] = form.clk_y;
+ }
+ }
+ }
+
+ // take a breath so that pending repaints get some cpu time before the upload starts
+ function doSubmit() {
+ // make sure form attrs are set
+ var t = $form.attr('target'), a = $form.attr('action');
+
+ // update form attrs in IE friendly way
+ form.setAttribute('target',id);
+ if (form.getAttribute('method') != 'POST') {
+ form.setAttribute('method', 'POST');
+ }
+ if (form.getAttribute('action') != s.url) {
+ form.setAttribute('action', s.url);
+ }
+
+ // ie borks in some cases when setting encoding
+ if (! s.skipEncodingOverride) {
+ $form.attr({
+ encoding: 'multipart/form-data',
+ enctype: 'multipart/form-data'
+ });
+ }
+
+ // support timout
+ if (s.timeout) {
+ setTimeout(function() { timedOut = true; cb(); }, s.timeout);
+ }
+
+ // add "extra" data to form if provided in options
+ var extraInputs = [];
+ try {
+ if (s.extraData) {
+ for (var n in s.extraData) {
+ extraInputs.push(
+ $('')
+ .appendTo(form)[0]);
+ }
+ }
+
+ // add iframe to doc and submit the form
+ $io.appendTo('body');
+ $io.data('form-plugin-onload', cb);
+ form.submit();
+ }
+ finally {
+ // reset attrs and remove "extra" input elements
+ form.setAttribute('action',a);
+ if(t) {
+ form.setAttribute('target', t);
+ } else {
+ $form.removeAttr('target');
+ }
+ $(extraInputs).remove();
+ }
+ }
+
+ if (s.forceSync) {
+ doSubmit();
+ }
+ else {
+ setTimeout(doSubmit, 10); // this lets dom updates render
+ }
+
+ var data, doc, domCheckCount = 50;
+
+ function cb() {
+ if (cbInvoked) {
+ return;
+ }
+
+ $io.removeData('form-plugin-onload');
+
+ var ok = true;
+ try {
+ if (timedOut) {
+ throw 'timeout';
+ }
+ // extract the server response from the iframe
+ doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
+
+ var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
+ log('isXml='+isXml);
+ if (!isXml && window.opera && (doc.body == null || doc.body.innerHTML == '')) {
+ if (--domCheckCount) {
+ // in some browsers (Opera) the iframe DOM is not always traversable when
+ // the onload callback fires, so we loop a bit to accommodate
+ log('requeing onLoad callback, DOM not available');
+ setTimeout(cb, 250);
+ return;
+ }
+ // let this fall through because server response could be an empty document
+ //log('Could not access iframe DOM after mutiple tries.');
+ //throw 'DOMException: not available';
+ }
+
+ //log('response detected');
+ cbInvoked = true;
+ xhr.responseText = doc.documentElement ? doc.documentElement.innerHTML : null;
+ xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
+ xhr.getResponseHeader = function(header){
+ var headers = {'content-type': s.dataType};
+ return headers[header];
+ };
+
+ var scr = /(json|script)/.test(s.dataType);
+ if (scr || s.textarea) {
+ // see if user embedded response in textarea
+ var ta = doc.getElementsByTagName('textarea')[0];
+ if (ta) {
+ xhr.responseText = ta.value;
+ }
+ else if (scr) {
+ // account for browsers injecting pre around json response
+ var pre = doc.getElementsByTagName('pre')[0];
+ var b = doc.getElementsByTagName('body')[0];
+ if (pre) {
+ xhr.responseText = pre.innerHTML;
+ }
+ else if (b) {
+ xhr.responseText = b.innerHTML;
+ }
+ }
+ }
+ else if (s.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
+ xhr.responseXML = toXml(xhr.responseText);
+ }
+ data = $.httpData(xhr, s.dataType);
+ }
+ catch(e){
+ log('error caught:',e);
+ ok = false;
+ xhr.error = e;
+ $.handleError(s, xhr, 'error', e);
+ }
+
+ // ordering of these callbacks/triggers is odd, but that's how $.ajax does it
+ if (ok) {
+ s.success.call(s.context, data, 'success', xhr);
+ if (g) {
+ $.event.trigger("ajaxSuccess", [xhr, s]);
+ }
+ }
+ if (g) {
+ $.event.trigger("ajaxComplete", [xhr, s]);
+ }
+ if (g && ! --$.active) {
+ $.event.trigger("ajaxStop");
+ }
+ if (s.complete) {
+ s.complete.call(s.context, xhr, ok ? 'success' : 'error');
+ }
+
+ // clean up
+ setTimeout(function() {
+ $io.removeData('form-plugin-onload');
+ $io.remove();
+ xhr.responseXML = null;
+ }, 100);
+ }
+
+ function toXml(s, doc) {
+ if (window.ActiveXObject) {
+ doc = new ActiveXObject('Microsoft.XMLDOM');
+ doc.async = 'false';
+ doc.loadXML(s);
+ }
+ else {
+ doc = (new DOMParser()).parseFromString(s, 'text/xml');
+ }
+ return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
+ }
+ }
+};
+
+/**
+ * ajaxForm() provides a mechanism for fully automating form submission.
+ *
+ * The advantages of using this method instead of ajaxSubmit() are:
+ *
+ * 1: This method will include coordinates for elements (if the element
+ * is used to submit the form).
+ * 2. This method will include the submit element's name/value data (for the element that was
+ * used to submit the form).
+ * 3. This method binds the submit() method to the form for you.
+ *
+ * The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
+ * passes the options argument along after properly binding events for submit elements and
+ * the form itself.
+ */
+$.fn.ajaxForm = function(options) {
+ // in jQuery 1.3+ we can fix mistakes with the ready state
+ if (this.length === 0) {
+ var o = { s: this.selector, c: this.context };
+ if (!$.isReady && o.s) {
+ log('DOM not ready, queuing ajaxForm');
+ $(function() {
+ $(o.s,o.c).ajaxForm(options);
+ });
+ return this;
+ }
+ // is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
+ log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
+ return this;
+ }
+
+ return this.ajaxFormUnbind().bind('submit.form-plugin', function(e) {
+ if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
+ e.preventDefault();
+ $(this).ajaxSubmit(options);
+ }
+ }).bind('click.form-plugin', function(e) {
+ var target = e.target;
+ var $el = $(target);
+ if (!($el.is(":submit,input:image"))) {
+ // is this a child element of the submit el? (ex: a span within a button)
+ var t = $el.closest(':submit');
+ if (t.length == 0) {
+ return;
+ }
+ target = t[0];
+ }
+ var form = this;
+ form.clk = target;
+ if (target.type == 'image') {
+ if (e.offsetX != undefined) {
+ form.clk_x = e.offsetX;
+ form.clk_y = e.offsetY;
+ } else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
+ var offset = $el.offset();
+ form.clk_x = e.pageX - offset.left;
+ form.clk_y = e.pageY - offset.top;
+ } else {
+ form.clk_x = e.pageX - target.offsetLeft;
+ form.clk_y = e.pageY - target.offsetTop;
+ }
+ }
+ // clear form vars
+ setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100);
+ });
+};
+
+// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
+$.fn.ajaxFormUnbind = function() {
+ return this.unbind('submit.form-plugin click.form-plugin');
+};
+
+/**
+ * formToArray() gathers form element data into an array of objects that can
+ * be passed to any of the following ajax functions: $.get, $.post, or load.
+ * Each object in the array has both a 'name' and 'value' property. An example of
+ * an array for a simple login form might be:
+ *
+ * [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
+ *
+ * It is this array that is passed to pre-submit callback functions provided to the
+ * ajaxSubmit() and ajaxForm() methods.
+ */
+$.fn.formToArray = function(semantic) {
+ var a = [];
+ if (this.length === 0) {
+ return a;
+ }
+
+ var form = this[0];
+ var els = semantic ? form.getElementsByTagName('*') : form.elements;
+ if (!els) {
+ return a;
+ }
+
+ var i,j,n,v,el,max,jmax;
+ for(i=0, max=els.length; i < max; i++) {
+ el = els[i];
+ n = el.name;
+ if (!n) {
+ continue;
+ }
+
+ if (semantic && form.clk && el.type == "image") {
+ // handle image inputs on the fly when semantic == true
+ if(!el.disabled && form.clk == el) {
+ a.push({name: n, value: $(el).val()});
+ a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
+ }
+ continue;
+ }
+
+ v = $.fieldValue(el, true);
+ if (v && v.constructor == Array) {
+ for(j=0, jmax=v.length; j < jmax; j++) {
+ a.push({name: n, value: v[j]});
+ }
+ }
+ else if (v !== null && typeof v != 'undefined') {
+ a.push({name: n, value: v});
+ }
+ }
+
+ if (!semantic && form.clk) {
+ // input type=='image' are not found in elements array! handle it here
+ var $input = $(form.clk), input = $input[0];
+ n = input.name;
+ if (n && !input.disabled && input.type == 'image') {
+ a.push({name: n, value: $input.val()});
+ a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
+ }
+ }
+ return a;
+};
+
+/**
+ * Serializes form data into a 'submittable' string. This method will return a string
+ * in the format: name1=value1&name2=value2
+ */
+$.fn.formSerialize = function(semantic) {
+ //hand off to jQuery.param for proper encoding
+ return $.param(this.formToArray(semantic));
+};
+
+/**
+ * Serializes all field elements in the jQuery object into a query string.
+ * This method will return a string in the format: name1=value1&name2=value2
+ */
+$.fn.fieldSerialize = function(successful) {
+ var a = [];
+ this.each(function() {
+ var n = this.name;
+ if (!n) {
+ return;
+ }
+ var v = $.fieldValue(this, successful);
+ if (v && v.constructor == Array) {
+ for (var i=0,max=v.length; i < max; i++) {
+ a.push({name: n, value: v[i]});
+ }
+ }
+ else if (v !== null && typeof v != 'undefined') {
+ a.push({name: this.name, value: v});
+ }
+ });
+ //hand off to jQuery.param for proper encoding
+ return $.param(a);
+};
+
+/**
+ * Returns the value(s) of the element in the matched set. For example, consider the following form:
+ *
+ *
+ *
+ * var v = $(':text').fieldValue();
+ * // if no values are entered into the text inputs
+ * v == ['','']
+ * // if values entered into the text inputs are 'foo' and 'bar'
+ * v == ['foo','bar']
+ *
+ * var v = $(':checkbox').fieldValue();
+ * // if neither checkbox is checked
+ * v === undefined
+ * // if both checkboxes are checked
+ * v == ['B1', 'B2']
+ *
+ * var v = $(':radio').fieldValue();
+ * // if neither radio is checked
+ * v === undefined
+ * // if first radio is checked
+ * v == ['C1']
+ *
+ * The successful argument controls whether or not the field element must be 'successful'
+ * (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
+ * The default value of the successful argument is true. If this value is false the value(s)
+ * for each element is returned.
+ *
+ * Note: This method *always* returns an array. If no valid value can be determined the
+ * array will be empty, otherwise it will contain one or more values.
+ */
+$.fn.fieldValue = function(successful) {
+ for (var val=[], i=0, max=this.length; i < max; i++) {
+ var el = this[i];
+ var v = $.fieldValue(el, successful);
+ if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
+ continue;
+ }
+ v.constructor == Array ? $.merge(val, v) : val.push(v);
+ }
+ return val;
+};
+
+/**
+ * Returns the value of the field element.
+ */
+$.fieldValue = function(el, successful) {
+ var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
+ if (successful === undefined) {
+ successful = true;
+ }
+
+ if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
+ (t == 'checkbox' || t == 'radio') && !el.checked ||
+ (t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
+ tag == 'select' && el.selectedIndex == -1)) {
+ return null;
+ }
+
+ if (tag == 'select') {
+ var index = el.selectedIndex;
+ if (index < 0) {
+ return null;
+ }
+ var a = [], ops = el.options;
+ var one = (t == 'select-one');
+ var max = (one ? index+1 : ops.length);
+ for(var i=(one ? index : 0); i < max; i++) {
+ var op = ops[i];
+ if (op.selected) {
+ var v = op.value;
+ if (!v) { // extra pain for IE...
+ v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
+ }
+ if (one) {
+ return v;
+ }
+ a.push(v);
+ }
+ }
+ return a;
+ }
+ return $(el).val();
+};
+
+/**
+ * Clears the form data. Takes the following actions on the form's input fields:
+ * - input text fields will have their 'value' property set to the empty string
+ * - select elements will have their 'selectedIndex' property set to -1
+ * - checkbox and radio inputs will have their 'checked' property set to false
+ * - inputs of type submit, button, reset, and hidden will *not* be effected
+ * - button elements will *not* be effected
+ */
+$.fn.clearForm = function() {
+ return this.each(function() {
+ $('input,select,textarea', this).clearFields();
+ });
+};
+
+/**
+ * Clears the selected form elements.
+ */
+$.fn.clearFields = $.fn.clearInputs = function() {
+ return this.each(function() {
+ var t = this.type, tag = this.tagName.toLowerCase();
+ if (t == 'text' || t == 'password' || tag == 'textarea') {
+ this.value = '';
+ }
+ else if (t == 'checkbox' || t == 'radio') {
+ this.checked = false;
+ }
+ else if (tag == 'select') {
+ this.selectedIndex = -1;
+ }
+ });
+};
+
+/**
+ * Resets the form data. Causes all form elements to be reset to their original value.
+ */
+$.fn.resetForm = function() {
+ return this.each(function() {
+ // guard against an input with the name of 'reset'
+ // note that IE reports the reset function as an 'object'
+ if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
+ this.reset();
+ }
+ });
+};
+
+/**
+ * Enables or disables any matching elements.
+ */
+$.fn.enable = function(b) {
+ if (b === undefined) {
+ b = true;
+ }
+ return this.each(function() {
+ this.disabled = !b;
+ });
+};
+
+/**
+ * Checks/unchecks any matching checkboxes or radio buttons and
+ * selects/deselects and matching option elements.
+ */
+$.fn.selected = function(select) {
+ if (select === undefined) {
+ select = true;
+ }
+ return this.each(function() {
+ var t = this.type;
+ if (t == 'checkbox' || t == 'radio') {
+ this.checked = select;
+ }
+ else if (this.tagName.toLowerCase() == 'option') {
+ var $sel = $(this).parent('select');
+ if (select && $sel[0] && $sel[0].type == 'select-one') {
+ // deselect all other options
+ $sel.find('option').selected(false);
+ }
+ this.selected = select;
+ }
+ });
+};
+
+// helper fn for console logging
+// set $.fn.ajaxSubmit.debug to true to enable debug logging
+function log() {
+ if ($.fn.ajaxSubmit.debug) {
+ var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
+ if (window.console && window.console.log) {
+ window.console.log(msg);
+ }
+ else if (window.opera && window.opera.postError) {
+ window.opera.postError(msg);
+ }
+ }
+};
+
+})(jQuery);
diff --git a/sources/extend/addon/matrix/jappixmini/jappix/js/jquery.js b/sources/extend/addon/matrix/jappixmini/jappix/js/jquery.js
new file mode 100644
index 00000000..a4f11458
--- /dev/null
+++ b/sources/extend/addon/matrix/jappixmini/jappix/js/jquery.js
@@ -0,0 +1,7179 @@
+/*!
+ * jQuery JavaScript Library v1.4.4
+ * http://jquery.com/
+ *
+ * Copyright 2010, John Resig
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * Includes Sizzle.js
+ * http://sizzlejs.com/
+ * Copyright 2010, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ *
+ * Date: Thu Nov 11 19:04:53 2010 -0500
+ */
+(function( window, undefined ) {
+
+// Use the correct document accordingly with window argument (sandbox)
+var document = window.document;
+var jQuery = (function() {
+
+// Define a local copy of jQuery
+var jQuery = function( selector, context ) {
+ // The jQuery object is actually just the init constructor 'enhanced'
+ return new jQuery.fn.init( selector, context );
+ },
+
+ // Map over jQuery in case of overwrite
+ _jQuery = window.jQuery,
+
+ // Map over the $ in case of overwrite
+ _$ = window.$,
+
+ // A central reference to the root jQuery(document)
+ rootjQuery,
+
+ // A simple way to check for HTML strings or ID strings
+ // (both of which we optimize for)
+ quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,
+
+ // Is it a simple selector
+ isSimple = /^.[^:#\[\.,]*$/,
+
+ // Check if a string has a non-whitespace character in it
+ rnotwhite = /\S/,
+ rwhite = /\s/,
+
+ // Used for trimming whitespace
+ trimLeft = /^\s+/,
+ trimRight = /\s+$/,
+
+ // Check for non-word characters
+ rnonword = /\W/,
+
+ // Check for digits
+ rdigit = /\d/,
+
+ // Match a standalone tag
+ rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
+
+ // JSON RegExp
+ rvalidchars = /^[\],:{}\s]*$/,
+ rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
+ rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
+ rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
+
+ // Useragent RegExp
+ rwebkit = /(webkit)[ \/]([\w.]+)/,
+ ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
+ rmsie = /(msie) ([\w.]+)/,
+ rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
+
+ // Keep a UserAgent string for use with jQuery.browser
+ userAgent = navigator.userAgent,
+
+ // For matching the engine and version of the browser
+ browserMatch,
+
+ // Has the ready events already been bound?
+ readyBound = false,
+
+ // The functions to execute on DOM ready
+ readyList = [],
+
+ // The ready event handler
+ DOMContentLoaded,
+
+ // Save a reference to some core methods
+ toString = Object.prototype.toString,
+ hasOwn = Object.prototype.hasOwnProperty,
+ push = Array.prototype.push,
+ slice = Array.prototype.slice,
+ trim = String.prototype.trim,
+ indexOf = Array.prototype.indexOf,
+
+ // [[Class]] -> type pairs
+ class2type = {};
+
+jQuery.fn = jQuery.prototype = {
+ init: function( selector, context ) {
+ var match, elem, ret, doc;
+
+ // Handle $(""), $(null), or $(undefined)
+ if ( !selector ) {
+ return this;
+ }
+
+ // Handle $(DOMElement)
+ if ( selector.nodeType ) {
+ this.context = this[0] = selector;
+ this.length = 1;
+ return this;
+ }
+
+ // The body element only exists once, optimize finding it
+ if ( selector === "body" && !context && document.body ) {
+ this.context = document;
+ this[0] = document.body;
+ this.selector = "body";
+ this.length = 1;
+ return this;
+ }
+
+ // Handle HTML strings
+ if ( typeof selector === "string" ) {
+ // Are we dealing with HTML string or an ID?
+ match = quickExpr.exec( selector );
+
+ // Verify a match, and that no context was specified for #id
+ if ( match && (match[1] || !context) ) {
+
+ // HANDLE: $(html) -> $(array)
+ if ( match[1] ) {
+ doc = (context ? context.ownerDocument || context : document);
+
+ // If a single string is passed in and it's a single tag
+ // just do a createElement and skip the rest
+ ret = rsingleTag.exec( selector );
+
+ if ( ret ) {
+ if ( jQuery.isPlainObject( context ) ) {
+ selector = [ document.createElement( ret[1] ) ];
+ jQuery.fn.attr.call( selector, context, true );
+
+ } else {
+ selector = [ doc.createElement( ret[1] ) ];
+ }
+
+ } else {
+ ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
+ selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
+ }
+
+ return jQuery.merge( this, selector );
+
+ // HANDLE: $("#id")
+ } else {
+ elem = document.getElementById( match[2] );
+
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ if ( elem && elem.parentNode ) {
+ // Handle the case where IE and Opera return items
+ // by name instead of ID
+ if ( elem.id !== match[2] ) {
+ return rootjQuery.find( selector );
+ }
+
+ // Otherwise, we inject the element directly into the jQuery object
+ this.length = 1;
+ this[0] = elem;
+ }
+
+ this.context = document;
+ this.selector = selector;
+ return this;
+ }
+
+ // HANDLE: $("TAG")
+ } else if ( !context && !rnonword.test( selector ) ) {
+ this.selector = selector;
+ this.context = document;
+ selector = document.getElementsByTagName( selector );
+ return jQuery.merge( this, selector );
+
+ // HANDLE: $(expr, $(...))
+ } else if ( !context || context.jquery ) {
+ return (context || rootjQuery).find( selector );
+
+ // HANDLE: $(expr, context)
+ // (which is just equivalent to: $(context).find(expr)
+ } else {
+ return jQuery( context ).find( selector );
+ }
+
+ // HANDLE: $(function)
+ // Shortcut for document ready
+ } else if ( jQuery.isFunction( selector ) ) {
+ return rootjQuery.ready( selector );
+ }
+
+ if (selector.selector !== undefined) {
+ this.selector = selector.selector;
+ this.context = selector.context;
+ }
+
+ return jQuery.makeArray( selector, this );
+ },
+
+ // Start with an empty selector
+ selector: "",
+
+ // The current version of jQuery being used
+ jquery: "1.4.4",
+
+ // The default length of a jQuery object is 0
+ length: 0,
+
+ // The number of elements contained in the matched element set
+ size: function() {
+ return this.length;
+ },
+
+ toArray: function() {
+ return slice.call( this, 0 );
+ },
+
+ // Get the Nth element in the matched element set OR
+ // Get the whole matched element set as a clean array
+ get: function( num ) {
+ return num == null ?
+
+ // Return a 'clean' array
+ this.toArray() :
+
+ // Return just the object
+ ( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
+ },
+
+ // Take an array of elements and push it onto the stack
+ // (returning the new matched element set)
+ pushStack: function( elems, name, selector ) {
+ // Build a new jQuery matched element set
+ var ret = jQuery();
+
+ if ( jQuery.isArray( elems ) ) {
+ push.apply( ret, elems );
+
+ } else {
+ jQuery.merge( ret, elems );
+ }
+
+ // Add the old object onto the stack (as a reference)
+ ret.prevObject = this;
+
+ ret.context = this.context;
+
+ if ( name === "find" ) {
+ ret.selector = this.selector + (this.selector ? " " : "") + selector;
+ } else if ( name ) {
+ ret.selector = this.selector + "." + name + "(" + selector + ")";
+ }
+
+ // Return the newly-formed element set
+ return ret;
+ },
+
+ // Execute a callback for every element in the matched set.
+ // (You can seed the arguments with an array of args, but this is
+ // only used internally.)
+ each: function( callback, args ) {
+ return jQuery.each( this, callback, args );
+ },
+
+ ready: function( fn ) {
+ // Attach the listeners
+ jQuery.bindReady();
+
+ // If the DOM is already ready
+ if ( jQuery.isReady ) {
+ // Execute the function immediately
+ fn.call( document, jQuery );
+
+ // Otherwise, remember the function for later
+ } else if ( readyList ) {
+ // Add the function to the wait list
+ readyList.push( fn );
+ }
+
+ return this;
+ },
+
+ eq: function( i ) {
+ return i === -1 ?
+ this.slice( i ) :
+ this.slice( i, +i + 1 );
+ },
+
+ first: function() {
+ return this.eq( 0 );
+ },
+
+ last: function() {
+ return this.eq( -1 );
+ },
+
+ slice: function() {
+ return this.pushStack( slice.apply( this, arguments ),
+ "slice", slice.call(arguments).join(",") );
+ },
+
+ map: function( callback ) {
+ return this.pushStack( jQuery.map(this, function( elem, i ) {
+ return callback.call( elem, i, elem );
+ }));
+ },
+
+ end: function() {
+ return this.prevObject || jQuery(null);
+ },
+
+ // For internal use only.
+ // Behaves like an Array's method, not like a jQuery method.
+ push: push,
+ sort: [].sort,
+ splice: [].splice
+};
+
+// Give the init function the jQuery prototype for later instantiation
+jQuery.fn.init.prototype = jQuery.fn;
+
+jQuery.extend = jQuery.fn.extend = function() {
+ var options, name, src, copy, copyIsArray, clone,
+ target = arguments[0] || {},
+ i = 1,
+ length = arguments.length,
+ deep = false;
+
+ // Handle a deep copy situation
+ if ( typeof target === "boolean" ) {
+ deep = target;
+ target = arguments[1] || {};
+ // skip the boolean and the target
+ i = 2;
+ }
+
+ // Handle case when target is a string or something (possible in deep copy)
+ if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
+ target = {};
+ }
+
+ // extend jQuery itself if only one argument is passed
+ if ( length === i ) {
+ target = this;
+ --i;
+ }
+
+ for ( ; i < length; i++ ) {
+ // Only deal with non-null/undefined values
+ if ( (options = arguments[ i ]) != null ) {
+ // Extend the base object
+ for ( name in options ) {
+ src = target[ name ];
+ copy = options[ name ];
+
+ // Prevent never-ending loop
+ if ( target === copy ) {
+ continue;
+ }
+
+ // Recurse if we're merging plain objects or arrays
+ if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
+ if ( copyIsArray ) {
+ copyIsArray = false;
+ clone = src && jQuery.isArray(src) ? src : [];
+
+ } else {
+ clone = src && jQuery.isPlainObject(src) ? src : {};
+ }
+
+ // Never move original objects, clone them
+ target[ name ] = jQuery.extend( deep, clone, copy );
+
+ // Don't bring in undefined values
+ } else if ( copy !== undefined ) {
+ target[ name ] = copy;
+ }
+ }
+ }
+ }
+
+ // Return the modified object
+ return target;
+};
+
+jQuery.extend({
+ noConflict: function( deep ) {
+ window.$ = _$;
+
+ if ( deep ) {
+ window.jQuery = _jQuery;
+ }
+
+ return jQuery;
+ },
+
+ // Is the DOM ready to be used? Set to true once it occurs.
+ isReady: false,
+
+ // A counter to track how many items to wait for before
+ // the ready event fires. See #6781
+ readyWait: 1,
+
+ // Handle when the DOM is ready
+ ready: function( wait ) {
+ // A third-party is pushing the ready event forwards
+ if ( wait === true ) {
+ jQuery.readyWait--;
+ }
+
+ // Make sure that the DOM is not already loaded
+ if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( !document.body ) {
+ return setTimeout( jQuery.ready, 1 );
+ }
+
+ // Remember that the DOM is ready
+ jQuery.isReady = true;
+
+ // If a normal DOM Ready event fired, decrement, and wait if need be
+ if ( wait !== true && --jQuery.readyWait > 0 ) {
+ return;
+ }
+
+ // If there are functions bound, to execute
+ if ( readyList ) {
+ // Execute all of them
+ var fn,
+ i = 0,
+ ready = readyList;
+
+ // Reset the list of functions
+ readyList = null;
+
+ while ( (fn = ready[ i++ ]) ) {
+ fn.call( document, jQuery );
+ }
+
+ // Trigger any bound ready events
+ if ( jQuery.fn.trigger ) {
+ jQuery( document ).trigger( "ready" ).unbind( "ready" );
+ }
+ }
+ }
+ },
+
+ bindReady: function() {
+ if ( readyBound ) {
+ return;
+ }
+
+ readyBound = true;
+
+ // Catch cases where $(document).ready() is called after the
+ // browser event has already occurred.
+ if ( document.readyState === "complete" ) {
+ // Handle it asynchronously to allow scripts the opportunity to delay ready
+ return setTimeout( jQuery.ready, 1 );
+ }
+
+ // Mozilla, Opera and webkit nightlies currently support this event
+ if ( document.addEventListener ) {
+ // Use the handy event callback
+ document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+
+ // A fallback to window.onload, that will always work
+ window.addEventListener( "load", jQuery.ready, false );
+
+ // If IE event model is used
+ } else if ( document.attachEvent ) {
+ // ensure firing before onload,
+ // maybe late but safe also for iframes
+ document.attachEvent("onreadystatechange", DOMContentLoaded);
+
+ // A fallback to window.onload, that will always work
+ window.attachEvent( "onload", jQuery.ready );
+
+ // If IE and not a frame
+ // continually check to see if the document is ready
+ var toplevel = false;
+
+ try {
+ toplevel = window.frameElement == null;
+ } catch(e) {}
+
+ if ( document.documentElement.doScroll && toplevel ) {
+ doScrollCheck();
+ }
+ }
+ },
+
+ // See test/unit/core.js for details concerning isFunction.
+ // Since version 1.3, DOM methods and functions like alert
+ // aren't supported. They return false on IE (#2968).
+ isFunction: function( obj ) {
+ return jQuery.type(obj) === "function";
+ },
+
+ isArray: Array.isArray || function( obj ) {
+ return jQuery.type(obj) === "array";
+ },
+
+ // A crude way of determining if an object is a window
+ isWindow: function( obj ) {
+ return obj && typeof obj === "object" && "setInterval" in obj;
+ },
+
+ isNaN: function( obj ) {
+ return obj == null || !rdigit.test( obj ) || isNaN( obj );
+ },
+
+ type: function( obj ) {
+ return obj == null ?
+ String( obj ) :
+ class2type[ toString.call(obj) ] || "object";
+ },
+
+ isPlainObject: function( obj ) {
+ // Must be an Object.
+ // Because of IE, we also have to check the presence of the constructor property.
+ // Make sure that DOM nodes and window objects don't pass through, as well
+ if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
+ return false;
+ }
+
+ // Not own constructor property must be Object
+ if ( obj.constructor &&
+ !hasOwn.call(obj, "constructor") &&
+ !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
+ return false;
+ }
+
+ // Own properties are enumerated firstly, so to speed up,
+ // if last one is own, then all properties are own.
+
+ var key;
+ for ( key in obj ) {}
+
+ return key === undefined || hasOwn.call( obj, key );
+ },
+
+ isEmptyObject: function( obj ) {
+ for ( var name in obj ) {
+ return false;
+ }
+ return true;
+ },
+
+ error: function( msg ) {
+ throw msg;
+ },
+
+ parseJSON: function( data ) {
+ if ( typeof data !== "string" || !data ) {
+ return null;
+ }
+
+ // Make sure leading/trailing whitespace is removed (IE can't handle it)
+ data = jQuery.trim( data );
+
+ // Make sure the incoming data is actual JSON
+ // Logic borrowed from http://json.org/json2.js
+ if ( rvalidchars.test(data.replace(rvalidescape, "@")
+ .replace(rvalidtokens, "]")
+ .replace(rvalidbraces, "")) ) {
+
+ // Try to use the native JSON parser first
+ return window.JSON && window.JSON.parse ?
+ window.JSON.parse( data ) :
+ (new Function("return " + data))();
+
+ } else {
+ jQuery.error( "Invalid JSON: " + data );
+ }
+ },
+
+ noop: function() {},
+
+ // Evalulates a script in a global context
+ globalEval: function( data ) {
+ if ( data && rnotwhite.test(data) ) {
+ // Inspired by code by Andrea Giammarchi
+ // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
+ var head = document.getElementsByTagName("head")[0] || document.documentElement,
+ script = document.createElement("script");
+
+ script.type = "text/javascript";
+
+ if ( jQuery.support.scriptEval ) {
+ script.appendChild( document.createTextNode( data ) );
+ } else {
+ script.text = data;
+ }
+
+ // Use insertBefore instead of appendChild to circumvent an IE6 bug.
+ // This arises when a base node is used (#2709).
+ head.insertBefore( script, head.firstChild );
+ head.removeChild( script );
+ }
+ },
+
+ nodeName: function( elem, name ) {
+ return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
+ },
+
+ // args is for internal usage only
+ each: function( object, callback, args ) {
+ var name, i = 0,
+ length = object.length,
+ isObj = length === undefined || jQuery.isFunction(object);
+
+ if ( args ) {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.apply( object[ name ], args ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( ; i < length; ) {
+ if ( callback.apply( object[ i++ ], args ) === false ) {
+ break;
+ }
+ }
+ }
+
+ // A special, fast, case for the most common use of each
+ } else {
+ if ( isObj ) {
+ for ( name in object ) {
+ if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
+ break;
+ }
+ }
+ } else {
+ for ( var value = object[0];
+ i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
+ }
+ }
+
+ return object;
+ },
+
+ // Use native String.trim function wherever possible
+ trim: trim ?
+ function( text ) {
+ return text == null ?
+ "" :
+ trim.call( text );
+ } :
+
+ // Otherwise use our own trimming functionality
+ function( text ) {
+ return text == null ?
+ "" :
+ text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
+ },
+
+ // results is for internal usage only
+ makeArray: function( array, results ) {
+ var ret = results || [];
+
+ if ( array != null ) {
+ // The window, strings (and functions) also have 'length'
+ // The extra typeof function check is to prevent crashes
+ // in Safari 2 (See: #3039)
+ // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
+ var type = jQuery.type(array);
+
+ if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
+ push.call( ret, array );
+ } else {
+ jQuery.merge( ret, array );
+ }
+ }
+
+ return ret;
+ },
+
+ inArray: function( elem, array ) {
+ if ( array.indexOf ) {
+ return array.indexOf( elem );
+ }
+
+ for ( var i = 0, length = array.length; i < length; i++ ) {
+ if ( array[ i ] === elem ) {
+ return i;
+ }
+ }
+
+ return -1;
+ },
+
+ merge: function( first, second ) {
+ var i = first.length,
+ j = 0;
+
+ if ( typeof second.length === "number" ) {
+ for ( var l = second.length; j < l; j++ ) {
+ first[ i++ ] = second[ j ];
+ }
+
+ } else {
+ while ( second[j] !== undefined ) {
+ first[ i++ ] = second[ j++ ];
+ }
+ }
+
+ first.length = i;
+
+ return first;
+ },
+
+ grep: function( elems, callback, inv ) {
+ var ret = [], retVal;
+ inv = !!inv;
+
+ // Go through the array, only saving the items
+ // that pass the validator function
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ retVal = !!callback( elems[ i ], i );
+ if ( inv !== retVal ) {
+ ret.push( elems[ i ] );
+ }
+ }
+
+ return ret;
+ },
+
+ // arg is for internal usage only
+ map: function( elems, callback, arg ) {
+ var ret = [], value;
+
+ // Go through the array, translating each of the items to their
+ // new value (or values).
+ for ( var i = 0, length = elems.length; i < length; i++ ) {
+ value = callback( elems[ i ], i, arg );
+
+ if ( value != null ) {
+ ret[ ret.length ] = value;
+ }
+ }
+
+ return ret.concat.apply( [], ret );
+ },
+
+ // A global GUID counter for objects
+ guid: 1,
+
+ proxy: function( fn, proxy, thisObject ) {
+ if ( arguments.length === 2 ) {
+ if ( typeof proxy === "string" ) {
+ thisObject = fn;
+ fn = thisObject[ proxy ];
+ proxy = undefined;
+
+ } else if ( proxy && !jQuery.isFunction( proxy ) ) {
+ thisObject = proxy;
+ proxy = undefined;
+ }
+ }
+
+ if ( !proxy && fn ) {
+ proxy = function() {
+ return fn.apply( thisObject || this, arguments );
+ };
+ }
+
+ // Set the guid of unique handler to the same of original handler, so it can be removed
+ if ( fn ) {
+ proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
+ }
+
+ // So proxy can be declared as an argument
+ return proxy;
+ },
+
+ // Mutifunctional method to get and set values to a collection
+ // The value/s can be optionally by executed if its a function
+ access: function( elems, key, value, exec, fn, pass ) {
+ var length = elems.length;
+
+ // Setting many attributes
+ if ( typeof key === "object" ) {
+ for ( var k in key ) {
+ jQuery.access( elems, k, key[k], exec, fn, value );
+ }
+ return elems;
+ }
+
+ // Setting one attribute
+ if ( value !== undefined ) {
+ // Optionally, function values get executed if exec is true
+ exec = !pass && exec && jQuery.isFunction(value);
+
+ for ( var i = 0; i < length; i++ ) {
+ fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
+ }
+
+ return elems;
+ }
+
+ // Getting an attribute
+ return length ? fn( elems[0], key ) : undefined;
+ },
+
+ now: function() {
+ return (new Date()).getTime();
+ },
+
+ // Use of jQuery.browser is frowned upon.
+ // More details: http://docs.jquery.com/Utilities/jQuery.browser
+ uaMatch: function( ua ) {
+ ua = ua.toLowerCase();
+
+ var match = rwebkit.exec( ua ) ||
+ ropera.exec( ua ) ||
+ rmsie.exec( ua ) ||
+ ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
+ [];
+
+ return { browser: match[1] || "", version: match[2] || "0" };
+ },
+
+ browser: {}
+});
+
+// Populate the class2type map
+jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
+ class2type[ "[object " + name + "]" ] = name.toLowerCase();
+});
+
+browserMatch = jQuery.uaMatch( userAgent );
+if ( browserMatch.browser ) {
+ jQuery.browser[ browserMatch.browser ] = true;
+ jQuery.browser.version = browserMatch.version;
+}
+
+// Deprecated, use jQuery.browser.webkit instead
+if ( jQuery.browser.webkit ) {
+ jQuery.browser.safari = true;
+}
+
+if ( indexOf ) {
+ jQuery.inArray = function( elem, array ) {
+ return indexOf.call( array, elem );
+ };
+}
+
+// Verify that \s matches non-breaking spaces
+// (IE fails on this test)
+if ( !rwhite.test( "\xA0" ) ) {
+ trimLeft = /^[\s\xA0]+/;
+ trimRight = /[\s\xA0]+$/;
+}
+
+// All jQuery objects should point back to these
+rootjQuery = jQuery(document);
+
+// Cleanup functions for the document ready method
+if ( document.addEventListener ) {
+ DOMContentLoaded = function() {
+ document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
+ jQuery.ready();
+ };
+
+} else if ( document.attachEvent ) {
+ DOMContentLoaded = function() {
+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
+ if ( document.readyState === "complete" ) {
+ document.detachEvent( "onreadystatechange", DOMContentLoaded );
+ jQuery.ready();
+ }
+ };
+}
+
+// The DOM ready check for Internet Explorer
+function doScrollCheck() {
+ if ( jQuery.isReady ) {
+ return;
+ }
+
+ try {
+ // If IE is used, use the trick by Diego Perini
+ // http://javascript.nwbox.com/IEContentLoaded/
+ document.documentElement.doScroll("left");
+ } catch(e) {
+ setTimeout( doScrollCheck, 1 );
+ return;
+ }
+
+ // and execute any waiting functions
+ jQuery.ready();
+}
+
+// Expose jQuery to the global object
+return (window.jQuery = window.$ = jQuery);
+
+})();
+
+
+(function() {
+
+ jQuery.support = {};
+
+ var root = document.documentElement,
+ script = document.createElement("script"),
+ div = document.createElement("div"),
+ id = "script" + jQuery.now();
+
+ div.style.display = "none";
+ div.innerHTML = "
a";
+
+ var all = div.getElementsByTagName("*"),
+ a = div.getElementsByTagName("a")[0],
+ select = document.createElement("select"),
+ opt = select.appendChild( document.createElement("option") );
+
+ // Can't get basic test support
+ if ( !all || !all.length || !a ) {
+ return;
+ }
+
+ jQuery.support = {
+ // IE strips leading whitespace when .innerHTML is used
+ leadingWhitespace: div.firstChild.nodeType === 3,
+
+ // Make sure that tbody elements aren't automatically inserted
+ // IE will insert them into empty tables
+ tbody: !div.getElementsByTagName("tbody").length,
+
+ // Make sure that link elements get serialized correctly by innerHTML
+ // This requires a wrapper element in IE
+ htmlSerialize: !!div.getElementsByTagName("link").length,
+
+ // Get the style information from getAttribute
+ // (IE uses .cssText insted)
+ style: /red/.test( a.getAttribute("style") ),
+
+ // Make sure that URLs aren't manipulated
+ // (IE normalizes it by default)
+ hrefNormalized: a.getAttribute("href") === "/a",
+
+ // Make sure that element opacity exists
+ // (IE uses filter instead)
+ // Use a regex to work around a WebKit issue. See #5145
+ opacity: /^0.55$/.test( a.style.opacity ),
+
+ // Verify style float existence
+ // (IE uses styleFloat instead of cssFloat)
+ cssFloat: !!a.style.cssFloat,
+
+ // Make sure that if no value is specified for a checkbox
+ // that it defaults to "on".
+ // (WebKit defaults to "" instead)
+ checkOn: div.getElementsByTagName("input")[0].value === "on",
+
+ // Make sure that a selected-by-default option has a working selected property.
+ // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
+ optSelected: opt.selected,
+
+ // Will be defined later
+ deleteExpando: true,
+ optDisabled: false,
+ checkClone: false,
+ scriptEval: false,
+ noCloneEvent: true,
+ boxModel: null,
+ inlineBlockNeedsLayout: false,
+ shrinkWrapBlocks: false,
+ reliableHiddenOffsets: true
+ };
+
+ // Make sure that the options inside disabled selects aren't marked as disabled
+ // (WebKit marks them as diabled)
+ select.disabled = true;
+ jQuery.support.optDisabled = !opt.disabled;
+
+ script.type = "text/javascript";
+ try {
+ script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
+ } catch(e) {}
+
+ root.insertBefore( script, root.firstChild );
+
+ // Make sure that the execution of code works by injecting a script
+ // tag with appendChild/createTextNode
+ // (IE doesn't support this, fails, and uses .text instead)
+ if ( window[ id ] ) {
+ jQuery.support.scriptEval = true;
+ delete window[ id ];
+ }
+
+ // Test to see if it's possible to delete an expando from an element
+ // Fails in Internet Explorer
+ try {
+ delete script.test;
+
+ } catch(e) {
+ jQuery.support.deleteExpando = false;
+ }
+
+ root.removeChild( script );
+
+ if ( div.attachEvent && div.fireEvent ) {
+ div.attachEvent("onclick", function click() {
+ // Cloning a node shouldn't copy over any
+ // bound event handlers (IE does this)
+ jQuery.support.noCloneEvent = false;
+ div.detachEvent("onclick", click);
+ });
+ div.cloneNode(true).fireEvent("onclick");
+ }
+
+ div = document.createElement("div");
+ div.innerHTML = "";
+
+ var fragment = document.createDocumentFragment();
+ fragment.appendChild( div.firstChild );
+
+ // WebKit doesn't clone checked state correctly in fragments
+ jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
+
+ // Figure out if the W3C box model works as expected
+ // document.body must exist before we can do this
+ jQuery(function() {
+ var div = document.createElement("div");
+ div.style.width = div.style.paddingLeft = "1px";
+
+ document.body.appendChild( div );
+ jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
+
+ if ( "zoom" in div.style ) {
+ // Check if natively block-level elements act like inline-block
+ // elements when setting their display to 'inline' and giving
+ // them layout
+ // (IE < 8 does this)
+ div.style.display = "inline";
+ div.style.zoom = 1;
+ jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2;
+
+ // Check if elements with layout shrink-wrap their children
+ // (IE 6 does this)
+ div.style.display = "";
+ div.innerHTML = "";
+ jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2;
+ }
+
+ div.innerHTML = "
t
";
+ var tds = div.getElementsByTagName("td");
+
+ // Check if table cells still have offsetWidth/Height when they are set
+ // to display:none and there are still other visible table cells in a
+ // table row; if so, offsetWidth/Height are not reliable for use when
+ // determining if an element has been hidden directly using
+ // display:none (it is still safe to use offsets if a parent element is
+ // hidden; don safety goggles and see bug #4512 for more information).
+ // (only IE 8 fails this test)
+ jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0;
+
+ tds[0].style.display = "";
+ tds[1].style.display = "none";
+
+ // Check if empty table cells still have offsetWidth/Height
+ // (IE < 8 fail this test)
+ jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
+ div.innerHTML = "";
+
+ document.body.removeChild( div ).style.display = "none";
+ div = tds = null;
+ });
+
+ // Technique from Juriy Zaytsev
+ // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
+ var eventSupported = function( eventName ) {
+ var el = document.createElement("div");
+ eventName = "on" + eventName;
+
+ var isSupported = (eventName in el);
+ if ( !isSupported ) {
+ el.setAttribute(eventName, "return;");
+ isSupported = typeof el[eventName] === "function";
+ }
+ el = null;
+
+ return isSupported;
+ };
+
+ jQuery.support.submitBubbles = eventSupported("submit");
+ jQuery.support.changeBubbles = eventSupported("change");
+
+ // release memory in IE
+ root = script = div = all = a = null;
+})();
+
+
+
+var windowData = {},
+ rbrace = /^(?:\{.*\}|\[.*\])$/;
+
+jQuery.extend({
+ cache: {},
+
+ // Please use with caution
+ uuid: 0,
+
+ // Unique for each copy of jQuery on the page
+ expando: "jQuery" + jQuery.now(),
+
+ // The following elements throw uncatchable exceptions if you
+ // attempt to add expando properties to them.
+ noData: {
+ "embed": true,
+ // Ban all objects except for Flash (which handle expandos)
+ "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
+ "applet": true
+ },
+
+ data: function( elem, name, data ) {
+ if ( !jQuery.acceptData( elem ) ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var isNode = elem.nodeType,
+ id = isNode ? elem[ jQuery.expando ] : null,
+ cache = jQuery.cache, thisCache;
+
+ if ( isNode && !id && typeof name === "string" && data === undefined ) {
+ return;
+ }
+
+ // Get the data from the object directly
+ if ( !isNode ) {
+ cache = elem;
+
+ // Compute a unique ID for the element
+ } else if ( !id ) {
+ elem[ jQuery.expando ] = id = ++jQuery.uuid;
+ }
+
+ // Avoid generating a new cache unless none exists and we
+ // want to manipulate it.
+ if ( typeof name === "object" ) {
+ if ( isNode ) {
+ cache[ id ] = jQuery.extend(cache[ id ], name);
+
+ } else {
+ jQuery.extend( cache, name );
+ }
+
+ } else if ( isNode && !cache[ id ] ) {
+ cache[ id ] = {};
+ }
+
+ thisCache = isNode ? cache[ id ] : cache;
+
+ // Prevent overriding the named cache with undefined values
+ if ( data !== undefined ) {
+ thisCache[ name ] = data;
+ }
+
+ return typeof name === "string" ? thisCache[ name ] : thisCache;
+ },
+
+ removeData: function( elem, name ) {
+ if ( !jQuery.acceptData( elem ) ) {
+ return;
+ }
+
+ elem = elem == window ?
+ windowData :
+ elem;
+
+ var isNode = elem.nodeType,
+ id = isNode ? elem[ jQuery.expando ] : elem,
+ cache = jQuery.cache,
+ thisCache = isNode ? cache[ id ] : id;
+
+ // If we want to remove a specific section of the element's data
+ if ( name ) {
+ if ( thisCache ) {
+ // Remove the section of cache data
+ delete thisCache[ name ];
+
+ // If we've removed all the data, remove the element's cache
+ if ( isNode && jQuery.isEmptyObject(thisCache) ) {
+ jQuery.removeData( elem );
+ }
+ }
+
+ // Otherwise, we want to remove all of the element's data
+ } else {
+ if ( isNode && jQuery.support.deleteExpando ) {
+ delete elem[ jQuery.expando ];
+
+ } else if ( elem.removeAttribute ) {
+ elem.removeAttribute( jQuery.expando );
+
+ // Completely remove the data cache
+ } else if ( isNode ) {
+ delete cache[ id ];
+
+ // Remove all fields from the object
+ } else {
+ for ( var n in elem ) {
+ delete elem[ n ];
+ }
+ }
+ }
+ },
+
+ // A method for determining if a DOM node can handle the data expando
+ acceptData: function( elem ) {
+ if ( elem.nodeName ) {
+ var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
+
+ if ( match ) {
+ return !(match === true || elem.getAttribute("classid") !== match);
+ }
+ }
+
+ return true;
+ }
+});
+
+jQuery.fn.extend({
+ data: function( key, value ) {
+ var data = null;
+
+ if ( typeof key === "undefined" ) {
+ if ( this.length ) {
+ var attr = this[0].attributes, name;
+ data = jQuery.data( this[0] );
+
+ for ( var i = 0, l = attr.length; i < l; i++ ) {
+ name = attr[i].name;
+
+ if ( name.indexOf( "data-" ) === 0 ) {
+ name = name.substr( 5 );
+ dataAttr( this[0], name, data[ name ] );
+ }
+ }
+ }
+
+ return data;
+
+ } else if ( typeof key === "object" ) {
+ return this.each(function() {
+ jQuery.data( this, key );
+ });
+ }
+
+ var parts = key.split(".");
+ parts[1] = parts[1] ? "." + parts[1] : "";
+
+ if ( value === undefined ) {
+ data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
+
+ // Try to fetch any internally stored data first
+ if ( data === undefined && this.length ) {
+ data = jQuery.data( this[0], key );
+ data = dataAttr( this[0], key, data );
+ }
+
+ return data === undefined && parts[1] ?
+ this.data( parts[0] ) :
+ data;
+
+ } else {
+ return this.each(function() {
+ var $this = jQuery( this ),
+ args = [ parts[0], value ];
+
+ $this.triggerHandler( "setData" + parts[1] + "!", args );
+ jQuery.data( this, key, value );
+ $this.triggerHandler( "changeData" + parts[1] + "!", args );
+ });
+ }
+ },
+
+ removeData: function( key ) {
+ return this.each(function() {
+ jQuery.removeData( this, key );
+ });
+ }
+});
+
+function dataAttr( elem, key, data ) {
+ // If nothing was found internally, try to fetch any
+ // data from the HTML5 data-* attribute
+ if ( data === undefined && elem.nodeType === 1 ) {
+ data = elem.getAttribute( "data-" + key );
+
+ if ( typeof data === "string" ) {
+ try {
+ data = data === "true" ? true :
+ data === "false" ? false :
+ data === "null" ? null :
+ !jQuery.isNaN( data ) ? parseFloat( data ) :
+ rbrace.test( data ) ? jQuery.parseJSON( data ) :
+ data;
+ } catch( e ) {}
+
+ // Make sure we set the data so it isn't changed later
+ jQuery.data( elem, key, data );
+
+ } else {
+ data = undefined;
+ }
+ }
+
+ return data;
+}
+
+
+
+
+jQuery.extend({
+ queue: function( elem, type, data ) {
+ if ( !elem ) {
+ return;
+ }
+
+ type = (type || "fx") + "queue";
+ var q = jQuery.data( elem, type );
+
+ // Speed up dequeue by getting out quickly if this is just a lookup
+ if ( !data ) {
+ return q || [];
+ }
+
+ if ( !q || jQuery.isArray(data) ) {
+ q = jQuery.data( elem, type, jQuery.makeArray(data) );
+
+ } else {
+ q.push( data );
+ }
+
+ return q;
+ },
+
+ dequeue: function( elem, type ) {
+ type = type || "fx";
+
+ var queue = jQuery.queue( elem, type ),
+ fn = queue.shift();
+
+ // If the fx queue is dequeued, always remove the progress sentinel
+ if ( fn === "inprogress" ) {
+ fn = queue.shift();
+ }
+
+ if ( fn ) {
+ // Add a progress sentinel to prevent the fx queue from being
+ // automatically dequeued
+ if ( type === "fx" ) {
+ queue.unshift("inprogress");
+ }
+
+ fn.call(elem, function() {
+ jQuery.dequeue(elem, type);
+ });
+ }
+ }
+});
+
+jQuery.fn.extend({
+ queue: function( type, data ) {
+ if ( typeof type !== "string" ) {
+ data = type;
+ type = "fx";
+ }
+
+ if ( data === undefined ) {
+ return jQuery.queue( this[0], type );
+ }
+ return this.each(function( i ) {
+ var queue = jQuery.queue( this, type, data );
+
+ if ( type === "fx" && queue[0] !== "inprogress" ) {
+ jQuery.dequeue( this, type );
+ }
+ });
+ },
+ dequeue: function( type ) {
+ return this.each(function() {
+ jQuery.dequeue( this, type );
+ });
+ },
+
+ // Based off of the plugin by Clint Helfers, with permission.
+ // http://blindsignals.com/index.php/2009/07/jquery-delay/
+ delay: function( time, type ) {
+ time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
+ type = type || "fx";
+
+ return this.queue( type, function() {
+ var elem = this;
+ setTimeout(function() {
+ jQuery.dequeue( elem, type );
+ }, time );
+ });
+ },
+
+ clearQueue: function( type ) {
+ return this.queue( type || "fx", [] );
+ }
+});
+
+
+
+
+var rclass = /[\n\t]/g,
+ rspaces = /\s+/,
+ rreturn = /\r/g,
+ rspecialurl = /^(?:href|src|style)$/,
+ rtype = /^(?:button|input)$/i,
+ rfocusable = /^(?:button|input|object|select|textarea)$/i,
+ rclickable = /^a(?:rea)?$/i,
+ rradiocheck = /^(?:radio|checkbox)$/i;
+
+jQuery.props = {
+ "for": "htmlFor",
+ "class": "className",
+ readonly: "readOnly",
+ maxlength: "maxLength",
+ cellspacing: "cellSpacing",
+ rowspan: "rowSpan",
+ colspan: "colSpan",
+ tabindex: "tabIndex",
+ usemap: "useMap",
+ frameborder: "frameBorder"
+};
+
+jQuery.fn.extend({
+ attr: function( name, value ) {
+ return jQuery.access( this, name, value, true, jQuery.attr );
+ },
+
+ removeAttr: function( name, fn ) {
+ return this.each(function(){
+ jQuery.attr( this, name, "" );
+ if ( this.nodeType === 1 ) {
+ this.removeAttribute( name );
+ }
+ });
+ },
+
+ addClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.addClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( value && typeof value === "string" ) {
+ var classNames = (value || "").split( rspaces );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 ) {
+ if ( !elem.className ) {
+ elem.className = value;
+
+ } else {
+ var className = " " + elem.className + " ",
+ setClass = elem.className;
+
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
+ setClass += " " + classNames[c];
+ }
+ }
+ elem.className = jQuery.trim( setClass );
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ removeClass: function( value ) {
+ if ( jQuery.isFunction(value) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.removeClass( value.call(this, i, self.attr("class")) );
+ });
+ }
+
+ if ( (value && typeof value === "string") || value === undefined ) {
+ var classNames = (value || "").split( rspaces );
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ var elem = this[i];
+
+ if ( elem.nodeType === 1 && elem.className ) {
+ if ( value ) {
+ var className = (" " + elem.className + " ").replace(rclass, " ");
+ for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
+ className = className.replace(" " + classNames[c] + " ", " ");
+ }
+ elem.className = jQuery.trim( className );
+
+ } else {
+ elem.className = "";
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ toggleClass: function( value, stateVal ) {
+ var type = typeof value,
+ isBool = typeof stateVal === "boolean";
+
+ if ( jQuery.isFunction( value ) ) {
+ return this.each(function(i) {
+ var self = jQuery(this);
+ self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
+ });
+ }
+
+ return this.each(function() {
+ if ( type === "string" ) {
+ // toggle individual class names
+ var className,
+ i = 0,
+ self = jQuery( this ),
+ state = stateVal,
+ classNames = value.split( rspaces );
+
+ while ( (className = classNames[ i++ ]) ) {
+ // check each className given, space seperated list
+ state = isBool ? state : !self.hasClass( className );
+ self[ state ? "addClass" : "removeClass" ]( className );
+ }
+
+ } else if ( type === "undefined" || type === "boolean" ) {
+ if ( this.className ) {
+ // store className if set
+ jQuery.data( this, "__className__", this.className );
+ }
+
+ // toggle whole className
+ this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || "";
+ }
+ });
+ },
+
+ hasClass: function( selector ) {
+ var className = " " + selector + " ";
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ val: function( value ) {
+ if ( !arguments.length ) {
+ var elem = this[0];
+
+ if ( elem ) {
+ if ( jQuery.nodeName( elem, "option" ) ) {
+ // attributes.value is undefined in Blackberry 4.7 but
+ // uses .value. See #6932
+ var val = elem.attributes.value;
+ return !val || val.specified ? elem.value : elem.text;
+ }
+
+ // We need to handle select boxes special
+ if ( jQuery.nodeName( elem, "select" ) ) {
+ var index = elem.selectedIndex,
+ values = [],
+ options = elem.options,
+ one = elem.type === "select-one";
+
+ // Nothing was selected
+ if ( index < 0 ) {
+ return null;
+ }
+
+ // Loop through all the selected options
+ for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
+ var option = options[ i ];
+
+ // Don't return options that are disabled or in a disabled optgroup
+ if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
+ (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
+
+ // Get the specific value for the option
+ value = jQuery(option).val();
+
+ // We don't need an array for one selects
+ if ( one ) {
+ return value;
+ }
+
+ // Multi-Selects return an array
+ values.push( value );
+ }
+ }
+
+ return values;
+ }
+
+ // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
+ if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
+ return elem.getAttribute("value") === null ? "on" : elem.value;
+ }
+
+
+ // Everything else, we just grab the value
+ return (elem.value || "").replace(rreturn, "");
+
+ }
+
+ return undefined;
+ }
+
+ var isFunction = jQuery.isFunction(value);
+
+ return this.each(function(i) {
+ var self = jQuery(this), val = value;
+
+ if ( this.nodeType !== 1 ) {
+ return;
+ }
+
+ if ( isFunction ) {
+ val = value.call(this, i, self.val());
+ }
+
+ // Treat null/undefined as ""; convert numbers to string
+ if ( val == null ) {
+ val = "";
+ } else if ( typeof val === "number" ) {
+ val += "";
+ } else if ( jQuery.isArray(val) ) {
+ val = jQuery.map(val, function (value) {
+ return value == null ? "" : value + "";
+ });
+ }
+
+ if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
+ this.checked = jQuery.inArray( self.val(), val ) >= 0;
+
+ } else if ( jQuery.nodeName( this, "select" ) ) {
+ var values = jQuery.makeArray(val);
+
+ jQuery( "option", this ).each(function() {
+ this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
+ });
+
+ if ( !values.length ) {
+ this.selectedIndex = -1;
+ }
+
+ } else {
+ this.value = val;
+ }
+ });
+ }
+});
+
+jQuery.extend({
+ attrFn: {
+ val: true,
+ css: true,
+ html: true,
+ text: true,
+ data: true,
+ width: true,
+ height: true,
+ offset: true
+ },
+
+ attr: function( elem, name, value, pass ) {
+ // don't set attributes on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ if ( pass && name in jQuery.attrFn ) {
+ return jQuery(elem)[name](value);
+ }
+
+ var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
+ // Whether we are setting (or getting)
+ set = value !== undefined;
+
+ // Try to normalize/fix the name
+ name = notxml && jQuery.props[ name ] || name;
+
+ // These attributes require special treatment
+ var special = rspecialurl.test( name );
+
+ // Safari mis-reports the default selected property of an option
+ // Accessing the parent's selectedIndex property fixes it
+ if ( name === "selected" && !jQuery.support.optSelected ) {
+ var parent = elem.parentNode;
+ if ( parent ) {
+ parent.selectedIndex;
+
+ // Make sure that it also works with optgroups, see #5701
+ if ( parent.parentNode ) {
+ parent.parentNode.selectedIndex;
+ }
+ }
+ }
+
+ // If applicable, access the attribute via the DOM 0 way
+ // 'in' checks fail in Blackberry 4.7 #6931
+ if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) {
+ if ( set ) {
+ // We can't allow the type property to be changed (since it causes problems in IE)
+ if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
+ jQuery.error( "type property can't be changed" );
+ }
+
+ if ( value === null ) {
+ if ( elem.nodeType === 1 ) {
+ elem.removeAttribute( name );
+ }
+
+ } else {
+ elem[ name ] = value;
+ }
+ }
+
+ // browsers index elements by id/name on forms, give priority to attributes.
+ if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
+ return elem.getAttributeNode( name ).nodeValue;
+ }
+
+ // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
+ // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
+ if ( name === "tabIndex" ) {
+ var attributeNode = elem.getAttributeNode( "tabIndex" );
+
+ return attributeNode && attributeNode.specified ?
+ attributeNode.value :
+ rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
+ 0 :
+ undefined;
+ }
+
+ return elem[ name ];
+ }
+
+ if ( !jQuery.support.style && notxml && name === "style" ) {
+ if ( set ) {
+ elem.style.cssText = "" + value;
+ }
+
+ return elem.style.cssText;
+ }
+
+ if ( set ) {
+ // convert the value to a string (all browsers do this but IE) see #1070
+ elem.setAttribute( name, "" + value );
+ }
+
+ // Ensure that missing attributes return undefined
+ // Blackberry 4.7 returns "" from getAttribute #6938
+ if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) {
+ return undefined;
+ }
+
+ var attr = !jQuery.support.hrefNormalized && notxml && special ?
+ // Some attributes require a special call on IE
+ elem.getAttribute( name, 2 ) :
+ elem.getAttribute( name );
+
+ // Non-existent attributes return null, we normalize to undefined
+ return attr === null ? undefined : attr;
+ }
+});
+
+
+
+
+var rnamespaces = /\.(.*)$/,
+ rformElems = /^(?:textarea|input|select)$/i,
+ rperiod = /\./g,
+ rspace = / /g,
+ rescape = /[^\w\s.|`]/g,
+ fcleanup = function( nm ) {
+ return nm.replace(rescape, "\\$&");
+ },
+ focusCounts = { focusin: 0, focusout: 0 };
+
+/*
+ * A number of helper functions used for managing events.
+ * Many of the ideas behind this code originated from
+ * Dean Edwards' addEvent library.
+ */
+jQuery.event = {
+
+ // Bind an event to an element
+ // Original by Dean Edwards
+ add: function( elem, types, handler, data ) {
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ // For whatever reason, IE has trouble passing the window object
+ // around, causing it to be cloned in the process
+ if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
+ elem = window;
+ }
+
+ if ( handler === false ) {
+ handler = returnFalse;
+ } else if ( !handler ) {
+ // Fixes bug #7229. Fix recommended by jdalton
+ return;
+ }
+
+ var handleObjIn, handleObj;
+
+ if ( handler.handler ) {
+ handleObjIn = handler;
+ handler = handleObjIn.handler;
+ }
+
+ // Make sure that the function being executed has a unique ID
+ if ( !handler.guid ) {
+ handler.guid = jQuery.guid++;
+ }
+
+ // Init the element's event structure
+ var elemData = jQuery.data( elem );
+
+ // If no elemData is found then we must be trying to bind to one of the
+ // banned noData elements
+ if ( !elemData ) {
+ return;
+ }
+
+ // Use a key less likely to result in collisions for plain JS objects.
+ // Fixes bug #7150.
+ var eventKey = elem.nodeType ? "events" : "__events__",
+ events = elemData[ eventKey ],
+ eventHandle = elemData.handle;
+
+ if ( typeof events === "function" ) {
+ // On plain objects events is a fn that holds the the data
+ // which prevents this data from being JSON serialized
+ // the function does not need to be called, it just contains the data
+ eventHandle = events.handle;
+ events = events.events;
+
+ } else if ( !events ) {
+ if ( !elem.nodeType ) {
+ // On plain objects, create a fn that acts as the holder
+ // of the values to avoid JSON serialization of event data
+ elemData[ eventKey ] = elemData = function(){};
+ }
+
+ elemData.events = events = {};
+ }
+
+ if ( !eventHandle ) {
+ elemData.handle = eventHandle = function() {
+ // Handle the second event of a trigger and when
+ // an event is called after a page has unloaded
+ return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
+ jQuery.event.handle.apply( eventHandle.elem, arguments ) :
+ undefined;
+ };
+ }
+
+ // Add elem as a property of the handle function
+ // This is to prevent a memory leak with non-native events in IE.
+ eventHandle.elem = elem;
+
+ // Handle multiple events separated by a space
+ // jQuery(...).bind("mouseover mouseout", fn);
+ types = types.split(" ");
+
+ var type, i = 0, namespaces;
+
+ while ( (type = types[ i++ ]) ) {
+ handleObj = handleObjIn ?
+ jQuery.extend({}, handleObjIn) :
+ { handler: handler, data: data };
+
+ // Namespaced event handlers
+ if ( type.indexOf(".") > -1 ) {
+ namespaces = type.split(".");
+ type = namespaces.shift();
+ handleObj.namespace = namespaces.slice(0).sort().join(".");
+
+ } else {
+ namespaces = [];
+ handleObj.namespace = "";
+ }
+
+ handleObj.type = type;
+ if ( !handleObj.guid ) {
+ handleObj.guid = handler.guid;
+ }
+
+ // Get the current list of functions bound to this event
+ var handlers = events[ type ],
+ special = jQuery.event.special[ type ] || {};
+
+ // Init the event handler queue
+ if ( !handlers ) {
+ handlers = events[ type ] = [];
+
+ // Check for a special event handler
+ // Only use addEventListener/attachEvent if the special
+ // events handler returns false
+ if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
+ // Bind the global event handler to the element
+ if ( elem.addEventListener ) {
+ elem.addEventListener( type, eventHandle, false );
+
+ } else if ( elem.attachEvent ) {
+ elem.attachEvent( "on" + type, eventHandle );
+ }
+ }
+ }
+
+ if ( special.add ) {
+ special.add.call( elem, handleObj );
+
+ if ( !handleObj.handler.guid ) {
+ handleObj.handler.guid = handler.guid;
+ }
+ }
+
+ // Add the function to the element's handler list
+ handlers.push( handleObj );
+
+ // Keep track of which events have been used, for global triggering
+ jQuery.event.global[ type ] = true;
+ }
+
+ // Nullify elem to prevent memory leaks in IE
+ elem = null;
+ },
+
+ global: {},
+
+ // Detach an event or set of events from an element
+ remove: function( elem, types, handler, pos ) {
+ // don't do events on text and comment nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return;
+ }
+
+ if ( handler === false ) {
+ handler = returnFalse;
+ }
+
+ var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
+ eventKey = elem.nodeType ? "events" : "__events__",
+ elemData = jQuery.data( elem ),
+ events = elemData && elemData[ eventKey ];
+
+ if ( !elemData || !events ) {
+ return;
+ }
+
+ if ( typeof events === "function" ) {
+ elemData = events;
+ events = events.events;
+ }
+
+ // types is actually an event object here
+ if ( types && types.type ) {
+ handler = types.handler;
+ types = types.type;
+ }
+
+ // Unbind all events for the element
+ if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
+ types = types || "";
+
+ for ( type in events ) {
+ jQuery.event.remove( elem, type + types );
+ }
+
+ return;
+ }
+
+ // Handle multiple events separated by a space
+ // jQuery(...).unbind("mouseover mouseout", fn);
+ types = types.split(" ");
+
+ while ( (type = types[ i++ ]) ) {
+ origType = type;
+ handleObj = null;
+ all = type.indexOf(".") < 0;
+ namespaces = [];
+
+ if ( !all ) {
+ // Namespaced event handlers
+ namespaces = type.split(".");
+ type = namespaces.shift();
+
+ namespace = new RegExp("(^|\\.)" +
+ jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
+ }
+
+ eventType = events[ type ];
+
+ if ( !eventType ) {
+ continue;
+ }
+
+ if ( !handler ) {
+ for ( j = 0; j < eventType.length; j++ ) {
+ handleObj = eventType[ j ];
+
+ if ( all || namespace.test( handleObj.namespace ) ) {
+ jQuery.event.remove( elem, origType, handleObj.handler, j );
+ eventType.splice( j--, 1 );
+ }
+ }
+
+ continue;
+ }
+
+ special = jQuery.event.special[ type ] || {};
+
+ for ( j = pos || 0; j < eventType.length; j++ ) {
+ handleObj = eventType[ j ];
+
+ if ( handler.guid === handleObj.guid ) {
+ // remove the given handler for the given type
+ if ( all || namespace.test( handleObj.namespace ) ) {
+ if ( pos == null ) {
+ eventType.splice( j--, 1 );
+ }
+
+ if ( special.remove ) {
+ special.remove.call( elem, handleObj );
+ }
+ }
+
+ if ( pos != null ) {
+ break;
+ }
+ }
+ }
+
+ // remove generic event handler if no more handlers exist
+ if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
+ if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
+ jQuery.removeEvent( elem, type, elemData.handle );
+ }
+
+ ret = null;
+ delete events[ type ];
+ }
+ }
+
+ // Remove the expando if it's no longer used
+ if ( jQuery.isEmptyObject( events ) ) {
+ var handle = elemData.handle;
+ if ( handle ) {
+ handle.elem = null;
+ }
+
+ delete elemData.events;
+ delete elemData.handle;
+
+ if ( typeof elemData === "function" ) {
+ jQuery.removeData( elem, eventKey );
+
+ } else if ( jQuery.isEmptyObject( elemData ) ) {
+ jQuery.removeData( elem );
+ }
+ }
+ },
+
+ // bubbling is internal
+ trigger: function( event, data, elem /*, bubbling */ ) {
+ // Event object or event type
+ var type = event.type || event,
+ bubbling = arguments[3];
+
+ if ( !bubbling ) {
+ event = typeof event === "object" ?
+ // jQuery.Event object
+ event[ jQuery.expando ] ? event :
+ // Object literal
+ jQuery.extend( jQuery.Event(type), event ) :
+ // Just the event type (string)
+ jQuery.Event(type);
+
+ if ( type.indexOf("!") >= 0 ) {
+ event.type = type = type.slice(0, -1);
+ event.exclusive = true;
+ }
+
+ // Handle a global trigger
+ if ( !elem ) {
+ // Don't bubble custom events when global (to avoid too much overhead)
+ event.stopPropagation();
+
+ // Only trigger if we've ever bound an event for it
+ if ( jQuery.event.global[ type ] ) {
+ jQuery.each( jQuery.cache, function() {
+ if ( this.events && this.events[type] ) {
+ jQuery.event.trigger( event, data, this.handle.elem );
+ }
+ });
+ }
+ }
+
+ // Handle triggering a single element
+
+ // don't do events on text and comment nodes
+ if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
+ return undefined;
+ }
+
+ // Clean up in case it is reused
+ event.result = undefined;
+ event.target = elem;
+
+ // Clone the incoming data, if any
+ data = jQuery.makeArray( data );
+ data.unshift( event );
+ }
+
+ event.currentTarget = elem;
+
+ // Trigger the event, it is assumed that "handle" is a function
+ var handle = elem.nodeType ?
+ jQuery.data( elem, "handle" ) :
+ (jQuery.data( elem, "__events__" ) || {}).handle;
+
+ if ( handle ) {
+ handle.apply( elem, data );
+ }
+
+ var parent = elem.parentNode || elem.ownerDocument;
+
+ // Trigger an inline bound script
+ try {
+ if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
+ if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) {
+ event.result = false;
+ event.preventDefault();
+ }
+ }
+
+ // prevent IE from throwing an error for some elements with some event types, see #3533
+ } catch (inlineError) {}
+
+ if ( !event.isPropagationStopped() && parent ) {
+ jQuery.event.trigger( event, data, parent, true );
+
+ } else if ( !event.isDefaultPrevented() ) {
+ var old,
+ target = event.target,
+ targetType = type.replace( rnamespaces, "" ),
+ isClick = jQuery.nodeName( target, "a" ) && targetType === "click",
+ special = jQuery.event.special[ targetType ] || {};
+
+ if ( (!special._default || special._default.call( elem, event ) === false) &&
+ !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
+
+ try {
+ if ( target[ targetType ] ) {
+ // Make sure that we don't accidentally re-trigger the onFOO events
+ old = target[ "on" + targetType ];
+
+ if ( old ) {
+ target[ "on" + targetType ] = null;
+ }
+
+ jQuery.event.triggered = true;
+ target[ targetType ]();
+ }
+
+ // prevent IE from throwing an error for some elements with some event types, see #3533
+ } catch (triggerError) {}
+
+ if ( old ) {
+ target[ "on" + targetType ] = old;
+ }
+
+ jQuery.event.triggered = false;
+ }
+ }
+ },
+
+ handle: function( event ) {
+ var all, handlers, namespaces, namespace_re, events,
+ namespace_sort = [],
+ args = jQuery.makeArray( arguments );
+
+ event = args[0] = jQuery.event.fix( event || window.event );
+ event.currentTarget = this;
+
+ // Namespaced event handlers
+ all = event.type.indexOf(".") < 0 && !event.exclusive;
+
+ if ( !all ) {
+ namespaces = event.type.split(".");
+ event.type = namespaces.shift();
+ namespace_sort = namespaces.slice(0).sort();
+ namespace_re = new RegExp("(^|\\.)" + namespace_sort.join("\\.(?:.*\\.)?") + "(\\.|$)");
+ }
+
+ event.namespace = event.namespace || namespace_sort.join(".");
+
+ events = jQuery.data(this, this.nodeType ? "events" : "__events__");
+
+ if ( typeof events === "function" ) {
+ events = events.events;
+ }
+
+ handlers = (events || {})[ event.type ];
+
+ if ( events && handlers ) {
+ // Clone the handlers to prevent manipulation
+ handlers = handlers.slice(0);
+
+ for ( var j = 0, l = handlers.length; j < l; j++ ) {
+ var handleObj = handlers[ j ];
+
+ // Filter the functions by class
+ if ( all || namespace_re.test( handleObj.namespace ) ) {
+ // Pass in a reference to the handler function itself
+ // So that we can later remove it
+ event.handler = handleObj.handler;
+ event.data = handleObj.data;
+ event.handleObj = handleObj;
+
+ var ret = handleObj.handler.apply( this, args );
+
+ if ( ret !== undefined ) {
+ event.result = ret;
+ if ( ret === false ) {
+ event.preventDefault();
+ event.stopPropagation();
+ }
+ }
+
+ if ( event.isImmediatePropagationStopped() ) {
+ break;
+ }
+ }
+ }
+ }
+
+ return event.result;
+ },
+
+ props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
+
+ fix: function( event ) {
+ if ( event[ jQuery.expando ] ) {
+ return event;
+ }
+
+ // store a copy of the original event object
+ // and "clone" to set read-only properties
+ var originalEvent = event;
+ event = jQuery.Event( originalEvent );
+
+ for ( var i = this.props.length, prop; i; ) {
+ prop = this.props[ --i ];
+ event[ prop ] = originalEvent[ prop ];
+ }
+
+ // Fix target property, if necessary
+ if ( !event.target ) {
+ // Fixes #1925 where srcElement might not be defined either
+ event.target = event.srcElement || document;
+ }
+
+ // check if target is a textnode (safari)
+ if ( event.target.nodeType === 3 ) {
+ event.target = event.target.parentNode;
+ }
+
+ // Add relatedTarget, if necessary
+ if ( !event.relatedTarget && event.fromElement ) {
+ event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
+ }
+
+ // Calculate pageX/Y if missing and clientX/Y available
+ if ( event.pageX == null && event.clientX != null ) {
+ var doc = document.documentElement,
+ body = document.body;
+
+ event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
+ event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
+ }
+
+ // Add which for key events
+ if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
+ event.which = event.charCode != null ? event.charCode : event.keyCode;
+ }
+
+ // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
+ if ( !event.metaKey && event.ctrlKey ) {
+ event.metaKey = event.ctrlKey;
+ }
+
+ // Add which for click: 1 === left; 2 === middle; 3 === right
+ // Note: button is not normalized, so don't use it
+ if ( !event.which && event.button !== undefined ) {
+ event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
+ }
+
+ return event;
+ },
+
+ // Deprecated, use jQuery.guid instead
+ guid: 1E8,
+
+ // Deprecated, use jQuery.proxy instead
+ proxy: jQuery.proxy,
+
+ special: {
+ ready: {
+ // Make sure the ready event is setup
+ setup: jQuery.bindReady,
+ teardown: jQuery.noop
+ },
+
+ live: {
+ add: function( handleObj ) {
+ jQuery.event.add( this,
+ liveConvert( handleObj.origType, handleObj.selector ),
+ jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
+ },
+
+ remove: function( handleObj ) {
+ jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
+ }
+ },
+
+ beforeunload: {
+ setup: function( data, namespaces, eventHandle ) {
+ // We only want to do this special case on windows
+ if ( jQuery.isWindow( this ) ) {
+ this.onbeforeunload = eventHandle;
+ }
+ },
+
+ teardown: function( namespaces, eventHandle ) {
+ if ( this.onbeforeunload === eventHandle ) {
+ this.onbeforeunload = null;
+ }
+ }
+ }
+ }
+};
+
+jQuery.removeEvent = document.removeEventListener ?
+ function( elem, type, handle ) {
+ if ( elem.removeEventListener ) {
+ elem.removeEventListener( type, handle, false );
+ }
+ } :
+ function( elem, type, handle ) {
+ if ( elem.detachEvent ) {
+ elem.detachEvent( "on" + type, handle );
+ }
+ };
+
+jQuery.Event = function( src ) {
+ // Allow instantiation without the 'new' keyword
+ if ( !this.preventDefault ) {
+ return new jQuery.Event( src );
+ }
+
+ // Event object
+ if ( src && src.type ) {
+ this.originalEvent = src;
+ this.type = src.type;
+ // Event type
+ } else {
+ this.type = src;
+ }
+
+ // timeStamp is buggy for some events on Firefox(#3843)
+ // So we won't rely on the native value
+ this.timeStamp = jQuery.now();
+
+ // Mark it as fixed
+ this[ jQuery.expando ] = true;
+};
+
+function returnFalse() {
+ return false;
+}
+function returnTrue() {
+ return true;
+}
+
+// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
+// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
+jQuery.Event.prototype = {
+ preventDefault: function() {
+ this.isDefaultPrevented = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+
+ // if preventDefault exists run it on the original event
+ if ( e.preventDefault ) {
+ e.preventDefault();
+
+ // otherwise set the returnValue property of the original event to false (IE)
+ } else {
+ e.returnValue = false;
+ }
+ },
+ stopPropagation: function() {
+ this.isPropagationStopped = returnTrue;
+
+ var e = this.originalEvent;
+ if ( !e ) {
+ return;
+ }
+ // if stopPropagation exists run it on the original event
+ if ( e.stopPropagation ) {
+ e.stopPropagation();
+ }
+ // otherwise set the cancelBubble property of the original event to true (IE)
+ e.cancelBubble = true;
+ },
+ stopImmediatePropagation: function() {
+ this.isImmediatePropagationStopped = returnTrue;
+ this.stopPropagation();
+ },
+ isDefaultPrevented: returnFalse,
+ isPropagationStopped: returnFalse,
+ isImmediatePropagationStopped: returnFalse
+};
+
+// Checks if an event happened on an element within another element
+// Used in jQuery.event.special.mouseenter and mouseleave handlers
+var withinElement = function( event ) {
+ // Check if mouse(over|out) are still within the same parent element
+ var parent = event.relatedTarget;
+
+ // Firefox sometimes assigns relatedTarget a XUL element
+ // which we cannot access the parentNode property of
+ try {
+ // Traverse up the tree
+ while ( parent && parent !== this ) {
+ parent = parent.parentNode;
+ }
+
+ if ( parent !== this ) {
+ // set the correct event type
+ event.type = event.data;
+
+ // handle event if we actually just moused on to a non sub-element
+ jQuery.event.handle.apply( this, arguments );
+ }
+
+ // assuming we've left the element since we most likely mousedover a xul element
+ } catch(e) { }
+},
+
+// In case of event delegation, we only need to rename the event.type,
+// liveHandler will take care of the rest.
+delegate = function( event ) {
+ event.type = event.data;
+ jQuery.event.handle.apply( this, arguments );
+};
+
+// Create mouseenter and mouseleave events
+jQuery.each({
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
+}, function( orig, fix ) {
+ jQuery.event.special[ orig ] = {
+ setup: function( data ) {
+ jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
+ },
+ teardown: function( data ) {
+ jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
+ }
+ };
+});
+
+// submit delegation
+if ( !jQuery.support.submitBubbles ) {
+
+ jQuery.event.special.submit = {
+ setup: function( data, namespaces ) {
+ if ( this.nodeName.toLowerCase() !== "form" ) {
+ jQuery.event.add(this, "click.specialSubmit", function( e ) {
+ var elem = e.target,
+ type = elem.type;
+
+ if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
+ e.liveFired = undefined;
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
+ var elem = e.target,
+ type = elem.type;
+
+ if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
+ e.liveFired = undefined;
+ return trigger( "submit", this, arguments );
+ }
+ });
+
+ } else {
+ return false;
+ }
+ },
+
+ teardown: function( namespaces ) {
+ jQuery.event.remove( this, ".specialSubmit" );
+ }
+ };
+
+}
+
+// change delegation, happens here so we have bind.
+if ( !jQuery.support.changeBubbles ) {
+
+ var changeFilters,
+
+ getVal = function( elem ) {
+ var type = elem.type, val = elem.value;
+
+ if ( type === "radio" || type === "checkbox" ) {
+ val = elem.checked;
+
+ } else if ( type === "select-multiple" ) {
+ val = elem.selectedIndex > -1 ?
+ jQuery.map( elem.options, function( elem ) {
+ return elem.selected;
+ }).join("-") :
+ "";
+
+ } else if ( elem.nodeName.toLowerCase() === "select" ) {
+ val = elem.selectedIndex;
+ }
+
+ return val;
+ },
+
+ testChange = function testChange( e ) {
+ var elem = e.target, data, val;
+
+ if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
+ return;
+ }
+
+ data = jQuery.data( elem, "_change_data" );
+ val = getVal(elem);
+
+ // the current data will be also retrieved by beforeactivate
+ if ( e.type !== "focusout" || elem.type !== "radio" ) {
+ jQuery.data( elem, "_change_data", val );
+ }
+
+ if ( data === undefined || val === data ) {
+ return;
+ }
+
+ if ( data != null || val ) {
+ e.type = "change";
+ e.liveFired = undefined;
+ return jQuery.event.trigger( e, arguments[1], elem );
+ }
+ };
+
+ jQuery.event.special.change = {
+ filters: {
+ focusout: testChange,
+
+ beforedeactivate: testChange,
+
+ click: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Change has to be called before submit
+ // Keydown will be called before keypress, which is used in submit-event delegation
+ keydown: function( e ) {
+ var elem = e.target, type = elem.type;
+
+ if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
+ (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
+ type === "select-multiple" ) {
+ return testChange.call( this, e );
+ }
+ },
+
+ // Beforeactivate happens also before the previous element is blurred
+ // with this event you can't trigger a change event, but you can store
+ // information
+ beforeactivate: function( e ) {
+ var elem = e.target;
+ jQuery.data( elem, "_change_data", getVal(elem) );
+ }
+ },
+
+ setup: function( data, namespaces ) {
+ if ( this.type === "file" ) {
+ return false;
+ }
+
+ for ( var type in changeFilters ) {
+ jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
+ }
+
+ return rformElems.test( this.nodeName );
+ },
+
+ teardown: function( namespaces ) {
+ jQuery.event.remove( this, ".specialChange" );
+
+ return rformElems.test( this.nodeName );
+ }
+ };
+
+ changeFilters = jQuery.event.special.change.filters;
+
+ // Handle when the input is .focus()'d
+ changeFilters.focus = changeFilters.beforeactivate;
+}
+
+function trigger( type, elem, args ) {
+ args[0].type = type;
+ return jQuery.event.handle.apply( elem, args );
+}
+
+// Create "bubbling" focus and blur events
+if ( document.addEventListener ) {
+ jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
+ jQuery.event.special[ fix ] = {
+ setup: function() {
+ if ( focusCounts[fix]++ === 0 ) {
+ document.addEventListener( orig, handler, true );
+ }
+ },
+ teardown: function() {
+ if ( --focusCounts[fix] === 0 ) {
+ document.removeEventListener( orig, handler, true );
+ }
+ }
+ };
+
+ function handler( e ) {
+ e = jQuery.event.fix( e );
+ e.type = fix;
+ return jQuery.event.trigger( e, null, e.target );
+ }
+ });
+}
+
+jQuery.each(["bind", "one"], function( i, name ) {
+ jQuery.fn[ name ] = function( type, data, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" ) {
+ for ( var key in type ) {
+ this[ name ](key, data, type[key], fn);
+ }
+ return this;
+ }
+
+ if ( jQuery.isFunction( data ) || data === false ) {
+ fn = data;
+ data = undefined;
+ }
+
+ var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
+ jQuery( this ).unbind( event, handler );
+ return fn.apply( this, arguments );
+ }) : fn;
+
+ if ( type === "unload" && name !== "one" ) {
+ this.one( type, data, fn );
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ jQuery.event.add( this[i], type, handler, data );
+ }
+ }
+
+ return this;
+ };
+});
+
+jQuery.fn.extend({
+ unbind: function( type, fn ) {
+ // Handle object literals
+ if ( typeof type === "object" && !type.preventDefault ) {
+ for ( var key in type ) {
+ this.unbind(key, type[key]);
+ }
+
+ } else {
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ jQuery.event.remove( this[i], type, fn );
+ }
+ }
+
+ return this;
+ },
+
+ delegate: function( selector, types, data, fn ) {
+ return this.live( types, data, fn, selector );
+ },
+
+ undelegate: function( selector, types, fn ) {
+ if ( arguments.length === 0 ) {
+ return this.unbind( "live" );
+
+ } else {
+ return this.die( types, null, fn, selector );
+ }
+ },
+
+ trigger: function( type, data ) {
+ return this.each(function() {
+ jQuery.event.trigger( type, data, this );
+ });
+ },
+
+ triggerHandler: function( type, data ) {
+ if ( this[0] ) {
+ var event = jQuery.Event( type );
+ event.preventDefault();
+ event.stopPropagation();
+ jQuery.event.trigger( event, data, this[0] );
+ return event.result;
+ }
+ },
+
+ toggle: function( fn ) {
+ // Save reference to arguments for access in closure
+ var args = arguments,
+ i = 1;
+
+ // link all the functions, so any of them can unbind this click handler
+ while ( i < args.length ) {
+ jQuery.proxy( fn, args[ i++ ] );
+ }
+
+ return this.click( jQuery.proxy( fn, function( event ) {
+ // Figure out which function to execute
+ var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
+ jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
+
+ // Make sure that clicks stop
+ event.preventDefault();
+
+ // and execute the function
+ return args[ lastToggle ].apply( this, arguments ) || false;
+ }));
+ },
+
+ hover: function( fnOver, fnOut ) {
+ return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
+ }
+});
+
+var liveMap = {
+ focus: "focusin",
+ blur: "focusout",
+ mouseenter: "mouseover",
+ mouseleave: "mouseout"
+};
+
+jQuery.each(["live", "die"], function( i, name ) {
+ jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
+ var type, i = 0, match, namespaces, preType,
+ selector = origSelector || this.selector,
+ context = origSelector ? this : jQuery( this.context );
+
+ if ( typeof types === "object" && !types.preventDefault ) {
+ for ( var key in types ) {
+ context[ name ]( key, data, types[key], selector );
+ }
+
+ return this;
+ }
+
+ if ( jQuery.isFunction( data ) ) {
+ fn = data;
+ data = undefined;
+ }
+
+ types = (types || "").split(" ");
+
+ while ( (type = types[ i++ ]) != null ) {
+ match = rnamespaces.exec( type );
+ namespaces = "";
+
+ if ( match ) {
+ namespaces = match[0];
+ type = type.replace( rnamespaces, "" );
+ }
+
+ if ( type === "hover" ) {
+ types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
+ continue;
+ }
+
+ preType = type;
+
+ if ( type === "focus" || type === "blur" ) {
+ types.push( liveMap[ type ] + namespaces );
+ type = type + namespaces;
+
+ } else {
+ type = (liveMap[ type ] || type) + namespaces;
+ }
+
+ if ( name === "live" ) {
+ // bind live handler
+ for ( var j = 0, l = context.length; j < l; j++ ) {
+ jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
+ { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
+ }
+
+ } else {
+ // unbind live handler
+ context.unbind( "live." + liveConvert( type, selector ), fn );
+ }
+ }
+
+ return this;
+ };
+});
+
+function liveHandler( event ) {
+ var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
+ elems = [],
+ selectors = [],
+ events = jQuery.data( this, this.nodeType ? "events" : "__events__" );
+
+ if ( typeof events === "function" ) {
+ events = events.events;
+ }
+
+ // Make sure we avoid non-left-click bubbling in Firefox (#3861)
+ if ( event.liveFired === this || !events || !events.live || event.button && event.type === "click" ) {
+ return;
+ }
+
+ if ( event.namespace ) {
+ namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
+ }
+
+ event.liveFired = this;
+
+ var live = events.live.slice(0);
+
+ for ( j = 0; j < live.length; j++ ) {
+ handleObj = live[j];
+
+ if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
+ selectors.push( handleObj.selector );
+
+ } else {
+ live.splice( j--, 1 );
+ }
+ }
+
+ match = jQuery( event.target ).closest( selectors, event.currentTarget );
+
+ for ( i = 0, l = match.length; i < l; i++ ) {
+ close = match[i];
+
+ for ( j = 0; j < live.length; j++ ) {
+ handleObj = live[j];
+
+ if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) {
+ elem = close.elem;
+ related = null;
+
+ // Those two events require additional checking
+ if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
+ event.type = handleObj.preType;
+ related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
+ }
+
+ if ( !related || related !== elem ) {
+ elems.push({ elem: elem, handleObj: handleObj, level: close.level });
+ }
+ }
+ }
+ }
+
+ for ( i = 0, l = elems.length; i < l; i++ ) {
+ match = elems[i];
+
+ if ( maxLevel && match.level > maxLevel ) {
+ break;
+ }
+
+ event.currentTarget = match.elem;
+ event.data = match.handleObj.data;
+ event.handleObj = match.handleObj;
+
+ ret = match.handleObj.origHandler.apply( match.elem, arguments );
+
+ if ( ret === false || event.isPropagationStopped() ) {
+ maxLevel = match.level;
+
+ if ( ret === false ) {
+ stop = false;
+ }
+ if ( event.isImmediatePropagationStopped() ) {
+ break;
+ }
+ }
+ }
+
+ return stop;
+}
+
+function liveConvert( type, selector ) {
+ return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspace, "&");
+}
+
+jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
+ "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
+ "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
+
+ // Handle event binding
+ jQuery.fn[ name ] = function( data, fn ) {
+ if ( fn == null ) {
+ fn = data;
+ data = null;
+ }
+
+ return arguments.length > 0 ?
+ this.bind( name, data, fn ) :
+ this.trigger( name );
+ };
+
+ if ( jQuery.attrFn ) {
+ jQuery.attrFn[ name ] = true;
+ }
+});
+
+// Prevent memory leaks in IE
+// Window isn't included so as not to unbind existing unload events
+// More info:
+// - http://isaacschlueter.com/2006/10/msie-memory-leaks/
+if ( window.attachEvent && !window.addEventListener ) {
+ jQuery(window).bind("unload", function() {
+ for ( var id in jQuery.cache ) {
+ if ( jQuery.cache[ id ].handle ) {
+ // Try/Catch is to handle iframes being unloaded, see #4280
+ try {
+ jQuery.event.remove( jQuery.cache[ id ].handle.elem );
+ } catch(e) {}
+ }
+ }
+ });
+}
+
+
+/*!
+ * Sizzle CSS Selector Engine - v1.0
+ * Copyright 2009, The Dojo Foundation
+ * Released under the MIT, BSD, and GPL Licenses.
+ * More information: http://sizzlejs.com/
+ */
+(function(){
+
+var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
+ done = 0,
+ toString = Object.prototype.toString,
+ hasDuplicate = false,
+ baseHasDuplicate = true;
+
+// Here we check if the JavaScript engine is using some sort of
+// optimization where it does not always call our comparision
+// function. If that is the case, discard the hasDuplicate value.
+// Thus far that includes Google Chrome.
+[0, 0].sort(function() {
+ baseHasDuplicate = false;
+ return 0;
+});
+
+var Sizzle = function( selector, context, results, seed ) {
+ results = results || [];
+ context = context || document;
+
+ var origContext = context;
+
+ if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
+ return [];
+ }
+
+ if ( !selector || typeof selector !== "string" ) {
+ return results;
+ }
+
+ var m, set, checkSet, extra, ret, cur, pop, i,
+ prune = true,
+ contextXML = Sizzle.isXML( context ),
+ parts = [],
+ soFar = selector;
+
+ // Reset the position of the chunker regexp (start from head)
+ do {
+ chunker.exec( "" );
+ m = chunker.exec( soFar );
+
+ if ( m ) {
+ soFar = m[3];
+
+ parts.push( m[1] );
+
+ if ( m[2] ) {
+ extra = m[3];
+ break;
+ }
+ }
+ } while ( m );
+
+ if ( parts.length > 1 && origPOS.exec( selector ) ) {
+
+ if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
+ set = posProcess( parts[0] + parts[1], context );
+
+ } else {
+ set = Expr.relative[ parts[0] ] ?
+ [ context ] :
+ Sizzle( parts.shift(), context );
+
+ while ( parts.length ) {
+ selector = parts.shift();
+
+ if ( Expr.relative[ selector ] ) {
+ selector += parts.shift();
+ }
+
+ set = posProcess( selector, set );
+ }
+ }
+
+ } else {
+ // Take a shortcut and set the context if the root selector is an ID
+ // (but not if it'll be faster if the inner selector is an ID)
+ if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
+ Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
+
+ ret = Sizzle.find( parts.shift(), context, contextXML );
+ context = ret.expr ?
+ Sizzle.filter( ret.expr, ret.set )[0] :
+ ret.set[0];
+ }
+
+ if ( context ) {
+ ret = seed ?
+ { expr: parts.pop(), set: makeArray(seed) } :
+ Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
+
+ set = ret.expr ?
+ Sizzle.filter( ret.expr, ret.set ) :
+ ret.set;
+
+ if ( parts.length > 0 ) {
+ checkSet = makeArray( set );
+
+ } else {
+ prune = false;
+ }
+
+ while ( parts.length ) {
+ cur = parts.pop();
+ pop = cur;
+
+ if ( !Expr.relative[ cur ] ) {
+ cur = "";
+ } else {
+ pop = parts.pop();
+ }
+
+ if ( pop == null ) {
+ pop = context;
+ }
+
+ Expr.relative[ cur ]( checkSet, pop, contextXML );
+ }
+
+ } else {
+ checkSet = parts = [];
+ }
+ }
+
+ if ( !checkSet ) {
+ checkSet = set;
+ }
+
+ if ( !checkSet ) {
+ Sizzle.error( cur || selector );
+ }
+
+ if ( toString.call(checkSet) === "[object Array]" ) {
+ if ( !prune ) {
+ results.push.apply( results, checkSet );
+
+ } else if ( context && context.nodeType === 1 ) {
+ for ( i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
+ results.push( set[i] );
+ }
+ }
+
+ } else {
+ for ( i = 0; checkSet[i] != null; i++ ) {
+ if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
+ results.push( set[i] );
+ }
+ }
+ }
+
+ } else {
+ makeArray( checkSet, results );
+ }
+
+ if ( extra ) {
+ Sizzle( extra, origContext, results, seed );
+ Sizzle.uniqueSort( results );
+ }
+
+ return results;
+};
+
+Sizzle.uniqueSort = function( results ) {
+ if ( sortOrder ) {
+ hasDuplicate = baseHasDuplicate;
+ results.sort( sortOrder );
+
+ if ( hasDuplicate ) {
+ for ( var i = 1; i < results.length; i++ ) {
+ if ( results[i] === results[ i - 1 ] ) {
+ results.splice( i--, 1 );
+ }
+ }
+ }
+ }
+
+ return results;
+};
+
+Sizzle.matches = function( expr, set ) {
+ return Sizzle( expr, null, null, set );
+};
+
+Sizzle.matchesSelector = function( node, expr ) {
+ return Sizzle( expr, null, null, [node] ).length > 0;
+};
+
+Sizzle.find = function( expr, context, isXML ) {
+ var set;
+
+ if ( !expr ) {
+ return [];
+ }
+
+ for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
+ var match,
+ type = Expr.order[i];
+
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
+ var left = match[1];
+ match.splice( 1, 1 );
+
+ if ( left.substr( left.length - 1 ) !== "\\" ) {
+ match[1] = (match[1] || "").replace(/\\/g, "");
+ set = Expr.find[ type ]( match, context, isXML );
+
+ if ( set != null ) {
+ expr = expr.replace( Expr.match[ type ], "" );
+ break;
+ }
+ }
+ }
+ }
+
+ if ( !set ) {
+ set = context.getElementsByTagName( "*" );
+ }
+
+ return { set: set, expr: expr };
+};
+
+Sizzle.filter = function( expr, set, inplace, not ) {
+ var match, anyFound,
+ old = expr,
+ result = [],
+ curLoop = set,
+ isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
+
+ while ( expr && set.length ) {
+ for ( var type in Expr.filter ) {
+ if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
+ var found, item,
+ filter = Expr.filter[ type ],
+ left = match[1];
+
+ anyFound = false;
+
+ match.splice(1,1);
+
+ if ( left.substr( left.length - 1 ) === "\\" ) {
+ continue;
+ }
+
+ if ( curLoop === result ) {
+ result = [];
+ }
+
+ if ( Expr.preFilter[ type ] ) {
+ match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
+
+ if ( !match ) {
+ anyFound = found = true;
+
+ } else if ( match === true ) {
+ continue;
+ }
+ }
+
+ if ( match ) {
+ for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
+ if ( item ) {
+ found = filter( item, match, i, curLoop );
+ var pass = not ^ !!found;
+
+ if ( inplace && found != null ) {
+ if ( pass ) {
+ anyFound = true;
+
+ } else {
+ curLoop[i] = false;
+ }
+
+ } else if ( pass ) {
+ result.push( item );
+ anyFound = true;
+ }
+ }
+ }
+ }
+
+ if ( found !== undefined ) {
+ if ( !inplace ) {
+ curLoop = result;
+ }
+
+ expr = expr.replace( Expr.match[ type ], "" );
+
+ if ( !anyFound ) {
+ return [];
+ }
+
+ break;
+ }
+ }
+ }
+
+ // Improper expression
+ if ( expr === old ) {
+ if ( anyFound == null ) {
+ Sizzle.error( expr );
+
+ } else {
+ break;
+ }
+ }
+
+ old = expr;
+ }
+
+ return curLoop;
+};
+
+Sizzle.error = function( msg ) {
+ throw "Syntax error, unrecognized expression: " + msg;
+};
+
+var Expr = Sizzle.selectors = {
+ order: [ "ID", "NAME", "TAG" ],
+
+ match: {
+ ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
+ CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
+ NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
+ ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
+ TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
+ CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+\-]*)\))?/,
+ POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
+ PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
+ },
+
+ leftMatch: {},
+
+ attrMap: {
+ "class": "className",
+ "for": "htmlFor"
+ },
+
+ attrHandle: {
+ href: function( elem ) {
+ return elem.getAttribute( "href" );
+ }
+ },
+
+ relative: {
+ "+": function(checkSet, part){
+ var isPartStr = typeof part === "string",
+ isTag = isPartStr && !/\W/.test( part ),
+ isPartStrNotTag = isPartStr && !isTag;
+
+ if ( isTag ) {
+ part = part.toLowerCase();
+ }
+
+ for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
+ if ( (elem = checkSet[i]) ) {
+ while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
+
+ checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
+ elem || false :
+ elem === part;
+ }
+ }
+
+ if ( isPartStrNotTag ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ },
+
+ ">": function( checkSet, part ) {
+ var elem,
+ isPartStr = typeof part === "string",
+ i = 0,
+ l = checkSet.length;
+
+ if ( isPartStr && !/\W/.test( part ) ) {
+ part = part.toLowerCase();
+
+ for ( ; i < l; i++ ) {
+ elem = checkSet[i];
+
+ if ( elem ) {
+ var parent = elem.parentNode;
+ checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
+ }
+ }
+
+ } else {
+ for ( ; i < l; i++ ) {
+ elem = checkSet[i];
+
+ if ( elem ) {
+ checkSet[i] = isPartStr ?
+ elem.parentNode :
+ elem.parentNode === part;
+ }
+ }
+
+ if ( isPartStr ) {
+ Sizzle.filter( part, checkSet, true );
+ }
+ }
+ },
+
+ "": function(checkSet, part, isXML){
+ var nodeCheck,
+ doneName = done++,
+ checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test(part) ) {
+ part = part.toLowerCase();
+ nodeCheck = part;
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
+ },
+
+ "~": function( checkSet, part, isXML ) {
+ var nodeCheck,
+ doneName = done++,
+ checkFn = dirCheck;
+
+ if ( typeof part === "string" && !/\W/.test( part ) ) {
+ part = part.toLowerCase();
+ nodeCheck = part;
+ checkFn = dirNodeCheck;
+ }
+
+ checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
+ }
+ },
+
+ find: {
+ ID: function( match, context, isXML ) {
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+ // Check parentNode to catch when Blackberry 4.6 returns
+ // nodes that are no longer in the document #6963
+ return m && m.parentNode ? [m] : [];
+ }
+ },
+
+ NAME: function( match, context ) {
+ if ( typeof context.getElementsByName !== "undefined" ) {
+ var ret = [],
+ results = context.getElementsByName( match[1] );
+
+ for ( var i = 0, l = results.length; i < l; i++ ) {
+ if ( results[i].getAttribute("name") === match[1] ) {
+ ret.push( results[i] );
+ }
+ }
+
+ return ret.length === 0 ? null : ret;
+ }
+ },
+
+ TAG: function( match, context ) {
+ return context.getElementsByTagName( match[1] );
+ }
+ },
+ preFilter: {
+ CLASS: function( match, curLoop, inplace, result, not, isXML ) {
+ match = " " + match[1].replace(/\\/g, "") + " ";
+
+ if ( isXML ) {
+ return match;
+ }
+
+ for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
+ if ( elem ) {
+ if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) {
+ if ( !inplace ) {
+ result.push( elem );
+ }
+
+ } else if ( inplace ) {
+ curLoop[i] = false;
+ }
+ }
+ }
+
+ return false;
+ },
+
+ ID: function( match ) {
+ return match[1].replace(/\\/g, "");
+ },
+
+ TAG: function( match, curLoop ) {
+ return match[1].toLowerCase();
+ },
+
+ CHILD: function( match ) {
+ if ( match[1] === "nth" ) {
+ // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
+ var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
+ match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
+ !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
+
+ // calculate the numbers (first)n+(last) including if they are negative
+ match[2] = (test[1] + (test[2] || 1)) - 0;
+ match[3] = test[3] - 0;
+ }
+
+ // TODO: Move to normal caching system
+ match[0] = done++;
+
+ return match;
+ },
+
+ ATTR: function( match, curLoop, inplace, result, not, isXML ) {
+ var name = match[1].replace(/\\/g, "");
+
+ if ( !isXML && Expr.attrMap[name] ) {
+ match[1] = Expr.attrMap[name];
+ }
+
+ if ( match[2] === "~=" ) {
+ match[4] = " " + match[4] + " ";
+ }
+
+ return match;
+ },
+
+ PSEUDO: function( match, curLoop, inplace, result, not ) {
+ if ( match[1] === "not" ) {
+ // If we're dealing with a complex expression, or a simple one
+ if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
+ match[3] = Sizzle(match[3], null, null, curLoop);
+
+ } else {
+ var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
+
+ if ( !inplace ) {
+ result.push.apply( result, ret );
+ }
+
+ return false;
+ }
+
+ } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
+ return true;
+ }
+
+ return match;
+ },
+
+ POS: function( match ) {
+ match.unshift( true );
+
+ return match;
+ }
+ },
+
+ filters: {
+ enabled: function( elem ) {
+ return elem.disabled === false && elem.type !== "hidden";
+ },
+
+ disabled: function( elem ) {
+ return elem.disabled === true;
+ },
+
+ checked: function( elem ) {
+ return elem.checked === true;
+ },
+
+ selected: function( elem ) {
+ // Accessing this property makes selected-by-default
+ // options in Safari work properly
+ elem.parentNode.selectedIndex;
+
+ return elem.selected === true;
+ },
+
+ parent: function( elem ) {
+ return !!elem.firstChild;
+ },
+
+ empty: function( elem ) {
+ return !elem.firstChild;
+ },
+
+ has: function( elem, i, match ) {
+ return !!Sizzle( match[3], elem ).length;
+ },
+
+ header: function( elem ) {
+ return (/h\d/i).test( elem.nodeName );
+ },
+
+ text: function( elem ) {
+ return "text" === elem.type;
+ },
+ radio: function( elem ) {
+ return "radio" === elem.type;
+ },
+
+ checkbox: function( elem ) {
+ return "checkbox" === elem.type;
+ },
+
+ file: function( elem ) {
+ return "file" === elem.type;
+ },
+ password: function( elem ) {
+ return "password" === elem.type;
+ },
+
+ submit: function( elem ) {
+ return "submit" === elem.type;
+ },
+
+ image: function( elem ) {
+ return "image" === elem.type;
+ },
+
+ reset: function( elem ) {
+ return "reset" === elem.type;
+ },
+
+ button: function( elem ) {
+ return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
+ },
+
+ input: function( elem ) {
+ return (/input|select|textarea|button/i).test( elem.nodeName );
+ }
+ },
+ setFilters: {
+ first: function( elem, i ) {
+ return i === 0;
+ },
+
+ last: function( elem, i, match, array ) {
+ return i === array.length - 1;
+ },
+
+ even: function( elem, i ) {
+ return i % 2 === 0;
+ },
+
+ odd: function( elem, i ) {
+ return i % 2 === 1;
+ },
+
+ lt: function( elem, i, match ) {
+ return i < match[3] - 0;
+ },
+
+ gt: function( elem, i, match ) {
+ return i > match[3] - 0;
+ },
+
+ nth: function( elem, i, match ) {
+ return match[3] - 0 === i;
+ },
+
+ eq: function( elem, i, match ) {
+ return match[3] - 0 === i;
+ }
+ },
+ filter: {
+ PSEUDO: function( elem, match, i, array ) {
+ var name = match[1],
+ filter = Expr.filters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+
+ } else if ( name === "contains" ) {
+ return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
+
+ } else if ( name === "not" ) {
+ var not = match[3];
+
+ for ( var j = 0, l = not.length; j < l; j++ ) {
+ if ( not[j] === elem ) {
+ return false;
+ }
+ }
+
+ return true;
+
+ } else {
+ Sizzle.error( "Syntax error, unrecognized expression: " + name );
+ }
+ },
+
+ CHILD: function( elem, match ) {
+ var type = match[1],
+ node = elem;
+
+ switch ( type ) {
+ case "only":
+ case "first":
+ while ( (node = node.previousSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+
+ if ( type === "first" ) {
+ return true;
+ }
+
+ node = elem;
+
+ case "last":
+ while ( (node = node.nextSibling) ) {
+ if ( node.nodeType === 1 ) {
+ return false;
+ }
+ }
+
+ return true;
+
+ case "nth":
+ var first = match[2],
+ last = match[3];
+
+ if ( first === 1 && last === 0 ) {
+ return true;
+ }
+
+ var doneName = match[0],
+ parent = elem.parentNode;
+
+ if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
+ var count = 0;
+
+ for ( node = parent.firstChild; node; node = node.nextSibling ) {
+ if ( node.nodeType === 1 ) {
+ node.nodeIndex = ++count;
+ }
+ }
+
+ parent.sizcache = doneName;
+ }
+
+ var diff = elem.nodeIndex - last;
+
+ if ( first === 0 ) {
+ return diff === 0;
+
+ } else {
+ return ( diff % first === 0 && diff / first >= 0 );
+ }
+ }
+ },
+
+ ID: function( elem, match ) {
+ return elem.nodeType === 1 && elem.getAttribute("id") === match;
+ },
+
+ TAG: function( elem, match ) {
+ return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
+ },
+
+ CLASS: function( elem, match ) {
+ return (" " + (elem.className || elem.getAttribute("class")) + " ")
+ .indexOf( match ) > -1;
+ },
+
+ ATTR: function( elem, match ) {
+ var name = match[1],
+ result = Expr.attrHandle[ name ] ?
+ Expr.attrHandle[ name ]( elem ) :
+ elem[ name ] != null ?
+ elem[ name ] :
+ elem.getAttribute( name ),
+ value = result + "",
+ type = match[2],
+ check = match[4];
+
+ return result == null ?
+ type === "!=" :
+ type === "=" ?
+ value === check :
+ type === "*=" ?
+ value.indexOf(check) >= 0 :
+ type === "~=" ?
+ (" " + value + " ").indexOf(check) >= 0 :
+ !check ?
+ value && result !== false :
+ type === "!=" ?
+ value !== check :
+ type === "^=" ?
+ value.indexOf(check) === 0 :
+ type === "$=" ?
+ value.substr(value.length - check.length) === check :
+ type === "|=" ?
+ value === check || value.substr(0, check.length + 1) === check + "-" :
+ false;
+ },
+
+ POS: function( elem, match, i, array ) {
+ var name = match[2],
+ filter = Expr.setFilters[ name ];
+
+ if ( filter ) {
+ return filter( elem, i, match, array );
+ }
+ }
+ }
+};
+
+var origPOS = Expr.match.POS,
+ fescape = function(all, num){
+ return "\\" + (num - 0 + 1);
+ };
+
+for ( var type in Expr.match ) {
+ Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
+ Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
+}
+
+var makeArray = function( array, results ) {
+ array = Array.prototype.slice.call( array, 0 );
+
+ if ( results ) {
+ results.push.apply( results, array );
+ return results;
+ }
+
+ return array;
+};
+
+// Perform a simple check to determine if the browser is capable of
+// converting a NodeList to an array using builtin methods.
+// Also verifies that the returned array holds DOM nodes
+// (which is not the case in the Blackberry browser)
+try {
+ Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
+
+// Provide a fallback method if it does not work
+} catch( e ) {
+ makeArray = function( array, results ) {
+ var i = 0,
+ ret = results || [];
+
+ if ( toString.call(array) === "[object Array]" ) {
+ Array.prototype.push.apply( ret, array );
+
+ } else {
+ if ( typeof array.length === "number" ) {
+ for ( var l = array.length; i < l; i++ ) {
+ ret.push( array[i] );
+ }
+
+ } else {
+ for ( ; array[i]; i++ ) {
+ ret.push( array[i] );
+ }
+ }
+ }
+
+ return ret;
+ };
+}
+
+var sortOrder, siblingCheck;
+
+if ( document.documentElement.compareDocumentPosition ) {
+ sortOrder = function( a, b ) {
+ if ( a === b ) {
+ hasDuplicate = true;
+ return 0;
+ }
+
+ if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
+ return a.compareDocumentPosition ? -1 : 1;
+ }
+
+ return a.compareDocumentPosition(b) & 4 ? -1 : 1;
+ };
+
+} else {
+ sortOrder = function( a, b ) {
+ var al, bl,
+ ap = [],
+ bp = [],
+ aup = a.parentNode,
+ bup = b.parentNode,
+ cur = aup;
+
+ // The nodes are identical, we can exit early
+ if ( a === b ) {
+ hasDuplicate = true;
+ return 0;
+
+ // If the nodes are siblings (or identical) we can do a quick check
+ } else if ( aup === bup ) {
+ return siblingCheck( a, b );
+
+ // If no parents were found then the nodes are disconnected
+ } else if ( !aup ) {
+ return -1;
+
+ } else if ( !bup ) {
+ return 1;
+ }
+
+ // Otherwise they're somewhere else in the tree so we need
+ // to build up a full list of the parentNodes for comparison
+ while ( cur ) {
+ ap.unshift( cur );
+ cur = cur.parentNode;
+ }
+
+ cur = bup;
+
+ while ( cur ) {
+ bp.unshift( cur );
+ cur = cur.parentNode;
+ }
+
+ al = ap.length;
+ bl = bp.length;
+
+ // Start walking down the tree looking for a discrepancy
+ for ( var i = 0; i < al && i < bl; i++ ) {
+ if ( ap[i] !== bp[i] ) {
+ return siblingCheck( ap[i], bp[i] );
+ }
+ }
+
+ // We ended someplace up the tree so do a sibling check
+ return i === al ?
+ siblingCheck( a, bp[i], -1 ) :
+ siblingCheck( ap[i], b, 1 );
+ };
+
+ siblingCheck = function( a, b, ret ) {
+ if ( a === b ) {
+ return ret;
+ }
+
+ var cur = a.nextSibling;
+
+ while ( cur ) {
+ if ( cur === b ) {
+ return -1;
+ }
+
+ cur = cur.nextSibling;
+ }
+
+ return 1;
+ };
+}
+
+// Utility function for retreiving the text value of an array of DOM nodes
+Sizzle.getText = function( elems ) {
+ var ret = "", elem;
+
+ for ( var i = 0; elems[i]; i++ ) {
+ elem = elems[i];
+
+ // Get the text from text nodes and CDATA nodes
+ if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
+ ret += elem.nodeValue;
+
+ // Traverse everything else, except comment nodes
+ } else if ( elem.nodeType !== 8 ) {
+ ret += Sizzle.getText( elem.childNodes );
+ }
+ }
+
+ return ret;
+};
+
+// Check to see if the browser returns elements by name when
+// querying by getElementById (and provide a workaround)
+(function(){
+ // We're going to inject a fake input element with a specified name
+ var form = document.createElement("div"),
+ id = "script" + (new Date()).getTime(),
+ root = document.documentElement;
+
+ form.innerHTML = "";
+
+ // Inject it into the root element, check its status, and remove it quickly
+ root.insertBefore( form, root.firstChild );
+
+ // The workaround has to do additional checks after a getElementById
+ // Which slows things down for other browsers (hence the branching)
+ if ( document.getElementById( id ) ) {
+ Expr.find.ID = function( match, context, isXML ) {
+ if ( typeof context.getElementById !== "undefined" && !isXML ) {
+ var m = context.getElementById(match[1]);
+
+ return m ?
+ m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
+ [m] :
+ undefined :
+ [];
+ }
+ };
+
+ Expr.filter.ID = function( elem, match ) {
+ var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
+
+ return elem.nodeType === 1 && node && node.nodeValue === match;
+ };
+ }
+
+ root.removeChild( form );
+
+ // release memory in IE
+ root = form = null;
+})();
+
+(function(){
+ // Check to see if the browser returns only elements
+ // when doing getElementsByTagName("*")
+
+ // Create a fake element
+ var div = document.createElement("div");
+ div.appendChild( document.createComment("") );
+
+ // Make sure no comments are found
+ if ( div.getElementsByTagName("*").length > 0 ) {
+ Expr.find.TAG = function( match, context ) {
+ var results = context.getElementsByTagName( match[1] );
+
+ // Filter out possible comments
+ if ( match[1] === "*" ) {
+ var tmp = [];
+
+ for ( var i = 0; results[i]; i++ ) {
+ if ( results[i].nodeType === 1 ) {
+ tmp.push( results[i] );
+ }
+ }
+
+ results = tmp;
+ }
+
+ return results;
+ };
+ }
+
+ // Check to see if an attribute returns normalized href attributes
+ div.innerHTML = "";
+
+ if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
+ div.firstChild.getAttribute("href") !== "#" ) {
+
+ Expr.attrHandle.href = function( elem ) {
+ return elem.getAttribute( "href", 2 );
+ };
+ }
+
+ // release memory in IE
+ div = null;
+})();
+
+if ( document.querySelectorAll ) {
+ (function(){
+ var oldSizzle = Sizzle,
+ div = document.createElement("div"),
+ id = "__sizzle__";
+
+ div.innerHTML = "";
+
+ // Safari can't handle uppercase or unicode characters when
+ // in quirks mode.
+ if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
+ return;
+ }
+
+ Sizzle = function( query, context, extra, seed ) {
+ context = context || document;
+
+ // Make sure that attribute selectors are quoted
+ query = query.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
+
+ // Only use querySelectorAll on non-XML documents
+ // (ID selectors don't work in non-HTML documents)
+ if ( !seed && !Sizzle.isXML(context) ) {
+ if ( context.nodeType === 9 ) {
+ try {
+ return makeArray( context.querySelectorAll(query), extra );
+ } catch(qsaError) {}
+
+ // qSA works strangely on Element-rooted queries
+ // We can work around this by specifying an extra ID on the root
+ // and working up from there (Thanks to Andrew Dupont for the technique)
+ // IE 8 doesn't work on object elements
+ } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
+ var old = context.getAttribute( "id" ),
+ nid = old || id;
+
+ if ( !old ) {
+ context.setAttribute( "id", nid );
+ }
+
+ try {
+ return makeArray( context.querySelectorAll( "#" + nid + " " + query ), extra );
+
+ } catch(pseudoError) {
+ } finally {
+ if ( !old ) {
+ context.removeAttribute( "id" );
+ }
+ }
+ }
+ }
+
+ return oldSizzle(query, context, extra, seed);
+ };
+
+ for ( var prop in oldSizzle ) {
+ Sizzle[ prop ] = oldSizzle[ prop ];
+ }
+
+ // release memory in IE
+ div = null;
+ })();
+}
+
+(function(){
+ var html = document.documentElement,
+ matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector,
+ pseudoWorks = false;
+
+ try {
+ // This should fail with an exception
+ // Gecko does not error, returns false instead
+ matches.call( document.documentElement, "[test!='']:sizzle" );
+
+ } catch( pseudoError ) {
+ pseudoWorks = true;
+ }
+
+ if ( matches ) {
+ Sizzle.matchesSelector = function( node, expr ) {
+ // Make sure that attribute selectors are quoted
+ expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
+
+ if ( !Sizzle.isXML( node ) ) {
+ try {
+ if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
+ return matches.call( node, expr );
+ }
+ } catch(e) {}
+ }
+
+ return Sizzle(expr, null, null, [node]).length > 0;
+ };
+ }
+})();
+
+(function(){
+ var div = document.createElement("div");
+
+ div.innerHTML = "";
+
+ // Opera can't find a second classname (in 9.6)
+ // Also, make sure that getElementsByClassName actually exists
+ if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
+ return;
+ }
+
+ // Safari caches class attributes, doesn't catch changes (in 3.2)
+ div.lastChild.className = "e";
+
+ if ( div.getElementsByClassName("e").length === 1 ) {
+ return;
+ }
+
+ Expr.order.splice(1, 0, "CLASS");
+ Expr.find.CLASS = function( match, context, isXML ) {
+ if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
+ return context.getElementsByClassName(match[1]);
+ }
+ };
+
+ // release memory in IE
+ div = null;
+})();
+
+function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+
+ if ( elem ) {
+ var match = false;
+
+ elem = elem[dir];
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 && !isXML ){
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+
+ if ( elem.nodeName.toLowerCase() === cur ) {
+ match = elem;
+ break;
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
+ for ( var i = 0, l = checkSet.length; i < l; i++ ) {
+ var elem = checkSet[i];
+
+ if ( elem ) {
+ var match = false;
+
+ elem = elem[dir];
+
+ while ( elem ) {
+ if ( elem.sizcache === doneName ) {
+ match = checkSet[elem.sizset];
+ break;
+ }
+
+ if ( elem.nodeType === 1 ) {
+ if ( !isXML ) {
+ elem.sizcache = doneName;
+ elem.sizset = i;
+ }
+
+ if ( typeof cur !== "string" ) {
+ if ( elem === cur ) {
+ match = true;
+ break;
+ }
+
+ } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
+ match = elem;
+ break;
+ }
+ }
+
+ elem = elem[dir];
+ }
+
+ checkSet[i] = match;
+ }
+ }
+}
+
+if ( document.documentElement.contains ) {
+ Sizzle.contains = function( a, b ) {
+ return a !== b && (a.contains ? a.contains(b) : true);
+ };
+
+} else if ( document.documentElement.compareDocumentPosition ) {
+ Sizzle.contains = function( a, b ) {
+ return !!(a.compareDocumentPosition(b) & 16);
+ };
+
+} else {
+ Sizzle.contains = function() {
+ return false;
+ };
+}
+
+Sizzle.isXML = function( elem ) {
+ // documentElement is verified for cases where it doesn't yet exist
+ // (such as loading iframes in IE - #4833)
+ var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
+
+ return documentElement ? documentElement.nodeName !== "HTML" : false;
+};
+
+var posProcess = function( selector, context ) {
+ var match,
+ tmpSet = [],
+ later = "",
+ root = context.nodeType ? [context] : context;
+
+ // Position selectors must be done after the filter
+ // And so must :not(positional) so we move all PSEUDOs to the end
+ while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
+ later += match[0];
+ selector = selector.replace( Expr.match.PSEUDO, "" );
+ }
+
+ selector = Expr.relative[selector] ? selector + "*" : selector;
+
+ for ( var i = 0, l = root.length; i < l; i++ ) {
+ Sizzle( selector, root[i], tmpSet );
+ }
+
+ return Sizzle.filter( later, tmpSet );
+};
+
+// EXPOSE
+jQuery.find = Sizzle;
+jQuery.expr = Sizzle.selectors;
+jQuery.expr[":"] = jQuery.expr.filters;
+jQuery.unique = Sizzle.uniqueSort;
+jQuery.text = Sizzle.getText;
+jQuery.isXMLDoc = Sizzle.isXML;
+jQuery.contains = Sizzle.contains;
+
+
+})();
+
+
+var runtil = /Until$/,
+ rparentsprev = /^(?:parents|prevUntil|prevAll)/,
+ // Note: This RegExp should be improved, or likely pulled from Sizzle
+ rmultiselector = /,/,
+ isSimple = /^.[^:#\[\.,]*$/,
+ slice = Array.prototype.slice,
+ POS = jQuery.expr.match.POS;
+
+jQuery.fn.extend({
+ find: function( selector ) {
+ var ret = this.pushStack( "", "find", selector ),
+ length = 0;
+
+ for ( var i = 0, l = this.length; i < l; i++ ) {
+ length = ret.length;
+ jQuery.find( selector, this[i], ret );
+
+ if ( i > 0 ) {
+ // Make sure that the results are unique
+ for ( var n = length; n < ret.length; n++ ) {
+ for ( var r = 0; r < length; r++ ) {
+ if ( ret[r] === ret[n] ) {
+ ret.splice(n--, 1);
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return ret;
+ },
+
+ has: function( target ) {
+ var targets = jQuery( target );
+ return this.filter(function() {
+ for ( var i = 0, l = targets.length; i < l; i++ ) {
+ if ( jQuery.contains( this, targets[i] ) ) {
+ return true;
+ }
+ }
+ });
+ },
+
+ not: function( selector ) {
+ return this.pushStack( winnow(this, selector, false), "not", selector);
+ },
+
+ filter: function( selector ) {
+ return this.pushStack( winnow(this, selector, true), "filter", selector );
+ },
+
+ is: function( selector ) {
+ return !!selector && jQuery.filter( selector, this ).length > 0;
+ },
+
+ closest: function( selectors, context ) {
+ var ret = [], i, l, cur = this[0];
+
+ if ( jQuery.isArray( selectors ) ) {
+ var match, selector,
+ matches = {},
+ level = 1;
+
+ if ( cur && selectors.length ) {
+ for ( i = 0, l = selectors.length; i < l; i++ ) {
+ selector = selectors[i];
+
+ if ( !matches[selector] ) {
+ matches[selector] = jQuery.expr.match.POS.test( selector ) ?
+ jQuery( selector, context || this.context ) :
+ selector;
+ }
+ }
+
+ while ( cur && cur.ownerDocument && cur !== context ) {
+ for ( selector in matches ) {
+ match = matches[selector];
+
+ if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
+ ret.push({ selector: selector, elem: cur, level: level });
+ }
+ }
+
+ cur = cur.parentNode;
+ level++;
+ }
+ }
+
+ return ret;
+ }
+
+ var pos = POS.test( selectors ) ?
+ jQuery( selectors, context || this.context ) : null;
+
+ for ( i = 0, l = this.length; i < l; i++ ) {
+ cur = this[i];
+
+ while ( cur ) {
+ if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
+ ret.push( cur );
+ break;
+
+ } else {
+ cur = cur.parentNode;
+ if ( !cur || !cur.ownerDocument || cur === context ) {
+ break;
+ }
+ }
+ }
+ }
+
+ ret = ret.length > 1 ? jQuery.unique(ret) : ret;
+
+ return this.pushStack( ret, "closest", selectors );
+ },
+
+ // Determine the position of an element within
+ // the matched set of elements
+ index: function( elem ) {
+ if ( !elem || typeof elem === "string" ) {
+ return jQuery.inArray( this[0],
+ // If it receives a string, the selector is used
+ // If it receives nothing, the siblings are used
+ elem ? jQuery( elem ) : this.parent().children() );
+ }
+ // Locate the position of the desired element
+ return jQuery.inArray(
+ // If it receives a jQuery object, the first element is used
+ elem.jquery ? elem[0] : elem, this );
+ },
+
+ add: function( selector, context ) {
+ var set = typeof selector === "string" ?
+ jQuery( selector, context || this.context ) :
+ jQuery.makeArray( selector ),
+ all = jQuery.merge( this.get(), set );
+
+ return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
+ all :
+ jQuery.unique( all ) );
+ },
+
+ andSelf: function() {
+ return this.add( this.prevObject );
+ }
+});
+
+// A painfully simple check to see if an element is disconnected
+// from a document (should be improved, where feasible).
+function isDisconnected( node ) {
+ return !node || !node.parentNode || node.parentNode.nodeType === 11;
+}
+
+jQuery.each({
+ parent: function( elem ) {
+ var parent = elem.parentNode;
+ return parent && parent.nodeType !== 11 ? parent : null;
+ },
+ parents: function( elem ) {
+ return jQuery.dir( elem, "parentNode" );
+ },
+ parentsUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "parentNode", until );
+ },
+ next: function( elem ) {
+ return jQuery.nth( elem, 2, "nextSibling" );
+ },
+ prev: function( elem ) {
+ return jQuery.nth( elem, 2, "previousSibling" );
+ },
+ nextAll: function( elem ) {
+ return jQuery.dir( elem, "nextSibling" );
+ },
+ prevAll: function( elem ) {
+ return jQuery.dir( elem, "previousSibling" );
+ },
+ nextUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "nextSibling", until );
+ },
+ prevUntil: function( elem, i, until ) {
+ return jQuery.dir( elem, "previousSibling", until );
+ },
+ siblings: function( elem ) {
+ return jQuery.sibling( elem.parentNode.firstChild, elem );
+ },
+ children: function( elem ) {
+ return jQuery.sibling( elem.firstChild );
+ },
+ contents: function( elem ) {
+ return jQuery.nodeName( elem, "iframe" ) ?
+ elem.contentDocument || elem.contentWindow.document :
+ jQuery.makeArray( elem.childNodes );
+ }
+}, function( name, fn ) {
+ jQuery.fn[ name ] = function( until, selector ) {
+ var ret = jQuery.map( this, fn, until );
+
+ if ( !runtil.test( name ) ) {
+ selector = until;
+ }
+
+ if ( selector && typeof selector === "string" ) {
+ ret = jQuery.filter( selector, ret );
+ }
+
+ ret = this.length > 1 ? jQuery.unique( ret ) : ret;
+
+ if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
+ ret = ret.reverse();
+ }
+
+ return this.pushStack( ret, name, slice.call(arguments).join(",") );
+ };
+});
+
+jQuery.extend({
+ filter: function( expr, elems, not ) {
+ if ( not ) {
+ expr = ":not(" + expr + ")";
+ }
+
+ return elems.length === 1 ?
+ jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
+ jQuery.find.matches(expr, elems);
+ },
+
+ dir: function( elem, dir, until ) {
+ var matched = [],
+ cur = elem[ dir ];
+
+ while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
+ if ( cur.nodeType === 1 ) {
+ matched.push( cur );
+ }
+ cur = cur[dir];
+ }
+ return matched;
+ },
+
+ nth: function( cur, result, dir, elem ) {
+ result = result || 1;
+ var num = 0;
+
+ for ( ; cur; cur = cur[dir] ) {
+ if ( cur.nodeType === 1 && ++num === result ) {
+ break;
+ }
+ }
+
+ return cur;
+ },
+
+ sibling: function( n, elem ) {
+ var r = [];
+
+ for ( ; n; n = n.nextSibling ) {
+ if ( n.nodeType === 1 && n !== elem ) {
+ r.push( n );
+ }
+ }
+
+ return r;
+ }
+});
+
+// Implement the identical functionality for filter and not
+function winnow( elements, qualifier, keep ) {
+ if ( jQuery.isFunction( qualifier ) ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ var retVal = !!qualifier.call( elem, i, elem );
+ return retVal === keep;
+ });
+
+ } else if ( qualifier.nodeType ) {
+ return jQuery.grep(elements, function( elem, i ) {
+ return (elem === qualifier) === keep;
+ });
+
+ } else if ( typeof qualifier === "string" ) {
+ var filtered = jQuery.grep(elements, function( elem ) {
+ return elem.nodeType === 1;
+ });
+
+ if ( isSimple.test( qualifier ) ) {
+ return jQuery.filter(qualifier, filtered, !keep);
+ } else {
+ qualifier = jQuery.filter( qualifier, filtered );
+ }
+ }
+
+ return jQuery.grep(elements, function( elem, i ) {
+ return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
+ });
+}
+
+
+
+
+var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
+ rleadingWhitespace = /^\s+/,
+ rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
+ rtagName = /<([\w:]+)/,
+ rtbody = /\s]+\/)>/g,
+ wrapMap = {
+ option: [ 1, "" ],
+ legend: [ 1, "" ],
+ thead: [ 1, "
", "
" ],
+ tr: [ 2, "
", "
" ],
+ td: [ 3, "
", "
" ],
+ col: [ 2, "
", "
" ],
+ area: [ 1, "" ],
+ _default: [ 0, "", "" ]
+ };
+
+wrapMap.optgroup = wrapMap.option;
+wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
+wrapMap.th = wrapMap.td;
+
+// IE can't serialize and ';
+
+ $files = getFiles($h, $l, $t, $g, $f);
+
+ if (is_string($files))
+ printf($pattern, $files);
+ else {
+ $c = count($files)-1;
+ for($i=0; $i<=$c; $i++) {
+ if ($i)
+ echo ' ';
+ printf($pattern, $files[$i]);
+ if ($i != $c)
+ echo "\n";
+ }
+ }
+}
+
+// The function to check if anonymous mode is authorized
+function anonymousMode() {
+ if(isset($_GET['r']) && !empty($_GET['r']) && HOST_ANONYMOUS && (ANONYMOUS == 'on'))
+ return true;
+ else
+ return false;
+}
+
+// The function to quickly translate a string
+function _e($string) {
+ echo T_gettext($string);
+}
+
+// The function to check the encrypted mode
+function sslCheck() {
+ if(ENCRYPTION == 'on')
+ return true;
+ else
+ return false;
+}
+
+// The function to return the encrypted link
+function sslLink() {
+ // Using HTTPS?
+ if(isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on'))
+ $link = ''.T_('Unencrypted').'';
+
+ // Using HTTP?
+ else
+ $link = ''.T_('Encrypted').'';
+
+ return $link;
+}
+
+// The function to get the Jappix static URL
+function staticURL() {
+ // Check for HTTPS
+ $protocol = isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on') ? 'https' : 'http';
+
+ // Full URL
+ $url = $protocol.'://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
+
+ return $url;
+}
+
+// The function to get the Jappix location (only from Get API!)
+function staticLocation() {
+ // Filter the URL
+ return preg_replace('/((.+)\/)php\/get\.php(\S)+$/', '$1', staticURL());
+}
+
+// The function to include a translation file
+function includeTranslation($locale, $domain) {
+ T_setlocale(LC_MESSAGES, $locale);
+ T_bindtextdomain($domain, JAPPIX_BASE.'/lang');
+ T_bind_textdomain_codeset($domain, 'UTF-8');
+ T_textdomain($domain);
+}
+
+// The function to check the cache presence
+function hasCache($hash) {
+ if(file_exists(JAPPIX_BASE.'/store/cache/'.$hash.'.cache'))
+ return true;
+ else
+ return false;
+}
+
+// The function to check if developer mode is enabled
+function isDeveloper() {
+ if(DEVELOPER == 'on')
+ return true;
+ else
+ return false;
+}
+
+// The function to get a file extension
+function getFileExt($name) {
+ return strtolower(preg_replace('/^(.+)(\.)([^\.]+)$/i', '$3', $name));
+}
+
+// The function to get a file type
+function getFileType($ext) {
+ switch($ext) {
+ // Images
+ case 'jpg':
+ case 'jpeg':
+ case 'png':
+ case 'bmp':
+ case 'gif':
+ case 'tif':
+ case 'svg':
+ case 'psp':
+ case 'xcf':
+ $file_type = 'image';
+
+ break;
+
+ // Videos
+ case 'ogv':
+ case 'mkv':
+ case 'avi':
+ case 'mov':
+ case 'mp4':
+ case 'm4v':
+ case 'wmv':
+ case 'asf':
+ case 'mpg':
+ case 'mpeg':
+ case 'ogm':
+ case 'rmvb':
+ case 'rmv':
+ case 'qt':
+ case 'flv':
+ case 'ram':
+ case '3gp':
+ case 'avc':
+ $file_type = 'video';
+
+ break;
+
+ // Sounds
+ case 'oga':
+ case 'ogg':
+ case 'mka':
+ case 'flac':
+ case 'mp3':
+ case 'wav':
+ case 'm4a':
+ case 'wma':
+ case 'rmab':
+ case 'rma':
+ case 'bwf':
+ case 'aiff':
+ case 'caf':
+ case 'cda':
+ case 'atrac':
+ case 'vqf':
+ case 'au':
+ case 'aac':
+ case 'm3u':
+ case 'mid':
+ case 'mp2':
+ case 'snd':
+ case 'voc':
+ $file_type = 'audio';
+
+ break;
+
+ // Documents
+ case 'pdf':
+ case 'odt':
+ case 'ott':
+ case 'sxw':
+ case 'stw':
+ case 'ots':
+ case 'sxc':
+ case 'stc':
+ case 'sxi':
+ case 'sti':
+ case 'pot':
+ case 'odp':
+ case 'ods':
+ case 'doc':
+ case 'docx':
+ case 'docm':
+ case 'xls':
+ case 'xlsx':
+ case 'xlsm':
+ case 'xlt':
+ case 'ppt':
+ case 'pptx':
+ case 'pptm':
+ case 'pps':
+ case 'odg':
+ case 'otp':
+ case 'sxd':
+ case 'std':
+ case 'std':
+ case 'rtf':
+ case 'txt':
+ case 'htm':
+ case 'html':
+ case 'shtml':
+ case 'dhtml':
+ case 'mshtml':
+ $file_type = 'document';
+
+ break;
+
+ // Packages
+ case 'tgz':
+ case 'gz':
+ case 'tar':
+ case 'ar':
+ case 'cbz':
+ case 'jar':
+ case 'tar.7z':
+ case 'tar.bz2':
+ case 'tar.gz':
+ case 'tar.lzma':
+ case 'tar.xz':
+ case 'zip':
+ case 'xz':
+ case 'rar':
+ case 'bz':
+ case 'deb':
+ case 'rpm':
+ case '7z':
+ case 'ace':
+ case 'cab':
+ case 'arj':
+ case 'msi':
+ $file_type = 'package';
+
+ break;
+
+ // Others
+ default:
+ $file_type = 'other';
+
+ break;
+ }
+
+ return $file_type;
+}
+
+// The function to get the MIME type of a file
+function getFileMIME($path) {
+ $finfo = finfo_open(FILEINFO_MIME_TYPE);
+ $cmime = finfo_file($finfo, $path);
+ finfo_close($finfo);
+
+ return $cmime;
+}
+
+// The function to keep the current GET vars
+function keepGet($current, $no_get) {
+ // Get the HTTP GET vars
+ $request = $_SERVER['REQUEST_URI'];
+
+ if(strrpos($request, '?') === false)
+ $get = '';
+
+ else {
+ $uri = explode('?', $request);
+ $get = $uri[1];
+ }
+
+ // Remove the items we don't want here
+ $proper = str_replace('&', '&', $get);
+ $proper = preg_replace('/((^)|(&))(('.$current.'=)([^&]+))/i', '', $proper);
+
+ // Nothing at the end?
+ if(!$proper)
+ return '';
+
+ // We have no defined GET var
+ if($no_get) {
+ // Remove the first "&" if it appears
+ if(preg_match('/^(&(amp;)?)/i', $proper))
+ $proper = preg_replace('/^(&(amp;)?)/i', '', $proper);
+
+ // Add the first "?"
+ $proper = '?'.$proper;
+ }
+
+ // Add a first "&" if there is no one and no defined GET var
+ else if(!$no_get && (substr($proper, 0, 1) != '&') && (substr($proper, 0, 5) != '&'))
+ $proper = '&'.$proper;
+
+ return $proper;
+}
+
+// Escapes regex special characters for in-regex usage
+function escapeRegex($string) {
+ return preg_replace('/[-[\]{}()*+?.,\\^$|#]/', '\\$&', $string);
+}
+
+// Generates the security HTML code
+function securityHTML() {
+ return '
+
+
+
+
+ Jappix - Forbidden
+
+
+
+