aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorroot2014-10-05 21:15:08 +0200
committerroot2014-10-05 21:15:08 +0200
commit3833ab7e3588b4f5c05f440713f5cdf30b9029ae (patch)
tree283217af2afe917bce80f7f9ad883adfbe077abc
parent80fb01db10054baf2c4c6e70a677e429fe5c34ee (diff)
downloadjungegemeinde-3833ab7e3588b4f5c05f440713f5cdf30b9029ae.tar.gz
Improved caching methods.
-rw-r--r--action.php30
-rw-r--r--functions.php19
-rw-r--r--index.php2
-rw-r--r--static/header.php22
4 files changed, 50 insertions, 23 deletions
diff --git a/action.php b/action.php
index 86129ae..1e70b21 100644
--- a/action.php
+++ b/action.php
@@ -259,23 +259,27 @@ JG Adlershof";
$suffix = ".csv";
}
lredirect("download;type=".$type);
- $res = $db->doQuery("SELECT * FROM " . DBPREFIX . "member;");
- $content .= "\n";
- $count = 1;
- while ($row = $res->fetch_array() ){
+ if ( $c->exists(CACHEPREFIX . "adressliste".$suffix) ){
+ $content = $c->getValue(CACHEPREFIX . "adressliste".$suffix);
+ } else {
+ $res = $db->doQuery("SELECT * FROM " . DBPREFIX . "member;");
+ $content .= "\n";
+ $count = 1;
+ while ($row = $res->fetch_array() ){
- if ( $type == "plain" ){
- $content .= $count . " | " . $row["name"] . " | " . $row["adresse"] . " | " . $row["telefonnummer"] . " | " . $row["handynummer"] . " | " . $row["email"] . " | " . $row["geburtstag"] . "\n";
- } else {
- $content .= $count;
- for ( $i=1;$i<7;$i++){
- $content .= ';' . $row[$i];
+ if ( $type == "plain" ){
+ $content .= $count . " | " . $row["name"] . " | " . $row["adresse"] . " | " . $row["telefonnummer"] . " | " . $row["handynummer"] . " | " . $row["email"] . " | " . $row["geburtstag"] . "\n";
+ } else {
+ $content .= $count;
+ for ( $i=1;$i<7;$i++){
+ $content .= ';' . $row[$i];
+ }
+ $content .= "\n";
}
- $content .= "\n";
+ $count++;
}
- $count++;
+ $c->setKey(CACHEPREFIX . "adressliste".$suffix, $content);
}
-
ob_clean();
header("Content-Type: text/".$type."; Charset=UTF-8");
header("Content-Disposition: attachment; filename=\"JG Adressliste ".date("j.n.Y", time()).$suffix."\"");
diff --git a/functions.php b/functions.php
index 62d5299..9f5ff49 100644
--- a/functions.php
+++ b/functions.php
@@ -162,6 +162,15 @@ function print_list($option = false){
<?php
}
?>
+<?php
+# start caching
+ if ( $c->exists(CACHEPREFIX . "adressliste.html")){
+ echo $c->getValue(CACHEPREFIX . "adressliste.html");
+ header("X-Cache-Table: Hit");
+ return;
+ }
+ ob_start();
+?>
</div>
<div class="row">
<div class="table-responsive">
@@ -188,10 +197,10 @@ function print_list($option = false){
<td>".htmlentities($row['adresse'])."</td>
<td>".htmlentities($row['telefonnummer'])."</td>
<td>".htmlentities($row['handynummer'])."</td>
- <td>".htmlentities($row['email'])."</td>
+ <td><a href='mailto:".htmlentities($row['email'])."' title='Sende ".htmlentities($row['name'])." eine E-Mail'>".htmlentities($row['email'])."</a></td>
<td>".htmlentities($row['geburtstag'])."</td>
<!--td><a href='/?page=update&id=".htmlentities($row['member_id'])."' onclick=\"window.location='/?page=update&id=".htmlentities($row['member_id'])."'\"><input type='checkbox' name='change' value='true'></a></td-->
- <td><a href='/?page=update&id=".htmlentities($row['member_id'])."'><span class='glyphicon glyphicon-pencil'></span></a></td>
+ <td><a href='/?page=update&id=".htmlentities($row['member_id'])."' title='Ändere den Eintrag'><span class='glyphicon glyphicon-pencil'></span></a></td>
</tr>";
$count++;
}
@@ -204,8 +213,10 @@ function print_list($option = false){
</form>
</div>
</div>
-
<?php
+ $table = ob_get_contents();
+ $c->setKey(CACHEPREFIX . "adressliste.html", $table);
+ ob_end_flush();
}
function print_update_list($id){
@@ -617,7 +628,7 @@ function print_download(){
lredirect("download;type=".$type);
header($_SERVER["SERVER_PROTOCOL"] . " 302 Moved");
- header("Refresh: 2; ".DOMAIN."/?page=action&task=download&type=".$type);
+ header("Refresh: 0; ".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>
diff --git a/index.php b/index.php
index 52bf162..af2a619 100644
--- a/index.php
+++ b/index.php
@@ -11,7 +11,7 @@ if ( ! isset($cache) )
$c = new cache(REDIS_CONNECT, REDIS_DB);
if ( isset($_SESSION["loggedin"]) && $_SESSION["loggedin"]){
- $a = "1_";
+ $a = $_SESSION["userid"]."_";
} else {
$a = "0_";
}
diff --git a/static/header.php b/static/header.php
index ff51e71..f6ecfd9 100644
--- a/static/header.php
+++ b/static/header.php
@@ -15,8 +15,8 @@
<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>
+ <li><a href="/?page=download&task=download&type=plain" title="Download: text/plain"><span class="glyphicon glyphicon-download"></span> Download als Text</a></li>
+ <li><a href="/?page=download&task=download&type=csv" title="Download: text/csv"><span class="glyphicon glyphicon-arrow-down"></span> Download als CSV</a></li>
</ul>
</li>
<li>
@@ -31,20 +31,32 @@
<a href="#" title="Much fancy, many amazing, wow" onclick="loadFancy();"><span class="glyphicon glyphicon-flag"></span> Fancy Mode</a>
</li>
<li class="dropdown">
- <a href="/?page=account" title="Manage deinen Account"><span class="glyphicon glyphicon-user"></span> Mitglied<span class="caret"></span></a>
+ <?php
+ if ( $user->isLoggedIn() ) {
+ $_name = $user->username;
+ $_title = "Ändere dein Profil";
+ } else {
+ $_name = "Mitglied";
+ $_title = "Einloggen, registrieren, Profil";
+ }
+ ?>
+ <a href="/?page=account" title="<?php echo $_title; ?>"><span class="glyphicon glyphicon-user"></span> <?php echo $_name; ?> <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li>
<?php
if ( $user->isLoggedIn() ) {
?>
+ <a href="/?page=account" title="Ändere dein Passwort"><span class="glyphicon glyphicon-user"></span> Profil</a>
+ </li>
+ <li>
<a href="/?page=logout" title="Beende die Session"><span class="glyphicon glyphicon-off"></span> Logout</a>
<?php
} else {
?>
- <a href="/?page=login&goto=index" title="Login"><span class="glyphicon glyphicon-off"></span> Login</a>
+ <a href="/?page=register&goto=index" title="Registriere dich für unbeschränkten Zugang"><span class="glyphicon glyphicon-share-alt"></span> Register</a>
</li>
<li>
- <a href="/?page=register&goto=index" title="Registriere dich für unbeschränkten Zugang"><span class="glyphicon glyphicon-user"></span> Register</a>
+ <a href="/?page=login&goto=index" title="Login"><span class="glyphicon glyphicon-off"></span> Login</a>
<?php
}
?>