aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot2014-09-30 04:39:21 +0200
committerroot2014-09-30 04:39:21 +0200
commit27bc0fe2182afafee830bda8b161f67282f631c8 (patch)
treedbd7d9cdc834b63c9b1b3e366b7935c177471c29
parentdb3252c646838b5cd5657cd5ba289b88256959e3 (diff)
downloadjungegemeinde-27bc0fe2182afafee830bda8b161f67282f631c8.tar.gz
fixed bug, added download page, prettified 404 page and general design
-rw-r--r--.gitignore1
-rw-r--r--action.php32
-rw-r--r--functions.php52
-rw-r--r--index.php9
-rw-r--r--static/error.webmbin0 -> 915587 bytes
-rw-r--r--static/header.php25
-rw-r--r--static/style.min.css2
7 files changed, 78 insertions, 43 deletions
diff --git a/.gitignore b/.gitignore
index aebd8b5..957f04e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,6 +10,7 @@ setup.php
piwik.html
favicon.ico
config.php
+cat.png
tmp/
pdf/
diff --git a/action.php b/action.php
index 1b48aeb..2f1bb58 100644
--- a/action.php
+++ b/action.php
@@ -23,8 +23,9 @@ switch($_GET["task"]){
if ( ! isset($_POST["name"]) || $_POST["name"] == "" || ! isset($_POST["password"]) || $_POST["password"] == "" ){
print_login("missing");
} else if ( $user->login($_POST["name"], $_POST["password"]) ){
+ $goto = preg_replace("/;/", "&", $_GET["goto"]);
header($_SERVER["SERVER_PROTOCOL"] . " 302 Moved");
- header("Location: /?page=" . $_GET["goto"]);
+ header("Location: /?page=" . $goto);
ob_clean();
exit;
} else {
@@ -118,7 +119,6 @@ switch($_GET["task"]){
if ( $result = $db->doQuery($sql) ){
header($_SERVER["SERVER_PROTOCOL"] . " 302 Moved");
header("Location: /?page=" . $_GET["goto"]);
- //$c->flush($_GET["_flush"]);
$c->flush();
}
break;
@@ -133,9 +133,6 @@ switch($_GET["task"]){
if ( ! isset($_GET["id"]) || $_GET["id"] == 0 || $_GET["id"] == "" ){
print_list("update");
} else {
- //$sql = $db->prepare("UPDATE " . DBPREFIX . "member SET name = %s, adresse = %s, telefonnummer = %s, handynummer = %s, email = %s, geburtstag = %s WHERE member_id = %d;",
- // $_POST["name"], $_POST["adresse"], $_POST["telefonnummer"], $_POST["handynummer"], $_POST["email"], $_POST["geburtstag"], $_GET["id"]
- //);
$sql = $db->prepare("DELETE FROM " . DBPREFIX . "member WHERE member_id = %d;", $_GET["id"]);
if ( ! $sql ){
ob_clean();
@@ -144,7 +141,6 @@ switch($_GET["task"]){
}
if ( $result = $db->doQuery($sql) ){
header($_SERVER["SERVER_PROTOCOL"] . " 302 Moved");
- //header("Location: /?page=" . $_GET["goto"]);
header("Location: /?page=liste");
$c->flush();
exit;
@@ -250,25 +246,25 @@ JG Adlershof";
}
break;
case("download"):
- lredirect("liste");
- $file = '/tmp/jg_data.txt';
- $fp=fopen($file, 'w');
if( ! isset($_GET["type"]) || $_GET["type"] == "" || $_GET["type"] == "plain" ){
$content = "Adressliste der JG \n";
$content .= "# | Name | Adresse | Telefon | Handy | E-Mail | Geburtstag\n";
+ $type = "plain";
+ $suffix = ".txt";
} else {
$content = "Adressliste der JG \n";
+ $type = "csv";
+ $suffix = ".csv";
}
+ lredirect("download;type=".$type);
$res = $db->doQuery("SELECT * FROM " . DBPREFIX . "member;");
$content .= "\n";
$count = 1;
- //while ($row = $res->fetch_array(MYSQLI_ASSOC) ){
while ($row = $res->fetch_array() ){
- if( ! isset($_GET["type"]) || $_GET["type"] == "" || $_GET["type"] == "plain" ){
+ if ( $type == "plain" ){
$content .= $count . " | " . $row["name"] . " | " . $row["adresse"] . " | " . $row["telefonnummer"] . " | " . $row["handynummer"] . " | " . $row["email"] . " | " . $row["geburtstag"] . "\n";
-
- }else if(($_GET["type"] == "csv")){
+ } else {
$content .= $count;
for ( $i=1;$i<7;$i++){
$content .= ';' . $row[$i];
@@ -278,13 +274,11 @@ JG Adlershof";
$count++;
}
- fputs($fp, $content);
- fclose($fp);
ob_clean();
- header("Content-Type: text/plain; Charset=UTF-8");
- header("Content-Disposition: attachment; filename=\"JG Adressliste ".time().".txt\"");
- readfile($file);
- unlink($file);
+ header("Content-Type: text/".$type."; Charset=UTF-8");
+ header("Content-Disposition: attachment; filename=\"JG Adressliste ".date("j.n.Y", time()).$suffix."\"");
+ echo $content;
+ ob_end_flush();
exit;
break;
default:
diff --git a/functions.php b/functions.php
index efb173c..854489f 100644
--- a/functions.php
+++ b/functions.php
@@ -37,10 +37,12 @@ function failure($reason, $httpcode, $ajax = true, $heading = NULL){
}
function print_login($option = false){
-if(isset($_GET["goto"]) && $_GET["goto"] != "")
+if( isset($_GET["goto"]) && $_GET["goto"] != "" ) {
$goto = htmlentities($_GET["goto"]);
-else
+
+} else {
$goto = "index";
+}
global $user;
if ( $user->isLoggedIn() ){
@@ -110,11 +112,11 @@ else
function print_logout(){
global $user;
- $user->logout();
- /*
- global $c;
- $c->flush();
- */
+ if ( $user->isLoggedIn() ){
+ $user->logout();
+ header($_SERVER["SERVER_PROTOCOL"] . " 301 Moved");
+ header("Location: ".DOMAIN."/?page=logout");
+ }
print_login("logout");
}
@@ -191,8 +193,6 @@ function print_list($option = false){
?>
</tbody>
</table>
- <p>Downloade als <a href="/?page=action&task=download&type=plain">[plain text]</a> oder als <a href="/?page=action&task=download&type=csv">[csv]</a> Datei.</p>
- <br>
</div>
<form method="POST" action="/?page=add&_flush="<?php echo $c->token; ?>>
<button id="singlebutton" class="btn btn-info" type="submit">Füge jemanden hinzu</button>
@@ -333,9 +333,18 @@ function _add_entry(){
function print_404(){
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
?>
-<h1>404 - Not Found</h1>
+<!--h1 style="color:red;font-size:3.0em;">404 - Not Found</h1-->
+<h1>Error 404 - Not Found</h1>
+ <!--h4>The requested page (<?php echo htmlentities($_SERVER['REQUEST_URI']); ?>) wasn't found on this server.</h4-->
<br>
-<h4>The requested page (<?php echo htmlentities($_SERVER['REQUEST_URI']); ?>) wasn't found on this server.</h4>
+</div>
+<div class="row video">
+ <div class="embed-responsive embed-responsive-16by9">
+ <video class="embed-responsive-item" src="/static/error.webm" controls autoplay loop></video>
+ </div>
+ <br>
+ <p>Wir haben die Seite <strong>'<?php echo htmlentities($_SERVER['REQUEST_URI']); ?>'</strong> nicht gefunden!</p>
+ <a href="javascript:history.go(-1)" title="Index">Geh eins zurück!</a>
</div>
<?php
}
@@ -583,6 +592,27 @@ function print_recover($option = false){
<?php
}
+function print_download(){
+ if ( ! isset($_GET["type"]) || $_GET["type"] == "plain" )
+ $type = "plain";
+ else
+ $type = "csv";
+
+ lredirect("download;type=".$type);
+ header($_SERVER["SERVER_PROTOCOL"] . " 301 Moved");
+ header("Refresh: 2; ".DOMAIN."/?page=action&task=download&type=".$type);
+?>
+<h1>Download</h1>
+<h4>Der Download der Adressliste (vom Typ 'text/<?php echo $type; ?>') sollte automatisch starten.</h4>
+<hr>
+</div>
+<div class="row">
+<strong><p>Ansonsten klick hier</p></strong>
+<a href="/?page=action&task=download&type=<?php echo $type; ?>" class="btn btn-primary" title="Download Link"><span class="glyphicon glyphicon-arrow-down"></span> Download</a>
+</div>
+<?php
+}
+
function minify($buffer){
$search = array(
'/\>[^\S ]+/s', // strip whitespaces after tags, except space
diff --git a/index.php b/index.php
index 8b91155..8c94c91 100644
--- a/index.php
+++ b/index.php
@@ -42,7 +42,7 @@ $user = new jg($u);
//<link rel ="stylesheet" href="/static/style.css">
echo "<style>" . file_get_contents('static/style.min.css');?>
- .dl-horizontal dt{white-space: normal;} .btn-info{background-color:#3083D6;} .img-responsive{margin: 0 auto;} @-moz-document url-prefix() { fieldset { display: table-cell; } }</style>
+ .dl-horizontal dt{white-space: normal;}.btn-info{background-color:#3083D6;}.img-responsive{margin:0 auto;}@-moz-document url-prefix(){fieldset{display:table-cell;}}ul.nav li.dropdown:hover ul.dropdown-menu {display:block;}.video{max-width:720px;margin-right: auto;margin-left: auto;}</style>
<noscript><style>.navbar{margin-bottom:0;}</style></noscript>
<title>Junge Gemeinde Adlershof</title>
<link rel='shortcut icon' href='/favicon.ico' type='image/x-icon'>
@@ -83,13 +83,16 @@ require_once 'static/header.php';
case("account"):
print_account();
break;
+ case("download"):
+ print_download();
+ break;
case("action"):
require_once 'action.php';
break;
case("404"):
print_404();
break;
- case("recover").
+ case("recover"):
print_recover();
break;
default:
@@ -105,7 +108,7 @@ require_once 'static/footer.php';
$html = ob_get_contents();
-if ( $_SERVER["REQUEST_METHOD"] == "GET" && $_SERVER["REDIRECT_STATUS"] == 200 && strpos($_SERVER["QUERY_STRING"], "account") === false ) {
+if ( $_SERVER["REQUEST_METHOD"] == "GET" && $_SERVER["REDIRECT_STATUS"] == 200 && strpos($_SERVER["QUERY_STRING"], "account") === false && strpos($_SERVER["QUERY_STRING"], "logout") === false && strpos($_SERVER["QUERY_STRING"], "action") === false) {
$c->setKey($token, $html, 3600);
}
ob_end_flush();
diff --git a/static/error.webm b/static/error.webm
new file mode 100644
index 0000000..35eef31
--- /dev/null
+++ b/static/error.webm
Binary files differ
diff --git a/static/header.php b/static/header.php
index d20ddf9..f47d815 100644
--- a/static/header.php
+++ b/static/header.php
@@ -7,15 +7,23 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
- <a class="navbar-brand" href="/?page=index" title="Startseite">Home</a>
+ <a class="navbar-brand" href="/?page=index" title="Startseite"><span class="glyphicon glyphicon-home"></span> Home</a>
+ <!--a class="navbar-brand" href="/?page=index" title="Startseite">Home</a-->
</div>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="nav navbar-nav navbar-left">
- <li>
- <a href="/?page=liste" title="Liste aller JG-Mitglieder">Adressliste</a>
+ <li class="dropdown">
+ <a href="/?page=liste" title="Liste aller JG-Mitglieder"><span class="glyphicon glyphicon-th-list"></span> Adressliste <span class="caret"></span></a>
+ <ul class="dropdown-menu" role="menu">
+ <li><a href="/?page=download&task=download&type=plain" title="Download: text/plain">Download als Text</a></li>
+ <li><a href="/?page=download&task=download&type=csv" title="Download: text/csv">Download als CSV</a></li>
+ </ul>
</li>
+ <li>
+ <a href="https://lists.iamfabulous.de/mailman/listinfo/jungegemeinde" target="_blank" title="JG E-Mail Verteiler"><span class="glyphicon glyphicon-envelope"></span> E-Mail Verteiler</a>
+ </li>
<li>
- <a href="https://lists.iamfabulous.de/mailman/listinfo/jungegemeinde" target="_blank" title="JG E-Mail Verteiler">E-Mail Verteiler</a>
+ <a href="https://lists.iamfabulous.de/mailman/private/jungegemeinde" target="_blank" title="Archiv der Mailing Liste "><span class="glyphicon glyphicon-send"></span> Mail Archiv</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
@@ -23,17 +31,17 @@
<?php
if ( $user->isLoggedIn() ) {
?>
- <a href="/?page=account" title="Manage deinen Account">Account</a>
+ <a href="/?page=account" title="Manage deinen Account"><span class="glyphicon glyphicon-user"></span> Account</a>
</li>
<li>
- <a href="/?page=logout" title="Beende die Session">Logout</a>
+ <a href="/?page=logout" title="Beende die Session"><span class="glyphicon glyphicon-off"></span> Logout</a>
<?php
} else {
?>
- <a href="/?page=register&goto=index" title="Registriere dich für unbeschränkten Zugang">Register</a>
+ <a href="/?page=register&goto=index" title="Registriere dich für unbeschränkten Zugang"><span class="glyphicon glyphicon-user"></span> Register</a>
</li>
<li>
- <a href="/?page=login&goto=index" title="Login">Login</a>
+ <a href="/?page=login&goto=index" title="Login"><span class="glyphicon glyphicon-off"></span> Login</a>
<?php
}
?>
@@ -51,4 +59,3 @@
</div>
</div>
</noscript>
-
diff --git a/static/style.min.css b/static/style.min.css
index dc54b0f..52aa281 100644
--- a/static/style.min.css
+++ b/static/style.min.css
@@ -1 +1 @@
-html{position:relative;min-height:100%}body{margin-bottom:60px}a{color:#3083D6}.navbar-default{border-color:#3083D6;background:#3083D6}.navbar-default .navbar-brand{color:#fff}.navbar-default .navbar-nav>li>a{color:#fff}.footer{border-color:#3083D6;background:#3083D6;color:#fff;position:absolute;bottom:0;width:100%}#copyright-text{color:#fff}.noscript{background-color:red;color:#fff}.table-center{margin:0 auto!important;float:none!important}.disabled{color:#5E5E5E;text-decoration:line-through}
+html{position:relative;min-height:100%}body{margin-bottom:60px}a{color:#3083D6}.navbar-default{border-color:#3083D6;background:#3083D6}.navbar-default .navbar-brand{color:#fff}.navbar-default .navbar-nav>li>a{color:#fff}.footer{border-color:#3083D6;background:#3083D6;color:#fff;position:absolute;bottom:0;width:100%}#copyright-text{color:#fff}.noscript{background-color:#DD5148;color:#fff}.table-center{margin:0 auto!important;float:none!important}.disabled{color:#5E5E5E;text-decoration:line-through}