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 2670 additions and 1229 deletions
<?php
/*!
* Medoo database framework
* http://medoo.in
* Version 1.1.3
* https://medoo.in
* Version 1.7.8
*
* Copyright 2016, Angel Lai
* Copyright 2019, Angel Lai
* Released under the MIT license
*/
class medoo
{
// General
protected $database_type;
protected $charset;
protected $database_name;
namespace Medoo;
// For MySQL, MariaDB, MSSQL, Sybase, PostgreSQL, Oracle
protected $server;
use PDO;
use Exception;
use PDOException;
use InvalidArgumentException;
protected $username;
class Raw {
public $map;
public $value;
}
protected $password;
class Medoo
{
public $pdo;
// For SQLite
protected $database_file;
protected $type;
// For MySQL or MariaDB with unix_socket
protected $socket;
protected $prefix;
// Optional
protected $port;
protected $statement;
protected $prefix;
protected $dsn;
protected $option = array();
protected $logs = [];
// Variable
protected $logs = array();
protected $logging = false;
protected $debug_mode = false;
public function __construct($options = null)
protected $guid = 0;
protected $errorInfo = null;
public function __construct(array $options)
{
try {
$commands = array();
$dsn = '';
if (isset($options[ 'database_type' ]))
{
$this->type = strtolower($options[ 'database_type' ]);
if (is_array($options))
if ($this->type === 'mariadb')
{
foreach ($options as $option => $value)
{
$this->$option = $value;
}
$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)
{
return false;
throw new InvalidArgumentException('Invalid PDO object supplied');
}
if (
isset($this->port) &&
is_int($this->port * 1)
)
$this->pdo = $options[ 'pdo' ];
foreach ($commands as $value)
{
$port = $this->port;
$this->pdo->exec($value);
}
$type = strtolower($this->database_type);
$is_port = isset($port);
return;
}
if (isset($options[ 'prefix' ]))
if (isset($options[ 'dsn' ]))
{
if (is_array($options[ 'dsn' ]) && isset($options[ 'dsn' ][ 'driver' ]))
{
$this->prefix = $options[ 'prefix' ];
$attr = $options[ 'dsn' ];
}
switch ($type)
else
{
throw new InvalidArgumentException('Invalid DSN option supplied');
}
}
else
{
if (
isset($options[ 'port' ]) &&
is_int($options[ 'port' ] * 1)
)
{
case 'mariadb':
$type = 'mysql';
$port = $options[ 'port' ];
}
$is_port = isset($port);
switch ($this->type)
{
case 'mysql':
if ($this->socket)
$attr = [
'driver' => 'mysql',
'dbname' => $options[ 'database_name' ]
];
if (isset($options[ 'socket' ]))
{
$dsn = $type . ':unix_socket=' . $this->socket . ';dbname=' . $this->database_name;
$attr[ 'unix_socket' ] = $options[ 'socket' ];
}
else
{
$dsn = $type . ':host=' . $this->server . ($is_port ? ';port=' . $port : '') . ';dbname=' . $this->database_name;
$attr[ 'host' ] = $options[ 'server' ];
if ($is_port)
{
$attr[ 'port' ] = $port;
}
}
// Make MySQL using standard quoted identifier
$commands[] = 'SET SQL_MODE=ANSI_QUOTES';
break;
case 'pgsql':
$dsn = $type . ':host=' . $this->server . ($is_port ? ';port=' . $port : '') . ';dbname=' . $this->database_name;
$attr = [
'driver' => 'pgsql',
'host' => $options[ 'server' ],
'dbname' => $options[ 'database_name' ]
];
if ($is_port)
{
$attr[ 'port' ] = $port;
}
break;
case 'sybase':
$dsn = 'dblib:host=' . $this->server . ($is_port ? ':' . $port : '') . ';dbname=' . $this->database_name;
$attr = [
'driver' => 'dblib',
'host' => $options[ 'server' ],
'dbname' => $options[ 'database_name' ]
];
if ($is_port)
{
$attr[ 'port' ] = $port;
}
break;
case 'oracle':
$dbname = $this->server ?
'//' . $this->server . ($is_port ? ':' . $port : ':1521') . '/' . $this->database_name :
$this->database_name;
$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' ];
}
$dsn = 'oci:dbname=' . $dbname . ($this->charset ? ';charset=' . $this->charset : '');
break;
case 'mssql':
$dsn = strstr(PHP_OS, 'WIN') ?
'sqlsrv:server=' . $this->server . ($is_port ? ',' . $port : '') . ';database=' . $this->database_name :
'dblib:host=' . $this->server . ($is_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' ];
}
$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 ];
}
}
}
// Keep MSSQL QUOTED_IDENTIFIER is ON for standard quoting
$commands[] = 'SET QUOTED_IDENTIFIER ON';
break;
case 'sqlite':
$dsn = $type . ':' . $this->database_file;
$this->username = null;
$this->password = null;
$attr = [
'driver' => 'sqlite',
$options[ 'database_file' ]
];
break;
}
}
if (
in_array($type, array('mariadb', 'mysql', 'pgsql', 'sybase', 'mssql')) &&
$this->charset
)
{
$commands[] = "SET NAMES '" . $this->charset . "'";
}
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)
......@@ -147,40 +320,154 @@ class medoo
}
}
catch (PDOException $e) {
throw new Exception($e->getMessage());
throw new PDOException($e->getMessage());
}
}
public function query($query)
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 $query;
echo $this->generate($query, $map);
$this->debug_mode = false;
return false;
}
$this->logs[] = $query;
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 $this->pdo->query($query);
return $statement;
}
public function exec($query)
protected function generate($query, $map)
{
if ($this->debug_mode)
$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)
{
echo $query;
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 ];
}
$this->debug_mode = false;
$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;
}
protected function isRaw($object)
{
return $object instanceof Raw;
}
protected function buildRaw($raw, &$map)
{
if (!$this->isRaw($raw))
{
return false;
}
$this->logs[] = $query;
$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 $this->pdo->exec($query);
return $query;
}
public function quote($string)
......@@ -188,211 +475,302 @@ class medoo
return $this->pdo->quote($string);
}
protected function table_quote($table)
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 column_quote($string)
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)
{
preg_match('/(\(JSON\)\s*|^#)?([a-zA-Z0-9_]*)\.([a-zA-Z0-9_]*)/', $string, $column_match);
if (!preg_match('/^[a-zA-Z0-9_]+(\.?[a-zA-Z0-9_]+)?$/i', $string))
{
throw new InvalidArgumentException("Incorrect column name \"$string\"");
}
if (isset($column_match[ 2 ], $column_match[ 3 ]))
if (strpos($string, '.') !== false)
{
return '"' . $this->prefix . $column_match[ 2 ] . '"."' . $column_match[ 3 ] . '"';
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)
{
if (is_array($value))
if (!is_int($key) && is_array($value) && $root && count(array_keys($columns)) === 1)
{
$stack[] = $this->column_push($value);
$stack[] = $this->columnQuote($key);
$stack[] = $this->columnPush($value, $map, false, $is_join);
}
else
elseif (is_array($value))
{
$stack[] = $this->columnPush($value, $map, false, $is_join);
}
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))
{
preg_match('/([a-zA-Z0-9_\-\.]*)\s*\(([a-zA-Z0-9_\-]*)\)/i', $value, $match);
if ($is_join && strpos($value, '*') !== false)
{
throw new InvalidArgumentException('Cannot use table.* to select all columns while joining table');
}
if (isset($match[ 1 ], $match[ 2 ]))
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->column_quote( $match[ 1 ] ) . ' AS ' . $this->column_quote( $match[ 2 ] );
$stack[] = $this->columnQuote($match[ 'column' ]) . ' AS ' . $this->columnQuote($match[ 'alias' ]);
$columns[ $key ] = $match[ 'alias' ];
$columns[ $key ] = $match[ 2 ];
if (!empty($match[ 'type' ]))
{
$columns[ $key ] .= ' [' . $match[ 'type' ] . ']';
}
}
else
{
$stack[] = $this->column_quote( $value );
$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);
}
protected function fn_quote($column, $string)
{
return (strpos($column, '#') === 0 && preg_match('/^[A-Z0-9\_]*\([^)]*\)$/', $string)) ?
$string :
$this->quote($string);
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 (
preg_match("/^(AND|OR)(\s+#.*)?$/i", $key, $relation_match) &&
$type == 'array'
$type === 'array' &&
preg_match("/^(AND|OR)(\s+#.*)?$/", $key, $relation_match)
)
{
$wheres[] = 0 !== count(array_diff_key($value, array_keys(array_keys($value)))) ?
'(' . $this->data_implode($value, ' ' . $relation_match[ 1 ]) . ')' :
'(' . $this->inner_conjunct($value, ' ' . $relation_match[ 1 ], $conjunctor) . ')';
$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 (
is_int($key) &&
preg_match('/([a-zA-Z0-9_\.]+)\[(?<operator>\>\=?|\<\=?|\!?\=)\]([a-zA-Z0-9_\.]+)/i', $value, $match)
)
{
$stack[] = $this->columnQuote($match[ 1 ]) . ' ' . $match[ 'operator' ] . ' ' . $this->columnQuote($match[ 3 ]);
}
else
{
preg_match('/(#?)([\w\.\-]+)(\[(\>|\>\=|\<|\<\=|\!|\<\>|\>\<|\!?~)\])?/i', $key, $match);
$column = $this->column_quote($match[ 2 ]);
preg_match('/([a-zA-Z0-9_\.]+)(\[(?<operator>\>\=?|\<\=?|\!|\<\>|\>\<|\!?~|REGEXP)\])?/i', $key, $match);
$column = $this->columnQuote($match[ 1 ]);
if (isset($match[ 4 ]))
if (isset($match[ 'operator' ]))
{
$operator = $match[ 4 ];
$operator = $match[ 'operator' ];
if (in_array($operator, ['>', '>=', '<', '<=']))
{
$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];
}
if ($operator == '!')
$stack[] = $condition;
}
elseif ($operator === '!')
{
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) . ')';
break;
$placeholders = [];
case 'integer':
case 'double':
$wheres[] = $column . ' != ' . $value;
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 'boolean':
$wheres[] = $column . ' != ' . ($value ? '1' : '0');
case 'object':
if ($raw = $this->buildRaw($value, $map))
{
$stack[] = $column . ' != ' . $raw;
}
break;
case 'integer':
case 'double':
case 'boolean':
case 'string':
$wheres[] = $column . ' != ' . $this->fn_quote($key, $value);
$stack[] = $column . ' != ' . $map_key;
$map[ $map_key ] = $this->typeMap($value, $type);
break;
}
}
if ($operator == '<>' || $operator == '><')
elseif ($operator === '~' || $operator === '!~')
{
if ($type == 'array')
if ($type !== 'array')
{
if ($operator == '><')
{
$column .= ' NOT';
}
if (is_numeric($value[ 0 ]) && is_numeric($value[ 1 ]))
{
$wheres[] = '(' . $column . ' BETWEEN ' . $value[ 0 ] . ' AND ' . $value[ 1 ] . ')';
}
else
{
$wheres[] = '(' . $column . ' BETWEEN ' . $this->quote($value[ 0 ]) . ' AND ' . $this->quote($value[ 1 ]) . ')';
}
$value = [ $value ];
}
}
if ($operator == '~' || $operator == '!~')
{
if ($type != 'array')
$connector = ' OR ';
$data = array_values($value);
if (is_array($data[ 0 ]))
{
$value = array($value);
if (isset($value[ 'AND' ]) || isset($value[ 'OR' ]))
{
$connector = ' ' . array_keys($value)[ 0 ] . ' ';
$value = $data[ 0 ];
}
}
$like_clauses = array();
$like_clauses = [];
foreach ($value as $item)
foreach ($value as $index => $item)
{
$item = strval($item);
if (preg_match('/^(?!(%|\[|_])).+(?<!(%|\]|_))$/', $item))
if (!preg_match('/(\[.+\]|[\*\?\!\%#^-_]|%.+|.+%)/', $item))
{
$item = '%' . $item . '%';
}
$like_clauses[] = $column . ($operator === '!~' ? ' NOT' : '') . ' LIKE ' . $this->fn_quote($key, $item);
$like_clauses[] = $column . ($operator === '!~' ? ' NOT' : '') . ' LIKE ' . $map_key . 'L' . $index;
$map[ $map_key . 'L' . $index ] = [$item, PDO::PARAM_STR];
}
$wheres[] = implode(' OR ', $like_clauses);
$stack[] = '(' . implode($connector, $like_clauses) . ')';
}
if (in_array($operator, array('>', '>=', '<', '<=')))
elseif ($operator === '<>' || $operator === '><')
{
$condition = $column . ' ' . $operator . ' ';
if (is_numeric($value))
{
$condition .= $value;
}
elseif (strpos($key, '#') === 0)
{
$condition .= $this->fn_quote($key, $value);
}
else
if ($type === 'array')
{
$condition .= $this->quote($value);
}
if ($operator === '><')
{
$column .= ' NOT';
}
$wheres[] = $condition;
$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
......@@ -400,86 +778,124 @@ class medoo
switch ($type)
{
case 'NULL':
$wheres[] = $column . ' IS NULL';
$stack[] = $column . ' IS NULL';
break;
case 'array':
$wheres[] = $column . ' IN (' . $this->array_quote($value) . ')';
break;
$placeholders = [];
case 'integer':
case 'double':
$wheres[] = $column . ' = ' . $value;
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 'boolean':
$wheres[] = $column . ' = ' . ($value ? '1' : '0');
case 'object':
if ($raw = $this->buildRaw($value, $map))
{
$stack[] = $column . ' = ' . $raw;
}
break;
case 'integer':
case 'double':
case 'boolean':
case 'string':
$wheres[] = $column . ' = ' . $this->fn_quote($key, $value);
$stack[] = $column . ' = ' . $map_key;
$map[ $map_key ] = $this->typeMap($value, $type);
break;
}
}
}
}
return implode($conjunctor . ' ', $wheres);
return implode($conjunctor . ' ', $stack);
}
protected function where_clause($where)
protected function whereClause($where, &$map)
{
$where_clause = '';
if (is_array($where))
{
$where_keys = array_keys($where);
$where_AND = preg_grep("/^AND\s*#?$/i", $where_keys);
$where_OR = preg_grep("/^OR\s*#?$/i", $where_keys);
$single_condition = array_diff_key($where, array_flip(
array('AND', 'OR', 'GROUP', 'ORDER', 'HAVING', 'LIMIT', 'LIKE', 'MATCH')
$conditions = array_diff_key($where, array_flip(
['GROUP', 'ORDER', 'HAVING', 'LIMIT', 'LIKE', 'MATCH']
));
if ($single_condition != array())
if (!empty($conditions))
{
$condition = $this->data_implode($single_condition, '');
if ($condition != '')
{
$where_clause = ' WHERE ' . $condition;
}
}
if (!empty($where_AND))
{
$value = array_values($where_AND);
$where_clause = ' WHERE ' . $this->data_implode($where[ $value[ 0 ] ], ' AND');
$where_clause = ' WHERE ' . $this->dataImplode($conditions, $map, ' AND');
}
if (!empty($where_OR))
{
$value = array_values($where_OR);
$where_clause = ' WHERE ' . $this->data_implode($where[ $value[ 0 ] ], ' OR');
}
if (isset($where[ 'MATCH' ]))
if (isset($where[ 'MATCH' ]) && $this->type === 'mysql')
{
$MATCH = $where[ 'MATCH' ];
if (is_array($MATCH) && isset($MATCH[ 'columns' ], $MATCH[ 'keyword' ]))
{
$where_clause .= ($where_clause != '' ? ' AND ' : ' WHERE ') . ' MATCH ("' . str_replace('.', '"."', implode($MATCH[ 'columns' ], '", "')) . '") AGAINST (' . $this->quote($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' ]))
{
$where_clause .= ' GROUP BY ' . $this->column_quote($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' ]))
{
$where_clause .= ' HAVING ' . $this->data_implode($where[ 'HAVING' ], ' AND');
if ($raw = $this->buildRaw($where[ 'HAVING' ], $map))
{
$where_clause .= ' HAVING ' . $raw;
}
else
{
$where_clause .= ' HAVING ' . $this->dataImplode($where[ 'HAVING' ], $map, ' AND');
}
}
}
......@@ -489,33 +905,59 @@ class medoo
if (is_array($ORDER))
{
$stack = array();
$stack = [];
foreach ($ORDER as $column => $value)
{
if (is_array($value))
{
$stack[] = 'FIELD(' . $this->column_quote($column) . ', ' . $this->array_quote($value) . ')';
$stack[] = 'FIELD(' . $this->columnQuote($column) . ', ' . $this->arrayQuote($value) . ')';
}
else if ($value === 'ASC' || $value === 'DESC')
elseif ($value === 'ASC' || $value === 'DESC')
{
$stack[] = $this->column_quote($column) . ' ' . $value;
$stack[] = $this->columnQuote($column) . ' ' . $value;
}
else if (is_int($column))
elseif (is_int($column))
{
$stack[] = $this->column_quote($value);
$stack[] = $this->columnQuote($value);
}
}
$where_clause .= ' ORDER BY ' . implode($stack, ',');
$where_clause .= ' ORDER BY ' . implode(',', $stack);
}
elseif ($raw = $this->buildRaw($ORDER, $map))
{
$where_clause .= ' ORDER BY ' . $raw;
}
else
{
$where_clause .= ' ORDER BY ' . $this->column_quote($ORDER);
$where_clause .= ' ORDER BY ' . $this->columnQuote($ORDER);
}
if (
isset($where[ 'LIMIT' ]) &&
in_array($this->type, ['oracle', 'mssql'])
)
{
$LIMIT = $where[ 'LIMIT' ];
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' ]))
if (isset($where[ 'LIMIT' ]) && !in_array($this->type, ['oracle', 'mssql']))
{
$LIMIT = $where[ 'LIMIT' ];
......@@ -523,239 +965,403 @@ class medoo
{
$where_clause .= ' LIMIT ' . $LIMIT;
}
if (
is_array($LIMIT) &&
is_numeric($LIMIT[ 0 ]) &&
is_numeric($LIMIT[ 1 ])
elseif (
is_array($LIMIT) &&
is_numeric($LIMIT[ 0 ]) &&
is_numeric($LIMIT[ 1 ])
)
{
if ($this->database_type === 'pgsql')
{
$where_clause .= ' OFFSET ' . $LIMIT[ 0 ] . ' LIMIT ' . $LIMIT[ 1 ];
}
else
{
$where_clause .= ' LIMIT ' . $LIMIT[ 0 ] . ',' . $LIMIT[ 1 ];
}
$where_clause .= ' LIMIT ' . $LIMIT[ 1 ] . ' OFFSET ' . $LIMIT[ 0 ];
}
}
}
else
elseif ($raw = $this->buildRaw($where, $map))
{
if ($where != null)
{
$where_clause .= ' ' . $where;
}
$where_clause .= ' ' . $raw;
}
return $where_clause;
}
protected function select_context($table, $join, &$columns = null, $where = null, $column_fn = null)
protected function selectContext($table, &$map, $join, &$columns = null, $where = null, $column_fn = null)
{
preg_match('/([a-zA-Z0-9_\-]*)\s*\(([a-zA-Z0-9_\-]*)\)/i', $table, $table_match);
preg_match('/(?<table>[a-zA-Z0-9_]+)\s*\((?<alias>[a-zA-Z0-9_]+)\)/i', $table, $table_match);
if (isset($table_match[ 1 ], $table_match[ 2 ]))
if (isset($table_match[ 'table' ], $table_match[ 'alias' ]))
{
$table = $this->table_quote($table_match[ 1 ]);
$table = $this->tableQuote($table_match[ 'table' ]);
$table_query = $this->table_quote($table_match[ 1 ]) . ' AS ' . $this->table_quote($table_match[ 2 ]);
$table_query = $table . ' AS ' . $this->tableQuote($table_match[ 'alias' ]);
}
else
{
$table = $this->table_quote($table);
$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
isset($join_key[ 0 ]) &&
strpos($join_key[ 0 ], '[') === 0
)
{
$table_join = array();
$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;
}
}
$join_array = array(
'>' => 'LEFT',
'<' => 'RIGHT',
'<>' => 'FULL',
'><' => 'INNER'
);
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)
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' ] !== '')
{
preg_match('/(\[(\<|\>|\>\<|\<\>)\])?([a-zA-Z0-9_\-]*)\s?(\(([a-zA-Z0-9_\-]*)\))?/', $sub_table, $match);
if (is_string($relation))
{
$relation = 'USING ("' . $relation . '")';
}
if ($match[ 2 ] != '' && $match[ 3 ] != '')
if (is_array($relation))
{
if (is_string($relation))
// For ['column1', 'column2']
if (isset($relation[ 0 ]))
{
$relation = 'USING ("' . $relation . '")';
$relation = 'USING ("' . implode('", "', $relation) . '")';
}
if (is_array($relation))
else
{
// For ['column1', 'column2']
if (isset($relation[ 0 ]))
$joins = [];
foreach ($relation as $key => $value)
{
$relation = 'USING ("' . implode($relation, '", "') . '")';
$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 . '"';
}
else
{
$joins = array();
foreach ($relation as $key => $value)
{
$joins[] = (
strpos($key, '.') > 0 ?
// For ['tableB.column' => 'column']
$this->column_quote($key) :
// For ['column1' => 'column2']
$table . '."' . $key . '"'
) .
' = ' .
$this->table_quote(isset($match[ 5 ]) ? $match[ 5 ] : $match[ 3 ]) . '."' . $value . '"';
}
$relation = 'ON ' . implode($joins, ' AND ');
}
$relation = 'ON ' . implode(' AND ', $joins);
}
}
$table_name = $this->table_quote($match[ 3 ]) . ' ';
$table_name = $this->tableQuote($match[ 'table' ]) . ' ';
if (isset($match[ 5 ]))
{
$table_name .= 'AS ' . $this->table_quote($match[ 5 ]) . ' ';
}
if (isset($match[ 'alias' ]))
{
$table_name .= 'AS ' . $this->tableQuote($match[ 'alias' ]) . ' ';
}
$table_join[] = $join_array[ $match[ 2 ] ] . ' JOIN ' . $table_name . $relation;
$table_join[] = $join_array[ $match[ 'join' ] ] . ' JOIN ' . $table_name . $relation;
}
}
return implode(' ', $table_join);
}
protected function columnMap($columns, &$stack, $root)
{
if ($columns === '*')
{
return $stack;
}
foreach ($columns as $key => $value)
{
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);
$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))
{
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' ];
$table_query .= ' ' . implode($table_join, ' ');
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);
}
}
else
return $stack;
}
protected function dataMap($data, $columns, $column_map, &$stack, $root, &$result)
{
if ($root)
{
if (is_null($columns))
$columns_key = array_keys($columns);
if (count($columns_key) === 1 && is_array($columns[$columns_key[0]]))
{
if (is_null($where))
$index_key = array_keys($columns)[0];
$data_key = preg_replace("/^[a-zA-Z0-9_]+\./i", "", $index_key);
$current_stack = [];
foreach ($data as $item)
{
if (
is_array($join) &&
isset($column_fn)
)
$this->dataMap($data, $columns[ $index_key ], $column_map, $current_stack, false, $result);
$index = $data[ $data_key ];
$result[ $index ] = $current_stack;
}
}
else
{
$current_stack = [];
$this->dataMap($data, $columns, $column_map, $current_stack, false, $result);
$result[] = $current_stack;
}
return;
}
foreach ($columns as $key => $value)
{
$isRaw = $this->isRaw($value);
if (is_int($key) || $isRaw)
{
$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']))
{
$where = $join;
$columns = null;
continue;
}
else
if (is_null($item))
{
$stack[ $column_key ] = null;
continue;
}
switch ($map[ 1 ])
{
$where = null;
$columns = $join;
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
{
$where = $join;
$columns = null;
$stack[ $column_key ] = $item;
}
}
else
{
$where = $columns;
$columns = $join;
$current_stack = [];
$this->dataMap($data, $value, $column_map, $current_stack, false, $result);
$stack[ $key ] = $current_stack;
}
}
}
if (isset($column_fn))
public function create($table, $columns, $options = null)
{
$stack = [];
$tableName = $this->prefix . $table;
foreach ($columns as $name => $definition)
{
if ($column_fn == 1)
if (is_int($name))
{
$column = '1';
if (is_null($where))
{
$where = $columns;
}
$stack[] = preg_replace('/\<([a-zA-Z0-9_]+)\>/i', '"$1"', $definition);
}
else
elseif (is_array($definition))
{
if (empty($columns))
{
$columns = '*';
$where = $join;
}
$column = $column_fn . '(' . $this->column_push($columns) . ')';
$stack[] = $name . ' ' . implode(' ', $definition);
}
elseif (is_string($definition))
{
$stack[] = $name . ' ' . $this->query($definition);
}
}
else
{
$column = $this->column_push($columns);
}
return 'SELECT ' . $column . ' FROM ' . $table_query . $this->where_clause($where);
}
$table_option = '';
protected function data_map($index, $key, $value, $data, &$stack)
{
if (is_array($value))
if (is_array($options))
{
$sub_stack = array();
$option_stack = [];
foreach ($value as $sub_key => $sub_value)
foreach ($options as $key => $value)
{
if (is_array($sub_value))
{
$current_stack = $stack[ $index ][ $key ];
$this->data_map(false, $sub_key, $sub_value, $data, $current_stack);
$stack[ $index ][ $key ][ $sub_key ] = $current_stack[ 0 ][ $sub_key ];
}
else
if (is_string($value) || is_int($value))
{
$this->data_map(false, preg_replace('/^[\w]*\./i', "", $sub_value), $sub_key, $data, $sub_stack);
$stack[ $index ][ $key ] = $sub_stack;
$option_stack[] = "$key = $value";
}
}
$table_option = ' ' . implode(', ', $option_stack);
}
else
elseif (is_string($options))
{
if ($index !== false)
{
$stack[ $index ][ $value ] = $data[ $value ];
}
else
{
if (preg_match('/[a-zA-Z0-9_\-\.]*\s*\(([a-zA-Z0-9_\-]*)\)/i', $key, $key_match))
{
$key = $key_match[ 1 ];
}
$stack[ $key ] = $data[ $key ];
}
$table_option = ' ' . $options;
}
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)
{
$column = $where == null ? $join : $columns;
$map = [];
$result = [];
$column_map = [];
$is_single_column = (is_string($column) && $column !== '*');
$index = 0;
$query = $this->query($this->select_context($table, $join, $columns, $where));
$column = $where === null ? $join : $columns;
$stack = array();
$is_single = (is_string($column) && $column !== '*');
$index = 0;
$query = $this->exec($this->selectContext($table, $map, $join, $columns, $where), $map);
if (!$query)
$this->columnMap($columns, $column_map, true);
if (!$this->statement)
{
return false;
}
......@@ -765,296 +1371,371 @@ class medoo
return $query->fetchAll(PDO::FETCH_ASSOC);
}
if ($is_single_column)
while ($data = $query->fetch(PDO::FETCH_ASSOC))
{
return $query->fetchAll(PDO::FETCH_COLUMN);
$current_stack = [];
$this->dataMap($data, $columns, $column_map, $current_stack, true, $result);
}
while ($row = $query->fetch(PDO::FETCH_ASSOC))
if ($is_single)
{
foreach ($columns as $key => $value)
$single_result = [];
$result_key = $column_map[ $column ][ 0 ];
foreach ($result as $item)
{
if (is_array($value))
{
$this->data_map($index, $key, $value, $row, $stack);
}
else
{
$this->data_map($index, $key, preg_replace('/^[\w]*\./i', "", $value), $row, $stack);
}
$single_result[] = $item[ $result_key ];
}
$index++;
return $single_result;
}
return $stack;
return $result;
}
public function insert($table, $datas)
{
$lastId = array();
$stack = [];
$columns = [];
$fields = [];
$map = [];
// Check indexed or associative array
if (!isset($datas[ 0 ]))
{
$datas = array($datas);
$datas = [$datas];
}
foreach ($datas as $data)
{
$values = array();
$columns = array();
foreach ($data as $key => $value)
{
$columns[] = $this->column_quote(preg_replace("/^(\(JSON\)\s*|#)/i", "", $key));
$columns[] = $key;
}
}
$columns = array_unique($columns);
foreach ($datas as $data)
{
$values = [];
switch (gettype($value))
foreach ($columns as $key)
{
if ($raw = $this->buildRaw($data[ $key ], $map))
{
case 'NULL':
$values[] = 'NULL';
break;
$values[] = $raw;
continue;
}
case 'array':
preg_match("/\(JSON\)\s*([\w]+)/i", $key, $column_match);
$map_key = $this->mapKey();
$values[] = isset($column_match[ 0 ]) ?
$this->quote(json_encode($value)) :
$this->quote(serialize($value));
break;
$values[] = $map_key;
case 'boolean':
$values[] = ($value ? '1' : '0');
break;
if (!isset($data[ $key ]))
{
$map[ $map_key ] = [null, PDO::PARAM_NULL];
}
else
{
$value = $data[ $key ];
case 'integer':
case 'double':
case 'string':
$values[] = $this->fn_quote($key, $value);
break;
$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 ' . $this->table_quote($table) . ' (' . implode(', ', $columns) . ') 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)
{
preg_match('/([\w]+)(\[(\+|\-|\*|\/)\])?/i', $key, $match);
$column = $this->columnQuote(preg_replace("/(\s*\[(JSON|\+|\-|\*|\/)\]$)/i", '', $key));
if ($raw = $this->buildRaw($value, $map))
{
$fields[] = $column . ' = ' . $raw;
continue;
}
$map_key = $this->mapKey();
if (isset($match[ 3 ]))
preg_match('/(?<column>[a-zA-Z0-9_]+)(\[(?<operator>\+|\-|\*|\/)\])?/i', $key, $match);
if (isset($match[ 'operator' ]))
{
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(preg_replace("/^(\(JSON\)\s*|#)/i", "", $key));
$fields[] = $column . ' = ' . $map_key;
switch (gettype($value))
{
case 'NULL':
$fields[] = $column . ' = NULL';
break;
$type = gettype($value);
switch ($type)
{
case 'array':
preg_match("/\(JSON\)\s*([\w]+)/i", $key, $column_match);
$fields[] = $column . ' = ' . $this->quote(
isset($column_match[ 0 ]) ? json_encode($value) : serialize($value)
);
$map[ $map_key ] = [
strpos($key, '[JSON]') === strlen($key) - 6 ?
json_encode($value) :
serialize($value),
PDO::PARAM_STR
];
break;
case 'boolean':
$fields[] = $column . ' = ' . ($value ? '1' : '0');
break;
case 'object':
$value = serialize($value);
case 'NULL':
case 'resource':
case 'boolean':
case 'integer':
case 'double':
case 'string':
$fields[] = $column . ' = ' . $this->fn_quote($key, $value);
$map[ $map_key ] = $this->typeMap($value, $type);
break;
}
}
}
return $this->exec('UPDATE ' . $this->table_quote($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 ' . $this->table_quote($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;
}
foreach ($columns as $column => $replacements)
{
foreach ($replacements as $replace_search => $replace_replacement)
{
$replace_query[] = $column . ' = REPLACE(' . $this->column_quote($column) . ', ' . $this->quote($replace_search) . ', ' . $this->quote($replace_replacement) . ')';
}
}
$map = [];
$stack = [];
$replace_query = implode(', ', $replace_query);
$where = $search;
}
else
foreach ($columns as $column => $replacements)
{
if (is_array($search))
if (is_array($replacements))
{
$replace_query = array();
foreach ($search as $replace_search => $replace_replacement)
foreach ($replacements as $old => $new)
{
$replace_query[] = $columns . ' = REPLACE(' . $this->column_quote($columns) . ', ' . $this->quote($replace_search) . ', ' . $this->quote($replace_replacement) . ')';
}
$map_key = $this->mapKey();
$replace_query = implode(', ', $replace_query);
$where = $replace;
}
else
{
$replace_query = $columns . ' = REPLACE(' . $this->column_quote($columns) . ', ' . $this->quote($search) . ', ' . $this->quote($replace) . ')';
$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];
}
}
}
return $this->exec('UPDATE ' . $this->table_quote($table) . ' SET ' . $replace_query . $this->where_clause($where));
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)
{
$column = $where == null ? $join : $columns;
$map = [];
$result = [];
$column_map = [];
$current_stack = [];
if ($where === null)
{
$column = $join;
unset($columns[ 'LIMIT' ]);
}
else
{
$column = $columns;
unset($where[ 'LIMIT' ]);
}
$is_single_column = (is_string($column) && $column !== '*');
$is_single = (is_string($column) && $column !== '*');
$query = $this->query($this->select_context($table, $join, $columns, $where) . ' LIMIT 1');
$query = $this->exec($this->selectContext($table, $map, $join, $columns, $where) . ' LIMIT 1', $map);
if ($query)
if (!$this->statement)
{
$data = $query->fetchAll(PDO::FETCH_ASSOC);
return false;
}
if (isset($data[ 0 ]))
{
if ($is_single_column)
{
return $data[ 0 ][ preg_replace('/^[\w]*\./i', "", $column) ];
}
$data = $query->fetchAll(PDO::FETCH_ASSOC);
if ($column === '*')
{
return $data[ 0 ];
}
if (isset($data[ 0 ]))
{
if ($column === '*')
{
return $data[ 0 ];
}
$stack = array();
$this->columnMap($columns, $column_map, true);
foreach ($columns as $key => $value)
{
if (is_array($value))
{
$this->data_map(0, $key, $value, $data[ 0 ], $stack);
}
else
{
$this->data_map(0, $key, preg_replace('/^[\w]*\./i', "", $value), $data[ 0 ], $stack);
}
}
$this->dataMap($data[ 0 ], $columns, $column_map, $current_stack, true, $result);
return $stack[ 0 ];
}
else
if ($is_single)
{
return false;
return $result[ 0 ][ $column_map[ $column ][ 0 ] ];
}
}
else
{
return false;
return $result[ 0 ];
}
}
public function has($table, $join, $where = null)
{
$map = [];
$column = null;
$query = $this->query('SELECT EXISTS(' . $this->select_context($table, $join, $column, $where, 1) . ')');
if ($query)
if ($this->type === 'mssql')
{
return $query->fetchColumn() === '1';
$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;
}
}
public function count($table, $join = null, $column = null, $where = null)
{
$query = $this->query($this->select_context($table, $join, $column, $where, 'COUNT'));
$result = $query->fetchColumn();
return $query ? 0 + $query->fetchColumn() : false;
return $result === '1' || $result === 1 || $result === true;
}
public function max($table, $join, $column = null, $where = null)
public function rand($table, $join = null, $columns = null, $where = null)
{
$query = $this->query($this->select_context($table, $join, $column, $where, 'MAX'));
$type = $this->type;
$order = 'RANDOM()';
if ($type === 'mysql')
{
$order = 'RAND()';
}
elseif ($type === 'mssql')
{
$order = 'NEWID()';
}
$order_raw = $this->raw($order);
if ($query)
if ($where === null)
{
$max = $query->fetchColumn();
if ($columns === null)
{
$columns = [
'ORDER' => $order_raw
];
}
else
{
$column = $join;
unset($columns[ 'ORDER' ]);
return is_numeric($max) ? $max + 0 : $max;
$columns[ 'ORDER' ] = $order_raw;
}
}
else
{
return false;
unset($where[ 'ORDER' ]);
$where[ 'ORDER' ] = $order_raw;
}
return $this->select($table, $join, $columns, $where);
}
public function min($table, $join, $column = null, $where = null)
private function aggregate($type, $table, $join = null, $column = null, $where = null)
{
$query = $this->query($this->select_context($table, $join, $column, $where, 'MIN'));
$map = [];
if ($query)
{
$min = $query->fetchColumn();
$query = $this->exec($this->selectContext($table, $map, $join, $column, $where, strtoupper($type)), $map);
return is_numeric($min) ? $min + 0 : $min;
}
else
if (!$this->statement)
{
return false;
}
$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);
}
public function avg($table, $join, $column = null, $where = null)
{
$query = $this->query($this->select_context($table, $join, $column, $where, 'AVG'));
return $this->aggregate('avg', $table, $join, $column, $where);
}
public function max($table, $join, $column = null, $where = null)
{
return $this->aggregate('max', $table, $join, $column, $where);
}
return $query ? 0 + $query->fetchColumn() : false;
public function min($table, $join, $column = null, $where = null)
{
return $this->aggregate('min', $table, $join, $column, $where);
}
public function sum($table, $join, $column = null, $where = null)
{
$query = $this->query($this->select_context($table, $join, $column, $where, 'SUM'));
return $query ? 0 + $query->fetchColumn() : false;
return $this->aggregate('sum', $table, $join, $column, $where);
}
public function action($actions)
......@@ -1063,21 +1744,56 @@ class medoo
{
$this->pdo->beginTransaction();
$result = $actions($this);
try {
$result = $actions($this);
if ($result === false)
{
$this->pdo->rollBack();
if ($result === false)
{
$this->pdo->rollBack();
}
else
{
$this->pdo->commit();
}
}
else
{
$this->pdo->commit();
catch (Exception $e) {
$this->pdo->rollBack();
throw $e;
}
return $result;
}
else
return false;
}
public function id()
{
if ($this->statement == null)
{
return false;
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 debug()
......@@ -1089,35 +1805,43 @@ class medoo
public function error()
{
return $this->pdo->errorInfo();
return $this->errorInfo;
}
public function last_query()
public function last()
{
return end($this->logs);
$log = end($this->logs);
return $this->generate($log[ 0 ], $log[ 1 ]);
}
public function log()
{
return $this->logs;
return array_map(function ($log)
{
return $this->generate($log[ 0 ], $log[ 1 ]);
},
$this->logs
);
}
public function info()
{
$output = array(
'server' => 'SERVER_INFO',
'driver' => 'DRIVER_NAME',
'client' => 'CLIENT_VERSION',
'version' => 'SERVER_VERSION',
'connection' => 'CONNECTION_STATUS'
);
$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[ $key ] = @$this->pdo->getAttribute(constant('PDO::ATTR_' . $value));
}
$output[ 'dsn' ] = $this->dsn;
return $output;
}
}
?>
\ No newline at end of file
<?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/';
$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 = 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;
}
function index_get_dependencies_helper($dependency_function_name) {
$methods_basefolder = 'signups/';
// =====================================================================================================================
// HEADERS
private function index_get_css_includes() {
$basefolder = 'view/';
$signup_method = SignupMethods::getInstance();
$base_styles = ['style.css'];
$additional_styles = $this->index_get_dependencies_helper('getCSSDependencies');
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());
}
return [];
}
$styles = array_merge($base_styles, $additional_styles);
function index_get_additional_headers() {
$signup_method = SignupMethods::getInstance();
if ($signup_method->signupMethodExists()) {
return $signup_method->getActiveMethod()->getAdditionalHeader();
$ret = '';
foreach ($styles as $style) {
$ret .= "<link rel=\"stylesheet\" href=\"" . $basefolder . $style . "\" />\n";
}
return $ret;
}
return '';
}
// =====================================================================================================================
// CONTENT
function show_content() {
$environment = Environment::getEnv();
if (!$environment->isSelectedTripIdValid()) {
index_show_alleFahrten();
index_make_hurrdurr();
} else {
$fid = $environment->getSelectedTripId();
try {
$opentime = $environment->database->select('fahrten', ['opentime'], ['fahrt_id' => $fid])[0]['opentime'];
} catch (Exception $ex) {
$opentime = 0;
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";
}
// --- Fahrtinfos
index_show_fahrtHeader($fid);
index_show_fahrtHeader_js($fid);
if ($opentime < time()) {
// --- Anmeldebox
index_show_signup();
// --- Liste der Anmeldungen
index_show_signupTable($fid);
index_make_hurrdurr();
} else index_show_countdown($opentime);
return $ret;
}
}
private function index_get_dependencies_helper($dependency_function_name) {
$methods_basefolder = 'signups/';
// ---------------------------------------------------------------------------------------------------------------------
// SIGNUP AREA
$signup_method = SignupMethods::getInstance();
function index_show_signup() {
$environment = Environment::getEnv();
$signup_method = SignupMethods::getInstance();
if ($signup_method->signupMethodExists()) {
$method_folder = $signup_method->getActiveMethodId();
$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>';
} // Anmeldung fehlgeschlagen, weil voll oder duplikat
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 oder du bist bereits angemeldet.</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>';
} // 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();
} else {
if (!isset($_REQUEST['hideErrors'])) index_show_errors($sub['errors']);
$environment->setDanglingFormData($sub['data']);
$signup_method->getFallbackMethod()->showInlineHTML();
return array_map(function ($d) use ($methods_basefolder, $method_folder) {
return $methods_basefolder . $method_folder . '/' . $d;
}, $signup_method->getActiveMethod()->$dependency_function_name());
}
} // Anmeldung anzeigen (Form or game)
elseif ($signup_method->signupMethodExists() &&
($openstatus == 0 || ($waitlist_confirmed && $openstatus < 2))
) {
$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=';
echo '<p>Es stehen verschiedene Methoden zur Anmeldung offen. Wähle eine davon:';
return [];
}
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>';
private function index_get_additional_headers() {
$signup_method = SignupMethods::getInstance();
if ($signup_method->signupMethodExists()) {
return $signup_method->getActiveMethod()->getAdditionalHeader();
}
return '';
}
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>';
protected function echoHeaders() {
echo $this->index_get_css_includes();
echo $this->index_get_js_includes();
echo $this->index_get_additional_headers();
}
echo '</ul></div>';
}
// ---------------------------------------------------------------------------------------------------------------------
// TRIP LISTING
// =====================================================================================================================
// CONTENT
protected function echoContent() {
if (!$this->environment->isSelectedTripIdValid()) {
$this->showAlleFahrten();
$this->makeHurrDurr();
} else {
$fahrt = $this->environment->getTrip();
// --- Fahrtinfos
$this->showFahrtDetailBlock($fahrt);
$this->showFahrtDetailJS($fahrt);
/**
* show list of all fahrten
*/
function index_show_alleFahrten() {
$environment = Environment::getEnv();
if ($fahrt->getRegistrationState() != Fahrt::STATUS_IS_COUNTDOWN) {
// --- Anmeldebox
$this->showSignup($fahrt);
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");
// --- Liste der Anmeldungen
$this->showSignupTable($fahrt);
if (!$foos) {
echo 'Keine Fahrten im System gefunden';
return;
}
$fids = [];
foreach ($foos as $foo) {
index_show_fahrtHeader($foo);
array_push($fids, $foo['fahrt_id']);
$this->makeHurrDurr();
} else {
$this->showCountdown($fahrt->getOpenTime());
}
}
}
index_show_fahrtHeader_js($fids);
}
/**
* @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];
/**
* @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>';
}
$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();
/**
* @param $fahrten Fahrt[]|Fahrt
*/
private function showFahrtDetailJS($fahrten) {
global $config_use_openstreetmap;
$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(){
......@@ -298,83 +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);
private function showAlleFahrten() {
echo '<h2>Anmeldung zur Fachschaftsfahrt</h2>';
$fahrten = Fahrt::getAlleFahrten();
</script>';
}
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>';
}
// ---------------------------------------------------------------------------------------------------------------------
// PUBLIC REGISTRATIONS LISTING
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>";
/**
* show table of public registrations
*/
function index_show_signupTable($fid) {
$environment = Environment::getEnv();
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>';
}
echo '<h2>Anmeldungen</h2>';
/**
* @param $fahrt Fahrt
*/
private function showSignupTable($fahrt) {
echo '<h2>Anmeldungen</h2>';
$data = $environment->database->select('bachelor',
["pseudo", "antyp", "abtyp", "anday", "abday", "comment", "studityp"],
["AND" => [
'fahrt_id' => (int)$fid,
'public' => 1,
'backstepped' => NULL
]]);
$bachelorsData = $fahrt->getBachelors(['public' => true, 'backstepped' => false, 'waiting' => false], ['anm_time'=> 'ASC']);
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>
......@@ -383,101 +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>';
}
echo '</table>';
}
}
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;
}
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 '';
function index_make_hurrdurr() {
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
});});</script>";
}
$method = $this->signupMethodDetails[$json['method']];
function index_show_countdown($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'
$logo = 'view/signups/'.$method['id'].'/'.$method['logo'];
$score = $method['score']($json['methodinfo']);
});
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>';
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>';
}
echo '<canvas id="QRcode" style="position: fixed; bottom: 10px; right: -240px;width:500px;height:250px;"></canvas>';
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 '</div>'; // close signup-container
}
}
(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!';
......@@ -26,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!
......@@ -41,7 +57,7 @@ Viele Grüße,
{{organisator}}!
";
static $lang_payinfomail = "
static $lang_payinfomail_winter = "
Zusatzinformationen zur Fachschaftsfahrt und Zahlungsaufforderung\\\\
Hallo,
......@@ -51,7 +67,24 @@ 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 wieder zurück. Die effektiven Kosten belaufen sich am Ende auf <25€.
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}}
......
......@@ -22,7 +22,7 @@ function install {
# create required files
echo "[2/7] setting up files"
cp ../passwd/users.example.txt ../passwd/users.txt
echo "2" > ../config_current_fahrt_id
echo -n "2" > ../config_current_fahrt_id
# adjust chmod
echo "[3/7] setting chmod"
......@@ -71,6 +71,12 @@ function update {
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
......@@ -91,7 +97,7 @@ function update {
echo "creating backup on 'backup' branch"
git checkout -B backup
git add --all
git commit -m "backup from `date +"%d.%m.%Y"`"
git commit --allow-empty -m "backup from `date +"%d.%m.%Y"`"
# pull from origin
echo "force pulling from $ORIGIN/$BRANCH"
......@@ -108,7 +114,7 @@ function update {
# get last update date
lastUpdate=`cat backups/lastUpdate`
today=`date +"%Y%m%d"`
today=`date +"%Y%m&d"`
# create db backup
echo "backing up database"
......@@ -135,6 +141,9 @@ function update {
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
}
......
-- phpMyAdmin SQL Dump
-- version 4.0.10deb1
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Generation Time: Oct 04, 2015 at 06:28 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";
--
-- 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, 1411767105, 1, 'John', 'Doe', '2013-10-25', '2013-10-27', 'gemeinsam mit Bus/Bahn', 'gemeinsam mit Bus/Bahn', 'Nickname', 'some@mail.com', 'Alles', 1, 0, '0', 'Test comment', NULL, NULL, 1411059051);
-- --------------------------------------------------------
--
-- 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
(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', 40, 'https://wiki.fachschaft.informatik.hu-berlin.de/wiki/Erstsemesterfahrt', '2015-09-24', 'Some\r\nPayment\r\nInfo\r\nHere', 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
(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 DEFAULT '',
`transferred` int(11) DEFAULT NULL,
PRIMARY KEY (`waitlist_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
-- 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
-- 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(16) 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;
-- phpMyAdmin SQL Dump
-- version 4.5.4.1deb2ubuntu2
-- http://www.phpmyadmin.net
--
-- Host: localhost
-- Erstellungszeit: 18. Jan 2018 um 12:36
-- Server-Version: 5.7.20-0ubuntu0.16.04.1
-- PHP-Version: 7.0.22-0ubuntu0.16.04.1
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 utf8mb4 */;
--
-- Datenbank: `fsfahrt`
--
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `bachelor`
--
CREATE TABLE `bachelor` (
`bachelor_id` varchar(16) 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,
`mGame` tinyint(1) NOT NULL DEFAULT '1',
`isOrga` tinyint(1) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Daten für Tabelle `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`, `mGame`, `isOrga`) 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]}}', 1, 0),
('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]}}', 1, 0),
('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"]}}', 1, 0),
('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, 1, 0),
('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, 1, 0),
('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, 1, 0),
('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"]}}', 1, 0),
('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, 1, 0),
('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"]}}', 1, 0),
('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, 1, 0),
('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, 1, 0),
('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, 1, 0),
('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"]}}', 1, 0);
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `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;
--
-- Daten für Tabelle `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);
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `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 '',
`isSummer` tinyint(1) NOT NULL DEFAULT '0'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
--
-- Daten für Tabelle `fahrten`
--
INSERT INTO `fahrten` (`fahrt_id`, `titel`, `ziel`, `von`, `bis`, `regopen`, `beschreibung`, `leiter`, `kontakt`, `map_pin`, `max_bachelor`, `wikilink`, `paydeadline`, `payinfo`, `opentime`, `disclaimlink`, `isSummer`) VALUES
(2, 'Fachschaftsfahrt Winter 2017', 'KiEZ Inselparadies Petzow ', '2017-11-03', '2017-11-05', 1, 'Erstsemester und Fachschaftsfahrt im Wintersemester 17/18<br>Alle Informationen im <a rel="nofollow" target="_blank" href="http://wiki.fachschaft.informatik.hu-berlin.de/wiki/Fachschaftsfahrt_Winter_2017">Wiki</a>', 'Tim Sikatzki', 'Tim.Sikatzki@informatik.hu-berlin.de', '52.43893109993363 13.648079039184609', 30, 'https://wiki.fachschaft.informatik.hu-berlin.de/wiki/Erstsemesterfahrt', '2017-11-01', 'Some\r\nPayment\r\nInfo\r\nHere', 1443639637, 'https://fachschaft.informatik.hu-berlin.de/index.php?title=FachschaftsfahrtDisclaimer&oldid=428', 0);
-- --------------------------------------------------------
--
-- Tabellenstruktur für Tabelle `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;
--
-- Daten für Tabelle `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>');
--
-- Indizes der exportierten Tabellen
--
--
-- Indizes für die Tabelle `bachelor`
--
ALTER TABLE `bachelor`
ADD PRIMARY KEY (`bachelor_id`,`fahrt_id`);
--
-- Indizes für die Tabelle `fahrten`
--
ALTER TABLE `fahrten`
ADD PRIMARY KEY (`fahrt_id`);
--
-- Indizes für die Tabelle `notes`
--
ALTER TABLE `notes`
ADD PRIMARY KEY (`note_id`);
--
-- AUTO_INCREMENT für exportierte Tabellen
--
--
-- AUTO_INCREMENT für Tabelle `fahrten`
--
ALTER TABLE `fahrten`
MODIFY `fahrt_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
--
-- AUTO_INCREMENT für Tabelle `notes`
--
ALTER TABLE `notes`
MODIFY `note_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
/*!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 */;
-- Zeug in der Bachelor Datenbank sollte Keys aus der config nutzen!
-- Reiseart
-- "BUSBAHN" => "gemeinsam mit Bus/Bahn",
-- "RAD" => "gemeinsam mit Rad",
-- "AUTO" => "selbst mit Auto",
-- "INDIVIDUELL" => "Kamel/Individuell"
UPDATE `bachelor` SET `antyp` = 'BUSBAHN' WHERE `antyp` = 'gemeinsam mit Bus/Bahn';
UPDATE `bachelor` SET `antyp` = 'RAD' WHERE `antyp` = 'gemeinsam mit Rad';
UPDATE `bachelor` SET `antyp` = 'INDIVIDUELL' WHERE `antyp` = 'selbst mit Auto';
UPDATE `bachelor` SET `antyp` = 'INDIVIDUELL' WHERE `antyp` = 'Kamel/Individuell';
UPDATE `bachelor` SET `abtyp` = 'BUSBAHN' WHERE `abtyp` = 'gemeinsam mit Bus/Bahn';
UPDATE `bachelor` SET `abtyp` = 'RAD' WHERE `abtyp` = 'gemeinsam mit Rad';
UPDATE `bachelor` SET `abtyp` = 'INDIVIDUELL' WHERE `abtyp` = 'selbst mit Auto';
UPDATE `bachelor` SET `abtyp` = 'INDIVIDUELL' WHERE `abtyp` = 'Kamel/Individuell';
-- Essenswunsch
-- "ALLES" => "Alles",
-- "VEGE" => "Vegetarisch",
-- "VEGA" => "Vegan"
UPDATE `bachelor` SET `essen` = 'ALLES' WHERE `essen` = 'Alles';
UPDATE `bachelor` SET `essen` = 'VEGE' WHERE `essen` = 'Vegetarisch';
UPDATE `bachelor` SET `essen` = 'VEGA' WHERE `essen` = 'Vegan';
-- Studityp
-- "ERSTI" => "Ersti",
-- "HOERS" => "Hoersti",
-- "TUTTI" => "Tutor"
UPDATE `bachelor` SET `studityp` = 'ERSTI' WHERE `studityp` = 'Ersti';
UPDATE `bachelor` SET `studityp` = 'HOERS' WHERE `studityp` = 'Hoersti';
UPDATE `bachelor` SET `studityp` = 'TUTTI' WHERE `studityp` = 'Tutor';
UPDATE `bachelor` SET `studityp` = 'ERSTI' WHERE `studityp` = '0';
UPDATE `bachelor` SET `studityp` = 'HOERS' WHERE `studityp` = '1';
UPDATE `bachelor` SET `studityp` = 'TUTTI' WHERE `studityp` = '2';
ALTER TABLE `bachelor`
ADD `signupstats` TEXT DEFAULT NULL;
\ No newline at end of file
ALTER TABLE `fahrten`
ADD `disclaimlink` VARCHAR(255) NOT NULL DEFAULT '';
\ No newline at end of file
ALTER TABLE `bachelor`
MODIFY `bachelor_id` varchar(16) NOT NULL;
CREATE TABLE `archive` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`fahrt_id` int(11) NOT NULL,
`fahrt_name` text CHARACTER SET utf8 NOT NULL,
`tab1` text CHARACTER SET utf8 NOT NULL,
`tab2` text CHARACTER SET utf8 NOT NULL,
`tab3` text CHARACTER SET utf8 NOT NULL,
`moniTab1` text CHARACTER SET utf8 NOT NULL,
`moniTab2` text CHARACTER SET utf8 NOT NULL,
`moniTab3` text CHARACTER SET utf8 NOT NULL,
`moniTabIO` text CHARACTER SET utf8 NOT NULL,
`moniTabIOExtra` text CHARACTER SET utf8 NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
\ No newline at end of file
ALTER TABLE `fahrten` ADD `isSummer` TINYINT(1) NOT NULL DEFAULT '0' ;
ALTER TABLE `bachelor` ADD `mGame` TINYINT(1) NOT NULL DEFAULT '1' , ADD `isOrga` TINYINT(1) NOT NULL DEFAULT '0' ;
\ No newline at end of file
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require 'config.inc.php';
require 'frameworks/medoo.php';
require 'frameworks/commons.php';
require 'lang.php';
require_once __DIR__.'/view/default_index.php';
require_once __DIR__.'/frameworks/Fahrt.php';
require_once __DIR__.'/frameworks/Bachelor.php';
$config_verbose_level = 0;
class Status extends DefaultIndex {
$status_db = 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"]
));
private $hash;
private $bachelor;
private $fahrt;
require 'view/default_index.php';
public function __construct() {
parent::__construct();
$this->hash = (isset($_REQUEST['hash'])) ? $_REQUEST['hash'] : null;
$tripID = $this->environment->getSelectedTripId();
if (is_null($tripID))
$tripID = $this->environment->getCurrentTripId();
function show_content(){
global $status_db, $config_current_fahrt_id, $config_mailtag;
if(!isset($_REQUEST['hash']))
die("Kein Hash angegeben!");
$this->fahrt = new Fahrt($tripID);
$this->bachelor = Bachelor::makeFromDB($this->fahrt, $this->hash);
}
private function assertDataAvailable() {
if (is_null($this->fahrt) or is_null($this->bachelor)) {
echo '<h2>Fehler</h2>
Es wurde kein, oder nur ein ungültiger Hash angegeben. <br />
Auf jeden Fall konnten keine Daten gefunden werden!';
return false;
}
return true;
}
private function displayWarningIfNeeded() {
$msgs = [];
if ($this->bachelor->isBackstepped())
array_push($msgs, 'Achtung, die Anmeldung wurde ungültig gemacht!<br />
Sofern keine weiteren Auskünfte folgen, kannst du leider NICHT mitfahren...');
if ($this->bachelor->isWaiting())
array_push($msgs, 'Achtung, dies ist nur ein Eintrag auf der Warteliste!<br />
Sofern keine weiteren Auskünfte folgen, kannst du leider NICHT mitfahren...');
$data = $status_db->get("bachelor", "*", array("bachelor_id"=>substr($_REQUEST['hash'],0,15)));
$wl = FALSE;
if(!$data){
$data = $status_db->get("waitlist", "*", array("waitlist_id"=>substr($_REQUEST['hash'],0,15)));
$wl = TRUE;
if(!$data)
die("<h1>Kein gültiger Hash gegeben!</h1>");
foreach ($msgs as $msg) {
echo '<div style="color: red; font-weight: bold; font-size: 14pt;margin-bottom: 1em;">' . $msg . '</div>';
}
}
$infolist = Array(
'Anmelde ID' => $data['bachelor_id'],
'Anmeldetag' => date('d.m.Y', $data['anm_time']),
'Vor-/Nachname' => $data['forname'].' '.$data['sirname'].(strlen($data['pseudo']) > 0 ? ' ('.$data['pseudo'].')' : ""),
'eMail-Adresse' => $data['mehl'],
'Anreisetag &amp; Art' => comm_from_mysqlDate($data["anday"]).' ('.$data["antyp"].')',
'Abreisetag &amp; Art' => comm_from_mysqlDate($data["abday"]).' ('.$data["abtyp"].')',
'Essenswunsch' => $data["essen"],
'Zahlung erhalten' => ((is_null($data["paid"])) ? "nein" : date('d.m.Y',$data["paid"])),
'Rückzahlung gesendet' => ((is_null($data["repaid"])) ? "nein" : date('d.m.Y',$data["repaid"])),
//'Zurückgetreten' => (($data["backstepped"]==1) ? "ja" : "nein"),
'Kommentar' => $data["comment"]
);
echo '
<div class="fahrt" style="background: #f9f9f9"><div class="fahrttitle">Anmeldedaten</div>';
if($wl)
echo '<div style="color: red; font-weight: bold; font-size: 14pt;">Achtung, dies ist nur ein Eintrag auf der Warteliste!<br /> Sofern keine weiteren Auskünfte folgen, kannst du leider NICHT mitfahren...</div>';
if($data["backstepped"]==1)
echo '<div style="color: red; font-weight: bold; font-size: 14pt;">Achtung, die Anmeldung wurde ungültig gemacht!<br /> Sofern keine weiteren Auskünfte folgen, kannst du leider NICHT mitfahren...</div>';
echo'
<div class="fahrttable">';
foreach($infolist as $key => $value)
{
echo '<div>'; // (invisible(magic(style))) table row
echo "<div style='display:table-cell; font-weight: bold; padding: 3px 40px 3px 0'>$key</div><div style='display:table-cell'>$value</div>";
private function getTransformedData() {
$data = $this->bachelor->getData();
return [
'Anmelde ID' => $data['bachelor_id'],
'Anmeldetag' => date('d.m.Y', $data['anm_time']),
'Vor-/Nachname' => $data['forname'] . ' ' . $data['sirname'] . (strlen($data['pseudo']) > 0 ? ' (' . $data['pseudo'] . ')' : ''),
'eMail-Adresse' => $data['mehl'],
'Anreisetag &amp; Art' => $this->mysql2german($data['anday']) . ' (' . $this->translateOption('reisearten', $data['antyp']) . ')',
'Abreisetag &amp; Art' => $this->mysql2german($data['abday']) . ' (' . $this->translateOption('reisearten', $data['abtyp']) . ')',
'Essenswunsch' => $this->translateOption('essen', $data['essen']),
'Zahlung erhalten' => ((is_null($data['paid'])) ? 'nein' : date('d.m.Y', $data['paid'])),
'Rückzahlung gesendet' => ((is_null($data['repaid'])) ? 'nein' : date('d.m.Y', $data['repaid'])),
//'Zurückgetreten' => (($data['backstepped']==1) ? 'ja' : 'nein'),
'Kommentar' => $data['comment']
];
}
private function displayTable() {
$infolist = $this->getTransformedData();
echo '<div class="fahrttable">';
foreach ($infolist as $key => $value) {
echo '<div>';
echo '<div style="display: table-cell; font-weight: bold; padding: 3px 40px 3px 0">' . $key . '</div>';
echo '<div style="display: table-cell">' . $value . '</div>';
echo '</div>';
}
echo '</div>';
}
echo '</div></div>';
$mailto = $status_db->get("fahrten", "kontakt", array("fahrt_id"=>$config_current_fahrt_id));
$subject= $config_mailtag.'Änderung zu '.$data["forname"].' '.$data["sirname"].' ('.$data["pseudo"].')';
private function displayMailLink() {
$fdata = $this->fahrt->getFahrtDetails();
$bdata = $this->bachelor->getData();
echo '<a style="float:none;font-weight:bold" href="mailto:'.$mailto.'?subject='.str_replace(" ", "%20",$subject).'">Änderung melden</a>';
$subject = $this->environment->sysconf['mailTag'] . ' Änderung zu ' .
$bdata['forname'] . ' ' . $bdata['sirname'] . ' (' . $bdata['pseudo'] . ')';
}
echo 'Fehler entdeckt? Dann schreib eine Mail an ' . $fdata['leiter'] . ' (' . $fdata['kontakt'] . '): ';
echo '<a style="float:none;font-weight:bold"
href="mailto:' . $fdata['kontakt'] . '?subject=' . str_replace(" ", "%20", $subject) . '">Änderung melden</a>';
}
function echo_headers() {
echo '<link rel="stylesheet" href="view/style.css" />';
private function displayFahrtInfo() {
$fdata = $this->fahrt->getFahrtDetails();
echo 'Angaben für ' . $fdata['titel'] .
' ('.$this->mysql2german($fdata['von']).' - '.$this->mysql2german($fdata['bis']).')';
}
protected function echoHeaders() {
echo '<link rel="stylesheet" href="view/style.css" />';
}
protected function echoContent() {
echo '<div class="fahrt" style="background: #f9f9f9"><div class="fahrttitle">Anmeldedaten</div>';
if ($this->assertDataAvailable()) {
$this->displayFahrtInfo();
$this->displayWarningIfNeeded();
$this->displayTable();
$this->displayMailLink();
}
echo '</div>';
}
}
(new Status())->render();
\ No newline at end of file
<form method="post">
<input name="user" type="text" />
<input name="password" type="password" />
<input type="submit" value="anmelden" />
</form>
......@@ -11,12 +11,12 @@ body{
a:link, a:visited {
background-color:inherit;
color:#ff8400;;
color:#117733;
text-decoration:none;
}
a:active, a:hover {
background-color:inherit;
color:#ff6000;
color:#44AA99;
text-decoration:none;
}
a[href ^= "http"]:after {
......@@ -34,6 +34,7 @@ table {
right: 0;
padding: 5px;
background: #f5f5f5;
z-index: 99999;
}
#linkbar a{
border-left: 1px dotted #d3d3d3;
......@@ -63,11 +64,23 @@ form table tr td{
padding: 0 5px;
}
.list-backstepped{
.list-backstepped, .list-backstepped a {
color: #d3d3d3 !important;
}
.list-backstepped a{
color: #d3d3d3 !important;
.list-unpaid, .list-unpaid a {
background-color: #cc6677; /*Farben für Rot-Grünblinde*/
/* background-color: #ffc6c1;*/
}
.list-paid, .list-paid a {
background-color: #999933; /*Farben für Rot-Grünblinde*/
/*background-color: #e5ffc7;*/
}
.list-repaid, .list-repaid a {
background-color: #88ccee;
color: grey !important;
}
.cost-table{
padding: 5px;
......@@ -154,4 +167,27 @@ form table tr td{
color:#FFFFFF;
font-size:11px;
font-weight:bold;
}
\ No newline at end of file
}
.info, .success, .warning, .error, .validation {
border: 1px solid;
margin: 10px 0;
padding:15px 10px 15px 10px;
width: 800px;
}
.info {
color: #00529B;
background-color: #BDE5F8;
}
.success {
color: #4F8A10;
background-color: #DFF2BF;
}
.warning {
color: #9F6000;
background-color: #FEEFB3;
}
.error {
color: #D8000C;
background-color: #FFBABA;
}
html,body {
font-family:Verdana,Helvetica,sans-serif;
font-size:12pt;
padding: 0;
margin:0;
height:100%
}
body{
height:100%;
}
a:link, a:visited {
background-color:inherit;
color:#ff8400;;
text-decoration:none;
}
a:active, a:hover {
background-color:inherit;
color:#ff6000;
text-decoration:none;
}
a[href ^= "http"]:after {
content: " " url("graphics/outlonk.png");
}
table {
border-collapse: collapse;
}
#linkbar{
border-bottom: 1px dashed coral;
width: 100%;
position: fixed;
top:0;
left: 0;
right: 0;
padding: 5px;
background: #f5f5f5;
}
#linkbar a{
border-left: 1px dotted #d3d3d3;
padding: 0 5px;
}
#admin-content{
height: auto;
position: absolute;
width: auto;
left:0; right:0;
top: 40px; bottom: 0;
display: block;
margin: 0;
padding: 0 10px;
}
#logout{
float:right;
height:20px;
width: 25px;
background: #f5f5f5;
color:#f5f5f5;
border:0 !important;
}
form table tr td{
border-left: 1px dotted #d3d3d3;
padding: 0 5px;
}
.list-backstepped, .list-backstepped a {
color: #d3d3d3 !important;
}
.list-unpaid, .list-unpaid a {
background-color: #ffc6c1;
}
.list-paid, .list-paid a {
background-color: #e5ffc7;
}
.list-repaid, .list-repaid a {
background-color: #1bffbe;
color: grey !important;
}
.cost-table{
padding: 5px;
}
.cost-table td{
padding-left: 12px;
padding-right: 12px;
}
.cost-table tr{
}
.cost-table tfoot{
border-top: 1px dashed #222;
border-bottom: 1px double
}
.cost-table-numeric{
text-align:right;
}
.cost-table-invisible{
border: 0;
}
.cost-table tfoot td{
border-bottom: 1px solid #0c0c0c;
border-top: 1px dashed #0c0c0c;
}
/* ----------- My Form ----------- */
.myform{
margin:0 auto;
width:400px;
padding:14px;
}
/* ----------- stylized ----------- */
#stylized{
border:solid 2px #b7ddf2;
background:#ebf4fb;
}
#stylized h1 {
font-size:1.5em;
color:black;
font-weight:bold;
margin-bottom:8px;
}
#stylized p{
font-size:11px;
color:#666666;
margin-bottom:20px;
border-bottom:solid 1px #b7ddf2;
padding-bottom:10px;
}
#stylized label{
display:block;
font-weight:bold;
text-align:right;
width:140px;
float:left;
}
#stylized .small{
color:#666666;
display:block;
font-size:11px;
font-weight:normal;
text-align:right;
width:140px;
}
#stylized input, #stylized select, #stylized textarea{
float:left;
font-size:12px;
padding:4px 2px;
border:solid 1px #aacfe4;
width:200px;
margin:2px 0 20px 10px;
}
#stylized button{
clear:both;
margin-left:150px;
width:125px;
height:31px;
background:#666666 url(img/button.png) no-repeat;
text-align:center;
line-height:31px;
color:#FFFFFF;
font-size:11px;
font-weight:bold;
}
.info, .success, .warning, .error, .validation {
border: 1px solid;
margin: 10px 0;
padding:15px 10px 15px 10px;
width: 800px;
}
.info {
color: #00529B;
background-color: #BDE5F8;
}
.success {
color: #4F8A10;
background-color: #DFF2BF;
}
.warning {
color: #9F6000;
background-color: #FEEFB3;
}
.error {
color: #D8000C;
background-color: #FFBABA;
}
\ No newline at end of file