diff options
| author | Horus3 | 2014-09-25 10:33:47 +0200 |
|---|---|---|
| committer | Horus3 | 2014-09-25 10:33:47 +0200 |
| commit | 1fe76ba743a3418da9a0883b29756d442384d0bc (patch) | |
| tree | 091910ffd183d94c0f8b70a8f4c362f733033b03 /bootstrap/functions.php | |
| parent | 2036626b560f22efd59673187a2de3b1319fcf8a (diff) | |
| download | jungegemeinde-1fe76ba743a3418da9a0883b29756d442384d0bc.tar.gz | |
init
Diffstat (limited to 'bootstrap/functions.php')
| -rw-r--r-- | bootstrap/functions.php | 578 |
1 files changed, 0 insertions, 578 deletions
diff --git a/bootstrap/functions.php b/bootstrap/functions.php deleted file mode 100644 index 3e937d2..0000000 --- a/bootstrap/functions.php +++ /dev/null @@ -1,578 +0,0 @@ -<?php - -function lredirect($goto){ - global $user; - if ( $user->isLoggedIn() != 1){ - redirect("login&goto=".$goto); - } -} - -function redirect($goto){ - header($_SERVER["SERVER_PROTOCOL"] . " 302 Moved"); - header("Location: /?page=".$goto); - ob_clean(); - exit; -} -function failure($reason, $httpcode, $ajax = true, $heading = NULL){ - - # send header with $httpcode - header($_SERVER['SERVER_PROTOCOL'] . " " . $httpcode); - - # just echo the reason to the ajax response - if($ajax){ - echo $reason; - exit; - } - - // TODO: Put pretty HTML here, please - - # print full error page - if($heading != NULL) - echo $heading; - - echo $reason; - - # exit the script here - exit; -} - -function print_login($option = false){ -if(isset($_GET["goto"]) && $_GET["goto"] != "") - $goto = htmlentities($_GET["goto"]); -else - $goto = "index"; - - global $user; - if ( $user->isLoggedIn() ){ - redirect("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> -<?php - if ( ! $option ){ -?> -<p>Login required</p> -<?php - } else if ( $option == "logout" ){ -?> -<p style="color:red">Logout erfolgreich!</p> -<?php - } else if ( $option == "password" ) { -?> -<p style="color:red">Nutzer/Passwort falsch</p> -<?php - } else if ( $option == "missing") { -?> -<p style="color:red">Bitte fülle alle Felder aus!</p> -<?php - } -?> -</legend> - -<!-- Text input--> -<div class="form-group"> - <label class="col-md-4 control-label" for="name">Username*</label> - <div class="col-md-4"> - <input id="name" name="name" placeholder="Name (Pflicht)" 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-4"> - <input id="password" name="password" placeholder="Passwort (Pflicht)" 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> -<br> -<p><strong>Mit * markierte Felder sind Pflichtfelder.</strong></p> -</div> -<div class="row"> -<a href="/?page=recover" title="Recover your password">[Passwort vergessen?]</a> -</div> -<?php -} - -function print_logout(){ - global $user; - $user->logout(); - print_login("logout"); -} - -function print_index(){ -?> - <h1>Junge Gemeinde Adlershof</h1> - <br> - </div> - <div class="row"> - <img src="/static/kitten-prays-small.jpg" alt="praing kitten" class="img-responsive"> - </div> - <br> - <div class="row"> - <p>Wir sind die Junge Gemeinde in Adlershof.</p> - <p>Wir treffen uns immer Donnerstags um 19:30 Uhr in der Remise Arndtstraße 12a.</p> - <p>Am besten sind wir über unsere <span id="mail"><strong>Aktiviere JavaScript um die E-Mail Adresse zu sehen!</strong></span> erreichbar.</p> - </div> -<?php -} - -function print_list($option = false){ - lredirect("liste"); - global $db; - - $result = $db->doQuery("SELECT * FROM " . DBPREFIX . "member;"); -?> - <h1>Adress Liste</h1> -<?php - if ( $option == "update"){ -?> -<h4 style="color:red;">Es existiert kein Mitglied mit dieser ID</h4> - <br> -<?php - } else if ( $option == false ) { -?> - <br> -<?php - } -?> - </div> - <div class="row"> - <div class="table-responsive"> - <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++; - } - ?> - </tbody> - </table> - </div> - <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){ - lredirect("liste"); - global $db; - - $sql = $db->prepare("SELECT * FROM " . DBPREFIX . "member WHERE member_id = %d", $id); - $result = $db->doQuery($sql); - if(!$result){ - print_list("update"); - exit; - } - if ( $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['member_id']); ?>&goto=liste'> - <div class="table-responsive"> - <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> - </div> - <button id="singlebutton" name="singlebutton" class="btn btn-info" type="submit">Ändere!</button> - </form> - </div> -<?php - } else { - print_list("update"); - } -} - -function print_add_entry_to_list(){ - lredirect("liste"); -?> - <h1>Füge die Daten hinzu</h1> - </div> - <div class="row"> - <form method='POST' action='/?page=action&task=add&goto=liste&_flush=<?php echo $c->token; ?>'> - <div class="table-responsive"> - <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> - </div> - <button id="singlebutton" name="singlebutton" class="btn btn-info" type="submit">Hinzufügen!</button> - </form> - </div> -<?php -} - -function _add_entry(){ - lredirect("liste"); - 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['SERVER_PROTOCOL'] . ' 404 Not Found'); -?> -<h1>404 - Not Found</h1> -<br> -<h4>The requested page (<?php echo htmlentities($_SERVER['REQUEST_URI']); ?>) wasn't found on this server.</h4> -</div> -<?php -} - -function print_register($option = false){ - global $user; - if ( $user->isLoggedIn() ){ - redirect("index"); - } -?> - -<form class="form-horizontal" method='POST' action='/?page=action&task=register&goto=account'> -<fieldset> - -<!-- Form Name --> -<legend><h1>Junge Gemeinde Adlershof</h1> -<?php - if ( $option == false ){ -?> -<p>Register</p> -<?php - } else if ( $option == "password") { -?> -<p style="color:red;">Passwörter stimmen nicht überein!</p> -<?php - } else if ( $option == "missing") { -?> -<p style="color:red;">Bitte fülle alle mit '*' markierten Felder aus!</p> -<?php - } else if ( $option == "key") { -?> -<p style="color:red;">Registrierung verweigert!</p> -<?php - } else if ( $option == "double") { -?> -<p style="color:red;">Nutzer/E-Mail gibt es schon!</p> -<?php - } else if ( $option == "double") { -?> -<p style="color:red;">Interner Fehler!</p> -<?php - } -?> -</legend> - -<!-- Text input--> -<div class="form-group"> - <label class="col-md-4 control-label" for="name">Name*</label> - <div class="col-md-4"> - <input id="name" name="name" placeholder="Name (Pflicht)" 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">Passwort*</label> - <div class="col-md-4"> - <input id="password" name="password" placeholder="Passwort (Pflicht)" class="form-control input-md" required="" type="password"> - - </div> -</div> - -<!-- Password input--> -<div class="form-group"> - <label class="col-md-4 control-label" for="confirm">Bestätige Passwort*</label> - <div class="col-md-4"> - <input id="confirm" name="confirm" placeholder="Passwort (Pflicht)" class="form-control input-md" required="" type="password"> - - </div> -</div> - -<!-- Text input--> -<div class="form-group"> - <label class="col-md-4 control-label" for="email">E-Mail</label> - <div class="col-md-4"> - <input id="email" name="email" placeholder="E-Mail" class="form-control input-md" type="text"> - <span class="help-block">Deine E-Mail wird gebraucht, wenn du dein Passwort vergessen hast.</span> - </div> -</div> - -<!-- Text input--> -<div class="form-group"> - <label class="col-md-4 control-label" for="key">Key*</label> - <div class="col-md-4"> - <input id="key" name="key" placeholder="Schlüssel (Pflicht)" class="form-control input-md" required="" type="text"> - <span class="help-block">Du solltest den Schlüssel in einer Mail bekommen haben.</span> - </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">Registrieren</button> - </div> -</div> - -</fieldset> -</form> -<br> -<p><strong>Mit * markierte Felder sind Pflichtfelder.</strong></p> -</div> -<?php -} - -function print_account($option = false){ - lredirect("accout"); - global $user; -?> -<form class="form-horizontal" method="POST" action="/?page=action&task=account&goto=account"> -<fieldset> - -<!-- Form Name --> -<legend> -<h1><?php echo htmlentities($_SESSION["username"]);?></h1> -<?php - if ( $option == false && ! isset($_GET["success"]) && $_GET["success"] != 1){ -?> -<p>Ändere deine Daten</p> -<?php - } else if ( $option == "info" ){ -?> -<p style="color:red;">Bitte fülle alle notwendigen Felder aus!</p> -<?php - } else if ( $option == "password" ){ -?> -<p style="color:red;">Dein Passwort stimmt nicht!</p> -<?php - } else if ( $option == "double" ){ -?> -<p style="color:red;">Nutzer/E-Mail schon vergeben!</p> -<?php - } else if ( $option == "database" ){ -?> -<p style="color:red;">Interner Fehler!</p> -<?php - } else if ( $option == "success" || $_GET["success"] == 1 ){ -?> -<p style="color:green;">Erfolgreich aktualisiert!</p> -<?php - } -?> -</legend> - -<!-- Text input--> -<div class="form-group"> - <label class="col-md-4 control-label" for="name">Name*</label> - <div class="col-md-4"> - <input id="name" name="name" placeholder="Neuer Name" class="form-control input-md" type="text" value="<?php echo $_SESSION["username"];?>" required=""> - <span class="help-block">Wechsle deinen Namen hier.</span> - </div> -</div> - -<!-- Password input--> -<div class="form-group"> - <label class="col-md-4 control-label" for="passwordinput">Neues Passwort</label> - <div class="col-md-4"> - <input id="passwordinput" name="password" placeholder="Neues Passwort" class="form-control input-md" type="password"> - <span class="help-block">Ändere dein Passwort. Lass das Feld leer, wenn du es nicht ändern möchtest.</span> - </div> -</div> - -<!-- Text input--> -<div class="form-group"> - <label class="col-md-4 control-label" for="textinput">E-Mail</label> - <div class="col-md-4"> - <input id="textinput" name="email" placeholder="E-Mail" class="form-control input-md" type="text" value="<?php echo $user->getEmail(); ?>"> - <span class="help-block">Ändere deine E-Mail Adresse.</span> - </div> -</div> - -<!-- Password input--> -<div class="form-group"> - <label class="col-md-4 control-label" for="confirm">Passwort*</label> - <div class="col-md-4"> - <input id="confirm" name="confirm" placeholder="Bestätige mit deinem alten Passwort." class="form-control input-md" required="" type="password"> - <span class="help-block">Bestätige die Angaben mit deinem gültigen Passwort.</span> - </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-primary">Ändere!</button> - </div> -</div> - -</fieldset> -</form> -<br> -<p><strong>Mit * markierte Felder sind Pflichtfelder.</strong></p> - </div> -<?php -} - -function print_recover($option = false){ -?> -<form class="form-horizontal" method='POST' action='/?page=action&task=recover'> -<fieldset> - -<!-- Form Name --> -<legend><h1>Junge Gemeinde Adlershof</h1> -<?php - if(isset($_GET["track"])){ - if ($_GET["track"] == 1) { -?> -<p style="color:green;">Passwort zugeschickt!</p> -<?php - } else { -?> -<p style="color:red;">Fehler! Passwort konnte nicht geändert werden.</p> -<?php - } - } else { -?> -<p>Passwort wiederherstellen</p> -<?php - } -?> -</legend> - -<!-- Text input--> -<div class="form-group"> - <label class="col-md-4 control-label" for="email">E-Mail*</label> - <div class="col-md-4"> - <input id="email" name="email" placeholder="Deine hinterlegte E-Mail Adresse." class="form-control input-md" required="" type="text"> - <span class="help-block">Wenn deine E-Mail gespeichert ist, wird dir das neue Passwort automatisch zugestellt.</span> - </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-primary">Recover!</button> - </div> -</div> - -</fieldset> -</form> - -</div> -<?php -} - -function minify($buffer){ - $search = array( - '/\>[^\S ]+/s', // strip whitespaces after tags, except space - '/[^\S ]+\</s', // strip whitespaces before tags, except space - '/(\s)+/s' // shorten multiple whitespace sequences - ); - - $replace = array( - '>', - '<', - '\\1' - ); - - $buffer = preg_replace($search, $replace, $buffer); - - return $buffer; -} |
