From 27bc0fe2182afafee830bda8b161f67282f631c8 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 30 Sep 2014 04:39:21 +0200 Subject: fixed bug, added download page, prettified 404 page and general design --- .gitignore | 1 + action.php | 32 +++++++++++++------------------ functions.php | 52 ++++++++++++++++++++++++++++++++++++++++----------- index.php | 9 ++++++--- static/error.webm | Bin 0 -> 915587 bytes static/header.php | 25 ++++++++++++++++--------- static/style.min.css | 2 +- 7 files changed, 78 insertions(+), 43 deletions(-) create mode 100644 static/error.webm 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){ ?> -

Downloade als [plain text] oder als [csv] Datei.

-
token; ?>> @@ -333,9 +333,18 @@ function _add_entry(){ function print_404(){ header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); ?> -

404 - Not Found

+ +

Error 404 - Not Found

+
-

The requested page () wasn't found on this server.

+ +
+
+ +
+
+

Wir haben die Seite '' nicht gefunden!

+ Geh eins zurück!
+

Download

+

Der Download der Adressliste (vom Typ 'text/') sollte automatisch starten.

+
+ +
+

Ansonsten klick hier

+ Download +
+[^\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); // echo " + .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;} Junge Gemeinde Adlershof @@ -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 Binary files /dev/null and b/static/error.webm 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 @@ - Home + Home + - 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} -- cgit v1.2.3