function customerFields($data, $badFields)
{
    global $states;
    global $COUNTRIES;
    if (userLoggedIn() && array_key_exists("CID", $data) && $data["CID"] != "") {
        tableRow(array(tableData(prompt("<b>CID:</b>"), "right", "top"), tableData(prompt($data["CID"]), "left", "top")));
        prepDatePicker();
        tableRow(array(tableData(prompt("<b>Met Date:</b>"), "right", "top"), tableData(text($data, "metDate", "", "", "datepicker"), "left", "middle")));
    }
    tableRow(array(tableData(prompt("<b>First name*:</b>", in_array("fname", $badFields)), "right"), tableData(text($data, "fname"), "left", "middle"), tableData(prompt("<b>Last name*:</b>", in_array("lname", $badFields)), "right"), tableData(text($data, "lname"), "left", "middle")));
    tableRow(array(tableData(prompt("<b>Email*:</b>", in_array("email", $badFields)), "right"), tableData(text($data, "email"), "left", "middle"), tableData(prompt("<b>Phone Number:</b>", in_array("phoneNum", $badFields)), "right"), tableData(text($data, "phoneNum"), "left", "middle")));
    tableRow(array(tableData(prompt("<b>Title:</b>", in_array("title", $badFields)), "right"), tableData(radioButton($data, "title", "Mr.", false, "Mr."), "center", "middle"), tableData(radioButton($data, "title", "Ms.", false, "Ms."), "center", "middle"), tableData(radioButton($data, "title", "Mrs.", false, "Mrs."), "center", "middle"), tableData(radioButton($data, "title", "Dr.", false, "Dr."), "center", "middle")));
    if (!userLoggedIn()) {
        if ($data["charity"] == true) {
            tableRow(array(tableData(prompt("Tell us about your situtation, your team and why you need a ChapR. The more information the better!"), "middle", "top", 6)));
        } else {
            tableRow(array(tableData(prompt("Write anything else you would like us to know about you below: <br> team info (type, name, number), how you heard about us (where, from who?) etc."), "middle", "top", 6)));
        }
    }
    tableRow(array(tableData(prompt("<b>Comments:</b>", in_array("customerCNotes", $badFields), ""), "right", "top"), tableData(textArea($data, "customerCNotes", 3), "center", "", 5)));
    tableRow(array(tableData(prompt("<b>Street1*:</b>", in_array("street1", $badFields)), "right"), tableData(text($data, "street1"), "left", "middle", 3)));
    tableRow(array(tableData(prompt("<b>Street2:</b>", in_array("street2", $badFields)), "right"), tableData(text($data, "street2"), "left", "middle", 3)));
    $stateDirections = 'only applicable for domestic teams';
    tableRow(array(tableData(prompt("<b>City*:</b>", in_array("city", $badFields)), "right"), tableData(text($data, "city"), "left", "middle"), tableData(prompt("<b>State*:</b>", in_array("state", $badFields), "", $stateDirections), "right"), tableData(dropDown($data, "state", $states, "--------Choose Your State-------"), "left", "middle")));
    tableRow(array(tableData(prompt("<b>Zip*:</b>", in_array("zip", $badFields)), "right"), tableData(text($data, "zip"), "left", "middle"), tableData(prompt("<b>Country:</b>", in_array("country", $badFields)), "right"), tableData(dropDown($data, "country", $COUNTRIES), "left", "middle")));
    if (userLoggedIn()) {
        tableRow(array(tableData(prompt("<b>Admin Comments:</b>", in_array("adminCNotes", $badFields), "", $commentDirections), "right", "top"), tableData(textArea($data, "adminCNotes", 3), "center", "", 5)));
    }
    tableRow(array(tableData(hiddenField("CID", $data["CID"])), tableData(hiddenField("OID", $data["OID"]))));
}
function checkUserLoggedIn()
{
    if (!userLoggedIn()) {
        echo "<h2>You must be logged in to use this function. ";
        switch (rand(0, 5)) {
            case 0:
                echo "Press the BACK button and log in!  or else...\n";
                break;
            case 1:
                echo "Press the BACK button and login, or just go away.</h2>";
                break;
            case 2:
                echo "Press the BACK button and login, or Ben will come after you.</h2>";
                break;
            case 3:
                echo "Press the BACK button and login, or Rachel may get mad at you.</h2>";
                break;
            case 4:
                echo "Press the BACK button and login, pretty please....</h2>";
                break;
            case 5:
                echo "Press the BACK button and login, or don't, or do,...</h2>";
                break;
        }
        exit(1);
    }
}
 public function postReply()
 {
     $validation = new Validator();
     $errors = $validation->isValid(Replies::$rules);
     if (sizeof($errors) > 0) {
         flash('errors', $errors);
         redirect($_SESSION['current_page']);
     }
     $data = ['topic_id' => $_POST['topic_id'], 'user_id' => userLoggedIn()->id, 'body' => strip_tags($_POST['body'])];
     if (Replies::create($data)) {
         flash('success', ['reply added successfully']);
         redirect($_SESSION['current_page']);
     }
 }
示例#4
0
function doHeader($title, $county)
{
    echo '<div id="main_header">';
    echo '<img id="logo" src="images/cnty_logo.png" height="98" alt="Home">';
    echo '<h1 id="Company">' . $county . '</h1>';
    echo '<h1 id="Application">' . $title . 's</h1>';
    if (userLoggedIn()) {
        echo '<div id="user_nav">';
        echo '<ul>';
        echo '	    <li><a href="userProfile.php">Profile</a></li>';
        echo '	    <li><a href="includes/logout.php">Log out</a></li>';
        echo '</ul>';
        echo '</div>';
    }
    echo '</div>';
}
示例#5
0
function the_whatpage_theme()
{
    global $globals, $mysql, $theme, $done, $error, $errors;
    global $user, $privs, $row;
    global $q, $q1;
    global $endpage_msg;
    error_handler($errors);
    //error_handler($endpage_msg);
    error_handler($endpage_msg);
    if (!userLoggedIn()) {
        return false;
    }
    if (!empty($errors) || !empty($endpage_msg)) {
        return false;
    }
    //		isAllowedTo();
    echo '<center>';
    echo '<h1>What?</h1>';
    echo '<h2>Which page is this, huh?</h2>';
    echo '<h3>Which page did you want, hunh!!!</h3>';
    echo '<h3>Redirecting you to the index page, lol :P :)</h3>';
    //echo '<h3>Awrite Cowboy, redirecting you to the index page, :P lol :)</h3>';
    echo '</center>';
}
<?php

if ($_GET["comp"] != '') {
    $comp = $_GET["comp"];
}
if ($_POST["comp"] != '') {
    $comp = $_POST["comp"];
}
require_once "./includes/applicationheader.php";
include "./languages/" . $_SP_language . "/invoke_chat.php";
$conn = getConnection();
if (userLoggedIn() && $_SESSION["sess_clientchatid"] != '') {
    /*$sql = "select vUserName from sptbl_users where nUserId = '".$_SESSION["sess_userid"]."'";
      $result = executeSelect($sql,$conn);
      if(mysql_num_rows($result) > 0) {
         while($row = mysql_fetch_array($result)) {
    		$username = $row["vUserName"];
    	 }
      }*/
    $username = $_SESSION["sess_userfullname"];
    header("location:client_chat.php?username="******"&comp=" . $comp);
}
/*Newly added on 190609*/
$sql = "Select vLookUpName,vLookUpValue from sptbl_lookup WHERE vLookUpName IN('LangChoice',\n          'DefaultLang','HelpdeskTitle','Logourl','logactivity','MaxPostsPerPage','OldestMessageFirst', 'PostTicketBeforeLogin','SMTPSettings','SMTPServer','SMTPPort')";
$rs = executeSelect($sql, $conn);
if (!isset($_SESSION['sess_cssurl'])) {
    $_SESSION['sess_cssurl'] = "styles/coolgreen.css";
}
if (mysql_num_rows($rs) > 0) {
    while ($row = mysql_fetch_array($rs)) {
        switch ($row["vLookUpName"]) {
function orderFields($data, $badFields)
{
    global $SETTINGS;
    // display data not supposed to be visible for customers
    if (userLoggedIn()) {
        if (array_key_exists("OID", $data) && $data["OID"] != "") {
            tableRow(array(tableData(prompt("<b>OID: </b>"), "right", "top"), tableData(prompt($data["OID"]), "left", "top")));
        }
        tableRow(array(tableData(prompt("<b>Expedite:</b>"), "right", "top"), tableData(checkBox($data, "isExpedited", "true", "YES"), "left", "middle", 3)));
        prepDatePicker();
        tableRow(array(tableData(prompt("<b>Ordered Date:</b>"), "right", "top"), tableData(text($data, "orderedDate", "", "", "datepicker"), "left", "middle")));
    }
    // show the order amount change fields if the user has permission (and in WordPress)
    if (inWordPress() && current_user_can("can_change_amounts")) {
        tableRow(array(tableData(prompt("<b>Shipping Fee:</b>", in_array("shippingFee", $badFields)), "right"), tableData(text($data, "shippingFee", null, "10"), "left"), tableData(prompt("<b>Expedite Fee:</b>", in_array("expediteFee", $badFields)), "right"), tableData(text($data, "expediteFee", null, "10"), "left"), tableData(prompt("<b>Discount:</b>", in_array("discount", $badFields)), "right"), tableData(text($data, "discount", null, "10"), "left")));
    }
    // figure out how many rows to display initially ($i is set to that value)
    for ($i = $SETTINGS["MaxItems"]; $i > 1; $i--) {
        if (array_key_exists("packages{$i}", $data) && $data["packages{$i}"] != "" && $data["packages{$i}"] != 0 || array_key_exists("personality{$i}", $data) && $data["personality{$i}"] != "" && $data["personality{$i}"] != 0 || array_key_exists("quantity{$i}", $data) && $data["quantity{$i}"] != "" && $data["quantity{$i}"] != 0) {
            break;
        }
    }
    $initialRows = $i;
    // get currently available packages (from database) for display
    $rows = dbGetPackages();
    $displayPackages = array();
    foreach ($rows as $row) {
        if ($row["Active"]) {
            $displayPackages[$row["PackageName"]] = $row["PKID"];
        }
    }
    // get currently available personalities (from database) for display
    $rows = dbGetPersonalities();
    $displayPersonalities = array();
    foreach ($rows as $row) {
        if ($row["Active"]) {
            $displayPersonalities[$row["PieceName"]] = $row["PID"];
        }
    }
    if (!userLoggedIn()) {
        tableRow(array(tableData(prompt("Note: \"personality\" refers to the type of software or platform the firmware is compatible with.\n<br> It can be changed later using a USB stick, but we might as well set it for you."), "middle", "top", 6)));
    }
    for ($i = 1; $i <= $SETTINGS["MaxItems"]; $i++) {
        // note that the "table-row" setting for display is controversial and may
        // not work well in Microsoft IE
        // note, too, that the reason while rows 2 through 5 don't initially display
        // is that they are set as display = 'none' in the style sheet - if that
        // is turned off, then they will display right away
        $magicClick = "";
        if ($i != $SETTINGS["MaxItems"]) {
            $magicClick = "<button id=\"prodrowclick-";
            $magicClick .= $i;
            $magicClick .= "\"";
            if ($i != $initialRows) {
                $magicClick .= " style=\"visibility:hidden;\"";
            }
            $magicClick .= " type=\"button\" onclick=\"";
            $magicClick .= "document.getElementById('prodrow-";
            $magicClick .= $i + 1;
            // sets the next row to visible
            $magicClick .= "').style.display = 'table-row';";
            if ($i < $SETTINGS["MaxItems"] - 1) {
                $magicClick .= "document.getElementById('prodrowclick-";
                $magicClick .= $i + 1;
                // sets the next button to visible
                $magicClick .= "').style.visibility = 'visible';";
            }
            $magicClick .= "document.getElementById('prodrowclick-";
            $magicClick .= $i;
            // sets its own button to hidden
            $magicClick .= "').style.visibility = 'hidden';";
            $magicClick .= "\">+</button>";
        }
        if (userLoggedIn() && array_key_exists("iid{$i}", $data) && $data["IID"] != "") {
            tableRow(array(tableData(prompt("<b>IID{$i}:</b>"), "right", "top"), tableData(prompt($data["iid{$i}"]), "left", "top")));
        }
        tableRow(array(tableData(prompt("<b>Product*:</b>", in_array("product{$i}", $badFields)), "right"), tableData(dropDown($data, "packages{$i}", $displayPackages, "----------Select Product----------")), tableData(prompt("<b>Personality:</b>", in_array("personality{$i}", $badFields)), "right"), tableData(dropDown($data, "personality{$i}", $displayPersonalities, " ")), tableData(prompt("<b>Quantity*:</b>", in_array("quantity{$i}", $badFields)), "right"), tableData(text($data, "quantity{$i}", "", "2"), "left"), tableData($magicClick)), "prodrow-" . $i, $i <= $initialRows);
        hiddenField("iid{$i}", $data["iid{$i}"]);
    }
    if (!userLoggedIn()) {
        tableRow(array(tableData(prompt("Write anything you would like us to know about the order: <br> a deadline you need to meet, some option you want that isn't offered etc."), "middle", "top", 6)));
    }
    tableRow(array(tableData(prompt("<b>Order Notes:</b>"), "right", "top"), tableData(textArea($data, "customerONotes", 5), "left", "", 5)));
    if (userLoggedIn()) {
        tableRow(array(tableData(prompt("<b>Admin Order Notes:</b>"), "right", "top"), tableData(textArea($data, "adminONotes", 5), "left", "", 5)));
    }
    hiddenField("charity", $data["charity"]);
    hiddenField("OID", $data["OID"]);
}
示例#8
0
function modifyprofile_theme()
{
    global $globals, $mysql, $theme, $done, $error, $errors;
    global $user, $privs, $row;
    global $q, $qe, $l;
    error_handler($errors);
    if (!empty($errors)) {
        return false;
    }
    if (!userLoggedIn()) {
        return false;
    }
    //		isAllowedTo();
    $cssThClassNm = 'class="dt-header"';
    $cssTrClassNm = 'class="dth-wp_post-tr"';
    $cssTdClassNm = 'class="dth-wp_post"';
    echo '
		<form method="post" action="">
			<table class="disp_table" id="disp_table" align="center" width="100%">
				<tr ' . $cssTrClassNm . '>
					<td ' . $cssTdClassNm . '>' . $l['usrnm'] . '</td>
					<td ' . $cssTdClassNm . '>' . $row['username'] . '</td>
				</tr>
				<tr ' . $cssTrClassNm . '>
					<td ' . $cssTdClassNm . '>' . $l['abt'] . '</td>
					<td ' . $cssTdClassNm . '><textarea name="about" rows="7" cols="40">' . $row['about'] . '</textarea></td>
				</tr>
				<tr ' . $cssTrClassNm . '>
					<td ' . $cssTdClassNm . '>' . $l['dob'] . '</td>
					<td ' . $cssTdClassNm . '><input type="text" name="dob" value=' . $row['dob'] . '></td>
				</tr>
				<tr ' . $cssTrClassNm . '>
					<td ' . $cssTdClassNm . '>' . $l['dp_url'] . '</td>
					<td ' . $cssTdClassNm . '><input type="text" name="display_pic_url" value=' . $row['display_pic_url'] . '></td>
				</tr>
				<tr ' . $cssTrClassNm . '>
					<td ' . $cssTdClassNm . '>' . $l['fav_perf'] . '</td>
					<td ' . $cssTdClassNm . '><input type="text" name="perfume" value=' . $row['perfume'] . '></td>
				</tr>
				<tr ' . $cssTrClassNm . '>
					<td ' . $cssTdClassNm . 'width="50%">' . $l['dp_nm'] . '</td>
					<td ' . $cssTdClassNm . '><input type="text" name="display_name" value=' . $row['display_name'] . '></td>
				</tr>' . '<tr ' . $cssTrClassNm . '>
					<td ' . $cssTdClassNm . '>' . $l['email'] . '</td>
					<td ' . $cssTdClassNm . '>' . $row['email'] . '</td>
				</tr>
				<tr ' . $cssTrClassNm . '>
					<td ' . $cssTdClassNm . 'width="50%">' . $l['web_url'] . '</td>
					<td ' . $cssTdClassNm . '><input type="text" name="url" value=' . $row['url'] . '></td>
				</tr>
				<tr ' . $cssTrClassNm . '>
					<td ' . $cssTdClassNm . '>' . $l['sex'] . '</td>
					<td ' . $cssTdClassNm . '>
						<select name="sex">';
    $options = array("" => "Select", "m" => "Male", "f" => "Female", "o" => "Special");
    $ht = "";
    foreach ($options as $k => $v) {
        $sel = $k == $row['sex'] ? "selected" : "";
        $ht .= "<option value='{$k}' {$sel}>{$v}</option>";
    }
    echo $ht . '
						</select>
					</td>
				</tr>
			</table>
			<br />
			<br />
			<center>
				<input class="mun-button-default" type="submit" id="modprof" name="modprof" value="Modify Profile">
			</center>
		</form>
	';
}
示例#9
0
/**
 * ChurchTools 2.0
 * http://www.churchtools.de
 *
 * Copyright (c) 2014 Jens Martin Rauen
 * Licensed under the MIT license, located in LICENSE.txt
 *
 * ChurchCal Module
 * Depends on ChurchCore
 */
function churchcal_main()
{
    global $config, $base_url, $config, $embedded;
    drupal_add_css(ASSETS . '/fullcalendar/fullcalendar.css');
    if (isset($_GET["printview"])) {
        drupal_add_css(ASSETS . '/fullcalendar/fullcalendar.print.css');
    }
    drupal_add_css(ASSETS . '/simplecolorpicker/jquery.simplecolorpicker.css');
    drupal_add_js(ASSETS . '/simplecolorpicker/jquery.simplecolorpicker.js');
    drupal_add_js(ASSETS . '/fullcalendar/moment.min.js');
    drupal_add_js(ASSETS . '/fullcalendar/fullcalendar.min.js');
    drupal_add_js(CHURCHCORE . '/cc_events.js');
    drupal_add_js(CHURCHCORE . '/cc_abstractview.js');
    drupal_add_js(CHURCHCORE . '/cc_standardview.js');
    drupal_add_js(CHURCHCORE . '/cc_maintainstandardview.js');
    drupal_add_js(CHURCHCAL . '/eventview.js');
    drupal_add_js(CHURCHCAL . '/yearview.js');
    drupal_add_js(CHURCHCAL . '/calendar.js');
    drupal_add_js(CHURCHCAL . '/cal_sources.js');
    drupal_add_js(createI18nFile("churchcore"));
    drupal_add_js(createI18nFile("churchcal"));
    $txt = '';
    if ($catId = getVar("category_id")) {
        include_once CHURCHCAL . '/churchcal_db.php';
        $auth = churchcal_getAuthForAjax();
        $perm = true;
        foreach (explode(",", $catId) as $id) {
            // Check permission, perhaps show login mask
            if (empty($auth["view category"]) || empty($auth["view category"][$id])) {
                $perm = false;
            }
        }
        if (!$perm) {
            include_once MAIN . '/login.php';
            $login = login_main();
            if (!userLoggedIn()) {
                return $login;
            }
        }
        $txt .= '<input type="hidden" id="filtercategory_id" name="category_id" value="' . $catId . '"/>' . NL;
        if ($id = getVar("id")) {
            // only of category_id is set
            $txt .= '<input type="hidden" id="filterevent_id" name="id" value="' . $id . '"/>' . NL;
        }
    }
    if (getVar("printview")) {
        $txt .= '<input type="hidden" id="printview" value="true"/>';
        $embedded = true;
    }
    if ($embedded) {
        if ($catSel = getVar("category_select")) {
            $txt .= '<input type="hidden" id="filtercategory_select" name="category_select" value="' . $catSel . '"/>' . NL;
        }
        if ($cssUrl = getVar("cssurl")) {
            drupal_add_css($cssUrl);
        }
        // if (getConf("churchcal_css", "-") != "-") $txt .= '<style>' . getConf("churchcal_css") . '</style>'; //TODO: is
        // the '-' important?
        if ($css = getConf("churchcal_css")) {
            $txt .= "<style>{$css}</style>" . NL;
        }
        if (getVar("minical")) {
            $txt .= '<input type="hidden" id="isminical"/>';
        }
        $txt .= '
        <div class="row-fluid">
          <div id="cdb_filter"></div>
        </div>
        <div id="cdb_content"><div id="calendar"></div></div>
    ';
        if (getVar("embedded")) {
            $txt .= '<input type="hidden" id="isembedded"/>';
        }
        if ($t = getVar("title")) {
            $txt .= '<input type="hidden" id="embeddedtitle" value="' . $t . '"/>';
        }
        if ($e = getVar("entries")) {
            $txt .= '<input type="hidden" id="entries" value="' . $e . '"/>';
        }
        if ($s = getVar("startdate")) {
            $txt .= '<input type="hidden" id="init_startdate" value="' . $s . '"/>';
        }
        if ($e = getVar("enddate")) {
            $txt .= '<input type="hidden" id="init_enddate" value="' . $e . '"/>';
        }
    } else {
        $txt .= '
      <div class="row-fluid">
    <div class="span3"><div id="cdb_filter"></div></div>
    <div class="span9"><div id="header" class="pull-right"></div><div id="cdb_content"><div id="calendar"></div></div></div>
        <p align=right><small>
          <a target="_blank" href="' . $base_url . '?q=churchcal&embedded=true"> ' . t("embed", getConf("churchcal_name")) . '</a>
          <a target="_clean" href="http://intern.churchtools.de/?q=churchwiki#WikiView/filterWikicategory_id:0/doc:ChurchCal%C2%A0einbetten/"><i class="icon-question-sign"></i></a>
          &nbsp; <a id="abo" href="' . $base_url . '?q=churchcal/ical">' . $config["churchcal_name"] . ' ' . t("subscribe.to.ical") . '</a>' . '</small>';
    }
    if ($d = getVar("date")) {
        $txt .= '<input type="hidden" name="viewdate" id="viewdate" value="' . $d . '"/>';
    }
    if ($v = getVar("viewname")) {
        $txt .= '<input type="hidden" name="viewname" id="viewname" value="' . $v . '"/>';
    }
    return $txt;
}
示例#10
0
	function delete_suggestion(){
		global $conn;
		
		$tablename = $_GET['tableName'];
		$suggestion_id = $_GET['suggestion_id'];
		$token = $_GET['jwt'];
		
		
		
		//we dont have to worry about checking what the result is, as as soon as it realizes we arent logged in 401 response header sent and caight by HTTP interceptor
		userLoggedIn($token);
		flush();
		
		
		$accepted_tables = get_tables();
		if(in_array($tablename, $accepted_tables)){
			$tablename = htmlspecialchars($tablename);
			$suggestion_id = htmlspecialchars($suggestion_id);
			if($sql = $conn->prepare("DELETE FROM $tablename WHERE suggestion_id = ?")){
				$sql->bind_param('s', $suggestion_id);
				if( !($sql->execute()) ){
					echo false;
				}
			}
		}

		
	}
示例#11
0
<?php

$router->map('GET', '/', 'App\\controllers\\HomeController@showIndex', 'home');
$router->map('POST', '/', 'App\\controllers\\AuthenticationController@postLogin', 'login');
$router->map('GET', '/topics', 'App\\controllers\\TopicController@showTopics', 'topics');
$router->map('GET', '/topics/category/[:action]', 'App\\controllers\\TopicController@showCategoryTopics', 'categoryTopics');
$router->map('GET', '/topic/[i:id]', 'App\\controllers\\TopicController@showTopic', 'topic');
if (userLoggedIn() != false) {
    $router->map('GET', '/logout', 'App\\controllers\\AuthenticationController@logout', 'logout');
    $router->map('GET', '/topic/create', 'App\\controllers\\TopicController@showcreateTopic', 'createTopic');
    $router->map('POST', '/topic/create', 'App\\controllers\\TopicController@postCreateTopic', 'postcreateTopic');
    $router->map('POST', '/topic/[i:id]', 'App\\controllers\\TopicController@postReply', 'postReply');
}
if (userLoggedIn() == false) {
    $router->map('GET', '/register', 'App\\controllers\\RegisterController@showRegister', 'register');
    $router->map('POST', '/register', 'App\\controllers\\RegisterController@postRegister', 'postRegister');
    $router->map('GET', '/captcha', 'App\\controllers\\HomeController@showCaptcha');
}
示例#12
0
function login_main()
{
    global $q, $config;
    $txt = "";
    if (isset($config["admin_message"]) && $config["admin_message"] != "") {
        addErrorMessage($config["admin_message"]);
    }
    if (isset($_GET["message"]) && $_GET["message"] != "") {
        addInfoMessage($_GET["message"]);
    }
    // Sicherstellen, dass keiner eingelogt ist!
    if (!userLoggedIn()) {
        if (isset($config["login_message"])) {
            addInfoMessage($config["login_message"], true);
        }
        $model = new CTForm("LoginForm", "prooveLogin", "Login");
        $model->setHeader(t("login.headline"), t("please.fill.following.fields"));
        $model->addField("email", "", "INPUT_REQUIRED", t("email.or.username"), true);
        $model->addField("password", "", "PASSWORD", t("password"));
        if (!isset($config["show_remember_me"]) || $config["show_remember_me"] == 1) {
            $model->addField("rememberMe", "", "CHECKBOX", t("remember.me"));
        }
        $model->addButton(t("login"), "ok");
        if (isset($_GET["newpwd"])) {
            $res = db_query("select count(*) c from {cdb_person} where email='" . $_GET["email"] . "' and archiv_yn=0")->fetch();
            if ($_GET["email"] == "" || $res->c == 0) {
                $txt .= '<div class="alert alert-error"><p>Bitte ein g&uuml;ltige EMail-Adresse angeben, 
          an die das neue Passwort gesendet werden kann! 
          Diese Adresse muss im System schon eingerichtet sein.
          <p>Falls die E-Mail-Adresse schon eingerichtet sein sollte, 
          wende Dich bitte an <a href="' . variable_get("site_mail") . '">' . variable_get("site_mail") . '</a>.</div>';
            } else {
                $newpwd = random_string(8);
                $scrambled_password = scramble_password($newpwd);
                db_query("update {cdb_person} set password='******' where email='" . $_GET["email"] . "'");
                $content = "<h3>Hallo!</h3><p>Ein neues Passwort wurde f&uuml;r die E-Mail-Adresse <i>" . $_GET["email"] . "</i> angefordert: {$newpwd}";
                churchcore_systemmail($_GET["email"], "[" . variable_get('site_name') . "] Neues Passwort", $content, true, 1);
                churchcore_sendMails(1);
                $txt .= '<div class="alert alert-info">Hinweis: Ein neues Passwort wurde nun an <i>' . $_GET["email"] . '</i> gesendet.</div>';
                ct_log("Neues Passwort angefordert " . $_GET["email"], 2, "-1", "login");
            }
        } else {
            if (isset($_POST["email"]) && isset($_POST["password"]) && isset($_POST["directtool"])) {
                include_once CHURCHCORE . "/churchcore_db.php";
                $sql = "select * from {cdb_person} where email=:email and active_yn=1 and archiv_yn=0";
                $res = db_query($sql, array(":email" => $_POST["email"]))->fetch();
                if ($res == false) {
                    drupal_json_output(jsend()->fail("Unbekannte E-Mail-Adresse"));
                } else {
                    if (user_check_password($_POST["password"], $res)) {
                        login_user($res);
                        ct_log("Login durch Direct-Tool " . $_POST["directtool"] . " mit " . $_POST["email"], 2, "-1", "login");
                        drupal_json_output(jsend()->success());
                    } else {
                        drupal_json_output(jsend()->fail("Falsches Passwort"));
                    }
                }
                return;
            } else {
                if (isset($_GET["loginstr"]) && $_GET["loginstr"] != "" && isset($_GET["id"])) {
                    // L�sche alte cc_loginurrls die �lter sind als 14 tage
                    db_query("delete from {cc_loginstr} where DATEDIFF( current_date, create_date ) > 13");
                    $sql = "select * from {cc_loginstr} where loginstr=:loginstr and person_id=:id";
                    $res = db_query($sql, array(":loginstr" => $_GET["loginstr"], ":id" => $_GET["id"]))->fetch();
                    if ($res == false) {
                        $txt .= '<div class="alert alert-info">Fehler: Der verwendete Login-Link ist nicht mehr aktuell und kann deshalb nicht mehr verwendet werden. Bitte mit E-Mail-Adresse und Passwort anmelden!</div>';
                    } else {
                        // Nehme den LoginStr heraus, damit er nicht mi�braucht werden kann.
                        $sql = "delete from {cc_loginstr} where loginstr=:loginstr and person_id=:id";
                        $res = db_query($sql, array(":loginstr" => $_GET["loginstr"], ":id" => $_GET["id"]));
                        ct_log("Login User " . $_GET["id"] . " erfolgreich mit loginstr ", 2, "-1", "login");
                        $res = churchcore_getPersonById($_GET["id"]);
                        login_user($res);
                    }
                }
            }
        }
        $txt .= $model->render();
        $txt .= '<script>jQuery("#newpwd").click(function(k,a) {
         if (confirm("' . t('want.to.receive.new.password') . '")) {
           window.location.href="?newpwd=true&email="+jQuery("#LoginForm_email").val()+"&q=' . $q . '";
            }
          });</script>';
    } else {
        // Wenn man sich ummelden m�chte und zur Familie geh�rt (also gleiche E-Mail-Adresse)
        if (isset($_GET["family_id"])) {
            if (isset($_SESSION["family"][$_GET["family_id"]])) {
                //logout_current_user();
                login_user($_SESSION["family"][$_GET["family_id"]]);
                $txt .= '<div class="alert alert-info">Ummelden erfolgreich! Du arbeitest nun mit der Berechtigung von ' . $_SESSION["user"]->vorname . ' ' . $_SESSION["user"]->name . '.</div>';
            } else {
                $txt .= '<div class="alert alert-info">Ummelden zu Id:' . $_GET["family_id"] . ' hat nicht funktioniert, Session ist leer!</div>';
            }
        } else {
            $txt .= '<div class="alert alert-info"><i>Hinweis:</i> Du bist angemeldet als ' . $_SESSION["user"]->vorname . ', weiter geht es <a href="?q=home">hier</a>!</div>';
        }
    }
    return $txt;
}
示例#13
0
/**
 * main function for login
 * @return string
 */
function login_main()
{
    global $q, $config, $user;
    $txt = "";
    if ($t = getConf("admin_message")) {
        addErrorMessage($t);
    }
    if ($t = getVar("message")) {
        addInfoMessage($t);
    }
    // Sicherstellen, dass keiner eingelogt ist!
    if (!userLoggedIn()) {
        if ($t = getVar("login_message")) {
            addInfoMessage($t, true);
        }
        $form = new CTForm("LoginForm", "validateLogin", "Login");
        $form->setHeader(t("login.headline"), t("please.fill.following.fields"));
        $form->addField("email", "", "INPUT_REQUIRED", t("email.or.username"), true);
        if (getVar("email")) {
            $form->fields["email"]->setValue(getVar("email"));
        }
        $form->addField("password", "", "PASSWORD", t("password"));
        // TODO: when is this false?
        if (getConf("show_remember_me", 1) == 1) {
            $form->addField("rememberMe", "", "CHECKBOX", t("remember.me"));
        }
        $form->addButton(t("login"), "ok");
        // access through externale tools through GET and additional direct
        // POST so no GET is used , so it is not visible in the URL
        if (getVar("email", false, $_POST) && getVar("password", false, $_POST) && getVar("directtool", false, $_POST)) {
            include_once CHURCHCORE . "/churchcore_db.php";
            $email = getVar("email", false, $_POST);
            $password = getVar("password", false, $_POST);
            $directTool = getVar("directtool", false, $_POST);
            $res = db_query("SELECT * FROM {cdb_person}\n                       WHERE email=:email AND active_yn=1 AND archiv_yn=0", array(":email" => $email))->fetch();
            if (!$res) {
                drupal_json_output(jsend()->fail(t('email.unknown')));
            } else {
                if (user_check_password($password, $res)) {
                    login_user($res, null, false);
                    ct_log("Login by Direct-Tool {$directTool} with {$email}", 2, "-1", "login");
                    drupal_json_output(jsend()->success());
                } else {
                    drupal_json_output(jsend()->fail(t('wrong.password')));
                }
            }
            return;
        } else {
            if (($loginstr = getVar("loginstr")) && ($id = getVar('id'))) {
                // delete login strings older then 14 days
                db_query("DELETE FROM {cc_loginstr}\n                WHERE DATEDIFF( current_date, create_date ) > 13");
                $res = db_query("SELECT * FROM {cc_loginstr}\n                       WHERE loginstr=:loginstr AND person_id=:id", array(":loginstr" => $loginstr, ":id" => $id))->fetch();
                if (!$res) {
                    $txt .= '<div class="alert alert-info">' . t('login.string.too.old') . '</div>';
                } else {
                    // delete current loginKey to prevent misuse
                    $res = db_query("DELETE FROM {cc_loginstr}\n                         WHERE loginstr=:loginstr AND person_id=:id", array(":loginstr" => $loginstr, ":id" => $id));
                    ct_log("Login User {$id} erfolgreich mit loginstr ", 2, "-1", "login");
                    $res = churchcore_getPersonById($id);
                    login_user($res);
                }
            }
        }
        $txt .= $form->render();
        $txt .= '<script>jQuery("#newpwd").click(function(k,a) {
         if (confirm("' . t('want.to.receive.new.password') . '")) {
           window.location.href="?q=login/newpwd&email="+jQuery("#LoginForm_email").val();
            }
          });</script>';
    } else {
        // switch to another family user (same email)
        if ($familyId = getVar("family_id")) {
            if (isset($_SESSION["family"][$familyId])) {
                // logout_current_user();
                login_user($_SESSION["family"][$familyId]);
                $txt .= '<div class="alert alert-info">' . t('user.succesfully.changed.now.you.work.with.permissions.of.x', $_SESSION["user"]->vorname . ' ' . $_SESSION["user"]->name) . '</div>';
            } else {
                $txt .= "<div class='alert alert-info'>" . t('user.change.to.familyX.failed.session.is.empty', $familyId) . "</div>";
            }
        } else {
            if (getVar("directtool", false, $_POST)) {
                drupal_json_output(jsend()->success("Already logged in"));
            } else {
                $txt .= '<div class="alert alert-info">' . t('you.are.logged.in.as.x.click.y.to.continue', $_SESSION["user"]->vorname, '<a href="?q=home">' . t('home') . '</a>') . '</div>';
            }
        }
    }
    return $txt;
}
示例#14
0
function the_endpage_theme()
{
    global $globals, $mysql, $theme, $done, $error, $errors;
    global $user, $privs, $row;
    global $q, $q1;
    global $endpage_msg;
    error_handler($errors);
    //error_handler($endpage_msg);
    error_handler($endpage_msg);
    if (!userLoggedIn()) {
        return false;
    }
    if (!empty($errors) || !empty($endpage_msg)) {
        return false;
    }
    //		isAllowedTo();
    echo '
		<form method="post" action="">
			<table align="center" width="100%" border="1">
				<tr>
					<td>Username</td>
					<td>' . $row['username'] . '</td>
				</tr>
				<tr>
					<td>About</td>
					<td><textarea name="about" rows="7" cols="40">' . $row['about'] . '</textarea></td>
				</tr>
				<tr>
					<td>DOB</td>
					<td><input type="text" name="dob" value=' . $row['dob'] . '></td>
				</tr>
				<tr>
					<td>Display Pic Url</td>
					<td><input type="text" name="display_pic_url" value=' . $row['display_pic_url'] . '></td>
				</tr>
				<tr>
					<td>Fave Perfume</td>
					<td><input type="text" name="perfume" value=' . $row['perfume'] . '></td>
				</tr>
				<tr>
					<td width="50%"> DisplayName </td>
					<td><input type="text" name="display_name" value=' . $row['display_name'] . '></td>
				</tr>' . '<tr>
					<td>Email </td>
					<td>' . $row['email'] . '</td>
				</tr>
				<tr>
					<td width="50%">Web URL</td>
					<td><input type="text" name="url" value=' . $row['url'] . '></td>
				</tr>
				<tr>
					<td>Sex</td>
					<td>
						<select name="sex">';
    $options = array("" => "Select", "m" => "Male", "f" => "Female", "o" => "Special");
    $ht = "";
    foreach ($options as $k => $v) {
        $sel = $k == $row['sex'] ? "selected" : "";
        $ht .= "<option value='{$k}' {$sel}>{$v}</option>";
    }
    echo $ht . '
						</select>
					</td>
				</tr>
			</table>
			<br />
			<br />
			<center>
				<input type="submit" id="modprof" name="modprof" value="Modify Profile">
			</center>
		</form>
	';
}
 function userLoggedIn()
 {
     $this->loadExtension('DeprecatedAPI');
     return userLoggedIn();
 }
示例#16
0
/**
 * TODO: put this into churchtools_main, no need for two functions
 *
 * Main entry point for churchtools.
 * This will be called from /index.php
 * Function loads i18n, configuration, check data security.
 * If everything is ok, it calls churchtools_processRequest()
 */
function churchtools_app()
{
    global $q, $q_orig, $currentModule, $add_header, $config, $mapping, $content, $base_url, $files_dir, $user, $embedded, $i18n;
    include_once CHURCHCORE . "/churchcore_db.php";
    $files_dir = DEFAULT_SITE;
    // which module is requested?
    $q = $q_orig = getVar("q", userLoggedIn() ? "home" : getConf("site_startpage", "home"));
    // $currentModule is needed for class autoloading and maybe other include paths
    list($currentModule) = explode('/', getVar("q"));
    // get first part of $q or churchcore
    $embedded = getVar("embedded", false);
    $base_url = getBaseUrl();
    $config = loadConfig();
    if ($config) {
        if (db_connect()) {
            // DBConfig overwrites the config files
            loadDBConfig();
            if (empty($config['site_name'])) {
                $config['site_name'] = 'ChurchTools';
            }
            //dont allow site_name to be empty
            date_default_timezone_set(getConf("timezone", "Europe/Berlin"));
            if (isset($_COOKIE["language"])) {
                $config["language"] = $_COOKIE["language"];
            }
            // Load i18n churchcore-bundle
            if (!isset($config["language"])) {
                if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
                    $config["language"] = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
                } else {
                    $config["language"] = DEFAULT_LANGUAGE;
                }
            }
            $i18n = new TextBundle(CHURCHCORE . "/resources/messages");
            $i18n->load("churchcore", $config["language"] != null ? $config["language"] : null);
            // Session Init
            if (!file_exists($files_dir . "/tmp")) {
                @mkdir($files_dir . "/tmp", 0775, true);
            }
            if (!file_exists($files_dir . "/tmp")) {
                // Admin should act accordingly, default suggestion is 0755.
                addErrorMessage(t("permission.denied.write.dir", $files_dir));
            } else {
                session_save_path($files_dir . "/tmp");
            }
            session_name("ChurchTools_" . $config["db_name"]);
            session_start();
            register_shutdown_function('handleShutdown');
            // Check for offline mode. If it's activated display message and return false;
            if (getConf("site_offline") == 1) {
                if (!isset($_SESSION["user"]) || !in_array($_SESSION["user"]->id, getConf("admin_ids"))) {
                    echo t("site.is.down");
                    return false;
                }
            }
            $embedded = getVar("embedded", false);
            $mapping = loadMapping();
            $success = true;
            // Check for DB-Updates and loginstr only if this is not an ajax call.
            if (strrpos($q, "ajax") === false) {
                $success = checkForDBUpdates();
            }
            // Log if debug ist activated
            if (isset($config["debug"])) {
                logParams();
            }
            if ($success) {
                // Is there a loginstr which does not fit to the current logged in user?
                if (getVar("loginstr") && getVar("id") && userLoggedIn() && $_SESSION["user"]->id != getVar("id")) {
                    logout_current_user();
                    session_start();
                } else {
                    loadUserObjectInSession();
                }
            }
            if ($success) {
                if (isset($_SESSION['user'])) {
                    $user = $_SESSION['user'];
                }
                // Accept data security?
                if (userLoggedIn() && !isset($_SESSION["simulate"]) && $q != "logout" && isset($config["accept_datasecurity"]) && $config["accept_datasecurity"] == 1 && !isset($user->acceptedsecurity)) {
                    $content .= pleaseAcceptDatasecurity();
                } else {
                    $content .= churchtools_processRequest($q);
                }
            }
        }
    }
    // TODO: i changed header/footer to a sort of template
    // probably some more logic could be removed from them by setting some more variables here
    // put header/footer into new file layout.php and add a variable $content
    $lang = getConf("language");
    $simulate = getVar("simulate", false, $_SESSION);
    $sitename = getConf("site_name");
    if (getConf("test")) {
        $sitename .= " TEST ";
    }
    $logo = ($logo = getConf("site_logo")) ? "{$files_dir}/files/logo/{$logo}" : '';
    include INCLUDES . "/header.php";
    echo $content;
    include INCLUDES . "/footer.php";
}
示例#17
0
<?php

/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004-2007 ARMIA INC                                    |
// +----------------------------------------------------------------------+
// | This source file is a part of supportpro supportdesk                 |
// +----------------------------------------------------------------------+
// | Authors: johnson<*****@*****.**>                                  |
// +----------------------------------------------------------------------+
require_once "./includes/applicationheader.php";
include "languages/" . $_SP_language . "/knowledgebase.php";
if (!userLoggedIn()) {
    require_once "./includes/withoutlogindata.php";
}
$conn = getConnection();
include "./includes/docheader.php";
include "./includes/functions/functions.php";
$kbId = $_REQUEST['id'];
if ($kbId > 0) {
    $kbDataRes = getKbData($kbId);
    $kbData = mysql_fetch_assoc($kbDataRes);
}
$title = $kbData['vKBTitle'] ? $kbData['vCatDesc'] . ' - ' . trim_the_string($kbData['vKBTitle'], 70) : HEADER_KB;
?>
<title><?php 
echo $title;
?>
</title>
示例#18
0
/**
 * update DB for new versions of CT
 *
 * TODO: do you notice if there are sql errors?
 *
 * @param $db_version
 * @return boolean
 */
function run_db_updates($db_version)
{
    global $config, $base_url, $user, $files_dir;
    set_time_limit(300);
    switch ($db_version) {
        case 'nodb':
            if (isset($_GET["installdb"])) {
                db_query("CREATE TABLE {cc_usermails} (\n          person_id int(11) NOT NULL,\n          mailtype varchar(255) NOT NULL,\n          domain_id int(11) NOT NULL,\n          letzte_mail datetime NOT NULL,\n          PRIMARY KEY (person_id,mailtype,domain_id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cc_usersettings} (\n          person_id int(11) NOT NULL,\n          modulename varchar(50) NOT NULL,\n          attrib varchar(100) NOT NULL,\n          value varchar(8192) DEFAULT NULL,\n          PRIMARY KEY (person_id,modulename,attrib)\n        ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cc_usersettings} VALUES\n           (1, 'churchcal', 'filterMeineKalender', '[104]'),\n           (1, 'churchcal', 'viewName', 'month'),\n           (1, 'churchdb', 'churchdbInitView', 'PersonView'),\n           (1, 'churchdb', 'selectedGroupType', '1'),\n           (1, 'churchservice', 'lastVisited', '2013-08-30 15:53'),\n           (1, 'churchservice', 'remindMe', '1'),\n           (736, 'churchcal', 'viewName', 'month'),\n           (736, 'churchservice', 'lastVisited', '2013-04-18 8:27'),\n           (736, 'churchservice', 'remindMe', '1')");
                db_query("CREATE TABLE {cdb_bereich} (\n          id int(11) NOT NULL,\n          bezeichnung varchar(20) NOT NULL,\n          kuerzel varchar(10) NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cdb_bereich} VALUES\n           (1, 'Gemeindeliste', 'G'),\n           (2, 'Jugendarbeit', 'J')");
                db_query("CREATE TABLE {cdb_bereich_person} (\n          bereich_id int(11) NOT NULL,\n          person_id int(11) NOT NULL,\n          PRIMARY KEY (bereich_id,person_id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cdb_bereich_person} VALUES\n           (1, 1)");
                db_query("CREATE TABLE {cdb_beziehung} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          vater_id int(11) NOT NULL,\n          kind_id int(11) NOT NULL,\n          beziehungstyp_id int(11) NOT NULL,\n          datum datetime NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cdb_beziehungstyp} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          bez_vater varchar(20) NOT NULL,\n          bez_kind varchar(20) NOT NULL,\n          bezeichnung varchar(30) NOT NULL,\n          export_aggregation_yn int(11) NOT NULL,\n          export_title varchar(20) NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM  DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cdb_beziehungstyp} VALUES\n           (1, 'Elternteil', 'Kind', 'Elternteil/Kind', 0, ''),\n           (2, 'Ehepartner', 'Ehepartner', 'Ehepartner', 1, 'Ehepaar')");
                db_query("CREATE TABLE {cdb_comment} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          relation_id int(11) NOT NULL,\n          relation_name varchar(20) NOT NULL,\n          text text NOT NULL,\n          userid varchar(20) NOT NULL,\n          datum datetime NOT NULL,\n          comment_viewer_id int(11) NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cdb_comment_viewer} (\n          id int(11) NOT NULL,\n          bezeichnung varchar(30) NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cdb_comment_viewer} VALUES\n           (0, 'Alle'),\n           (1, 'Distriktleiter'),\n           (2, 'Vorstand')");
                db_query("CREATE TABLE {cdb_distrikt} (\n          id int(11) NOT NULL,\n          bezeichnung varchar(30) NOT NULL,\n          gruppentyp_id int(11) NOT NULL,\n          imageurl varchar(50) DEFAULT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cdb_distrikt} VALUES\n           (1, 'Nord', 1, 'gruppe_schwarz.png'),\n           (2, 'Süd', 1, 'gruppe_gelb.png'),\n           (3, 'Ost', 1, 'gruppe_blau.png'),\n           (4, 'West', 1, 'gruppe_gruen.png'),\n           (5, 'Sommerfreizeiten', 4, NULL)");
                db_query("CREATE TABLE {cdb_familienstand} (\n          id int(11) NOT NULL,\n          bezeichnung varchar(20) NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cdb_familienstand} VALUES\n           (0, 'unbekannt'),\n           (1, 'ledig'),\n           (2, 'verheiratet'),\n           (3, 'getrennt'),\n           (4, 'geschieden'),\n           (5, 'verwitwet')");
                db_query("CREATE TABLE {cdb_followup_typ} (\n          id int(1) NOT NULL,\n          bezeichnung varchar(50) NOT NULL,\n          comment_viewer_id int(11) NOT NULL DEFAULT '0',\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cdb_followup_typ} VALUES\n           (0, 'Kein Followup', 0),\n           (1, 'Integration Kontaktkarte', 0),\n           (2, 'Ein Monat', 0)");
                db_query("CREATE TABLE {cdb_followup_typ_intervall} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          followup_typ_id int(1) NOT NULL,\n          count_no int(1) NOT NULL,\n          days_diff int(2) NOT NULL,\n          info varchar(500) NOT NULL,\n          PRIMARY KEY (id),\n          UNIQUE KEY typ_no (followup_typ_id,count_no)\n        ) ENGINE=MyISAM  DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cdb_followup_typ_intervall} VALUES\n           (1, 1, 1, 7, 'Anruf 1 soll erfolgen.<br>Bitte sei nett zu der Person:)'),\n           (2, 1, 2, 14, 'Anruf 2 soll erfolgen.<br/>Kleingruppe gefunden?'),\n           (3, 1, 3, 90, 'Anruf 3 soll erfolgen. <br>Wie geht es so?'),\n           (4, 2, 1, 31, 'Person nachhalten nach einem Monat')");
                db_query("CREATE TABLE {cdb_gemeindeperson} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          person_id int(11) NOT NULL,\n          beruf varchar(50) NOT NULL,\n          geburtsname varchar(30) NOT NULL,\n          geburtsdatum datetime DEFAULT NULL,\n          geburtsort varchar(30) NOT NULL,\n          nationalitaet varchar(30) NOT NULL,\n          familienstand_no int(11) NOT NULL DEFAULT '0',\n          hochzeitsdatum datetime DEFAULT NULL,\n          station_id int(11) NOT NULL DEFAULT '0',\n          status_id int(11) NOT NULL DEFAULT '0',\n          erstkontakt datetime DEFAULT NULL,\n          zugehoerig datetime DEFAULT NULL,\n          eintrittsdatum datetime DEFAULT NULL,\n          austrittsgrund varchar(10) NOT NULL,\n          austrittsdatum datetime DEFAULT NULL,\n          taufdatum datetime DEFAULT NULL,\n          taufort varchar(50) NOT NULL,\n          getauftdurch varchar(50) NOT NULL,\n          ueberwiesenvon varchar(30) NOT NULL,\n          ueberwiesennach varchar(30) NOT NULL,\n          imageurl varchar(50) DEFAULT NULL,\n          letzteaenderung datetime DEFAULT NULL,\n          aenderunguser varchar(20) DEFAULT NULL,\n          PRIMARY KEY (id),\n          KEY person_id (person_id)\n        ) ENGINE=MyISAM  DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cdb_gemeindeperson} VALUES\n           (1, 1, '', '', null, '', '', 0, NULL, 1, 2, null, null, null, '', NULL, null, '', '', '', '', null, now(), 'admin')");
                db_query("CREATE TABLE {cdb_gemeindeperson_gruppe} (\n          gemeindeperson_id int(11) NOT NULL,\n          gruppe_id int(11) NOT NULL,\n          status_no int(1) NOT NULL DEFAULT '0',\n          letzteaenderung datetime DEFAULT NULL,\n          aenderunguser varchar(20) DEFAULT NULL,\n          followup_count_no int(1) DEFAULT NULL,\n          followup_add_diff_days int(3) DEFAULT NULL,\n          PRIMARY KEY (gemeindeperson_id,gruppe_id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cdb_gemeindeperson_gruppe_archive} (\n          gemeindeperson_id int(10) NOT NULL,\n          gruppe_id int(10) NOT NULL,\n          status_no int(1) NOT NULL DEFAULT '0',\n          letzteaenderung datetime DEFAULT NULL,\n          aenderunguser varchar(20) DEFAULT NULL\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cdb_gemeindeperson_tag} (\n          gemeindeperson_id int(11) NOT NULL,\n          tag_id int(11) NOT NULL,\n          letzteaenderung datetime DEFAULT NULL\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cdb_geschlecht} (\n          id int(11) NOT NULL,\n          bezeichnung varchar(20) NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cdb_geschlecht} VALUES\n           (0, 'unbekannt'),\n           (1, 'maennlich'),\n           (2, 'weiblich')");
                db_query("CREATE TABLE {cdb_gruppe} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          valid_yn int(1) NOT NULL DEFAULT '1',\n          versteckt_yn int(1) NOT NULL DEFAULT '0',\n          bezeichnung varchar(100) NOT NULL,\n          gruendungsdatum datetime DEFAULT NULL,\n          abschlussdatum datetime DEFAULT NULL,\n          treffzeit varchar(30) NOT NULL,\n          treffpunkt varchar(50) NOT NULL,\n          zielgruppe varchar(30) NOT NULL,\n          gruppentyp_id int(11) NOT NULL,\n          distrikt_id int(11) DEFAULT NULL,\n          geolat varchar(20) NOT NULL,\n          geolng varchar(20) NOT NULL,\n          treffname varchar(30) NOT NULL,\n          notiz varchar(200) NOT NULL,\n          treffen_yn int(11) NOT NULL,\n          instatistik_yn int(1) NOT NULL,\n          followup_typ_id int(1) DEFAULT NULL,\n          fu_nachfolge_typ_id int(11) NOT NULL DEFAULT '0',\n          fu_nachfolge_objekt_id int(11) DEFAULT NULL,\n          letzteaenderung datetime DEFAULT NULL,\n          aenderunguser varchar(20) DEFAULT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cdb_gruppentreffen} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          gruppe_id int(11) NOT NULL,\n          datumvon datetime NOT NULL,\n          datumbis datetime NOT NULL,\n          eintragerfolgt_yn int(11) NOT NULL,\n          ausgefallen_yn int(11) NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cdb_gruppentreffen_gemeindeperson} (\n          gruppentreffen_id int(11) NOT NULL,\n          gemeindeperson_id int(11) NOT NULL,\n          treffen_yn int(11) NOT NULL,\n          UNIQUE KEY gruppentreffen_id (gruppentreffen_id,gemeindeperson_id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cdb_gruppentyp} (\n          id int(11) NOT NULL,\n          bezeichnung varchar(30) NOT NULL,\n          anzeigen_in_meinegruppen_teilnehmer_yn int(1) NOT NULL,\n          muss_leiter_enthalten_yn int(1) NOT NULL,\n          in_neue_person_erstellen_yn int(1) NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cdb_gruppentyp} VALUES\n           (1, 'Kleingruppe', 1, 1, 0),\n           (2, 'Dienst', 1, 0, 0),\n           (3, 'Maßnahme', 0, 0, 1),\n           (4, 'Merkmal', 0, 0, 1)");
                db_query("CREATE TABLE {cdb_gruppe_tag} (\n          gruppe_id int(11) NOT NULL,\n          tag_id int(11) NOT NULL,\n          letzteaenderung datetime NOT NULL\n        ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cdb_log} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          level int(11) NOT NULL,\n          datum datetime NOT NULL,\n          userid varchar(255) NOT NULL,\n          domain_type varchar(255) DEFAULT NULL,\n          domain_id int(11) DEFAULT NULL,\n          schreiben_yn int(1) DEFAULT NULL,\n          txt varchar(2048) NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cdb_mailnotify} (\n          id varchar(20) NOT NULL,\n          emails varchar(200) NOT NULL,\n          enabled int(11) NOT NULL\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cdb_newsletter} (\n          person_id int(11) NOT NULL,\n          last_send datetime DEFAULT NULL,\n          PRIMARY KEY (person_id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cdb_person} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          name varchar(30) NOT NULL,\n          vorname varchar(30) NOT NULL,\n          password varchar(255) DEFAULT NULL,\n          loginstr varchar(255) DEFAULT NULL,\n          lastlogin datetime DEFAULT NULL,\n          geschlecht_no int(11) NOT NULL DEFAULT '0',\n          titel varchar(30) NOT NULL,\n          strasse varchar(30) NOT NULL,\n          plz varchar(6) NOT NULL,\n          ort varchar(40) NOT NULL,\n          land varchar(30) NOT NULL,\n          zusatz varchar(30) NOT NULL,\n          telefonprivat varchar(30) NOT NULL,\n          telefongeschaeftlich varchar(20) NOT NULL,\n          telefonhandy varchar(20) NOT NULL,\n          fax varchar(20) NOT NULL,\n          email varchar(50) NOT NULL,\n          geolat varchar(20) NOT NULL,\n          geolng varchar(20) NOT NULL,\n          cmsuserid varchar(50) NOT NULL,\n          createdate datetime DEFAULT NULL,\n          letzteaenderung datetime DEFAULT NULL,\n          aenderunguser varchar(20) DEFAULT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM  DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cdb_person} VALUES\n           (1, 'Admin', 'Admin', '21232f297a57a5a743894a0e4a801fc3', NULL, null, 0, '', '', '', '', '', '', '', '', '', '', '*****@*****.**', '', '', 'admin', now(), now(), 'admin')");
                db_query("CREATE TABLE {cdb_station} (\n          id int(11) NOT NULL,\n          bezeichnung varchar(20) NOT NULL,\n          kuerzel varchar(10) NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cdb_station} VALUES\n           (0, 'unbekannt', '?'),\n           (1, 'Zentrale', 'Z')");
                db_query("CREATE TABLE {cdb_status} (\n          id int(11) NOT NULL,\n          bezeichnung varchar(30) NOT NULL,\n          kuerzel varchar(10) NOT NULL,\n          mitglied_yn int(1) NOT NULL,\n          infreitextauswahl_yn int(1) NOT NULL DEFAULT '1',\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cdb_status} VALUES\n           (0, 'unbekannt', '?', 0, 1),\n           (1, 'Freund', 'F', 0, 1),\n           (2, 'Mitglied', 'M', 1, 1),\n           (3, 'zu löschen', 'X', 0, 0)");
                db_query("CREATE TABLE {cdb_tag} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          bezeichnung varchar(255) NOT NULL,\n          letzteaenderung datetime DEFAULT NULL,\n          aenderunguser varchar(60) DEFAULT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cr_booking} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          resource_id int(11) NOT NULL,\n          userid varchar(50) DEFAULT NULL,\n          startdate datetime NOT NULL,\n          enddate datetime NOT NULL,\n          repeat_id int(11) NOT NULL,\n          repeat_frequence int(11) NOT NULL,\n          repeat_until datetime NOT NULL,\n          status_id int(11) NOT NULL,\n          text varchar(30) NOT NULL,\n          location varchar(20) NOT NULL,\n          note tinytext NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cr_exception} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          booking_id int(11) NOT NULL,\n          except datetime NOT NULL,\n          userid varchar(20) NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cr_hours} (\n          id int(11) NOT NULL,\n          bezeichnung varchar(20) NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cr_hours} VALUES\n           (0, '00'),\n           (1, '01'),\n           (2, '02'),\n           (3, '03'),\n           (4, '04'),\n           (5, '05'),\n           (6, '06'),\n           (7, '07'),\n           (8, '08'),\n           (9, '09'),\n           (10, '10'),\n           (11, '11'),\n           (12, '12'),\n           (13, '13'),\n           (14, '14'),\n           (15, '15'),\n           (16, '16'),\n           (17, '17'),\n           (18, '18'),\n           (19, '19'),\n           (20, '20'),\n           (21, '21'),\n           (22, '22'),\n           (23, '23')");
                db_query("CREATE TABLE {cr_log} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          level int(11) NOT NULL,\n          datum datetime NOT NULL,\n          userid varchar(20) NOT NULL,\n          booking_id int(11) NOT NULL,\n          txt varchar(400) NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cr_minutes} (\n          id int(11) NOT NULL,\n          bezeichnung varchar(20) NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cr_minutes} VALUES\n           (0, '00'),\n           (15, '15'),\n           (30, '30'),\n           (45, '45')");
                db_query("CREATE TABLE {cr_resource} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          resourcetype_id int(11) NOT NULL,\n          sortkey int(11) NOT NULL,\n          bezeichnung varchar(20) NOT NULL,\n          location varchar(20) NOT NULL,\n          autoaccept_yn int(1) NOT NULL,\n          adminmails varchar(30) DEFAULT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM  DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cr_resource} VALUES\n           (1, 1, 0, 'Buero-Beamer', 'Buero von Max', 1, ''),\n           (2, 1, 0, 'Mobil-Beamer', 'Buero von Hans', 1, ''),\n           (3, 1, 0, 'Bus', '', 1, ''),\n           (5, 2, 0, 'Haupt-Cafe', '', 0, ''),\n           (4, 2, 0, 'Schokoraum', '', 1, '')");
                db_query("CREATE TABLE {cr_resourcetype} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          bezeichnung varchar(20) NOT NULL,\n          sortkey int(11) NOT NULL DEFAULT '0',\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM  DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cr_resourcetype} VALUES\n           (2, 'Raum', 1),\n           (1, 'Gegenstand', 0)");
                db_query("CREATE TABLE {cr_status} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          bezeichnung varchar(30) NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM  DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cr_status} VALUES\n           (1, 'Wartet auf Bestaetigung'),\n           (2, 'Bestaetigt'),\n           (3, 'Abgelehnt'),\n           (99, 'Geloescht')");
                db_query("CREATE TABLE {cs_category} (\n          id int(11) NOT NULL,\n          bezeichnung varchar(255) NOT NULL,\n          sortkey int(11) NOT NULL DEFAULT '0',\n          PRIMARY KEY (id)\n        ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cs_category} VALUES\n           (0, 'Sonstige Veranstaltung', 20),\n           (1, 'Sonntagsgodis', 10),\n           (2, 'Jugend', 30)");
                db_query("CREATE TABLE {cs_event} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          datum datetime NOT NULL,\n          bezeichnung varchar(255) NOT NULL,\n          special varchar(255) DEFAULT NULL,\n          admin varchar(255) DEFAULT NULL,\n          category_id int(11) NOT NULL DEFAULT '0',\n          PRIMARY KEY (id)\n        ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cs_eventservice} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          event_id int(11) NOT NULL,\n          service_id int(11) NOT NULL,\n          valid_yn int(1) NOT NULL DEFAULT '1',\n          zugesagt_yn int(11) NOT NULL DEFAULT '0',\n          name varchar(255) DEFAULT NULL,\n          cdb_person_id int(11) DEFAULT NULL,\n          reason varchar(255) DEFAULT NULL,\n          mailsenddate datetime DEFAULT NULL,\n          modifieddate datetime NOT NULL,\n          modifieduser varchar(255) NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cs_eventtemplate} (\n          id int(11) NOT NULL,\n          bezeichnung varchar(255) NOT NULL,\n          category_id int(11) DEFAULT NULL,\n          event_bezeichnung varchar(255) DEFAULT NULL,\n          special varchar(255) DEFAULT NULL,\n          stunde int(11) DEFAULT NULL,\n          minute int(11) DEFAULT NULL,\n          admin varchar(255) DEFAULT NULL,\n          sortkey int(11) NOT NULL DEFAULT '0',\n          PRIMARY KEY (id)\n        ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cs_eventtemplate} VALUES(0, 'Standard', 1, 'Standard', 'Weitere Infos...', 12, 0, '', 0)");
                db_query("CREATE TABLE {cs_eventtemplate_service} (\n          eventtemplate_id int(11) NOT NULL,\n          service_id int(11) NOT NULL\n        ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cs_service} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          bezeichnung varchar(50) NOT NULL,\n          standard_yn int(11) NOT NULL DEFAULT '0',\n          servicegroup_id int(11) NOT NULL,\n          cdb_gruppen_ids varchar(255) DEFAULT NULL,\n          cdb_tag_ids varchar(255) DEFAULT NULL,\n          sendremindermails_yn int(1) NOT NULL DEFAULT '0',\n          sortkey int(11) NOT NULL DEFAULT '0',\n          PRIMARY KEY (id)\n        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cs_service} VALUES\n           (1, 'Predigt', 1, 1, NULL, NULL, 0, 0),\n           (2, 'Lobpreis', 1, 1, NULL, NULL, 0, 0),\n           (3, 'Leitung', 1, 1, NULL, NULL, 0, 0),\n           (4, 'Hauptordner', 1, 2, NULL, NULL, 0, 1),\n           (5, 'Nebenordner', 0, 2, NULL, NULL, 0, 0),\n           (6, 'Ton', 1, 3, NULL, NULL, 0, 0),\n           (7, 'Licht', 0, 3, NULL, NULL, 0, 0),\n           (8, 'Video', 0, 3, NULL, NULL, 0, 0)");
                db_query("CREATE TABLE {cr_repeat} (\n          id int(11) NOT NULL\n        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8");
                db_query("CREATE TABLE {cs_servicegroup} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          bezeichnung varchar(255) NOT NULL,\n          sortkey int(11) NOT NULL DEFAULT '0',\n          PRIMARY KEY (id)\n        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8");
                db_query("INSERT INTO {cs_servicegroup} VALUES\n           (1, 'Programm', 10),\n           (2, 'Ordner', 20),\n           (3, 'Techniker', 30)");
            } else {
                addInfoMessage('Keine Datenbank-Tabellen gefunden. Soll ich sie nun anlegen?<p><a href="?installdb=true" class="btn">Tabellen jetzt anlegen</a>');
                return false;
            }
        case 'pre-2.0':
            db_query("create table {cc_config} (name varchar(255) not null, value varchar(255) not null) CHARSET=utf8");
            db_query("ALTER TABLE {cc_config} ADD PRIMARY KEY(name)");
            db_query("INSERT INTO {cc_config} VALUES\n         ('churchcal_name', 'ChurchCal'),\n         ('churchdb_birthdaylist_station', '1,2,3'),\n         ('churchdb_birthdaylist_status', '1,2,3'),\n         ('churchdb_emailseparator', ';'),\n         ('churchdb_groupnotchoosable', '90'),\n         ('churchdb_home_lat', '53.568537'),\n         ('churchdb_home_lng', '10.03656'),\n         ('churchdb_maxexporter', '250'),\n         ('churchdb_memberlist_station', '1,2,3'),\n         ('churchdb_memberlist_status', '1,2,3'),\n         ('churchdb_name', 'ChurchDB'),\n         ('churchdb_sendgroupmails', '1'),\n         ('churchresource_entries_last_days', '90'),\n         ('churchresource_name', 'ChurchResource'),\n         ('churchservice_entries_last_days', '90'),\n         ('churchservice_name', 'ChurchService'),\n         ('churchservice_openservice_rememberdays', '3'),\n         ('currently_mail_sending', '0'),\n         ('last_cron', '1377871248'),\n         ('last_db_dump', '1377868285'),\n         ('login_message', 'Willkommen auf dem neuen " . getConf("site_name") . " Zum Anmelden bitte die Felder ausfüllen!'),\n         ('mail_enabled', '1'),\n         ('site_mail', '*****@*****.**'),\n         ('site_name', '" . getConf("site_name") . "'),\n         ('version', '2.00'),\n         ('welcome', 'Herzlich willkommen'),\n         ('welcome_subtext', 'Das ist die Startseite von " . getConf("site_name") . "');");
            db_query("create table {cc_session} (person_id int(11) not null, session varchar(255) not null, hostname varchar(255) not null, datum datetime not null) CHARSET=utf8");
            db_query("CREATE TABLE {cc_auth} (id int(11) NOT NULL, auth varchar(80) NOT NULL, modulename varchar(80) NOT NULL, datenfeld varchar(255) DEFAULT NULL, bezeichnung varchar(255) NOT NULL,PRIMARY KEY (id)) CHARSET=utf8");
            db_query("insert into {cc_auth}  VALUES(1, 'administer settings', 'churchcore', NULL, 'Stammdaten pflegen, Logfile einsehen, Einstellung, ...')");
            db_query("insert into {cc_auth}  VALUES(2, 'administer persons', 'churchcore', NULL, 'Berechtigungen setzen, löschen und Benutzer simulieren')");
            db_query("insert into {cc_auth}  VALUES(3, 'view logfile', 'churchcore', NULL, 'Logfile einsehen')");
            db_query("insert into {cc_auth}  VALUES(101, 'view', 'churchdb', NULL, 'Anwendung ChurchDB sehen')");
            db_query("insert into {cc_auth}  VALUES(102, 'view alldata', 'churchdb', 'cdb_bereich', 'Alle Datensätze des jeweiligen Bereiches einsehen')");
            db_query("insert into {cc_auth}  VALUES(103, 'view birthdaylist', 'churchdb', NULL, 'Geburtagsliste einsehen')");
            db_query("insert into {cc_auth}  VALUES(104, 'view group statistics', 'churchdb', NULL, 'Gruppenstatistik einsehen')");
            db_query("insert into {cc_auth}  VALUES(105, 'view memberliste', 'churchdb', NULL, 'Mitgliederliste einsehen')");
            db_query("insert into {cc_auth}  VALUES(106, 'view statistics', 'churchdb', NULL, 'Gesamtstatistik einsehen')");
            db_query("insert into {cc_auth}  VALUES(107, 'view tags', 'churchdb', NULL, 'Tags einsehen')");
            db_query("insert into {cc_auth}  VALUES(108, 'view history', 'churchdb', NULL, 'Historie eines Datensatzes ansehen')");
            db_query("insert into {cc_auth}  VALUES(109, 'edit relations', 'churchdb', NULL, 'Beziehungen editieren')");
            db_query("insert into {cc_auth}  VALUES(110, 'edit groups', 'churchdb', NULL, 'Gruppenzuordnungen editieren')");
            db_query("insert into {cc_auth}  VALUES(111, 'write access', 'churchdb', NULL, 'Schreibzugriff auf bestimmen Bereich')");
            db_query("insert into {cc_auth}  VALUES(112, 'export data', 'churchdb', NULL, 'Daten exportieren')");
            db_query("insert into {cc_auth}  VALUES(113, 'view comments', 'churchdb', 'cdb_comment_viewer', 'Kommentare einsehen')");
            db_query("insert into {cc_auth}  VALUES(114, 'administer groups', 'churchdb', NULL, 'Gruppen erstellen, löschen, etc.')");
            db_query("insert into {cc_auth}  VALUES(199, 'edit masterdata', 'churchdb', NULL, 'Stammdaten editieren')");
            db_query("insert into {cc_auth}  VALUES(201, 'view', 'churchresource', NULL, 'Anwendung ChurchResource sehen')");
            db_query("insert into {cc_auth}  VALUES(202, 'administer bookings', 'churchresource', NULL, 'Anfragen editieren, ablehen, etc.')");
            db_query("insert into {cc_auth}  VALUES(299, 'edit masterdata', 'churchresource', NULL, 'Stammdaten editieren')");
            db_query("insert into {cc_auth}  VALUES(301, 'view', 'churchservice', NULL, 'Anwendung ChurchService sehen')");
            db_query("insert into {cc_auth}  VALUES(302, 'view history', 'churchservice', NULL, 'Historie anschauen')");
            db_query("insert into {cc_auth}  VALUES(303, 'edit events', 'churchservice', NULL, 'Events erstellen, löschen, etc.')");
            db_query("insert into {cc_auth}  VALUES(304, 'view servicegroup', 'churchservice', 'cs_servicegroup', 'Dienstanfragen der jeweiligen Gruppe einsehen')");
            db_query("insert into {cc_auth}  VALUES(305, 'edit servicegroup', 'churchservice', 'cs_servicegroup', 'Dienstanfragen der jeweiligen Gruppe editieren')");
            db_query("insert into {cc_auth}  VALUES(306, 'create bookings', 'churchresource', NULL, 'Erstelle eigene Anfragen')");
            db_query("insert into {cc_auth}  VALUES(399, 'edit masterdata', 'churchservice', NULL, 'Stammdaten editieren')");
            db_query("CREATE TABLE {cc_domain_auth} (domain_type varchar(30) NOT NULL, domain_id int(11) NOT NULL, auth_id int(11) NOT NULL,  daten_id int(11) DEFAULT NULL) CHARSET=utf8");
            addInfoMessage("Installiere Tabellen f&uuml;r Version 2.00");
            /* fall through to regular update */
        /* fall through to regular update */
        case '2.00':
            db_query("ALTER TABLE {cs_servicegroup} ADD viewall_yn int( 1 ) NOT NULL DEFAULT 0 AFTER bezeichnung");
            db_query("update {cs_servicegroup} set viewall_yn=1 where id=1");
            set_version("2.01");
        case '2.01':
            db_query("CREATE TABLE {cc_help} (doc_id varchar(255) NOT NULL,\n        text blob NOT NULL,\n        modifieddate datetime NOT NULL,\n        modifieduser int(11) NOT NULL,\n        PRIMARY KEY (doc_id)\n        ) ENGINE=InnoDB DEFAULT CHARSET=latin1;");
            db_query("update {cc_auth} set id=121 where id=103");
            db_query("update {cc_domain_auth} set auth_id=121 where auth_id=103");
            db_query("update {cc_auth} set id=122 where id=105");
            db_query("update {cc_domain_auth} set auth_id=122 where auth_id=105");
            db_query("INSERT INTO {cc_auth} (id, auth, modulename, datenfeld ,bezeichnung) VALUES (\n                103,  'view alldetails',  'churchdb', NULL ,  'Alle Informationen der Person sehen')");
            set_version("2.02");
        case '2.02':
            db_query("ALTER TABLE {cs_eventtemplate_service} ADD UNIQUE (eventtemplate_id , service_id)");
            set_version("2.03");
        case '2.03':
            db_query("CREATE TABLE {cc_file} (\n      id int(11) NOT NULL AUTO_INCREMENT,\n      domain_type varchar(30) NOT NULL,\n      domain_id int(11) NOT NULL,\n      filename varchar(255) NOT NULL,\n      UNIQUE KEY domain_type (domain_type,domain_id,filename),\n      PRIMARY KEY (id)) CHARSET=utf8");
            db_query("INSERT INTO {cc_auth} (id ,auth ,modulename ,datenfeld ,bezeichnung)\n         VALUES ('307',  'manage absent',  'churchservice', NULL ,  'Abwesenheiten einsehen und pflegen');");
            db_query("INSERT INTO {cc_auth} (id ,auth ,modulename ,datenfeld ,bezeichnung)\n         VALUES ('308',  'edit facts',  'churchservice', NULL ,  'Fakten pflegen');");
            db_query("CREATE TABLE {cs_absent_reason} (\n        id int(11) NOT NULL AUTO_INCREMENT,\n        bezeichnung varchar(255) NOT NULL,\n        sortkey int(11) NOT NULL,\n        PRIMARY KEY (id)\n      ) CHARSET=utf8");
            db_query("INSERT INTO {cs_absent_reason} VALUES(1, 'Abwesend', 2)");
            db_query("INSERT INTO {cs_absent_reason} VALUES(2, 'Urlaub', 1)");
            db_query("INSERT INTO {cs_absent_reason} VALUES(3, 'Krank', 0)");
            db_query("CREATE TABLE {cs_absent} (\n        id int(11) NOT NULL AUTO_INCREMENT,\n        person_id int(11) NOT NULL,\n        absent_reason_id int(11) NOT NULL,\n        bezeichnung varchar(255) DEFAULT NULL,\n        startdate datetime NOT NULL,\n        enddate datetime NOT NULL,\n        modifieddate datetime NOT NULL,\n        modifieduser int(11) NOT NULL,\n      PRIMARY KEY (id)\n      ) CHARSET=utf8");
            db_query("CREATE TABLE {cs_event_fact} (\n        event_id int(11) NOT NULL,\n        fact_id int(11) NOT NULL,\n        value int(11) NOT NULL,\n        modifieddate datetime DEFAULT NULL,\n        modifieduser int(11) DEFAULT NULL,\n        PRIMARY KEY (event_id,fact_id)\n      ) CHARSET=utf8");
            db_query("\n        CREATE TABLE {cs_fact} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          bezeichnung varchar(255) NOT NULL,\n          sortkey int(11) NOT NULL DEFAULT '0',\n          PRIMARY KEY (id)\n      ) CHARSET=utf8");
            db_query("INSERT INTO {cs_fact} VALUES(1, 'Besucher', 0)");
            db_query("INSERT INTO {cs_fact} VALUES(2, 'Kollekte', 0)");
            set_version("2.04");
        case '2.04':
            db_query("INSERT INTO {cc_auth} (id ,auth ,modulename ,datenfeld ,bezeichnung)\n         VALUES ('401',  'view',  'churchcal', NULL ,  'ChurchCal sehen');");
            db_query("INSERT INTO {cc_auth} (id ,auth ,modulename ,datenfeld ,bezeichnung)\n         VALUES ('402',  'edit events',  'churchcal', NULL ,  'Termine pflegen');");
            db_query("CREATE TABLE {cc_cal} (\n        id int(11) NOT NULL AUTO_INCREMENT,\n        bezeichnung varchar(255) NOT NULL,\n        startdate datetime NOT NULL,\n        enddate datetime NOT NULL,\n        repeat_id int(1) NOT NULL,\n        repeat_frequence int(2) NOT NULL,\n        repeat_until datetime NOT NULL,\n        modifieddate datetime NOT NULL,\n        modifieduser int(11) NOT NULL,\n        PRIMARY KEY (id)\n      ) CHARSET=utf8");
            set_version("2.05");
        case '2.05':
        case '2.06':
        case '2.07':
            db_query("ALTER TABLE {cc_cal} CHANGE repeat_frequence repeat_frequence INT( 2 ) NULL DEFAULT NULL");
            db_query("ALTER TABLE {cc_cal} CHANGE repeat_until repeat_until DATETIME NULL");
            db_query("CREATE TABLE {cc_cal_except} (\n        id int(11) NOT NULL AUTO_INCREMENT,\n        cal_id int(11) NOT NULL,\n        except_date datetime not null,\n        modifieddate datetime NOT NULL,\n        modifieduser int(11) NOT NULL,\n        PRIMARY KEY (id)) CHARSET=utf8");
            db_query("ALTER TABLE {cs_category} ADD color VARCHAR( 20 ) NULL AFTER bezeichnung");
            db_query("ALTER TABLE {cc_cal} ADD category_id INT( 11 ) NOT NULL DEFAULT '0' AFTER enddate");
            db_query("ALTER TABLE {cdb_status} ADD sortkey INT( 11 ) NOT NULL DEFAULT '0'");
            db_query("ALTER TABLE {cdb_bereich} ADD sortkey INT( 11 ) NOT NULL DEFAULT '0'");
            db_query("ALTER TABLE {cdb_gruppentyp} ADD sortkey INT( 11 ) NOT NULL DEFAULT '0'");
            db_query("ALTER TABLE {cdb_station} ADD sortkey INT( 11 ) NOT NULL DEFAULT '0'");
            db_query("ALTER TABLE {cs_eventservice} ADD counter INT( 11 ) NULL AFTER service_id");
            db_query("ALTER TABLE {cr_booking} CHANGE userid userid VARCHAR( 50 )");
            db_query("insert into {cc_config} (name, value) values ('cronjob_delay','0')");
            set_version("2.08");
        case '2.08':
            db_query("ALTER TABLE {cdb_person} ADD active_yn INT( 1 ) NOT NULL DEFAULT  '1' AFTER vorname");
            db_query("ALTER TABLE {cdb_person} ADD optigem_nr VARCHAR( 30 ) NOT NULL AFTER cmsuserid");
            db_query("ALTER TABLE {cc_cal} ADD ort VARCHAR( 255 ) NOT NULL DEFAULT '' AFTER bezeichnung");
            db_query("ALTER TABLE {cc_cal} ADD notizen VARCHAR( 255 ) NOT NULL DEFAULT '' AFTER ort");
            db_query("ALTER TABLE {cc_cal} ADD intern_yn int(1) not NULL default '0' AFTER notizen");
            set_version("2.09");
        case '2.09':
        case '2.10':
            db_query("ALTER TABLE {cs_category} ADD show_in_churchcal_yn INT(1) NOT NULL DEFAULT '1' AFTER color");
            db_query("ALTER TABLE {cr_booking} ADD show_in_churchcal_yn INT(1) NOT NULL DEFAULT '0'");
            set_version("2.11");
        case '2.11':
            db_query("INSERT INTO  {cc_auth} (id, auth, modulename, bezeichnung) values (105, 'view address', 'churchdb', 'Darf die Adressdaten einsehen')");
            db_query("UPDATE {cc_auth} set bezeichnung='Alle Informationen der Person sehen, inkl. Adressdaten, Gruppenzuordnung, etc.' where auth='view alldetails'");
            db_query("ALTER TABLE {cc_cal} CHANGE modifieddate modified_date DATETIME NOT NULL");
            db_query("ALTER TABLE {cc_cal} CHANGE modifieduser modified_pid int(11) not null");
            db_query("ALTER TABLE {cc_cal_except} CHANGE modifieddate modified_date DATETIME NOT NULL");
            db_query("ALTER TABLE {cc_cal_except} CHANGE modifieduser modified_pid int(11) not null");
            db_query("ALTER TABLE {cc_help} CHANGE modifieddate modified_date DATETIME NOT NULL");
            db_query("ALTER TABLE {cc_help} CHANGE modifieduser modified_pid int(11) not null");
            // change structure...
            db_query("ALTER TABLE {cdb_log} ADD person_id int(11) not null default -1 after userid");
            db_query("ALTER TABLE {cdb_comment} ADD person_id int(11) not null default -1 after userid");
            db_query("ALTER TABLE {cs_eventservice} CHANGE modifieddate modified_date DATETIME NOT NULL");
            db_query("ALTER TABLE {cs_eventservice} ADD modified_pid int(11) not null default -1 after modifieduser");
            db_query("ALTER TABLE {cs_event_fact} CHANGE modifieddate modified_date DATETIME NOT NULL");
            db_query("ALTER TABLE {cs_event_fact} CHANGE modifieduser modified_pid int(11) not null");
            db_query("ALTER TABLE {cs_absent} CHANGE modifieddate modified_date DATETIME NOT NULL");
            db_query("ALTER TABLE {cs_absent} CHANGE modifieduser modified_pid int(11) not null");
            // ...and update data to matchh
            db_query("UPDATE {cdb_log} log JOIN {cdb_person} p ON p.cmsuserid=log.userid SET log.person_id=p.id");
            db_query("UPDATE {cdb_comment} c JOIN {cdb_person} p ON p.cmsuserid=c.userid SET c.person_id=p.id");
            db_query("UPDATE {cs_eventservice} es JOIN {cdb_person} p ON p.cmsuserid=es.modifieduser SET es.modified_pid=p.id");
            set_version("2.12");
        case '2.12':
            db_query("ALTER TABLE {cr_booking} ADD person_id int(11) not null default -1 after userid");
            db_query("ALTER TABLE {cr_exception} ADD person_id int(11) not null default -1 after userid");
            db_query("ALTER TABLE {cr_log} ADD person_id int(11) not null default -1 after userid");
            db_query("ALTER TABLE {cr_resource} ADD admin_person_ids int(11) not null default -1 after adminmails");
            db_query("ALTER TABLE {cr_resource} CHANGE adminmails adminmails_old varchar(30) null");
            db_query("UPDATE {cr_booking} a JOIN {cdb_person} p ON p.cmsuserid=a.userid SET a.person_id=p.id");
            db_query("UPDATE {cr_exception} a JOIN {cdb_person} p ON p.cmsuserid=a.userid SET a.person_id=p.id");
            db_query("UPDATE {cr_log} a JOIN {cdb_person} p ON p.cmsuserid=a.userid SET a.person_id=p.id");
            db_query("UPDATE {cr_resource} a JOIN {cdb_person} p ON p.email=a.adminmails_old SET a.admin_person_ids=p.id");
            set_version("2.13");
        case '2.13':
            db_query("INSERT INTO  {cc_auth} (id, auth, modulename, bezeichnung) values (4, 'view whoisonline', 'churchcore', 'Sieht auf der Startseite, wer aktuell online ist')");
            db_query("CREATE TABLE {cc_loginstr}\n          (person_id int(11) NOT NULL, loginstr varchar(255) NOT NULL, create_date date NOT NULL) CHARSET=utf8");
            db_query("insert into {cc_loginstr} (person_id, loginstr, create_date)\n                   select id person_id, loginstr, now() from {cdb_person} where loginstr is not null");
            set_version("2.14");
        case '2.14':
            db_query("ALTER TABLE {cs_service} ADD allowtonotebyconfirmation_yn INT( 1 ) NOT NULL DEFAULT 0 AFTER sendremindermails_yn");
            set_version("2.15");
        case '2.15':
            db_query("INSERT INTO  {cc_auth} (id, auth, modulename, bezeichnung) values (311, 'view song', 'churchservice', 'Darf die Songs anschauen und Dateien herunterladen')");
            db_query("INSERT INTO  {cc_auth} (id, auth, modulename, bezeichnung) values (312, 'edit song', 'churchservice', 'Darf die Songs editieren und Dateien hochladen')");
            db_query("CREATE TABLE {cs_song} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          bezeichnung varchar(50) NOT NULL,\n          author varchar(255) NOT NULL,\n          ccli varchar(50) NOT NULL,\n          copyright varchar(255) NOT NULL,\n          note varchar(255) NOT NULL,\n          modified_date datetime NOT NULL,\n          modified_pid int(11) NOT NULL,\n        PRIMARY KEY (id)) CHARSET=utf8");
            db_query("CREATE TABLE {cs_song_arrangement} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          song_id int(11) NOT NULL,\n          bezeichnung varchar(50) NOT NULL,\n          default_yn int(1) NOT NULL,\n          tonality varchar(20) NOT NULL,\n          bpm varchar(10) NOT NULL,\n          beat varchar(10) NOT NULL,\n          length_min int(3) NOT NULL DEFAULT '0',\n          length_sec int(2) NOT NULL DEFAULT '0',\n          note varchar(255) NOT NULL,\n          modified_date datetime NOT NULL,\n          modified_pid int(11) NOT NULL,\n        PRIMARY KEY (id)) CHARSET=utf8\n      ");
            db_query("\n      CREATE TABLE {cs_servicegroup_person_weight} (\n        person_id int(11) NOT NULL,\n        servicegroup_id int(11) NOT NULL,\n        max_per_month int(1) NOT NULL DEFAULT '4',\n        relation_weight int(1) NOT NULL DEFAULT '0',\n        morning_weight int(1) NOT NULL DEFAULT '0',\n        modified_date datetime NOT NULL,\n        modified_pid int(11) NOT NULL,\n        PRIMARY KEY (person_id,servicegroup_id)) CHARSET=utf8");
            $files = churchcore_getTableData("cc_file");
            if ($files != null) {
                foreach ($files as $file) {
                    if (!file_exists("{$files_dir}/files/{$file->domain_type}")) {
                        mkdir("{$files_dir}/files/{$file->domain_type}", 0777, true);
                    }
                    if (file_exists("{$files_dir}/files/{$file->domain_id}")) {
                        rename("{$files_dir}/files/{$file->domain_id}", "{$files_dir}/files/{$file->domain_type}/{$file->domain_id}");
                    }
                }
            }
            set_version("2.16");
        case '2.16':
            db_query("insert into {cc_config} values ('max_uploadfile_size_kb', 10000)");
            db_query("insert into {cc_config} values ('cronjob_dbdump', 0)");
            db_query("CREATE TABLE {cs_songcategory} (\n        id INT( 11 ) NOT NULL,\n        bezeichnung VARCHAR( 100 ) NOT NULL ,\n        sortkey int(11) not null default 0,\n        PRIMARY KEY (  id )) CHARSET=utf8");
            db_query("insert into {cs_songcategory} values (0,'Unbekannt',0)");
            db_query("ALTER TABLE {cs_song} ADD songcategory_id INT( 11 ) NOT NULL AFTER bezeichnung");
            db_query("INSERT INTO  {cc_auth} (\n        id, auth , modulename , datenfeld ,bezeichnung )\n        VALUES (\n        '313',  'view songcategory',  'churchservice',  'cs_songcategory',  'Erlaubt den Zugriff auf bestimmte Song-Kategorien'\n        )");
            db_query("ALTER TABLE {cc_file} ADD modified_date DATETIME NOT NULL");
            db_query("ALTER TABLE {cc_file} ADD modified_pid INT( 11 ) NOT NULL");
            set_version("2.17");
        case '2.17':
            db_query("RENAME TABLE {cc_help} TO {cc_wiki}");
            db_query("CREATE TABLE {cc_wikicategory} (id INT( 11 ) NOT NULL, bezeichnung VARCHAR( 50 ) NOT NULL , sortkey INT( 11 ) NOT NULL)");
            db_query("ALTER TABLE {cc_wikicategory} ADD PRIMARY KEY ( id )");
            db_query("insert into {cc_wikicategory} values (0, 'Standard', 1)");
            db_query("ALTER TABLE {cc_wiki} ADD version_no INT( 11 ) NOT NULL default 1 AFTER doc_id");
            db_query("ALTER TABLE {cc_wiki} ADD wikicategory_id INT( 11 ) NOT NULL default 0 AFTER version_no");
            db_query("ALTER TABLE {cc_wiki} DROP PRIMARY KEY, ADD PRIMARY KEY (doc_id, version_no, wikicategory_id)");
            db_query("INSERT INTO  {cc_auth} (id, auth, modulename, bezeichnung) values (501, 'view', 'churchwiki', 'Darf das Wiki sehen')");
            db_query("INSERT INTO  {cc_auth} (id, auth, modulename, datenfeld, bezeichnung) values (502, 'view category', 'churchwiki', 'cc_wikicategory', 'Darf bestimmte Wiki-Kategorien einsehen')");
            db_query("INSERT INTO  {cc_auth} (id, auth, modulename, datenfeld, bezeichnung) values (503, 'edit category', 'churchwiki', 'cc_wikicategory', 'Darf bestimmte Wiki-Kategorien editieren')");
            db_query("INSERT INTO  {cc_auth} (id, auth, modulename, bezeichnung) values (599, 'edit masterdata', 'churchwiki', 'Darf die Stammdaten editieren')");
            db_query("insert into {cc_config} values ('churchwiki_name', 'ChurchWiki')");
            db_query("ALTER TABLE {cdb_gemeindeperson_gruppe} ADD comment VARCHAR( 255 ) null");
            db_query("CREATE TABLE {cdb_feldkategorie} (\n        id int(11) NOT NULL,\n        bezeichnung varchar(50) NOT NULL,\n        intern_code varchar(50) NOT NULL,\n        db_tabelle varchar(50) NOT NULL,\n        id_name varchar(50) NOT NULL,\n        PRIMARY KEY (id)\n        ) CHARSET=utf8");
            db_query("INSERT INTO {cdb_feldkategorie} VALUES (1, 'Adresse', 'f_address', 'cdb_person', 'id')");
            db_query("INSERT INTO {cdb_feldkategorie} VALUES (2, 'Informationen', 'f_church', 'cdb_gemeindeperson', 'person_id')");
            db_query("INSERT INTO {cdb_feldkategorie} VALUES (3, 'Kategorien', 'f_category', 'cdb_gemeindeperson', 'id')");
            db_query("INSERT INTO {cdb_feldkategorie} VALUES (4, 'Gruppe', 'f_group', 'cdb_gruppe', 'id')");
            db_query("CREATE TABLE {cdb_feldtyp} (\n      id int(11) NOT NULL,\n      bezeichnung varchar(30) NOT NULL,\n      intern_code varchar(10) NOT NULL,\n      PRIMARY KEY (id)\n    ) CHARSET=utf8");
            db_query("INSERT INTO {cdb_feldtyp} VALUES (1, 'Textfeld', 'text')");
            db_query("INSERT INTO {cdb_feldtyp} VALUES (2, 'Auswahlfeld', 'select')");
            db_query("INSERT INTO {cdb_feldtyp} VALUES (3, 'Datumsfeld', 'date');");
            db_query("INSERT INTO {cdb_feldtyp} VALUES (4, 'Ja-Nein-Feld', 'checkbox')");
            db_query("INSERT INTO {cdb_feldtyp} VALUES (5, 'Kommentarfeld', 'textarea')");
            db_query("CREATE TABLE {cdb_feld} (\n      id int(11) NOT NULL,\n      feldkategorie_id int(11) NOT NULL,\n      feldtyp_id int(11) NOT NULL,\n      db_spalte varchar(50) NOT NULL,\n      db_stammdatentabelle varchar(50) DEFAULT NULL,\n      aktiv_yn int(1) NOT NULL DEFAULT '1',\n      langtext varchar(200) NOT NULL,\n      kurztext varchar(50) NOT NULL,\n      zeilenende varchar(10) NOT NULL,\n      autorisierung varchar(50) DEFAULT NULL,\n      laenge int(3) DEFAULT NULL,\n      sortkey int(11) NOT NULL,\n      PRIMARY KEY (id)\n    ) CHARSET=utf8");
            db_query("INSERT INTO {cdb_feld} VALUES(1, 1, 1, 'titel', NULL, 1, 'Titel', '', '', NULL, 12, 1)");
            db_query("INSERT INTO {cdb_feld} VALUES(2, 1, 1, 'vorname', NULL, 1, 'Vorname', '', '&nbsp;', NULL, 30, 2)");
            db_query("INSERT INTO {cdb_feld} VALUES(3, 1, 1, 'name', NULL, 1, 'Name', '', '<br/>', NULL, 30, 3)");
            db_query("INSERT INTO {cdb_feld} VALUES(4, 1, 1, 'strasse', NULL, 1, 'Strasse', '', '<br/>', 'ViewAllDetailsOrPersonLeader', 30, 4)");
            db_query("INSERT INTO {cdb_feld} VALUES(5, 1, 1, 'zusatz', NULL, 1, 'Addresszusatz', '', '<br/>', 'ViewAllDetailsOrPersonLeader', 30, 5)");
            db_query("INSERT INTO {cdb_feld} VALUES(6, 1, 1, 'plz', NULL, 1, 'Postleitzahl', '', '&nbsp;', NULL, 6, 6)");
            db_query("INSERT INTO {cdb_feld} VALUES(7, 1, 1, 'ort', NULL, 1, 'Ort', '', '<br/>', NULL, 40, 7)");
            db_query("INSERT INTO {cdb_feld} VALUES(8, 1, 1, 'land', NULL, 1, 'Land', '', '<br/><br/>', NULL, 30, 8)");
            db_query("INSERT INTO {cdb_feld} VALUES(9, 1, 2, 'geschlecht_no', 'sex', 1, 'Geschlecht', 'Geschlecht', '<br/>', NULL, 11, 9)");
            db_query("INSERT INTO {cdb_feld} VALUES(10, 1, 1, 'telefonprivat', NULL, 1, 'Telefon privat', 'Tel. privat', '<br/>', NULL, 30, 10)");
            db_query("INSERT INTO {cdb_feld} VALUES(11, 1, 1, 'telefongeschaeftlich', NULL, 1, 'Telefon gesch&auml;ftl.', 'Tel. gesch&auml;ft.', '<br/>', NULL, 20, 11)");
            db_query("INSERT INTO {cdb_feld} VALUES(12, 1, 1, 'telefonhandy', NULL, 1, 'Mobil', 'Mobil', '<br/>', NULL, 20, 12)");
            db_query("INSERT INTO {cdb_feld} VALUES(13, 1, 1, 'fax', NULL, 1, 'Fax', 'Fax', '<br/>', NULL, 20, 13)");
            db_query("INSERT INTO {cdb_feld} VALUES(14, 1, 1, 'email', NULL, 1, 'E-Mail', 'E-Mail', '<br/>', NULL, 50, 14)");
            db_query("INSERT INTO {cdb_feld} VALUES(15, 1, 1, 'cmsuserid', NULL, 1, 'Benutzername', 'Benutzername', '<br/>', NULL, 50, 15)");
            db_query("INSERT INTO {cdb_feld} VALUES(16, 2, 3, 'geburtsdatum', NULL, 1, 'Geburtsdatum', 'Geburtsdatum', '<br/>', NULL, 0, 1)");
            db_query("INSERT INTO {cdb_feld} VALUES(17, 2, 1, 'geburtsname', NULL, 1, 'Geburtsname', 'Geburtsname', '<br/>', NULL, 30, 2)");
            db_query("INSERT INTO {cdb_feld} VALUES(18, 2, 1, 'geburtsort', NULL, 1, 'Geburtsort', 'Geburtsort', '<br/>', NULL, 30, 3)");
            db_query("INSERT INTO {cdb_feld} VALUES(19, 2, 1, 'beruf', NULL, 1, 'Beruf', 'Beruf', '<br/>', NULL, 50, 4)");
            db_query("INSERT INTO {cdb_feld} VALUES(20, 2, 1, 'nationalitaet_id', 'nationalitaet', 2, 'Nationalit&auml;t', 'Nationalit&auml;t', '<br/>', NULL, 11, 5)");
            db_query("INSERT INTO {cdb_feld} VALUES(21, 2, 2, 'familienstand_no', 'familyStatus', 1, 'Familenstand', 'Familenstand', '<br/>', NULL, 11, 6)");
            db_query("INSERT INTO {cdb_feld} VALUES(22, 2, 3, 'hochzeitsdatum', NULL, 1, 'Hochzeitstag', 'Hochzeitstag', '<br/><br/>', NULL, 0, 7)");
            db_query("INSERT INTO {cdb_feld} VALUES(23, 2, 3, 'erstkontakt', NULL, 1, 'Erstkontakt', 'Erstkontakt', '<br/>', NULL, 0, 8)");
            db_query("INSERT INTO {cdb_feld} VALUES(24, 2, 3, 'zugehoerig', NULL, 1, 'Zugeh&ouml;rig', 'Zugeh&ouml;rig', '<br/>', NULL, 0, 9)");
            db_query("INSERT INTO {cdb_feld} VALUES(25, 2, 3, 'eintrittsdatum', NULL, 1, 'Mitglied seit', 'Mitglied seit', '<br/>', NULL, 0, 10)");
            db_query("INSERT INTO {cdb_feld} VALUES(26, 2, 1, 'ueberweisen von', NULL, 1, '&Uuml;berwiesen von', '&Uuml;berwiesen von', '<br/>', NULL, 30, 11)");
            db_query("INSERT INTO {cdb_feld} VALUES(27, 2, 3, 'austrittsdatum', NULL, 1, 'Mitglied bis', 'Mitglied bis', '<br/>', NULL, 0, 12)");
            db_query("INSERT INTO {cdb_feld} VALUES(28, 2, 1, 'ueberwiesen nach', NULL, 1, '&Uuml;berwiesen nach', '&Uuml;berwiesen nach', '<br/><br/>', NULL, 30, 13)");
            db_query("INSERT INTO {cdb_feld} VALUES(29, 2, 3, 'taufdatum', NULL, 1, 'Taufdatum', 'Taufdatum', '<br/>', NULL, 0, 14)");
            db_query("INSERT INTO {cdb_feld} VALUES(30, 2, 1, 'taufort', NULL, 1, 'Taufort', '', '<br/>', NULL, 50, 15)");
            db_query("INSERT INTO {cdb_feld} VALUES(31, 2, 1, 'getauftdurch', NULL, 1, 'Getauft durch', 'Getauft durch', '<br/>', NULL, 50, 16)");
            db_query("INSERT INTO {cdb_feld} VALUES(32, 3, 2, 'status_id', 'status', 1, 'Status', 'Status', '<br/>', NULL, 11, 1)");
            db_query("INSERT INTO {cdb_feld} VALUES(33, 3, 2, 'station_id', 'station', 1, 'Station', 'Station', '<br/>', NULL, 11, 2)");
            db_query("INSERT INTO {cdb_feld} VALUES(34, 4, 1, 'bezeichnung', NULL, 1, 'Bezeichnung', 'Bezeichnung', '<br/>', NULL, 35, 1)");
            db_query("INSERT INTO {cdb_feld} VALUES(35, 4, 2, 'distrikt_id', 'districts', 1, 'Distrikt', 'Distrikt', '<br/>', 'admingroups', 11, 2)");
            db_query("INSERT INTO {cdb_feld} VALUES(36, 4, 2, 'followup_typ_id', 'followupTypes', 1, 'Followup-Typ', 'Followup-Typ', '<br/>', 'admingroups', 11, 3)");
            db_query("INSERT INTO {cdb_feld} VALUES(37, 4, 2, 'fu_nachfolge_typ_id', 'FUNachfolgeDomains', 1, 'Followup-Nachfolger', 'Followup-Nachfolger', '<br/>', 'admingroups', 11, 4)");
            db_query("INSERT INTO {cdb_feld} VALUES(38, 4, 2, 'fu_nachfolge_objekt_id', 'code:selectNachfolgeObjektId', 1, 'Followup-Nachfolger-Auswahl', 'Followup-Nachfolger-Auswahl', '<br/>', 'admingroups', 11, 5)");
            db_query("INSERT INTO {cdb_feld} VALUES(39, 4, 3, 'gruendungsdatum', NULL, 1, 'Gr&uuml;ndungsdatum', 'Gr&uuml;ndungsdatum', '<br/>', NULL, 0, 6)");
            db_query("INSERT INTO {cdb_feld} VALUES(40, 4, 3, 'abschlussdatum', NULL, 1, 'Abschlussdatum', 'Abschlussdatum', '<br/>', NULL, 0, 7)");
            db_query("INSERT INTO {cdb_feld} VALUES(41, 4, 1, 'treffzeit', NULL, 1, 'Zeit des Treffens', 'Treffzeit', '<br/>', NULL, 30, 8)");
            db_query("INSERT INTO {cdb_feld} VALUES(42, 4, 1, 'treffpunkt', NULL, 1, 'Ort des Treffens', 'Treffort', '<br/>', NULL, 50, 9)");
            db_query("INSERT INTO {cdb_feld} VALUES(43, 4, 1, 'treffname', NULL, 1, 'Treffen bei', 'Treffen bei', '<br/>', NULL, 30, 10)");
            db_query("INSERT INTO {cdb_feld} VALUES(44, 4, 1, 'zielgruppe', NULL, 1, 'Zielgruppe', 'Zielgruppe', '<br/>', NULL, 30, 11)");
            db_query("INSERT INTO {cdb_feld} VALUES(45, 4, 5, 'notiz', NULL, 1, 'Notiz', 'Notiz', '<br/>', NULL, 200, 12)");
            db_query("INSERT INTO {cdb_feld} VALUES(46, 4, 4, 'valid_yn', NULL, 1, '<p>Gruppe ausw&auml;hlbar<br/><small>Bei Verneinung kann die Gruppe nicht mehr zugeordnet und gefiltert werden</small>', 'Ausw&auml;hlbar', '<br/>', 'admingroups', 1, 13)");
            db_query("INSERT INTO {cdb_feld} VALUES(47, 4, 4, 'versteckt_yn', NULL, 1, '<p>Versteckte Gruppe<br/><small>Gruppe ist nur f&uuml;r Gruppenadmins & Leiter sichbar</small>', 'Versteckt', '<br/>', 'admingroups', 1, 14)");
            db_query("INSERT INTO {cdb_feld} VALUES(48, 4, 4, 'instatistik_yn', NULL, 1, '<p>Zeige in Statistik<br/><small>In der Statistik explizit aufgef&uuml;hrt</small>', 'In Statistik', '<br/>', 'admingroups', 1, 15)");
            db_query("INSERT INTO {cdb_feld} VALUES(49, 4, 4, 'treffen_yn', NULL, 1, '<p>W&ouml;chentliche Teilnahme pflegen<br/><small>Erm&ouml;glicht die Pflege der Teilnahme an dieser Gruppe</small>', 'Teilnahme', '<br/>', 'admingroups', 1, 16)");
            db_query("INSERT INTO {cdb_feld} VALUES(50, 1, 1, 'optigem_nr', NULL, 1, 'Optigem-Nr', 'Optigem-Nr.', '<br/>', 'admin', NULL, 16)");
            db_query("CREATE TABLE {cdb_nationalitaet} (\n      id int(11) NOT NULL,\n      bezeichnung varchar(50) not null,\n      PRIMARY KEY (id)\n    )");
            db_query("INSERT INTO {cdb_nationalitaet} VALUES(0, 'unbekannt')");
            // Add existing nationality values to new table
            db_query("ALTER TABLE {cdb_nationalitaet} CHANGE  id id INT( 11 ) NOT NULL AUTO_INCREMENT");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung)\n               SELECT nationalitaet\n               FROM {cdb_gemeindeperson} gp LEFT JOIN {cdb_nationalitaet} n ON (gp.nationalitaet=n.bezeichnung)\n               WHERE n.bezeichnung IS NULL AND gp.nationalitaet!=''\n               GROUP BY nationalitaet");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('&Auml;gypten')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('&Auml;quatorialguinea')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('&Auml;thiopien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Afghanistan')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Albanien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Algerien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Andorra')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Angola')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Antigua und Barbuda')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Argentinien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Armenien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Aserbaidschan')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Australien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Bahamas')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Bahrain')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Bangladesch')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Barbados')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Belgien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Belize')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Benin')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Bhutan')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Bolivien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Bosnien und Herzegowina')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Botsuana')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Brasilien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Brunei')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Bulgarien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Burkina Faso')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Burundi')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Chile')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('China')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Costa Rica')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('D&auml;nemark')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Deutschland')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Dominica')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Dominikanische Republik')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Dschibuti')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Ecuador')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('El Salvador')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Elfenbeink&uuml;ste')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Eritrea')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Estland')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Fidschi')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Finnland')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Frankreich')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Gabun')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Gambia')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Georgien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Ghana')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Grenada')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Griechenland')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Gro&szlig;britannien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Guatemala')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Guinea')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Guinea-Bissau')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Guyana')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Haiti')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Honduras')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Indien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Indonesien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Irak')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Iran')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Irland')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Island')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Israel')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Italien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Jamaika')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Japan')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Jemen')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Jordanien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Kambodscha')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Kamerun')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Kanada')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Kap Verde')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Kasachstan')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Katar')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Kenia')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Kirgistan')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Kiribati')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Kolumbien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Komoren')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Kongo, Republik')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Kongo, Demokratische Republik')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Kroatien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Kuba')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Kuwait')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Laos')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Lesotho')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Lettland')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Libanon')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Liberia')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Libyen')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Liechtenstein')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Litauen')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Luxemburg')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Madagaskar')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Malawi')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Malaysia')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Malediven')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Mali')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Malta')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Marokko')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Marshallinseln')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Mauretanien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Mauritius')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Mazedonien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Mexiko')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Mikronesien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Moldawien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Monaco')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Mongolei')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Montenegro')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Mosambik')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Myanmar')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Namibia')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Nauru')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Nepal')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Neuseeland')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Nicaragua')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Niederlande')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Niger')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Nigeria')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Niue')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Nordkorea')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Norwegen')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('&Ouml;sterreich')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Oman')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Pakistan')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Palau')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Pal&auml;stinensische Gebiete')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Panama')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Papua-Neuguinea')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Paraguay')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Peru')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Philippinen')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Polen')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Portugal')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Ruanda')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Rum&auml;nien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Russland')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Sahara')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Salomonen')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Sambia')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Samoa')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('San Marino')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('S&atilde;o Tom&eacute; und Pr&iacute;ncipe')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Saudi-Arabien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Schweden')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Schweiz')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Senegal')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Serbien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Seychellen')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Sierra Leone')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Simbabwe')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Singapur')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Slowakei')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Slowenien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Somalia')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Spanien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Sri Lanka')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('St. Kitts und Nevis')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('St. Lucia')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('St. Vincent und die Grenadinen')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Sudan')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('S&uuml;dafrika')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('S&uuml;dkorea')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Suriname')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Swasiland')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Syrien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Tadschikistan')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Taiwan')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Tansania')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Thailand')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Timor-Leste')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Togo')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Tonga')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Trinidad und Tobago')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Tschad')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Tschechien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Tunesien')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Turkmenistan')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Turks- und Caicosinseln')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Tuvalu')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('T&uuml;rkei')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Uganda')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Ukraine')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Ungarn')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Uruguay')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('USA')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Usbekistan')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Vanuatu')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Vatikanstadt')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Venezuela')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Vereinigte Arabische Emirate')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Vietnam')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Wei&szlig;russland')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Zentralafrikanische Republik')");
            db_query("INSERT INTO {cdb_nationalitaet} (bezeichnung) VALUES('Zypern')");
            db_query("ALTER TABLE {cdb_gemeindeperson} ADD nationalitaet_id INT( 11 ) NOT NULL AFTER nationalitaet");
            // Mappe nun die schon gesetzen
            db_query("update {cdb_gemeindeperson} gp join {cdb_nationalitaet} n on gp.nationalitaet=n.bezeichnung set gp.nationalitaet_id=n.id");
            db_query("insert into {cc_config} values ('show_remember_me', '1')");
            db_query("ALTER TABLE {cdb_gruppe} ADD max_teilnehmer INT( 11 ) NULL AFTER zielgruppe");
            db_query("ALTER TABLE {cdb_gruppe} ADD oeffentlich_yn INT( 1 ) NOT NULL DEFAULT 0 AFTER notiz");
            db_query("ALTER TABLE {cdb_gruppe} ADD offen_yn INT( 1 ) NOT NULL DEFAULT 0 AFTER notiz");
            db_query("insert into {cdb_feldtyp} (id, bezeichnung, intern_code) VALUES (6,  'Nummernfeld',  'number')");
            db_query("INSERT INTO {cdb_feld} VALUES (51, 4, 6, 'max_teilnehmer', NULL, 1, 'Maximale Teilnehmer', 'Max. Teilnehmer', '<br/>', null, 11, 10)");
            db_query("INSERT INTO {cdb_feld} VALUES (52, 4, 4, 'oeffentlich_yn', NULL, 1, '<p>&Ouml;ffentliche Gruppe<br/><small>Die Info-Daten der Gruppe kann ohne Autorisierung eingesehen werden', '&Ouml;ffentlich', '<br/>', 'admingroups', 1, 17)");
            db_query("INSERT INTO {cdb_feld} VALUES (53, 4, 4, 'offen_yn', NULL, 1, '<p>Offene Gruppe<br/><small>Man kann eine Teilnehmeranfrage an diese Gruppe stellen', '&Offen', '<br/>', 'admingroups', 1, 18)");
            db_query("ALTER TABLE {cdb_feld} CHANGE id id INT( 11 ) NOT NULL AUTO_INCREMENT");
            db_query("CREATE TABLE {cdb_gruppenteilnehmer_email} (\n      id int(11) NOT NULL AUTO_INCREMENT,\n      gruppe_id int(11) NOT NULL,\n      status_no int(11) NOT NULL,\n      aktiv_yn int(1) NOT NULL,\n      sender_pid int(11) NOT NULL,\n      email_betreff varchar(255) NOT NULL,\n      email_inhalt blob NOT NULL,\n      PRIMARY KEY (id),\n      UNIQUE KEY gruppe_id (gruppe_id,status_no)) CHARSET=utf8");
            db_query("ALTER TABLE  {cr_resource} CHANGE admin_person_ids admin_person_ids VARCHAR( 50 ) NOT NULL DEFAULT  '-1'");
            set_version("2.18");
        case '2.18':
        case '2.19':
        case '2.20':
            db_query("update {cdb_feld} set feldtyp_id=2, aktiv_yn=1 where db_spalte='nationalitaet_id'");
            db_query("ALTER TABLE {cc_wikicategory} CONVERT TO CHARACTER SET utf8");
            db_query("ALTER TABLE {cc_wiki} CONVERT TO CHARACTER SET utf8");
            db_query("ALTER TABLE {cdb_nationalitaet} CONVERT TO CHARACTER SET utf8");
            db_query("update {cdb_nationalitaet} set bezeichnung='&Auml;gypten' where bezeichnung='?gypten'");
            db_query("update {cdb_nationalitaet} set bezeichnung='&Auml;quatorialguinea' where bezeichnung='?quatorialguinea'");
            db_query("update {cdb_nationalitaet} set bezeichnung='&Auml;thiopien' where bezeichnung='?thiopien'");
            db_query("update {cdb_nationalitaet} set bezeichnung='&Ouml;sterreich' where bezeichnung='?sterreich'");
            db_query("update {cdb_nationalitaet} set bezeichnung='T&uuml;rkei' where bezeichnung='T?rkei'");
            db_query("update {cdb_nationalitaet} set bezeichnung='S&uuml;dafrika' where bezeichnung='S?dafrika'");
            db_query("update {cdb_nationalitaet} set bezeichnung='S&uuml;dkorea' where bezeichnung='S?dkorea'");
            db_query("update {cdb_nationalitaet} set bezeichnung='D&auml;nemark' where bezeichnung='D?nemark'");
            // Fix error von 220
            db_query("ALTER TABLE {cdb_nationalitaet} CHANGE  id id INT( 11 ) NOT NULL");
            db_query("ALTER TABLE {cdb_gemeindeperson} CHANGE nationalitaet_id  nationalitaet_id INT( 11 ) NOT NULL DEFAULT '0'");
            // Suche nun nach unbekannt mit id 1, und setze es auf 0
            $res = db_query("select count(*) c from {cdb_nationalitaet} where id=1 and upper(bezeichnung) like 'UNBEKANNT'")->fetch();
            if ($res->c > 0) {
                db_query("update {cdb_nationalitaet} set id=0 where id=1 and upper(bezeichnung) like 'UNBEKANNT'");
                db_query("update {cdb_gemeindeperson} set nationalitaet_id=0 where nationalitaet_id=1");
            }
            $res = db_query("select count(*) c from {cdb_nationalitaet} where id=0 and upper(bezeichnung) like 'UNBEKANNT'")->fetch();
            if ($res->c == 0) {
                db_query("INSERT INTO  {cdb_nationalitaet} (id, bezeichnung) VALUES ('0', 'unbekannt')");
            }
            db_query("ALTER TABLE {cdb_nationalitaet} ADD UNIQUE (bezeichnung)");
            set_version("2.21");
        case '2.21':
        case '2.22':
            db_query("ALTER TABLE {cc_session} CHANGE session session VARCHAR( 100 ) NOT NULL");
            db_query("ALTER TABLE {cc_session} CHANGE hostname hostname VARCHAR( 100 ) NOT NULL");
            db_query("ALTER TABLE {cc_session} ADD PRIMARY KEY (person_id , session , hostname)");
            db_query("CREATE TABLE {cdb_gruppenteilnehmerstatus} (\n      id int(11) NOT NULL,\n      intern_code int(1) NOT NULL,\n      bezeichnung varchar(50) NOT NULL,\n      kuerzel varchar(10) NOT NULL,\n      PRIMARY KEY (id),\n        UNIQUE KEY intern_code (intern_code)) DEFAULT CHARSET=utf8");
            db_query("INSERT INTO {cdb_gruppenteilnehmerstatus} VALUES(1, 0, 'Teilnehmer', '')");
            db_query("INSERT INTO {cdb_gruppenteilnehmerstatus} VALUES(2, 1, 'Leiter', 'L')");
            db_query("INSERT INTO {cdb_gruppenteilnehmerstatus} VALUES(3, 2, 'Co-Leiter', 'CoL')");
            db_query("INSERT INTO {cdb_gruppenteilnehmerstatus} VALUES(4, 3, 'Supervisor', 'S')");
            db_query("INSERT INTO {cdb_gruppenteilnehmerstatus} VALUES(5, 4, 'Mitarbeiter', 'M')");
            db_query("INSERT INTO {cdb_gruppenteilnehmerstatus} VALUES(6, -2, 'Teilnahme beantragt', '')");
            db_query("INSERT INTO {cdb_gruppenteilnehmerstatus} VALUES(7, -1, 'zu l&ouml;schen', '');");
            set_version("2.23");
        case '2.23':
            db_query("insert into {cc_config} (name, value) values ('site_offline','0')");
            db_query("update {cdb_feld} set db_spalte='ueberwiesenvon' where db_spalte='ueberweisen von'");
            db_query("update {cdb_feld} set db_spalte='ueberwiesennach' where db_spalte='ueberwiesen nach'");
            db_query("CREATE TABLE {cdb_person_gruppentyp} (\n        person_id int(11) NOT NULL,\n        gruppentyp_id int(11) NOT NULL,\n        modified_date datetime NOT NULL,\n        modified_pid int(11) NOT NULL,\n        PRIMARY KEY (person_id,gruppentyp_id)) DEFAULT CHARSET=utf8;");
            db_query("CREATE TABLE {cdb_person_distrikt} (\n        person_id int(11) NOT NULL,\n        distrikt_id int(11) NOT NULL,\n        modified_date datetime NOT NULL,\n        modified_pid int(11) NOT NULL,\n        PRIMARY KEY (person_id,distrikt_id)) DEFAULT CHARSET=utf8;");
            set_version("2.24");
        case '2.24':
            db_query("ALTER TABLE {cc_file} CHANGE domain_id domain_id VARCHAR( 30 ) NOT NULL");
            db_query("ALTER TABLE {cc_file} ADD bezeichnung VARCHAR( 50 ) NOT NULL AFTER domain_id");
            db_query("update {cc_file} set bezeichnung=filename");
            db_query("ALTER TABLE {cdb_gemeindeperson} CHANGE imageurl imageurl VARCHAR( 50 )");
            set_version("2.25");
        case '2.25':
            db_query("ALTER TABLE {cdb_gruppe} ADD fu_nachfolge_gruppenteilnehmerstatus_id INT( 11 ) NULL AFTER fu_nachfolge_objekt_id");
            db_query("ALTER TABLE {cdb_gemeindeperson_gruppe} ADD  followup_erfolglos_zurueck_gruppen_id INT( 11 ) NULL AFTER followup_add_diff_days");
            db_query("UPDATE {cdb_feld} set sortkey=2 where db_spalte='max_teilnehmer' and feldkategorie_id=4");
            db_query("INSERT INTO {cdb_feld} VALUES(-1, 4, 2, 'fu_nachfolge_gruppenteilnehmerstatus_id', 'groupMemberTypes', 1, 'Followup-Nachfolger-Teilnehmerstatus', 'Followup-Nachfolger-Teilnehmerstatus', '<br/>', 'admingroups', 11, 5)");
            db_query("update {cdb_feld} set langtext='<p>Versteckte Gruppe<br/><small>Gruppe ist nur f&uuml;r Gruppenadmins & Leiter sichtbar</small>'\n                  where langtext='<p>Versteckte Gruppe<br/><small>Gruppe ist nur f&uuml;r Gruppenadmins & Leiter sichbar</small>'");
            set_version("2.26");
        case '2.26':
            db_query("CREATE TABLE {cc_cal_add} (\n        id int(11) NOT NULL AUTO_INCREMENT,\n        cal_id int(11) NOT NULL,\n        add_date datetime NOT NULL,\n        modified_date datetime NOT NULL,\n        modified_pid int(11) NOT NULL,\n        PRIMARY KEY (id)\n      ) DEFAULT CHARSET=utf8");
            db_query("ALTER TABLE {cc_cal_except} CHANGE except_date except_date_start DATETIME NOT NULL");
            db_query("ALTER TABLE  {cc_cal_except} ADD except_date_end DATETIME NOT NULL AFTER except_date_start");
            db_query("update {cc_cal_except} set except_date_end=except_date_start");
            db_query("ALTER TABLE {cc_cal} ADD repeat_option_id INT( 11 ) NULL AFTER repeat_until");
            db_query("CREATE TABLE {cr_addition} (\n        id int(11) NOT NULL AUTO_INCREMENT,\n        booking_id int(11) NOT NULL,\n        add_date datetime NOT NULL,\n        modified_date datetime NOT NULL,\n        modified_pid int(11) NOT NULL,\n        PRIMARY KEY (id)\n      ) DEFAULT CHARSET=utf8");
            db_query("ALTER TABLE {cr_exception} CHANGE except except_date_start DATETIME NOT NULL");
            db_query("ALTER TABLE  {cr_exception} ADD except_date_end DATETIME NOT NULL AFTER except_date_start");
            db_query("ALTER TABLE  {cr_exception} ADD modified_date DATETIME NOT NULL AFTER userid");
            db_query("ALTER TABLE {cr_exception} CHANGE person_id  modified_pid INT( 11 ) NOT NULL DEFAULT '-1'");
            db_query("update {cr_exception} set except_date_end=except_date_start");
            db_query("ALTER TABLE {cr_booking} ADD repeat_option_id INT( 11 ) NULL AFTER repeat_until");
            db_query("CREATE TABLE {cc_repeat} (\n      id int(11) NOT NULL, bezeichnung varchar(30) NOT NULL, sortkey int(11) NOT NULL, PRIMARY KEY (id)\n      ) DEFAULT CHARSET=utf8");
            db_query("INSERT INTO {cc_repeat} VALUES(0, 'Keine Wiederholung', 0)");
            db_query("INSERT INTO {cc_repeat} VALUES(1, 'T&auml;glich', 1)");
            db_query("INSERT INTO {cc_repeat} VALUES(7, 'W&ouml;chentlich', 2)");
            db_query("INSERT INTO {cc_repeat} VALUES(31, 'Monatlich nach Datum', 3)");
            db_query("INSERT INTO {cc_repeat} VALUES(32, 'Monatlich nach Wochentag', 4)");
            db_query("INSERT INTO {cc_repeat} VALUES(365, 'J&auml;hrlich', 5)");
            db_query("INSERT INTO {cc_repeat} VALUES(999, 'Manuell', 6)");
            db_query("DROP TABLE  {cr_repeat}");
            db_query("ALTER TABLE {cs_eventservice} ADD INDEX ( event_id )");
            db_query("ALTER TABLE {cc_wiki} CHANGE text text MEDIUMBLOB NOT NULL");
            set_version("2.27");
        case '2.27':
            db_query("ALTER TABLE {cc_wiki} ADD auf_startseite_yn INT( 1 ) NOT NULL DEFAULT '0' AFTER text");
            db_query("ALTER TABLE {cc_cal_add} ADD with_repeat_yn INT( 1 ) NOT NULL DEFAULT '1' AFTER add_date");
            db_query("ALTER TABLE {cr_addition} ADD with_repeat_yn INT( 1 ) NOT NULL DEFAULT '1' AFTER add_date");
            db_query("ALTER TABLE {cdb_person} ADD spitzname VARCHAR( 30 ) NOT NULL AFTER vorname");
            db_query("update {cdb_feld} set sortkey=sortkey+1 where feldkategorie_id=1 and sortkey>=3");
            db_query("INSERT INTO {cdb_feld} VALUES(0, 1, 1, 'spitzname', NULL, 1, 'Spitzname', '', '(%) ', NULL, 30, 3)");
            db_query("ALTER TABLE {cdb_beziehungstyp} ADD sortkey INT( 11 ) NOT NULL");
            db_query("ALTER TABLE {cdb_person} ADD loginerrorcount INT( 11 ) NOT NULL AFTER lastlogin");
            //TODO: add path CONSTANT?
            db_query("INSERT INTO {cc_wiki} VALUES ('main',1,0,'<h2>​<strong>Was ist das Wiki?</strong></h2>\n\n<p><span style=\\\"font-size:14px\\\">D</span><img alt=\\\"\\\" src=\\\"http://intern.churchtools.de/system/assets/img/wiki_logo.png\\\" style=\\\"float:right; height:270px; width:300px\\\" /><span style=\\\"font-size:14px\\\">as Wiki soll als Dokumentation, Informations- und Arbeitsgrundlage f&uuml;r die verschiedenen Dienstbereiche der Gemeinde dienen. Jeder Mitarbeiter eines Dienstbereiches kann auf Wunsch Zugriff auf die entsprechenden Wiki-Kategorien erhalten. Diese Seiten k&ouml;nnen dann&nbsp;von allen aus demselben Dienstbereich gelesen und bearbeitet werden. So k&ouml;nnen aktuelle Information, Abl&auml;ufe, Einstellungen, etc. zeitnah gespeichert werden und sind sofort f&uuml;r alle einsehbar. Damit ist jeder zu jederzeit auf dem neusten Wissenstand.</span></p>\n\n<div><span style=\\\"font-size:14px\\\">Durch das Wiki haben neue Mitarbeiter alle n&ouml;tigen Informationen, Anleitungen und Hintergrundinformationen f&uuml;r ihren Dienst. Erfahrene Mitarbeiter k&ouml;nnen ihr Wissen und gesammelte Informationen dokumentieren und auf sie zur&uuml;ckgreifen.</span></div>\n\n<h2>Weitere Infos</h2>\n\n<div><span style=\\\"font-size:14px\\\">Mehr Infos zum Wiki gibt es <a href=\\\"http://intern.churchtools.de/?q=churchwiki#WikiView/filterWikicategory_id:0/doc:ChurchWiki/\\\" target=\\\"_blank\\\">hier</a>.</span></div>\n',0,'2013-08-30 15:59:42',1)");
            db_query("INSERT INTO {cc_wiki} VALUES ('Sicherheitsbestimmungen',1,0,'<p><strong>Verpflichtung auf das Datengeheimnis gem&auml;&szlig; &sect; 5 Bundesdatenschutzgesetz (BDSG), auf das Fernmeldegeheimnis gem&auml;&szlig; &sect; 88 Telekommunikationsgesetz (TKG) und auf Wahrung von Gesch&auml;ftsgeheimnissen</strong><br />\n<br />\nHallo&nbsp;[Vorname]!<br />\nDie pers&ouml;nlichen Daten unserer Mitarbeiter und Mitglieder wollen wir sch&uuml;tzen. Darum bitten wir Dich, Dich auf das Datengeheimnis wie folgt zu verpflichten:<br />\n<br />\n<strong>1. Verpflichtung auf das Datengeheimnis nach &sect; 5 BDSG</strong><br />\nAufgrund von &sect; 5 BDSG ist mir untersagt, personenbezogene Daten, die mir dienstlich bekannt werden, unbefugt zu erheben, zu verarbeiten oder zu nutzen. Dies gilt sowohl f&uuml;r die dienstliche T&auml;tigkeit innerhalb wie auch au&szlig;erhalb (z.B. bei Kunden und Interessenten) des Unternehmens/der Beh&ouml;rde.<br />\nDie Pflicht zur Wahrung des Datengeheimnisses bleibt auch im Falle einer Versetzung oder nach Beendigung des Arbeits-/Dienstverh&auml;ltnisses bestehen.<br />\n<br />\n<strong>2. Verpflichtung auf das Fernmeldegeheimnis</strong><br />\nAufgrund von &sect; 88 TKG bin ich zur Wahrung des Fernmeldegeheimnisses verpflichtet, so- weit ich im Rahmen meiner T&auml;tigkeit bei der Erbringung gesch&auml;ftsm&auml;&szlig;iger Telekommunikationsdienste mitwirke.<br />\n<br />\n<strong>3. Verpflichtung auf Wahrung von Gesch&auml;ftsgeheimnissen</strong><br />\n&Uuml;ber Angelegenheiten des Unternehmens, die beispielsweise Einzelheiten ihrer Organisation und ihre Einrichtung betreffen, sowie &uuml;ber Gesch&auml;ftsvorg&auml;nge und Zahlen des internen Rechnungswesens, ist auch nach Beendigung des Arbeitsverh&auml;ltnisses von mir Verschwiegenheit zu wahren, sofern sie nicht allgemein &ouml;ffentlich bekannt geworden sind. Hierunter fallen&nbsp;auch Vorg&auml;nge von Drittunternehmen, mit denen ich dienstlich befasst bin. Auf die gesetzli- chen Bestimmungen &uuml;ber unlauteren Wettbewerb wurde ich besonders hingewiesen.<br />\nAlle dienstliche T&auml;tigkeiten betreffenden Aufzeichnungen, Abschriften, Gesch&auml;ftsunterlagen, Ablichtungen dienstlicher oder gesch&auml;ftlicher Vorg&auml;nge, die mir &uuml;berlassen oder von mir angefertigt werden, sind vor Einsichtnahme Unbefugter zu sch&uuml;tzen.<br />\n<br />\nVon diesen Verpflichtungen habe ich Kenntnis genommen. Ich bin mir bewusst, dass ich mich bei Verletzungen des Datengeheimnisses, des Fernmeldegeheimnisses oder von Gesch&auml;ftsgeheimnissen strafbar machen kann, insbesondere nach &sect;&sect; 44, 43 Abs. 2 BDSG, &sect; 206 Strafgesetzbuch (StGB) und nach &sect; 17 Gesetz gegen den unlauteren Wettbewerb (UWG).</p>',0,'0000-00-00 00:00:00',0)");
            db_query("insert into {cc_config} (name, value) values ('accept_datasecurity','0')");
            db_query("ALTER TABLE {cdb_person} ADD acceptedsecurity DATETIME NULL AFTER loginerrorcount");
            set_version("2.28");
        case '2.28':
        case '2.29':
            db_query("INSERT INTO {cc_auth} (id ,auth ,modulename ,datenfeld,bezeichnung)\n        VALUES ( '601',  'view',  'churchcheckin', NULL ,  'Darf die Checkin-Anwendung nutzen')");
            db_query("ALTER TABLE  {cdb_gruppentreffen_gemeindeperson}\n                       ADD modified_date DATETIME NOT NULL AFTER treffen_yn");
            db_query("ALTER TABLE  {cdb_gruppentreffen_gemeindeperson}\n                       ADD modified_pid int(11) NOT NULL AFTER modified_date");
            db_query("ALTER TABLE  {cdb_gruppentreffen_gemeindeperson} ADD zufallscode VARCHAR( 10 ) NOT NULL AFTER treffen_yn");
            db_query("ALTER TABLE  {cdb_gruppentreffen}\n                       ADD modified_date DATETIME NOT NULL AFTER ausgefallen_yn");
            db_query("ALTER TABLE  {cdb_gruppentreffen}\n                       ADD modified_pid int(11) NOT NULL AFTER modified_date");
            db_query("insert into {cc_config} values ('churchcheckin_name', 'Checkin')");
            db_query("CREATE TABLE {cc_printer} (\n      id int(11) NOT NULL AUTO_INCREMENT,\n      bezeichnung varchar(50) NOT NULL,\n      ort varchar(50) NOT NULL,\n      active_yn int(1) not null default '0',\n      modified_date datetime NOT NULL,\n      modified_pid int(11) NOT NULL,\n      PRIMARY KEY (id),\n        UNIQUE KEY bezeichnung (bezeichnung,ort)\n      ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 ");
            db_query("CREATE TABLE {cc_printer_queue} (\n       id int(11) NOT NULL AUTO_INCREMENT,\n        printer_id int(11) NOT NULL,\n        data blob NOT NULL,\n        modified_date datetime NOT NULL,\n        modified_pid int(11) NOT NULL,\n        PRIMARY KEY (id)\n      ) ENGINE=InnoDB  DEFAULT CHARSET=utf8");
            db_query("ALTER TABLE {cdb_gruppe} ADD mail_an_leiter_yn INT( 1 ) NOT NULL DEFAULT  '1' AFTER instatistik_yn");
            db_query("INSERT INTO {cdb_feld} VALUES (null, 4, 4, 'mail_an_leiter_yn', NULL, 1, '<p>Leiter informieren<br/><small>(Co-)Leiter und Supverisor bekommen E-Mails bei &Auml;nderungen in der Gruppe', '&Leiter informieren', '<br/>', 'admingroups', 1, 19)");
            db_query("INSERT INTO  {cc_auth} (id ,auth ,modulename ,datenfeld ,bezeichnung)\n      VALUES ('115',  'view group',  'churchdb',  'cdb_gruppe',  'View-Rechte auf andere Gruppen')");
            db_query("CREATE TABLE {cdb_gruppe_mailchimp} (\n      gruppe_id int(11) NOT NULL,\n      modified_pid int(11) NOT NULL,\n      modified_date datetime NOT NULL,\n      mailchimp_list_id varchar(30) NOT NULL,\n      optin_yn int(1) NOT NULL DEFAULT '1',\n      goodbye_yn int(1) NOT NULL DEFAULT '0',\n      notifyunsubscribe_yn int(1) NOT NULL DEFAULT '0',\n        PRIMARY KEY (gruppe_id,mailchimp_list_id)\n      ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
            db_query("CREATE TABLE {cdb_gruppe_mailchimp_person} (\n      gruppe_id int(11) NOT NULL,\n      mailchimp_list_id varchar(20) NOT NULL,\n      person_id int(11) NOT NULL,\n      email varchar(50) NOT NULL,\n        PRIMARY KEY (gruppe_id,mailchimp_list_id,person_id)\n      ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
            db_query("insert into {cc_config} values ('churchdb_mailchimp_apikey', '')");
            db_query("ALTER TABLE {cdb_gruppentreffen} ADD anzahl_gaeste INT( 11 ) NULL AFTER ausgefallen_yn");
            db_query("ALTER TABLE {cdb_gruppentreffen} ADD kommentar TEXT NULL AFTER anzahl_gaeste");
            db_query("ALTER TABLE {cdb_person} ADD archiv_yn INT( 0 ) NOT NULL DEFAULT  '0' AFTER cmsuserid");
            db_query("INSERT INTO  {cc_auth} (id ,auth ,modulename ,datenfeld ,bezeichnung)\n      VALUES ('116',  'view archive',  'churchdb',  null,  'View-Rechte auf das Personen-Archiv')");
            set_version("2.30");
        case '2.30':
            db_query("insert into {cc_config} values ('churchcheckin_inmenu', '1')");
            db_query("insert into {cc_config} values ('churchcheckin_sortcode', '1')");
            db_query("insert into {cc_config} values ('churchcheckin_startbutton', '1')");
            db_query("insert into {cc_config} values ('churchdb_inmenu', '1')");
            db_query("insert into {cc_config} values ('churchdb_sortcode', '2')");
            db_query("insert into {cc_config} values ('churchdb_startbutton', '1')");
            db_query("insert into {cc_config} values ('churchresource_inmenu', '1')");
            db_query("insert into {cc_config} values ('churchresource_sortcode', '3')");
            db_query("insert into {cc_config} values ('churchresource_startbutton', '1')");
            db_query("insert into {cc_config} values ('churchservice_inmenu', '1')");
            db_query("insert into {cc_config} values ('churchservice_sortcode', '4')");
            db_query("insert into {cc_config} values ('churchservice_startbutton', '1')");
            db_query("insert into {cc_config} values ('churchwiki_inmenu', '1')");
            db_query("insert into {cc_config} values ('churchwiki_sortcode', '5')");
            db_query("insert into {cc_config} values ('churchwiki_startbutton', '1')");
            db_query("insert into {cc_config} values ('churchcal_inmenu', '1')");
            db_query("insert into {cc_config} values ('churchcal_sortcode', '6')");
            db_query("insert into {cc_config} values ('churchcal_startbutton', '1')");
            db_query("insert into {cc_config} values ('churchdb_smspromote_apikey', '')");
            db_query("INSERT INTO  {cc_auth} (id ,auth ,modulename ,datenfeld ,bezeichnung)\n      VALUES ('117',  'send sms',  'churchdb',  null,  'Darf die SMS-Schnittstelle verwenden')");
            set_version("2.31");
        case '2.31':
            db_query("ALTER TABLE {cs_service} ADD notiz VARCHAR( 50 ) NOT NULL AFTER bezeichnung");
            db_query("ALTER TABLE {cs_service} CHANGE bezeichnung  bezeichnung VARCHAR( 50 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
            db_query("ALTER TABLE {cc_cal} ADD domain_type VARCHAR( 30 ) NULL AFTER id");
            db_query("ALTER TABLE {cc_cal} ADD domain_id INT( 11 ) NULL AFTER domain_type");
            db_query("insert into {cc_config} values ('churchservice_reminderhours', '24')");
            db_query("INSERT INTO {cdb_feld} VALUES(null, 4, 2, 'gruppentyp_id', 'groupTypes', 1, 'Gruppentyp', 'Gruppentyp', '<br/>', 'admingroups', 11, 2)");
            set_version("2.32");
        case '2.32':
        case '2.33':
            db_query("ALTER TABLE {cc_cal} DROP domain_type");
            db_query("ALTER TABLE {cc_cal} DROP domain_id");
            db_query("ALTER TABLE {cs_event} ADD cc_cal_id INT( 11 ) NOT NULL AFTER id");
            // create parent cc_cal entries
            db_query("insert into {cc_cal} (select null, bezeichnung, '', '', 0, datum, DATE_ADD(datum, INTERVAL 1 HOUR), category_id, 0, null, null, null, current_date(), -1 from {cs_event})");
            // link to parent cc_cal
            db_query("update {cs_event} e\n        inner join (select * from {cc_cal}) as cal\n        on cal.category_id=e.category_id and cal.bezeichnung=e.bezeichnung and cal.startdate=e.datum and e.cc_cal_id=0\n        set e.cc_cal_id=cal.id");
            db_query("ALTER TABLE {cs_event} CHANGE category_id old_category_id INT( 11 ) NOT NULL DEFAULT  '0'");
            db_query("ALTER TABLE {cs_event} CHANGE bezeichnung old_bezeichnung VARCHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
            db_query("ALTER TABLE {cs_event} CHANGE datum startdate DATETIME NOT NULL ");
            // CALENDAR
            // first, import descriptions
            db_query("CREATE TABLE {cc_calcategory} (\n        id int(11) NOT NULL AUTO_INCREMENT,\n        bezeichnung varchar(100) NOT NULL,\n        sortkey int(11) not null default 0,\n        color varchar(20) null,\n        oeffentlich_yn int(1) not null default 0,\n        privat_yn int(1) not null default 0,\n        modified_date datetime NOT NULL,\n        modified_pid int(11) NOT NULL,\n      PRIMARY KEY (id),\n      UNIQUE KEY bezeichnung_per_user (bezeichnung,modified_pid)\n      ) ENGINE=InnoDB  DEFAULT CHARSET=utf8");
            db_query("insert into {cc_calcategory} (select null, bezeichnung, sortkey, color, 1, 0, current_date(), -1 from {cs_category})");
            db_query("ALTER TABLE {cc_cal} CHANGE category_id  old_category_id INT( 11 ) NOT NULL DEFAULT 0");
            db_query("ALTER TABLE {cc_cal} ADD category_id INT( 11 ) NOT NULL AFTER old_category_id");
            $db = db_query("select cal.id cal_id, cs.id cs_id from {cc_calcategory} cal, {cs_category} cs where cal.bezeichnung=cs.bezeichnung");
            // adapt IDs since auto_increment is used now
            if ($db != null) {
                foreach ($db as $ids) {
                    db_query("update {cc_cal} set category_id=:cal_id where old_category_id=:cs_id", array(":cal_id" => $ids->cal_id, ":cs_id" => $ids->cs_id));
                }
            }
            // admin may not see everything, eg. personal calendars
            db_query("ALTER TABLE {cc_auth} ADD admindarfsehen_yn INT( 1 ) NOT NULL DEFAULT 1");
            db_query("UPDATE {cc_auth} SET admindarfsehen_yn =  0  WHERE id=115");
            db_query("INSERT INTO  {cc_auth} (id, auth, modulename, datenfeld, bezeichnung, admindarfsehen_yn) values (403, 'view category', 'churchcal', 'cc_calcategory', 'Darf bestimmte Kalender einsehen',1)");
            db_query("INSERT INTO  {cc_auth} (id, auth, modulename, datenfeld, bezeichnung, admindarfsehen_yn) values (404, 'edit category', 'churchcal', 'cc_calcategory', 'Darf bestimmte Kalender anpassen',1)");
            // COMMENTS
            db_query("CREATE TABLE {cc_comment} (\n        id int(11) NOT NULL AUTO_INCREMENT,\n        domain_type varchar(30) NOT NULL,\n        domain_id int(11) NOT NULL,\n        text text NOT NULL,\n        modified_date datetime NOT NULL,\n        modified_pid int(11) NOT NULL,\n        PRIMARY KEY (id),\n        UNIQUE KEY domain_type (domain_type,domain_id)\n      ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ");
            set_version("2.34");
        case '2.34':
            db_query("CREATE TABLE {cc_mail_queue} (\n      id int(11) NOT NULL AUTO_INCREMENT,\n      receiver varchar(255) NOT NULL,\n      sender varchar(255) NOT NULL,\n      subject varchar(255) NOT NULL,\n      body blob NOT NULL,\n      htmlmail_yn int(1) NOT NULL,\n      priority int(1) NOT NULL DEFAULT '2',\n      modified_date datetime NOT NULL,\n      modified_pid int(11) NOT NULL,\n      send_date datetime DEFAULT NULL,\n      error int(11) DEFAULT '0',\n      reading_count int(11) NOT NULL DEFAULT '0',\n      PRIMARY KEY (id)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ");
            db_query("ALTER TABLE {cdb_gruppe} CHANGE bezeichnung bezeichnung VARCHAR( 100 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
            db_query("ALTER TABLE {cdb_log} CHANGE txt txt VARCHAR( 2048 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
            // public user may see the calendar function and church service calendars
            db_query("INSERT INTO {cc_domain_auth} (\n        domain_type, domain_id, auth_id, daten_id)\n        VALUES ('person',  '-1',  '401', NULL);");
            db_query("INSERT INTO {cc_domain_auth} VALUES('person', -1, 403, 2)");
            db_query("INSERT INTO {cc_domain_auth} VALUES('person', -1, 403, 3)");
            db_query("update {cc_auth} set bezeichnung='Admin-Einstellungen anpassen' where id=1");
            // authorize viewing the calendar by status
            db_query("insert into {cc_domain_auth} SELECT 'status', s.id, 403, cat.id FROM {cc_calcategory} cat, {cdb_status} s where cat.oeffentlich_yn=1");
            set_version("2.35");
        case '2.35':
        case '2.36':
            db_query("update {cc_calcategory} set bezeichnung = replace(bezeichnung, '', '')\n        WHERE  bezeichnung LIKE  '%s Kalender'");
            db_query("ALTER TABLE {cc_cal} ADD link VARCHAR( 255 ) NOT NULL AFTER notizen");
            db_query("ALTER TABLE {cc_calcategory} ADD randomurl VARCHAR( 100 ) NOT NULL AFTER privat_yn");
            db_query("update {cc_calcategory} set randomurl=MD5(RAND()) where randomurl=''");
            db_query("TRUNCATE TABLE {cs_eventtemplate_service}");
            db_query("ALTER TABLE {cs_eventtemplate_service} ADD PRIMARY KEY ( eventtemplate_id ,  service_id )");
            db_query("ALTER TABLE {cr_booking} ADD cc_cal_id INT( 11 ) NULL");
            db_query("ALTER TABLE {cs_absent_reason} ADD color VARCHAR( 20 ) NOT NULL AFTER bezeichnung");
            db_query("ALTER TABLE {cs_eventtemplate_service} ADD count INT( 2 ) NOT NULL DEFAULT 1");
            set_version("2.37");
        case '2.37':
            db_query("ALTER TABLE {cs_eventtemplate} ADD dauer_sec INT( 11 ) NOT NULL DEFAULT  '5400' AFTER minute");
            db_query("ALTER TABLE {cdb_feld} ADD inneuerstellen_yn INT( 1 ) NOT NULL DEFAULT '0' AFTER aktiv_yn");
            db_query("update {cdb_feld} set inneuerstellen_yn=1 where db_spalte in ('strasse', 'plz', 'ort', 'email')");
            db_query("UPDATE {cc_auth} SET auth = 'church category',\n            bezeichnung = 'Kategorien von Gemeindekalendern anpassen' WHERE id =402");
            db_query("INSERT {cc_auth} (id, auth, modulename, bezeichnung) values(405, 'group category', 'churchcal',\n            'Kategorien von Gruppenkalendern anpassen')");
            db_query("INSERT {cc_auth} (id, auth, modulename, bezeichnung) values(406, 'personal category', 'churchcal',\n            'Kategorien von persoenlichen Kalendern anpassen')");
            db_query("ALTER TABLE {cc_auth} ADD UNIQUE (auth, modulename)");
            db_query("UPDATE {cc_auth} SET admindarfsehen_yn = 0 WHERE  id =403");
            db_query("UPDATE {cc_auth} SET admindarfsehen_yn = 0 WHERE  id =404");
            db_query("insert into {cc_domain_auth} select 'person', modified_pid, 404, id from {cc_calcategory} where id>0 and modified_pid>0");
            db_query("ALTER TABLE {cr_booking} ADD INDEX (cc_cal_id)");
            set_version("2.38");
        case '2.38':
        case '2.39':
        case '2.40':
            // Give some more facts permission for CS facts
            db_query("INSERT INTO {cc_auth} (id, auth, modulename, datenfeld, bezeichnung, admindarfsehen_yn) values (309, 'edit template', 'churchservice', null, 'Darf Event-Templates editieren',1)");
            db_query("INSERT INTO {cc_auth} (id, auth, modulename, datenfeld, bezeichnung, admindarfsehen_yn) values (321, 'view facts', 'churchservice', null, 'Darf Fakten sehen',1)");
            db_query("INSERT INTO {cc_auth} (id, auth, modulename, datenfeld, bezeichnung, admindarfsehen_yn) values (322, 'export facts', 'churchservice', null, 'Darf Fakten exportieren',1)");
            // Give permission to push/pull people from/to archive in CDB
            db_query("INSERT INTO {cc_auth} (id, auth, modulename, datenfeld, bezeichnung, admindarfsehen_yn) values (118, 'push/pull archive', 'churchdb', null, 'Darf Personen ins Archiv verschieben und zurueckholen',1)");
            // Resolves problem with some wiki pages with long page names
            db_query("ALTER TABLE {cc_file} CHANGE filename filename VARCHAR( 100 ) NOT NULL");
            db_query("ALTER TABLE {cc_file} CHANGE domain_id domain_id VARCHAR( 100 ) NOT NULL");
            // Add authorization for agenda in CS module
            db_query("INSERT INTO {cc_auth} (id, auth, modulename, datenfeld, bezeichnung, admindarfsehen_yn) values (331, 'view agenda', 'churchservice', 'cc_calcategory', 'Darf Ablaufplaene sehen',1)");
            db_query("INSERT INTO {cc_auth} (id, auth, modulename, datenfeld, bezeichnung, admindarfsehen_yn) values (332, 'edit agenda', 'churchservice', 'cc_calcategory', 'Darf Ablaufplaene editieren',1)");
            db_query("INSERT INTO {cc_auth} (id, auth, modulename, datenfeld, bezeichnung, admindarfsehen_yn) values (333, 'edit agenda templates', 'churchservice', 'cc_calcategory', 'Darf Ablaufplan-Vorlagen editieren',1)");
            // Add tables for agenda in CS module
            db_query("CREATE TABLE {cs_agenda} (\n      id int(11) NOT NULL AUTO_INCREMENT,\n      calcategory_id int(11) NOT NULL,\n      bezeichnung varchar(100) NOT NULL,\n      template_yn int(1) NOT NULL DEFAULT '0',\n      series varchar(100) DEFAULT NULL,\n      modified_date datetime NOT NULL,\n      modified_pid int(11) NOT NULL,\n      PRIMARY KEY (id)\n    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
            db_query("CREATE TABLE {cs_item} (\n      id int(11) NOT NULL AUTO_INCREMENT,\n      agenda_id int(11) NOT NULL,\n      bezeichnung varchar(100) NOT NULL,\n      header_yn int(1) NOT NULL DEFAULT '0',\n      responsible varchar(100) NOT NULL,\n      arrangement_id int(11) DEFAULT NULL,\n      note varchar(255) NOT NULL,\n      sortkey int(11) NOT NULL,\n      duration int(11) NOT NULL,\n      preservice_yn int(1) NOT NULL DEFAULT '0',\n      modified_date datetime NOT NULL,\n      modified_pid int(11) NOT NULL,\n      PRIMARY KEY (id)\n    ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
            db_query("CREATE TABLE {cs_event_item} (\n      event_id int(11) NOT NULL,\n      item_id int(11) NOT NULL,\n      PRIMARY KEY (event_id,item_id)\n    ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
            db_query("CREATE TABLE {cs_item_servicegroup} (\n      item_id int(11) NOT NULL,\n      servicegroup_id int(11) NOT NULL,\n      note varchar(255) NOT NULL,\n      PRIMARY KEY (item_id,servicegroup_id)\n    ) ENGINE=InnoDB DEFAULT CHARSET=utf8");
            set_version("2.41");
        case '2.41':
            db_query("INSERT INTO {cc_auth} (id, auth, modulename, datenfeld, bezeichnung, admindarfsehen_yn) values (407, 'create personal category', 'churchcal', null, 'Darf persoenliche Kalender erstellen',1)");
            db_query("INSERT INTO {cc_auth} (id, auth, modulename, datenfeld, bezeichnung, admindarfsehen_yn) values (408, 'create group category', 'churchcal', null, 'Darf Gruppenkalender erstellen',1)");
            db_query("UPDATE {cc_auth} SET auth = 'admin church category',\n          bezeichnung = 'Gemeindekalender administrieren' WHERE id =402");
            db_query("UPDATE {cc_auth} SET auth = 'admin group category',\n          bezeichnung = 'Gruppenkalender administrieren' WHERE id =405");
            db_query("UPDATE {cc_auth} SET auth = 'admin personal category',\n          bezeichnung = 'Persoenliche Kalender administrieren' WHERE id =406");
            // Drop old userid-col
            db_query("ALTER TABLE {cdb_log} DROP userid");
            db_query("INSERT INTO  {cc_config} (name, value) VALUES ('timezone', 'Europe/Berlin')");
            // Gives the admin the permission to edit categories. Cause 404 has admindarfsehen_yn=0
            db_query("INSERT INTO {cc_domain_auth} VALUES('person', 1, 404, 1)");
            db_query("INSERT INTO {cc_domain_auth} VALUES('person', 1, 404, 2)");
            db_query("INSERT INTO {cc_domain_auth} VALUES('person', 1, 404, 3)");
            set_version("2.42");
        case '2.42':
            db_query("update {cdb_nationalitaet} set bezeichnung='Elfenbeink&uuml;ste' where bezeichnung='Elfenbeink?ste'");
            db_query("update {cdb_nationalitaet} set bezeichnung='Gro&szlig;britannien' where bezeichnung='Gro?britannien'");
            db_query("update {cdb_nationalitaet} set bezeichnung='Pal&auml;stinensische Gebiete' where bezeichnung='Pal?stinensische Gebiete'");
            db_query("update {cdb_nationalitaet} set bezeichnung='Rum&auml;nien' where bezeichnung='Rum?nien'");
            db_query("update {cdb_nationalitaet} set bezeichnung='S&atilde;o Tom&eacute; und Pr&iacute;ncipe' where bezeichnung='S?o Tom? und Pr?ncipe'");
            db_query("update {cdb_nationalitaet} set bezeichnung='Wei&szlig;russland' where bezeichnung='Wei?russland'");
            db_query("update {cc_config} set value=1 where name='cronjob_dbdump' and value=0");
            db_query("update {cc_config} set value=3600 where name='cronjob_delay' and value=0");
            set_version("2.43");
        case '2.43':
            db_query("ALTER TABLE {cs_event} ADD created_by_template_id INT( 11 ) NULL");
            set_version("2.44");
        case '2.44':
            set_version("2.45");
        case '2.45':
            // Throuh an error in the update in 2.42, the value is 60, that doesnt make sense...
            db_query("update {cc_config} set value=3600 where name='cronjob_delay' and value=60");
            db_query("INSERT INTO {cdb_feldkategorie} (id , bezeichnung , intern_code , db_tabelle , id_name)\n      VALUES ( '5',  'Bereich',  'f_dep',  'cdb_bereich',  'id');");
            db_query("INSERT INTO  {cdb_feld} (id, feldkategorie_id , feldtyp_id , db_spalte ,\n         db_stammdatentabelle , aktiv_yn , inneuerstellen_yn , langtext , kurztext , zeilenende ,\n         autorisierung , laenge , sortkey )\n        VALUES (NULL ,  '5',  '2',  'bereich_id',  'dep',  '1',  '0',  'Bereich',  'Bereich',  '<br/>', NULL , NULL , 1\n      )");
            set_version("2.46");
        case '2.46':
            db_query("ALTER TABLE {cc_wikicategory} ADD in_menu_yn INT( 1 ) NOT NULL DEFAULT '1'");
            db_query("UPDATE {cdb_feld} set autorisierung='viewalldetails || leader' where autorisierung='ViewAllDetailsOrPersonLeader'");
            db_query("CREATE TABLE {cc_notification} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          domain_type varchar(20) NOT NULL,\n          domain_id int(11) NOT NULL,\n          person_id int(11) NOT NULL,\n          notificationtype_id int(11) NOT NULL,\n          lastsenddate datetime DEFAULT NULL,\n          PRIMARY KEY (id),\n          UNIQUE KEY domain_type (domain_type,domain_id,person_id)\n        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ");
            db_query("CREATE TABLE {cc_notificationtype} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          bezeichnung varchar(40) NOT NULL,\n          delay_hours int(11) NOT NULL,\n          PRIMARY KEY (id)\n        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
            db_query("INSERT INTO {cc_notificationtype} (bezeichnung, delay_hours) VALUES\n        ('sofort', 0),\n        ('alle 3 Stunden', 3),\n        ('jeden Tag', 24),\n        ('alle 3 Tage', 72)\n        ");
            db_query("CREATE TABLE {cc_meetingrequest} (\n          id int(11) NOT NULL AUTO_INCREMENT,\n          cal_id int(11) NOT NULL,\n          person_id int(11) NOT NULL,\n          event_date datetime NOT NULL,\n          zugesagt_yn int(1) DEFAULT NULL,\n          mailsend_date datetime DEFAULT NULL,\n          response_date datetime DEFAULT NULL,\n          PRIMARY KEY (id),\n          UNIQUE KEY cal_id (cal_id,person_id,event_date)\n        ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
            // Fix bug when person_id differs from id
            db_query("UPDATE {cdb_feldkategorie} SET id_name = 'person_id' WHERE intern_code='f_category'");
            // Copy permission from viewalldata to new perm: complex filter
            db_query("insert into {cc_domain_auth} (\n        select domain_type, domain_id, 120, null from {cc_domain_auth} where auth_id=102\n        group by domain_id, domain_type)");
            db_query("ALTER TABLE {cs_agenda} ADD final_yn INT( 1 ) NOT NULL DEFAULT '0' AFTER series");
            set_version("2.47");
        case '2.47':
            db_query("ALTER TABLE {cs_service} ADD cal_text_template VARCHAR( 255 ) NULL AFTER allowtonotebyconfirmation_yn");
            // Fix bug when events was created with repeat function in ChurchService
            db_query("update {cc_cal} set enddate=date_add(startdate, interval 1 hour) where datediff(startdate, enddate)>0");
            // Add new report tables
            db_query("CREATE TABLE {crp_person} (\n        date date NOT NULL,\n        status_id int(11) NOT NULL,\n        station_id int(11) NOT NULL,\n        newperson_count int(11) NOT NULL,\n        count int(11) NOT NULL,\n        PRIMARY KEY (date,status_id,station_id)\n      ) ENGINE=MyISAM DEFAULT CHARSET=utf8");
            db_query("CREATE TABLE {crp_group} (\n        date date NOT NULL,\n        gruppe_id int(11) NOT NULL,\n        status_id int(11) NOT NULL,\n        station_id int(11) NOT NULL,\n        gruppenteilnehmerstatus_id int(11) NOT NULL,\n        newperson_count int(11) NOT NULL,\n        count int(11) NOT NULL,\n        PRIMARY KEY (date,gruppe_id,status_id,station_id,gruppenteilnehmerstatus_id)\n      ) ENGINE=MyISAM DEFAULT CHARSET=utf8;");
            set_version("2.48");
        case "2.48":
            db_query("ALTER TABLE {cs_event_fact} CHANGE value value VARCHAR( 11 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL");
            db_query("ALTER TABLE {cs_song_arrangement} CHANGE  note  note text");
            // Set permission to all resource_ids
            db_query("UPDATE {cc_domain_auth} SET daten_id=-1 WHERE auth_id=202");
            db_query("ALTER TABLE {cdb_gruppe} ADD members_allowedmail_eachother_yn INT( 1 ) NOT NULL DEFAULT  '0' AFTER mail_an_leiter_yn");
            db_query("INSERT INTO {cdb_feld} VALUES (null, 4, 4, 'members_allowedmail_eachother_yn', NULL, 1, 0, '<p>Kommunikation untereinander<br/><small>Teilnehmer der Gruppe d&uuml;rfen sich gegenseitig E-Mails zusenden', 'Untereinander kommunizieren', '<br/>', null, 1, 19)");
            db_query("ALTER TABLE {cdb_feld} CHANGE autorisierung  autorisierung VARCHAR( 100 )");
            db_query("UPDATE {cdb_feld} SET autorisierung = 'viewaddress||viewalldetails||leader||changeownaddress' WHERE db_spalte='strasse'");
            db_query("UPDATE {cdb_feld} SET autorisierung = 'viewaddress||viewalldetails||leader||changeownaddress' WHERE db_spalte='zusatz'");
            db_query("UPDATE {cdb_feld} set autorisierung = 'viewalldetails' where feldkategorie_id=2 and autorisierung is null and db_spalte!='geburtsdatum'");
            set_version("2.49");
        case "2.49":
            db_query("insert into {cc_config} values('invite_email_text', 'Du wurdest zur Nutzung von %sitename eingeladen.\n\n" . "Klicke auf die folgende Schaltfläche, um Dich direkt dort anzumelden und um Dein Passwort zu wählen:')");
            db_query("ALTER TABLE {cs_event} DROP old_category_id");
            db_query("ALTER TABLE {cs_event} DROP old_bezeichnung");
            db_query("ALTER TABLE {cr_resource} DROP adminmails_old");
            db_query("ALTER TABLE {cs_event} ADD valid_yn INT( 1 ) NOT NULL DEFAULT  '1' AFTER startdate");
            // Report
            db_query("CREATE TABLE {crp_report} (\n  id int(11) NOT NULL AUTO_INCREMENT,\n  query_id int(11) NOT NULL,\n  bezeichnung varchar(50) NOT NULL,\n  sortkey int(11) NOT NULL DEFAULT '0',\n  rows varchar(255) NOT NULL,\n  cols varchar(255) NOT NULL,\n  aggregatorName varchar(255) DEFAULT NULL,\n  PRIMARY KEY (id)\n      ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=5");
            db_query("INSERT INTO {crp_report} (id, query_id, bezeichnung, sortkey, rows, cols, aggregatorName) VALUES\n    (1, 1, 'Anzahl Personen Gesamt', 10, 'Monat', 'Station,Mitglied', 'Anzahl Personen'),\n    (2, 1, 'Anzahl neuer Personen', 20, 'Monat', 'Station', 'Anzahl neuer Personen'),\n    (3, 2, 'Gruppentypen', 10, 'Datum', 'Gruppentyp', 'Anzahl Personen'),\n    (4, 3, 'Gruppen per Distrikt', 10, 'Datum', 'Distrikt,Mitglied', '');");
            db_query("CREATE TABLE {crp_query} (\n    id int(11) NOT NULL AUTO_INCREMENT,\n    bezeichnung varchar(50) CHARACTER SET latin1 NOT NULL,\n    query_sql blob NOT NULL,\n    sortkey int(11) NOT NULL DEFAULT '0',\n    PRIMARY KEY (id)\n    ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=6");
            db_query("INSERT INTO {crp_query} (id, bezeichnung, query_sql, sortkey) VALUES\n    (1, 'Personen', 0x73656c65637420702e6461746520446174756d2c207965617228702e6461746529204a6168722c20646174655f666f726d617428702e646174652c202725592d256d2729204d6f6e61742c0a2020202020202020732e62657a656963686e756e67205374617475732c200a202020202020202073742e62657a656963686e756e672053746174696f6e2c0a20202020202020202863617365207768656e20732e6d6974676c6965645f796e3d30207468656e20274b65696e204d6974676c6965642720656c736520274d6974676c6965642720656e6429206173204d6974676c6965642c200a2020202020202020702e6e6577706572736f6e5f636f756e742c20702e636f756e742061732027636f756e74272066726f6d206372705f706572736f6e2070200a2020202020202020202020202020206c656674206a6f696e206364625f7374617475732073206f6e2028732e69643d702e7374617475735f6964290a2020202020202020202020202020206c656674206a6f696e206364625f73746174696f6e207374206f6e202873742e69643d702e73746174696f6e5f696429, 10),\n    (2, 'Gruppen per Monat', 0x73656c65637420646174655f666f726d617428702e646174652c202725592d256d27292061732027446174756d272c0a20202020202020207965617228702e6461746529204a6168722c0a2020202020202020732e62657a656963686e756e67205374617475732c0a202020202020202073742e62657a656963686e756e672053746174696f6e2c0a2020202020202020672e62657a656963686e756e67204772757070652c0a2020202020202020642e62657a656963686e756e67204469737472696b742c0a202020202020202067742e62657a656963686e756e67204772757070656e7479702c0a20202020202020206774732e62657a656963686e756e67204772757070656e7465696c6e65686d65727374617475732c0a20202020202020202863617365207768656e20732e6d6974676c6965645f796e3d30207468656e20274b65696e204d6974676c6965642720656c736520274d6974676c6965642720656e642920617320204d6974676c6965642c0a202020202020202073756d28702e6e6577706572736f6e5f636f756e7429206e6577706572736f6e5f636f756e742c200a2020202020202020726f756e642873756d28702e636f756e74292f636f756e7428702e636f756e74292c302920617320636f756e740a202020202020202066726f6d206372705f67726f757020700a2020202020202020202020202020206c656674206a6f696e206364625f7374617475732073206f6e2028732e69643d702e7374617475735f6964290a2020202020202020202020202020206c656674206a6f696e206364625f6772757070652067206f6e2028672e69643d702e6772757070655f6964290a2020202020202020202020202020202020202020206c656674206a6f696e206364625f6772757070656e747970206774206f6e202867742e69643d672e6772757070656e7479705f69642920202020202020200a2020202020202020202020202020202020202020206c656674206a6f696e206364625f6469737472696b742064206f6e2028642e69643d672e6469737472696b745f69642920202020202020200a2020202020202020202020202020206c656674206a6f696e206364625f6772757070656e7465696c6e65686d657273746174757320677473206f6e20286774732e69643d702e6772757070656e7465696c6e65686d65727374617475735f6964290a2020202020202020202020202020206c656674206a6f696e206364625f73746174696f6e207374206f6e202873742e69643d702e73746174696f6e5f6964290a20202020202020202067726f757020627920446174756d2c205374617475732c2053746174696f6e2c204772757070652c204469737472696b742c204772757070656e7479702c204d6974676c6965642c204772757070656e7465696c6e65686d657273746174757309, 20),\n    (3, 'Aktuelle Gruppen pro Woche', 0x73656c65637420636f6e63617428274b5720272c7965617228702e64617465292c272d272c20646174655f666f726d617428702e646174652c2027257527292b31292061732027446174756d272c0a20202020202020207965617228702e6461746529204a6168722c0a2020202020202020732e62657a656963686e756e67205374617475732c0a202020202020202073742e62657a656963686e756e672053746174696f6e2c0a2020202020202020672e62657a656963686e756e67204772757070652c0a2020202020202020642e62657a656963686e756e67204469737472696b742c0a202020202020202067742e62657a656963686e756e67204772757070656e7479702c0a20202020202020206774732e62657a656963686e756e67204772757070656e7465696c6e65686d65727374617475732c0a20202020202020202863617365207768656e20732e6d6974676c6965645f796e3d30207468656e20274b65696e204d6974676c6965642720656c736520274d6974676c6965642720656e642920617320204d6974676c6965642c0a202020202020202073756d28702e6e6577706572736f6e5f636f756e7429206e6577706572736f6e5f636f756e742c200a2020202020202020726f756e642873756d28702e636f756e74292f636f756e7428702e636f756e74292c302920617320636f756e740a202020202020202066726f6d206372705f67726f757020700a2020202020202020202020202020206c656674206a6f696e206364625f7374617475732073206f6e2028732e69643d702e7374617475735f6964290a2020202020202020202020202020206c656674206a6f696e206364625f6772757070652067206f6e2028672e69643d702e6772757070655f6964290a2020202020202020202020202020202020202020206c656674206a6f696e206364625f6772757070656e747970206774206f6e202867742e69643d672e6772757070656e7479705f69642920202020202020200a2020202020202020202020202020202020202020206c656674206a6f696e206364625f6469737472696b742064206f6e2028642e69643d672e6469737472696b745f69642920202020202020200a2020202020202020202020202020206c656674206a6f696e206364625f6772757070656e7465696c6e65686d657273746174757320677473206f6e20286774732e69643d702e6772757070656e7465696c6e65686d65727374617475735f6964290a2020202020202020202020202020206c656674206a6f696e206364625f73746174696f6e207374206f6e202873742e69643d702e73746174696f6e5f6964290a2020202020202020207768657265206461746564696666286e6f7728292c20702e64617465293c372a380a20202020202020202067726f757020627920446174756d2c205374617475732c2053746174696f6e2c204772757070652c204469737472696b742c204772757070656e7479702c204d6974676c6965642c204772757070656e7465696c6e65686d6572737461747573090a202020202020202020, 30)");
            db_query("ALTER TABLE {cdb_gruppe} ENGINE = INNODB");
            db_query("ALTER TABLE {cdb_gruppentyp} ENGINE = INNODB");
            db_query("ALTER TABLE {cdb_distrikt} ENGINE = INNODB");
            db_query("ALTER TABLE {cdb_person} ENGINE = INNODB");
            db_query("ALTER TABLE {cdb_gemeindeperson} ENGINE = INNODB");
            db_query("ALTER TABLE {cdb_status} ENGINE = INNODB");
            db_query("ALTER TABLE {cdb_station} ENGINE = INNODB");
            db_query("ALTER TABLE {cdb_bereich} ENGINE = INNODB");
            db_query("ALTER TABLE {cdb_gemeindeperson_gruppe} ENGINE = INNODB");
            db_query("ALTER TABLE {cdb_bereich_person} ENGINE = INNODB");
            db_query("ALTER TABLE {cdb_gruppe} ADD FOREIGN KEY ( gruppentyp_id ) REFERENCES {cdb_gruppentyp}( id )");
            db_query("ALTER TABLE {cdb_gruppe} ADD FOREIGN KEY ( distrikt_id) REFERENCES {cdb_distrikt}( id )");
            db_query("ALTER TABLE {cdb_gemeindeperson} ADD FOREIGN KEY (person_id) REFERENCES {cdb_person}( id )");
            db_query("ALTER TABLE {cdb_gemeindeperson} ADD FOREIGN KEY (status_id) REFERENCES {cdb_status}( id )");
            db_query("ALTER TABLE {cdb_gemeindeperson} ADD FOREIGN KEY (station_id) REFERENCES {cdb_station}( id )");
            db_query("ALTER TABLE {cdb_bereich_person} ADD FOREIGN KEY (person_id) REFERENCES {cdb_person}( id )");
            db_query("ALTER TABLE {cdb_bereich_person} ADD FOREIGN KEY (bereich_id) REFERENCES {cdb_bereich}( id )");
            db_query("ALTER TABLE {cs_service} ADD FOREIGN KEY (servicegroup_id) REFERENCES {cs_servicegroup}( id )");
            db_query("ALTER TABLE {cs_song} ADD FOREIGN KEY (songcategory_id) REFERENCES {cs_songcategory}( id )");
            db_query("ALTER TABLE {cs_song_arrangement} ADD FOREIGN KEY (song_id) REFERENCES {cs_song}( id )");
            db_query("ALTER TABLE {cc_usersettings} ADD serialized_yn INT( 1 ) NOT NULL DEFAULT '0'");
            // Change the save method for intelligente groups to separte usersettings for each group
            $db = db_query("select * from {cc_usersettings} where modulename='churchdb' and attrib='filter'");
            foreach ($db as $filter) {
                $arr = unserialize($filter->value);
                if ($arr != null) {
                    foreach ($arr as $key => $val) {
                        churchcore_saveUserSetting("churchdb", $filter->person_id, "myFilter[" . $key . "]", $val);
                    }
                }
            }
            db_query("delete from {cc_usersettings} where modulename='churchdb' and attrib='filter'");
            // Repair group ids in cs_service
            $db = db_query('select * from {cs_service} s');
            foreach ($db as $s) {
                if ($s->cdb_gruppen_ids != null) {
                    $arr = explode(",", $s->cdb_gruppen_ids);
                    $res = array();
                    foreach ($arr as $a) {
                        if ($a != "") {
                            $res[] = $a;
                        }
                    }
                    if (count($res) > 0) {
                        db_query("update {cs_service} set cdb_gruppen_ids=:ids where id=:id", array(":ids" => implode(",", $res), ":id" => $s->id));
                    } else {
                        db_query("update {cs_service} set cdb_gruppen_ids=null where id=:id", array(":id" => $s->id));
                    }
                }
            }
            set_version("2.50");
        case '2.50':
            db_query("ALTER TABLE {cs_item} CHANGE note note VARCHAR(1024)");
            db_query("ALTER TABLE {cdb_gemeindeperson_gruppe_archive} ADD comment VARCHAR( 512 ) NULL");
            db_query("ALTER TABLE {cdb_feld} ADD del_when_move_to_archive_yn INT( 0 ) NOT NULL DEFAULT '0'");
            db_query("UPDATE {cc_calcategory} SET color='black' WHERE color IS NULL");
            set_version("2.51");
        case '2.51':
            db_query("ALTER TABLE {cr_resource} ADD virtual_yn INT(1) NOT NULL DEFAULT '0'");
            db_query("CREATE TABLE {cc_reminder} (id int(11) NOT NULL, domain_type varchar(30) NOT NULL,\n                domain_id int(11) NOT NULL,  person_id int(11) NOT NULL, reminddate datetime NOT NULL,\n                mailsenddate datetime NOT NULL\n              ) ENGINE=InnoDB ");
            db_query("ALTER TABLE {cc_calcategory} ADD ical_source_url VARCHAR(255) NULL AFTER randomurl");
            db_query("ALTER TABLE {cr_booking} DROP userid");
            // Was deprecated, now use person_id
            set_version("2.52");
        case '2.52':
            db_query("UPDATE {cc_cal} SET enddate = ADDDATE(startdate, INTERVAL '60:00' MINUTE_SECOND)\n              WHERE enddate<startdate AND startdate>=now()");
            set_version("2.53");
        case '2.53':
            // Switch to MyISAM for big tables for better InnoDB performance cause not eating all of the cache:)
            db_query("ALTER TABLE {cdb_log} ENGINE = MyISAM");
            db_query("ALTER TABLE {cc_mail_queue} ENGINE = MyISAM");
            set_version("2.54");
        case '2.54':
            db_query("UPDATE {cdb_feld} set langtext='Familienstand' where langtext='Familenstand'");
            db_query("UPDATE {cdb_feld} set kurztext='Familienstand' where kurztext='Familenstand'");
            set_version("2.55");
        case '2.55':
            db_query("ALTER TABLE {cs_song} CHANGE bezeichnung bezeichnung VARCHAR(255)");
            set_version("2.56");
        case '2.56':
            set_version("2.57");
        case '2.57':
            //not exactly a database update, but is there any better place for it?
            $htaccess = __DIR__ . '/../../' . $files_dir . '/.htaccess';
            if (file_exists($htaccess)) {
                $handle = fopen($htaccess, 'a');
                if ($handle) {
                    fwrite($handle, "# IMPORTANT, prevents directory content listing!\nOptions -Indexes\n");
                    fclose($handle);
                }
            }
            set_version("2.58");
    }
    //end switch
    $a = db_query("select * from {cc_config} where name='version'", null, false);
    $software_version = $a->fetch()->value;
    $link = ' <a href="https://intern.churchtools.de/?q=churchwiki#WikiView/filterWikicategory_id:0/doc:changelog/" target="_clean">Neuigkeiten anschauen</a>';
    if ($db_version == "nodb") {
        addInfoMessage("Datenbankupdates ausgef&uuml;hrt auf v{$software_version}.");
    } else {
        addInfoMessage("Datenbankupdates ausgef&uuml;hrt von <I>" . getConf("site_name") . "</i>. Versionswechsel von {$db_version} auf {$software_version}. {$link}");
    }
    cleandir("{$files_dir}/files/messages/");
    //delete temporal i18n files
    $sitename = $config["site_name"];
    if (isset($config["site_mail"])) {
        churchcore_systemmail($config["site_mail"], "Neue Version auf " . $config["site_name"], "Datenbankupdates ausgef&uuml;hrt von " . getConf("site_name") . "' v{$db_version} auf v{$software_version}. {$link}<br/><br/>" . "<a href=\"{$base_url}\" class=\"btn\">{$sitename} aufrufen</a>", true);
    }
    if (userLoggedIn()) {
        $user = $_SESSION["user"];
        $user->auth = getUserAuthorization($user->id);
        $_SESSION["user"] = $user;
    }
    return true;
}
<?php

if (userLoggedIn()) {
    /* Newly Addedby Amaldev starts */
    $sql = "Select vLookUpValue from sptbl_lookup where vLookUpName='LiveChat'";
    $rs_chat = executeSelect($sql, $conn);
    if (mysql_num_rows($rs_chat) > 0) {
        $var_row = mysql_fetch_array($rs_chat);
        $var_livechat_enb = $var_row["vLookUpValue"];
    } else {
        $var_livechat_enb = '0';
    }
}
?>


<div class="icons_main_container">
    <div class="icons_left_column">
        <div class="icon1">
            <?php 
$ticketUrl = SITE_URL . "postticket.php?mt=y&stylename=POSTTICKETS&styleminus=twominus&styleplus=twoplus&";
?>
            <a class="icon_image1" href="<?php 
echo $ticketUrl;
?>
"></a>
            <h2><a href="<?php 
echo $ticketUrl;
?>
" > <?php 
echo CREATE_NEW_TCKT;
<?php
	require('lib/db_info.php');
	require('jwt/JWT.php');
	require('mysqlnd_polyfill.php');
	
	
	switch($_GET['action'])
	{
		case 'create_user': post_new_user(); break;
		case 'login_user': login_user(); break;
		case 'check_log': userLoggedIn(); break;
		case 'test': test(); break;
		default: break;
	}
	
	
	
	function post_new_user(){
		//make sure the username is aokay and not already taken
		global $conn;
		$data 		= json_decode(file_get_contents('php://input'));
		$username 	= htmlspecialchars($data->username);
		$email 		= htmlspecialchars($data->email);
		$password 	= htmlspecialchars($data->password);
		
		$password_hash = password_hash($password, PASSWORD_DEFAULT);
		
		//check if username is already taken
		
		if($sql = $conn->prepare("SELECT * FROM members where member_name = ?")){