diff --git a/.htaccess b/.htaccess
index 6f8ef27..6fef37a 100644
--- a/.htaccess
+++ b/.htaccess
@@ -7,8 +7,11 @@ RewriteEngine On
#RewriteRule ^fonts/glyphicons-halflings-regular\.woff$ lib/system/lib/bootstrap/lib/fonts/glyphicons-halflings-regular.woff$1 [L]
#RewriteRule ^fonts/glyphicons-halflings-regular\.woff2$ lib/system/lib/bootstrap/lib/fonts/glyphicons-halflings-regular.woff2$1 [L]
+RewriteRule ^invite/([^/]*)$ invite.php?code=$1
+RewriteRule ^invite$ invite.php$1
+
RewriteRule ^(.*)/fonts/fontawesome-webfont(.*)$ lib/font_awesome/lib/fonts/fontawesome-webfont$2 [L]
RewriteRule ^sai$ sai.php$1 [L]
-RewriteRule ^files/([^/]+)/([^/]+)$ api.php?call=files&cat=$1&id=$2 [L]
-RewriteRule ^cache/([^/]+)/([^/]+)$ api.php?call=cache&id=$1&ident=$2 [L]
\ No newline at end of file
+RewriteRule ^(.*)files/([^/]+)/([^/]+)$ api.php?call=files&cat=$2&id=$3 [L]
+RewriteRule ^(.*)cache/([^/]+)/([^/]+)$ api.php?call=cache&id=$2&ident=$3 [L]
\ No newline at end of file
diff --git a/democracy/api/api_democracy.php b/democracy/api/api_democracy.php
index b05946d..f60c11b 100644
--- a/democracy/api/api_democracy.php
+++ b/democracy/api/api_democracy.php
@@ -94,4 +94,29 @@ class api_democracy extends \SYSTEM\API\api_system {
\SQL\SUBSCRIBE_EMAIL_COUNT::Q1(array($email));
}
+
+ public static function call_beta($ios,$android,$email,$code){
+ $code_valid = self::validate_code($code);
+
+ if($code_valid){
+ $data = \SQL\BETA_EMAIL_FIND::Q1(array($email));
+ if(!$data){
+ \SQL\BETA_INSERT::QI(array($code,$email,$android,$ios));
+ } else {
+ if(!self::validate_code($data['code'])){
+ \SQL\BETA_DELETE::QI(array($email));
+ \SQL\BETA_INSERT::QI(array($code,$email,$android,$ios));
+ } else {
+ throw new ERROR('This EMail has already redeemed a Code');}
+ }
+ } else {
+ \SQL\BETA_INSERT::QI(array($code,$email,$android,$ios));
+ }
+
+ return \SYSTEM\LOG\JsonResult::ok();
+ }
+
+ public static function validate_code($code){
+ return \SQL\BETA_CODE_VALIDATE::Q1(array($code))['count'] !== 0 ? true: false;
+ }
}
\ No newline at end of file
diff --git a/democracy/api/sql/BETA_CODES_FIND.php b/democracy/api/sql/BETA_CODES_FIND.php
new file mode 100644
index 0000000..a48d161
--- /dev/null
+++ b/democracy/api/sql/BETA_CODES_FIND.php
@@ -0,0 +1,12 @@
+SERVERPATH(), $vars);
+ }
+}
\ No newline at end of file
diff --git a/democracy/page/default_invite/js/default_invite.js b/democracy/page/default_invite/js/default_invite.js
new file mode 100644
index 0000000..872a537
--- /dev/null
+++ b/democracy/page/default_invite/js/default_invite.js
@@ -0,0 +1,85 @@
+$(document).ready(function() {
+ if($('#code').attr('valid') === '1'){
+ $('#device').show();
+ } else {
+ $('#apply').show();
+ }
+
+ $('#apply_go').click(function(){
+ $('#apply').hide();
+ $('#device').show();
+ });
+ $('#select_ios').click(function(){
+ $('#device').hide();
+ $('#ios').show();
+ });
+ $('#select_android').click(function(){
+ $('#device').hide();
+ $('#android').show();
+ });
+ $('#android_go').click(function(){
+ var email = $('#googleid').val();
+ var code = $('#code').attr('code');
+ var android = 1;
+ var ios = 0;
+
+ if(!validateEmail(email)){
+ $('#googleid').addClass("blink-class");
+ $('#duplicate_android').hide();
+ } else {
+ $('#googleid').removeClass("blink-class");
+ $('#duplicate_android').hide();
+ register(email,code,ios,android,function(data){
+ if(data.status){
+ $('#android').hide();
+ $('#final_android').show();
+ } else {
+ $('#duplicate_android').show();
+ }
+ });
+ }
+ });
+ $('#ios_go').click(function(){
+ var email = $('#appleid').val();
+ var code = $('#code').attr('code');
+ var android = 0;
+ var ios = 1;
+
+ if(!validateEmail(email)){
+ $('#appleid').addClass("blink-class");
+ $('#duplicate_ios').hide();
+ } else {
+ $('#appleid').removeClass("blink-class");
+ $('#duplicate_ios').hide();
+ register(email,code,ios,android,function(data){
+ if(data.status){
+ $('#ios').hide();
+ $('#final_ios').show();
+ } else {
+ $('#duplicate_ios').show();
+ }
+ });
+ }
+ });
+});
+
+function register(email,code,ios,android, success){
+ $.ajax({
+ url: '../api.php',
+ type: 'GET',
+ dataType: 'JSON',
+ data: {
+ call: 'beta',
+ ios: ios,
+ android: android,
+ email: email,
+ code: code
+ },
+ success: success
+ });
+}
+
+function validateEmail(email) {
+ var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
+ return re.test(String(email).toLowerCase());
+}
\ No newline at end of file
diff --git a/democracy/page/default_invite/tpl/default_invite.tpl b/democracy/page/default_invite/tpl/default_invite.tpl
new file mode 100644
index 0000000..a7bb3dd
--- /dev/null
+++ b/democracy/page/default_invite/tpl/default_invite.tpl
@@ -0,0 +1,150 @@
+
+
+
+ ${title_start}
+
+
+ ${css}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
DEMOCRACY
+
prototyp_access
+
+
+ Als crowdmoderierte und politisch unabhängige
+ Plattform informiert die App DEMOCRACY über die
+ aktuellen Bundestagsabstimmungen und ermöglicht
+ den Nutzer*Innen eine eigene direkte Abstimmung
+
+
+
+ JETZT FÜR DEN PROTOTYP BEWERBEN
+
+
+
+
+
+
+
+
+
+
Bitte wähle Deine Plattform
+
+
+
+
+
Diese EMail scheint bereits registriert zu sein!
+
+
+ FREISCHALTUNG ANFORDERN
+
+
Bitte gib Deine Apple-ID ein
+
(Die AppStore-EMail-Adresse Deines Handys)
+
+
+
+
+
Diese EMail scheint bereits registriert zu sein!
+
+
+ FREISCHALTUNG ANFORDERN
+
+
Bitte gib Deine Google Play ID ein
+
(Die Google-EMail-Adresse Deines Handys)
+
+
+
+ Sobald Du im AppStore freigeschaltet wurdest, erhälst Du eine EMail mit einer genauen Anleitung von uns.
+
+
+
+ Du erhälst demnächst eine E-Mail von TestFlight
+ Öffne diese Mail, klicke den blauen Button View in TestFlight
+ Lade dir TestFlight im AppStore herunter
+ Öffne TestFlight und Drücke “Redeem”
+ Gib den Bestätigungscode, also z.B. QJHFFNDF ein und lade Dir DEMOCRACY herunter.
+ Öffne DEMOCRACY und leg los!
+
+
+
+
+
+ Sobald Du im PlayStore freigeschaltet wurdest, erhälst Du eine EMail mit einer genauen Anleitung von uns.
+
+
+
+ Du erhälst demnächst eine E-Mail von uns mit einem Bestätigungslink
+ Öffne diese Mail auf deinem Handy und folge dem Link
+ Drücke den Button ganz unten auf dem es heißt: Tester werden
+ Eine neue Ansicht lädt, drücke nun die App DEMOCRACY bei Google Play herunterladen.
+ Du wirst in den Google Play Store weitergeleitet und kannst die App dort herunterladen, öffnen und testen
+
+
+
+
+
+
+ ${js}
+
+
\ No newline at end of file
diff --git a/democracy/page/page_invite.php b/democracy/page/page_invite.php
new file mode 100644
index 0000000..c59a1be
--- /dev/null
+++ b/democracy/page/page_invite.php
@@ -0,0 +1,12 @@
+html($_escaped_fragment_);}
+}
\ No newline at end of file
diff --git a/democracy/sai/autoload.inc b/democracy/sai/autoload.inc
index 11bb2da..13a7d6c 100644
--- a/democracy/sai/autoload.inc
+++ b/democracy/sai/autoload.inc
@@ -1,3 +1,2 @@
SERVERPATH(),
+ (new \PSQL('/mysql/schema_beta.sql'))->SERVERPATH(),
+ (new \PSQL('/mysql/schema_beta_code.sql'))->SERVERPATH(),
(new \PSQL('/mysql/system_page.sql'))->SERVERPATH(),
(new \PSQL('/mysql/system_text.sql'))->SERVERPATH(),
(new \PSQL('/mysql/system_api.sql'))->SERVERPATH());
diff --git a/democracy/sql/mysql/schema_beta.sql b/democracy/sql/mysql/schema_beta.sql
new file mode 100644
index 0000000..d5fa8c4
--- /dev/null
+++ b/democracy/sql/mysql/schema_beta.sql
@@ -0,0 +1,10 @@
+CREATE TABLE `beta` (
+ `code` varchar(8) DEFAULT NULL,
+ `email` varchar(255) NOT NULL DEFAULT '',
+ `android` int(11) DEFAULT NULL,
+ `ios` int(11) DEFAULT NULL,
+ `redeemedAt` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
+ `storedAt` timestamp NULL DEFAULT NULL,
+ `emailedAt` timestamp NULL DEFAULT NULL,
+ PRIMARY KEY (`email`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
\ No newline at end of file
diff --git a/democracy/sql/mysql/schema_beta_code.sql b/democracy/sql/mysql/schema_beta_code.sql
new file mode 100644
index 0000000..5e5441b
--- /dev/null
+++ b/democracy/sql/mysql/schema_beta_code.sql
@@ -0,0 +1,6 @@
+CREATE TABLE `beta_code` (
+ `code` varchar(8) NOT NULL,
+ `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ `comment` varchar(255) DEFAULT NULL,
+ PRIMARY KEY (`code`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
\ No newline at end of file
diff --git a/democracy/sql/mysql/system_api.sql b/democracy/sql/mysql/system_api.sql
index 839a3cb..a56c6b0 100644
--- a/democracy/sql/mysql/system_api.sql
+++ b/democracy/sql/mysql/system_api.sql
@@ -1,2 +1,9 @@
REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (100, 0, 2, 10, 'send_mail_faq', 'data', 'JSON');
-REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (110, 0, 2, 10, 'send_subscribe', 'data', 'JSON');
\ No newline at end of file
+REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (110, 0, 2, 10, 'send_subscribe', 'data', 'JSON');
+
+REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (120, 0, 2, 10, 'beta', 'ios', 'BOOL');
+REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (121, 0, 2, 10, 'beta', 'android', 'BOOL');
+REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (122, 0, 2, 10, 'beta', 'email', 'EMAIL');
+REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (123, 0, 2, 10, 'beta', 'code', 'STRING');
+
+# REPLACE INTO `system_api` (`ID`, `group`, `type`, `parentID`, `parentValue`, `name`, `verify`) VALUES (100, 1, 3, -1, null, '_code', 'STRING');
\ No newline at end of file
diff --git a/invite.php b/invite.php
new file mode 100644
index 0000000..3b8f4a4
--- /dev/null
+++ b/invite.php
@@ -0,0 +1,9 @@
+