changeset 122:7d9e8c82e744

Work on votekey printing.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 22 Oct 2013 14:40:42 +0300
parents 73608dc4123f
children 5837b9333964
files print.php
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/print.php	Tue Oct 22 14:22:50 2013 +0300
+++ b/print.php	Tue Oct 22 14:40:42 2013 +0300
@@ -18,6 +18,12 @@
   stSessionEnd(SESS_ADMIN);
 
   stSetStatus(404, "Not Found");
+  
+  cmPrintPageHeader("Error");
+  echo "<h1>Permission denied</h1>\n".
+  "<p>You need to be logged in as administrator to access this data.</p>\n".
+  "<p><a href=\"admin\">Click here for login form</a></p>\n";
+  cmPrintPageFooter();
   exit;
 }
 
@@ -70,7 +76,7 @@
     if (($res = stExecSQL($sql)) !== FALSE)
     {
       cmPrintPageHeader("Votekeys");
-      $keyLen = stGetSetting("");
+      $keyLen = stGetSetting("userKeyLength");
       echo "<table class=\"votekeys\">\n";
       $index = 0;
       foreach ($res as $item)
@@ -78,8 +84,11 @@
         if ($index == 0)
           echo "<tr>\n";
         
-        printf("<td><span class=\"keyid\">%03d</span> : <span class=\"keycode\">%-".$keyLen."s</span></td>\n",
-          $item["id"], $item["key"]);
+        // This funny code is to ensure that the cells are of uniform width
+        printf("<td><span class=\"keyid\">%03d</span>&nbsp;:&nbsp;".
+          "<span class=\"keycode\">%s</span></td>\n",
+          $item["id"],
+          str_repeat("&nbsp;", $keyLen - strlen($item["key"])).$item["key"]);
         
         if ($index++ >= 5)
         {