Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • fsini-informatik/fsfahrttool
  • kleemeis/fsfahrttool
2 results
Show changes
Showing
with 2746 additions and 1128 deletions
<?php
$invalidCharsRegEx = "/^[^0-9<>!?.::,#*@^_$\\\"'%;()&+]{2,50}$/"; // d©_©b
/**
* converts mail into safe for web format
* @param $mail - mail to convert
* @return mixed - converted mail
*/
function comm_convert_mail($mail){
return str_replace(array("@","."),array("&Oslash;", "&middot;"), $mail);
}
function comm_verbose($level, $text){
global $config_verbose_level;
if($config_verbose_level >= $level) {
if(is_array($text)){
echo "<pre>"; print_r($text); echo "</pre>";
} else
echo $text.'<br />';
}
}
function comm_from_mysqlDate($date){
return date('d.m.Y', strtotime($date));
}
function comm_get_possible_dates($db, $fid){
$dates = $db->get("fahrten", ["von", "bis"], ["fahrt_id" => $fid]);
$end = new DateTime($dates['bis']);
$period = new DatePeriod(
new DateTime($dates['von']),
new DateInterval('P1D'),
$end->modify( '+1 day' )
);
$ret = [];
foreach($period as $d){
array_push($ret, $d->format("d.m.Y"));
}
return $ret;
}
/*
* returns TRUE iff registration is allowed
*/
function comm_isopen_fid($db_handle, $fid){
$ret = comm_isopen_fid_helper($db_handle, $fid);
return $ret == 0;
}
/*
* returns value depending on registration status
* 0 = registration open (slots available)
* 1 = all slots taken -> waitlist open
* 2 = registration closed!
*/
function comm_isopen_fid_helper($db_handle, $fid){
comm_verbose(3,"checking if fid ". $fid . " is open");
$open = $db_handle->has('fahrten', ['AND' => ['fahrt_id'=>$fid, 'regopen'=>1]]);
if(!$open)
return 2;
$cnt = $db_handle->count("bachelor", ["AND"=>
["backstepped" => NULL,
"fahrt_id" => $fid]]);
$max = $db_handle->get("fahrten", "max_bachelor", ["fahrt_id" => $fid]);
$wl = $db_handle->count('waitlist', ['AND' =>
["transferred" => NULL,
"fahrt_id" => $fid]]);
comm_verbose(3,"cnt: ".$cnt.", max: ".$max.", open: ".($open ? "yes" : "no"));
if ( $cnt < $max && $wl == 0 )
return 0;
return 1;
}
function comm_generate_key($db_handle, $check, $conditions){
again:
$bytes = openssl_random_pseudo_bytes(8);
$hex = bin2hex($bytes);
comm_verbose(3,"generated hex for test: ".$hex);
foreach($check as $table => $col){
if($db_handle->has($table, array("AND"=>[$col => $hex]))) goto again;
}
comm_verbose(2,"generated hex: ".$hex);
return $hex;
}
/*
* sends mail
*
* first line of $cont is used as subject iff terminated by double backslash (\\)
* note that there should be no "\\" anywhere else in the string!!!
*
* returns true/false depending on success
*/
function comm_send_mail($db_handle, $addr, $cont, $from = NULL){
global $config_current_fahrt_id, $config_mailtag;
if(is_null($from))
$from = $db_handle->get("fahrten", "kontakt", array("fahrt_id"=>$config_current_fahrt_id));
$subj = "Wichtige Information";
$mess = $cont;
$tmp = explode("\\\\", $cont);
if(count($tmp)>1){
$subj = $tmp[0];
$mess = $tmp[1];
}
$headers = 'From: ' . $from . "\r\n" .
'Reply-To: ' . $from. "\r\n" .
'X-Mailer: PHP/' . phpversion();
comm_verbose(3, "sending mail... from: ".$from."<br/>to:".$addr."<br />subject: ".$subj."<br/>content:".$mess);
return mail($addr, $config_mailtag.$subj, $mess, $headers);
}
function comm_get_lang($lang, $replace){
global $config_basepath;
//require_once($config_basepath."/lang.php");
//echo $config_basepath."/lang.php";
global $$lang;
comm_verbose(3,"found lang variable: <br />".$$lang);
return str_replace(array_keys($replace), array_values($replace), $$lang);
}
<?php
require __DIR__.'/../config.inc.php';
require __DIR__.'/../lang.php';
require 'medoo.php';
require 'commons.php';
require 'soft_protect.php';
class Environment {
private static $__instance;
public $database;
public $config;
private $dangling_form_data;
public static function getEnv() {
if(self::$__instance == NULL) self::$__instance = new Environment();
return self::$__instance;
}
protected function __construct() {
global $config_db, $config_studitypen, $config_essen, $config_reisearten, $invalidCharsRegEx;
$this->database = new medoo(array(
'database_type' => $config_db["type"],
'database_name' => $config_db["name"],
'server' => $config_db["host"],
'username' => $config_db["user"],
'password' => $config_db["pass"]
));
$this->config = [
'studitypen' => $config_studitypen,
'essen' => $config_essen,
'reisearten' => $config_reisearten,
'invalidChars' => $invalidCharsRegEx
];
}
// signup method
// only waitlist
/**
* @returns TRUE iff regular registration is allowed
*/
public function isRegistrationOpen($fid) {
$ret = $this->getRegistrationState($fid);
return $ret === 0;
}
/**
* returns value depending on registration status
* 0 = registration open (slots available)
* 1 = all slots taken -> waitlist open
* 2 = registration closed!
*
* @param $fid (optional) to pass this parameter
* @returns int the state of the trip (see above)
*/
public function getRegistrationState($fid = NULL) {
if(is_null($fid)) $fid = $this->getSelectedTripId();
comm_verbose(3,"checking if fid ". $fid . " is open");
$open = $this->database->has('fahrten', ['AND' => ['fahrt_id'=>$fid, 'regopen'=>1]]);
if(!$open)
return 2;
$cnt = $this->database->count("bachelor", ["AND"=>
["backstepped" => NULL,
"fahrt_id" => $fid]]);
$max = $this->database->get("fahrten", "max_bachelor", ["fahrt_id" => $fid]);
$wl = $this->database->count('waitlist', ['AND' =>
["transferred" => NULL,
"fahrt_id" => $fid]]);
comm_verbose(3,"cnt: ".$cnt.", max: ".$max.", open: ".($open ? "yes" : "no"));
if ( $cnt < $max && $wl == 0 )
return 0;
return 1;
}
/**
* @return trip selected via $_REQUEST (or null)
*/
public function getSelectedTripId() {
if(isset($_REQUEST['fid']))
return (int) $_REQUEST['fid'];
else
return null;
}
/**
* @return bool true iff selected trip id is in the DB
*/
public function isSelectedTripIdValid() {
$valid = $this->database->has('fahrten',
['fahrt_id'=> $this->getSelectedTripId()]);
if(!$valid) comm_verbose(1,"FID nicht vorhanden!");
return $valid;
}
/**
* @return bool true iff user confirmed to enter waitlist
*/
public function isInWaitlistMode() {
return isset($_REQUEST['waitlist']);
}
/**
* Stash form data in this class (i.e. for edit)
* @param $data
*/
public function setDanglingFormData($data) {
$this->dangling_form_data = $data;
}
/**
* @return bool true iff formdata is received
*/
public function formDataReceived() {
return isset($_REQUEST['submit']) || isset($_REQUEST['storySubmit']);
}
public function getBachelor($bid = NULL) {
if(!is_null($this->dangling_form_data))
return $this->dangling_form_data;
if(is_null($bid))
return $this->getEmptyBachelor();
else
return $this->getBachelorFromDB($bid);
}
/**
* Given a registration id, return all parameters from the db
*
* @param $bid
* @return null or registration details
*/
public function getBachelorFromDB($bid) {
if(!is_null($bid) &&
$this->database->has('bachelor', ['bachelor_id' => $bid])){
$bachelor = $this->database->select('bachelor',
['forname','sirname','anday','abday','antyp','abtyp','pseudo',
'mehl','essen','public','virgin','studityp','comment'],
['bachelor_id'=>$bid]);
$bachelor['id'] = $bid;
return $bachelor[0];
}
return $this->getEmptyBachelor();
}
/**
* Will return an empty registration field
*
* @return array
*/
public function getEmptyBachelor() {
$possible_dates = comm_get_possible_dates($this->database, $this->getSelectedTripId());
return [
'forname' => "", 'sirname' => "",
'anday' => $possible_dates[0], 'abday' => $possible_dates[count($possible_dates)-1],
'antyp' => "", 'abtyp' => "",
'pseudo' => "", 'mehl' => "", 'essen' => "", 'public' => "",
'studityp' => "", 'comment'=>""
];
}
/**
* @param $data
* @return bool
*/
public function sendBachelorToDB($data) {
// === prepare data to insert ===
$data['anm_time'] = time();
$data['anday'] = date('Y-m-d', DateTime::createFromFormat('d.m.Y',$data['anday'])->getTimestamp());
$data['abday'] = date('Y-m-d', DateTime::createFromFormat('d.m.Y',$data['abday'])->getTimestamp());
if($this->isInWaitlistMode()){
if($this->getRegistrationState($data['fahrt_id'])==1){
// === prepare data to insert ===
$data['waitlist_id'] = comm_generate_key($this->database,
["bachelor" => "bachelor_id", "waitlist" => "waitlist_id"],
['fahrt_id'=>$data['fahrt_id']]);
// === insert data ===
$this->database->insert("waitlist", $data);
// === notify success ===
$this->feedbackHelper("lang_waitmail", $data['mehl'], $data['waitlist_id'], $data['fahrt_id']);
}
else return false;
} else {
// === prepare data to insert ===
$data['version'] = 1;
$data['bachelor_id'] = comm_generate_key($this->database,
["bachelor" => "bachelor_id"],
['fahrt_id'=>$data['fahrt_id']]);
// === check regstration full ===
$res = $this->database->get("fahrten",
["regopen", "max_bachelor"],
["fahrt_id" => $data['fahrt_id']]);
if (!$res || $res['regopen'] != "1")
return false;
$this->database->exec("LOCK TABLES fahrten, bachelor WRITE"); // count should not be calculated in two scripts at once
$insertOk = $this->isRegistrationOpen($data['fahrt_id']);
if ($insertOk)
$this->database->insert("bachelor", $data);
$this->database->exec("UNLOCK TABLES"); // insert is done now, count may be recalculated in other threads
if (!$insertOk)
return false; // full
// === notify success ===
$this->feedbackHelper("lang_regmail", $data['mehl'], $data['bachelor_id'], $data['fahrt_id']);
}
return true;
}
private function feedbackHelper($mail_lang, $to, $hash, $fid) {
global $config_baseurl;
$from = $this->database->get("fahrten", ["kontakt","leiter"], ["fahrt_id"=>$fid]);
$mail = comm_get_lang($mail_lang, array( "{{url}}" => $config_baseurl."status.php?hash=".$hash,
"{{organisator}}" => $from['leiter']));
comm_send_mail($this->database, $to, $mail, $from['kontakt']);
}
}
\ No newline at end of file
<?php
/*!
* Medoo database framework
* http://medoo.in
* Version 0.9.1.1
*
* Copyright 2013, Angel Lai
* https://medoo.in
* Version 1.7.8
*
* Copyright 2019, Angel Lai
* Released under the MIT license
*/
class medoo
namespace Medoo;
use PDO;
use Exception;
use PDOException;
use InvalidArgumentException;
class Raw {
public $map;
public $value;
}
class Medoo
{
protected $database_type = 'mysql';
public $pdo;
// For MySQL, MSSQL, Sybase
protected $server = 'localhost';
protected $type;
protected $username = 'username';
protected $prefix;
protected $password = 'password';
protected $statement;
// For SQLite
protected $database_file = '';
protected $dsn;
// Optional
protected $port = 3306;
protected $logs = [];
protected $charset = 'utf8';
protected $logging = false;
protected $database_name = '';
protected $debug_mode = false;
protected $option = array();
protected $guid = 0;
// Variable
protected $queryString;
protected $errorInfo = null;
public function __construct($options)
public function __construct(array $options)
{
try {
$commands = array();
if (isset($options[ 'database_type' ]))
{
$this->type = strtolower($options[ 'database_type' ]);
if (is_string($options))
if ($this->type === 'mariadb')
{
if (strtolower($this->database_type) == 'sqlite')
{
$this->database_file = $options;
}
else
{
$this->database_name = $options;
}
$this->type = 'mysql';
}
else
}
if (isset($options[ 'prefix' ]))
{
$this->prefix = $options[ 'prefix' ];
}
if (isset($options[ 'logging' ]) && is_bool($options[ 'logging' ]))
{
$this->logging = $options[ 'logging' ];
}
$option = isset($options[ 'option' ]) ? $options[ 'option' ] : [];
$commands = (isset($options[ 'command' ]) && is_array($options[ 'command' ])) ? $options[ 'command' ] : [];
switch ($this->type)
{
case 'mysql':
// Make MySQL using standard quoted identifier
$commands[] = 'SET SQL_MODE=ANSI_QUOTES';
break;
case 'mssql':
// Keep MSSQL QUOTED_IDENTIFIER is ON for standard quoting
$commands[] = 'SET QUOTED_IDENTIFIER ON';
// Make ANSI_NULLS is ON for NULL value
$commands[] = 'SET ANSI_NULLS ON';
break;
}
if (isset($options[ 'pdo' ]))
{
if (!$options[ 'pdo' ] instanceof PDO)
{
foreach ($options as $option => $value)
{
$this->$option = $value;
}
throw new InvalidArgumentException('Invalid PDO object supplied');
}
$type = strtolower($this->database_type);
$this->pdo = $options[ 'pdo' ];
foreach ($commands as $value)
{
$this->pdo->exec($value);
}
return;
}
if (isset($options[ 'dsn' ]))
{
if (is_array($options[ 'dsn' ]) && isset($options[ 'dsn' ][ 'driver' ]))
{
$attr = $options[ 'dsn' ];
}
else
{
throw new InvalidArgumentException('Invalid DSN option supplied');
}
}
else
{
if (
isset($this->port) &&
is_int($this->port * 1)
isset($options[ 'port' ]) &&
is_int($options[ 'port' ] * 1)
)
{
$port = $this->port;
$port = $options[ 'port' ];
}
$set_charset = "SET NAMES '" . $this->charset . "'";
$is_port = isset($port);
switch ($type)
switch ($this->type)
{
case 'mariadb':
$type = 'mysql';
case 'mysql':
// Make MySQL using standard quoted identifier
$commands[] = 'SET SQL_MODE=ANSI_QUOTES';
$attr = [
'driver' => 'mysql',
'dbname' => $options[ 'database_name' ]
];
if (isset($options[ 'socket' ]))
{
$attr[ 'unix_socket' ] = $options[ 'socket' ];
}
else
{
$attr[ 'host' ] = $options[ 'server' ];
if ($is_port)
{
$attr[ 'port' ] = $port;
}
}
break;
case 'pgsql':
$dsn = $type . ':host=' . $this->server . (isset($port) ? ';port=' . $port : '') . ';dbname=' . $this->database_name;
$commands[] = $set_charset;
$attr = [
'driver' => 'pgsql',
'host' => $options[ 'server' ],
'dbname' => $options[ 'database_name' ]
];
if ($is_port)
{
$attr[ 'port' ] = $port;
}
break;
case 'sybase':
$dsn = $type . ':host=' . $this->server . (isset($port) ? ',' . $port : '') . ';dbname=' . $this->database_name;
$commands[] = $set_charset;
$attr = [
'driver' => 'dblib',
'host' => $options[ 'server' ],
'dbname' => $options[ 'database_name' ]
];
if ($is_port)
{
$attr[ 'port' ] = $port;
}
break;
case 'oracle':
$attr = [
'driver' => 'oci',
'dbname' => $options[ 'server' ] ?
'//' . $options[ 'server' ] . ($is_port ? ':' . $port : ':1521') . '/' . $options[ 'database_name' ] :
$options[ 'database_name' ]
];
if (isset($options[ 'charset' ]))
{
$attr[ 'charset' ] = $options[ 'charset' ];
}
break;
case 'mssql':
$dsn = strpos(PHP_OS, 'WIN') !== false ?
'sqlsrv:server=' . $this->server . (isset($port) ? ',' . $port : '') . ';database=' . $this->database_name :
'dblib:host=' . $this->server . (isset($port) ? ':' . $port : '') . ';dbname=' . $this->database_name;
if (isset($options[ 'driver' ]) && $options[ 'driver' ] === 'dblib')
{
$attr = [
'driver' => 'dblib',
'host' => $options[ 'server' ] . ($is_port ? ':' . $port : ''),
'dbname' => $options[ 'database_name' ]
];
if (isset($options[ 'appname' ]))
{
$attr[ 'appname' ] = $options[ 'appname' ];
}
if (isset($options[ 'charset' ]))
{
$attr[ 'charset' ] = $options[ 'charset' ];
}
}
else
{
$attr = [
'driver' => 'sqlsrv',
'Server' => $options[ 'server' ] . ($is_port ? ',' . $port : ''),
'Database' => $options[ 'database_name' ]
];
if (isset($options[ 'appname' ]))
{
$attr[ 'APP' ] = $options[ 'appname' ];
}
// Keep MSSQL QUOTED_IDENTIFIER is ON for standard quoting
$commands[] = 'SET QUOTED_IDENTIFIER ON';
$commands[] = $set_charset;
$config = [
'ApplicationIntent',
'AttachDBFileName',
'Authentication',
'ColumnEncryption',
'ConnectionPooling',
'Encrypt',
'Failover_Partner',
'KeyStoreAuthentication',
'KeyStorePrincipalId',
'KeyStoreSecret',
'LoginTimeout',
'MultipleActiveResultSets',
'MultiSubnetFailover',
'Scrollable',
'TraceFile',
'TraceOn',
'TransactionIsolation',
'TransparentNetworkIPResolution',
'TrustServerCertificate',
'WSID',
];
foreach ($config as $value)
{
$keyname = strtolower(preg_replace(['/([a-z\d])([A-Z])/', '/([^_])([A-Z][a-z])/'], '$1_$2', $value));
if (isset($options[ $keyname ]))
{
$attr[ $value ] = $options[ $keyname ];
}
}
}
break;
case 'sqlite':
$dsn = $type . ':' . $this->database_file;
$this->username = null;
$this->password = null;
$attr = [
'driver' => 'sqlite',
$options[ 'database_file' ]
];
break;
}
}
if (!isset($attr))
{
throw new InvalidArgumentException('Incorrect connection options');
}
$driver = $attr[ 'driver' ];
if (!in_array($driver, PDO::getAvailableDrivers()))
{
throw new InvalidArgumentException("Unsupported PDO driver: {$driver}");
}
unset($attr[ 'driver' ]);
$stack = [];
foreach ($attr as $key => $value)
{
$stack[] = is_int($key) ? $value : $key . '=' . $value;
}
$dsn = $driver . ':' . implode(';', $stack);
if (
in_array($this->type, ['mysql', 'pgsql', 'sybase', 'mssql']) &&
isset($options[ 'charset' ])
)
{
$commands[] = "SET NAMES '{$options[ 'charset' ]}'" . (
$this->type === 'mysql' && isset($options[ 'collation' ]) ?
" COLLATE '{$options[ 'collation' ]}'" : ''
);
}
$this->dsn = $dsn;
try {
$this->pdo = new PDO(
$dsn,
$this->username,
$this->password,
$this->option
$dsn,
isset($options[ 'username' ]) ? $options[ 'username' ] : null,
isset($options[ 'password' ]) ? $options[ 'password' ] : null,
$option
);
foreach ($commands as $value)
{
$this->pdo->exec($value);
$this->pdo->exec($value);
}
}
catch (PDOException $e) {
//trigger_error("MySQL Connection was not established!\n".$e->getMessage(), E_USER_ERROR);
throw new Exception($e->getMessage());
throw new PDOException($e->getMessage());
}
}
public function query($query, $map = [])
{
$raw = $this->raw($query, $map);
$query = $this->buildRaw($raw, $map);
return $this->exec($query, $map);
}
public function exec($query, $map = [])
{
$this->statement = null;
if ($this->debug_mode)
{
echo $this->generate($query, $map);
$this->debug_mode = false;
return false;
}
if ($this->logging)
{
$this->logs[] = [$query, $map];
}
else
{
$this->logs = [[$query, $map]];
}
$statement = $this->pdo->prepare($query);
if (!$statement)
{
$this->errorInfo = $this->pdo->errorInfo();
$this->statement = null;
return false;
}
$this->statement = $statement;
foreach ($map as $key => $value)
{
$statement->bindValue($key, $value[ 0 ], $value[ 1 ]);
}
$execute = $statement->execute();
$this->errorInfo = $statement->errorInfo();
if (!$execute)
{
$this->statement = null;
}
return $statement;
}
protected function generate($query, $map)
{
$identifier = [
'mysql' => '`$1`',
'mssql' => '[$1]'
];
$query = preg_replace(
'/"([a-zA-Z0-9_]+)"/i',
isset($identifier[ $this->type ]) ? $identifier[ $this->type ] : '"$1"',
$query
);
foreach ($map as $key => $value)
{
if ($value[ 1 ] === PDO::PARAM_STR)
{
$replace = $this->quote($value[ 0 ]);
}
elseif ($value[ 1 ] === PDO::PARAM_NULL)
{
$replace = 'NULL';
}
elseif ($value[ 1 ] === PDO::PARAM_LOB)
{
$replace = '{LOB_DATA}';
}
else
{
$replace = $value[ 0 ];
}
$query = str_replace($key, $replace, $query);
}
return $query;
}
public static function raw($string, $map = [])
{
$raw = new Raw();
$raw->map = $map;
$raw->value = $string;
return $raw;
}
public function query($query)
protected function isRaw($object)
{
$this->queryString = $query;
comm_verbose(4,$query);
return $this->pdo->query($query);
return $object instanceof Raw;
}
public function exec($query)
protected function buildRaw($raw, &$map)
{
$this->queryString = $query;
comm_verbose(4,$query);
return $this->pdo->exec($query);
if (!$this->isRaw($raw))
{
return false;
}
$query = preg_replace_callback(
'/((FROM|TABLE|INTO|UPDATE)\s*)?\<([a-zA-Z0-9_\.]+)\>/i',
function ($matches)
{
if (!empty($matches[ 2 ]))
{
return $matches[ 2 ] . ' ' . $this->tableQuote($matches[ 3 ]);
}
return $this->columnQuote($matches[ 3 ]);
},
$raw->value);
$raw_map = $raw->map;
if (!empty($raw_map))
{
foreach ($raw_map as $key => $value)
{
$map[ $key ] = $this->typeMap($value, gettype($value));
}
}
return $query;
}
public function quote($string)
......@@ -146,550 +475,1373 @@ class medoo
return $this->pdo->quote($string);
}
protected function column_quote($string)
protected function tableQuote($table)
{
if (!preg_match('/^[a-zA-Z0-9_]+$/i', $table))
{
throw new InvalidArgumentException("Incorrect table name \"$table\"");
}
return '"' . $this->prefix . $table . '"';
}
protected function mapKey()
{
return ':MeDoO_' . $this->guid++ . '_mEdOo';
}
protected function typeMap($value, $type)
{
$map = [
'NULL' => PDO::PARAM_NULL,
'integer' => PDO::PARAM_INT,
'double' => PDO::PARAM_STR,
'boolean' => PDO::PARAM_BOOL,
'string' => PDO::PARAM_STR,
'object' => PDO::PARAM_STR,
'resource' => PDO::PARAM_LOB
];
if ($type === 'boolean')
{
$value = ($value ? '1' : '0');
}
elseif ($type === 'NULL')
{
$value = null;
}
return [$value, $map[ $type ]];
}
protected function columnQuote($string)
{
return '"' . str_replace('.', '"."', $string) . '"';
if (!preg_match('/^[a-zA-Z0-9_]+(\.?[a-zA-Z0-9_]+)?$/i', $string))
{
throw new InvalidArgumentException("Incorrect column name \"$string\"");
}
if (strpos($string, '.') !== false)
{
return '"' . $this->prefix . str_replace('.', '"."', $string) . '"';
}
return '"' . $string . '"';
}
protected function column_push($columns)
protected function columnPush(&$columns, &$map, $root, $is_join = false)
{
if ($columns == '*')
if ($columns === '*')
{
return $columns;
}
$stack = [];
if (is_string($columns))
{
$columns = array($columns);
$columns = [$columns];
}
$stack = array();
foreach ($columns as $key => $value)
{
preg_match('/([a-zA-Z0-9_\-\.]*)\s*\(([a-zA-Z0-9_\-]*)\)/i', $value, $match);
if (!is_int($key) && is_array($value) && $root && count(array_keys($columns)) === 1)
{
$stack[] = $this->columnQuote($key);
if (
isset($match[1]) &&
isset($match[2])
)
$stack[] = $this->columnPush($value, $map, false, $is_join);
}
elseif (is_array($value))
{
array_push($stack, $this->column_quote( $match[1] ) . ' AS ' . $this->column_quote( $match[2] ));
$stack[] = $this->columnPush($value, $map, false, $is_join);
}
else
elseif (!is_int($key) && $raw = $this->buildRaw($value, $map))
{
preg_match('/(?<column>[a-zA-Z0-9_\.]+)(\s*\[(?<type>(String|Bool|Int|Number))\])?/i', $key, $match);
$stack[] = $raw . ' AS ' . $this->columnQuote($match[ 'column' ]);
}
elseif (is_int($key) && is_string($value))
{
array_push($stack, $this->column_quote( $value ));
if ($is_join && strpos($value, '*') !== false)
{
throw new InvalidArgumentException('Cannot use table.* to select all columns while joining table');
}
preg_match('/(?<column>[a-zA-Z0-9_\.]+)(?:\s*\((?<alias>[a-zA-Z0-9_]+)\))?(?:\s*\[(?<type>(?:String|Bool|Int|Number|Object|JSON))\])?/i', $value, $match);
if (!empty($match[ 'alias' ]))
{
$stack[] = $this->columnQuote($match[ 'column' ]) . ' AS ' . $this->columnQuote($match[ 'alias' ]);
$columns[ $key ] = $match[ 'alias' ];
if (!empty($match[ 'type' ]))
{
$columns[ $key ] .= ' [' . $match[ 'type' ] . ']';
}
}
else
{
$stack[] = $this->columnQuote($match[ 'column' ]);
}
}
}
return implode($stack, ',');
return implode(',', $stack);
}
protected function array_quote($array)
protected function arrayQuote($array)
{
$temp = array();
$stack = [];
foreach ($array as $value)
{
$temp[] = is_int($value) ? $value : $this->pdo->quote($value);
$stack[] = is_int($value) ? $value : $this->pdo->quote($value);
}
return implode($temp, ',');
return implode(',', $stack);
}
protected function inner_conjunct($data, $conjunctor, $outer_conjunctor)
protected function innerConjunct($data, $map, $conjunctor, $outer_conjunctor)
{
$haystack = array();
$stack = [];
foreach ($data as $value)
{
$haystack[] = '(' . $this->data_implode($value, $conjunctor) . ')';
$stack[] = '(' . $this->dataImplode($value, $map, $conjunctor) . ')';
}
return implode($outer_conjunctor . ' ', $haystack);
return implode($outer_conjunctor . ' ', $stack);
}
protected function data_implode($data, $conjunctor, $outer_conjunctor = null)
protected function dataImplode($data, &$map, $conjunctor)
{
$wheres = array();
$stack = [];
foreach ($data as $key => $value)
{
$type = gettype($value);
if (
$type === 'array' &&
preg_match("/^(AND|OR)(\s+#.*)?$/", $key, $relation_match)
)
{
$relationship = $relation_match[ 1 ];
$stack[] = $value !== array_keys(array_keys($value)) ?
'(' . $this->dataImplode($value, $map, ' ' . $relationship) . ')' :
'(' . $this->innerConjunct($value, $map, ' ' . $relationship, $conjunctor) . ')';
continue;
}
$map_key = $this->mapKey();
if (
($key == 'AND' || $key == 'OR') &&
is_array($value)
is_int($key) &&
preg_match('/([a-zA-Z0-9_\.]+)\[(?<operator>\>\=?|\<\=?|\!?\=)\]([a-zA-Z0-9_\.]+)/i', $value, $match)
)
{
$wheres[] = 0 !== count(array_diff_key($value, array_keys(array_keys($value)))) ?
'(' . $this->data_implode($value, ' ' . $key) . ')' :
'(' . $this->inner_conjunct($value, ' ' . $key, $conjunctor) . ')';
$stack[] = $this->columnQuote($match[ 1 ]) . ' ' . $match[ 'operator' ] . ' ' . $this->columnQuote($match[ 3 ]);
}
else
{
preg_match('/([\w\.]+)(\[(\>|\>\=|\<|\<\=|\!|\<\>)\])?/i', $key, $match);
if (isset($match[3]))
preg_match('/([a-zA-Z0-9_\.]+)(\[(?<operator>\>\=?|\<\=?|\!|\<\>|\>\<|\!?~|REGEXP)\])?/i', $key, $match);
$column = $this->columnQuote($match[ 1 ]);
if (isset($match[ 'operator' ]))
{
if ($match[3] == '')
$operator = $match[ 'operator' ];
if (in_array($operator, ['>', '>=', '<', '<=']))
{
$wheres[] = $this->column_quote($match[1]) . ' ' . $match[3] . '= ' . $this->quote($value);
$condition = $column . ' ' . $operator . ' ';
if (is_numeric($value))
{
$condition .= $map_key;
$map[ $map_key ] = [$value, is_float($value) ? PDO::PARAM_STR : PDO::PARAM_INT];
}
elseif ($raw = $this->buildRaw($value, $map))
{
$condition .= $raw;
}
else
{
$condition .= $map_key;
$map[ $map_key ] = [$value, PDO::PARAM_STR];
}
$stack[] = $condition;
}
elseif ($match[3] == '!')
elseif ($operator === '!')
{
$column = $this->column_quote($match[1]);
switch (gettype($value))
switch ($type)
{
case 'NULL':
$wheres[] = $column . ' IS NOT NULL';
$stack[] = $column . ' IS NOT NULL';
break;
case 'array':
$wheres[] = $column . ' NOT IN (' . $this->array_quote($value) . ')';
$placeholders = [];
foreach ($value as $index => $item)
{
$stack_key = $map_key . $index . '_i';
$placeholders[] = $stack_key;
$map[ $stack_key ] = $this->typeMap($item, gettype($item));
}
$stack[] = $column . ' NOT IN (' . implode(', ', $placeholders) . ')';
break;
case 'integer':
case 'double':
$wheres[] = $column . ' != ' . $value;
case 'object':
if ($raw = $this->buildRaw($value, $map))
{
$stack[] = $column . ' != ' . $raw;
}
break;
case 'integer':
case 'double':
case 'boolean':
case 'string':
$wheres[] = $column . ' != ' . $this->quote($value);
$stack[] = $column . ' != ' . $map_key;
$map[ $map_key ] = $this->typeMap($value, $type);
break;
}
}
else
elseif ($operator === '~' || $operator === '!~')
{
if ($match[3] == '<>')
if ($type !== 'array')
{
$value = [ $value ];
}
$connector = ' OR ';
$data = array_values($value);
if (is_array($data[ 0 ]))
{
if (is_array($value))
if (isset($value[ 'AND' ]) || isset($value[ 'OR' ]))
{
if (is_numeric($value[0]) && is_numeric($value[1]))
{
$wheres[] = $this->column_quote($match[1]) . ' BETWEEN ' . $value[0] . ' AND ' . $value[1];
}
else
{
$wheres[] = $this->column_quote($match[1]) . ' BETWEEN ' . $this->quote($value[0]) . ' AND ' . $this->quote($value[1]);
}
$connector = ' ' . array_keys($value)[ 0 ] . ' ';
$value = $data[ 0 ];
}
}
else
$like_clauses = [];
foreach ($value as $index => $item)
{
if (is_numeric($value))
$item = strval($item);
if (!preg_match('/(\[.+\]|[\*\?\!\%#^-_]|%.+|.+%)/', $item))
{
$wheres[] = $this->column_quote($match[1]) . ' ' . $match[3] . ' ' . $value;
$item = '%' . $item . '%';
}
else
{
$datetime = strtotime($value);
if ($datetime)
{
$wheres[] = $this->column_quote($match[1]) . ' ' . $match[3] . ' ' . $this->quote(date('Y-m-d H:i:s', $datetime));
}
$like_clauses[] = $column . ($operator === '!~' ? ' NOT' : '') . ' LIKE ' . $map_key . 'L' . $index;
$map[ $map_key . 'L' . $index ] = [$item, PDO::PARAM_STR];
}
$stack[] = '(' . implode($connector, $like_clauses) . ')';
}
elseif ($operator === '<>' || $operator === '><')
{
if ($type === 'array')
{
if ($operator === '><')
{
$column .= ' NOT';
}
$stack[] = '(' . $column . ' BETWEEN ' . $map_key . 'a AND ' . $map_key . 'b)';
$data_type = (is_numeric($value[ 0 ]) && is_numeric($value[ 1 ])) ? PDO::PARAM_INT : PDO::PARAM_STR;
$map[ $map_key . 'a' ] = [$value[ 0 ], $data_type];
$map[ $map_key . 'b' ] = [$value[ 1 ], $data_type];
}
}
elseif ($operator === 'REGEXP')
{
$stack[] = $column . ' REGEXP ' . $map_key;
$map[ $map_key ] = [$value, PDO::PARAM_STR];
}
}
else
{
if (is_int($key))
switch ($type)
{
$wheres[] = $this->quote($value);
case 'NULL':
$stack[] = $column . ' IS NULL';
break;
case 'array':
$placeholders = [];
foreach ($value as $index => $item)
{
$stack_key = $map_key . $index . '_i';
$placeholders[] = $stack_key;
$map[ $stack_key ] = $this->typeMap($item, gettype($item));
}
$stack[] = $column . ' IN (' . implode(', ', $placeholders) . ')';
break;
case 'object':
if ($raw = $this->buildRaw($value, $map))
{
$stack[] = $column . ' = ' . $raw;
}
break;
case 'integer':
case 'double':
case 'boolean':
case 'string':
$stack[] = $column . ' = ' . $map_key;
$map[ $map_key ] = $this->typeMap($value, $type);
break;
}
}
}
}
return implode($conjunctor . ' ', $stack);
}
protected function whereClause($where, &$map)
{
$where_clause = '';
if (is_array($where))
{
$where_keys = array_keys($where);
$conditions = array_diff_key($where, array_flip(
['GROUP', 'ORDER', 'HAVING', 'LIMIT', 'LIKE', 'MATCH']
));
if (!empty($conditions))
{
$where_clause = ' WHERE ' . $this->dataImplode($conditions, $map, ' AND');
}
if (isset($where[ 'MATCH' ]) && $this->type === 'mysql')
{
$MATCH = $where[ 'MATCH' ];
if (is_array($MATCH) && isset($MATCH[ 'columns' ], $MATCH[ 'keyword' ]))
{
$mode = '';
$mode_array = [
'natural' => 'IN NATURAL LANGUAGE MODE',
'natural+query' => 'IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION',
'boolean' => 'IN BOOLEAN MODE',
'query' => 'WITH QUERY EXPANSION'
];
if (isset($MATCH[ 'mode' ], $mode_array[ $MATCH[ 'mode' ] ]))
{
$mode = ' ' . $mode_array[ $MATCH[ 'mode' ] ];
}
$columns = implode(', ', array_map([$this, 'columnQuote'], $MATCH[ 'columns' ]));
$map_key = $this->mapKey();
$map[ $map_key ] = [$MATCH[ 'keyword' ], PDO::PARAM_STR];
$where_clause .= ($where_clause !== '' ? ' AND ' : ' WHERE') . ' MATCH (' . $columns . ') AGAINST (' . $map_key . $mode . ')';
}
}
if (isset($where[ 'GROUP' ]))
{
$GROUP = $where[ 'GROUP' ];
if (is_array($GROUP))
{
$stack = [];
foreach ($GROUP as $column => $value)
{
$stack[] = $this->columnQuote($value);
}
$where_clause .= ' GROUP BY ' . implode(',', $stack);
}
elseif ($raw = $this->buildRaw($GROUP, $map))
{
$where_clause .= ' GROUP BY ' . $raw;
}
else
{
$where_clause .= ' GROUP BY ' . $this->columnQuote($GROUP);
}
if (isset($where[ 'HAVING' ]))
{
if ($raw = $this->buildRaw($where[ 'HAVING' ], $map))
{
$where_clause .= ' HAVING ' . $raw;
}
else
{
$column = $this->column_quote($match[1]);
$where_clause .= ' HAVING ' . $this->dataImplode($where[ 'HAVING' ], $map, ' AND');
}
}
}
if (isset($where[ 'ORDER' ]))
{
$ORDER = $where[ 'ORDER' ];
switch (gettype($value))
if (is_array($ORDER))
{
$stack = [];
foreach ($ORDER as $column => $value)
{
if (is_array($value))
{
case 'NULL':
$wheres[] = $column . ' IS NULL';
break;
$stack[] = 'FIELD(' . $this->columnQuote($column) . ', ' . $this->arrayQuote($value) . ')';
}
elseif ($value === 'ASC' || $value === 'DESC')
{
$stack[] = $this->columnQuote($column) . ' ' . $value;
}
elseif (is_int($column))
{
$stack[] = $this->columnQuote($value);
}
}
case 'array':
$wheres[] = $column . ' IN (' . $this->array_quote($value) . ')';
break;
$where_clause .= ' ORDER BY ' . implode(',', $stack);
}
elseif ($raw = $this->buildRaw($ORDER, $map))
{
$where_clause .= ' ORDER BY ' . $raw;
}
else
{
$where_clause .= ' ORDER BY ' . $this->columnQuote($ORDER);
}
case 'integer':
case 'double':
$wheres[] = $column . ' = ' . $value;
break;
if (
isset($where[ 'LIMIT' ]) &&
in_array($this->type, ['oracle', 'mssql'])
)
{
$LIMIT = $where[ 'LIMIT' ];
case 'string':
$wheres[] = $column . ' = ' . $this->quote($value);
break;
if (is_numeric($LIMIT))
{
$LIMIT = [0, $LIMIT];
}
if (
is_array($LIMIT) &&
is_numeric($LIMIT[ 0 ]) &&
is_numeric($LIMIT[ 1 ])
)
{
$where_clause .= ' OFFSET ' . $LIMIT[ 0 ] . ' ROWS FETCH NEXT ' . $LIMIT[ 1 ] . ' ROWS ONLY';
}
}
}
if (isset($where[ 'LIMIT' ]) && !in_array($this->type, ['oracle', 'mssql']))
{
$LIMIT = $where[ 'LIMIT' ];
if (is_numeric($LIMIT))
{
$where_clause .= ' LIMIT ' . $LIMIT;
}
elseif (
is_array($LIMIT) &&
is_numeric($LIMIT[ 0 ]) &&
is_numeric($LIMIT[ 1 ])
)
{
$where_clause .= ' LIMIT ' . $LIMIT[ 1 ] . ' OFFSET ' . $LIMIT[ 0 ];
}
}
}
elseif ($raw = $this->buildRaw($where, $map))
{
$where_clause .= ' ' . $raw;
}
return $where_clause;
}
protected function selectContext($table, &$map, $join, &$columns = null, $where = null, $column_fn = null)
{
preg_match('/(?<table>[a-zA-Z0-9_]+)\s*\((?<alias>[a-zA-Z0-9_]+)\)/i', $table, $table_match);
if (isset($table_match[ 'table' ], $table_match[ 'alias' ]))
{
$table = $this->tableQuote($table_match[ 'table' ]);
$table_query = $table . ' AS ' . $this->tableQuote($table_match[ 'alias' ]);
}
else
{
$table = $this->tableQuote($table);
$table_query = $table;
}
$is_join = false;
$join_key = is_array($join) ? array_keys($join) : null;
if (
isset($join_key[ 0 ]) &&
strpos($join_key[ 0 ], '[') === 0
)
{
$is_join = true;
$table_query .= ' ' . $this->buildJoin($table, $join);
}
else
{
if (is_null($columns))
{
if (
!is_null($where) ||
(is_array($join) && isset($column_fn))
)
{
$where = $join;
$columns = null;
}
else
{
$where = null;
$columns = $join;
}
}
else
{
$where = $columns;
$columns = $join;
}
}
if (isset($column_fn))
{
if ($column_fn === 1)
{
$column = '1';
if (is_null($where))
{
$where = $columns;
}
}
elseif ($raw = $this->buildRaw($column_fn, $map))
{
$column = $raw;
}
else
{
if (empty($columns) || $this->isRaw($columns))
{
$columns = '*';
$where = $join;
}
$column = $column_fn . '(' . $this->columnPush($columns, $map, true) . ')';
}
}
else
{
$column = $this->columnPush($columns, $map, true, $is_join);
}
return 'SELECT ' . $column . ' FROM ' . $table_query . $this->whereClause($where, $map);
}
protected function buildJoin($table, $join)
{
$table_join = [];
$join_array = [
'>' => 'LEFT',
'<' => 'RIGHT',
'<>' => 'FULL',
'><' => 'INNER'
];
foreach($join as $sub_table => $relation)
{
preg_match('/(\[(?<join>\<\>?|\>\<?)\])?(?<table>[a-zA-Z0-9_]+)\s?(\((?<alias>[a-zA-Z0-9_]+)\))?/', $sub_table, $match);
if ($match[ 'join' ] !== '' && $match[ 'table' ] !== '')
{
if (is_string($relation))
{
$relation = 'USING ("' . $relation . '")';
}
if (is_array($relation))
{
// For ['column1', 'column2']
if (isset($relation[ 0 ]))
{
$relation = 'USING ("' . implode('", "', $relation) . '")';
}
else
{
$joins = [];
foreach ($relation as $key => $value)
{
$joins[] = (
strpos($key, '.') > 0 ?
// For ['tableB.column' => 'column']
$this->columnQuote($key) :
// For ['column1' => 'column2']
$table . '."' . $key . '"'
) .
' = ' .
$this->tableQuote(isset($match[ 'alias' ]) ? $match[ 'alias' ] : $match[ 'table' ]) . '."' . $value . '"';
}
$relation = 'ON ' . implode(' AND ', $joins);
}
}
$table_name = $this->tableQuote($match[ 'table' ]) . ' ';
if (isset($match[ 'alias' ]))
{
$table_name .= 'AS ' . $this->tableQuote($match[ 'alias' ]) . ' ';
}
$table_join[] = $join_array[ $match[ 'join' ] ] . ' JOIN ' . $table_name . $relation;
}
}
return implode($conjunctor . ' ', $wheres);
return implode(' ', $table_join);
}
public function where_clause($where)
protected function columnMap($columns, &$stack, $root)
{
$where_clause = '';
if ($columns === '*')
{
return $stack;
}
if (is_array($where))
foreach ($columns as $key => $value)
{
$single_condition = array_diff_key($where, array_flip(
explode(' ', 'AND OR GROUP ORDER HAVING LIMIT LIKE MATCH')
));
if (is_int($key))
{
preg_match('/([a-zA-Z0-9_]+\.)?(?<column>[a-zA-Z0-9_]+)(?:\s*\((?<alias>[a-zA-Z0-9_]+)\))?(?:\s*\[(?<type>(?:String|Bool|Int|Number|Object|JSON))\])?/i', $value, $key_match);
if ($single_condition != array())
$column_key = !empty($key_match[ 'alias' ]) ?
$key_match[ 'alias' ] :
$key_match[ 'column' ];
if (isset($key_match[ 'type' ]))
{
$stack[ $value ] = [$column_key, $key_match[ 'type' ]];
}
else
{
$stack[ $value ] = [$column_key, 'String'];
}
}
elseif ($this->isRaw($value))
{
$where_clause = ' WHERE ' . $this->data_implode($single_condition, '');
preg_match('/([a-zA-Z0-9_]+\.)?(?<column>[a-zA-Z0-9_]+)(\s*\[(?<type>(String|Bool|Int|Number))\])?/i', $key, $key_match);
$column_key = $key_match[ 'column' ];
if (isset($key_match[ 'type' ]))
{
$stack[ $key ] = [$column_key, $key_match[ 'type' ]];
}
else
{
$stack[ $key ] = [$column_key, 'String'];
}
}
elseif (!is_int($key) && is_array($value))
{
if ($root && count(array_keys($columns)) === 1)
{
$stack[ $key ] = [$key, 'String'];
}
$this->columnMap($value, $stack, false);
}
}
return $stack;
}
protected function dataMap($data, $columns, $column_map, &$stack, $root, &$result)
{
if ($root)
{
$columns_key = array_keys($columns);
if (count($columns_key) === 1 && is_array($columns[$columns_key[0]]))
{
$index_key = array_keys($columns)[0];
$data_key = preg_replace("/^[a-zA-Z0-9_]+\./i", "", $index_key);
$current_stack = [];
foreach ($data as $item)
{
$this->dataMap($data, $columns[ $index_key ], $column_map, $current_stack, false, $result);
$index = $data[ $data_key ];
$result[ $index ] = $current_stack;
}
}
if (isset($where['AND']))
else
{
$where_clause = ' WHERE ' . $this->data_implode($where['AND'], ' AND');
$current_stack = [];
$this->dataMap($data, $columns, $column_map, $current_stack, false, $result);
$result[] = $current_stack;
}
if (isset($where['OR']))
return;
}
foreach ($columns as $key => $value)
{
$isRaw = $this->isRaw($value);
if (is_int($key) || $isRaw)
{
$where_clause = ' WHERE ' . $this->data_implode($where['OR'], ' OR');
$map = $column_map[ $isRaw ? $key : $value ];
$column_key = $map[ 0 ];
$item = $data[ $column_key ];
if (isset($map[ 1 ]))
{
if ($isRaw && in_array($map[ 1 ], ['Object', 'JSON']))
{
continue;
}
if (is_null($item))
{
$stack[ $column_key ] = null;
continue;
}
switch ($map[ 1 ])
{
case 'Number':
$stack[ $column_key ] = (double) $item;
break;
case 'Int':
$stack[ $column_key ] = (int) $item;
break;
case 'Bool':
$stack[ $column_key ] = (bool) $item;
break;
case 'Object':
$stack[ $column_key ] = unserialize($item);
break;
case 'JSON':
$stack[ $column_key ] = json_decode($item, true);
break;
case 'String':
$stack[ $column_key ] = $item;
break;
}
}
else
{
$stack[ $column_key ] = $item;
}
}
if (isset($where['LIKE']))
else
{
$like_query = $where['LIKE'];
if (is_array($like_query))
{
$is_OR = isset($like_query['OR']);
$current_stack = [];
if ($is_OR || isset($like_query['AND']))
{
$connector = $is_OR ? 'OR' : 'AND';
$like_query = $is_OR ? $like_query['OR'] : $like_query['AND'];
}
else
{
$connector = 'AND';
}
$this->dataMap($data, $value, $column_map, $current_stack, false, $result);
$clause_wrap = array();
foreach ($like_query as $column => $keyword)
{
if (is_array($keyword))
{
foreach ($keyword as $key)
{
$clause_wrap[] = $this->column_quote($column) . ' LIKE ' . $this->quote('%' . $key . '%');
}
}
else
{
$clause_wrap[] = $this->column_quote($column) . ' LIKE ' . $this->quote('%' . $keyword . '%');
}
}
$where_clause .= ($where_clause != '' ? ' AND ' : ' WHERE ') . '(' . implode($clause_wrap, ' ' . $connector . ' ') . ')';
}
$stack[ $key ] = $current_stack;
}
if (isset($where['MATCH']))
}
}
public function create($table, $columns, $options = null)
{
$stack = [];
$tableName = $this->prefix . $table;
foreach ($columns as $name => $definition)
{
if (is_int($name))
{
$match_query = $where['MATCH'];
if (is_array($match_query) && isset($match_query['columns']) && isset($match_query['keyword']))
{
$where_clause .= ($where_clause != '' ? ' AND ' : ' WHERE ') . ' MATCH ("' . str_replace('.', '"."', implode($match_query['columns'], '", "')) . '") AGAINST (' . $this->quote($match_query['keyword']) . ')';
}
$stack[] = preg_replace('/\<([a-zA-Z0-9_]+)\>/i', '"$1"', $definition);
}
if (isset($where['GROUP']))
elseif (is_array($definition))
{
$where_clause .= ' GROUP BY ' . $this->column_quote($where['GROUP']);
$stack[] = $name . ' ' . implode(' ', $definition);
}
if (isset($where['ORDER']))
elseif (is_string($definition))
{
preg_match('/(^[a-zA-Z0-9_\-\.]*)(\s*(DESC|ASC))?/', $where['ORDER'], $order_match);
$stack[] = $name . ' ' . $this->query($definition);
}
}
$where_clause .= ' ORDER BY "' . str_replace('.', '"."', $order_match[1]) . '" ' . (isset($order_match[3]) ? $order_match[3] : '');
$table_option = '';
if (isset($where['HAVING']))
{
$where_clause .= ' HAVING ' . $this->data_implode($where['HAVING'], '');
}
}
if (isset($where['LIMIT']))
if (is_array($options))
{
$option_stack = [];
foreach ($options as $key => $value)
{
if (is_numeric($where['LIMIT']))
{
$where_clause .= ' LIMIT ' . $where['LIMIT'];
}
if (
is_array($where['LIMIT']) &&
is_numeric($where['LIMIT'][0]) &&
is_numeric($where['LIMIT'][1])
)
if (is_string($value) || is_int($value))
{
$where_clause .= ' LIMIT ' . $where['LIMIT'][0] . ',' . $where['LIMIT'][1];
$option_stack[] = "$key = $value";
}
}
$table_option = ' ' . implode(', ', $option_stack);
}
else
elseif (is_string($options))
{
if ($where != null)
{
$where_clause .= ' ' . $where;
}
$table_option = ' ' . $options;
}
return $where_clause;
return $this->exec("CREATE TABLE IF NOT EXISTS $tableName (" . implode(', ', $stack) . ")$table_option");
}
public function drop($table)
{
$tableName = $this->prefix . $table;
return $this->exec("DROP TABLE IF EXISTS $tableName");
}
public function select($table, $join, $columns = null, $where = null)
{
$table = '"' . $table . '"';
$join_key = is_array($join) ? array_keys($join) : null;
$map = [];
$result = [];
$column_map = [];
if (strpos($join_key[0], '[') !== false)
{
$table_join = array();
$index = 0;
$join_array = array(
'>' => 'LEFT',
'<' => 'RIGHT',
'<>' => 'FULL',
'><' => 'INNER'
);
$column = $where === null ? $join : $columns;
foreach($join as $sub_table => $relation)
{
preg_match('/(\[(\<|\>|\>\<|\<\>)\])?([a-zA-Z0-9_\-]*)/', $sub_table, $match);
$is_single = (is_string($column) && $column !== '*');
if ($match[2] != '' && $match[3] != '')
{
if (is_string($relation))
{
$relation = 'USING ("' . $relation . '")';
}
$query = $this->exec($this->selectContext($table, $map, $join, $columns, $where), $map);
if (is_array($relation))
{
// For ['column1', 'column2']
if (isset($relation[0]))
{
$relation = 'USING ("' . implode($relation, '", "') . '")';
}
// For ['column1' => 'column2']
else
{
$relation = 'ON ' . $table . '."' . key($relation) . '" = "' . $match[3] . '"."' . current($relation) . '"';
}
}
$this->columnMap($columns, $column_map, true);
$table_join[] = $join_array[ $match[2] ] . ' JOIN "' . $match[3] . '" ' . $relation;
}
}
if (!$this->statement)
{
return false;
}
$table .= ' ' . implode($table_join, ' ');
if ($columns === '*')
{
return $query->fetchAll(PDO::FETCH_ASSOC);
}
else
while ($data = $query->fetch(PDO::FETCH_ASSOC))
{
$where = $columns;
$columns = $join;
$current_stack = [];
$this->dataMap($data, $columns, $column_map, $current_stack, true, $result);
}
$query = $this->query('SELECT ' . $this->column_push($columns) . ' FROM ' . $table . $this->where_clause($where));
if ($is_single)
{
$single_result = [];
$result_key = $column_map[ $column ][ 0 ];
foreach ($result as $item)
{
$single_result[] = $item[ $result_key ];
}
return $single_result;
}
return $query ? $query->fetchAll(
(is_string($columns) && $columns != '*') ? PDO::FETCH_COLUMN : PDO::FETCH_ASSOC
) : false;
return $result;
}
public function insert($table, $datas)
{
$lastId = array();
$stack = [];
$columns = [];
$fields = [];
$map = [];
// Check indexed or associative array
if (!isset($datas[0]))
if (!isset($datas[ 0 ]))
{
$datas = array($datas);
$datas = [$datas];
}
foreach ($datas as $data)
{
$keys = implode('", "', array_keys($data));
$values = array();
foreach ($data as $key => $value)
{
switch (gettype($value))
$columns[] = $key;
}
}
$columns = array_unique($columns);
foreach ($datas as $data)
{
$values = [];
foreach ($columns as $key)
{
if ($raw = $this->buildRaw($data[ $key ], $map))
{
case 'NULL':
$values[] = 'NULL';
break;
$values[] = $raw;
continue;
}
case 'array':
$values[] = $this->quote(serialize($value));
break;
$map_key = $this->mapKey();
case 'integer':
case 'double':
case 'string':
$values[] = $this->quote($value);
break;
$values[] = $map_key;
if (!isset($data[ $key ]))
{
$map[ $map_key ] = [null, PDO::PARAM_NULL];
}
else
{
$value = $data[ $key ];
$type = gettype($value);
switch ($type)
{
case 'array':
$map[ $map_key ] = [
strpos($key, '[JSON]') === strlen($key) - 6 ?
json_encode($value) :
serialize($value),
PDO::PARAM_STR
];
break;
case 'object':
$value = serialize($value);
case 'NULL':
case 'resource':
case 'boolean':
case 'integer':
case 'double':
case 'string':
$map[ $map_key ] = $this->typeMap($value, $type);
break;
}
}
}
$this->exec('INSERT INTO "' . $table . '" ("' . $keys . '") VALUES (' . implode($values, ', ') . ')');
$stack[] = '(' . implode(', ', $values) . ')';
}
$lastId[] = $this->pdo->lastInsertId();
foreach ($columns as $key)
{
$fields[] = $this->columnQuote(preg_replace("/(\s*\[JSON\]$)/i", '', $key));
}
return count($lastId) > 1 ? $lastId : $lastId[ 0 ];
return $this->exec('INSERT INTO ' . $this->tableQuote($table) . ' (' . implode(', ', $fields) . ') VALUES ' . implode(', ', $stack), $map);
}
public function update($table, $data, $where = null)
{
$fields = array();
$fields = [];
$map = [];
foreach ($data as $key => $value)
{
if (is_array($value))
$column = $this->columnQuote(preg_replace("/(\s*\[(JSON|\+|\-|\*|\/)\]$)/i", '', $key));
if ($raw = $this->buildRaw($value, $map))
{
$fields[] = $this->column_quote($key) . '=' . $this->quote(serialize($value));
$fields[] = $column . ' = ' . $raw;
continue;
}
else
$map_key = $this->mapKey();
preg_match('/(?<column>[a-zA-Z0-9_]+)(\[(?<operator>\+|\-|\*|\/)\])?/i', $key, $match);
if (isset($match[ 'operator' ]))
{
preg_match('/([\w]+)(\[(\+|\-|\*|\/)\])?/i', $key, $match);
if (isset($match[3]))
if (is_numeric($value))
{
if (is_numeric($value))
{
$fields[] = $this->column_quote($match[1]) . ' = ' . $this->column_quote($match[1]) . ' ' . $match[3] . ' ' . $value;
}
$fields[] = $column . ' = ' . $column . ' ' . $match[ 'operator' ] . ' ' . $value;
}
else
{
$column = $this->column_quote($key);
}
else
{
$fields[] = $column . ' = ' . $map_key;
switch (gettype($value))
{
case 'NULL':
$fields[] = $column . ' = NULL';
break;
$type = gettype($value);
case 'array':
$fields[] = $column . ' = ' . $this->quote(serialize($value));
break;
switch ($type)
{
case 'array':
$map[ $map_key ] = [
strpos($key, '[JSON]') === strlen($key) - 6 ?
json_encode($value) :
serialize($value),
PDO::PARAM_STR
];
break;
case 'integer':
case 'double':
case 'string':
$fields[] = $column . ' = ' . $this->quote($value);
break;
}
case 'object':
$value = serialize($value);
case 'NULL':
case 'resource':
case 'boolean':
case 'integer':
case 'double':
case 'string':
$map[ $map_key ] = $this->typeMap($value, $type);
break;
}
}
}
return $this->exec('UPDATE "' . $table . '" SET ' . implode(', ', $fields) . $this->where_clause($where));
return $this->exec('UPDATE ' . $this->tableQuote($table) . ' SET ' . implode(', ', $fields) . $this->whereClause($where, $map), $map);
}
public function delete($table, $where)
{
return $this->exec('DELETE FROM "' . $table . '"' . $this->where_clause($where));
$map = [];
return $this->exec('DELETE FROM ' . $this->tableQuote($table) . $this->whereClause($where, $map), $map);
}
public function replace($table, $columns, $search = null, $replace = null, $where = null)
public function replace($table, $columns, $where = null)
{
if (is_array($columns))
if (!is_array($columns) || empty($columns))
{
$replace_query = array();
return false;
}
$map = [];
$stack = [];
foreach ($columns as $column => $replacements)
foreach ($columns as $column => $replacements)
{
if (is_array($replacements))
{
foreach ($replacements as $replace_search => $replace_replacement)
foreach ($replacements as $old => $new)
{
$replace_query[] = $column . ' = REPLACE("' . $column . '", ' . $this->quote($replace_search) . ', ' . $this->quote($replace_replacement) . ')';
$map_key = $this->mapKey();
$stack[] = $this->columnQuote($column) . ' = REPLACE(' . $this->columnQuote($column) . ', ' . $map_key . 'a, ' . $map_key . 'b)';
$map[ $map_key . 'a' ] = [$old, PDO::PARAM_STR];
$map[ $map_key . 'b' ] = [$new, PDO::PARAM_STR];
}
}
$replace_query = implode(', ', $replace_query);
$where = $search;
}
if (!empty($stack))
{
return $this->exec('UPDATE ' . $this->tableQuote($table) . ' SET ' . implode(', ', $stack) . $this->whereClause($where, $map), $map);
}
return false;
}
public function get($table, $join = null, $columns = null, $where = null)
{
$map = [];
$result = [];
$column_map = [];
$current_stack = [];
if ($where === null)
{
$column = $join;
unset($columns[ 'LIMIT' ]);
}
else
{
if (is_array($search))
$column = $columns;
unset($where[ 'LIMIT' ]);
}
$is_single = (is_string($column) && $column !== '*');
$query = $this->exec($this->selectContext($table, $map, $join, $columns, $where) . ' LIMIT 1', $map);
if (!$this->statement)
{
return false;
}
$data = $query->fetchAll(PDO::FETCH_ASSOC);
if (isset($data[ 0 ]))
{
if ($column === '*')
{
$replace_query = array();
return $data[ 0 ];
}
foreach ($search as $replace_search => $replace_replacement)
{
$replace_query[] = $columns . ' = REPLACE("' . $columns . '", ' . $this->quote($replace_search) . ', ' . $this->quote($replace_replacement) . ')';
}
$replace_query = implode(', ', $replace_query);
$where = $replace;
$this->columnMap($columns, $column_map, true);
$this->dataMap($data[ 0 ], $columns, $column_map, $current_stack, true, $result);
if ($is_single)
{
return $result[ 0 ][ $column_map[ $column ][ 0 ] ];
}
return $result[ 0 ];
}
}
public function has($table, $join, $where = null)
{
$map = [];
$column = null;
if ($this->type === 'mssql')
{
$query = $this->exec($this->selectContext($table, $map, $join, $column, $where, Medoo::raw('TOP 1 1')), $map);
}
else
{
$query = $this->exec('SELECT EXISTS(' . $this->selectContext($table, $map, $join, $column, $where, 1) . ')', $map);
}
if (!$this->statement)
{
return false;
}
$result = $query->fetchColumn();
return $result === '1' || $result === 1 || $result === true;
}
public function rand($table, $join = null, $columns = null, $where = null)
{
$type = $this->type;
$order = 'RANDOM()';
if ($type === 'mysql')
{
$order = 'RAND()';
}
elseif ($type === 'mssql')
{
$order = 'NEWID()';
}
$order_raw = $this->raw($order);
if ($where === null)
{
if ($columns === null)
{
$columns = [
'ORDER' => $order_raw
];
}
else
{
$replace_query = $columns . ' = REPLACE("' . $columns . '", ' . $this->quote($search) . ', ' . $this->quote($replace) . ')';
$column = $join;
unset($columns[ 'ORDER' ]);
$columns[ 'ORDER' ] = $order_raw;
}
}
else
{
unset($where[ 'ORDER' ]);
$where[ 'ORDER' ] = $order_raw;
}
return $this->exec('UPDATE "' . $table . '" SET ' . $replace_query . $this->where_clause($where));
return $this->select($table, $join, $columns, $where);
}
public function get($table, $columns, $where = null)
private function aggregate($type, $table, $join = null, $column = null, $where = null)
{
if (!isset($where))
$map = [];
$query = $this->exec($this->selectContext($table, $map, $join, $column, $where, strtoupper($type)), $map);
if (!$this->statement)
{
$where = array();
return false;
}
$where['LIMIT'] = 1;
$data = $this->select($table, $columns, $where);
$number = $query->fetchColumn();
return is_numeric($number) ? $number + 0 : $number;
}
public function count($table, $join = null, $column = null, $where = null)
{
return $this->aggregate('count', $table, $join, $column, $where);
}
return isset($data[0]) ? $data[0] : false;
public function avg($table, $join, $column = null, $where = null)
{
return $this->aggregate('avg', $table, $join, $column, $where);
}
public function has($table, $where)
public function max($table, $join, $column = null, $where = null)
{
return $this->query('SELECT EXISTS(SELECT 1 FROM "' . $table . '"' . $this->where_clause($where) . ')')->fetchColumn() === '1';
return $this->aggregate('max', $table, $join, $column, $where);
}
public function count($table, $where = null)
public function min($table, $join, $column = null, $where = null)
{
return 0 + ($this->query('SELECT COUNT(*) FROM "' . $table . '"' . $this->where_clause($where))->fetchColumn());
return $this->aggregate('min', $table, $join, $column, $where);
}
public function max($table, $column, $where = null)
public function sum($table, $join, $column = null, $where = null)
{
return 0 + ($this->query('SELECT MAX("' . $column . '") FROM "' . $table . '"' . $this->where_clause($where))->fetchColumn());
return $this->aggregate('sum', $table, $join, $column, $where);
}
public function min($table, $column, $where = null)
public function action($actions)
{
return 0 + ($this->query('SELECT MIN("' . $column . '") FROM "' . $table . '"' . $this->where_clause($where))->fetchColumn());
if (is_callable($actions))
{
$this->pdo->beginTransaction();
try {
$result = $actions($this);
if ($result === false)
{
$this->pdo->rollBack();
}
else
{
$this->pdo->commit();
}
}
catch (Exception $e) {
$this->pdo->rollBack();
throw $e;
}
return $result;
}
return false;
}
public function avg($table, $column, $where = null)
public function id()
{
return 0 + ($this->query('SELECT AVG("' . $column . '") FROM "' . $table . '"' . $this->where_clause($where))->fetchColumn());
if ($this->statement == null)
{
return null;
}
$type = $this->type;
if ($type === 'oracle')
{
return 0;
}
elseif ($type === 'pgsql')
{
return $this->pdo->query('SELECT LASTVAL()')->fetchColumn();
}
$lastId = $this->pdo->lastInsertId();
if ($lastId != "0" && $lastId != "")
{
return $lastId;
}
return null;
}
public function sum($table, $column, $where = null)
public function debug()
{
return 0 + ($this->query('SELECT SUM("' . $column . '") FROM "' . $table . '"' . $this->where_clause($where))->fetchColumn());
$this->debug_mode = true;
return $this;
}
public function error()
{
return $this->pdo->errorInfo();
return $this->errorInfo;
}
public function last_query()
public function last()
{
return $this->queryString;
$log = end($this->logs);
return $this->generate($log[ 0 ], $log[ 1 ]);
}
public function info()
public function log()
{
return array(
'server' => $this->pdo->getAttribute(PDO::ATTR_SERVER_INFO),
'client' => $this->pdo->getAttribute(PDO::ATTR_CLIENT_VERSION),
'driver' => $this->pdo->getAttribute(PDO::ATTR_DRIVER_NAME),
'version' => $this->pdo->getAttribute(PDO::ATTR_SERVER_VERSION),
'connection' => $this->pdo->getAttribute(PDO::ATTR_CONNECTION_STATUS)
return array_map(function ($log)
{
return $this->generate($log[ 0 ], $log[ 1 ]);
},
$this->logs
);
}
public function info()
{
$output = [
'server' => 'SERVER_INFO',
'driver' => 'DRIVER_NAME',
'client' => 'CLIENT_VERSION',
'version' => 'SERVER_VERSION',
'connection' => 'CONNECTION_STATUS'
];
foreach ($output as $key => $value)
{
$output[ $key ] = @$this->pdo->getAttribute(constant('PDO::ATTR_' . $value));
}
$output[ 'dsn' ] = $this->dsn;
return $output;
}
}
?>
<?php
class template {
private $template_base = "template/default.php";
private $default_page = "error";
private $pages_base = "template/pages/";
private $state, $skey, $page;
private $content = "";
private function getSlug( $page ) {
$page = strip_tags( $page );
preg_match_all( "/([a-z0-9A-Z-_]+)/", $page, $matches );
$matches = array_map( "ucfirst", $matches[0] );
$slug = implode( "-", $matches );
return $slug;
}
public function set_page($pg){
$this->page = $pg;
}
public function set_content($cont){
$this->content = $cont;
}
public function show(){
$contentfile = (!isset($_REQUEST['page'])) ? $this->page : getSlug($_REQUEST['page']);
if($this->content == ""){
$content = @file_get_contents($this->pages_base."/".$contentfile.".txt");
if(!$content)
$content = @file_get_contents($this->pages_base."/".$this->default_page.".txt");
$this->content = $content;
}
require($this->template_base);
}
private function displayMainContent(){
echo $this->content;
}
private function display_status(){
}
}
<?php
session_start();
require_once __DIR__ . '/frameworks/Environment.php';
require_once __DIR__ . '/view/default_index.php';
require_once __DIR__ . '/view/signups/index.php';
require 'frameworks/environment.php';
require 'view/signups/index.php';
class IndexPage extends DefaultIndex {
require 'view/default_index.php';
// =====================================================================================================================
// HEADERS
function echo_headers() {
echo index_get_css_includes();
echo index_get_js_includes();
echo index_get_additional_headers();
}
function index_get_css_includes() {
$basefolder = 'view/';
$base_styles = ['style.css'];
$additional_styles = index_get_dependencies_helper('getCSSDependencies');
$styles = array_merge($base_styles, $additional_styles);
$ret = '';
foreach ($styles as $style) {
$ret .= "<link rel=\"stylesheet\" href=\"" . $basefolder . $style . "\" />\n";
protected $signupMethodDetails;
public function __construct() {
parent::__construct();
$this->signupMethodDetails = SignupMethods::getInstance()->getSignupMethodsBaseInfo();
}
return $ret;
}
function index_get_js_includes() {
$basefolder = 'view/';
// =====================================================================================================================
// HEADERS
private function index_get_css_includes() {
$basefolder = 'view/';
$base_js = [
'js/jquery-1.11.1.min.js',
'js/jquery-ui.min.js',
'js/angular.min.js',
'js/api.js'
];
$additional_js = index_get_dependencies_helper('getJSDependencies');
$base_styles = ['style.css'];
$additional_styles = $this->index_get_dependencies_helper('getCSSDependencies');
$scripts = array_merge($base_js, $additional_js);
$styles = array_merge($base_styles, $additional_styles);
$ret = '';
foreach ($scripts as $script) {
$ret .= "<script type=\"text/javascript\" src=\"" . $basefolder . $script . "\"></script>\n";
}
return $ret;
}
function index_get_dependencies_helper($dependency_function_name) {
$methods_basefolder = 'signups/';
$signup_method = SignupMethods::getInstance();
if($signup_method->signupMethodExists()){
$method_folder = $signup_method->getActiveMethodId();
return array_map(function($d) use ($methods_basefolder, $method_folder) {
return $methods_basefolder . $method_folder . '/' . $d;
}, $signup_method->getActiveMethod()->$dependency_function_name());
$ret = '';
foreach ($styles as $style) {
$ret .= "<link rel=\"stylesheet\" href=\"" . $basefolder . $style . "\" />\n";
}
return $ret;
}
return [];
}
function index_get_additional_headers() {
$signup_method = SignupMethods::getInstance();
if($signup_method->signupMethodExists()){
return $signup_method->getActiveMethod()->getAdditionalHeader();
private function index_get_js_includes() {
$basefolder = 'view/';
$base_js = [
'js/jquery-1.11.1.min.js',
'js/jquery-ui.min.js',
'js/angular.min.js',
'js/elevator.js',
'js/hurrdurr.js',
'js/api.js'
];
$additional_js = $this->index_get_dependencies_helper('getJSDependencies');
$scripts = array_merge($base_js, $additional_js);
$ret = '';
$currPathLength = strlen(realpath(".")) + 1;
$uniq = array();
foreach ($scripts as $script) {
$script = substr(realpath($basefolder . $script), $currPathLength);
if (isset($uniq[$script])) continue;
$uniq[$script] = true;
$ret .= "<script type=\"text/javascript\" src=\"" . $script . "\"></script>\n";
}
return $ret;
}
return '';
}
// =====================================================================================================================
// CONTENT
function show_content() {
$environment = Environment::getEnv();
if(!$environment->isSelectedTripIdValid()) {
index_show_alleFahrten();
} else {
$fid = $environment->getSelectedTripId();
private function index_get_dependencies_helper($dependency_function_name) {
$methods_basefolder = 'signups/';
// --- Fahrtinfos
index_show_fahrtHeader($fid);
index_show_fahrtHeader_js($fid);
$signup_method = SignupMethods::getInstance();
// --- Anmeldebox
index_show_signup();
if ($signup_method->signupMethodExists()) {
$method_folder = $signup_method->getActiveMethodId();
// --- Liste der Anmeldungen
index_show_signupTable($fid);
return array_map(function ($d) use ($methods_basefolder, $method_folder) {
return $methods_basefolder . $method_folder . '/' . $d;
}, $signup_method->getActiveMethod()->$dependency_function_name());
}
return [];
}
}
// ---------------------------------------------------------------------------------------------------------------------
// SIGNUP AREA
function index_show_signup() {
$environment = Environment::getEnv();
$signup_method = SignupMethods::getInstance();
$fid = $environment->getSelectedTripId();
$openstatus = $environment->getRegistrationState($fid);
$waitlist_confirmed = $environment->isInWaitlistMode();
echo '<div id="signup-container">';
echo '<h2>Anmeldung</h2>';
// Anmeldung erfolgreich
if(isset($_REQUEST['success'])) {
echo '<div style="text-align:center; font-size: 20pt; font-weight: bold">Die Anmeldung war erfolgreich.</div>';
private function index_get_additional_headers() {
$signup_method = SignupMethods::getInstance();
if ($signup_method->signupMethodExists()) {
return $signup_method->getActiveMethod()->getAdditionalHeader();
}
return '';
}
// Anmeldung fehlgeschlagen, weil voll
elseif (isset($_REQUEST['full'])) {
echo '<div style="text-align:center; font-size: 20pt; font-weight: bold">Anmeldung leider fehlgeschlagen.</div>';
echo '<div style="text-align:center; font-size: 16pt; font-weight: bold">Die Anmeldegrenze wurde leider erreicht.</div>';
echo '<div style="text-align:center; font-size: 14pt; ">Es besteht die Möglichkeit sich auf der Warteliste einzutragen.<br />
Wenn du das möchtest, klicke hier: <a class="normallink" href="?fid='.$fid.'&waitlist">&#8694; Warteliste</a></div>';
protected function echoHeaders() {
echo $this->index_get_css_includes();
echo $this->index_get_js_includes();
echo $this->index_get_additional_headers();
}
// Formulardaten empfangen -> auswerten!
elseif($environment->formDataReceived()){
comm_verbose(1, "Formular bekommen");
$sub = $signup_method->validateSubmission();
if ($sub['valid']) {
if ($environment->sendBachelorToDB($sub['data']))
header("Location: ?fid=".$fid."&success");
else
header("Location: ?fid=".$fid."&full");
die();
// =====================================================================================================================
// CONTENT
protected function echoContent() {
if (!$this->environment->isSelectedTripIdValid()) {
$this->showAlleFahrten();
$this->makeHurrDurr();
} else {
index_show_errors($sub['errors']);
$environment->setDanglingFormData($sub['data']);
$signup_method->getFallbackMethod()->showInlineHTML();
}
}
$fahrt = $this->environment->getTrip();
// Anmeldung anzeigen (Form or game)
elseif ($signup_method->signupMethodExists() &&
($openstatus == 0 || ($waitlist_confirmed && $openstatus < 2 ))) {
// --- Fahrtinfos
$this->showFahrtDetailBlock($fahrt);
$this->showFahrtDetailJS($fahrt);
$signup_method->getActiveMethod()->showInlineHTML();
// future feature: option to show edit view (when $_GET['bid'] isset)
}
// Anmeldeoptionen anzeigen
else {
if($openstatus > 0 && !$waitlist_confirmed) {
echo '<div style="text-align:center; font-size: 20pt; font-weight: bold">Die Anmeldung wurde geschlossen.</div>';
if ($openstatus != 2) {
echo '
<div style="text-align:center; font-size: 16pt; font-weight: bold">
Ein Auge offen halten, ob Plätze frei werden.
</div><div style="text-align:center; font-size: 14pt;">
Es gibt aber auch eine Warteliste.<br />
Wenn du da rauf möchtest, klicke hier:
<a class="normallink" href="?fid=' . $fid . '&waitlist">&#8694; Warteliste</a>
</div>';
}
} elseif ($openstatus < 2) {
$methods = $signup_method->getSignupMethodsBaseInfo();
$link = '?fid=' . $fid . ($waitlist_confirmed ? '&waitlist' : '') . '&method=';
if ($fahrt->getRegistrationState() != Fahrt::STATUS_IS_COUNTDOWN) {
// --- Anmeldebox
$this->showSignup($fahrt);
echo '<p>Es stehen verschiedene Methoden zur Anmeldung offen. Wähle eine davon:';
// --- Liste der Anmeldungen
$this->showSignupTable($fahrt);
echo '<ul id="method-list">';
foreach ($methods as $method) {
echo '<li><a href="' . $link . $method['id'] . '">' . $method["name"] . '</a> <br />' . $method['description'] . '</li>';
$this->makeHurrDurr();
} else {
$this->showCountdown($fahrt->getOpenTime());
}
echo '</ul>';
}
}
echo '</div>'; // close signup-container
}
/**
* puts out a list of all errors
* @param $errors
*/
function index_show_errors($errors){
echo '<div class="message error"><ul>';
foreach($errors as $e){
echo '<li>'.$e.'</li>';
/**
* @param $fahrt Fahrt
*/
private function showFahrtDetailBlock($fahrt) {
$details = $fahrt->getFahrtDetails();
echo '<div class="fahrt">
<div class="fahrt-left">
<a class="fahrthead" href="index.php?fid=' . $details['fahrt_id'] . '">' . $details['titel'] . '</a>
Ziel: <i>' . $details['ziel'] . '</i><br />
Datum: <i>' . $this->mysql2german($details['von']) . " - " . $this->mysql2german($details['bis']) . '</i><br />
Ansprechpartner: <i>' . $details['leiter'] . ' (' . $this->transformMail($details['kontakt']) . ')</i><br />
Anmeldungen: <i>' . $fahrt->getNumTakenSpots() . ' / ' . $fahrt->getNumMaxSpots() . '</i>
<p>' . $details['beschreibung'] . '</p>
</div>
<div class="map-canvas" id="map-canvas-' . $fahrt->getID() . '"></div>
<div style="clear:both"></div>
</div>';
}
echo'</ul></div>';
}
// ---------------------------------------------------------------------------------------------------------------------
// TRIP LISTING
/**
* show list of all fahrten
*/
function index_show_alleFahrten() {
$environment = Environment::getEnv();
comm_verbose(2,"Liste aller Fahrten (Jahr, Ziel, Zeitraum, Anz. Mitfahrer)");
echo '<h2>Anmeldung zur Fachschaftsfahrt</h2>';
$foos = $environment->database->select("fahrten",
['fahrt_id','titel','ziel','von','bis','beschreibung','leiter','kontakt', 'max_bachelor'],
"ORDER BY fahrt_id DESC");
if(!$foos) {
echo 'Keine Fahrten im System gefunden';
return;
}
$fids = [];
foreach($foos as $foo){
index_show_fahrtHeader($foo);
array_push($fids, $foo['fahrt_id']);
}
index_show_fahrtHeader_js($fids);
}
/**
* @param $fahrten Fahrt[]|Fahrt
*/
private function showFahrtDetailJS($fahrten) {
global $config_use_openstreetmap;
/**
* @param $fahrt wenn array, dann Datenbankrow; wenn zahl, dann wird das selektiert
*/
function index_show_fahrtHeader($fahrt){
$environment = Environment::getEnv();
if(!is_array($fahrt)){
// select fahrt by ID
$fahrt = $environment->database->select('fahrten',
['fahrt_id','titel','ziel', 'von', 'bis', 'leiter', 'kontakt', 'beschreibung', 'max_bachelor'],
['fahrt_id'=> $fahrt]);
if(!$fahrt)
return; // break here and show nothing!
else
$fahrt = $fahrt[0];
}
$cnt = $environment->database->count("bachelor", ["AND"=>
["backstepped" => NULL,
"fahrt_id" => $fahrt['fahrt_id']]]);
echo '<div class="fahrt">
<div class="fahrt-left">
<a class="fahrthead" href="index.php?fid='.$fahrt['fahrt_id'].'">'.$fahrt['titel'].'</a>';
echo 'Ziel: <i>'.$fahrt['ziel'].'</i><br />';
echo 'Datum: <i>'.comm_from_mysqlDate($fahrt['von'])." - ".comm_from_mysqlDate($fahrt['bis']).'</i><br />';
echo "Ansprechpartner: <i>".$fahrt['leiter']." (".comm_convert_mail($fahrt['kontakt']).")</i><br />";
echo "Anmeldungen: <i>".$cnt." / ".$fahrt['max_bachelor']."</i>";
echo '<p>'.$fahrt['beschreibung'].'</p></div>
<div class="map-canvas" id="map-canvas-'.$fahrt['fahrt_id'].'"></div>
<div style="clear:both"></div>
</div>';
}
function index_show_fahrtHeader_js($fahrten){
$environment = Environment::getEnv();
$pins = $environment->database->select("fahrten", ["fahrt_id", "map_pin"], ["fahrt_id" => $fahrten]);
echo '<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
if (!is_array($fahrten))
$fahrten = [$fahrten];
if ($config_use_openstreetmap) {
echo '<script type="text/javascript" src="https://openlayers.org/api/OpenLayers.js"></script><script type="text/javascript">';
} else {
echo '<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<script type="text/javascript">
window.onload = function() {
$("div.fahrt-left i").click(function(){
......@@ -293,86 +162,199 @@ function index_show_fahrtHeader_js($fahrten){
}
);
};';
}
foreach($pins as $p){
// if not valid GPS pos, fallback to Kheta!
if(!preg_match("/\\d+\\.\\d+ \\d+\\.\\d+/m", $p["map_pin"]))
$p["map_pin"] = '71.555267 99.690962';
$fids = [];
foreach ($fahrten as $fahrt) {
$fid = $fahrt->getID();
$pin = $fahrt->getGPS();
array_push($fids, $fid);
if ($config_use_openstreetmap) {
echo '
var ziel_' . $fid . ' = [' . str_replace(" ", ", ", $pin) . '];';
} else {
echo '
var ziel_' . $fid . ' = new google.maps.LatLng(' . str_replace(" ", ", ", $pin) . ');';
}
echo '
var marker_' . $fid . ';
var map_' . $fid . ';';
}
echo '
var ziel_' . $p['fahrt_id'] . ' = new google.maps.LatLng(' . str_replace(" ", ", ", $p["map_pin"]) . ');
var marker_' . $p['fahrt_id'] . ';
var map_' . $p['fahrt_id'] . ';
function initialize_maps() {
';
foreach ($fids as $fid) {
if ($config_use_openstreetmap) {
echo <<<EOF
map_$fid = new OpenLayers.Map("map-canvas-$fid");
map_$fid.addLayer(new OpenLayers.Layer.OSM());
var lonLat = new OpenLayers.LonLat(parseFloat(ziel_${fid}[1]), parseFloat(ziel_${fid}[0]))
.transform(
new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
map_$fid.getProjectionObject() // to Spherical Mercator Projection
);
var zoom=10;
var markers = new OpenLayers.Layer.Markers("Markers");
map_$fid.addLayer(markers);
markers.addMarker(new OpenLayers.Marker(lonLat));
map_$fid.setCenter(lonLat, zoom);
EOF;
} else {
echo '
var mapOptions_' . $fid . ' = {
zoom: 8,
center: ziel_' . $fid . ',
panControl: false,
zoomControl: false,
scaleControl: true,
mapTypeControl: false,
streetViewControl: false,
overviewMapControl: false
};
map_' . $fid . ' = new google.maps.Map(document.getElementById(\'map-canvas-' . $fid . '\'), mapOptions_' . $fid . ');
marker_' . $fid . ' = new google.maps.Marker({
map:map_' . $fid . ',
draggable:true,
animation: google.maps.Animation.DROP,
position: ziel_' . $fid . '
});
marker_' . $fid . '.setAnimation(google.maps.Animation.BOUNCE);';
}
}
echo '}';
if ($config_use_openstreetmap) {
echo '$(initialize_maps)';
} else {
echo 'google.maps.event.addDomListener(window, \'load\', initialize_maps);';
}
echo '</script>';
}
echo'
function initialize() {
';
foreach($pins as $p){
echo'
var mapOptions_'.$p['fahrt_id'].' = {
zoom: 8,
center: ziel_'.$p['fahrt_id'].',
panControl: false,
zoomControl: false,
scaleControl: true,
mapTypeControl: false,
streetViewControl: false,
overviewMapControl: false
};
map_'.$p['fahrt_id'].' = new google.maps.Map(document.getElementById(\'map-canvas-'.$p['fahrt_id'].'\'), mapOptions_'.$p['fahrt_id'].');
marker_'.$p['fahrt_id'].' = new google.maps.Marker({
map:map_'.$p['fahrt_id'].',
draggable:true,
animation: google.maps.Animation.DROP,
position: ziel_'.$p['fahrt_id'].'
private function makeHurrDurr() {
echo "<script>
$(function () {
var hurdur = new HurDur();
new Elevator({
element: document.getElementById('nyan'),
mainAudio: 'view/audio/audio.ogg',
endAudio: 'view/audio/end-audio.ogg',
duration: 5000,
startCallback: hurdur.start,
endCallback: hurdur.stop
});
});
marker_'.$p['fahrt_id'].'.setAnimation(google.maps.Animation.BOUNCE);';
</script>";
}
echo'
}
google.maps.event.addDomListener(window, \'load\', initialize);
</script>';
}
private function showAlleFahrten() {
echo '<h2>Anmeldung zur Fachschaftsfahrt</h2>';
$fahrten = Fahrt::getAlleFahrten();
if (!$fahrten) {
echo 'Keine Fahrten im System gefunden';
} else {
foreach ($fahrten as $fahrt) {
$this->showFahrtDetailBlock($fahrt);
}
$this->showFahrtDetailJS($fahrten);
}
}
private function showErrors($errors) {
echo '<div class="message error"><ul>';
foreach ($errors as $e) {
echo '<li>' . $e . '</li>';
}
echo '</ul></div>';
}
private function showCountdown($opentime) {
echo '<script type="text/javascript" src="view/js/jquery.qrcode.js"></script>';
echo "
<script>
var opentime = " . $opentime . ";
var b = true;
$(function () {
var url = window.location.href;
if(url.indexOf('#showQR')>0) $('#QRcode').qrcode({
render: 'canvas',
ecLevel: 'Q',
size: 150,
fill: '#000',
background: null,
text: url.replace('#showQR',''),
radius: 0.5,
quiet:2,
mode: 2,
label: 'FS Fahrt',
fontname: 'sans',
fontcolor: '#ff9818'
});
var hurdur = new HurDur({
cats: 10,
loopcb: function() {
$('#text, body').stop().animate({color:b?'#ffffff':'#000000'}, 1000);
var now = (Date.now() + ((new Date()).getTimezoneOffset()*60))/1000;
var diff = opentime - now;
var view = '';
if (diff <= 0) {
view = '00:00:00.00';
} else {
view = hurrdurrr(parseInt(diff/60/60/24, 10)) + 'd ' + hurrdurrr(parseInt(diff / 60 / 60 % 24, 10))
+ 'h:' + hurrdurrr(parseInt(diff / 60 % 60, 10)) + 'm.' + hurrdurrr(parseInt(diff%60, 10)) + 's';
}
$('#countdown').html(view);
function hurrdurrr(num) {
return ((num < 10) ? '0' : '') + num;
}
b = !b;
}
});
hurdur.start();
});
</script>";
echo '<div id="text" style="font-weight:bold;text-align:center;font-size:40pt;font-family:Verdana, Geneva, sans-serif">
ANMELDUNG IN KÜRZE<br />
<span id="countdown"></span>
</div>';
echo '<div style="width:100%; margin-top: 20px;">
<div style="margin:0 auto; width:300px">
<iframe width="300" height="300" scrolling="no" frameborder="no"
src="https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/109529816&amp;auto_play=true&amp;hide_related=false&amp;show_comments=true&amp;show_user=true&amp;show_reposts=false&amp;visual=true"></iframe>
</div>
</div>';
echo '<canvas id="QRcode" style="position: fixed; bottom: 10px; right: -240px;width:500px;height:250px;"></canvas>';
echo '<div style="position: fixed; right: 10px; bottom:10px;"><a href="#QRcode">QR-Code</a></div>';
}
/**
* @param $fahrt Fahrt
*/
private function showSignupTable($fahrt) {
echo '<h2>Anmeldungen</h2>';
$bachelorsData = $fahrt->getBachelors(['public' => true, 'backstepped' => false, 'waiting' => false], ['anm_time'=> 'ASC']);
// ---------------------------------------------------------------------------------------------------------------------
// PUBLIC REGISTRATIONS LISTING
/**
* show table of public registrations
*/
function index_show_signupTable($fid){
$environment = Environment::getEnv();
echo '<h2>Anmeldungen</h2>';
$data = $environment->database->select('bachelor',
["pseudo","antyp","abtyp","anday","abday","comment","studityp"],
["AND" => [
'fahrt_id' => (int) $fid,
'public' => 1
]]);
if(!$data) echo'<div class="signups">Noch keine (sichtbaren) Anmeldungen!</div>';
else {
echo '
<table class="signups">
if (!$bachelorsData) {
echo '<div class="signups">Noch keine (sichtbaren) Anmeldungen!</div>';
} else {
echo '
<table class="signups" cellspacing="0" cellpadding="0">
<thead>
<tr>
<!--th></th-->
<th></th>
<th>Anzeigename</th>
<th>Anreisetag</th>
<th>Anreiseart</th>
......@@ -381,24 +363,133 @@ function index_show_signupTable($fid){
<th>Kommentar</th>
</tr>
</thead>';
foreach($data as $d){
echo '<tr>
<!--td>'.$d["studityp"].'</td-->
<td>'.$d["pseudo"].'</td>
<td>'.comm_from_mysqlDate($d["anday"]).'</td>
<td>'.index_show_signupTable_destroyTypes($d["antyp"]).'</td>
<td>'.comm_from_mysqlDate($d["abday"]).'</td>
<td>'.index_show_signupTable_destroyTypes($d["abtyp"]).'</td>
<td>'.$d["comment"].'</td>
</tr>';
foreach ($bachelorsData as $d) {
echo '<tr>
<td style="width: 58px;">'.$this->makeSignupBadge($d['signupstats']).' </td>
<td>' . $d["pseudo"] . '</td>
<td>' . $this->mysql2german($d["anday"]) . '</td>
<td>' . $this->translateTravelType($d["antyp"]) . '</td>
<td>' . $this->mysql2german($d["abday"]) . '</td>
<td>' . $this->translateTravelType($d["abtyp"]) . '</td>
<td style="word-break:break-all;">' . $d["comment"] . '</td>
</tr>';
}
echo '</table>';
}
}
private function makeSignupBadge($stats) {
$json = (empty($stats)) ? null : json_decode($stats, true);
if (empty($json) or !isset($json['method']) or !isset($json['methodinfo']) or !isset($this->signupMethodDetails[$json['method']]))
return '';
$method = $this->signupMethodDetails[$json['method']];
$logo = 'view/signups/'.$method['id'].'/'.$method['logo'];
$score = $method['score']($json['methodinfo']);
return '<img src="'.$logo.'" style="height: 1.2em;"/>
<span style="font-size:0.7em;float:right;margin-top:0.8em;">'.$score.'%</span>
<div class="progressbar"><span style="width: '.$score.'%"></span></div>';
}
private function translateTravelType($anabtyp) {
if ($anabtyp == 'INDIVIDUELL') {
return $this->environment->config['reiseartenDestroyed'][array_rand($this->environment->config['reiseartenDestroyed'])];
}
if (isset($this->environment->oconfig['reiseartenShort'][$anabtyp]))
return $this->environment->oconfig['reiseartenShort'][$anabtyp];
// well done, hacked the system, gets props for it :)
return $anabtyp;
}
/**
* @param $fahrt Fahrt
*/
private function showSignup($fahrt) {
$signup_method = SignupMethods::getInstance();
$fid = $fahrt->getID();
$status = $fahrt->getRegistrationState();
$waitlist_confirmed = $this->environment->isInWaitlistMode();
echo '<div id="signup-container">';
echo '<h2>Anmeldung</h2>';
// Anmeldung erfolgreich
if (isset($_REQUEST['success'])) {
echo '<div style="text-align:center; font-size: 20pt; font-weight: bold">Die Anmeldung war erfolgreich.</div>';
} // Anmeldung fehlgeschlagen, weil voll oder duplikat
elseif (isset($_REQUEST['saveerror'])) {
echo '<div style="text-align:center; font-size: 20pt; font-weight: bold">Anmeldung fehlgeschlagen.</div>';
echo '<div style="text-align:center; font-size: 16pt; font-weight: bold">';
$error = (int)$_REQUEST['saveerror'];
if ($error == Bachelor::SAVE_ERROR_FULL) {
echo 'Die Anmeldegrenze wurde leider erreicht.</div>';
echo '<div style="text-align:center; font-size: 14pt; ">
Es besteht die Möglichkeit sich auf der Warteliste einzutragen.<br />
Wenn du das möchtest, klicke hier: <a class="normallink" href="?fid=' . $fid . '&waitlist">&#8694; Warteliste</a></div>';
} elseif ($error == Bachelor::SAVE_ERROR_DUPLICATE) {
echo 'Es scheint so, als hättest du dich bereits angemeldet...</div>';
} elseif ($error == Bachelor::SAVE_ERROR_CLOSED) {
echo 'Die Anmeldung ist bereits geschlossen!</div>';
} elseif ($error == Bachelor::SAVE_ERROR_MISSING_RIGHTS) {
echo 'Das System hat beschlossen, dass du dazu nicht berechtigt bist...</div>';
} elseif ($error == Bachelor::SAVE_ERROR_INVALID) {
echo 'Deine Daten sind Murks und das ist erst beim Speichern aufgefallen.</div>';
} else { // $error == Bachelor::SAVE_ERROR_EXCEPTION
echo 'Etwas ist gehörig schiefgelaufen. Nochmal probieren oder Mail schreiben!</div>';
}
} // Formulardaten empfangen -> auswerten!
elseif ($this->environment->formDataReceived()) {
$bachelor = $this->environment->getBachelor(false, false, true);
if ($bachelor->isDataValid()) {
$saveResult = $bachelor->save();
if ($saveResult == Bachelor::SAVE_SUCCESS)
header("Location: ?fid=" . $fid . "&success");
else
header("Location: ?fid=" . $fid . "&saveerror=" . $saveResult);
} else {
if (!isset($_REQUEST['hideErrors'])) {
$this->showErrors($bachelor->getValidationErrors());
}
$signup_method->getFallbackMethod()->showInlineHTML();
}
} // Anmeldung anzeigen
elseif ($signup_method->signupMethodExists() && ($status == Fahrt::STATUS_IS_OPEN_NOT_FULL ||
($waitlist_confirmed && $status == Fahrt::STATUS_IS_OPEN_FULL))
) {
$signup_method->getActiveMethod()->showInlineHTML();
} // Anmeldung geschlossen
elseif ($status == Fahrt::STATUS_IS_CLOSED) {
echo '<div style="text-align:center; font-size: 20pt; font-weight: bold">Die Anmeldung wurde geschlossen.</div>';
}
elseif ($status == Fahrt::STATUS_IS_OPEN_FULL && !$waitlist_confirmed) {
echo '<div style="text-align:center; font-size: 20pt; font-weight: bold">Die Fahrt ist voll voll.</div>
<div style="text-align:center; font-size: 16pt; font-weight: bold">
Ein Auge offen halten, ob Plätze frei werden.
</div><div style="text-align:center; font-size: 14pt;">
Es gibt aber auch eine Warteliste.<br />
Wenn du da rauf möchtest, klicke hier:
<a class="normallink" href="?fid=' . $fid . '&waitlist">&#8694; Warteliste</a>
</div>';
} else {
$methods = $signup_method->getSignupMethodsBaseInfo();
$link = '?fid=' . $fid . ($waitlist_confirmed ? '&waitlist' : '') . '&method=';
echo '<p>Es stehen verschiedene Methoden zur Anmeldung zur Verfügung. Wähle eine davon:';
echo '<ul id="method-list">';
foreach ($methods as $method) {
echo '<li><a href="' . $link . $method['id'] . '#signup-container">' . $method["name"] . '</a> <br />' .
$method['description'] . '</li>';
}
echo '</ul>';
}
echo '</table>';
echo '</div>'; // close signup-container
}
}
function index_show_signupTable_destroyTypes($anabtyp){
global $config_reisearten, $config_reisearten_destroyed;
if(array_search($anabtyp, $config_reisearten)>=2)
return $config_reisearten_destroyed[array_rand($config_reisearten_destroyed)];
return $anabtyp;
}
\ No newline at end of file
(new IndexPage())->render();
......@@ -2,6 +2,5 @@
<?php
// phpinfo();
// safe key generation:
//$bytes = openssl_random_pseudo_bytes(6);
//$hex = bin2hex($bytes);
echo 'go away! nothing for you to see here!';
<?php
/**
* Created by PhpStorm.
* User: tim
* Date: 8/16/14
* Time: 5:02 PM
*/
static $lang_regmail = "
Deine Anmeldung zur Fachschaftsfahrt\\\\
......@@ -32,6 +26,22 @@ Viele Grüße,
{{organisator}}!
";
static $lang_waitalumnimail = "
Warteliste zur Fachschaftsfahrt\\\\
Hallo!
Vielen Dank für die Anmeldung bei der Fachschaftsfahrt. Da du dich als Alumni eingetragen hast, bist du vorerst auf der Warteliste, da wir Studierenden den Vorrang gewähren.
Den Status der Meldung kannst Du jederzeit auf folgender Seite überprüfen:
{{url}}
Weitere Informationen werden wir an diese E-Mail-Adresse senden, also bitte regelmäßig lesen und bei Fragen einfach fragen :-)
Bitte beachte, dass dies nur eine Anmeldung auf der Warteliste ist. Sofern keine weiteren Infos kommen, kannst du leider NICHT mitfahren.
Viele Grüße,
{{organisator}}!
";
static $lang_waittoregmail = "
Deine Anmeldung zur Fachschaftsfahrt\\\\
Hallo!
......@@ -47,4 +57,40 @@ Viele Grüße,
{{organisator}}!
";
static $lang_payinfomail_winter = "
Zusatzinformationen zur Fachschaftsfahrt und Zahlungsaufforderung\\\\
Hallo,
du solltest bereits eine Anmeldebestätigung erhalten haben. Hier folgen jetzt noch ein paar kurze Infos:
Wie bereits angekündigt sammeln wir zunächst 60,-€ pro Person ein.
Diesen Betrag bitte bis zum {{paydeadline}} an folgendes Konto überweisen:
{{payinfo}}
Den Differenzbetrag bekommst du *nach* der Fahrt zusammen mit der Förderung, sofern vorhanden, wieder zurück. Die effektiven Kosten belaufen sich am Ende auf <25€.
Alle Informationen findest du weiterhin hier:
{{wikilink}}
Bis dann,
{{organisator}}!
";
static $lang_payinfomail_summer = "
Zusatzinformationen zur Fachschaftsfahrt und Zahlungsaufforderung\\\\
Hallo,
du solltest bereits eine Anmeldebestätigung erhalten haben. Hier folgen jetzt noch ein paar kurze Infos:
Wie bereits angekündigt sammeln wir zunächst 60,-€ pro Person ein.
Diesen Betrag bitte bis zum {{paydeadline}} an folgendes Konto überweisen:
{{payinfo}}
Alle Informationen findest du weiterhin hier:
{{wikilink}}
Bis dann,
{{organisator}}!
";
?>
Require all denied
\ No newline at end of file
#!/usr/bin/env bash
set -e
function install {
echo "starting install wizzard"
# sure?
echo "this might destroy your current installation (if existing)"
read -r -p "Are you sure you want to proceed? [y/N] " response
response=${response,,} # tolower
if [[ ! $response =~ ^(yes|y)$ ]] ; then exit 1 ; fi
echo "[1/7] initialising"
# change operation dir
cd "${BASH_SOURCE%/*}"
mkdir -p backups
# create last update file
date +"%Y%m%d" > backups/lastUpdate
# create required files
echo "[2/7] setting up files"
cp ../passwd/users.example.txt ../passwd/users.txt
echo -n "2" > ../config_current_fahrt_id
# adjust chmod
echo "[3/7] setting chmod"
chmod -R 644 ../
chmod 777 ../config_current_fahrt_id
chmod 777 ../passwd/users.txt
# ask config stuff
echo "[4/7] some config params, please..."
read -p "baseurl (i.e. \"https://domain.com/fsfahrt\"): " base
read -p "database name: " dbname
read -p "database user: " dbuser
read -p "database pw: " dbpass
read -p "database host: " dbhost
# adapt config.local.php file
echo "[5/7] writing config file"
sed -i "s/($var = \")[^\"]*/\1$base/" ../config.local.php
sed -i "s/(\"dbname\" => \")[^\"]*/\1$dbname/" ../config.local.php
sed -i "s/(\"dbuser\" => \")[^\"]*/\1$dbuser/" ../config.local.php
sed -i "s/(\"dbpass\" => \")[^\"]*/\1$dbpass/" ../config.local.php
sed -i "s/(\"dbhost\" => \")[^\"]*/\1$dbhost/" ../config.local.php
# get init sql files
inits=()
echo "[6/7] available init files:"
for initsql in sqlDumps/init_*.sql; do
inits=("${inits[@]}" "$initsql")
echo "${#inits[@]}) $initsql"
done
# run db init
echo "[7/7] select init dump or kill script to do it manually"
read -p "which dump do you want (latest recommended): " dump
mysql -h $dbhost -u $dbuser -p $dbpass $dbname < ${inits[$dump]}
exit 0
}
function update {
echo "updating system"
# sure?
echo "this might destroy your current installation (if existing)"
read -r -p "Are you sure you want to proceed? [y/N] " response
response=${response,,} # tolower
if [[ ! $response =~ ^(yes|y)$ ]] ; then exit 1 ; fi
if [[ ! -f backups/lastUpdate ]] ; then
read -r -p "Last update or install? As 'Ymd' (zero padded)" response
echo response > backups/lastUpdate
fi
# change operation dir
cd "${BASH_SOURCE%/*}"
mkdir -p backups
# backup config files
echo "backing up config files"
cp ../config_current_fahrt_id backups/
cp ../passwd/users.txt backups/
cp ../config.local.php backups/
# fetch from github
read -p "git branch to pull from [default: master]: " BRANCH
read -p "git origin to pull from [default: origin]: " ORIGIN
if [[ -z $BRANCH ]] ; then BRANCH=master ; fi
if [[ -z $ORIGIN ]] ; then ORIGIN=origin ; fi
# create backup
echo "creating backup on 'backup' branch"
git checkout -B backup
git add --all
git commit --allow-empty -m "backup from `date +"%d.%m.%Y"`"
# pull from origin
echo "force pulling from $ORIGIN/$BRANCH"
git checkout $BRANCH
git fetch $ORIGIN
git reset --hard $ORIGIN/$BRANCH
# fetch db credentials
echo "fetching db config"
dbname=`cat backups/config.local.php | grep \"name\" | cut -d \" -f 4`
dbuser=`cat backups/config.local.php | grep \"user\" | cut -d \" -f 4`
dbpass=`cat backups/config.local.php | grep \"pass\" | cut -d \" -f 4`
dbhost=`cat backups/config.local.php | grep \"host\" | cut -d \" -f 4`
# get last update date
lastUpdate=`cat backups/lastUpdate`
today=`date +"%Y%m&d"`
# create db backup
echo "backing up database"
mysqldump -h $dbhost -u $dbuser -p $dbpass $dbname > backups/backup_$today.sql
# look for pending SQL updates and execute
echo "updating database"
for update in sqlDumps/update_*.sql; do
if [ $lastUpdate -lt `echo $update | cut -d _ -f 2 | cut -d . -f 1` ] ; then
echo "applying update $update"
mysql -h $dbhost -u $dbuser -p $dbpass $dbname < $update
else
echo "already up to date with $update"
fi
done
echo "finishing up update"
# update last update file
echo $today > backups/lastUpdate
# move config files back
mv backups/config_current_fahrt_id ../
mv backups/config.local.php ../
mv backups/users.txt ../passwd/users.txt
echo "Please check whether the format of config files has changed..."
echo "Now get a coffee and add syntactic sugar~!"
exit 0
}
function printHelp {
echo "Script usage"
echo "-h | --help echo this help"
echo "-u | --update to update the system"
echo "-i | --install to install the system"
}
if [[ $# -eq 0 ]]; then
echo "No param given"
printHelp
else
while [[ $# -gt 0 ]];
do
opt="$1"
shift;
case "$opt" in
"-h" | "--help" )
printHelp
exit 0;;
"-u" | "--update" )
update ;;
"-i" | "--install" )
install ;;
* )
echo "Unexpected option ${opt}"
printHelp
exit 1;;
esac
done
fi
\ No newline at end of file
Require all denied
\ No newline at end of file
-- phpMyAdmin SQL Dump
-- version 4.0.10deb1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Sep 23, 2015 at 08:02 PM
-- Server version: 5.5.44-0ubuntu0.14.04.1
-- PHP Version: 5.5.9-1ubuntu4.11
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `fsfahrt`
--
-- --------------------------------------------------------
--
-- Table structure for table `bachelor`
--
CREATE TABLE IF NOT EXISTS `bachelor` (
`bachelor_id` varchar(15) NOT NULL,
`fahrt_id` int(11) NOT NULL,
`anm_time` int(11) NOT NULL,
`version` int(11) NOT NULL,
`forname` varchar(50) NOT NULL,
`sirname` varchar(50) NOT NULL,
`anday` date NOT NULL,
`abday` date NOT NULL,
`antyp` varchar(100) NOT NULL,
`abtyp` varchar(100) NOT NULL,
`pseudo` varchar(50) NOT NULL,
`mehl` varchar(100) NOT NULL,
`essen` varchar(50) NOT NULL,
`public` int(11) NOT NULL,
`virgin` int(11) NOT NULL,
`studityp` varchar(11) NOT NULL,
`comment` text NOT NULL,
`paid` int(10) DEFAULT NULL COMMENT 'zahlung erhalten am unix timestamp',
`repaid` int(10) DEFAULT NULL COMMENT 'rückzahlung abgeschickt am unix timestamp',
`backstepped` int(10) DEFAULT NULL COMMENT 'rücktritt als unix timestamp',
PRIMARY KEY (`bachelor_id`,`fahrt_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `bachelor`
--
INSERT INTO `bachelor` (`bachelor_id`, `fahrt_id`, `anm_time`, `version`, `forname`, `sirname`, `anday`, `abday`, `antyp`, `abtyp`, `pseudo`, `mehl`, `essen`, `public`, `virgin`, `studityp`, `comment`, `paid`, `repaid`, `backstepped`) VALUES
('5b61b92044983e1', 2, 0, 1, 'asd', 'ad', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'ffas', 'asdasd@asd.de', 'Alles', 1, 0, '0', 'dasd', NULL, NULL, 1411059051),
('f35f12ca7c55462', 2, 0, 1, 'fcacs', 'ads', '2013-10-18', '2013-10-19', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'fas', 'asd@asd.de', 'Alles', 0, 0, '0', 'adasdasda', NULL, NULL, NULL),
('068e4198f255a1e', 2, 0, 1, 'göll', 'asd', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'adsad', 'adskd@asdl.de', 'Alles', 1, 0, '0', 'adasd', 1409779206, NULL, NULL),
('d748d40c0d7e475', 2, 0, 1, 'ad', 'adsd', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'asdadl', 'asdas@asd.de', 'Vegan', 1, 0, '0', 'ad', NULL, NULL, NULL),
('ec2cac23f915bf9', 2, 0, 1, 'gbhg', 'ncvbx', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'cvxcvxsdfs', 'ads@asdl.de', 'Alles', 1, 0, '0', 'ycyxc', NULL, NULL, 1408205076),
('78a322842b66657', 2, 0, 1, 'lkblka', 'kbvnfj', '2013-10-18', '2013-10-20', 'individuell', 'gemeinsam mit Rad', 'kmkm', 'sdkk@ksad.de', 'Vegan', 1, 0, 'MasterErsti', 'asda', NULL, NULL, NULL),
('8d70b435d61c302', 2, 0, 1, 'gm', 'sdlkjflkj', '2013-10-18', '2013-10-20', 'gemeinsam mit Rad', 'individuell', 'skldfmlk', 'sfjdkl@dfjklj.de', 'Grießbrei', 1, 0, 'Hoersti', 'asddsa', NULL, NULL, NULL),
('c8c1d8a327fd88f', 2, 0, 1, 'lkdnl', 'sdkjfhnk', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Rad', 'adhsj', 'fsfahrt@byom.de', 'Frutarisch', 1, 0, 'Hoersti', 'adas', 1408205076, NULL, NULL),
('7f5609769cce5f1', 2, 0, 1, 'lkdnl', 'sdkjfhnk', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Rad', 'adhsj', 'fsfahrt@byom.de', 'Frutarisch', 1, 0, 'Hoersti', 'adas', 1408105076, 1408205076, NULL),
('61fd805b3bbe4b5', 2, 0, 1, 'rcsa', 'adas', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'gdsfa', 'asdas@deda-de.de', 'Extrawurst', 1, 0, 'Wechsli', '', NULL, NULL, 1411251707),
('9593abed7ec0b79', 2, 0, 1, 'bla', 'blubb', '2013-10-18', '2013-10-20', 'mit Kamel', 'mit Kamel', 'ah', 'reichskanzlei@web.dr', 'Vegetarisch', 1, 0, 'Tutor', 'Mit Kamel!', NULL, NULL, NULL),
('4eb203cf14c7a4e', 2, 1409761827, 1, 'dlklödsa', 'adlökl', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Rad', 'dsaoif', 'daskdj@asdkj.de', 'Alles', 1, 0, 'Ersti', '', NULL, NULL, NULL),
('810789efb42264d', 2, 1409763812, 1, 'klalsd', 'ladköl', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'sdkfölk', 'alksd@aslkdj.de', 'Alles', 1, 0, 'Ersti', '', NULL, NULL, NULL),
('09ca2d98ea68524', 2, 1411224273, 1, 'ölmm', 'ölkö', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'lkkldslk', 'aksdllk@asdjk.de', 'Alles', 1, 0, 'Ersti', '', NULL, NULL, 1411251706),
('9de69c5684a4c28', 2, 1411249881, 1, 'random', 'so random', '2013-10-18', '2013-10-20', 'individuell', 'individuell', 'superrandom', 'ran@om.de', 'Alles', 1, 0, 'Ersti', 'randomtest', NULL, NULL, NULL),
('0baff8036ee698b', 2, 1411432206, 1, 'as', 'das', '0000-00-00', '0000-00-00', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'ffas', 'asdsa@asd.de', 'Vegan', 1, 0, 'Hoersti', '', NULL, NULL, NULL),
('54cdf371a2f56b9', 2, 1411432331, 1, 'klau', 'asdk', '0000-00-00', '0000-00-00', 'Kamel/Individuell', 'gemeinsam mit Bus/Bahn', 'mutter', 'back@web.de', 'Vegan', 1, 0, 'Ersti', '', NULL, NULL, NULL),
('a62d6883688789f', 2, 1411682781, 1, 'asd', 'asdd', '0000-00-00', '0000-00-00', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'asdas', 'asdas@sad.de', 'Alles', 1, 0, 'Ersti', '', NULL, NULL, NULL),
('61ed33f03d0de0b', 2, 1411686132, 1, 'adsd', 'adss', '2013-10-19', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'date', 'adslk@asldk.de', 'Alles', 1, 0, 'Ersti', '', NULL, NULL, NULL),
('bb4dc6d782c98c0', 2, 1411767105, 1, 'letzter', 'adkslj', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Rad', 'letzter', 'adslkj@askd.de', 'Vegetarisch', 1, 0, 'Tutor', 'asdads', NULL, NULL, NULL),
('bfdefb03deb3bcb', 2, 1411767151, 1, 'nkjkl', 'kjlk', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'kljlk', 'alkdsj@ads.de', 'Alles', 1, 0, 'Ersti', '', NULL, NULL, NULL),
('6ec42e12e2368c0', 2, 1411767427, 1, 'qwe', 'qwe', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'asd', 'qwe@qw.qw', 'Alles', 1, 0, 'Ersti', '', NULL, NULL, NULL),
('9e450c55e562d0c', 2, 1439849004, 1, 'asdsad', 'asd', '2013-10-25', '2013-10-27', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'ad', 'asd@aasd.de', 'Alles', 1, 0, 'Ersti', 'asdas', NULL, NULL, NULL),
('0856eee9f07a698', 2, 1439849898, 1, 'sd', 'sad', '2013-10-25', '2013-10-27', 'selbst mit Auto', 'gemeinsam mit Bus/Bahn', 'asd', 'asd@asd.de', 'Alles', 1, 0, 'Hoersti', 'asdasd', NULL, NULL, NULL),
('15e27f42693195e', 2, 1442605414, 1, 'asd', 'kjkj', '2013-10-25', '2013-10-27', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'kjklj', 'doch@byom.de', 'Alles', 1, 0, 'Ersti', 'asdd', NULL, NULL, NULL),
('af0dadca8dbd2f2', 2, 1442606515, 1, 'lödasklök', 'ödasklö', '2013-10-25', '2013-10-27', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'asdlkö', 'adskl@adskl.de', 'Alles', 1, 0, 'Ersti', 'adsdas', NULL, NULL, NULL);
-- --------------------------------------------------------
--
-- Table structure for table `cost`
--
CREATE TABLE IF NOT EXISTS `cost` (
`fahrt_id` int(11) NOT NULL COMMENT 'trip associated to calculation',
`tab1` text NOT NULL COMMENT 'JSON dump of tab1',
`tab2` text NOT NULL COMMENT 'JSON dump of tab2',
`tab3` text NOT NULL COMMENT 'JSON dump of tab3',
`moneyIO` text NOT NULL COMMENT 'JSON dump of money IO',
`collected` int(11) NOT NULL COMMENT 'amount collected per person before trip'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `cost`
--
INSERT INTO `cost` (`fahrt_id`, `tab1`, `tab2`, `tab3`, `moneyIO`, `collected`) VALUES
(2, '', '', '', '', 60);
-- --------------------------------------------------------
--
-- Table structure for table `fahrten`
--
CREATE TABLE IF NOT EXISTS `fahrten` (
`fahrt_id` int(11) NOT NULL AUTO_INCREMENT,
`titel` varchar(200) NOT NULL,
`ziel` varchar(100) NOT NULL,
`von` date NOT NULL,
`bis` date NOT NULL,
`regopen` int(1) NOT NULL,
`beschreibung` text NOT NULL,
`leiter` varchar(100) NOT NULL,
`kontakt` varchar(100) NOT NULL,
`map_pin` text NOT NULL,
`max_bachelor` int(4) NOT NULL,
`wikilink` varchar(255) NOT NULL DEFAULT 'https://wiki.fachschaft.informatik.hu-berlin.de/wiki/Erstsemesterfahrt',
`paydeadline` date NOT NULL,
`payinfo` text NOT NULL,
`opentime` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`fahrt_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
--
-- Dumping data for table `fahrten`
--
INSERT INTO `fahrten` (`fahrt_id`, `titel`, `ziel`, `von`, `bis`, `regopen`, `beschreibung`, `leiter`, `kontakt`, `map_pin`, `max_bachelor`, `wikilink`, `paydeadline`, `payinfo`, `opentime`) VALUES
(1, 'Fachschaftsfahrt Winter 2012', 'KiEZ Inselparadies am Schwielowsee bei Werder', '2012-10-26', '2012-10-28', 0, 'Alle Informationen zur Fahrt im <a rel="nofollow" target="_blank" href="http://wiki.fachschaft.informatik.hu-berlin.de/wiki/Fachschaftsfahrt_Winter_2012">Wiki</a>', 'Tim Repke', 'nein@nein.de', ' ', 2, 'https://wiki.fachschaft.informatik.hu-berlin.de/wiki/Erstsemesterfahrt', '0000-00-00', '', 0),
(2, 'Fachschaftsfahrt Winter 2013', 'KiEZ Frauensee bei Gräbendorf', '2013-10-25', '2013-10-27', 1, 'Erstsemester und Fachschaftsfahrt im Wintersemester 13/14<br>Alle Informationen im <a rel="nofollow" target="_blank" href="http://wiki.fachschaft.informatik.hu-berlin.de/wiki/Fachschaftsfahrt_Winter_2013">Wiki</a>', 'Tim Repke', 'nein@byom.de', '52.49151043325418 13.453114630310097', 30, 'https://wiki.fachschaft.infdtik.hu-berlin.de/wiki/Erstsemesterfahrt', '2015-09-16', 'sad\r\nasd\r\nasd\r\nadd', 1443024045),
(5, 'Fachschaftsfahrt Winter 2014', ' Jugendherberge Münchehofe', '2014-10-24', '2014-10-26', 1, 'Dies ist die Anmeldung zur Erstsemester-/Fachschaftsfahrt im Wintersemester 2014/15. <br>Weitere Infos sind im <a rel="nofollow" target="_blank" href="http://wiki.fachschaft.informatik.hu-berlin.de/wiki/Fachschaftsfahrt_Winter_2014">Wiki</a>', 'Georg Gentzen', 'gentzeng@informatik.hu-berlin.de', '52.55853564453215 14.14091885241703', 60, 'https://wiki.fachschaft.informatik.hu-berlin.de/wiki/Erstsemesterfahrt', '0000-00-00', '', 0),
(6, 'neu', 'asds', '2015-08-17', '2015-08-17', 1, 'saddaasda &nbsp;asdd ad s', 'asad', 'asds@asdkd.de', '52.43893109993363 13.648079039184609', 30, 'https://wiki.fachschaft.informatik.hu-berlin.de/wiki/Erstsemesterfahrt', '2015-09-24', 'asd\r\nasd\r\n234\r\n14', 1443034837);
-- --------------------------------------------------------
--
-- Table structure for table `notes`
--
CREATE TABLE IF NOT EXISTS `notes` (
`note_id` int(11) NOT NULL AUTO_INCREMENT,
`fahrt_id` int(11) NOT NULL,
`note` text NOT NULL,
PRIMARY KEY (`note_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `notes`
--
INSERT INTO `notes` (`note_id`, `fahrt_id`, `note`) VALUES
(1, 1, 'fahrt1 note'),
(2, 2, '<h1><b>Testnotiz 123<br></b></h1>hier kann man <i>notizen </i>hinterlassen test<br><br><h2><b>Dumme Bemerkung</b></h2>Notiz = no&nbsp;<span class="wysiwyg-color-red">tits!<br></span><b><br><br>aoisdkd<br>asdlji<br><br></b><b><br></b>');
-- --------------------------------------------------------
--
-- Table structure for table `waitlist`
--
CREATE TABLE IF NOT EXISTS `waitlist` (
`waitlist_id` int(11) NOT NULL AUTO_INCREMENT,
`fahrt_id` int(11) NOT NULL,
`anm_time` int(11) NOT NULL,
`forname` varchar(50) NOT NULL,
`sirname` varchar(50) NOT NULL,
`anday` date NOT NULL,
`abday` date NOT NULL,
`antyp` varchar(100) NOT NULL,
`abtyp` varchar(100) NOT NULL,
`pseudo` varchar(50) NOT NULL,
`mehl` varchar(100) NOT NULL,
`essen` varchar(50) NOT NULL,
`public` int(11) NOT NULL,
`virgin` int(11) NOT NULL,
`studityp` varchar(11) NOT NULL,
`comment` text NOT NULL,
`transferred` int(11) NOT NULL,
PRIMARY KEY (`waitlist_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
-- phpMyAdmin SQL Dump
-- version 4.0.10deb1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Oct 04, 2015 at 06:43 PM
-- Server version: 5.5.44-0ubuntu0.14.04.1
-- PHP Version: 5.5.9-1ubuntu4.11
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `fsfahrt`
--
-- --------------------------------------------------------
--
-- Table structure for table `bachelor`
--
CREATE TABLE IF NOT EXISTS `bachelor` (
`bachelor_id` varchar(15) NOT NULL,
`fahrt_id` int(11) NOT NULL,
`anm_time` int(11) NOT NULL,
`version` int(11) NOT NULL,
`forname` varchar(50) NOT NULL,
`sirname` varchar(50) NOT NULL,
`anday` date NOT NULL,
`abday` date NOT NULL,
`antyp` varchar(100) NOT NULL,
`abtyp` varchar(100) NOT NULL,
`pseudo` varchar(50) NOT NULL,
`mehl` varchar(100) NOT NULL,
`essen` varchar(50) NOT NULL,
`public` int(11) NOT NULL,
`virgin` int(11) NOT NULL,
`studityp` varchar(11) NOT NULL,
`comment` text NOT NULL,
`paid` int(10) DEFAULT NULL COMMENT 'zahlung erhalten am unix timestamp',
`repaid` int(10) DEFAULT NULL COMMENT 'rückzahlung abgeschickt am unix timestamp',
`backstepped` int(10) DEFAULT NULL COMMENT 'rücktritt als unix timestamp',
PRIMARY KEY (`bachelor_id`,`fahrt_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `bachelor`
--
INSERT INTO `bachelor` (`bachelor_id`, `fahrt_id`, `anm_time`, `version`, `forname`, `sirname`, `anday`, `abday`, `antyp`, `abtyp`, `pseudo`, `mehl`, `essen`, `public`, `virgin`, `studityp`, `comment`, `paid`, `repaid`, `backstepped`) VALUES
('5b61b92044983e1', 2, 0, 1, 'asd', 'ad', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'ffas', 'asdasd@asd.de', 'Alles', 1, 0, '0', 'dasd', NULL, NULL, 1411059051),
('f35f12ca7c55462', 2, 0, 1, 'fcacs', 'ads', '2013-10-18', '2013-10-19', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'fas', 'asd@asd.de', 'Alles', 0, 0, '0', 'adasdasda', NULL, NULL, NULL),
('068e4198f255a1e', 2, 0, 1, 'göll', 'asd', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'adsad', 'adskd@asdl.de', 'Alles', 1, 0, '0', 'adasd', 1409779206, NULL, NULL),
('d748d40c0d7e475', 2, 0, 1, 'ad', 'adsd', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'asdadl', 'asdas@asd.de', 'Vegan', 1, 0, '0', 'ad', NULL, NULL, NULL),
('ec2cac23f915bf9', 2, 0, 1, 'gbhg', 'ncvbx', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'cvxcvxsdfs', 'ads@asdl.de', 'Alles', 1, 0, '0', 'ycyxc', NULL, NULL, 1408205076),
('78a322842b66657', 2, 0, 1, 'lkblka', 'kbvnfj', '2013-10-18', '2013-10-20', 'individuell', 'gemeinsam mit Rad', 'kmkm', 'sdkk@ksad.de', 'Vegan', 1, 0, 'MasterErsti', 'asda', NULL, NULL, NULL),
('8d70b435d61c302', 2, 0, 1, 'gm', 'sdlkjflkj', '2013-10-18', '2013-10-20', 'gemeinsam mit Rad', 'individuell', 'skldfmlk', 'sfjdkl@dfjklj.de', 'Grießbrei', 1, 0, 'Hoersti', 'asddsa', NULL, NULL, NULL),
('c8c1d8a327fd88f', 2, 0, 1, 'lkdnl', 'sdkjfhnk', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Rad', 'adhsj', 'fsfahrt@byom.de', 'Frutarisch', 1, 0, 'Hoersti', 'adas', 1408205076, NULL, NULL),
('7f5609769cce5f1', 2, 0, 1, 'lkdnl', 'sdkjfhnk', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Rad', 'adhsj', 'fsfahrt@byom.de', 'Frutarisch', 1, 0, 'Hoersti', 'adas', 1408105076, 1408205076, NULL),
('61fd805b3bbe4b5', 2, 0, 1, 'rcsa', 'adas', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'gdsfa', 'asdas@deda-de.de', 'Extrawurst', 1, 0, 'Wechsli', '', NULL, NULL, 1411251707),
('9593abed7ec0b79', 2, 0, 1, 'bla', 'blubb', '2013-10-18', '2013-10-20', 'mit Kamel', 'mit Kamel', 'ah', 'reichskanzlei@web.dr', 'Vegetarisch', 1, 0, 'Tutor', 'Mit Kamel!', NULL, NULL, NULL),
('4eb203cf14c7a4e', 2, 1409761827, 1, 'dlklödsa', 'adlökl', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Rad', 'dsaoif', 'daskdj@asdkj.de', 'Alles', 1, 0, 'Ersti', '', NULL, NULL, NULL),
('810789efb42264d', 2, 1409763812, 1, 'klalsd', 'ladköl', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'sdkfölk', 'alksd@aslkdj.de', 'Alles', 1, 0, 'Ersti', '', NULL, NULL, NULL),
('09ca2d98ea68524', 2, 1411224273, 1, 'ölmm', 'ölkö', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'lkkldslk', 'aksdllk@asdjk.de', 'Alles', 1, 0, 'Ersti', '', NULL, NULL, 1411251706),
('9de69c5684a4c28', 2, 1411249881, 1, 'random', 'so random', '2013-10-18', '2013-10-20', 'individuell', 'individuell', 'superrandom', 'ran@om.de', 'Alles', 1, 0, 'Ersti', 'randomtest', NULL, NULL, NULL),
('0baff8036ee698b', 2, 1411432206, 1, 'as', 'das', '0000-00-00', '0000-00-00', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'ffas', 'asdsa@asd.de', 'Vegan', 1, 0, 'Hoersti', '', NULL, NULL, NULL),
('54cdf371a2f56b9', 2, 1411432331, 1, 'klau', 'asdk', '0000-00-00', '0000-00-00', 'Kamel/Individuell', 'gemeinsam mit Bus/Bahn', 'mutter', 'back@web.de', 'Vegan', 1, 0, 'Ersti', '', NULL, NULL, NULL),
('a62d6883688789f', 2, 1411682781, 1, 'asd', 'asdd', '0000-00-00', '0000-00-00', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'asdas', 'asdas@sad.de', 'Alles', 1, 0, 'Ersti', '', NULL, NULL, NULL),
('61ed33f03d0de0b', 2, 1411686132, 1, 'adsd', 'adss', '2013-10-19', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'date', 'adslk@asldk.de', 'Alles', 1, 0, 'Ersti', '', NULL, NULL, NULL),
('bb4dc6d782c98c0', 2, 1411767105, 1, 'letzter', 'adkslj', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Rad', 'letzter', 'adslkj@askd.de', 'Vegetarisch', 1, 0, 'Tutor', 'asdads', NULL, NULL, NULL),
('bfdefb03deb3bcb', 2, 1411767151, 1, 'nkjkl', 'kjlk', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'kljlk', 'alkdsj@ads.de', 'Alles', 1, 0, 'Ersti', '', NULL, NULL, NULL),
('6ec42e12e2368c0', 2, 1411767427, 1, 'qwe', 'qwe', '2013-10-18', '2013-10-20', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'asd', 'qwe@qw.qw', 'Alles', 1, 0, 'Ersti', '', NULL, NULL, NULL),
('9e450c55e562d0c', 2, 1439849004, 1, 'asdsad', 'asd', '2013-10-25', '2013-10-27', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'ad', 'asd@aasd.de', 'Alles', 1, 0, 'Ersti', 'asdas', NULL, NULL, NULL),
('0856eee9f07a698', 2, 1439849898, 1, 'sd', 'sad', '2013-10-25', '2013-10-27', 'selbst mit Auto', 'gemeinsam mit Bus/Bahn', 'asd', 'asd@asd.de', 'Alles', 1, 0, 'Hoersti', 'asdasd', NULL, NULL, NULL),
('15e27f42693195e', 2, 1442605414, 1, 'asd', 'kjkj', '2013-10-25', '2013-10-27', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'kjklj', 'doch@byom.de', 'Alles', 1, 0, 'Ersti', 'asdd', NULL, NULL, NULL),
('af0dadca8dbd2f2', 2, 1442606515, 1, 'lödasklök', 'ödasklö', '2013-10-25', '2013-10-27', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'asdlkö', 'adskl@adskl.de', 'Alles', 1, 0, 'Ersti', 'adsdas', NULL, NULL, NULL);
-- --------------------------------------------------------
--
-- Table structure for table `cost`
--
CREATE TABLE IF NOT EXISTS `cost` (
`fahrt_id` int(11) NOT NULL COMMENT 'trip associated to calculation',
`tab1` text NOT NULL COMMENT 'JSON dump of tab1',
`tab2` text NOT NULL COMMENT 'JSON dump of tab2',
`tab3` text NOT NULL COMMENT 'JSON dump of tab3',
`moneyIO` text NOT NULL COMMENT 'JSON dump of money IO',
`collected` int(11) NOT NULL COMMENT 'amount collected per person before trip'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `cost`
--
INSERT INTO `cost` (`fahrt_id`, `tab1`, `tab2`, `tab3`, `moneyIO`, `collected`) VALUES
(2, '', '', '', '', 60);
-- --------------------------------------------------------
--
-- Table structure for table `fahrten`
--
CREATE TABLE IF NOT EXISTS `fahrten` (
`fahrt_id` int(11) NOT NULL AUTO_INCREMENT,
`titel` varchar(200) NOT NULL,
`ziel` varchar(100) NOT NULL,
`von` date NOT NULL,
`bis` date NOT NULL,
`regopen` int(1) NOT NULL,
`beschreibung` text NOT NULL,
`leiter` varchar(100) NOT NULL,
`kontakt` varchar(100) NOT NULL,
`map_pin` text NOT NULL,
`max_bachelor` int(4) NOT NULL,
`wikilink` varchar(255) NOT NULL DEFAULT 'https://wiki.fachschaft.informatik.hu-berlin.de/wiki/Erstsemesterfahrt',
`paydeadline` date NOT NULL,
`payinfo` text NOT NULL,
`opentime` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`fahrt_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ;
--
-- Dumping data for table `fahrten`
--
INSERT INTO `fahrten` (`fahrt_id`, `titel`, `ziel`, `von`, `bis`, `regopen`, `beschreibung`, `leiter`, `kontakt`, `map_pin`, `max_bachelor`, `wikilink`, `paydeadline`, `payinfo`, `opentime`) VALUES
(1, 'Fachschaftsfahrt Winter 2012', 'KiEZ Inselparadies am Schwielowsee bei Werder', '2012-10-26', '2012-10-28', 0, 'Alle Informationen zur Fahrt im <a rel="nofollow" target="_blank" href="http://wiki.fachschaft.informatik.hu-berlin.de/wiki/Fachschaftsfahrt_Winter_2012">Wiki</a>', 'Tim Repke', 'nein@nein.de', ' ', 2, 'https://wiki.fachschaft.informatik.hu-berlin.de/wiki/Erstsemesterfahrt', '0000-00-00', '', 0),
(2, 'Fachschaftsfahrt Winter 2013', 'KiEZ Frauensee bei Gräbendorf', '2013-10-25', '2013-10-27', 1, 'Erstsemester und Fachschaftsfahrt im Wintersemester 13/14<br>Alle Informationen im <a rel="nofollow" target="_blank" href="http://wiki.fachschaft.informatik.hu-berlin.de/wiki/Fachschaftsfahrt_Winter_2013">Wiki</a>', 'Tim Repke', 'nein@byom.de', '52.49151043325418 13.453114630310097', 30, 'https://wiki.fachschaft.infdtik.hu-berlin.de/wiki/Erstsemesterfahrt', '2015-09-16', 'sad\r\nasd\r\nasd\r\nadd', 1443024045),
(5, 'Fachschaftsfahrt Winter 2014', ' Jugendherberge Münchehofe', '2014-10-24', '2014-10-26', 1, 'Dies ist die Anmeldung zur Erstsemester-/Fachschaftsfahrt im Wintersemester 2014/15. <br>Weitere Infos sind im <a rel="nofollow" target="_blank" href="http://wiki.fachschaft.informatik.hu-berlin.de/wiki/Fachschaftsfahrt_Winter_2014">Wiki</a>', 'Georg Gentzen', 'gentzeng@informatik.hu-berlin.de', '52.55853564453215 14.14091885241703', 60, 'https://wiki.fachschaft.informatik.hu-berlin.de/wiki/Erstsemesterfahrt', '0000-00-00', '', 0),
(6, 'neu', 'asds', '2015-10-23', '2015-10-25', 1, 'saddaasda &nbsp;asdd ad s', 'asad', 'asds@asdkd.de', '52.43893109993363 13.648079039184609', 0, 'https://wiki.fachschaft.informatik.hu-berlin.de/wiki/Erstsemesterfahrt', '2015-09-24', 'asd\r\nasd\r\n234\r\n14', 1443639637);
-- --------------------------------------------------------
--
-- Table structure for table `notes`
--
CREATE TABLE IF NOT EXISTS `notes` (
`note_id` int(11) NOT NULL AUTO_INCREMENT,
`fahrt_id` int(11) NOT NULL,
`note` text NOT NULL,
PRIMARY KEY (`note_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `notes`
--
INSERT INTO `notes` (`note_id`, `fahrt_id`, `note`) VALUES
(1, 1, 'fahrt1 note'),
(2, 2, '<h1><b>Testnotiz 123<br></b></h1>hier kann man <i>notizen </i>hinterlassen test<br><br><h2><b>Dumme Bemerkung</b></h2>Notiz = no&nbsp;<span class="wysiwyg-color-red">tits!<br></span><b><br><br>aoisdkd<br>asdlji<br><br></b><b><br></b>');
-- --------------------------------------------------------
--
-- Table structure for table `waitlist`
--
CREATE TABLE IF NOT EXISTS `waitlist` (
`waitlist_id` int(11) NOT NULL AUTO_INCREMENT,
`fahrt_id` int(11) NOT NULL,
`anm_time` int(11) NOT NULL,
`forname` varchar(50) NOT NULL,
`sirname` varchar(50) NOT NULL,
`anday` date NOT NULL,
`abday` date NOT NULL,
`antyp` varchar(100) NOT NULL,
`abtyp` varchar(100) NOT NULL,
`pseudo` varchar(50) NOT NULL,
`mehl` varchar(100) NOT NULL,
`essen` varchar(50) NOT NULL,
`public` int(11) NOT NULL,
`virgin` int(11) NOT NULL,
`studityp` varchar(11) NOT NULL,
`comment` text NOT NULL,
`transferred` int(11) DEFAULT NULL,
PRIMARY KEY (`waitlist_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
--
-- Dumping data for table `waitlist`
--
INSERT INTO `waitlist` (`waitlist_id`, `fahrt_id`, `anm_time`, `forname`, `sirname`, `anday`, `abday`, `antyp`, `abtyp`, `pseudo`, `mehl`, `essen`, `public`, `virgin`, `studityp`, `comment`, `transferred`) VALUES
(1, 6, 1443975605, 'sddsa', 'asd', '2015-10-23', '2015-10-25', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'asd', 'asd@aasd.de', 'Alles', 1, 0, 'Ersti', '', 0);
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
-- phpMyAdmin SQL Dump
-- version 4.6.4
-- https://www.phpmyadmin.net/
--
-- Host: db:3306
-- Generation Time: Oct 20, 2016 at 08:20 PM
-- Server version: 5.5.52-MariaDB-1ubuntu0.14.04.1
-- PHP Version: 5.6.26
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
--
-- Database: `fsfahrt`
--
-- --------------------------------------------------------
--
-- Table structure for table `bachelor`
--
CREATE TABLE `bachelor` (
`bachelor_id` varchar(15) NOT NULL,
`fahrt_id` int(11) NOT NULL,
`anm_time` int(11) NOT NULL,
`version` int(11) NOT NULL,
`forname` varchar(50) NOT NULL,
`sirname` varchar(50) NOT NULL,
`anday` date NOT NULL,
`abday` date NOT NULL,
`antyp` varchar(100) NOT NULL,
`abtyp` varchar(100) NOT NULL,
`pseudo` varchar(50) NOT NULL,
`mehl` varchar(100) NOT NULL,
`essen` varchar(50) NOT NULL,
`public` int(11) NOT NULL,
`virgin` int(11) NOT NULL,
`studityp` varchar(11) NOT NULL,
`comment` text NOT NULL,
`paid` int(10) DEFAULT NULL COMMENT 'zahlung erhalten am unix timestamp',
`repaid` int(10) DEFAULT NULL COMMENT 'rückzahlung abgeschickt am unix timestamp',
`backstepped` int(10) DEFAULT NULL COMMENT 'rücktritt als unix timestamp',
`on_waitlist` int(11) NOT NULL DEFAULT '0',
`transferred` int(11) DEFAULT NULL,
`signupstats` text
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `bachelor`
--
INSERT INTO `bachelor` (`bachelor_id`, `fahrt_id`, `anm_time`, `version`, `forname`, `sirname`, `anday`, `abday`, `antyp`, `abtyp`, `pseudo`, `mehl`, `essen`, `public`, `virgin`, `studityp`, `comment`, `paid`, `repaid`, `backstepped`, `on_waitlist`, `transferred`, `signupstats`) VALUES
('5b61b92044983e1', 2, 1411767105, 3, 'John', 'Doe', '2013-10-25', '2013-10-27', 'BUSBAHN', 'BUSBAHN', 'Backstepped', 'some@mail.com', 'ALLES', 1, 1, 'ERSTI', 'Test comment', NULL, NULL, 1476889935, 0, NULL, '{"method":"game1", "methodinfo":{"achievedAchievements":[1,2,3,4,5,3,3,3,3,3,3]}}'),
('06030f06b6e9194', 2, 1476889983, 2, 'TestA', 'Test', '2013-10-25', '2013-10-27', 'BUSBAHN', 'BUSBAHN', 'Paid', 'test@test.de', 'ALLES', 1, 0, 'ERSTI', 'huii', 1476890174, NULL, NULL, 0, NULL, '{"method":"game1", "methodinfo":{"achievedAchievements":[1,2,3,4,5,3,3,3,3,3,3]}}'),
('06030f06b6e9195', 2, 1476889983, 2, 'TestA', 'Test', '2013-10-25', '2013-10-27', 'BUSBAHN', 'BUSBAHN', 'RePaid', 'test@test.de', 'ALLES', 1, 0, 'ERSTI', 'huii', NULL, 1476890179, NULL, 0, NULL, '{"method":"game1", "methodinfo":{"achievedAchievements":["first_step", "some_water", "saw_devs1", "spotted_gorilla", "hydrant", "muell","randomwalk", "rettich_pick", "kohl", "mais", "rasenmeh", "moneyboy", "batteries", "bierball", "bild","hu", "holz", "karriereleiter", "wrong_board", "hugo_water", "laptop2", "laptop1", "marathon", "ffa","stolper", "fs_chair", "laser", "speedrun", "woman", "plumber", "princess", "stroh", "blumen", "maske","gentzen", "kacke", "antler", "flowers", "wine", "chair", "started_game", "gameDone", "achievement42"]}}'),
('06030f06b6e9196', 2, 1476889983, 3, 'TestA', 'Test', '2013-10-26', '2013-10-27', 'BUSBAHN', 'BUSBAHN', 'Paid+repaid', 'test@test.de', 'ALLES', 0, 0, 'ERSTI', 'huii', 1476890176, 1476890177, NULL, 0, NULL, NULL),
('06030f06b6e9197', 2, 1476889983, 5, 'TestA', 'Test', '2013-10-25', '2013-10-27', 'BUSBAHN', 'BUSBAHN', 'Paid+backstepped', 'test@test.de', 'ALLES', 1, 0, 'ERSTI', 'huii', 1476890169, NULL, 1476890168, 0, NULL, NULL),
('06030f06b6e9198', 2, 1476889983, 1, 'TestA', 'Test', '2013-10-25', '2013-10-27', 'BUSBAHN', 'BUSBAHN', 'tutti', 'test@test.de', 'ALLES', 0, 0, 'TUTTI', 'huii', NULL, NULL, NULL, 0, NULL, NULL),
('06030f06b6e9193', 2, 1476889983, 1, 'TestA', 'Test', '2013-10-25', '2013-10-27', 'BUSBAHN', 'BUSBAHN', 'hoersti', 'test@test.de', 'ALLES', 1, 0, 'HOERS', 'huii', NULL, NULL, NULL, 0, NULL, '{"method":"game1", "methodinfo":{"achievedAchievements":["first_step", "some_water", "saw_devs1", "spotted_gorilla", "hydrant", "muell","randomwalk", "rettich_pick", "kohl", "mais", "rasenmeh", "moneyboy", "batteries", "bierball", "bild","hu", "holz", "karriereleiter", "wrong_board", "hugo_water", "laptop2", "laptop1", "marathon", "ffa","stolper", "fs_chair", "laser", "speedrun", "woman", "plumber", "princess", "stroh", "blumen", "maske", "achievement42"]}}'),
('06030f06b6e919', 2, 1476889983, 3, 'TestA', 'Test', '2013-10-25', '2013-10-26', 'INDIVIDUELL', 'INDIVIDUELL', 'individuell', 'test@test.de', 'VEGA', 1, 0, 'ERSTI', 'huii', NULL, NULL, NULL, 1, NULL, NULL),
('06030f06b6e929', 2, 1476889983, 3, 'TestA', 'Test', '2013-10-25', '2013-10-27', 'RAD', 'BUSBAHN', 'rad', 'test@test.de', 'VEGE', 1, 0, 'ERSTI', 'huii', NULL, NULL, NULL, 0, NULL, '{"method":"game1", "methodinfo":{"achievedAchievements":["first_step", "some_water", "saw_devs1", "spotted_gorilla", "hydrant", "muell","randomwalk", "rettich_pick", "kohl", "mais", "rasenmeh", "moneyboy", "batteries", "bierball", "bild","hu", "holz", "karriereleiter", "wrong_board", "achievement42"]}}'),
('06030f06b6e939', 2, 1476889983, 3, 'TestA', 'Test', '2013-10-25', '2013-10-27', 'BUSBAHN', 'BUSBAHN', 'wait', 'test@test.de', 'VEGE', 0, 0, 'ERSTI', 'huii', NULL, NULL, NULL, 1, NULL, NULL),
('06030f06b6e949', 2, 1476889983, 3, 'TestA', 'Test', '2013-10-25', '2013-10-27', 'INDIVIDUELL', 'BUSBAHN', 'bla', 'test@test.de', 'ALLES', 1, 0, 'ERSTI', 'huii', NULL, NULL, NULL, 0, NULL, NULL),
('06030f06b6e959', 2, 1476889983, 4, 'TestA', 'Test', '2013-10-26', '2013-10-27', 'BUSBAHN', 'BUSBAHN', 'wait+trans', 'test@test.de', 'ALLES', 1, 0, 'ERSTI', 'huii', NULL, NULL, NULL, 1, 1476890563, NULL),
('dc29d62c30756a3', 2, 1476992412, 2, 'asd', 'asd', '2013-10-26', '2013-10-27', 'BUSBAHN', 'BUSBAHN', 'asd', 'asd@asd.de', 'VEGA', 1, 1, 'ERSTI', '', NULL, NULL, NULL, 1, 1476992435, '{"method":"story","methodinfo":{"achievements":["stein","elch2","park"]}}');
-- --------------------------------------------------------
--
-- Table structure for table `cost`
--
CREATE TABLE `cost` (
`fahrt_id` int(11) NOT NULL COMMENT 'trip associated to calculation',
`tab1` text NOT NULL COMMENT 'JSON dump of tab1',
`tab2` text NOT NULL COMMENT 'JSON dump of tab2',
`tab3` text NOT NULL COMMENT 'JSON dump of tab3',
`moneyIO` text NOT NULL COMMENT 'JSON dump of money IO',
`collected` int(11) NOT NULL COMMENT 'amount collected per person before trip'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
--
-- Dumping data for table `cost`
--
INSERT INTO `cost` (`fahrt_id`, `tab1`, `tab2`, `tab3`, `moneyIO`, `collected`) VALUES
(2, '', '', '[{"pos":"Bettwäsche","cnt":"1","mul":"40","price":"1.43"},{"pos":"Grillnutzung","cnt":"1","mul":"40","price":"0.3"},{"pos":"Halbpension","cnt":"2","mul":"40","price":"12.30"},{"pos":"Klodeckel","cnt":1,"mul":1,"price":"33"},{"pos":"blubb","cnt":1,"mul":1,"price":"03"}]', '', 60);
-- --------------------------------------------------------
--
-- Table structure for table `fahrten`
--
CREATE TABLE `fahrten` (
`fahrt_id` int(11) NOT NULL,
`titel` varchar(200) NOT NULL,
`ziel` varchar(100) NOT NULL,
`von` date NOT NULL,
`bis` date NOT NULL,
`regopen` int(1) NOT NULL,
`beschreibung` text NOT NULL,
`leiter` varchar(100) NOT NULL,
`kontakt` varchar(100) NOT NULL,
`map_pin` text NOT NULL,
`max_bachelor` int(4) NOT NULL,
`wikilink` varchar(255) NOT NULL DEFAULT 'https://wiki.fachschaft.informatik.hu-berlin.de/wiki/Erstsemesterfahrt',
`paydeadline` date NOT NULL,
`payinfo` text NOT NULL,
`opentime` int(11) NOT NULL DEFAULT '0',
`disclaimlink` varchar(255) NOT NULL DEFAULT ''
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `fahrten`
--
INSERT INTO `fahrten` (`fahrt_id`, `titel`, `ziel`, `von`, `bis`, `regopen`, `beschreibung`, `leiter`, `kontakt`, `map_pin`, `max_bachelor`, `wikilink`, `paydeadline`, `payinfo`, `opentime`, `disclaimlink`) VALUES
(2, 'Fachschaftsfahrt Winter 2013', 'KiEZ Frauensee bei Gräbendorf', '2013-10-25', '2013-10-27', 1, 'Erstsemester und Fachschaftsfahrt im Wintersemester 13/14<br>Alle Informationen im <a rel="nofollow" target="_blank" href="http://wiki.fachschaft.informatik.hu-berlin.de/wiki/Fachschaftsfahrt_Winter_2013">Wiki</a>', 'Orga Name', 'organame@mail.com', '52.43893109993363 13.648079039184609', 10, 'https://wiki.fachschaft.informatik.hu-berlin.de/wiki/Erstsemesterfahrt', '2015-09-24', 'Some\r\nPayment\r\nInfo\r\nHere', 1443639637, 'https://fachschaft.informatik.hu-berlin.de/index.php?title=FachschaftsfahrtDisclaimer&oldid=428');
-- --------------------------------------------------------
--
-- Table structure for table `notes`
--
CREATE TABLE `notes` (
`note_id` int(11) NOT NULL,
`fahrt_id` int(11) NOT NULL,
`note` text NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Dumping data for table `notes`
--
INSERT INTO `notes` (`note_id`, `fahrt_id`, `note`) VALUES
(2, 2, '<h1><b>Testnotiz 123<br></b></h1>hier kann man <i>notizen </i>hinterlassen test<br><br><h2><b>Dumme Bemerkung</b></h2>Notiz = no&nbsp;<span class="wysiwyg-color-red">tits!<br></span><b><br><br>aoisdkd<br>asdlji<br><br></b><b><br></b>');
--
-- Indexes for dumped tables
--
--
-- Indexes for table `bachelor`
--
ALTER TABLE `bachelor`
ADD PRIMARY KEY (`bachelor_id`,`fahrt_id`);
--
-- Indexes for table `fahrten`
--
ALTER TABLE `fahrten`
ADD PRIMARY KEY (`fahrt_id`);
--
-- Indexes for table `notes`
--
ALTER TABLE `notes`
ADD PRIMARY KEY (`note_id`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `fahrten`
--
ALTER TABLE `fahrten`
MODIFY `fahrt_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT for table `notes`
--
ALTER TABLE `notes`
MODIFY `note_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
\ No newline at end of file