Added autoloader
[memberdb.git] / index.php
index 2fc1cd8..889a6f1 100644 (file)
--- a/index.php
+++ b/index.php
 <?php
 
+error_reporting(E_ALL);
+ini_set('display_errors', 1);
+
 header('Content-type: text/html; charset=utf-8');
-if (function_exists('date_default_timezone_set')) date_default_timezone_set('UTC');
+date_default_timezone_set('UTC');
 bcscale(2);
 
+set_exception_handler(function (Throwable $e) {
+    echo('Caught exception: ' . $e->getMessage());
+    exit();
+});
+
+require_once(__DIR__ . '/include/autoload.php');
+
+if (!file_exists(__DIR__ . '/config.php')) {
+    die('Not configured');
+}
+
 require_once('config.php');
-require_once('include/database.php');
-require_once('include/misc.php');
-require_once('include/installation.php');
-require_once('include/html.php');
-
-require_once('include/finances.php');
-require_once('include/fees.php');
-require_once('include/cryptography.php');
-require_once('include/earnings.php');
-require_once('include/events.php');
-require_once('include/expenses.php');
-require_once('include/members.php');
-require_once('include/payments.php');
-require_once('include/dtaus.php');
-require_once('include/export.php');
-
-
-try {
-
-    db_connect();
-
-    if (!defined('IS_INSTALLED') || !IS_INSTALLED) install_database();
-
-    $action = 'list_members';
-    if (isset($_REQUEST['action'])) $action = $_REQUEST['action'];
-
-    ob_start();
-
-    switch ($action) {
-        case 'list_members'   : action_list_members();    break;
-        case 'view_member'    : action_view_member();     break;
-        case 'export_email'   : action_export_email();    break;
-        case 'create_member'  : action_create_member();   break;
-        case 'change_member'  : action_change_member();   break;
-        case 'create_event'   : action_create_event();    break;
-        case 'change_event'   : action_change_event();    break;
-        case 'delete_event'   : action_delete_event();    break;
-        case 'create_earnings': action_create_earnings(); break;
-        case 'create_earning' : action_create_earning();  break;
-        case 'change_earning' : action_change_earning();  break;
-        case 'delete_earning' : action_delete_earning();  break;
-        case 'create_expense' : action_create_expense();  break;
-        case 'change_expense' : action_change_expense();  break;
-        case 'delete_expense' : action_delete_expense();  break;
-        case 'cryptography'   : action_cryptography();    break;
-        case 'fees'           : action_fees();            break;
-        case 'dtaus'          : action_dtaus();           break;
-        case 'finances'       : action_finances();        break;
-        case 'export'         : action_export();          break;
-        default: action_404();
-    }
-
-    $content = ob_get_contents();
-    ob_end_clean();
+require_once(__DIR__ . '/include/includes.php');
+
+
+db_connect();
+
+if (!defined('IS_INSTALLED') || !IS_INSTALLED) {
+    install_database();
+}
+
+$action = 'list_members';
+if (isset($_GET['action'])) {
+    $action = $_GET['action'];
+}
+
+ob_start();
+
+switch ($action) {
+    case 'list_members'   :
+        action_list_members();
+        break;
+    case 'view_member'    :
+        action_view_member();
+        break;
+    case 'export_email'   :
+        action_export_email();
+        break;
+    case 'create_member'  :
+        action_create_member();
+        break;
+    case 'change_member'  :
+        action_change_member();
+        break;
+    case 'export_ibanhin' :
+        action_export_ibanhin();
+        break;
+    case 'create_event'   :
+        action_create_event();
+        break;
+    case 'change_event'   :
+        action_change_event();
+        break;
+    case 'delete_event'   :
+        action_delete_event();
+        break;
+    case 'create_earnings':
+        action_create_earnings();
+        break;
+    case 'create_earning' :
+        action_create_earning();
+        break;
+    case 'change_earning' :
+        action_change_earning();
+        break;
+    case 'delete_earning' :
+        action_delete_earning();
+        break;
+    case 'create_expense' :
+        action_create_expense();
+        break;
+    case 'change_expense' :
+        action_change_expense();
+        break;
+    case 'delete_expense' :
+        action_delete_expense();
+        break;
+    case 'cryptography'   :
+        action_cryptography();
+        break;
+    case 'fees'           :
+        action_fees();
+        break;
+    case 'directdebit'    :
+        action_directdebit();
+        break;
+    case 'finances'       :
+        action_finances();
+        break;
+    case 'export'         :
+        action_export_payments();
+        break;
+    case 'export_members' :
+        action_export_members();
+        break;
+    default:
+        action_404();
+}
+
+$content = ob_get_contents();
+ob_end_clean();
 
 ?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
 <html xmlns="http://www.w3.org/1999/xhtml" lang="de" xml:lang="de">
-    <head>
-        <title>Mitgliedsverwaltung - Chaos Computer Club Frankfurt am Main</title>
-        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-        <style type="text/css">
-            form  { line-height: 2em; }
-            fieldset { line-height: 2em; border: 1px solid #ccc; margin-bottom: 1em; float:left; border-width: 1px 0 0 0; width: 27em; }
-            /*fieldset { border: 1px solid #ccc; margin-bottom: 1em; float:left; border-width: 1px 0 0 0; } */
-            legend { font-size: 1.4em; }
-            label { clear: left; display: block; width: 10em; float: left; }
-            input, select { display: block; width: 20em; float: left; }
-            form small { clear: left; display: block; text-align: right; margin-right: 1.8em; line-height: 1em; margin-bottom: 1.5em; }
-            fieldset small { clear: left; display: block; text-align: right; margin-right: 1.8em; line-height: 1em; margin-bottom: 1.5em; }
-            .checkbox label { clear: none; margin-left: 0.5em; }
-            .checkbox input { clear: left; width: auto;  }
-            #header { margin: 0; padding: 1px 0; background-color: #464646; }
-            #content { font-size: 1.4em; }
-            .content { margin: 0 auto; width: 960px; }
-            .submit { clear: left; }
-            h1 { color: #fff; }
-            body { margin: 0; padding: 0; font-family:  Arial, Verdana, Tahoma; font-size: 62.5%; color: #333; }
-            html { margin: 0; padding: 0; }
-            table { border-collapse: collapse; margin-bottom: 1em; border: 1px solid #ccc; }
-            th, td { padding: 0.3em 2em 0.3em 0.3em;}
-            tr:hover { background-color: #eee; }
-            tr.earning { background-color: #efe; }
-            tr.expense { background-color: #fee; }
-            tr.earning:hover { background-color: #dfd; }
-            tr.expense:hover { background-color: #fdd; }
-            tr.total { background-color: #eee; font-weight: bold; }
-            tr.current { background-color: #eee; font-weight: bold; }
-            tr.inactive { color: #999; }
-            #earning_form { background-color: #efe; }
-            #expense_form { background-color: #fee; }
-            th { text-align: left; background-color: #eee; font-weight: normal; border-bottom: 1px solid #ccc;  }
-            h1, h2, h3, legend { font-family: Georgia, Sans-Serif, Verdana; font-weight: normal; color: #333;}
-            #header h1 { font-size: 4em; color: #fff; }
-            h2 { font-size: 2.2em; }
-            h3 { font-size: 1.8em; }
-            #pagemenu { background-color: #e0e0e0; border-top: 1px solid #e4f2fd; font-size: 1.4em; }
-            #pagemenu ul { list-style: none; padding: 0px 10px; display:block; margin-top: 6px; }
-            #pagemenu li { line-height:28px; font-weight: bold; display: inline; float: left; margin-left: 5px; }
-            #pagemenu li a { display: block; color: #888; background-color: #eee; padding: 0px 20px; text-decoration: none; }
-            #pagemenu li a:hover { color: #000; background: #fff; }
-            #footer { background-color: #eee; border-top: 1px solid #ddd; height: 50px; margin-top: 3em; }
-            .clearfix:after { content: " "; display: block; clear: both; visibility: hidden; line-height: 0; height: 0; }
-            .clearfix { display: inline-block; }
-            html[xmlns] .clearfix { display: block; }
-            * html .clearfix { height: 1%; }
-            .log_messages { color: #cc0000; }
-            p.error { border: 1px solid #900;  padding: 1em; color: #cc0000; background-color: #fff9f9;}
-
-            #content a { text-decoration: none; padding: 0 1px; color: #21759B; border-bottom: 1px solid #ccc; }
-            #content a:hover { color: #D54E21; background: #F5D1C5; border-bottom: 1px solid #D54E21; }
-            .modal_window { position:absolute; display:none; background-color: #fff; padding: 1em; }
-            #mask { position:absolute; top:0px; left:0px; height:100%; width:100%; display:none; background-color: black; }
-
-            .pagination { text-align: center; margin: 10px 0; font-weight: bold; }
-            .pagination .prev { float: left; }
-            .pagination .next { float: right; }
-
-        </style>
-        <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
-        <script type="text/javascript" src="js/crypto-js/crypto/crypto-min.js"></script>
-        <script type="text/javascript" src="js/crypto-js/sha1/sha1-min.js"></script>
-        <script type="text/javascript" src="js/crypto-js/hmac/hmac-min.js"></script>
-        <script type="text/javascript" src="js/crypto-js/pbkdf2/pbkdf2-min.js"></script>
-        <script type="text/javascript" src="js/crypto-js/ofb/ofb-min.js"></script>
-        <script type="text/javascript" src="js/crypto-js/aes/aes_modified.js"></script>
-        <script type="text/javascript" src="js/dtaus.js"></script>
-    </head>
-    <body>
-    <div id="header"><div class="content"><h1>Mitgliedsverwaltung</h1></div></div>
-    <div id="pagemenu">
-        <ul class="content clearfix">
-            <li><a href="<?=link_to()?>">Mitglieder</a></li>
-            <li><a href="<?=link_to('finances')?>">Finanzen</a></li>
-            <li><a href="<?=link_to('fees')?>">Mitgliedsbeitr&auml;ge</a></li>
-            <li><a href="<?=link_to('dtaus')?>">Bankeinzug</a></li>
-            <li><a href="<?=link_to('cryptography')?>">Kryptographie</a></li>
-        </ul>
-    </div>
-    <div id="content" class="content"><?=$content?></div>
-    <div id="footer"></div>
-    </body>
-</html>
+<head>
+    <title>Mitgliedsverwaltung - Chaos Computer Club Frankfurt am Main</title>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+    <style type="text/css">
+        form {
+            line-height: 2em;
+        }
 
-<?php
+        fieldset {
+            line-height: 2em;
+            border: 1px solid #ccc;
+            margin-bottom: 1em;
+            float: left;
+            border-width: 1px 0 0 0;
+            width: 27em;
+        }
 
-}
-catch (Exception $e) {
-    echo 'Caught exception: ',  $e->getMessage(), "\n";
-}
\ No newline at end of file
+        /*fieldset { border: 1px solid #ccc; margin-bottom: 1em; float:left; border-width: 1px 0 0 0; } */
+        legend {
+            font-size: 1.4em;
+        }
+
+        label {
+            clear: left;
+            display: block;
+            width: 10em;
+            float: left;
+        }
+
+        input, select {
+            display: block;
+            width: 20em;
+            float: left;
+        }
+
+        form small {
+            clear: left;
+            display: block;
+            text-align: right;
+            margin-right: 1.8em;
+            line-height: 1em;
+            margin-bottom: 1.5em;
+        }
+
+        fieldset small {
+            clear: left;
+            display: block;
+            text-align: right;
+            margin-right: 1.8em;
+            line-height: 1em;
+            margin-bottom: 1.5em;
+        }
+
+        .checkbox label {
+            clear: none;
+            margin-left: 0.5em;
+        }
+
+        .checkbox input {
+            clear: left;
+            width: auto;
+        }
+
+        #header {
+            margin: 0;
+            padding: 1px 0;
+            background-color: #464646;
+        }
+
+        #content {
+            font-size: 1.4em;
+        }
+
+        .content {
+            margin: 0 auto;
+            width: 960px;
+        }
+
+        .submit {
+            clear: left;
+        }
+
+        h1 {
+            color: #fff;
+        }
+
+        body {
+            margin: 0;
+            padding: 0;
+            font-family: Arial, Verdana, Tahoma;
+            font-size: 62.5%;
+            color: #333;
+        }
+
+        html {
+            margin: 0;
+            padding: 0;
+        }
+
+        table {
+            border-collapse: collapse;
+            margin-bottom: 1em;
+            border: 1px solid #ccc;
+        }
+
+        th, td {
+            padding: 0.3em 2em 0.3em 0.3em;
+        }
+
+        tr:hover {
+            background-color: #eee;
+        }
+
+        tr.earning {
+            background-color: #efe;
+        }
+
+        tr.expense {
+            background-color: #fee;
+        }
+
+        tr.earning:hover {
+            background-color: #dfd;
+        }
+
+        tr.expense:hover {
+            background-color: #fdd;
+        }
+
+        tr.total {
+            background-color: #eee;
+            font-weight: bold;
+        }
+
+        tr.current {
+            background-color: #eee;
+            font-weight: bold;
+        }
+
+        tr.inactive {
+            color: #999;
+        }
+
+        #earning_form {
+            background-color: #efe;
+        }
+
+        #expense_form {
+            background-color: #fee;
+        }
+
+        th {
+            text-align: left;
+            background-color: #eee;
+            font-weight: normal;
+            border-bottom: 1px solid #ccc;
+        }
+
+        h1, h2, h3, legend {
+            font-family: Georgia, Sans-Serif, Verdana;
+            font-weight: normal;
+            color: #333;
+        }
+
+        #header h1 {
+            font-size: 4em;
+            color: #fff;
+        }
+
+        h2 {
+            font-size: 2.2em;
+        }
+
+        h3 {
+            font-size: 1.8em;
+        }
+
+        #pagemenu {
+            background-color: #e0e0e0;
+            border-top: 1px solid #e4f2fd;
+            font-size: 1.4em;
+        }
+
+        #pagemenu ul {
+            list-style: none;
+            padding: 0px 10px;
+            display: block;
+            margin-top: 6px;
+        }
+
+        #pagemenu li {
+            line-height: 28px;
+            font-weight: bold;
+            display: inline;
+            float: left;
+            margin-left: 5px;
+        }
+
+        #pagemenu li a {
+            display: block;
+            color: #888;
+            background-color: #eee;
+            padding: 0px 20px;
+            text-decoration: none;
+        }
+
+        #pagemenu li a:hover {
+            color: #000;
+            background: #fff;
+        }
+
+        #footer {
+            background-color: #eee;
+            border-top: 1px solid #ddd;
+            height: 50px;
+            margin-top: 3em;
+        }
+
+        .clearfix:after {
+            content: " ";
+            display: block;
+            clear: both;
+            visibility: hidden;
+            line-height: 0;
+            height: 0;
+        }
+
+        .clearfix {
+            display: inline-block;
+        }
+
+        html[xmlns] .clearfix {
+            display: block;
+        }
+
+        * html .clearfix {
+            height: 1%;
+        }
+
+        .log_messages {
+            color: #cc0000;
+        }
+
+        p.error {
+            border: 1px solid #900;
+            padding: 1em;
+            color: #cc0000;
+            background-color: #fff9f9;
+        }
+
+        #content a {
+            text-decoration: none;
+            padding: 0 1px;
+            color: #21759B;
+            border-bottom: 1px solid #ccc;
+        }
+
+        #content a:hover {
+            color: #D54E21;
+            background: #F5D1C5;
+            border-bottom: 1px solid #D54E21;
+        }
+
+        .modal_window {
+            position: absolute;
+            display: none;
+            background-color: #fff;
+            padding: 1em;
+        }
+
+        #mask {
+            position: absolute;
+            top: 0px;
+            left: 0px;
+            height: 100%;
+            width: 100%;
+            display: none;
+            background-color: black;
+        }
+
+        .pagination {
+            text-align: center;
+            margin: 10px 0;
+            font-weight: bold;
+        }
+
+        .pagination .prev {
+            float: left;
+        }
+
+        .pagination .next {
+            float: right;
+        }
+
+    </style>
+    <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
+    <script type="text/javascript" src="js/crypto-js/crypto/crypto-min.js"></script>
+    <script type="text/javascript" src="js/crypto-js/sha1/sha1-min.js"></script>
+    <script type="text/javascript" src="js/crypto-js/hmac/hmac-min.js"></script>
+    <script type="text/javascript" src="js/crypto-js/pbkdf2/pbkdf2-min.js"></script>
+    <script type="text/javascript" src="js/crypto-js/ofb/ofb-min.js"></script>
+    <script type="text/javascript" src="js/crypto-js/aes/aes_modified.js"></script>
+    <script type="text/javascript" src="js/date.js"></script>
+    <script type="text/javascript" src="js/utils.js"></script>
+    <script type="text/javascript" src="js/dtaus.js"></script>
+    <script type="text/javascript" src="js/sepa-CORE.js"></script>
+</head>
+<body>
+<div id="header">
+    <div class="content"><h1>Mitgliedsverwaltung</h1></div>
+</div>
+<div id="pagemenu">
+    <ul class="content clearfix">
+        <li><a href="<?= link_to() ?>">Mitglieder</a></li>
+        <li><a href="<?= link_to('finances') ?>">Finanzen</a></li>
+        <li><a href="<?= link_to('fees') ?>">Mitgliedsbeitr&auml;ge</a></li>
+        <li><a href="<?= link_to('directdebit') ?>">Bankeinzug</a></li>
+        <li><a href="<?= link_to('cryptography') ?>">Kryptographie</a></li>
+    </ul>
+</div>
+<div id="content" class="content"><?= $content ?></div>
+<div id="footer"></div>
+</body>
+</html>