aboutsummaryrefslogtreecommitdiff
path: root/bootstrap/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'bootstrap/functions.php')
-rw-r--r--bootstrap/functions.php214
1 files changed, 214 insertions, 0 deletions
diff --git a/bootstrap/functions.php b/bootstrap/functions.php
index 8c998fc..60408a2 100644
--- a/bootstrap/functions.php
+++ b/bootstrap/functions.php
@@ -22,3 +22,217 @@ function failure($reason, $httpcode, $ajax = true, $heading = NULL){
# exit the script here
exit;
}
+
+function print_login(){
+if(isset($_GET["goto"]) && $_GET["goto"] != "")
+ $goto = $_GET["goto"];
+else
+ $goto = "index";
+?>
+<form class="form-horizontal" method="POST" action="/?page=action&task=login&goto=<?php echo $goto; ?>">
+<fieldset>
+
+<!-- Form Name -->
+<legend><h1>Junge Gemeinde Adlershof</h1><p>Login required</p></legend>
+
+<!-- Text input-->
+<div class="form-group">
+ <label class="col-md-4 control-label" for="name">Username*:</label>
+ <div class="col-md-5">
+ <input id="name" name="name" placeholder="Put your username here." class="form-control input-md" required="" type="text">
+ </div>
+</div>
+
+<!-- Password input-->
+<div class="form-group">
+ <label class="col-md-4 control-label" for="password">Password*:</label>
+ <div class="col-md-5">
+ <input id="password" name="password" placeholder="Put your password here." class="form-control input-md" required="" type="password">
+ </div>
+</div>
+
+<!-- Button -->
+<div class="form-group">
+ <label class="col-md-4 control-label" for="submit"></label>
+ <div class="col-md-4">
+ <button id="submit" name="submit" class="btn btn-info">Log In</button>
+ </div>
+</div>
+
+</fieldset>
+</form>
+</div>
+<?php
+}
+
+function print_index(){
+?>
+ <h1>Junge Gemeinde Adlershof</h1>
+ </div>
+ <div class="row">
+ </div>
+<?php
+}
+
+function print_list(){
+ global $db;
+
+ $result = $db->doQuery("SELECT * FROM " . DBPREFIX . "member;");
+?>
+ <h1>Adress Liste</h1>
+ <br>
+ </div>
+ <div class="row">
+ <table width='60%' class='table table-striped'>
+ <thead>
+ <tr>
+ <th><p>#</p></th>
+ <th><p>Name</p></th>
+ <th><p>Adresse</p></th>
+ <th><p>Telefon</p></th>
+ <th><p>Handynummer</p></th>
+ <th><p>E-Mail</p></th>
+ <th><p>Geburtstag</p></th>
+ <th><p>ändern</p></th>
+ </tr>
+ </thead>
+ <tbody>
+ <?php
+ $count = 1;
+ while ( $row = $result->fetch_array(MYSQLI_ASSOC) ){
+ echo "<tr>
+ <td>$count</td>
+ <td>".htmlentities($row['name'])."</td>
+ <td>".htmlentities($row['adresse'])."</td>
+ <td>".htmlentities($row['telefonnummer'])."</td>
+ <td>".htmlentities($row['handynummer'])."</td>
+ <td>".htmlentities($row['email'])."</td>
+ <td>".htmlentities($row['geburtstag'])."</td>
+ <td><a href='/?page=update&id=".htmlentities($row['member_id'])."'><input type='checkbox' name='change' value='true'></a></td>
+ <tr>";
+ $count++;
+ }
+ ?>
+ <?php /*
+ <tr><td align='center'><a href=\"/liste/".$row[0]."\">".$count."</a></td><td align='left'><a href=\"/liste/".$row[0]."\">".$row[1]."</a></td><td align='left'>
+ <a href=\"/liste/".$row[0]."\">".$row[2]."</a></td><td align='left'><a href=\"/liste/".$row[0]."\">".$row[3]."</a></td><td align='left'><a href=\"/liste/".$row[0]."\">".$row[4]."</a></td><td align='left'><a href=\"/liste/".$row[0]."\">".$row[5]."</a></td><td align='left'><a href=\"/liste/".$row[0]."\">".$row[6]."</a></td><td align='center'><a href=\"/liste/".$row[0]."\"><input type='checkbox' name='change' value='true'</td></a><tr>
+ */
+ ?>
+ </tbody>
+ </table>
+ <form method="POST" action="/?page=add">
+ <button id="singlebutton" class="btn btn-info" type="submit">Füge jemanden hinzu</button>
+ </form>
+</div>
+</div>
+
+<?php
+}
+
+function print_update_list($id){
+ global $db;
+
+ $sql = $db->prepare("SELECT * FROM " . DBPREFIX . "member WHERE member_id = %d", $id);
+ $result = $db->doQuery($sql);
+ if(!$result){
+ echo "Fail!";
+ exit;
+ }
+ while ( $row = $result->fetch_array(MYSQLI_ASSOC) ){
+?>
+ <h1>Änderung für <?php echo htmlentities($row['name']); ?></h1>
+ </div>
+ <div class="row">
+ <form method='POST' action='/?page=action&task=update&id=<?php echo htmlentities($row['memberid']); ?>&goto=liste'>
+ <table class='table'>
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Adresse</th>
+ <th>Telefon</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><input type='text' name='name' value='<?php echo htmlentities($row['name']); ?>'></td>
+ <td><input type='text' name='adresse' value='<?php echo htmlentities($row['adresse']); ?>'></td>
+ <td><input type='text' name='telefonnummer' value='<?php echo htmlentities($row['telefonnummer']); ?>'></td>
+ </tr>
+ </tbody>
+ <thead>
+ <tr>
+ <th>Handynummer</th>
+ <th>E-Mail</th>
+ <th>Geburtstag</th>
+ </tr>
+ <tbody>
+ <tr>
+ <td><input type='text' name='handynummer' value='<?php echo htmlentities($row['handynummer']); ?>'></td>
+ <td><input type='text' name='email' value='<?php echo htmlentities($row['email']); ?>'></td>
+ <td><input type='text' name='geburtstag' value='<?php echo htmlentities($row['geburtstag']); ?>'></td>
+ </tr>
+ </tbody>
+ </table>
+ <button id="singlebutton" name="singlebutton" class="btn btn-info" type="submit">Ändere!</button>
+ </form>
+ </div>
+<?php
+ }
+}
+
+function print_add_entry_to_list(){
+?>
+ <h1>Füge die Daten hinzu</h1>
+ </div>
+ <div class="row">
+ <form method='POST' action='/?page=action&task=add&goto=liste'>
+ <table class='table'>
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Adresse</th>
+ <th>Telefon</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td><input type='text' name='name' placeholder='Name'></td>
+ <td><input type='text' name='adresse' placeholder='Adresse'></td>
+ <td><input type='text' name='telefonnummer' placeholder='Telefonnummer'></td>
+ </tr>
+ </tbody>
+ <thead>
+ <tr>
+ <th>Handynummer</th>
+ <th>E-Mail</th>
+ <th>Geburtstag</th>
+ </tr>
+ <tbody>
+ <tr>
+ <td><input type='text' name='handynummer' placeholder='Handynummer'></td>
+ <td><input type='text' name='email' placeholder='E-Mail'></td>
+ <td><input type='text' name='geburtstag' placeholder='Geburtstag'></td>
+ </tr>
+ </tbody>
+ </table>
+ <button id="singlebutton" name="singlebutton" class="btn btn-info" type="submit">Hinzufügen!</button>
+ </form>
+ </div>
+<?php
+}
+
+function _add_entry(){
+ global $db;
+
+ $sql = $db->prepare("INSERT INTO " . DPREFIX . "member (id, name, adresse, telefonnummer, handynummer, email, geburtstag) VALUES (NULL. %s, %s, %s, %s, %s, %s);", $_POST['name'], $_POST['adresse'], $_POST['telefonnummer'], $_POST['handynummer'], $_POST['email'], $_POST['geburtstag']);
+ if( ! $db->doQuery($sql) )
+ return false;
+ else
+ return true;
+}
+
+function print_404(){
+ header($_SERVER['HTTP_PROTOCOL'] . ' 404 Not Found');
+?>
+<?php
+}